Free-form, fixed-form and file extensions for fortran

http://gcc.gnu.org/wiki/GFortranGettingStarted

Free-form, fixed-form and file extensions

By default, gfortran is aware of a few file extensions, and its action depends on the extension of the file you ask it to compile. Examples:

  • if the file is named code.f gfortran supposes it is fixed-form source, with no preprocessing needed.
  • if the file is named code.f90 gfortran supposes it is free-form source, with no preprocessing needed.
  • if the file is named code.F gfortran supposes it is fixed-form source and performs preprocessing.
  • if the file is named code.F90 gfortran supposes it is free-form source and preprocess it.

There are other extensions recognized, such as: .f95 is the same as .f90 and .F95 is the same as .F90

Of course, you can override gfortran’s default, with options -ffree-form and -ffixed-form (many gfortran options are named -f''=option-name ‘. For example, if you have a free-form code named bessel.f, you can compile it with

 

gfortran -ffree-form bessel.f -o bessel.exe