Install Gfortran 8.1 on Linux/Mac/Windows

less than 1 minute read

Gfortran 8.1 Fortran 2018 features includes excellent coarray support.

Caveat: Newer versions of Gfortran my 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

Linux

GCC/Gfortran 8 for Ubuntu 18.04 is available from the Ubuntu-test PPA:

  1. add Ubuntu-test PPA
    add-apt-repository ppa:ubuntu-toolchain-r/test
    apt update
    
  2. install the most recent Gfortran (similarly for gcc-8, g++-8)
    apt install gfortran-8
    
  3. Switch between compiler versions with update-alternatives.

A popular alternative is Linuxbrew, which is a fork of Mac homebrew.

Mac

Install the latest gcc, g++ and gfortran on Mac OS via homebrew:

brew install gcc

Windows

Install the latest gcc, g++ and gfortran on Windows

Notes

  • Ubuntu 16.04 can install up to GCC/Gfortran 7 via the PPA.
  • Ubuntu 14.04 can install up to GCC/Gfortran 6 via the PPA.

  • If you’re having errors getting any version of gfortran installed, try:
    apt-add-repository universe
    

Leave a Comment