将预处理指令引入 Cray 编译器的 Fortran 代码的正确方法

The correct way to introduce preprocessing directives into a Fortran code for the Cray compiler

我正在尝试使用 Cray 编译器编译 Fortran 代码。我在代码中有一个标准的预处理 ifdef 块:

#ifdef DEBUG
!  print extra info
#endif

克雷一点也不喜欢这样。它告诉我

#ifdef DEBUG
^            
ftn-100 crayftn: ERROR BALANCE_DATA, File = balance_data.f90, Line = 9, Column = 1 
  This statement must begin with a label, a keyword, or an identifier.
#endif
^      
ftn-100 crayftn: ERROR BALANCE_DATA, File = balance_data.f90, Line = 11, Column = 1 
  This statement must begin with a label, a keyword, or an identifier.

有谁知道如何让 Cray 编译器满意? (顺便说一句,这段代码可以用 intel 和 gcc 编译得很好。)

这些宏不是标准 Fortran 的一部分。必须以某种方式告诉编译器执行预处理器(cppfpp 或自定义的东西,它们 do 不同)。

对于 Cray,您应该使用 -e Z 或在文件扩展名中使用大写 F。始终查阅任何新编译器的手册。但是,crayftn 的联机帮助页非常不完整,它确实提到了该选项,但只是间接提及。必须进入完整的文档,例如在 RussF 提供的 link 中。