MPI_FILE_WRITE_ALL(3)
π MPI_FILE_WRITE_ALL π
okay so bestie π«Ά welcome to section 3 of the Open MPI manual. today's main character is MPI_FILE_WRITE_ALL, and yeah the title up top says MPI_FILE_WRITE_ALL(3), we're just folding that in here so the vibe stays cute. no cap, this one is lowkey iconic: it writes to a file, it's blocking, and it's collective. let's get into it π
πΈ NAME πΈ
MPI_File_write_all β writes a file starting at the locations specified by individual file pointers. it's blocking, and it's collective. yes bestie, both. periodt.
β¨ SYNTAX β¨
π C Syntax π
#include <mpi.h>
int MPI_File_write_all(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_ALL(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_all(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 PARAMETERS π
fhβ the file handle. it's a handle, bestie. that's the whole thing. β¨bufβ the initial address of your buffer. it's a choice. (a "choice" type, if you know MPI-speak β iykyk π§)countβ how many elements you got in that buffer. an integer, obviously. π’datatypeβ the data type of each buffer element. a handle. π
π¦ OUTPUT PARAMETERS π¦
statusβ the status object. it's a status, she's just standing there being a status. πierrorβ Fortran only: the error status. an integer. π
π DESCRIPTION π
okay so MPI_File_write_all is a collective routine that attempts to write into the file associated with fh β specifically at the current individual file pointer position, the one the system maintains for you, she's doing her own thing β a total number of count data items, and those items have datatype type, and they're coming from your buffer buf. the data gets written into those parts of the file specified by the current view. that's the whole deal. πΈ
MPI_File_write_all stores the number of datatype elements actually written in status. note the word actually β it's doing a lot of work there. every other field of status is undefined, so don't go poking around in there looking for extra info, bestie, there is none π.
π¨ okay important: it is erroneous to call this function if MPI_MODE_SEQUENTIAL mode was specified when the file was opened. like, don't. that's a no from the standard. π
π ERRORS π
almost all MPI routines return an error value β the C routines hand it back as the return result of the function, and the Fortran routines stick it in the last argument. classic.
before the error value comes back to you, the current MPI error handler associated with the communication object (so like a communicator, a window, a file β one of those) gets called. if no communication object is associated with the MPI call, then that call is considered attached to MPI_COMM_SELF and it'll call the associated MPI error handler. and when MPI_COMM_SELF is not initialized β i.e. before MPI_Init/MPI_Init_thread, or after MPI_Finalize, or when you're using the Sessions Model exclusively β the error raises the initial error handler. that one can be changed by calling MPI_Comm_set_errhandler on MPI_COMM_SELF when you're using the World model, or by the mpi_initial_errhandler CLI argument to mpiexec, or the info key to MPI_Comm_spawn/MPI_Comm_spawn_multiple. and if no other appropriate error handler has been set? then the MPI_ERRORS_RETURN error handler gets called for MPI I/O functions, and the MPI_ERRORS_ABORT error handler gets called for all other MPI functions. so like, know which one you're in. π
Open MPI includes three predefined error handlers that can be used:
MPI_ERRORS_ARE_FATALβ causes the program to abort all connected MPI processes. yeah she's dramatic like that πMPI_ERRORS_ABORTβ an error handler that can be invoked on a communicator, window, file, or session. when it's called on a communicator, it acts as ifMPI_Abortwas called on that communicator. if it's called on a window or a file, it acts as ifMPI_Abortwas called on a communicator containing the group of processes in the corresponding window or file. and if it's called on a session, it aborts only the local process. so like, scope matters, bestie. πMPI_ERRORS_RETURNβ returns an error code to the application. the chill one. π«Ά
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. that's just the rules, bestie.
see the MPI man page for a full list of MPI error codes. π
see the Error Handling section of the MPI-3.1 standard for more information. π
π Copyright π
and that's the page, bestie!! π huge thanks to The Open MPI Community π β the copyright on this one runs 2003-2026, and this version is dated Sep 10, 2026, living under the Open MPI banner. go forth and write collectively, you ate. π
β¨π¦
π¦ where this page comes from
- ubuntu stonking: openmpi-doc 5.0.10-6 Β· other
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms