MPI_FILE_WRITE_SHARED(3)
π MPI_FILE_WRITE_SHARED(3) β like, the Open MPI manual page, section 3, but make it make sense π«Ά
okay bestie, so this is the Open MPI page for MPI_File_write_shared, and yes it's a whole mouthful but we're gonna get through it together. grab a lil snack π
β¨ NAME β¨
MPI_File_write_shared β writes to a file using the shared file pointer. It's blocking, and it's noncollective. that's the whole vibe. π
π SYNTAX π
π C Syntax
#include <mpi.h>
int MPI_File_write_shared(MPI_File fh, const void *buf, int count,
MPI_Datatype datatype, MPI_Status *status)
π¦ Fortran Syntax
USE MPI
! or the older form: INCLUDE 'mpif.h'
MPI_FILE_WRITE_SHARED(FH, BUF, COUNT, DATATYPE, STATUS, IERROR)
<type> BUF(*)
INTEGER FH, COUNT, DATATYPE, STATUS(MPI_STATUS_SIZE), IERROR
π Fortran 2008 Syntax
USE mpi_f08
MPI_File_write_shared(fh, buf, count, datatype, status, ierror)
TYPE(MPI_File), INTENT(IN) :: fh
TYPE(*), DIMENSION(..), INTENT(IN) :: buf
INTEGER, INTENT(IN) :: count
TYPE(MPI_Datatype), INTENT(IN) :: datatype
TYPE(MPI_Status) :: status
INTEGER, OPTIONAL, INTENT(OUT) :: ierror
π INPUT/OUTPUT PARAMETER π
fhβ the file handle, bestie. it's a handle. (the file one, not the lil "handle this" one π)
π₯ INPUT PARAMETERS π₯
bufβ the initial address of your buffer. it's a choice, so pick one, we love options β¨countβ how many elements are chillin' in that buffer (integer, no decimals, don't try it)datatypeβ the data type of each element in the buffer (handle). yes every single element has one, consistent queen π
π€ OUTPUT PARAMETERS π€
statusβ the status object. it's giving "here's what happened" (status)ierrorβ Fortran only: the error status (integer). C girlies, you get your error as the return value instead π
π£οΈ DESCRIPTION π£οΈ
so. MPI_File_write_shared is a blocking routine that writes files using the shared file pointer. that's the entire plot.
but here's the tea β β because this is a noncollective routine, the order of serialization is not deterministic. like, at all. nobody can promise you who writes first. it's giving group chat at 2am, everyone typing at once, nobody knowing whose message lands where π
π ERRORS π
okay so, literally almost every MPI routine returns an error value. C routines hand it back as the return result of the function, and Fortran routines tuck it into the last argument. classic.
before that error value comes back home, the current MPI error handler associated with the communication object (think: communicator, window, file) gets called. and if there's no communication object associated with the MPI call? then the call is considered attached to MPI_COMM_SELF and calls the associated MPI error handler. yep.
when MPI_COMM_SELF isn't initialized (i.e. before MPI_Init/MPI_Init_thread, after MPI_Finalize, or when using the Sessions Model exclusively), the error raises the initial error handler. and you can change that initial error handler:
- by calling
MPI_Comm_set_errhandleronMPI_COMM_SELFwhen using the World model, or - the
mpi_initial_errhandlerCLI argument tompiexec, or - an info key to
MPI_Comm_spawn/MPI_Comm_spawn_multiple.
and if no other appropriate error handler has been set? then MPI_ERRORS_RETURN gets called for MPI I/O functions, and MPI_ERRORS_ABORT gets called for all other MPI functions. slay, consistent.
Open MPI includes three predefined error handlers you can use, and yes we're listing all three:
MPI_ERRORS_ARE_FATALβ causes the program to abort all connected MPI processes. dramatic, but make it fatal πMPI_ERRORS_ABORTβ an error handler that can be invoked on a communicator, window, file, or session. when called on a communicator, it acts as ifMPI_Abortwas called on that communicator. if called on a window or file, it acts as ifMPI_Abortwas called on a communicator containing the group of processes in the corresponding window or file. and if called on a session, it aborts only the local process. context is everything bestie β¨MPI_ERRORS_RETURNβ returns an error code to the application. polite. respectful. π
MPI applications can also implement their own error handlers by calling:
MPI_Comm_create_errhandlerthenMPI_Comm_set_errhandlerMPI_File_create_errhandlerthenMPI_File_set_errhandlerMPI_Session_create_errhandlerthenMPI_Session_set_errhandleror atMPI_Session_initMPI_Win_create_errhandlerthenMPI_Win_set_errhandler
β οΈ note that MPI does not guarantee that an MPI program can continue past an error. like, it genuinely might just not. no cap.
see the MPI man page for a full list of MPI error codes, and the Error Handling section of the MPI-3.1 standard for more info. iykyk π
π COPYRIGHT π
2003-2026, The Open MPI Community
and that's the whole page, bestie π§β¨ β brought to you by the Open MPI girlies, MPI_FILE_WRITE_SHARED(3), dated Sep 11, 2026. go forth and write those files, shared-pointer style. periodt π
πΈ
π¦ where this page comes from
- arch rolling: openmpi 5.0.11-1 Β· BSD-3-Clause AND LicenseRef-MPICH
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms