Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/fortran/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Compilation 使用nagfor预处理器的用户定义错误_Compilation_Fortran_Preprocessor_Nag Fortran - Fatal编程技术网

Compilation 使用nagfor预处理器的用户定义错误

Compilation 使用nagfor预处理器的用户定义错误,compilation,fortran,preprocessor,nag-fortran,Compilation,Fortran,Preprocessor,Nag Fortran,如果使用了不受支持的fortran编译器,我将尝试中止编译。nagfor预处理器定义了宏nagfor,因此我编写了以下测试程序: program foo implicit none #ifdef NAGFOR PRINT *, "Hello from nagfor" #else #error "Compiler not supported" #endif end program foo 当我使用gfortran或ifort编译时,我会收到预期的错误消息 $ gfortran fo

如果使用了不受支持的fortran编译器,我将尝试中止编译。nagfor预处理器定义了宏
nagfor
,因此我编写了以下测试程序:

program foo

  implicit none

#ifdef NAGFOR
  PRINT *, "Hello from nagfor"
#else
#error "Compiler not supported"
#endif

end program foo
当我使用gfortran或ifort编译时,我会收到预期的错误消息

$ gfortran foo.F90
foo.F90:8:2: error: #error "Compiler not supported"

$ ifort foo.F90
foo.F90(8): #error:  "Compiler not supported"
但是nagfor给出了一个不同的错误

$ nagfor foo.F90
NAG Fortran Compiler Release 5.3.1(907)
"foo.F90", line 8: error: unknown fpp directive.

我找不到任何关于如何在nagfor中创建错误的内容,因此可能不存在
#error
。在这种情况下,是否有其他方法可以获得相同的效果?

我使用NAG编译器。fpp在操作(和功能)方面是非常轻量级的。它起源于太阳;我们正在使用一个基于netlib的版本

fpp手册()没有记录您发现的受支持的
#错误

正如弗朗西斯卡勒斯所建议的那样,实现你想要的最好的方法就是按照你的想法去做

program foo

  implicit none

#ifdef NAGFOR
  PRINT *, "Hello from nagfor"
#else
  error "Compiler not supported"
#endif

end program foo

fpp
似乎不知道
#error
指令。看看手册,你还有什么其他的可能性。一种可能的方法是放一些明显的垃圾,编译器自己会致命地拒绝。不理想(所以答案质量不理想),但除非您有大量的预处理(因此希望提前中止),否则可能会有相同的最终结果。[但是,致命流产也不是便携式的。]