MPI_FILE_GET_AMODE(3)

πŸ’– MPI_FILE_GET_AMODE(3) β€” Open MPI πŸ’–

okay bestie, welcome to the MPI_FILE_GET_AMODE(3) page, brought to you by your friends at Open MPI ✨


🌸 NAME 🌸

MPI_File_get_amode β€” literally just returns the access mode associated with an open file. that's it. that's the whole job. and she eats every time πŸ’…


πŸ¦‹ SYNTAX πŸ¦‹

✨ C Syntax

#include <mpi.h>

int MPI_File_get_amode(MPI_File fh, int *amode)

✨ Fortran Syntax

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

✨ Fortran 2008 Syntax

USE mpi_f08
MPI_File_get_amode(fh, amode, ierror)
     TYPE(MPI_File), INTENT(IN) :: fh
     INTEGER, INTENT(OUT) :: amode
     INTEGER, OPTIONAL, INTENT(OUT) :: ierror

πŸŽ€ INPUT PARAMETER πŸŽ€

  • fh β€” bestie, this is the file handle (handle). the lil key you pass in so she knows which file we're talking about πŸ’–

🫢 OUTPUT PARAMETERS 🫢

  • amode β€” the file access mode that was used to open the file (integer). she's gonna drop it right in there for you ✨
  • ierror β€” Fortran only: error status (integer). no cap, that's just for the Fortran girlies.

πŸ‘‘ DESCRIPTION πŸ‘‘

MPI_File_get_amode returns, in amode, the access mode associated with the open file fh. periodt. she tells you how that file was opened, and she tells you with zero drama πŸ’…


πŸ’€ ERRORS πŸ’€

ngl, 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 that last argument. iconic behavior tbh.

Before the error value is even returned, the current MPI error handler associated with the communication object (like a communicator, window, or file β€” iykyk) gets called. And listen: if there's no communication object associated with the MPI call, then the call counts as being attached to MPI_COMM_SELF and it'll call the MPI error handler associated with that. When MPI_COMM_SELF isn't initialized β€” like before MPI_Init/MPI_Init_thread, after MPI_Finalize, or when you're running the Sessions Model exclusively β€” the error raises the initial error handler. 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 the info key to MPI_Comm_spawn/MPI_Comm_spawn_multiple. And if literally 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 the other MPI functions. yes really. 😭

Open MPI ships three predefined error handlers you can use, and they are:

  • MPI_ERRORS_ARE_FATAL β€” causes the program to abort all connected MPI processes. so… nuclear. πŸ’€
  • MPI_ERRORS_ABORT β€” an error handler you can invoke 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. she's selective, okay? πŸ’…
  • MPI_ERRORS_RETURN β€” returns an error code to the application. the chill one. the lowkey one. 🫢

MPI applications can also go full DIY and 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
⚠️ heads up bestie: MPI does not guarantee that an MPI program can continue past an error. fr fr, plan accordingly.

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 vibe check, bestie πŸ¦‹ this page came from the Open MPI crew and it's dated Sep 10, 2026 β€” go forth, read your access modes, and slay πŸ’–βœ¨πŸŽ€πŸŒˆπŸ‘‘

πŸ“¦ where this page comes from