MPI_TYPE_MATCH_SIZE(3)
๐ MPI_TYPE_MATCH_SIZE(3) โ the Open MPI glow-up
okay bestie, so this is a page from the Open MPI manual set, and it's about MPI_Type_match_size. it's literally the "which datatype matches this size" hotline. let's get into it โจ
๐ธ NAME ๐ธ
MPI_Type_match_size โ returns an MPI datatype of a given type and size ๐
โจ SYNTAX โจ
๐ง C Syntax
#include <mpi.h>
int MPI_Type_match_size(int typeclass, int size,
MPI_Datatype *type)
๐ฆ Fortran Syntax
USE MPI
! or the older form: INCLUDE 'mpif.h'
MPI_TYPE_MATCH_SIZE(TYPECLASS, SIZE, TYPE, IERROR)
INTEGER TYPECLASS, SIZE, TYPE, IERROR
๐ Fortran 2008 Syntax
USE mpi_f08
MPI_Type_match_size(typeclass, size, datatype, ierror)
INTEGER, INTENT(IN) :: typeclass, size
TYPE(MPI_Datatype), INTENT(OUT) :: datatype
INTEGER, OPTIONAL, INTENT(OUT) :: ierror
๐ INPUT PARAMETERS ๐
typeclassโ the generic type specifier, an integer. this is you telling it "girl, I want a real / integer / complex type". ๐ซsizeโ the size, in bytes, of the representation. also an integer. ๐
๐ OUTPUT PARAMETERS ๐
typeโ the datatype with the correct type and size, as a handle. ๐ซถierrorโ Fortran only: the error status, an integer. ๐
๐ฅ DESCRIPTION ๐ฅ
so what it does: the function returns an MPI datatype that matches a local variable of type (typeclass, size). and listen โ the type it hands you back is a reference (handle) to a predefined named datatype, not a duplicate. which means you cannot free this type. not "shouldn't", cannot. it's not yours to yeet. ๐
typeclass can be set to one of MPI_TYPECLASS_REAL, MPI_TYPECLASS_INTEGER, or MPI_TYPECLASS_COMPLEX, depending on which datatype you're craving. ๐
and here's the iconic use case: MPI_Type_match_size can be used to obtain a size-specific type that matches a Fortran numeric intrinsic type. the workflow is literally:
- call
MPI_Sizeofto compute the variable size ๐งฎ - call
MPI_Type_match_sizeto find a suitable datatype ๐ฏ
and if you're in C? use the sizeof builtin instead of MPI_Sizeof. easy. no cap. โจ
โ ๏ธ it is erroneous to specify a size not supported by the compiler. so, like, don't do that. fr fr. ๐
๐ ERRORS ๐
almost all MPI routines return an error value. C routines return it as the return result of the function, and Fortran routines put it in the last argument. standard behavior, you know the drill. ๐
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. 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 that you can use, and they are:
MPI_ERRORS_ARE_FATALโ causes the program to abort all connected MPI processes. dramatic, but make it functional. ๐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. 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
โ ๏ธ note that MPI does not guarantee that an MPI program can continue past an error. like, it might just not. so plan accordingly 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. ๐
๐ SEE ALSO ๐
MPI_SizeofMPI_Type_get_extent
๐ COPYRIGHT ๐
2003-2026, The Open MPI Community
and that's the whole page, bestie ๐ซถ โ big slay, iconique, no notes. this one's dated Sep 11, 2026, brought to you by The Open MPI Community, and it's officially a wrap. ๐โจ๐
๐ฆ where this page comes from
- arch rolling: openmpi 5.0.11-1 ยท BSD-3-Clause AND LicenseRef-MPICH
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms