MPI_ADD_ERROR_STRING(3)
π MPI_ADD_ERROR_STRING(3) π
okay so real talk, this is a page from the Open MPI manual and it's about MPI_Add_error_string, a.k.a. the glow-up your error messages deserve β¨ bestie, if you've ever stared at a raw integer error code and thought "girl what does that even mean" β this is the routine for you. let's get into it π«Ά
πΈ NAME πΈ
MPI_Add_error_string β pairs a string with an error code or class. that's it, that's the whole vibe. it's giving "give your errors a personality" π
β¨ SYNTAX β¨
π C Syntax
#include <mpi.h>
int MPI_Add_error_string(int errorcode, const char *string)
π Fortran Syntax
USE MPI
! or the older form: INCLUDE 'mpif.h'
MPI_ADD_ERROR_STRING(ERRORCODE, STRING, IERROR)
INTEGER ERRORCODE, IERROR
CHARACTER*(*) STRING
π Fortran 2008 Syntax
USE mpi_f08
MPI_Add_error_string(errorcode, string, ierror)
INTEGER, INTENT(IN) :: errorcode
CHARACTER(LEN=*), INTENT(IN) :: string
INTEGER, OPTIONAL, INTENT(OUT) :: ierror
like, three whole flavors of syntax? she's versatile, she contains multitudes π
π¦ INPUT PARAMETERS π¦
errorcodeβ an MPI error class, or an error code that came back from an MPI routine (integer). basically the thing you're attaching your little caption to πstringβ the text that corresponds to that error code or class (string). this is the part where you get to be cute about what went wrong π¬
β OUTPUT PARAMETER β
ierrorβ Fortran only, bestie: the error status (integer). C girlies get theirs as the return value, no cap.
π DESCRIPTION π
so this routine associates an error string with an error code or class. simple, iconic, does exactly what it says on the tin π
now here's the tea β if you call MPI_Add_error_string for an error code or class that already has an associated error string, it's not gonna throw a fit. it just replaces the old string with the new one. out with the old, in with the new, main character energy β¨
β οΈ but listen β it is erroneous to callMPI_Add_error_stringfor an error value that was not generated viaMPI_Add_error_classorMPI_Add_error_code. like, for example, an error code or class with a value not greater thanMPI_LAST_ERRCODE. don't do it, bestie, that's not your error to name π«π
π ERRORS π
almost all MPI routines return an error value β C routines hand it back as the return result of the function, and Fortran routines put it in the last argument. classic, iykyk.
before that error value gets returned, the current MPI error handler associated with the communication object (like a communicator, window, or file) gets called. and 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 β 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. that initial error handler can be changed 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 via 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 gets called for MPI I/O functions, and the MPI_ERRORS_ABORT error handler gets called for all other MPI functions. that's just how it is, periodt. π
Open MPI ships with three predefined error handlers you can use:
MPI_ERRORS_ARE_FATALβ causes the program to abort all connected MPI processes. dramatic? yes. effective? also yes π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. and if it's called on a session, it aborts only the local process. flexible queen πMPI_ERRORS_RETURNβ returns an error code to the application. the chill one, the reasonable one, the one you probably want π«Ά
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
DIY icon behavior, honestly π§
β οΈ note that MPI does not guarantee that an MPI program can continue past an error. so like... don't count on it, bestie π
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_Add_error_classMPI_Add_error_codeMPI_Error_classMPI_Error_string
the whole error-handling friend group, go read them too, they're all slay π
π COPYRIGHT π
2003-2026, The Open MPI Community β legends, all of them, we stan π«Ά
and that's the page, bestie!! β¨ this was MPI_ADD_ERROR_STRING(3) from Open MPI, dated Sep 11, 2026 (she's fresh π
). now go forth and give your errors names that actually mean something πΈπ¦π
π¦ 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