MPI_FILE_CLOSE(3)
π MPI_FILE_close π
okay so welcome to the Open MPI page for MPI_File_close, bestie β this is the one you call when you're done with a file and you want it closed, like actually properly closed, not just "eh, whatever" closed. It's collective, it syncs first, and it's lowkey the politest way to say bye to your file handle. π«Ά
β¨ SYNTAX β¨
πΈ C Syntax
#include <mpi.h>
int MPI_File_close(MPI_File *fh)
π¦ Fortran Syntax
USE MPI
! or the older form: INCLUDE 'mpif.h'
MPI_FILE_CLOSE(FH, IERROR)
INTEGER FH, IERROR
π Fortran 2008 Syntax
USE mpi_f08
MPI_File_close(fh, ierror)
TYPE(MPI_File), INTENT(INOUT) :: fh
INTEGER, OPTIONAL, INTENT(OUT) :: ierror
π INPUT/OUTPUT PARAMETER
fhβ the file handle (a handle, bestie). You pass it in, and yeah it gets touched on the way out β that's the input/output life. β¨
β OUTPUT PARAMETER
ierrorβ Fortran only: the error status, which is aninteger. That's it, that's the whole vibe. π
π₯ DESCRIPTION
So here's the tea: MPI_File_close first synchronizes file state, and then it closes the file associated with fh. In that order. No skipping ahead. π§
It's a collective routine, which means everybody's in on it β no solo main character energy here, the whole group has to show up.
And this part is on you, okay? The user is responsible for ensuring that all outstanding requests associated with fh have completed before calling MPI_File_close. Like, don't close the door while stuff's still walking through it. π
π ERRORS
Almost all MPI routines return an error value β C routines hand it back as the return result of the function, and Fortran routines put it in the last argument. Classic. π
Before that error value comes back to you, the current MPI error handler associated with the communication object (e.g., 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 it'll call the associated MPI error handler. π
When MPI_COMM_SELF is not initialized β that's 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 - via the
mpi_initial_errhandlerCLI argument tompiexec, or - via the info key to
MPI_Comm_spawn/MPI_Comm_spawn_multiple.
If no other appropriate error handler has been set, then the MPI_ERRORS_RETURN error handler is called for MPI I/O functions, and the MPI_ERRORS_ABORT error handler is called for all other MPI functions. That's just how it is, fr fr. β
Open MPI includes three predefined error handlers you can use:
MPI_ERRORS_ARE_FATALβ causes the program to abort all connected MPI processes. Dramatic? Yes. Effective? Also yes. π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. If called on a session, it aborts only the local process. (iconic, honestly β knows how to scope itself π)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. So likeβ¦ don't build your whole personality on surviving one, okay? π
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
2003-2026, The Open MPI Community
and that's the whole page, bestie!! β¨ this one's from the Open MPI crew β copyright 2003-2026, The Open MPI Community β and the version/footer vibes are dated Sep 11, 2026, filed under MPI_FILE_CLOSE(3). go close that file. slay. π
ππ¦
π¦ 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