MPI_File_write_at(3)

πŸ’– MPI_File_write_at πŸ’–

okay bestie, welcome to the MPI manual, page MPI_File_write_at(3) β€” yes that's the whole manual name, we're fancy like that πŸ’…


✨ NAME ✨

MPI_File_write_at β€” write using explicit offset πŸ¦‹


🌸 SYNOPSIS 🌸

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

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

no cap, that's literally the whole thing. two whole signatures, both iconic ✨


πŸŽ€ INPUT PARAMETERS πŸŽ€

okay so here's what you gotta hand over, bestie:

  • fh β€” the file handle (a handle, obviously πŸ’…). it's giving "which file are we even talking about" energy.
  • offset β€” the file offset (integer). this is the explicit offset. that's the whole vibe of this function fr fr.
  • buf β€” initial address of the buffer (choice). where your little bytes live before they go on their journey πŸ₯Ί
  • count β€” number of elements in the buffer (integer). how many. count them. πŸ”₯
  • datatype β€” datatype of each buffer element (handle). yes each one has a type, we're not animals 🌈

πŸ‘‘ OUTPUT PARAMETERS πŸ‘‘

  • status β€” status object (Status). it comes back with the tea β˜•

πŸ’œ THREAD AND INTERRUPT SAFETY πŸ’œ

okay so the good news: this routine is thread-safe. meaning what? meaning multiple threads can use it at the same time and you do not need to bring your own thread locks. no user-provided thread locks, zero, none, you can leave them at home 🫢 slay.

the bad news, and I'm gonna need you to sit down: it is not interrupt safe. 😭

typically this is because of memory allocation routines like malloc, or other non-MPICH runtime routines that are themselves not interrupt-safe. so like... it's the malloc's fault, not hers πŸ’€ periodt.


🧚 NOTES FOR FORTRAN 🧚

bestie, Fortran girlies get a little extra garnish ✨

  • All MPI routines in Fortran (except for MPI_WTIME and MPI_WTICK) have an additional argument ierr at the end of the argument list. ierr is an integer and has the same meaning as the return value of the routine in C. (yes. same meaning. she's bilingual πŸ’…)
  • In Fortran, MPI routines are subroutines, and they're invoked with the call statement. call her by her name 🎀
  • All MPI objects (e.g., MPI_Datatype, MPI_Comm) are of type INTEGER in Fortran. every single one. no exceptions. 🌸

😭 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 the last argument. Before the value is returned, the current MPI error handler is called. By default, this error handler aborts the MPI job (dramatic, I know πŸ’€).

The error handler may be changed 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 β€” like, it's still here but it's not the moment, okay? πŸ™ˆ

The predefined error handler MPI_ERRORS_RETURN may be used to cause error values to be returned instead. Note that MPI does not guarantee that an MPI program can continue past an error; however, MPI implementations will attempt to continue whenever possible. (they're trying their best, bestie 🫢)

here's the error roster, the whole cast πŸ‘‘

  • MPI_SUCCESS β€” no error; MPI routine completed successfully. ate and left no crumbs βœ…
  • 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. not the null buffer in the club πŸ’€
  • MPI_ERR_COUNT β€” invalid count argument. count arguments must be non-negative; a count of zero is often valid. so zero is fine, negative is not, got it πŸ“
  • 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 or don't show up 😀
  • MPI_ERR_OTHER β€” other error; use MPI_Error_string to get more information about this error code. the mystery box of errors 🎁

and that's the whole page, bestie!! go write some bytes at an explicit offset, you absolute main character πŸ‘‘

mwah πŸ’‹ β€” this was the MPI manual's MPI_File_write_at(3) page, dated 4/10/2026. version vibes: MPI. bye pookie πŸ¦‹

πŸ“¦ where this page comes from