20.1.11. Problems Due to Strong Typing

PreviousUpNext
Up: Support for Fortran Next: Problems Due to Data Copying and Sequence Association with Subscript Triplets Previous: Problems With Fortran Bindings for MPI

All MPI functions with choice arguments associate actual arguments of different Fortran datatypes with the same dummy argument. This is not allowed by Fortran 77, and in Fortran 90, it is technically only allowed if the function is overloaded with a different function for each type (see also Section MPI for Different Fortran Standard Versions). In C, the use of void* formal arguments avoids these problems. Similar to C, with Fortran 2008 with TS 29113 (and later) together with the mpi_f08 module, the problem is avoided by declaring choice arguments with TYPE(*), DIMENSION(..), i.e., as assumed-type and assumed-rank dummy arguments.

Using INCLUDE 'mpif.h' (deprecated), the following code fragment is technically invalid and may generate a compile-time error.

Image file

In practice, it is rare for compilers to do more than issue a warning. When using either the mpi_f08 or mpi module, the problem is usually resolved through the assumed-type and assumed-rank declarations of the dummy arguments, or with a compiler-dependent mechanism that overrides type checking for choice arguments.

It is also technically invalid in Fortran to pass a scalar actual argument to an array dummy argument that is not a choice buffer argument. Thus, when using the mpi_f08 or mpi module, the following code fragment usually generates an error since the dims and periods arguments to MPI_CART_CREATE are declared as assumed size arrays INTEGER :: DIMS(*) and LOGICAL :: PERIODS(*).


Example It is erroneous to pass a variable instead of an array with one element.

Image file

Although this is a nonconforming MPI call, compiler warnings are not expected (but may occur) when using INCLUDE 'mpif.h' (deprecated) and this include file does not use Fortran explicit interfaces.


PreviousUpNext
Up: Support for Fortran Next: Problems Due to Data Copying and Sequence Association with Subscript Triplets Previous: Problems With Fortran Bindings for MPI


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