MPI_COMM_SET_ERRHANDLER(3)
π MPI_COMM_SET_ERRHANDLER π
okay bestie, welcome to the MPI_Comm_set_errhandler page from the Open MPI manual, 3rd section (that's the <pink>(3)</pink>, iykyk β library calls live there). this one's short and sweet: it's literally about attaching a new error handler to a communicator. main character energy for error handling, fr fr.
β¨ NAME β¨
MPI_Comm_set_errhandler β attaches a new error handler to a communicator. that's it, that's the whole vibe. π
β¨ SYNTAX β¨
πΈ C Syntax
#include <mpi.h>
int MPI_Comm_set_errhandler(MPI_Comm comm,
MPI_Errhandler errhandler)
πΈ Fortran Syntax
USE MPI
! or the older form: INCLUDE 'mpif.h'
MPI_COMM_SET_ERRHANDLER(COMM, ERRHANDLER, IERROR)
INTEGER COMM, ERRHANDLER, IERROR
πΈ Fortran 2008 Syntax
USE mpi_f08
MPI_Comm_set_errhandler(comm, errhandler, ierror)
TYPE(MPI_Comm), INTENT(IN) :: comm
TYPE(MPI_Errhandler), INTENT(IN) :: errhandler
INTEGER, OPTIONAL, INTENT(OUT) :: ierror
β¨ INPUT/OUTPUT PARAMETER β¨
commβ the communicator, bestie. it's a handle. π«Ά
β¨ OUTPUT PARAMETERS β¨
errhandlerβ the new error handler for the communicator (handle). yes, it's listed under output parameters in the man page even though it's the thing you're setting β not me, the docs said it. πierrorβ Fortran only: error status (integer).
β¨ DESCRIPTION β¨
so <purple>MPI_Comm_set_errhandler</purple> attaches a new error handler to a communicator. two rules, no cap:
- the error handler has to be either a predefined error handler
- or an error handler you made with a call to
<cyan>MPI_Comm_create_errhandler</cyan>
and the tea: this call is identical to <cyan>MPI_Errhandler_set</cyan>, the use of which is deprecated. so likeβ¦ use this one, not that one. periodt. π
β¨ ERRORS β¨
almost all MPI routines return an error value, okay? in C it's the return result of the function, and in Fortran it lands in the last argument.
before that error value comes back, the current MPI error handler associated with the communication object (think: communicator, window, file) gets called. and if there's no communication object associated with the MPI call? then the call is considered attached to <hotpink>MPI_COMM_SELF</hotpink> and it'll call the associated MPI error handler. π
now, when MPI_COMM_SELF is not initialized β that's 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. and you can change that initial error handler by:
- calling
MPI_Comm_set_errhandleronMPI_COMM_SELFwhen using the World model, or - the
mpi_initial_errhandlerCLI argument tompiexec, or the info key toMPI_Comm_spawn/MPI_Comm_spawn_multiple
if no other appropriate error handler has been set, then:
- the
<blue>MPI_ERRORS_RETURN</blue>error handler is called for MPI I/O functions - and the
<red>MPI_ERRORS_ABORT</red>error handler is called for all other MPI functions
π the three predefined error handlers in Open MPI π
Open MPI includes three predefined error handlers that can be used β here's the lineup:
MPI_ERRORS_ARE_FATALβ causes the program to abort all connected MPI processes. dramatic, but make it fatal. π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 ifMPI_Abortwas called on that communicator. if called on a window or file, it acts as ifMPI_Abortwas 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. situational awareness, slay. π₯MPI_ERRORS_RETURNβ returns an error code to the application. polite. respectful. π
π¦ rolling your own π¦
MPI applications can also implement their own error handlers by calling:
MPI_Comm_create_errhandlerthenMPI_Comm_set_errhandlerMPI_File_create_errhandlerthenMPI_File_set_errhandlerMPI_Session_create_errhandlerthenMPI_Session_set_errhandleror atMPI_Session_initMPI_Win_create_errhandlerthenMPI_Win_set_errhandler
β οΈ note that MPI does not guarantee that an MPI program can continue past an error. like, don't build your whole architecture on the assumption that it will. not the move. π
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_Comm_create_errhandlerMPI_Comm_get_errhandler
β¨ COPYRIGHT β¨
2003-2026, The Open MPI Community π
and that's the page, bestie β this one's dated Sep 11, 2026, straight from the Open MPI crew, and yes both of those things go together in the footer like a little friendship bracelet: the copyright line up top, the date down below. π«Άβ¨ go set some errhandlers, you've got this. π
π¦ where this page comes from
- arch rolling: openmpi 5.0.11-1 Β· BSD-3-Clause AND LicenseRef-MPICH
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms