The Fortran MPI language bindings have been designed to be compatible with the Fortran 90 standard with additional features from Fortran 2018 [48]. In previous versions of this document, references were made to Fortran 2003 and Fortran 2008 [46] with TS 29113 [47]; where appropriate, the specific features of Fortran 2018 that MPI requires will be noted explicitly.
Rationale.
Fortran 90 contains numerous features designed to
make it a more ``modern'' language than Fortran 77. It seems natural
that MPI should be able to take advantage of these new features with
a set of bindings tailored to Fortran 90.
In Fortran 2008 with TS 29113 and later Fortran 2018,
the major new language features
used are the ASYNCHRONOUS attribute to protect nonblocking MPI operations,
and assumed-type and assumed-rank dummy arguments for choice buffer arguments.
Further requirements for compiler support are listed in
Section Requirements on Fortran Compilers.
( End of rationale.)
MPI defines three methods of Fortran support:
Application subroutines and functions may use either
one of the modules or the
(deprecated) mpif.h include file. An implementation may
require the use of one of the modules
to prevent type mismatch errors.
Advice to users.
Users are advised to utilize one of the MPI modules even if
mpif.h enforces type checking
on a particular system.
Using a module provides several
potential advantages over using an include file;
the mpi_f08 module offers the most robust and complete Fortran support.
( End of advice to users.)
In a single application, it must be possible to link together routines
that USE mpi_f08, USE mpi, and INCLUDE 'mpif.h'.
The LOGICAL constant MPI_SUBARRAYS_SUPPORTED is set to .TRUE. if all buffer choice arguments are defined in explicit interfaces with assumed-type and assumed-rank [48]; otherwise it is set to .FALSE.. The LOGICAL constant MPI_ASYNC_PROTECTS_NONBLOCKING is set to .TRUE. if the ASYNCHRONOUS attribute was added to the choice buffer arguments of all nonblocking interfaces and the underlying Fortran compiler supports the ASYNCHRONOUS attribute for MPI communication (as part of TS 29113, which has been superceded by Fortran 2018), otherwise it is set to .FALSE.. These constants exist for each Fortran support method, but not in the C header file. The values may be different for each Fortran support method. All other constants and the integer values of handles must be the same for each Fortran support method.
Sections Fortran Support Through the mpi_f08 Module through Fortran Support Through the mpif.h Include File define the Fortran support methods. The Fortran interfaces of each MPI routine are shorthands. Section Interface Specifications, Procedure Names, and the Profiling Interface defines the corresponding full interface specification together with the specific procedure names and implications for the profiling interface. Section MPI for Different Fortran Standard Versions describes the implementation of the MPI routines for different versions of the Fortran standard. Section Requirements on Fortran Compilers summarizes major requirements for MPI implementations with Fortran support. Section Additional Support for Fortran Register-Memory-Synchronization and Section Additional Support for Fortran Numeric Intrinsic Types describe additional functionality that is part of the Fortran support. MPI_F_SYNC_REG is needed for one of the methods to prevent register optimization problems. A set of functions provides additional support for Fortran intrinsic numeric types, including parameterized types: MPI_TYPE_MATCH_SIZE, MPI_TYPE_CREATE_F90_INTEGER, MPI_TYPE_CREATE_F90_REAL and MPI_TYPE_CREATE_F90_COMPLEX. In the context of MPI, parameterized types are Fortran intrinsic types that are specified using KIND type parameters. Sections Problems With Fortran Bindings for MPI through Permanent Data Movement give an overview and details on known problems when using Fortran together with MPI; Section Comparison with C compares the Fortran problems with those in C.