MPI_COMM_CREATE_ERRHANDLER(3)
π MPI_Comm_create_errhandler β bestie, let's build you a custom error handler π
okay so this is a page from the Open MPI manual, section 3, and it's all about making your very own error handler that you can then attach to communicators. no cap. it's literally called MPI_Comm_create_errhandler and yes, it Creates an error handler that can be attached to communicators. slay.
β¨ SYNTAX β¨
bestie pick your language, they're all iconic π«Ά
π©΅ C Syntax
#include <mpi.h>
int MPI_Comm_create_errhandler(MPI_Comm_errhandler_function *function,
MPI_Errhandler *errhandler)
π Fortran Syntax
USE MPI
! or the older form: INCLUDE 'mpif.h'
MPI_COMM_CREATE_ERRHANDLER(FUNCTION, ERRHANDLER, IERROR)
EXTERNAL FUNCTION
INTEGER ERRHANDLER, IERROR
π¦ Fortran 2008 Syntax
USE mpi_f08
MPI_Comm_create_errhandler(comm_errhandler_fn, errhandler, ierror)
PROCEDURE(MPI_Comm_errhandler_function) :: comm_errhandler_fn
TYPE(MPI_Errhandler), INTENT(OUT) :: errhandler
INTEGER, OPTIONAL, INTENT(OUT) :: ierror
πΈ DEPRECATED TYPE NAME NOTE πΈ
so MPI-2.2 deprecated the MPI_Comm_errhandler_fn type in favor of MPI_Comm_errhandler_function. the glow-up was real π
. and good news: Open MPI supports both names β indeed, the _fn names are typedefs to the _function names. so nobody's getting left behind, we love a backwards-compatible queen π
π INPUT PARAMETER π
functionβ your user-defined error handling procedure (a function). it's yours, you wrote it, main character energy fr fr β¨
π OUTPUT PARAMETERS π
errhandlerβ the MPI error handler (a handle). this is the little treasure you requested and now get to keep πierrorβ Fortran only: error status (an integer). Fortran besties get an extra lil status field, periodt.
π DESCRIPTION π
MPI_Comm_create_errhandler creates an error handler that can be attached to communicators. it is identical to MPI_Errhandler_create, the use of which is deprecated. so like, same vibe, but the older one is giving "2010 Facebook post" and we've moved on πΆβοΈ
ngl there's a small thing you gotta know about each language:
in C, your user routine should be a function of type MPI_Comm_errhandler_function, which is defined as
typedef void MPI_Comm_errhandler_function(MPI_Comm *, int *, ...);
- the first argument is the communicator in use.
- the second is the error code to be returned by the MPI routine that raised the error.
and the way that this typedef replaces MPI_Handler_function β whose use is also deprecated. out with the old π§Ήβ¨
in Fortran, your user routine should be of this form:
SUBROUTINE COMM_ERRHANDLER_FUNCTION(COMM, ERROR_CODE, ...)
INTEGER COMM, ERROR_CODE
π ERRORS π
bestie, listen up, this part is lowkey important.
Almost all MPI routines return an error value; C routines as the return result of the function and Fortran routines in the last argument. so like, check it, okay?
Before the error value is returned, the current MPI error handler associated with the communication object (e.g., communicator, window, file) is called. If no communication object is associated with the MPI call, then the call is considered attached to MPI_COMM_SELF and will call the associated MPI error handler. When MPI_COMM_SELF is not initialized (i.e., before MPI_Init/MPI_Init_thread, after MPI_Finalize, or when 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 the mpi_initial_errhandler CLI argument to mpiexec or info key to MPI_Comm_spawn/MPI_Comm_spawn_multiple. If no other appropriate error handler has been set, then the MPI_ERRORS_RETURN error handler is called for MPI I/O functions and the MPI_ERRORS_ABORT error handler is called for all other MPI functions.
π¨ okay so lowkey terrifying but: Note that MPI does not guarantee that an MPI program can continue past an error. it's giving "we'll see", not "you're fine". do not sleep on that. π
Open MPI includes three predefined error handlers that can be used:
MPI_ERRORS_ARE_FATALβ Causes the program to abort all connected MPI processes. π yea. everything. gone.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, acts as ifMPI_Abortwas called on a communicator containing the group of processes in the corresponding window or file. If called on a session, aborts only the local process. so like, context-aware king πMPI_ERRORS_RETURNβ Returns an error code to the application. the polite one. the "here's your receipt, handle it yourself" icon π§Ύ
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
so whichever flavor of object you're on β comm, file, session, window β there's a create/set duo waiting for you. pick your fighter π₯
if you want the full list of MPI error codes, go see the MPI man page. and for more actual details, see the Error Handling section of the MPI-3.1 standard. iykyk, the standard is where the lore lives πβ¨
π«Ά SEE ALSO π«Ά
MPI_Errhandler_createMPI_InitMPI_Init_threadMPI_FinalizeMPI_Comm_set_errhandlerMPI_Comm_spawnMPI_Comm_spawn_multipleMPI_AbortMPI_File_create_errhandlerMPI_File_set_errhandlerMPI_Session_create_errhandlerMPI_Session_set_errhandlerMPI_Session_initMPI_Win_create_errhandlerMPI_Win_set_errhandler- the MPI man page (full list of MPI error codes)
- the Error Handling section of the MPI-3.1 standard
π Copyright π
2003-2026, The Open MPI Community β protect them at all costs, they keep the vibes running π
and that's the whole page bestie!! π this was MPI_COMM_CREATE_ERRHANDLER(3) from the Open MPI manual, dated Sep 10, 2026. tysm for reading, go forth and handle your errors with grace and a cute little subroutine, mwah ππβ¨
π¦ where this page comes from
- ubuntu stonking: openmpi-doc 5.0.10-6 Β· other
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms