我正在修改用 Fortran 77 编写的模型中的代码,但我遇到了一件奇怪的事情。在某些文件中,一行的第一列中有一个标签“d”,如下例所示:
d real*8 co2rootfix,co2rootloss,co2shootfix
d character komma*1
d open(unit=87,file='crop_CO2.csv',status='unknown')
d write(87,*) 'date,co2rootfix,co2rootloss,co2shootfix'
d open(unit=88,file='crop_dm.csv',status='unknown')
d write(88,*) 'date,wrtpot,wrt,wstpot,wst,rdpot,rd,laipot,lai,
d &gwrt,gwst,drrt,drlv,drst'
奇怪的是,它被Intel的ifort编译器成功编译了。但是,gfortran 在逻辑上返回以下错误:
Error: Non-numeric character in statement label at (1)
我想知道:
最佳答案
ifort 文档中有选项 -d-lines
和 -nod-lines
:
This option compiles debug statements. It specifies that lines in fixed-format files that contain a D in column 1 (debug statements) should be treated as source code.
所以,如果代码是在没有
-d-lines
的情况下编译的(或使用 -nod-lines
这是默认值)然后那些带有 d
的行在第一列中被视为注释并被忽略。在 gfortran 中
-fd-lines-as-code
和 -fd-lines-as-comments
有同样的效果。这里的区别在于,作为扩展,ifort 接受代码而不管标志(如上,它具有隐式 -nod-lines
)。 gfortran 需要指定其中一个标志来接受代码。
关于fortran - 第一列中的 "d"标签,Fortran 77,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29771879/