Major changes in Gfortran by version

Gfortran and Intel Fortran are the most advanced modern Fortran compilers, particularly with regard to Fortran 2008 and Fortran 2018 standards. One of the most useful Fortran 2018 enhancements is error stop within pure procedures. Previous to the official Fortran 2018 standard, Gfortran ≥ 7 and Intel Fortran allowed error stop in pure procedures with a harmless warning.

minimum Gfortran version to support

We currently recommend Gfortran 6 as the minimum version to support, as a good tradeoff between ease of install on older operating systems and useful Fortran standard features. Gfortran < 5 is lacking too many features of “modern Fortran” that is, Fortran 2003/2008/2018 features to be useful for current development.

Intel Fortran

  • Intel Fortran 18 includes “complete” Fortran 2008 support.
  • Intel Fortran 19 improves upon Fortran 2018 support.

Gfortran major changes

Gfortran 9

Under development.

FIXME: will random_init that has been submitted be added?

Gfortran 8.1

(Gfortran 8.2 and 8.3 did not introduce new Fortran features)

  • Optimization: automatic nested loop exchange with do concurrent
  • Checks: Actual argument array with too few elements for dummy argument now errors
  • Polymorphism: initial support for parameterized derived types (simply define kind at initialization)
  • Coarray: Initial support for teams

Gfortran 8

  • std=f2008ts deprecated, do not use as it errors on compiling error stop for Gfortran < 8.
  • std=f2018 added

Gfortran 7

  • Polymorphism: derived type IO select type etc. fully supported from Fortran 2003.
  • Fortran 2018: Non-constant stop and error stop codes (even Intel 2019 doesn’t support this!)
  • Compatibility: -fdec- options help compiling very old non-standard code that was previously only compatible with Intel Fortran (of DEC heritage).

Gfortran 6

  • Fortran 2008: submodule support, useful for large projects to save compilation time and allow powerful use scenarios
  • Fortran 2003: improved support for deferred-length character. These are very useful for avoiding bothersome trim() everywhere. Example:

    character(256) :: argv
    character(:), allocatable :: filename
    call get_command_argument(1, argv)
    filename = trim(argv)
    end program

    In this example, filename is now exactly the length required to fit the text. If the filename (in argv) was “hello.txt” then len(filename) is 9. That is, len_trim == len with auto-allocated characters (unless subsequently rewritten with a shorter string).

Practical examples are in gitrev.f90 and split_string.f90. For split_string.f90, note that this is the proper way to avoid assumed-length character functions, which are obsolete as of Fortran 95. Specifically:


! don't do this!
character(*) function myfun(a)


pure function myfun(a)
character(:), allocatable :: myfun

Gfortran 5

Gfortran 5 is the bare minimum version to even consider using, with Gfortran ≥ 6 strongly recommended

  • OpenMP 4.0 fully supported
  • Fortran 2003: ieee_ intrinsics supported, allowing convenient standard-compliant use of nan, ieee_is_nan, etc.
  • Fortran 2008: Initial coarray support
  • Fortran 2008: error stop in pure procedures, but only without specifying std= (until Gfortran 8 std=f2018). Error code must be constant.

Gfortran 4.9

  • Fortran 2003: allow deferred-length character variables in derived types

Gfortran 4.8

By this release, substantial Fortran 2008 polymorphism support had been initially added, including

  • select type
  • class(*)
  • type(*)
  • assumed rank dimension(..)

Gfortran 4.6

Gfortran 4.6 is the first version of Gfortran basically usable with commonly used code beyond Fortran 95. It is somewhat futile to attempt to use modern Fortran code with Gfortran ≤ 4.6

  • Fortran 2003: deferred-length character variable (not in derived types until 4.9)
  • Fortran 2008: impure elemental support

Gfortran 4.5

  • Fortran 2008: iso_fortran_env real64 etc. added

Gfortran 4.4

Gfortran 4.4 added initial support for polymorphism, but is still very rudimentary and difficult to use command Fortran 2003 techniques with Gfortran 4.4.

  • OpenMP 3

Operating system vs. Gfortran version:

Here are a few common operating systems vs. easily available Gfortran version. Ubuntu 16.04 should use the ubuntu-test PPA. CentOS should use devtoolset.


Homebrew / Linuxbrew

Ubuntu / Debian

  • Ubuntu gfortran repo defaults

  • Ubuntu 18.10 default: gfortran-8

  • Ubuntu 18.04 (EOL April 2023): install gfortran-8 via PPA

  • Ubuntu 18.04 default: gfortran-7

  • Windows Subsystem for Linux currently includes Ubuntu 18.04.

  • Ubuntu 16.04 (EOL April 2021): install gfortran-8 via PPA

  • Ubuntu 16.04 default: gfortran-5

  • Ubuntu 14.04 (EOL April 2019): install gfortran-8 via PPA

  • Ubuntu 14.04 default: gfortran-4.8

  • Debian Stretch 9, including Raspberry Pi: gfortran-6


Including RHEL and Scientific Linux.

  • CentOS 6 (EOL Nov 2020) devtoolset-8: gfortran-8
  • CentOS 6 default: gfortran-4.4

  • CentOS 7 (EOL June 2024) devtoolset-8: gfortran-8

  • CentOS 7 EPEL: gfortran-4.9

  • CentOS 7 default: gfortran-4.8


CMake allows switching parameters based on compiler version. This is very useful for modern Fortran programs. We recommend CMake ≥ 3.7 to give more powerful compiler version detection and action syntax (in general, not just for Fortran).

Fortran 2018

Example CMakeLists.txt for Fortran compiler version dependent options.

cmake_minimum_required(VERSION 3.7)
project(MyProject Fortran)


  if (UNIX AND NOT APPLE) # just an example for Linux-only option, nothing to do with Fortran standards
    list(APPEND FFLAGS -fstack-protector-all)

    list(APPEND FFLAGS -std=f2018)


add_executable(myprog main.f90)
target_compile_options(myprog PRIVATE ${FFLAGS})

Non-Fortran 2008 workaround

Here we assume that assert.f90 contains error stop in a procedure that’s called from a pure procedure. Old compilers don’t have the statement error stop, but can use stop instead with a harmless warning from a pure procedure, in assert_old.f90. Another perhaps better choice would be to use Fortran preprocessor.

cmake_minimum_required(VERSION 3.7)
project(MyProject Fortran)

check_fortran_source_compiles("program a; error stop; end"
  f08errorstop SRC_EXT f90)

add_executable(myprog PRIVATE main.f90)

if(CMAKE_Fortran_COMPILER_ID IN_LIST f2008errorstop)
  target_sources(myprog PRIVATE assert.f90)
  target_sources(myprog PRIVATE assert_old.f90)