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 of type (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 if MPI_Abort was called on that communicator. if 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 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_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

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

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