MPI_FILE_GET_POSITION_SHARED(3)

πŸ’… MPI_FILE_GET_POSITION_SHARED(3) β€” an Open MPI moment

okay bestie, so this is a page from the Open MPI manual, and today's main character is MPI_File_get_position_shared ✨ β€” the little routine that tells you where the shared file pointer is currently sitting. Yes, shared. As in, everybody. Group project energy. 🫢


✨ SYNTAX ✨

C Syntax

#include <mpi.h>

int MPI_File_get_position_shared(MPI_File fh, MPI_Offset *offset)

Fortran Syntax

USE MPI
! or the older form: INCLUDE 'mpif.h'
MPI_FILE_GET_POSITION_SHARED(FH, OFFSET, IERROR)
     INTEGER FH, IERROR
     INTEGER(KIND=MPI_OFFSET_KIND)   OFFSET

Fortran 2008 Syntax

USE mpi_f08
MPI_File_get_position_shared(fh, offset, ierror)
     TYPE(MPI_File), INTENT(IN) :: fh
     INTEGER(KIND=MPI_OFFSET_KIND), INTENT(OUT) :: offset
     INTEGER, OPTIONAL, INTENT(OUT) :: ierror

🌸 INPUT PARAMETER 🌸

  • fh β€” the file handle, bestie. It's a handle (handle). πŸŽ€

πŸ¦‹ OUTPUT PARAMETERS πŸ¦‹

  • offset β€” the offset of the shared file pointer. It's an integer. That's literally it, and it's iconic. πŸ’–
  • ierror β€” Fortran only, babes: the error status (integer).

πŸ’« DESCRIPTION πŸ’«

so MPI_File_get_position_shared hands you back, in offset, the current position of the shared file pointer β€” measured in etype units, relative to the current displacement and file type. the way it's just casually etype-relative... we love a units-aware king πŸ‘‘.


πŸ”₯ ERRORS πŸ”₯

okay listen, because this part is important and I'm not gonna let you gloss over it πŸ™ˆ.

Almost all MPI routines return an error value. C routines give it to you as the return result of the function, and Fortran routines put it in the last argument. Both iconic, both valid.

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, like, 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. periodt.

When MPI_COMM_SELF is not initialized β€” meaning 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. And you can change that initial error handler by calling MPI_Comm_set_errhandler on MPI_COMM_SELF when you're using the World model, or via the mpi_initial_errhandler CLI argument to mpiexec, or the info key to MPI_Comm_spawn/MPI_Comm_spawn_multiple. iykyk πŸ’…

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 the vibe check, and the vibe is: know which one you're in. πŸ’€

Open MPI ships three predefined error handlers you can use, and yes, we're listing all three:

  • 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 it's called on a communicator, it acts as if MPI_Abort was called on that communicator. If it's called on a window or file, it acts as if MPI_Abort was called on a communicator containing the group of processes in the corresponding window or file. If it's called on a session, it aborts only the local process. yes, that's three whole behaviours, go off. πŸ”₯
  • 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_errhandler then MPI_Comm_set_errhandler
  • MPI_File_create_errhandler then MPI_File_set_errhandler
  • MPI_Session_create_errhandler then MPI_Session_set_errhandler or at MPI_Session_init
  • MPI_Win_create_errhandler then MPI_Win_set_errhandler
⚠️ bestie, real talk: note that MPI does not guarantee that an MPI program can continue past an error. no cap. plan accordingly. πŸ’€

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.


2003-2026, The Open MPI Community


and that's the whole page, bestie β€” slay. this was the MPI_FILE_GET_POSITION_SHARED(3) man page for Open MPI, dated Sep 11, 2026, and honestly? she ate. πŸ’…βœ¨πŸŒ·

πŸ“¦ where this page comes from