MPI_FILE_SET_ATOMICITY(3)

✨ NAME ✨

MPI_File_set_atomicity β€” okay so this one sets the consistency semantics for data-access operations, and it's collective babe, don't forget that part πŸ’…

(this is from the Open MPI manual, section 3, and yes we're getting into it)


πŸŽ€ SYNTAX πŸŽ€

C Syntax

#include <mpi.h>

int MPI_File_set_atomicity(MPI_File fh, int flag)

Fortran Syntax

USE MPI
! or the older form: INCLUDE 'mpif.h'
MPI_FILE_SET_ATOMICITY(FH, FLAG, IERROR)
     INTEGER FH, FLAG, IERROR

Fortran 2008 Syntax

USE mpi_f08
MPI_File_set_atomicity(fh, flag, ierror)
     TYPE(MPI_File), INTENT(IN) :: fh
     LOGICAL, INTENT(IN) :: flag
     INTEGER, OPTIONAL, INTENT(OUT) :: ierror

🌸 INPUT PARAMETERS 🌸

  • fh β€” the file handle, bestie. It's a handle. That's the whole vibe. 🫢
  • flag β€” a boolean, and it's giving very binary: true flips on atomic mode, false flips on nonatomic mode. Pick a lane. ✨

πŸ’œ OUTPUT PARAMETER πŸ’œ

  • ierror β€” Fortran only, it's the error status, and it's an integer. That's it. That's the whole output. πŸŽ€

πŸ¦‹ DESCRIPTION πŸ¦‹

So here's the tea β˜•: the consistency semantics for data-access operations β€” using the set of file handles that got created by one collective MPI_File_open β€” get set by collectively calling MPI_File_set_atomicity. Collective. Did I say collective? Collective πŸ’€

Every process in the group has to pass identical values for fh and flag. No side-eyeing, no "I'll pass something different," no main-character nonsense. Everyone agrees or nobody eats.

If flag is true β†’ atomic mode is set. If flag is false β†’ nonatomic mode is set. Simple. Iconic. No cap.

And the default on a call to MPI_File_open in Open MPI? Glad you asked πŸ‘‘ β€” it's true for jobs running on more than one node, and false for jobs running on a single SMP. That's the default, not a suggestion. For more info, go read the MPI-2 standard, it's right there. πŸ“š


πŸ”₯ ERRORS πŸ”₯

Okay so error handling in MPI, buckle up buttercup 😭

Almost all MPI routines return an error value. C routines give it to you as the return result of the function, and Fortran routines park it in the last argument. That's the system. 🫢

Before that error value comes back to you, the current MPI error handler associated with the communication object gets called β€” and "communication object" means things like a communicator, a window, or a file. If there's no communication object associated with the MPI call, then the call counts as attached to MPI_COMM_SELF, and it'll call the associated MPI error handler. And when MPI_COMM_SELF isn't initialized β€” meaning 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 how do you change that initial error handler? Two ways, iykyk:

  • call MPI_Comm_set_errhandler on MPI_COMM_SELF when using the World model, or
  • use the mpi_initial_errhandler CLI argument to mpiexec, or the info key to MPI_Comm_spawn/MPI_Comm_spawn_multiple.

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. Different handlers for different departments, honestly fair. ✨

Open MPI ships three predefined error handlers you can use:

  • MPI_ERRORS_ARE_FATAL β€” causes the program to abort all connected MPI processes. Like, everyone. Gone. πŸ’€
  • 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 β€” just you, bestie, rip. 🫠
  • MPI_ERRORS_RETURN β€” returns an error code to the application. The chill one. The one that lets you handle it. 🌈

MPI applications can also roll 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. Like, fr fr. Don't assume you can just pick yourself up and keep going, because the standard is not promising you that πŸ’€

See the MPI man page for the full list of MPI error codes. And see the Error Handling section of the MPI-3.1 standard for more info. Go read it, it's good for you πŸ“–


2003-2026, The Open MPI Community


and that's the whole page bestie, mwah πŸ’‹ β€” this was MPI_FILE_SET_ATOMICITY(3) from Open MPI, dated Sep 11, 2026, so you know it's fresh πŸŽ€βœ¨πŸ¦‹

πŸ“¦ where this page comes from