在 ubuntu 18.04 的 gfortran 中编译旧的 fortran 代码

Compiling an old fortran code in gfortran of ubuntu 18.04

我是 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

如果有人能回答我的问题,我将不胜感激。

格式字符串无效。 f6.1,)中出现了一个逗号。因此,gfortran 需要另一个编辑描述符而不是右括号。如果删除那个错误的逗号,代码就会编译。请注意,这可能是 gfortran 中的错误,因此您可能希望与 gfortran 开发人员进行交互。