MPI_FILE_SEEK(3)
πΎ MPI_FILE_SEEK(3) β the Open MPI glow-up π¦
okay bestie, we're in the Open MPI corner of the manual, and today's main character is MPI_File_seek. it updates individual file pointers, and ngl it does it noncollectively β that's the whole vibe. no group chat needed, just you and your file handle π
β¨ NAME β¨
MPI_File_seek β updates individual file pointers (noncollective). periodt.
πΈ SYNTAX πΈ
π C Syntax
#include <mpi.h>
int MPI_File_seek(MPI_File fh, MPI_Offset offset,
int whence)
π Fortran Syntax
USE MPI
! or the older form: INCLUDE 'mpif.h'
MPI_FILE_SEEK(FH, OFFSET, WHENCE, IERROR)
INTEGER FH, WHENCE, IERROR
INTEGER(KIND=MPI_OFFSET_KIND) OFFSET
π Fortran 2008 Syntax
USE mpi_f08
MPI_File_seek(fh, offset, whence, ierror)
TYPE(MPI_File), INTENT(IN) :: fh
INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN) :: offset
INTEGER, INTENT(IN) :: whence
INTEGER, OPTIONAL, INTENT(OUT) :: ierror
π«Ά INPUT PARAMETERS π«Ά
fhβ the file handle, bestie. (handle)offsetβ the file offset, as an integer. (integer)whenceβ the update mode, also an integer. (integer)
π OUTPUT PARAMETER π
ierrorβ Fortran only, bestie: it's the error status (integer).
π DESCRIPTION π
so MPI_File_seek updates the individual file pointer, and it does it based on whence, which can be one of these iconic little values:
MPI_SEEK_SETβ the pointer gets set tooffset. boom, placed.MPI_SEEK_CURβ the pointer gets set to wherever it currently is, plusoffset.MPI_SEEK_ENDβ the pointer gets set to the end of the file, plusoffset.
the offset can be negative, which is how you seek backwards β yes, we're rewinding, it's giving time travel βͺ but listen: seeking to a negative position in the file is erroneous. do not do that, it's not cute π«
also, the end of the file is defined to be the location of the next elementary data item immediately after the last accessed data item β even if that location is a hole. (yes, a hole. the file said "it's giving void" π)
π 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 that last argument.
before the error value gets returned, the current MPI error handler associated with the communication object (like a communicator, window, or 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 will call the associated MPI error handler. when MPI_COMM_SELF is not 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. that initial error handler can be changed by calling MPI_Comm_set_errhandler on MPI_COMM_SELF when using the World model, or 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 is called for MPI I/O functions, and the MPI_ERRORS_ABORT error handler is called for all other MPI functions.
Open MPI includes three predefined error handlers you can use, and they are:
MPI_ERRORS_ARE_FATALβ causes the program to abort all connected MPI processes. dramatic, but make it 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, 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.MPI_ERRORS_RETURNβ returns an error code to the application. it's giving "here, you deal with it".
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 count on it, 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. iykyk π
π Copyright π
2003-2026, The Open MPI Community
and that's the whole page, no cap π huge thank you to The Open MPI Community for this absolute classic, dated Sep 10, 2026, filed under MPI_FILE_SEEK(3) β the way she's been serving file pointers since 2003 and still ate down π«Άβ¨ go seek responsibly, bestie π¦
π¦ 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