Related: Gfortran feature set vs. OS and version
For scientists, engineers and other practical coders, modern Fortran offers immediate clear advantages. The clarity, conciseness and power of modern Fortran are widely available in contemporary compilers. This brief post was motivated by meeting someone whose supervisor insisted on Fortran 77. They didn’t know anything newer than Fortran 90 existed.
This was a programming travesty to me. One generally shouldn’t needlessly upgrade all Fortran 77 code to modern Fortran, since Fortran has always maintained good backward compatibility. However, new and upgraded Fortran code should almost never be written in Fortran 77 unless specific job conditions dictate.
New Fortran code should at least use Fortran 2003, which is universally supported by worthwhile compilers. In our work, including in HPC environments, Gfortran and Intel Fortran are widely supported, so we use Fortran 2003, 2008 and 2018 features in virtually every program. We fallback to limited Fortran 2003 feature sets using CMake where strictly necessary.
Modern Fortran support
The compilers easily available supporting modern Fortran include:
- Gfortran 8: Most of Fortran 2008, growing useful subset of Fortran 2018
- Intel Fortran: all of Fortran 2008, growing Fortran 2018 support
- NAG: Fortran 2003 and useful subset of Fortran 2008
- Flang: Fortran 2003 comprehensive support, growing Fortran 2008 support
- PGI: Fortran 2003 comprehensive support
What did the major Fortran versions add
- Fortran 95 brought strong N-dimensional arrow operations. It is a small but important base of modern Fortran, mainly enabling arbitrary size (elemental) intrinsic and non-intrinsic procedures. With Fortran 95, one no longer had to to explicitly loop over almost every array operation.
- Fortran 2003 brought polymorphism and true object-oriented procedures, critical parts of modern generic programming.
- Fortran 2008 strengthened polymorphism, and baked coarray (distributed parallelism) directly into Fortran, transparently using underlying libraries such as OpenMPI. Improved Fortran software architecture comes through the submodules enabled by Fortran 2008.
- Fortran 2018 strengthened coarray support, and did further important language cleanup such as enabling