MPI_FILE_READ_SHARED(3)

πŸ’– MPI_FILE_READ_SHARED πŸ’–

okay so bestie, you just landed on the MPI_FILE_READ_SHARED page of the Open MPI manual (section 3, the library-call girlies 🫢). Grab a strawberry πŸ“, we're reading files with a shared file pointer and it's lowkey iconic.


✨ NAME ✨

MPI_File_read_shared β€” reads a file using the shared file pointer (blocking, noncollective). πŸ’…


🌸 SYNTAX 🌸

πŸŽ€ C Syntax πŸŽ€

#include <mpi.h>

int MPI_File_read_shared(MPI_File fh, void *buf, int count,
     MPI_Datatype datatype, MPI_Status *status)

πŸŽ€ Fortran Syntax πŸŽ€

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

πŸŽ€ Fortran 2008 Syntax πŸŽ€

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

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

  • fh β€” file handle (handle). yeah she's both an input AND an output situation, main character energy honestly πŸ‘‘

πŸ“₯ INPUT PARAMETERS πŸ“₯

  • count β€” number of elements in the buffer (integer). like, how many lil guys you want 🧚
  • datatype β€” the data type of each buffer element (handle).

πŸ“€ OUTPUT PARAMETERS πŸ“€

  • buf β€” initial address of the buffer (choice).
  • status β€” status object (status).
  • ierror β€” Fortran only: error status (integer).

πŸ¦‹ DESCRIPTION πŸ¦‹

MPI_File_read_shared is a blocking routine that uses the shared file pointer to read files. The way it does that…

and okay, important part, no cap: the order of serialization is not deterministic for this noncollective routine. So don't come for her when the ordering is a little chaotic β€” that's just the vibe. πŸ’€


😭 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 tuck it into the last argument.

Before that error value 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 attached to the MPI call? Then the call is considered attached to MPI_COMM_SELF and it'll call the associated MPI error handler. When MPI_COMM_SELF isn't initialized (i.e., 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 instead.

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 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.

Open MPI ships three predefined error handlers you can use, periodt:

  • MPI_ERRORS_ARE_FATAL β€” causes the program to abort all connected MPI processes. πŸ’€
  • 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.
  • MPI_ERRORS_RETURN β€” returns an error code to the application.

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, she might just not recover, bestie, that's the tea β˜•

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, pookie 🫢 this was MPI_FILE_READ_SHARED(3) from Open MPI, dated Sep 10, 2026 β€” slay, you're officially a shared-file-pointer girly now. go read some files. πŸ’…βœ¨πŸŒˆ

πŸ“¦ where this page comes from