Install Gfortran 8.2 on Linux

Related: Install latest gfortran on Windows


Gfortran 8.2 Fortran 2018 features includes excellent coarray support.

Caveat: Newer versions of Gfortran may require recompiling other libraries linked with Fortran compiler, such as HDF5. Trivially switch between Gfortran compiler versions (or any other program versions) with update-alternatives.

Install

GCC/Gfortran 8 for Ubuntu 18.04 / 16.04 / 14.04 is available from the Ubuntu-test PPA.

Add Ubuntu-test PPA by:

add-apt-repository ppa:ubuntu-toolchain-r/test
apt update

Then install the most recent Gfortran (similarly for gcc-8, g++-8)

apt install gfortran-8

Switch between compiler versions with update-alternatives.

A popular alternative is Linuxbrew, which is officially part of Mac homebrew.

Notes

  • If you’re having errors getting any version of gfortran installed, try:
add-apt-repository universe
  • MacOS: install gfortran on Mac OS via homebrew:
brew install gcc