210. Determining Whether MPI Has Finished

PreviousUpNext
Up: Startup Next: Portable MPI Process Startup Previous: Allowing User Functions at Process Termination

One of the goals of MPI was to allow for layered libraries. In order for a library to do this cleanly, it needs to know if MPI is active. In MPI the function MPI_INITIALIZED was provided to tell if MPI had been initialized. The problem arises in knowing if MPI has been finalized. Once MPI has been finalized it is no longer active and cannot be restarted. A library needs to be able to determine this to act accordingly. To achieve this the following function is needed:

MPI_FINALIZED(flag)
OUT flagtrue if MPI was finalized (logical)

int MPI_Finalized(int *flag)

MPI_Finalized(flag, ierror)
LOGICAL, INTENT(OUT) :: flag
INTEGER, OPTIONAL, INTENT(OUT) :: ierror
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 .


Advice to users.

MPI is ``active'' and it is thus safe to call MPI functions if MPI_INIT has completed and MPI_FINALIZE has not completed. If a library has no other way of knowing whether MPI is active or not, then it can use MPI_INITIALIZED and MPI_FINALIZED to determine this. For example, MPI is ``active'' in callback functions that are invoked during MPI_FINALIZE. ( End of advice to users.)


PreviousUpNext
Up: Startup Next: Portable MPI Process Startup Previous: Allowing User Functions at Process Termination


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

(Unofficial) MPI-3.1 of June 4, 2015
HTML Generated on June 4, 2015