嗨,这是 Chapman 为科学家和工程师编写的 Fortran 95-2003 (3ed) 一书第 195 页中给出的代码
WRITE (*,100) index, time, depth, amplitude, phase
100 FORMAT('1',t20,'results for the test number ',i3,///,&
1x,'time = ',f7.0/, &
1x,'depth = ',f7.1,' meters',/, &
1x,'amplitude = ',f8.2/ &,
1x,'phase = ',f7.1)
为了运行它,我完成了其余的语句
program test
implicit none
INTEGER :: index = 10
real:: time=300.0,depth=330.0,amplitude=850.65,phase=30.0
WRITE (*,100) index, time, depth, amplitude, phase
100 FORMAT('1',t20,'results for the test number ',i3,///,&
1x,'time = ',f7.0/, &
1x,'depth = ',f7.1,' meters',/, &
1x,'amplitude = ',f8.2/ &,
1x,'phase = ',f7.1)
end program test
当我用 gfortran 编译它时,我得到以下错误..
test.f90:12.31:
1x,'amplitude = ',f8.2/ &,
1
Error: Unexpected element '&' in format string at (1)
test.f90:13.8:
1x,'phase = ',f7.1)
1
Error: Non-numeric character in statement label at (1)
test.f90:13.9:
1x,'phase = ',f7.1)
1
Error: Invalid character in name at (1)
test.f90:7.12:
WRITE (*,100) index, time, depth, amplitude, phase
1
Error: FORMAT label 100 at (1) not defined
这里发生了什么事 ?我在stackoverflow上看到了另一个线程,问题是关于fortran中的控制字符。查普曼在他的书中讨论了它,但没有提到在 Fortran 2003 中删除了控制字符的功能。所以我想知道这是否是 gfortran 无法识别的类似旧东西?