12.2.3. Determining Whether MPI Has Been Initialized When Using the World Model

PreviousUpNext
Up: The World Model Next: Allowing User Functions at MPI Finalization Previous: Finalizing MPI

One of the goals of MPI is to allow for layered libraries. A library using the World Model needs to know if MPI has been initialized using either of MPI_INIT or MPI_INIT_THREAD. In MPI the function MPI_INITIALIZED is provided to tell if MPI had been initialized using the World Model. In the World Model, once MPI has been finalized it cannot be restarted. A library needs to be able to determine this to act accordingly. To achieve this, the function MPI_FINALIZED is needed.

MPI_INITIALIZED(flag)
OUT flagFlag is true if MPI_INIT or MPI_INIT_THREAD has been called and false otherwise (logical)
C binding
int MPI_Initialized(int *flag)
Fortran 2008 binding
MPI_Initialized(flag, ierror)

LOGICAL, INTENT(OUT) :: flag
INTEGER, OPTIONAL, INTENT(OUT) :: ierror
Fortran binding
MPI_INITIALIZED(FLAG, IERROR)

LOGICAL FLAG
INTEGER IERROR

This routine may be used to determine whether MPI_INIT or MPI_INIT_THREAD has been called. MPI_INITIALIZED returns true if the calling process has called either of these MPI procedures. Whether MPI_FINALIZE has been called does not affect the behavior of MPI_INITIALIZED. This function must always be thread-safe, as defined in Section MPI and Threads. This function returns false for applications using the Sessions Model exclusively.

MPI_FINALIZED(flag)
OUT flagtrue if MPI_FINALIZE has been called and false otherwise. (logical)
C binding
int MPI_Finalized(int *flag)
Fortran 2008 binding
MPI_Finalized(flag, ierror)

LOGICAL, INTENT(OUT) :: flag
INTEGER, OPTIONAL, INTENT(OUT) :: ierror
Fortran binding
MPI_FINALIZED(FLAG, IERROR)

LOGICAL FLAG
INTEGER IERROR

This routine returns true if MPI_FINALIZE has completed. It is valid to call MPI_FINALIZED before MPI_INIT and after MPI_FINALIZE. This function must always be thread-safe, as defined in Section MPI and Threads.


PreviousUpNext
Up: The World Model Next: Allowing User Functions at MPI Finalization Previous: Finalizing 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