MPI_FILE_READ_AT_ALL(3)

πŸ’– MPI_FILE_READ_AT_ALL(3) πŸ’–

okay bestie, you found a page from the Open MPI manual β€” it's the MPI_FILE_READ_AT_ALL(3) one β€” and honestly? it's giving "collective file reading, but make it explicit offsets." let's get into it 🫢

✨ NAME ✨

MPI_File_read_at_all β€” Reads a file at explicitly specified offsets (blocking, collective).


🌸 SYNTAX 🌸

πŸ’… C Syntax

#include <mpi.h>

int MPI_File_read_at_all(MPI_File fh, MPI_Offset offset,
     void *buf, int count, MPI_Datatype datatype,
     MPI_Status *status)

πŸ’… Fortran Syntax

USE MPI
! or the older form: INCLUDE 'mpif.h'
MPI_FILE_READ_AT_ALL(FH, OFFSET, BUF, COUNT,
     DATATYPE, STATUS, IERROR)
     <type>  BUF(*)
     INTEGER FH, COUNT, DATATYPE, STATUS(MPI_STATUS_SIZE), IERROR
     INTEGER(KIND=MPI_OFFSET_KIND)   OFFSET

πŸ’… Fortran 2008 Syntax

USE mpi_f08
MPI_File_read_at_all(fh, offset, buf, count, datatype, status, ierror)
     TYPE(MPI_File), INTENT(IN) :: fh
     INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN) :: offset
     TYPE(*), DIMENSION(..) :: buf
     INTEGER, INTENT(IN) :: count
     TYPE(MPI_Datatype), INTENT(IN) :: datatype
     TYPE(MPI_Status) :: status
     INTEGER, OPTIONAL, INTENT(OUT) :: ierror

πŸŽ€ INPUT PARAMETERS πŸŽ€

  • fh β€” File handle (handle). it's the lil pass you need to get into the file, no cap πŸ’–
  • offset β€” File offset (integer). this is you telling it exactly where to go, main character energy fr ✨
  • count β€” Number of elements in buffer (integer). how many lil guys you want back πŸ“
  • datatype β€” Data type of each buffer element (handle). the vibe/genre of each element πŸ‘‘

🌈 OUTPUT PARAMETERS 🌈

  • buf β€” Initial address of buffer (choice). this is where the goods land, periodt πŸ’…
  • status β€” Status object (status). receipts, basically 🧾
  • ierror β€” Fortran only: Error status (integer). fortran girlies get the error report in the last arg, ikyk 😭

✨ DESCRIPTION ✨

so MPI_File_read_at_all is a collective routine (meaning the whole crew has to show up, no ghosting 🫢) that attempts to read from the file associated with fh β€” at the offset position β€” a total number of count data items having datatype type, right into your buffer buf. iconic behavior honestly.

the offset is in etype units relative to the current view. translation bestie: holes are not counted when locating an offset. like, they're just not part of the math, we ignore them πŸ’€. the data is taken out of those parts of the file specified by the current view.

MPI_File_read_at_all stores the number of datatype elements actually read in status. all other fields of status are undefined β€” so don't go poking around in there expecting answers, it's not the vibe πŸ™ˆ.

⚠️ It is erroneous to call this function if MPI_MODE_SEQUENTIAL mode was specified when the file was opened. like, that's a hard no. do not. fr fr 🚫

πŸ’€ ERRORS πŸ’€

almost all MPI routines return an error value, bestie. C routines hand it back as the return result of the function, and Fortran routines put it in the last argument. that's just how it is.

before that error value comes back, the current MPI error handler associated with the communication object (e.g., communicator, window, file) is called. and if no communication object is associated with the MPI call? then the call is considered attached to MPI_COMM_SELF and it'll call the associated MPI error handler. so it's never just floating, it's always got a home 🏠

when MPI_COMM_SELF is not initialized β€” i.e., before MPI_Init/MPI_Init_thread, after MPI_Finalize, or when using the Sessions Model exclusively β€” the error raises the initial error handler. and that initial error handler can be changed by calling MPI_Comm_set_errhandler on MPI_COMM_SELF when using the World model, or by the mpi_initial_errhandler CLI argument to mpiexec, or by info key to MPI_Comm_spawn/MPI_Comm_spawn_multiple. noted, screenshot taken πŸ“Έ

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. spicy distinction, don't forget it πŸ‘‘

πŸ‘‘ the three predefined error handlers πŸ‘‘

Open MPI includes three predefined error handlers that can be used:

  • MPI_ERRORS_ARE_FATAL β€” Causes the program to abort all connected MPI processes. everyone goes down together, dramatic af 😭
  • 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, 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, aborts only the local process. versatile queen πŸ’…
  • MPI_ERRORS_RETURN β€” Returns an error code to the application. the chill one. hands you the L politely 🫢

πŸ¦‹ roll your own error handler πŸ¦‹

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

basically: create it, then set it. two-step. you got this πŸ’œ

⚠️ Note that MPI does not guarantee that an MPI program can continue past an error. so like… plan accordingly bestie, no cap πŸ’€

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. if you want the deep lore, it's all there πŸ“š


2003-2026, The Open MPI Community


and that's the whole page, bestie β€” you ate πŸ“πŸ’– it's from the Open MPI manual (it lives in section 3, hence the (3)), and this version is dated Sep 10, 2026. go read some files at explicit offsets, you iconic collective queen πŸ‘‘βœ¨ mwah! πŸ’…πŸŒˆ

πŸ“¦ where this page comes from