ovevans / fortran2018-examples

Fortran 2018 standard examples with broad applications

Home Page:https://scivision.github.io/fortran2018-examples/index.html

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Fortran 2018 Examples

Actions Status Actions Status

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)

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

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

The CMake or Meson build system automatically walks through the subdirectories:

CMake

cmake -B build
cmake --build build --parallel

cd build
ctest --parallel 4 --output-on-failure

Meson

meson build

meson test -C build

Compilers

Intel oneAPI

Intel oneAPI has complete Fortran 2018 support. Use Intel compilers (oneAPI or Parallel Studio) by:

  • MacOS or Linux:

    cmake --preset=intel
  • Windows

    cmake --preset=intelwin
    

Programs

Each directory has its own README and examples.

  • array/: Array math in modern CMake and Fortran, including MKL, BLAS, LAPACK and LAPACK95.
  • block/: Highly useful block element is demonstrated
  • coarray/: modern Fortran is the only major compiled language standard with intrinsic massively parallel arrays.
  • contiguous/: Fortran 2008 contiguous array examples, including Fortran preprocessor with modern CMake.
  • git/ Git tracability
  • mpi/: MPI parallel computing examples
  • namelist/: Fortran 90 / 2003 Namelist parsing -- native text config files for Fortran
  • openmp/: OpenMP threading exmaples
  • random/: random numbers with modern Fortran

  • 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

About

Fortran 2018 standard examples with broad applications

https://scivision.github.io/fortran2018-examples/index.html

License:MIT License


Languages

Language:Fortran 55.0%Language:CMake 27.9%Language:Meson 9.7%Language:Python 6.1%Language:Shell 0.8%Language:C 0.4%Language:C++ 0.1%