MPI_FILE_CLOSE(3)
π MPI_File_close π
okay bestie, so this is a page from the Open MPI manual, and it's literally all about saying byeee to a file. yes, THE MPI_File_close β closes a file (collective). collective, meaning everybody's in on it, no sneaky solo exits. π«Ά
β¨ NAME β¨
MPI_File_close β Closes a file (collective). that's the whole vibe. πβοΈ
β¨ 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, and it's a handle. it goes in AND out, it's giving bidirectional main character energy. π
β¨ OUTPUT PARAMETER β¨
ierrorβ Fortran only, bestie, C doesn't get one of these. it's the error status, and it's an integer. π
β¨ DESCRIPTION β¨
okay so here's the tea β: MPI_File_close first synchronizes file state, and then closes the file associated with fh. in that order. sync first, close second, no skipping steps.
and like, MPI_File_close is a collective routine. periodt. π
β οΈ real talk though: the user is responsible for making sure that all outstanding requests associated withfhhave completed before callingMPI_File_close. that's on you, not on MPI. don't be out here closing files with requests still hanging, iykyk. π
β¨ ERRORS β¨
ngl, almost every MPI routine returns an error value, and the way it comes back depends on your language:
- C routines β return it as the return result of the function
- Fortran routines β put it in the last argument
before that error value even gets returned, the current MPI error handler associated with the communication object (think communicator, window, file) gets called. π¦
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. and when MPI_COMM_SELF isn't initialized (like before MPI_Init/MPI_Init_thread, after MPI_Finalize, or when you're using the Sessions Model exclusively) the error raises the initial error handler. β¨
that initial error handler can be changed by:
- calling
MPI_Comm_set_errhandleronMPI_COMM_SELFwhen using the World model, or - the
mpi_initial_errhandlerCLI argument tompiexec, or - the 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. that's just how it is. π
Open MPI ships three predefined error handlers you can use, and they are:
MPI_ERRORS_ARE_FATALβ Causes the program to abort all connected MPI processes. dramatic much? yes. on purpose. π₯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, acts as ifMPI_Abortwas called on a communicator containing the group of processes in the corresponding window or file. If called on a session, aborts only the local process. π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
π¨ bestie heads up: note that MPI does not guarantee that an MPI program can continue past an error. like, it might just be over. no cap.
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. protecting the brand since 2003, we love to see it. π
and that's the whole page, bestie!! this one came straight out of the Open MPI docs, dated Sep 10, 2026, and it lives at page MPI_FILE_CLOSE(3). go forth and close your files responsibly, mwah π β¨π
π¦ 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