Compile dodgy Fortran 77 code in a modern compiler
fortran, linux, ubuntu
Solution
Pass the argument `-std=legacy` to gfortran. Features removed in F95, like real loop and array indices, should compile (perhaps with a warning) in legacy mode.
Problem
I am trying to compile a piece of software written in Fortran 77. I should point out that I don't know much at all about Fortran, and would really rather not start modifying the code for this software - particularly as I'm not sure what the licensing of the software is, and I don't know if I would be able to redistribute my modified version. The code compiles fine on OS X and Windows using the g77 compiler that is (fairly easily) available for these systems. However, I cannot get it to work on my Ubuntu distribution, as I can't seem to get hold of g77 for Ubuntu anymore, and if I try and install an old version of it, it seems to muck up my entire GCC installation. I have tried compiling the code with both gfortran and g95, but it doesn't work with either as: - The code uses real variables as loop indices (yes, I know, bad idea). g95 supports this with the `-freal-loops` option, but gfortran doesn't. - The code uses real variables to index into arrays, which gfortran will support (with a warning), but g95 won't support. Can anyone suggest a way to compile this code with those two 'dodgy' features using a modern and easily-available compiler such as g95 or gfortran?