MPI_File_read_ordered(3)

πŸ’… NAME πŸ’…

MPI_File_read_ordered β€” it's giving collective read using shared file pointer, bestie. Everyone in the group reads together, in order, and the file pointer is shared. Periodt.


✨ SYNOPSIS ✨

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

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

Two of them! One with int count, one with MPI_Count count (the _c one, obviously, main character energy). Same vibe, bigger count. 🫢


🌸 INPUT PARAMETERS 🌸

  • fh β€” the file handle, bestie. It's a handle. You gotta have the file open before you can read from it, iykyk.
  • count β€” how many elements are chillin' in your buffer. It's an integer.
  • datatype β€” the datatype of each element in your buffer. It's a handle, so like, an actual MPI_Datatype, not vibes.

πŸŽ€ OUTPUT PARAMETERS πŸŽ€

  • buf β€” initial address of the buffer. It's a choice (which is MPI-speak for "it's whatever type you want, queen, we're not picky").
  • status β€” the status object. Type: Status. She holds receipts. πŸ’…

πŸ¦‹ THREAD AND INTERRUPT SAFETY πŸ¦‹

Okay so the good news first: this routine is thread-safe. That means multiple threads can use it at the same time and you do not need to bring your own thread locks. No gatekeeping, no drama. Slay. ✨

But the bad news? She is not interrupt safe. 😭 And typically that's because of memory allocation routines like malloc, or other non-MPICH runtime routines, that are themselves not interrupt-safe. So like β€” not her fault, it's the company she keeps.

Not interrupt safe, bestie. Don't @ me, it's the malloc of it all.

πŸ’œ NOTES FOR FORTRAN πŸ’œ

Fortran girlies, listen up, this part is for you:

  • All MPI routines in Fortran (except MPI_WTIME and MPI_WTICK β€” those two are the exception, don't come for me) have an additional argument ierr tacked onto the end of the argument list. The ierr is an integer and it means the exact same thing as the return value of the routine in C. Same energy, different font.
  • In Fortran, MPI routines are subroutines, and you invoke them with the call statement. That's just how it is over there.
  • All MPI objects β€” like MPI_Datatype and MPI_Comm β€” are of type INTEGER in Fortran. Yes, really. INTEGER. 🧚

πŸ”₯ ERRORS πŸ”₯

Every MPI routine (except MPI_Wtime and MPI_Wtick, the forever exceptions) returns an error value β€” in C it's the return value of the function, and in Fortran it's that last argument we just talked about.

Before that value comes back to you, the current MPI error handler gets called. And by default? That error handler aborts the whole MPI job. Like, everything. Gone. πŸ’€

You can switch the error handler out though:

  • MPI_Comm_set_errhandler β€” for communicators
  • MPI_File_set_errhandler β€” for files
  • MPI_Win_set_errhandler β€” for RMA windows
  • The MPI-1 routine MPI_Errhandler_set may be used, but its use is deprecated. We don't do that anymore, it's not the vibe.

The predefined error handler MPI_ERRORS_RETURN may be used to cause error values to be returned instead. Helpful!

And note (this matters): MPI does not guarantee that an MPI program can continue past an error. However, MPI implementations will attempt to continue whenever possible. So like, sometimes you get to keep going. Sometimes. Fingers crossed. 🀞

Here's the error roster:

  • MPI_SUCCESS β€” No error; MPI routine completed successfully. The dream. The moment. We ate. πŸ‘‘
  • MPI_ERR_ARG β€” Invalid argument. Some argument is invalid and is not identified by a specific error class (e.g., MPI_ERR_RANK). Very "something's wrong but I'm not telling you what" of it.
  • MPI_ERR_BUFFER β€” Invalid buffer pointer. Usually a null buffer where one is not valid. Babygirl, you passed NULL. πŸ™ˆ
  • MPI_ERR_COUNT β€” Invalid count argument. Count arguments must be non-negative; a count of zero is often valid. Negative counts? Not the vibe.
  • 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. Commit your types, bestie, fr fr.
  • MPI_ERR_OTHER β€” Other error; use MPI_Error_string to get more information about this error code. The catch-all. The "miscellaneous" of errors.

🌈 SEE ALSO 🌈

(nothing extra here, so go forth and read, ordered and collective, like the icon you are)


Okay that's literally the whole page, bestie β€” go read something collectively and in order. Stay iconic. πŸ’–

Sign-off tea: this page comes from the MPI manual, and the footer date on it is 4/10/2026, filed under MPI_File_read_ordered(3). K bye! πŸŽ€βœ¨

πŸ“¦ where this page comes from