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 call MPI_Add_error_string for an error value that was not generated via MPI_Add_error_class or MPI_Add_error_code. like, for example, an error code or class with a value not greater than MPI_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 if MPI_Abort was called on that communicator. if it's called on a window or file, it acts as if MPI_Abort was 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_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

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

the whole error-handling friend group, go read them too, they're all slay πŸ’–


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