-
Notifications
You must be signed in to change notification settings - Fork 109
Fortran
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.
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.
Side note: Intel Fortran maps DO CONCURRENT
to something along the lines of omp parallel do simd
. It is likely that other compilers will do this.
Support for Fortran 2015 coarray features are not yet widely available and may not be used.
The GCC Wiki has an excellent collection of links to standards documents.
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.
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.
Intel compiler:
export FOR_COARRAY_NUM_IMAGES=32
This is work-in-progress
# MPICH_* override because MPICH was built against GCC-5
export MPICH_CC=gcc-6
export MPICH_FC=gfortran-6
export MPI_DIR=/opt/mpich/dev/gcc/default # Jeff's Mac
git clone https://github.com/sourceryinstitute/opencoarrays.git && cd opencoarrays && \
mkdir build && cd build && \
CC=$MPI_DIR/bin/mpicc FC=$MPI_DIR/bin/mpifort cmake .. \
-DCMAKE_INSTALL_PREFIX=/opt/opencoarrays/mpich-dev-gcc-6 \
-DMPI_C_COMPILER=$MPI_DIR/bin/mpicc -DMPI_Fortran_COMPILER=$MPI_DIR/bin/mpifort && \
make -j4 && \
ctest && \
make install
# This is required because OpenCoarrays "caf" compiler wrapper does not capture absolute path.
export CAFC=$MPI_DIR/bin/mpifort