One tool I picked up from Clive Page’s Page on Fortran was ftnchek. This program is a static analyser. It enables checking or Fortran77 for semantic errors (rather than syntax errors), which usually aren’t reported by compilers. Once a Program compiles you can check for syntax errors by running
I found most of my errors are of this type.
189 XTO400=XTO400+0.0001 ^ Warning near line 189 col 26 file mucg83.f: promotion may not give desired precision: dble XTO400 + real const 0.0001
What I should have written is
Which means the fortran compiler knows the number involved is meant to be used in double precision. Since there is really no cost penalty to using ‘double’ precision rather than ‘single’ precision used with ‘Real’ numbers – and this might change depending on compiler.
I found the static analyser to be very useful for finding unused parts of a program, this might be useful to find errors, if you think those parts of the code are meant to do something! Or in cleaning up the code after making changes.
ftnchek can be downloaded from the ftnchek developers website, or installed in debian from the program repositories using apt-get, dselect or aptitude, etc.
ftnchek --version FTNCHEK Version 3.3 November 2004 Patch Level 1