【发布时间】:2019-01-12 17:07:30
【问题描述】:
我是 fortran 新手,我想编译一段 1988 年编写的代码,http://www.seg.ethz.ch/software/velest.html。 我使用了这个命令:
f77 -o velest velest.f
并显示此错误
velest.f:10165:45:
write(ifil,'(''North rotate= '',f6.1,)') rotate
1
Error: Unexpected element ‘)’ in format string at (1)
velest.f:4384:25:
call RAYPATH(1,1,1,1.,1.,1.,1.,nl,thk,h,v,vsq,
1
Warning: Rank mismatch in argument ‘x’ at (1) (rank-1 and scalar) [-Wargument-mismatch]
然后我在代码中找到了第一个错误的位置,并删除了“f6.1”的“,”。这次再次编译后,出现了这些错误:
velest.f:4384:25:
call RAYPATH(1,1,1,1.,1.,1.,1.,nl,thk,h,v,vsq,
1
Warning: Rank mismatch in argument ‘x’ at (1) (rank-1 and scalar) `[-Wargument-mismatch]`
/tmp/ccQk4MAf.o: In function `datetime_':
velest.f:(.text+0x310c): undefined reference to `time_'
velest.f:(.text+0x3120): undefined reference to `ctime_'
velest.f:(.text+0x3149): undefined reference to `sprintf_'
/tmp/ccQk4MAf.o: In function `cputimer_':
velest.f:(.text+0x3abf): undefined reference to `clock_'
collect2: error: ld returned 1 exit status
为了解决我按照本网站的指示http://nota.tw/2011/04/21/adjust-velest-in-ubuntu/ 但是这次编译后出现了这个错误:
velest.f:4384:25:
call RAYPATH(1,1,1,1.,1.,1.,1.,nl,thk,h,v,vsq,
1
Warning: Rank mismatch in argument ‘x’ at (1) (rank-1 and scalar) [-Wargument-mismatch]
/tmp/cc7WrZmF.o: In function `datetime_':
velest.f:(.text+0x3119): undefined reference to `ctime_'
collect2: error: ld returned 1 exit status
如果有人能回答我的问题,我将不胜感激。
【问题讨论】:
-
你提到了gfortran,但使用的是fort77,后者在我看来是一个从Fortran到C的转换脚本,然后运行gcc。使用时会发生什么:
gfortran -o velest velest.f? -
欢迎您,您不能只显示错误消息,我们还需要查看代码的相关部分(minimal reproducible example)。对于最后的错误,您必须向我们展示调用 CTIME 的代码部分。它不是标准的 Fortran 过程,并且在不同的编译器之间不兼容。 Gfortran 使用这个定义gcc.gnu.org/onlinedocs/gfortran/CTIME.html
-
代码的外部链接不够。我们需要在您的调整后查看您的代码!很可能只是忘记更改使用 CTIME 的行。
-
在这一行“RAYPATH(1,1,1, 1.,1.,1.,1., ...)”中,1.0... 的虚拟(正式)参数是四个数组(x,y,z,vel),我认为 gfortran 正在抱怨。为了让它工作,我想我们需要更多地修改代码(比如使用临时数组 x、y、z、vel)。
标签: fortran gfortran fortran77