MPI_ADD_ERROR_CODE(3)
β¨ MPI_Add_error_code π
okay so bestie, you're reading the MPI_ADD_ERROR_CODE(3) page from the Open MPI manual β¨ congrats, you're in the right place. This one's a lil cutie β it Creates a new error code associated with errorclass. That's the whole vibe. Let's get into it π
π SYNTAX
π©΅ C Syntax
#include <mpi.h>
int MPI_Add_error_code(int errorclass, int *errorcode)
π Fortran Syntax
USE MPI
! or the older form: INCLUDE 'mpif.h'
MPI_ADD_ERROR_CODE(ERRORCLASS, ERRORCODE, IERROR)
INTEGER ERRORCLASS, ERRORCODE, IERROR
π¦ Fortran 2008 Syntax
USE mpi_f08
MPI_Add_error_code(errorclass, errorcode, ierror)
INTEGER, INTENT(IN) :: errorclass
INTEGER, INTENT(OUT) :: errorcode
INTEGER, OPTIONAL, INTENT(OUT) :: ierror
πΈ INPUT PARAMETER
errorclassβ an MPI error class, and it's an integer. That's the thing you're hitching your shiny new error code to π«Ά
π OUTPUT PARAMETERS
errorcodeβ the error code that an MPI routine returns, or an MPI error class (integer). This is where your brand-new code lands β¨ierrorβ Fortran only, bestie: the error status, also an integer π
π DESCRIPTION
So what it does: it creates a new error code that's associated with errorclass, and hands you its value back in errorcode. That's it, that's the whole function. Lowkey elegant, highkey useful π₯
β NOTES
- There's literally no function provided to free error codes, because nobody expects an application to be out here creating them in significant numbers. So don't stress about cleanup β it's not that kind of party π
- the value it gives you back is always greater than or equal to
MPI_ERR_LASTCODE. no cap, always β¬οΈ
π ERRORS
Almost all MPI routines return an error value, jsyk β C routines give it back as the return result of the function, and Fortran routines put it in the last argument π
Before that error value makes its way back to you, the current MPI error handler associated with the communication object (think 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'll call the associated MPI error handler instead. And when MPI_COMM_SELF isn't 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. You can change that initial error handler by calling MPI_Comm_set_errhandler on MPI_COMM_SELF when you're 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. If no other appropriate error handler has been set, then MPI_ERRORS_RETURN gets called for MPI I/O functions, and MPI_ERRORS_ABORT gets called for all the 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. dramatic but make it effective πMPI_ERRORS_ABORTβ an error handler that can be invoked on a communicator, window, file, or session. When it's called on a communicator, it acts as ifMPI_Abortwas called on that communicator. If it's 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 it's called on a session, it aborts only the local process.MPI_ERRORS_RETURNβ Returns an error code to the application. the chill one π§
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. fr fr, plan accordingly π
Also: see the MPI man page for a full list of MPI error codes, and see the Error Handling section of the MPI-3.1 standard for more info π
π SEE ALSO
MPI_Add_error_classMPI_Error_class
π COPYRIGHT
2003-2026, The Open MPI Community π
and that's the page, bestie π written by the Open MPI girlies, dated Sep 11, 2026 β go forth and make your error codes iconic β¨π π¦
π¦ 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