Skip to content
Easy examples of scientific computing with modern, powerful, easy Fortran 2018 standard
Fortran CMake Meson Python Shell C++ C
Branch: master
Clone or download
Latest commit 0a7d336 Nov 12, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github init Nov 12, 2019
archive Cmake: HDF5 template Nov 5, 2019
array init Nov 12, 2019
benchmarks meson: move find/capability logic to cmake/meson.build Oct 28, 2019
block Cmake: HDF5 template Nov 5, 2019
character Cmake: HDF5 template Nov 5, 2019
cmake array: assumed rank Nov 12, 2019
cmake_examples Cmake: HDF5 template Nov 5, 2019
coarray Cmake: HDF5 template Nov 5, 2019
contiguous Cmake: HDF5 template Nov 5, 2019
cxx Cmake: HDF5 template Nov 5, 2019
debug Cmake: HDF5 template Nov 5, 2019
hdf5 Cmake: HDF5 template Nov 5, 2019
io array: polymorph select type Nov 12, 2019
lapack95 Cmake: HDF5 template Nov 5, 2019
mpi Cmake: HDF5 template Nov 5, 2019
mumps Cmake: HDF5 template Nov 5, 2019
namelist remove needless restrictions on windows tests Sep 9, 2019
netcdf cmake: streamline netcdf Nov 5, 2019
openmp Cmake: HDF5 template Nov 5, 2019
overloading Cmake: HDF5 template Nov 5, 2019
random Cmake: HDF5 template Nov 5, 2019
real Cmake: HDF5 template Nov 5, 2019
standard Cmake: HDF5 template Nov 5, 2019
submodule cmake: add submodule externalProject example Oct 28, 2019
subprojects add submodule subproject. cleanup meson hdf5 Oct 7, 2019
system Cmake: HDF5 template Nov 5, 2019
tests folderize Nov 30, 2018
.f2py_f2cmap f2py types Jun 4, 2017
.gitattributes template Oct 23, 2017
.gitignore array: assumed rank Nov 12, 2019
CMakeLists.txt cmake: add submodule externalProject example Oct 28, 2019
CODE_OF_CONDUCT.md array: polymorph select type Nov 12, 2019
LICENSE Initial commit May 6, 2016
README.md CI: make cmake and meson individual workflows Oct 28, 2019
ford.md move [skip ci] Dec 4, 2018
meson.build meson: move find/capability logic to cmake/meson.build Oct 28, 2019
meson_options.txt init azure Jul 31, 2019
requirements.txt metadata "used by" meson [skip ci] Jul 8, 2019

README.md

Actions Status Actions Status

Fortran 2018 Examples

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 / Windows: apt install cmake gfortran libhdf5-dev libopenmpi-dev libnetcdff-dev libcoarrays-dev open-coarrays-bin
  • Mac: brew install gcc cmake open-mpi opencoarrays

Build

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

CMake

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

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

Meson

meson build

meson test -C build

ifort Intel

Be sure you have the Intel Parallel Studio Cluster Edition that has mpiifort.

FC=ifort CC=icc CXX=icpc cmake ..

Flang / Clang

Flang is a Free compiler.

FC=flang CC=clang CXX=clang++ cmake ..

PGI

PGI is available at no cost.

FC=pgf90 CC=pgcc CXX=pgc++ cmake ..

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.
  • mpi/: OpenMPI 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
  • netcdf/: Easy multidimensional file IO with NetCDF
  • hdf5/: HDF5 is one of the most popular self-describing file formats for massively scalable files.

  • CMake/: CMake work well with modern Fortran features
  • cxx/: standard Fortran C / C++ bindings
  • 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

Bugs

iso_fortran_env

Flang 6 and PGI 18.10 seem to have a bug with iso_fortran_env that doesn't allow compiler_version and compiler_options to work unless use iso_fortran_env is ONLY used in program and NOT module even if using only. Thus, simple programs like pragma.f90 work, but not the usual programs to print the compiler versions and options with Flang and PGI.

Resources

Fortran standards

Books

Compiler User Guides

Surveys

You can’t perform that action at this time.