MPI_FILE_SEEK_SHARED(3)
π MPI_File_seek_shared β updates the global shared file pointer (collective) π
hiii bestie π«Ά this one's from the Open MPI manual, section 3 (yes, the man page section, not a vibe). It's giving "everyone in the group chat moves the cursor together or nobody moves it at all." periodt. β¨
β¨ SYNTAX β¨
C Syntax
#include <mpi.h>
int MPI_File_seek_shared(MPI_File fh, MPI_Offset offset,
int whence)
Fortran Syntax
USE MPI
! or the older form: INCLUDE 'mpif.h'
MPI_FILE_SEEK_SHARED(FH, OFFSET, WHENCE, IERROR)
INTEGER FH, WHENCE, IERROR
INTEGER(KIND=MPI_OFFSET_KIND) OFFSET
Fortran 2008 Syntax
USE mpi_f08
MPI_File_seek_shared(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. It's a handle type, so it's one of those opaque little icons you just pass around. π«offsetβ the file offset, an integer. Lowkey the main character of this whole function. πwhenceβ the update mode, also an integer. This is the one that decides how your offset gets applied, so don't sleep on it. π§
πΈ OUTPUT PARAMETER πΈ
ierrorβ Fortran only β¨ error status, an integer. C girlies get their error as the return value instead, iykyk. π
π₯ DESCRIPTION π₯
MPI_File_seek_shared updates the shared file pointer according to whence, and whence can be any of these iconic values π«:
MPI_SEEK_SETβ the pointer is set tooffset. Just. Straight up. Set. π―MPI_SEEK_CURβ the pointer is set to the current pointer position plusoffset. Nudge nudge. πMPI_SEEK_ENDβ the pointer is set to the end of the file plusoffset. End credits energy. π¬
Not me reminding you that MPI_File_seek_shared is collective β it literally is, and that's not a drill. All the processes in the communicator group associated with the file handle fh must call MPI_File_seek_shared with the same offset and whence. And the way that all processes in the communicator group are synchronized before the shared file pointer is updated? Chef's kiss. π€β¨
Okay so the offset can be negative, which allows seeking backwards π. But! It is erroneous to seek to a negative position in the view π. And the end of the view is defined to be the position of the next elementary data item, relative to the current view, following the last whole elementary data item accessible. Write that down, put it on your wall, it's on the quiz. π
π ERRORS π
Almost all MPI routines return an error value: C routines as the return result of the function, and Fortran routines in the last argument. π
Before the error value is returned, the current MPI error handler associated with the communication object (e.g., communicator, window, file) is called. If no communication object is 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. The 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 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. π
Open MPI includes three predefined error handlers that can be used π«Ά:
MPI_ERRORS_ARE_FATALβ causes the program to abort all connected MPI processes. Okay so it's dramatic and it means it. π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. Pick your fighter. βοΈMPI_ERRORS_RETURNβ returns an error code to the application. The chill one. Returns the receipt. π§Ύ
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 might just be over. π«
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 thing, bestie, no notes π this was the Open MPI page for MPI_FILE_SEEK_SHARED(3), dated Sep 10, 2026. go update that shared file pointer, you absolute icon π§β¨π
π¦ 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