Compiling Fortran

Mixing of Fortran types occurs, and often results in problems when mixing free-form Fortran with older styles of Fortran, and when using different compilers.

As pointed out at Geek Tricks.

In Fortran 90/95, a “&” at the end of a line, or in the front of a line, is treated as line continuation sign. But in Fortran 77, it has to be a character at the sixth column. In the code I get, most “&”‘s comply to the Fortran 77 format, but some are not. So I move all “&”‘s to the sixth column, and now the code compile with gfortran.

If you want to replace lots ampersands from the ‘first column’ to the ‘sixth column’ on a lot of lines you could use ‘sed’ string editor to do that.

sed 's/^&/ &/g' input.f > output.f

You also need to check for lines which are too long in your input.

Many errors can be suppressed for now, with command such as gfortran -std=legacy output.f -o justwork