Fortran Compilers

There are several free compilers available or up-coming for Unix-like operating systems that support modern Fortran language standards:

Flang
Front-end for LLVM, with limited support of the Fortran 2003 and 2008 language standards. Based on source code of PGI.
Flang/F18
LLVM front-end for Fortran 2018 in development, contributed by NVIDIA.
GNU Fortran (gfortran)
Modern Fortran compiler, part of the GNU Compiler Collection and successor of g77.
Intel oneAPI Fortran
Intel’s Fortran, C, C++, and Python compilers for Windows, Linux, and macOS (freeware).
IBM XL Fortran
Proprietary no-charge full-function Community Edition of IBM’s Fortran compiler for Linux.
LFortran
A Fortran 2018 REPL-like front-end for LLVM, in pre-alpha stage.

GNU Fortran is a fork of G95, a discontinued Fortran 95 compiler that has been removed from the FreeBSD ports collection due to deprecated dependencies that are required for building. Flang in an older front-end for LLVM, missing most features of Fortran 2008 and 2018.

Fortran compilers are available for many platforms. Most of them target Microsoft Windows and/or Linux, but do not produce native binaries for FreeBSD and other Unix systems, like Intel Fortran, PGI Community Edition, or the abandoned Open64.

Some historic compilers for FORTRAN 77 are open-source as well:

Proprietary compilers targeting CP/M, DOS (fig. 1), and Microsoft Windows can be downloaded from various web sites dedicated to historic software, like old-dos.ru or winworldpc.com.

Microsoft FORTRAN Compiler for DOS
Fig. 1: Box of Microsoft FORTRAN Compiler for DOS

Online Compilers

There are services that provide online access to Fortran compilers, to build and run Fortran programs through the web browser, like:

You may want to try some of the examples in the next sections by using an online compiler.

Modern Fortran on FreeBSD

Using FreeBSD as a programming environment for modern Fortran currently limits the list of available compilers to GNU Fortran and Flang, as Flang/F18 is still in early stage and LFortran is just a prototype. All four can be installed from ports or by using the FreeBSD package manager. The Intel Fortran compiler for FreeBSD was removed from the ports collection in 2010.

References