MPI_Comm_ser_errhandler(3)
π MPI_Comm_ser_errhandler(3) β the LAM/MPI era β¨
okay bestie, so this is a page from the LAM/MPI manual, and it's about setting who handles your communicator's oopsies. yes the title says MPI_Comm_ser_errhandler and the actual function is MPI_Comm_set_errhandler β that typo has been living here rent free since forever, we don't fix it, we just love it. π
πΈ NAME πΈ
MPI_Comm_ser_errhandler β set error handler of communicator
fr fr that's the whole job: pick who deals with the drama when your communicator misbehaves.
β¨ SYNOPSIS β¨
#include <mpi.h>
int
MPI_Comm_set_errhandler(MPI_Comm comm, MPI_Errhandler errhdl)
look at her. so simple. so iconic. π
π INPUT PARAMETER π
commβ Communicator. the little social circle we're attaching a handler to.
π«Ά OUTPUT PARAMETER π«Ά
errhdlβ Error Handler. yes bestie, it's listed as an output parameter here, we're just reporting the page exactly as it is. that's the handler in question.
π¦ NOTES FOR FORTRAN π¦
so here's the tea for the Fortran girlies:
- every single MPI routine in Fortran has an extra argument called
ierrtacked onto the end of the argument list β the only exceptions areMPI_WTIMEandMPI_WTICK.ierris an integer and it means exactly the same thing as the return value of the routine in C. no cap. - in Fortran, MPI routines are subroutines, and you invoke them with the
callstatement. - all MPI objects (like
MPI_Datatype,MPI_Comm) are of typeINTEGERin Fortran. periodt.
π ERRORS π
when an error happens inside an MPI function, the current MPI error handler gets called to deal with it. by default? that handler aborts the whole MPI job. π dramatic but true.
you can swap it out with MPI_Errhandler_set, and you can use the predefined handler MPI_ERRORS_RETURN if you'd rather have error values handed back to you (works in C and Fortran; it's less useful with the C++ MPI bindings β for C++, use the predefined MPI::ERRORS_THROW_EXCEPTIONS if you actually need to recover the error value). and ngl, MPI does not guarantee that an MPI program can keep going after an error. that's not a vibe, that's just the rules.
now, error-value housekeeping:
- all MPI routines (except
MPI_WtimeandMPI_Wtick) return an error value. C routines return it as the function's value; Fortran routines put it in that last argument. - the C++ bindings for MPI do not return error values. instead, error values are communicated by throwing exceptions of type
MPI::Exceptionβ but not by default. exceptions are only thrown if the error value is notMPI::SUCCESS. - > heads up bestie: if
MPI::ERRORS_RETURNis set in C++, MPI functions will return on an error, but there is literally no way to recover what the actual error value was. gone. lost to the void. π
and here are the actual error codes:
MPI_SUCCESSβ no error; the MPI routine completed successfully. slay. β¨MPI_ERR_COMMβ invalid communicator. a common way to land here is using a null communicator in a call β which isn't even allowed inMPI_Comm_rank, so don't try it.MPI_ERR_ARGβ invalid argument. some argument is invalid and isn't identified by a specific error class. typically this is a NULL pointer or other such error.
π SEE ALSO π
go read those too, they're the rest of the friend group. π«Ά
π MORE INFORMATION π
want the deep lore? the official MPI Forum web site has the full text of both the MPI-1 and MPI-2 standards. those documents contain detailed information about every MPI function β most of which is not duplicated in these man pages, so if you're a completionist, that's your stop:
http://www.mpi-forum.org/
π LOCATION π
cseterr.c
and that's the whole page, bestie. this one shipped as part of LAM/MPI 7.1.4, dated 6/24/2006 β vintage, honestly. mwah. π β¨
π¦ where this page comes from
- debian bookworm: lam4-dev 7.1.4-7+b1
- debian trixie: lam4-dev 7.1.4-7.2
- ubuntu jammy: lam4-dev 7.1.4-7
- ubuntu noble: lam4-dev 7.1.4-7.1build2
- ubuntu questing: lam4-dev 7.1.4-8
- ubuntu resolute: lam4-dev 7.1.4-8build1
- ubuntu stonking: lam4-dev 7.1.4-8build1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms