Coarray Fortran on LRZ HPC systems
How to compile and run Coarray Fortran programs on LRZ HPC systems
Availability on LRZ HPC systems
Coarrays are supported by the following compilers on the LRZ HPC systems:
- Intel's Fortran compiler (ifort)
- GCC's gfortran compiler, beginning with version 5.1
Please load the environment module caf, which gives you one of the coarray environments:
module load caf
By default, the Intel compiler's run time is added to the existing fortran/intel module.
module load caf/gfortran
will load the gfortran implementation. The latter has additional prerequisites, which will be pointed out when you try to load the module.
Building and running programs
A trivial example program
write(*, '(''Hello from image '',i0, '' of '',i0)') &
stored in the file hello.f90 can then be compiled and subsequently executed, typically using multiple cores, at least one for each image. The following table indicates how this works for the various compilers.
|Compiling||ifort -coarray=distributed -o h.exe hello.f90||ifort -coarray -o h.exe hello.f90||gfortran -fcoarray=lib -o h.exe hello.f90 $CAF_LIB $MPI_LIB|
# may need to unload other MPI before
module load mpi.intel
module load mpi.intel/5.0_gcc
mpiexec -n 4 ./h.exe
The configuration file pointed at by FOR_COARRAY_CONFIG_FILE is described in a separate section below.
The mpiexec command from the currently loaded MPI module is used for startup. The same MPI module should be used for compilation and execution.
Intel Fortran configuration file
For startup of distributed memory coarray programs a configuration file must be used that transmits the necessary startup information to Intel MPI. The file should contain a line with at least the following entries:
-hosts $SLURMD_NODENAME ./h.exe
-machines $LOADL_HOSTFILE ./h.exe
Other Intel MPI options like -genvall or -n <task count> etc. can also be added, but this is only necessary for specialized setups. The executables' name and its command line arguments are taken from this configuration file, so care must be taken to keep these consistent.
- Summary of the coarray feature (as covered in the Fortran 2008 standard) by John Reid. Some coarray features not discussed in this paper have been split off and will be reintroduced via a technical specification.
- Andy Vaught's coarray compendium
- Intel Fortran compiler documentation, available from the Intel web site