GFortran is the name of the GNU Fortran project. The main wiki page offers many helpful links about GFortran, as well as Fortran in general. In this guide, the installation process for GFortran on Windows, Linux, macOS and OpenBSD is presented in a beginner-friendly format based on the information from GFortranBinaries.
Three sources provide quick and easy way to install GFortran compiler on Windows:
In all the above choices, the process is straightforward—just download the installer and follow the installation wizard.
For those familiar with a unix-like development environment, several emulation options are available on Windows each of which provide packages for gfortran:
All of the above approaches provide access to common shells such as bash and development tools including GNU coreutils, Make, CMake, autotools, git, grep, sed, awk, ssh, etc.
We recommend the WSL environment for those looking for a Unix-like development environment on Windows.
Check whether you have gfortran already installed
If nothing is returned then gfortran is not installed. To install gfortran type:
sudo apt-get install gfortran
to check what version was installed type:
You can install multiple versions up to version 9 by typing the version number immediately after “gfortran”, e.g.:
sudo apt-get install gfortran-7
To install the latest version 10 you need first to add / update the following repository and then install:
sudo add-apt-repository ppa:ubuntu-toolchain-r/test sudo apt update sudo apt install gfortran-10
Finally, you can switch between different versions or set the default one with the update-alternatives (see manpage). There are many online tutorials on how to use this feature. A well structured one using as an example C and C++ can be found here, you can apply the same logic by replacing either
sudo yum install gcc-gfortran
Since Fedora 22,
dnf is the default package manager for Fedora:
sudo dnf install gcc-gfortran
sudo pacman -S gcc-fortran
If you have Xcode installed, open a terminal window and type:
Go to fxcoudert/gfortran-for-macOS to directly install binaries.
brew install gcc
GNU-gcc Package link
Search for available gcc versions:
port search gcc
Install a gcc version:
sudo port install gcc10
On OpenBSD, the GFortran executable is named
egfortran. To test it, type:
OpenCoarrays is an open-source software project that produces an application binary interface (ABI) used by the GNU Compiler Collection (GCC) Fortran front-end to build executable programs that leverage the parallel programming features of Fortran 2018. Since OpenCoarrays is not a separate compiler, we include it here, under gfortran.
While with gfortran you can compile perfectly valid code using coarrays, the generated binaries will only run in a single image (image is a Fortran term for a parallel process), that is, in serial mode. OpenCoarrays allows running code in parallel on shared- and distributed-memory machines, similar to MPI:
cafrun -n <number_of_images> <executable_name>
The process of installation is provided in a clear and comprehensive manner on the official site.
We emphasize that native installation on Windows is not possible. It is only possible through WSL.