Skip to content

Latest commit

 

History

History
102 lines (71 loc) · 4.66 KB

README.md

File metadata and controls

102 lines (71 loc) · 4.66 KB

Fortran 2018 Examples

cmake oneapi-linux fpm

Easy examples of scientific computing with modern, powerful, easy Fortran 2018 standard. Fortran 2018 began as the TS18508 extension, formerly known as Fortran 2015.

Modern Fortran benefits from modern CMake, which supports Fortran features such as

  • submodule
  • preprocessing
  • detecting specific support of Fortran features (so users know their compiler is too old)
  • coarray: modern Fortran is the only major compiled language standard with intrinsic massively parallel arrays.
  • mpi:

Based on widespread compiler support and beneficial features, most new and upgraded Fortran programs should use at least portions of the Fortran 2008 standard.

Compilers known to work include: GCC, Intel oneAPI, Nvidia HPC SDK, AOCC (AMD), Flang, Cray.

Prereq

  • Linux: apt install cmake gfortran
  • Mac: brew install gcc cmake
  • Windows MSYS2: pacman -S mingw-w64-x86_64-gcc-fortran mingw-w64-x86_64-cmake

Build

Fortran Package Manager:

fpm build

or CMake:

cmake --workflow --preset default

Programs

Each test/ directory has its own README and examples.

  • array: Array math in modern CMake and Fortran
  • Git tracability
  • namelist: Fortran 90 / 2003 Namelist parsing -- native text config files for Fortran
  • openmp: OpenMP threading exmaples
  • io: modern Fortran File I/O including resolving absolute path
  • real: Numerous examples dealing with practical features of real floating point numbers, including sentinel NaN and polymorphism.
  • character: String handling is easy and performant in modern Fortran.
  • standard: advanced features that can be done with Fortran standard coding
  • submodule: Fortran 2008 and CMake ≥ 3.12 enable even better large program architecture with submodule
  • system: system (hardware) functionality accessible via Fortran

Companion libraries and examples

Resources

Fortran standards

Books

Compiler User Guides

Surveys