MPI_FINALIZED(3)

πŸ’– MPI_FINALIZED πŸ’–

okay bestie, gather round, because we are looking at MPI_FINALIZED(3) from the Open MPI manual set, and it's lowkey one of the most useful little gossip-checkers in all of MPI ✨


🌸 SYNOPSIS 🌸

here's the vibe, in every dialect you might be speaking πŸ’…

🌈 C Syntax

#include <mpi.h>

int MPI_Finalized(int *flag)

πŸ¦‹ Fortran Syntax

USE MPI
! or the older form: INCLUDE 'mpif.h'

MPI_FINALIZED(FLAG, IERROR)
    LOGICAL FLAG
    INTEGER IERROR

πŸŽ€ Fortran 2008 Syntax

USE mpi_f08

MPI_Finalized(flag, ierror)
    LOGICAL, INTENT(OUT) :: flag
    INTEGER, OPTIONAL, INTENT(OUT) :: ierror

🌟 OUTPUT PARAMETER 🌟

  • flag β€” true if the MPI world model was finalized, and false otherwise (logical). it's literally just a yes/no, bestie, no nuance πŸ’…
  • ierror β€” Fortran only: error status (integer).

✨ DESCRIPTION ✨

so this routine is the one you call to figure out whether the MPI world model has been finalized. that's it, that's the job 🫢

and ngl, there's a different routine for the other direction β€” MPI_Initialized β€” and that one is what tells you whether the MPI world model has been initialized. two besties, two questions, don't mix them up πŸ™ˆ

if you want the receipts on which MPI functionality is still available to you (like, stuff that works even when the MPI world model hasn't initialized yet, or has already been finalized), go look at MPI-5.0:11.4.1 over at <https://www.mpi-forum.org/> πŸ“š


πŸ’€ ERRORS πŸ’€

almost all MPI routines return an error value. for C routines it comes back as the return result of the function, and for Fortran routines it shows up in the last argument. classic.

before that error value gets returned, the current MPI error handler associated with the communication object (so like, communicator, window, file) gets called. if there's no communication object associated with the MPI call, then the call is considered attached to MPI_COMM_SELF and it will call the associated MPI error handler. and when MPI_COMM_SELF is not initialized β€” meaning before MPI_Init / MPI_Init_thread, after MPI_Finalize, or when you're using the Sessions Model exclusively β€” the error raises the initial error handler. the initial error handler can be changed by calling MPI_Comm_set_errhandler on MPI_COMM_SELF when using the World model, or via the mpi_initial_errhandler CLI argument to mpiexec, or the info key to MPI_Comm_spawn / MPI_Comm_spawn_multiple. and if no other appropriate error handler has been set, then the MPI_ERRORS_RETURN error handler is called for MPI I/O functions, while the MPI_ERRORS_ABORT error handler gets called for all other MPI functions. 😭

Open MPI ships with three predefined error handlers you can use, and they are:

  • MPI_ERRORS_ARE_FATAL β€” causes the program to abort all connected MPI processes. πŸ’€
  • MPI_ERRORS_ABORT β€” an error handler that can be invoked on a communicator, window, file, or session. when called on a communicator, it acts as if MPI_Abort was called on that communicator. if called on a window or file, it acts as if MPI_Abort was called on a communicator containing the group of processes in the corresponding window or file. if called on a session, it aborts only the local process.
  • MPI_ERRORS_RETURN β€” returns an error code to the application.

MPI applications can also implement their own error handlers by calling:

  • MPI_Comm_create_errhandler then MPI_Comm_set_errhandler
  • MPI_File_create_errhandler then MPI_File_set_errhandler
  • MPI_Session_create_errhandler then MPI_Session_set_errhandler or at MPI_Session_init
  • MPI_Win_create_errhandler then MPI_Win_set_errhandler
⚠️ important, bestie: note that MPI does not guarantee that an MPI program can continue past an error. so don't be out here assuming things will just keep vibing after a failure, because they might not, fr fr.

see the MPI man page for a full list of MPI error codes. see the Error Handling section of the MPI-3.1 standard for more information. πŸ“–

see also:

  • MPI_Init
  • MPI_Init_thread
  • MPI_Finalize
  • MPI_Finalized
  • MPI_Session_init
  • MPI_Session_finalize

2003-2026, The Open MPI Community


and that's the whole page, no crumbs left behind πŸ“

Open MPI Β· Sep 10, 2026 Β· MPI_FINALIZED(3) β€” slay, go finalize responsibly, mwah πŸ’…βœ¨πŸ«Ά

πŸ“¦ where this page comes from