NAME
MMPPIIFFiinnaalliizzee - Terminates MPI execution environment.
SSYYNNTTAAXX CC SSyynnttaaxx#include
int MPIFinalize() FFoorrttrraann SSyynnttaaxx INCLUDE 'mpif.h'MPIFINALIZE(IERROR)
INTEGER IERROR
CC++++ SSyynnttaaxx#include
void Finalize() OOUUTTPPUUTT PPAARRAAMMEETTEERRIERROR Fortran only: Error status (integer).
DESCRIPTION
This routine cleans up all MPI states. Once this routine is called, noMPI routine (not even MPIInit) may be called, except for MPIGetver-
sion, MPIInitialized, and MPIFinalized. Unless there has been a call to MPIAbort, you must ensure that all pending communications involving a process are complete before the process calls MPIFinalize. If the call returns, each process may either continue local computations orexit without participating in further communication with other pro-
cesses. At the moment when the last process calls MPIFinalize, all pending sends must be matched by a receive, and all pending receives must be matched by a send.MPIFinalize is collective over all connected processes. If no pro-
cesses were spawned, accepted, or connected, then this means it is col-
lective over MPICOMMWORLD. Otherwise, it is collective over the union of all processes that have been and continue to be connected. NNOOTTEESS All processes must call this routine before exiting. All processes willstill exist but may not make any further MPI calls. MPIFinalize guar-
antees that all local actions required by communications the user has completed will, in fact, occur before it returns. However, MPIFinalizeguarantees nothing about pending communications that have not been com-
pleted; completion is ensured only by MPIWait, MPITest, or MPIRequestfree combined with some other verification of completion.For example, a successful return from a blocking communication opera-
tion or from MPIWait or MPITest means that the communication is com-
pleted by the user and the buffer can be reused, but does not guarantee that the local process has no more work to do. Similarly, a successful return from MPIRequestfree with a request handle generated by anMPIIsend nullifies the handle but does not guarantee that the opera-
tion has completed. The MPIIsend is complete only when a matching receive has completed. If you would like to cause actions to happen when a process finishes, attach an attribute to MPICOMMSELF with a callback function. Then, when MPIFinalize is called, it will first execute the equivalent of an MPICommfree on MPICOMMSELF. This will cause the delete callback function to be executed on all keys associated with MPICOMMSELF in an arbitrary order. If no key has been attached to MPICOMMSELF, then no callback is invoked. This freeing of MPICOMMSELF happens before any other parts of MPI are affected. Calling MPIFinalized will thus return "false" in any of these callback functions. Once you have done this with MPICOMMSELF, the results of MPIFinalize are not specified. EERRRROORRSS Almost all MPI routines return an error value; C routines as the valueof the function and Fortran routines in the last argument. C++ func-
tions do not return errors. If the default error handler is set toMPI::ERRORSTHROWEXCEPTIONS, then on error the C++ exception mechanism
will be used to throw an MPI:Exception object. Before the error value is returned, the current MPI error handler is called. By default, this error handler aborts the MPI job, except for I/O function errors. The error handler may be changed withMPICommseterrhandler; the predefined error handler MPIERRORSRETURN
may be used to cause error values to be returned. Note that MPI does not guarantee that an MPI program can continue past an error. Open MPI 1.2 September 2006 MPIFinalize(3OpenMPI)