MPI_File_read_shared(3)

πŸ’– MPI_File_read_shared β€” the shared-file-pointer read glow-up πŸ’–

okay bestie, so this one lives in the MPI manual, section 3 (MPI_File_read_shared(3)), and it's literally just: read stuff using the shared file pointer. that's the whole vibe. no cap.


✨ NAME ✨

MPI_File_read_shared β€” read using the shared file pointer πŸ¦‹


πŸŽ€ SYNOPSIS πŸŽ€

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

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

two flavours, same energy. pick your count type and go πŸ’…


🌸 INPUT PARAMETERS 🌸

  • fh β€” the file handle, fr fr. type: handle.
  • count β€” how many elements are chillin' in the buffer. type: integer.
  • datatype β€” the datatype of each buffer element. type: handle. yes it's a handle, not a type-type, don't @ me.

πŸ’œ OUTPUT PARAMETERS πŸ’œ

  • buf β€” the initial address of the buffer. type: choice.
  • status β€” the status object, holding the receipts. type: Status.

🫢 THREAD AND INTERRUPT SAFETY 🫢

this routine is thread-safe. meaning: multiple threads can use it and you do not need to bring your own thread locks, bestie, it handles itself. main character energy.

but 🚨 it is not interrupt safe. typically that's because it calls memory allocation routines like malloc, or other non-MPICH runtime routines, and those are themselves not interrupt-safe. so like, respect the boundary, ok?


🧚 NOTES FOR FORTRAN 🧚

  • every MPI routine in Fortran (except for MPI_WTIME and MPI_WTICK) has an extra argument ierr tacked onto the end of the argument list. ierr is an integer and means the exact same thing as the return value of the routine in C. in Fortran, MPI routines are subroutines, and you invoke them with the call statement.
  • every MPI object (e.g., MPI_Datatype, MPI_Comm) is of type INTEGER in Fortran. iconic honestly.

πŸ‘‘ ERRORS πŸ‘‘

all MPI routines (except MPI_Wtime and MPI_Wtick) return an error value β€” C routines as the value of the function, and Fortran routines in that last argument. before the value comes back, the current MPI error handler gets called. by default, that error handler aborts the MPI job 😭 (dramatic? yes. accurate? also yes.)

the error handler can be swapped out with MPI_Comm_set_errhandler (for communicators), MPI_File_set_errhandler (for files), and MPI_Win_set_errhandler (for RMA windows). the MPI-1 routine MPI_Errhandler_set may be used but its use is deprecated β€” retired, past its era, we don't do that anymore. the predefined error handler MPI_ERRORS_RETURN may be used to cause error values to be returned.

note that MPI does not guarantee that an MPI program can continue past an error. however, MPI implementations will attempt to continue whenever possible. so like… try, bestie. but don't count on it πŸ’€

the error codes, one by one, no skipping:

  • MPI_SUCCESS β€” no error; MPI routine completed successfully. the slay outcome ✨
  • MPI_ERR_ARG β€” invalid argument. some argument is invalid and is not identified by a specific error class (e.g., MPI_ERR_RANK).
  • MPI_ERR_BUFFER β€” invalid buffer pointer. usually a null buffer where one is not valid.
  • MPI_ERR_COUNT β€” invalid count argument. count arguments must be non-negative; a count of zero is often valid.
  • MPI_ERR_TYPE β€” invalid datatype argument. additionally, this error can occur if an uncommitted MPI_Datatype (see MPI_Type_commit) is used in a communication call.
  • MPI_ERR_OTHER β€” other error; use MPI_Error_string to get more information about this error code.

that's the whole page, no notes πŸŽ€ go read some files with your shared pointer and be iconic about it πŸ’–πŸŒˆβ­

this was MPI manual, MPI_File_read_shared(3), dated 4/10/2026. periodt. πŸ¦‹πŸ’…

πŸ“¦ where this page comes from