MPI_File_write(3)
π MPI_File_write(3) β the MPI_File_write manual page, bestie edition π
okay so real talk: this is page MPI_File_write(3) from the MPI manual set, and it's about writing to a file using the individual file pointer. yes, that individual file pointer. let's get into it πΈ
β¨ NAME β¨
MPI_File_write β write using individual file pointer π
β¨ SYNOPSIS β¨
int MPI_File_write(MPI_File fh, const void *buf, int count,
MPI_Datatype datatype, MPI_Status *status)
int MPI_File_write_c(MPI_File fh, const void *buf, MPI_Count count,
MPI_Datatype datatype, MPI_Status *status)
two flavors, same vibe π«Ά β the plain one takes an int count, and the _c one takes an MPI_Count count for when your counts are getting large and lowkey unhinged. literally keep them exact, i'm not fixing your types for you.
β¨ INPUT PARAMETERS β¨
fhβ the file handle (a handle, mwah) πbufβ initial address of buffer (choice) β¨countβ number of elements in buffer (integer) π’datatypeβ datatype of each buffer element (handle) π¦
π OUTPUT PARAMETERS π
statusβ status object (Status) π
π₯ THREAD AND INTERRUPT SAFETY π₯
slay alert: 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 user-provided thread locks. no gatekeeping, it just works π
but bestieβ¦ 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, thread-safe yes, interrupt-safe no. know the difference fr fr.
π§ NOTES FOR FORTRAN π§
all MPI routines in Fortran (except for MPI_WTIME and MPI_WTICK) get an extra argument ierr tacked onto the end of the argument list. ierr is an integer, and it means the exact same thing as the return value of the routine in C. in Fortran, MPI routines are subroutines and they're invoked with the call statement, periodt.
also: all MPI objects (e.g., MPI_Datatype, MPI_Comm) are of type INTEGER in Fortran. iconic behavior honestly.
π ERRORS π
every MPI routine (except MPI_Wtime and MPI_Wtick) returns an error value β C routines as the return value of the function, Fortran routines in that last argument. and before the value comes back, the current MPI error handler gets called. by default, this error handler aborts the MPI job. π¨ dramatic but true.
you can swap the handler 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 π. and you can use the predefined error handler MPI_ERRORS_RETURN if you'd rather have error values returned instead.
ngl, note that MPI does not guarantee an MPI program can continue past an error. that said, MPI implementations will attempt to continue whenever possible. so likeβ¦ don't count on it bestie π
here's the full error lineup, no skips:
MPI_SUCCESSβ no error; MPI routine completed successfully. β¨MPI_ERR_ARGβ invalid argument. some argument is invalid and isn't 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 uncommittedMPI_Datatype(seeMPI_Type_commit) is used in a communication call. π¦MPI_ERR_OTHERβ other error; useMPI_Error_stringto get more information about this error code. π«Ά
and that's the whole page, no crumbs left π
sign-off time: this was MPI_File_write(3) from the MPI manual, dated 4/10/2026 β go forth, write those files with your individual file pointer, and stay interrupt-unsafe-aware ππ
π¦ where this page comes from
- nixos 26.05: mpich 5.0.1
- ubuntu stonking: mpich-doc 5.0.1-9 Β· other
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms