For decades, Fortran code was written in fixed format, with reserved areas for statement labels and indentification fields, caused by the fixed form of Hollerith punch cards. That means, the first six characters of each line are reserved for line numbers, comment identifiers, continuation characters, and so on. Lines were limited to 72 characters. With Fortran 90, free format was introduced, which abolished indention patterns and improved readability.
Modern Fortran compilers provide command-line flags in order to distinguish
between the old fixed format and the new free format. Use
-ffree-form to force free format with GNU Fortran:
$ gfortran7 -ffree-form -o foo foo.f
For Flang, use
$ flang -Mfreeform -o foo foo.f
Historically, the file endings of Fortran source files are
.for. These are associated with Fortran < 90, and therefore
with fixed format. Even modern compilers assume fixed format for these endings,
unless a free format command-line flag is used.
For this reason, file endings should be used that represent modern Fortran
versions. You can either set endings that correspond with the actual language
.f03 for 2003,
.f08 for 2008,
.f18 for 2018) or simply use
.f90 as a default to
indicate modern Fortran. The latter is recommended.
Be aware that you must set the file ending to either
.f95 if you like to build your Fortran projects with
|< Editors and IDEs||[Index]||Libraries >|