MPI_FILE_SET_ERRHANDLER(3)
π MPI_File_set_errhandler(3) β the Open MPI glow-up β¨
okay bestie, welcome to the MPI_File_set_errhandler page from the Open MPI manual, section 3. this one's short and sweet but it's giving "important little function that you'll forget about until 2am" energy, so let's lock in π«Ά
πΈ NAME πΈ
MPI_File_set_errhandler β sets the error handler for a file. literally that's it, that's the whole vibe π
β¨ SYNTAX β¨
π C Syntax
#include <mpi.h>
int MPI_File_set_errhandler(MPI_File file, MPI_Errhandler
errhandler)
π¦ Fortran Syntax
USE MPI
! or the older form: INCLUDE 'mpif.h'
MPI_FILE_SET_ERRHANDLER(FILE, ERRHANDLER, IERROR)
INTEGER FILE, ERRHANDLER, IERROR
π Fortran 2008 Syntax
USE mpi_f08
MPI_File_set_errhandler(file, errhandler, ierror)
TYPE(MPI_File), INTENT(IN) :: file
TYPE(MPI_Errhandler), INTENT(IN) :: errhandler
INTEGER, OPTIONAL, INTENT(OUT) :: ierror
note the Fortran 2008 version has ierror as OPTIONAL β she's flexible like that π
π INPUT/OUTPUT PARAMETER
- file β the file handle. that's your file bestie, the main character π¬
π INPUT PARAMETER
- errhandler β the new error handler for the file (it's a handle too, iykyk). this is the whole point of the function, no pressure π
π§ OUTPUT PARAMETER
- ierror β Fortran only: the error status, and yeah it's an integer π
π DESCRIPTION π
so what she does: she attaches a new error handler to a file. that's the tea π΅
and there's a rule, bestie, don't skip it β the error handler must be either:
- a predefined error handler, or
- an error handler created by a call to
MPI_File_create_errhandler
no random off-brand handlers, the vibe check is strict π€
π ERRORS π
okay this is the long part but it's all facts, so stay with me π«Ά
Almost all MPI routines return an error value. C routines return it as the return result of the function, and Fortran routines put it in the last argument. classic.
Before the error value gets returned, the current MPI error handler associated with the communication object (think: communicator, window, file) is called. If there's no communication object associated with the MPI call, then the call is considered attached to MPI_COMM_SELF and will call the associated MPI error handler. π
and here's the little edge case that gets people: when MPI_COMM_SELF is not initialized β like before MPI_Init/MPI_Init_thread, after MPI_Finalize, or when using the Sessions Model exclusively β the error raises the initial error handler. and you can change that initial error handler:
- by calling
MPI_Comm_set_errhandleronMPI_COMM_SELFwhen using the World model, or - with the
mpi_initial_errhandlerCLI argument tompiexec, or - with the 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. periodt. π₯
πΈ the three predefined error handlers that ship with Open MPI πΈ
Open MPI includes three predefined error handlers that can be used:
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 called on a communicator, it acts as ifMPI_Abortwas called on that communicator. if 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 called on a session, it aborts only the local process. context-dependent queen πMPI_ERRORS_RETURNβ returns an error code to the application. the gentle one, the "here's your problem back, you deal with it" one π
π¦ DIY error handlers (yes you can make your own) π¦
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
look at that pipeline, it's giving create-then-set, create-then-set, over and over πβ¨
β οΈ important caveat, do not skip: note that MPI does not guarantee that an MPI program can continue past an error. like, 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 information. ngl the standard is a lot but it's there if you need it π
π COPYRIGHT π
2003-2026, The Open MPI Community π«Ά
and that's the whole page bestie!! short, iconic, and now you know exactly how to give your file a brand new error handler β¨
~ with love, your Open MPI era ~ π
this edition of MPI_FILE_SET_ERRHANDLER(3) dropped Sep 11, 2026, courtesy of the Open MPI crew β slay, and good luck out there π
π¦ 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