MPI_TYPE_DUP(3)
π MPI_TYPE_DUP(3) β the Open MPI glow-up guide π¦
okay so bestie, welcome to the MPI_TYPE_DUP(3) page from the Open MPI manual. this one is short and sweet and honestly kind of iconic β it's the "make me a copy of this datatype, but with the key values too" era. let's get into it β¨
β¨ SYNOPSIS β¨
π C Syntax
#include <mpi.h>
int MPI_Type_dup(MPI_Datatype type, MPI_Datatype *newtype)
π Fortran Syntax
USE MPI
! or the older form: INCLUDE 'mpif.h'
MPI_TYPE_DUP(TYPE, NEWTYPE, IERROR)
INTEGER TYPE, NEWTYPE, IERROR
π Fortran 2008 Syntax
USE mpi_f08
MPI_Type_dup(oldtype, newtype, ierror)
TYPE(MPI_Datatype), INTENT(IN) :: oldtype
TYPE(MPI_Datatype), INTENT(OUT) :: newtype
INTEGER, OPTIONAL, INTENT(OUT) :: ierror
πΈ INPUT PARAMETER πΈ
typeβ the data type handle you're duplicating, bestie. that's the one. (handle) π
π OUTPUT PARAMETERS π
newtypeβ your fresh little copy oftype(handle). she's brand new, she's got the same vibe πierrorβ Fortran only, bestie: the error status (integer). β¨
π¦ DESCRIPTION π¦
so MPI_Type_dup is a type constructor that duplicates the existing type with associated key values. yes, key values come along too. for each key value, the respective copy callback function decides what attribute value gets associated with that key in the new communicator. and fun fact β one particular action a copy callback may take is to delete the attribute from the new data type. so she's allowed to be a little dramatic, it's fine π
it returns in newtype a new data type with exactly the same properties as type, plus any copied cached information. the new data type has identical upper bound and lower bound and yields the same net result when fully decoded with the functions described in Section 8.6 of the MPI-2 standard. also newtype has the same committed state as the old type. no cap, she's a genuinely faithful copy π
β NOTES β
heads up bestie β it's not defined by the MPI standard what happens if the attribute copy callback invokes other MPI functions. like, standard says Β―\_(γ)_/Β―
in Open MPI though, it is not valid for attribute copy callbacks (or any of their children, lol) to add or delete attributes on the same object on which the attribute copy callback is being invoked. so don't do that. fr fr π
π₯ 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. classic.
before the error value gets 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 the 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. slay π
Open MPI includes three predefined error handlers you can use:
MPI_ERRORS_ARE_FATALβ causes the program to abort all connected MPI processes. π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. so like, don't count on it π
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_Type_create_keyval
π COPYRIGHT π
that's the whole page bestie β and to wrap it up in a cute little bow π: this manual page is copyright 2003-2026, The Open MPI Community, and it was dated Sep 11, 2026 on the MPI_TYPE_DUP(3) page. periodt. πβ¨π¦
π¦ 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