MPI_FILE_GET_AMODE(3)

πŸ’… MPI_FILE_GET_AMODE(3) β€” an Open MPI moment πŸ’…

okay so bestie, welcome to the MPI_FILE_GET_AMODE(3) page from the Open MPI manual set β€” yes, the whole manual, she's iconic. this one's a little function with big "just tell me how you opened the file" energy and honestly? we love her for it.

✨ SYNOPSIS ✨

🌸 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 β€” the file handle, aka your lil file's passport. type: handle. she's giving "I already know this file, I just need the receipt".

πŸ’– OUTPUT PARAMETERS πŸ’–

  • amode β€” the file access mode that was used to open the file. type: integer. this is literally the answer to "so what mode were we in, bestie?" πŸŽ€
  • ierror β€” Fortran only, sorry C girlies: the error status. type: integer.

🌈 DESCRIPTION 🌈

so MPI_File_get_amode returns, in amode, the access mode associated with the open file fh. that's it. that's the whole vibe. it's a getter. she gets. periodt. ✨


πŸ’€ ERRORS πŸ’€

okay buckle up because this section is the main character of the page. almost all MPI routines return an error value β€” C routines hand it back as the return value of the function, and Fortran routines drop it in that last argument. not me being consistent across languages, we love to see it πŸ’…

before that error value even shows up, the current MPI error handler associated with the communication object (like, a communicator, window, or file, iykyk) gets called. and if there's no communication object associated with the MPI call? then the call is considered attached to MPI_COMM_SELF and it calls the associated MPI error handler. when MPI_COMM_SELF is not 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 you can change that initial error handler! by calling MPI_Comm_set_errhandler on MPI_COMM_SELF when 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. so many options, so much power 🧚

and 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. just so we're clear on who's catching what πŸ“

Open MPI includes three predefined error handlers you can use:

  • MPI_ERRORS_ARE_FATAL β€” causes the program to abort all connected MPI processes. yeah. everyone. gone. πŸ’€
  • 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 if MPI_Abort was called on that communicator. if 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 called on a session, it aborts only the local process. context-aware queen πŸ‘‘
  • MPI_ERRORS_RETURN β€” returns an error code to the application. the chill one. the "here's your problem, handle it yourself" one 🫢

MPI applications can also 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
⚠️ note that MPI does not guarantee that an MPI program can continue past an error. like, no promises bestie. none. πŸ™ˆ

see the MPI man page for a full list of MPI error codes β€” that's where the lore lives. and see the Error Handling section of the MPI-3.1 standard for more information, if you're the kind of girl who reads the standard. (respect.)


2003-2026, The Open MPI Community.


and that's the whole page, bestie! this masterpiece was served up to you on Sep 11, 2026 by the one and only Open MPI β€” go forth and get those access modes πŸ’œπŸ¦‹βœ¨

πŸ“¦ where this page comes from