3.5.4. Named Constants

PreviousUpNext
Up: Datatypes Next: Choice Previous: State

MPI procedures sometimes assign a special meaning to a special value of a basic type argument; e.g., tag is an integer-valued argument of point-to-point communication operations, with a special wild-card value, MPI_ANY_TAG. Such arguments will have a range of regular values, which is a proper subrange of the range of values of the corresponding basic type; special values (such as MPI_ANY_TAG) will be outside the regular range. The range of regular values, such as tag, can be queried using environmental inquiry functions, see Chapter MPI Environmental Management. The range of other values, such as source, depends on values given by other MPI routines (in the case of source it is the communicator size).

MPI also provides predefined named constant handles, such as MPI_COMM_WORLD.

All named MPI constants, with the exceptions noted below for Fortran, can be used in initialization expressions or assignments. Opaque objects accessed by constant handles are defined and do not change value between MPI initialization (e.g., with MPI_INIT) and MPI finalization (e.g., with MPI_FINALIZE). The handles themselves are constants and can be also used in initialization expressions or assignments.

In C, all named MPI constants that are described as ``integer constant expression'' in Section Defined Constants must be implemented as C integer constant expressions of the specified integer type. All other MPI constants in C are not required to be C integer constant expressions but must be usable in initialization expressions and assignments. Thus, they are not guaranteed to be usable in array declarations or as case-labels in switch statements.

In Fortran, all named MPI constants (with the exceptions below) must be declared with the PARAMETER attribute.

The constants that cannot be used in initialization expressions or assignments in Fortran are as follows:

Image file


Advice to implementors.

In Fortran the implementation of these special constants may require the use of language constructs that are outside the Fortran standard. Using special values for the constants (e.g., by defining them through PARAMETER statements) is not possible because an implementation cannot distinguish these values from valid data. Typically, these constants are implemented as predefined static variables (e.g., a variable in an MPI-declared COMMON block), relying on the fact that the target compiler passes data by address. Inside the subroutine, this address can be extracted by some mechanism outside the Fortran standard (e.g., by Fortran extensions or by implementing the function in C). ( End of advice to implementors.)


PreviousUpNext
Up: Datatypes Next: Choice Previous: State


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