MPI_SIZEOF(3)
πΈ NAME πΈ
MPI_Sizeof β it hands you the size, in bytes, of whatever type you pass it. that's it. that's the whole job. π
(oh and bestie, this one lives in the Open MPI manual, section 3. yes we're fancy.)
β¨ SYNTAX β¨
π Fortran Syntax
USE MPI
! or the older form: INCLUDE 'mpif.h'
MPI_SIZEOF(X, SIZE, IERROR)
<type> X
INTEGER SIZE, IERROR
π¦ Fortran 2008 Syntax
USE mpi_f08
MPI_Sizeof(x, size, ierror)
TYPE(*), DIMENSION(..) :: x
INTEGER, INTENT(OUT) :: size
INTEGER, OPTIONAL, INTENT(OUT) :: ierror
π INPUT PARAMETER
Xβ a Fortran variable of numeric intrinsic type (choice). it's giving "pick your fighter" energy, you literally choose which numeric type you're asking about. π
π«Ά OUTPUT PARAMETERS
SIZEβ the size of the machine representation of that type (integer). like the byte count. the receipts. π§Ύierrorβ error status (integer).
π₯ DESCRIPTION π₯
MPI_Sizeof returns the size, in bytes, of the machine representation of the variable you gave it. periodt. π
It's a generic Fortran type and it has a Fortran binding only β so don't come looking for it anywhere else, bestie, it's not there. π
It's basically the same vibe as the sizeof builtin in C. iconic behavior honestly.
BUT β and this is the plot twist, pay attention π β if you hand it an array argument, it returns the size of the base element, not the size of the whole array. so like, the individual thing, not the whole squad. don't get got by that one.
π NOTES π
This function is not available in C because it is not necessary. yeah. C said "I already have sizeof, I'm good," and honestly? valid. π
π ERRORS π
okay so this part is long but it's important, stay with me. π«Ά
Almost all MPI routines return an error value: C routines return it as the return result of the function, and Fortran routines return it in the last argument.
Before that error value 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 will call the associated MPI error handler. And when MPI_COMM_SELF is not initialized β that means 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.
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 via an 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 ships three predefined error handlers you can use:
MPI_ERRORS_ARE_FATALβ causes the program to abort all connected MPI processes. yes, everyone. the whole group chat. π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 ifMPI_Abortwas called on that communicator. If it's called on a window or a file, it acts as ifMPI_Abortwas 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.MPI_ERRORS_RETURNβ returns an error code to the application. polite. considerate. we love her. π
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, no promises, bestie. 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. iykyk π
π Copyright
2003-2026, The Open MPI Community
and that's the whole page, bestie β Open MPI's MPI_SIZEOF(3), dated Sep 10, 2026. go forth and byte-count responsibly, 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