MPI_WIN_SET_ERRHANDLER(3)

πŸ’– MPI_Win_set_errhandler β€” Open MPI πŸ’–

okay so bestie, this is the Open MPI man page for MPI_Win_set_errhandler, and it does exactly one thing: it glues a brand-new error handler onto a window. That's it. That's the whole personality. ✨


🌸 SYNTAX 🌸

C Syntax

#include <mpi.h>

int MPI_Win_set_errhandler(MPI_Win win, MPI_Errhandler errhandler)

Fortran Syntax

USE MPI
! or the older form: INCLUDE 'mpif.h'
MPI_WIN_SET_ERRHANDLER(WIN, ERRHANDLER, IERROR)
     INTEGER WIN, ERRHANDLER, IERROR

Fortran 2008 Syntax

USE mpi_f08
MPI_Win_set_errhandler(win, errhandler, ierror)
     TYPE(MPI_Win), INTENT(IN) :: win
     TYPE(MPI_Errhandler), INTENT(IN) :: errhandler
     INTEGER, OPTIONAL, INTENT(OUT) :: ierror

πŸ”„ INPUT/OUTPUT PARAMETER πŸ”„

  • win β€” the window, as a handle. (yes it's both input and output coded, that's just how the standard labels it, don't come for me πŸ’…)

πŸŽ€ INPUT PARAMETER πŸŽ€

  • errhandler β€” the shiny new error handler you're assigning to this window (a handle).

πŸ“€ OUTPUT PARAMETER πŸ“€

  • ierror β€” Fortran only: the error status, as an integer. (C girlies get their error as the return value instead, slay)

πŸ“– DESCRIPTION πŸ“–

MPI_Win_set_errhandler attaches a new error handler to a window. That's the vibe. πŸ¦‹

And there's a rule here, bestie, don't skip it: the error handler you pass must be either a predefined error handler, or one you made yourself by calling MPI_Win_create_errhandler. No random handles, no homemade structs, no "it's giving error handler" energy. It's got to be one of those two. periodt.


πŸ’€ ERRORS πŸ’€

Almost all MPI routines return an error value. C routines hand it back as the return result of the function, and Fortran routines stash it in that last argument. fr fr.

Before that error value ever gets returned, the current MPI error handler associated with the communication object (think: communicator, window, file) gets called. And if there's no communication object associated with the MPI call at all? Then the call is considered attached to MPI_COMM_SELF and it'll call the MPI error handler attached to that. 🌈

Now here's the part where you have to pay attention πŸ‘€ β€” when MPI_COMM_SELF is not initialized (that means 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. And you can change that initial error handler:

  • 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 MPI_ERRORS_RETURN gets called for MPI I/O functions, and MPI_ERRORS_ABORT gets called for all other MPI functions. That's the default lore. πŸ“œ

Open MPI ships three predefined error handlers you can use:

  • MPI_ERRORS_ARE_FATAL β€” causes the program to abort all connected MPI processes. yes, all of them. dramatic but effective πŸ’€
  • 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. If it's called on a session, it aborts only the local process. 🫢
  • MPI_ERRORS_RETURN β€” returns an error code to the application. the chill one.

MPI applications can also implement their own error handlers by calling:

  • MPI_Comm_create_errhandler and then MPI_Comm_set_errhandler
  • MPI_File_create_errhandler and then MPI_File_set_errhandler
  • MPI_Session_create_errhandler and then MPI_Session_set_errhandler, or at MPI_Session_init
  • MPI_Win_create_errhandler and then MPI_Win_set_errhandler (hey, that's this one!! you're literally reading it πŸ’–)
⚠️ Note that MPI does not guarantee that an MPI program can continue past an error. Like, don't assume. It's not promised. 😭

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.


2003-2026, The Open MPI Community


and that's the whole page bestie, you ate it up πŸ“ stay hydrated, set your errhandlers responsibly, and remember: error handlers are not a personality trait, they're a lifestyle πŸ§šπŸ’œ

β€” with love, from the Open MPI girlies, version dated Sep 10, 2026, MPI_WIN_SET_ERRHANDLER(3), mwah πŸ’…

πŸ“¦ where this page comes from