Source Format

Source files written in modern Fortran versions (2003+) may have the corresponding file-endings (.f03 for 2003, .f08 for 2008) because most Fortran compilers then assume the free source format as a default. Files with the endings .f and .for are associated with Fortran < 90 (fixed source format), which won’t compile if the code is in free source format. This behaviour can be changed with a compiler flag to force free format.

Force free source format with Flang, even if the file-ending is .f:

$ flang -Mfreeform -o foo foo.f

With GNU Fortran:

$ gfortran7 -ffree-form -o foo foo.f

If you like to build your Fortran projects with CMake, the file ending must be set to .f90 or .f95.