Lots of friends and colleagues have been happily using g77 as their fortran compiler for years. Now, however, you can’t find an up-to-date g77 compiler very easily and we’re all supposed to start using gfortran. Here’s some tips for getting your old .f files to compile:
- Use the following command-line arguments when invoking the gfortran compiler to get better compatibility:
gfortran -ffixed-line-length-none -fdefault-real-8 -std=legacy -fd-lines-as-comments
- Two commonly used argument names for the OPEN() procedure have changed. Instead of specifying NAME=FNAME, use FILE=FNAME and instead of using TYPE=, use STATUS=.
- When linking with external libraries, you may find “symbol not found” errors, even though you know those symbols are defined in the library. This likely has to do with how many underscores (_) are in the symbol name. gfortran has some switches than can help: -fsecond-underscore, -fno-second-underscore, depending on what the error reports and what the symbols are called in the library (use the ‘nm’ or ‘ldd’ command on the library to show it’s contents).