Major changes in GCC Gfortran by version
GCC Gfortran and Intel oneAPI are the most advanced modern Fortran compilers.
Useful Fortran 2018 enhancements include:
select rank
assumed array rank,
error stop
within pure
procedures,
random_init
to initialize random number seed, and
implicit none (type, external)
to require external procedures to be explicitly declared.
GCC 8 is the
oldest version
currently maintained.
Intel oneAPI also has full Fortran 2018
support.
To get recent GCC is usually straightforward. Red Hat should use devtoolset. MacOS Homebrew quickly adds the lastest GCC version. If Ubuntu gfortran repo defaults aren’t adequate, get recent Gfortran via PPA.
Here are some of the major changes in Gfortran by version:
- Gfortran 10 added
select rank
- Gfortran 9 added
random_init()
to initialize the random generator seed…randomly - Gfortran 8.1 added automatic nested loop exchange with
do concurrent
, actual argument array with too few elements for dummy argument now errors, initial support for parameterized derived types (simply definekind
at initialization) and coarray support for teams. Gfortran 8.2 and 8.3 did not introduce new Fortran features. - Gfortran 8.0 added
-std=f2018
and deprecated-std=f2008ts
. - Gfortran 7 added derived type IO
select type
et all–complete Fortran 2003, Fortran 2018 non-constantstop
anderror stop
codes, and-fdec-
options to help compile very old non-standard code. - Gfortran 6 added Fortran 2008
submodule
support, useful for large projects to save compilation time and allow powerfuluse
scenarios. Fortran 2003 deferred-lengthcharacter
are useful for avoiding bothersometrim()
everywhere. - GCC 5 added full support for OpenMP 4.0, Fortran 2003
ieee_
intrinsics, Fortran 2008error stop
inpure
procedures with constant error code.
GCC 4.9 added Fortran 2003 deferred-length character variables in derived types.
GCC 4.8 supported Fortran 2008 polymorphism, including select type
, class(*)
, type(*)
, and assumed rank dimension(..)
.
GCC 4.6 was the first version of Gfortran reaching beyond Fortran 95, with Fortran 2003 deferred-length character variable and Fortran 2008 impure elemental
support.
GCC 4.5 added Fortran 2008 iso_fortran_env
.
GCC 4.4 added initial support for polymorphism and OpenMP 3.
CMake allows switching parameters based on compiler version. This is very useful for modern Fortran programs.
Example CMakeLists.txt
for Fortran compiler version dependent options.
if(CMAKE_Fortran_COMPILER_ID STREQUAL GNU)
# option applying to any language for this compiler
add_compile_options(-mtune=native)
# language-specific, note LEADING space
string(APPEND CMAKE_Fortran_FLAGS " -fimplicit-none")
if(CMAKE_Fortran_COMPILER_VERSION VERSION_GREATER_EQUAL 8)
string(APPEND CMAKE_Fortran_FLAGS " -std=f2018")
endif()
endif()
add_executable(myprog main.f90)
Reference: Gfortran changelog