MPI_ADD_ERROR_STRING(3)

πŸ’– MPI_Add_error_string β€” bestie edition πŸ’–

okay so. you know how MPI errors are like "code 47, good luck lol"? this is the girl who fixes that. it's in the Open MPI manual, and it's lowkey iconic.


✨ NAME ✨

MPI_Add_error_string β€” associates a string with an error code or class πŸŽ€


πŸ“œ 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

🌸 INPUT PARAMETERS 🌸

  • errorcode β€” an MPI error class, or an error code that some MPI routine handed back to you (integer). the whole point, fr.
  • string β€” the text that goes with that error code or class (string). your lil label <3

🫢 OUTPUT PARAMETER 🫢

  • ierror β€” Fortran only: error status (integer).

πŸ‘‘ DESCRIPTION πŸ‘‘

this routine associates an error string with an error code or class. that's it. that's the vibe. πŸ¦‹

if you call MPI_Add_error_string for an error code or class that already has an associated error string, it will replace the old string with the new one. glow-up, essentially. old string out, new string in, no drama.

⚠️ bestie listen. it is erroneous to call MPI_Add_error_string for an error value not generated via MPI_Add_error_class or MPI_Add_error_code β€” like, an error code or class with a value not greater than MPI_LAST_ERRCODE. that's not a "haha whoops" situation, that's a no. don't do it. πŸ’€

😭 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.

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.


πŸŽ€ the three predefined error handlers Open MPI ships with πŸŽ€

  • MPI_ERRORS_ARE_FATAL β€” causes the program to abort all connected MPI processes. rip to everyone, collectively.
  • 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, 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, aborts only the local process (just you, solo πŸ’…).
  • MPI_ERRORS_RETURN β€” returns an error code to the application. the chill one.

🌈 roll your own handler 🌈

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

note that MPI does not guarantee that an MPI program can continue past an error. no promises, no cap. 🫠

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_class
  • MPI_Add_error_code
  • MPI_Error_class
  • MPI_Error_string

2003-2026, The Open MPI Community


and that's the whole page, bestie πŸ’– thanks for reading all the way to the end β€” this one was MPI_ADD_ERROR_STRING(3) from Open MPI, dated Sep 10, 2026. slay, go label your errors. πŸŽ€βœ¨πŸ¦‹

πŸ“¦ where this page comes from