fortrangfortranfortran77

Compiling an old fortran code in gfortran of ubuntu 18.04


I am new to fortran and I want to compile a code which was written in 1988, http://www.seg.ethz.ch/software/velest.html. I used this command :

f77 -o velest velest.f

and this error was displayed

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]

Then I found the place of the first error inside the code and removed "," of "f6.1". After compiling again this time, these errors appeared :

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

For solving that I followed the instruction of this websitehttp://nota.tw/2011/04/21/adjust-velest-in-ubuntu/ but after compiling this time, this error appeared :

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

I would be grateful if someone could answer to my question.


Solution

  • The format string is invalid. There is a comma appearing in f6.1,). Thus, gfortran is expecting another edit descriptor not a right parenthesis. If you delete that erroneous comma, the code compiles. Note, this could be a bug in gfortran so you may want to interact with gfortran developers.