Skip to content
Programming language · Format description concepts

Fortran source files: extensions, fixed and free source forms

Published Formatory editorial team

Fortran is a compiled, general-purpose programming language for numerical and scientific computing whose programs are stored as plain-text source files.

Format registries use the language as a value that ties a source-code format to the programming language its text is written in.

A deck of punched cards and a 1960s line printer still shape how many Fortran files look today. Fortran (sometimes mistyped as Fortan, a spelling that has crept into a few metadata vocabularies) was developed at IBM by a team led by John Backus, with the first compiler shipped in 1957. It remains in daily use for weather and climate models, computational physics and linear-algebra libraries, which is why preservation repositories keep receiving Fortran code alongside research data.

In a format registry, Fortran appears as a programming language value. A record for “Fortran 77 source” or “Fortran 90 source” points to it so that a search for all source-code formats in a given language returns them together, the same way C++ groups .cpp and .hpp files.

Fixed form and free form

The most important technical property of a Fortran file is its source form, and the two forms differ more than a casual reader expects.

Fixed form inherits the 80-column punched card. In FORTRAN 77, a C or * in column 1 marks a comment, columns 1–5 hold an optional statement label, any non-blank character in column 6 marks a continuation line, and statements live in columns 7–72. Anything past column 72 is ignored, a rule that once left room for card sequence numbers and still silently truncates long lines.

Free form arrived with Fortran 90. Statements can start anywhere, lines may run to 132 characters, ! begins a comment and a trailing & continues a statement onto the next line.

The two forms are incompatible at the text level: a free-form file fed to a compiler in fixed-form mode fails, and the reverse often does too. A registry that describes Fortran source therefore benefits from recording the form as a separate property next to the text form and character encoding.

Extensions and what they actually signal

Extension Usual meaning
.f, .for, .ftn fixed form
.f90, .f95, .f03, .f08 free form
.F, .F90 (uppercase) same, preprocessed first (GNU Fortran convention)
.mod compiler-generated module file, not source

The number in .f90 or .f95 names the standard that introduced the habit, not the revision the code uses. The language itself is standardized as ISO/IEC 1539-1, with revisions known as Fortran 95, 2003, 2008, 2018 and 2023. A file called solver.f90 can legally contain coarrays from Fortran 2008.

Identification in practice

Fortran source is plain text with no signature bytes, so tools such as DROID or Siegfried largely rely on the extension. Content-based checks look for keywords (PROGRAM, SUBROUTINE, MODULE, END DO), the column-6 continuation pattern or ! comments. The media type is not registered with IANA; text/x-fortran is the label most systems use informally.

When the extension is missing (a frequent case with older code from tape or floppy transfers), the fixed-form layout is often the most reliable clue: a run of lines starting with six spaces and uppercase keywords is hard to confuse with anything else. Mixed-case keywords and ! comments point to free form. For the wider method, see the file format identification guide and the other entries in the vocabulary index.

Preserving Fortran code

A source file alone rarely rebuilds a program. Fortran projects depend on include files, makefiles, compiler flags and sometimes vendor extensions (DEC and Cray dialects are the classic examples). Collecting the build scripts and noting the compiler and version used turns a folder of .f files into something a later reader can compile. The same holds for data: many Fortran programs write unformatted sequential files whose record markers and byte order depend on the compiler and platform, so the code that wrote them is often the only documentation of their structure.

Example in RDF

<format rdf:about="https://example.org/formats/fortran-90-source">
  <name>Fortran 90 source code</name>
  <programmingLanguage>Fortran</programmingLanguage>
  <textForm>free source form</textForm>
  <extension>f90</extension>
  <internetMediaType>text/x-fortran</internetMediaType>
</format>

Questions about Fortran

Is it Fortran or Fortan?

The language is Fortran, from 'Formula Translation'. 'Fortan' is a common typo, and it even appears as a label in some older format vocabularies. Early standards wrote the name in capitals (FORTRAN 77); since Fortran 90 the standard uses mixed case.

What file extension does a Fortran file use?

Fixed-form files usually end in .f, .for or .ftn. Free-form files usually end in .f90, .f95, .f03 or .f08. With GNU Fortran, an uppercase extension such as .F or .F90 tells the compiler to run the C preprocessor first.

Does .f95 mean the file needs a Fortran 95 compiler?

Not necessarily. Compilers read the suffix mainly as a hint about source form, not about the language revision. A .f90 file can use Fortran 2008 features, and most current compilers accept any of the free-form suffixes.

Can a tool identify Fortran source code without the extension?

Only by heuristics. Fortran source has no magic number, so identification falls back on keywords such as PROGRAM, SUBROUTINE or MODULE, column layout and comment markers. The Unix file utility tries this and is often, but not always, right.

Are Fortran .mod files part of the source format?

No. A .mod file is written by the compiler when it compiles a module. Its layout is specific to one compiler and often to one compiler version, so it is a build artifact and does not travel between toolchains.

More from Format description concepts

All 16 in this group