Skip to content
Jeff Hammond edited this page May 30, 2016 · 14 revisions

Style

Fortran implementations of the PRK should be written in ISO Fortran 2008, without reliance upon compiler extensions, with a few exceptions:

  • Preprocessing can be used, because the portable fallback is to use the C preprocessor if the Fortran compiler cannot handle this.
  • Directives can be used, because they are in comments and should have no effect if not supported.
  • OpenMP is not part of ISO Fortran, but Fortran OpenMP compilers have well-defined behavior, so long as one only uses Fortran features that are defined to be supported in OpenMP.

OpenMP

One importance note on the second point is that DO CONCURRENT is part of Fortran 2008 and its interaction with OpenMP is not defined. Thus, one should not use DO CONCURRENT with OpenMP. OpenMP supports simple DO loops and WORKSHARE for implicit loops (i.e. array notation), which should be used instead.

Fortran 2015

Support for Fortran 2015 coarray features are not yet widely available and may not be used.

Documents

The GCC Wiki has an excellent collection of links to standards documents.

Compiler Options

Syntax and Standards

In common/make.defs, use the following to get the right language support. In particular, one must explicitly preprocess Stencil.

Compiler FC OPENMPFLAG
Intel ifort -std08 -fpp -qopenmp
GCC gfortran-5 -std=f2008 -cpp -fopenmp

Whenever we get around to supporting Fortran coarrays, https://gcc.gnu.org/wiki/Coarray will be useful.

Debugging

When developing, it is useful to build with the Intel Fortran compiler using

FLAGS="-O0 -g3 -warn all -traceback -check bounds"

where FLAGS is PRK_FLAGS when building in the top directory and DEFAULT_OPT_FLAGS in a specific subdirectory.

Coarray images

Intel compiler:

export FOR_COARRAY_NUM_IMAGES=32

Documentation

Clone this wiki locally