3.6.2. Fortran Binding Issues

Up: Language Binding Next: C Binding Issues Previous: Deprecated and Removed Interfaces

Originally, MPI-1.1 provided bindings for Fortran 77. These bindings are retained, but they are now interpreted in the context of the Fortran 90 standard. MPI can still be used with most Fortran 77 compilers, as noted below. When the term ``Fortran'' is used it means Fortran 90 or later; it means Fortran 2008 with TS 29113, which is now an integral part of Fortran 2018 and later if the mpi_f08 module is used.

All Fortran MPI names have an MPI_ prefix. Although Fortran is not case sensitive, if the mpi_f08 module is used, the first character after the MPI_ prefix is capital and all others are lower case. If the mpi_f08 module is not used, all characters are capitals. Programs must not declare names, e.g., for variables, subroutines, functions, parameters, derived types, abstract interfaces, or modules, beginning with the prefix MPI_. To avoid conflicting with the profiling interface, programs must also avoid subroutines and functions with the prefix PMPI_. This is mandated to avoid possible name collisions.

All MPI Fortran subroutines have an error code in the last argument. With USE mpi_f08, this last argument is declared as OPTIONAL, except for user-defined callback functions (e.g., COMM_COPY_ATTR_FUNCTION) and their predefined callbacks (e.g., MPI_COMM_NULL_COPY_FN). A few MPI operations that are functions do not have the error code argument. The error code value for successful completion is MPI_SUCCESS. Other error codes are implementation dependent; see the error codes in Chapter MPI Environmental Management and Annex Language Bindings Summary.

Constants representing the maximum length of a string are one smaller in Fortran than in C as discussed in Section Constants.

Handles are represented in Fortran as INTEGERs, or as a BIND(C) derived type with the mpi_f08 module; see Section Opaque Objects. Binary-valued variables are of type LOGICAL.

Array arguments are indexed from one.

The older MPI Fortran bindings---use mpi and (deprecated) mpif.h---are inconsistent with the Fortran standard in several respects. These inconsistencies, such as register optimization problems, have implications for user codes that are discussed in detail in Section Optimization Problems, an Overview.

The support for large count and displacement in Fortran is only available when using newer MPI Fortran bindings (USE mpi_f08). For better readability, all Fortran large count procedure declarations are marked with a comment ``!(_c)''.

Up: Language Binding Next: C Binding Issues Previous: Deprecated and Removed Interfaces

Return to MPI-4.1 Standard Index
Return to MPI Forum Home Page

(Unofficial) MPI-4.1 of November 2, 2023
HTML Generated on November 19, 2023