Major changes in GCC Gfortran by version
GCC GFortran, LLVM Flang, and Intel oneAPI are among the most advanced free-to-usemodern Fortran compilers. Currently we recommend writing Fortran code to support:
- GCC ≥ 12
- Flang (recent release)
- oneAPI (currently supported release)
Useful
GFortran standard 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 13 is the
oldest version
currently maintained.
To get recent GCC is usually straightforward. Red Hat should use GCC Toolset. macOS Homebrew quickly adds the latest 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 16 adds improved Fortran 2023 support including the
splitintrinsic subroutine, optionallowerargument toc_f_pointer, and additional trigonometric functions (sinpi, etc.). It also enhances coarray support with native shared memory multithreading on single-node machines and better Fortran 2018TEAMhandling, improves Fortran 2003 parameterized derived types (LEN parameters), and adds Fortran 2018 extensions to theIMPORTstatement, theREDUCEintrinsic, and the newGENERICstatement. - Gfortran 15 adds experimental support for unsigned modular integers (
-funsigned), Fortran 2018/2023 locality specifiers indo concurrent, and stricter format string parsing (missing commas in I/O descriptors are now rejected by default). The module file format is now incompatible with GCC 8–14 (but older.modfiles can still be read). Coarray support has been significantly reworked. - Gfortran 14 adds
-std=f2023(prepares for Fortran 2023) with increased free-form line length (10,000 characters) and statement length (up to 1 million characters). It also improves preprocessing output with-save-temps(.fii/.fifiles). - Gfortran 13 completes full support for finalization and improves OpenMP 5.0 support for Fortran (e.g. some non-rectangular loop nests).
- Gfortran 12 enhances OpenMP 5 and OpenACC 2.6 support. Numerous bugfixes.
bind(C)with character length greater than one. This is a groundbreaking improvement for C interoperability forcharacterand strings, even C++<string>usingISO_Fortran_binding.h. - Gfortran 11 completed OpenMP 4.5 support.
- Gfortran 10 added
select rank. - Gfortran 9 added
random_init()to initialize the random generator seed. - Gfortran 8 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 definekindat initialization) and coarray support for teams. Standard flag-std=f2018added and deprecated-std=f2008ts. - Gfortran 7 added derived type IO
select type. Complete Fortran 2003 support, Fortran 2018 non-constantstopanderror stopcodes, 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 powerful use scenarios.
Fortran 2003 deferred-length character are
useful
for avoiding bothersome trim() everywhere.
GCC 5 added full support for OpenMP 4.0, Fortran 2003 ieee_ intrinsics, Fortran 2008 error stop in pure 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 Fortran 2018 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")
add_compile_options($<$<COMPILE_LANGUAGE:Fortran>:-fimplicit-none>)
if(CMAKE_Fortran_COMPILER_VERSION VERSION_GREATER_EQUAL "10.0")
add_compile_options($<$<COMPILE_LANGUAGE:Fortran>:-fallow-argument-mismatch>)
endif()
endif()or using generator expressions exclusively:
add_compile_options(
$<$<COMPILE_LANG_AND_ID:Fortran,GNU>:-fimplicit-none>
$<$<AND:$<COMPILE_LANG_AND_ID:Fortran,GNU>,$<VERSION_GREATER_EQUAL:$<CMAKE_Fortran_COMPILER_VERSION>,10.0>>:-fallow-argument-mismatch>
)Reference: Gfortran changelog