MPI_File_write_shared(3)
π NAME π
MPI_File_write_shared β bestie, it writes using the shared file pointer β¨
πΈ SYNOPSIS πΈ
int MPI_File_write_shared(MPI_File fh, const void *buf, int count,
MPI_Datatype datatype, MPI_Status *status)
int MPI_File_write_shared_c(MPI_File fh, const void *buf, MPI_Count count,
MPI_Datatype datatype, MPI_Status *status)
like yes, two of them. the _c one is the cool cousin with the MPI_Count count π
β¨ INPUT PARAMETERS β¨
fhβ file handle (handle). it's giving "which file are we even writing to" π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 π«Ά
okay so the good news: this routine is thread-safe. literally means you can use it from multiple threads without bringing your own thread locks, no cap. slay. π
the not-so-good news: it is not interrupt safe. and why? typically because of memory allocation routines like malloc or other non-MPICH runtime routines that are themselves not interrupt-safe. so like, the vibe check fails on interrupts specifically. π
π NOTES FOR FORTRAN π
Fr fr, 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 exactly the same thing as the return value of the routine in C. and in Fortran, MPI routines are subroutines, invoked with the call statement. periodt.
also: all MPI objects (e.g., MPI_Datatype, MPI_Comm) are of type INTEGER in Fortran. remember it. iykyk π
π ERRORS π
so 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, this error handler aborts the MPI job. like, the whole thing. π
you can change the error handler 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 there, but we don't talk about it π
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.
MPI_SUCCESSβ no error; MPI routine completed successfully. we love to see it π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 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.
ok that's the whole page bestie, go forth and write to that shared file pointer ππ§
signing off β¨ this was the MPI manual page for MPI_File_write_shared(3), dated 4/10/2026 β mwah, take care of her ππ
π¦ 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