Fortran Compilers

There are two free/open-source compilers for Unix-like operating systems that support modern Fortran versions:

GNU Fortran is a fork of G95, a discontinued Fortran 95 compiler that has been removed from the FreeBSD ports collection some time ago due to deprecated dependencies that are required for building. Flang is still in development and therefore less mature than GNU Fortran. For instance, there is no Unicode support yet in Flang 5.

There are even more free Fortran compilers available, like Intel Fortran, PGI Community Edition, or the abandoned Open64. Most of them have Linux support, but won’t produce native binaries for FreeBSD or other Unix systems. Please see the Fortran Wiki and Wikipedia for an overview.

Some historic compilers for ancient Fortran 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 or

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

On-line Compilers

Fortran code can be compiled and executed in your web browser by using on-line services, like:

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

Modern Fortran on FreeBSD

Using FreeBSD as a programming environment for modern Fortran limits the list of available compilers to GNU Fortran and Flang. Both can be installed from Ports or by using the FreeBSD package manager.

Install GNU Fortran with:

# pkg install lang/gcc8
# gfortran8 --version
GNU Fortran (FreeBSD Ports Collection) 8.2.1 20190104
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO

Install Flang with:

# pkg install devel/flang
# flang --version
clang version 6.0.1
Target: x86_64-portbld-freebsd12.0
Thread model: posix
InstalledDir: /usr/local/bin

The Intel Fortran compiler for FreeBSD has been removed in 2010.