MPI_TYPE_FREE(3)
π MPI_TYPE_FREE π
okay so quick vibe check: this whole page is MPI_TYPE_FREE(3) from the Open MPI crew π«Ά β the manual page that tells you how to yeet a datatype into the void. Let's get into it bestie β¨
πΈ NAME πΈ
MPI_Type_free β frees a data type. bye boo ππ
π SYNTAX π
β¨ C Syntax β¨
#include <mpi.h>
int MPI_Type_free(MPI_Datatype *datatype)
β¨ Fortran Syntax β¨
USE MPI
! or the older form: INCLUDE 'mpif.h'
MPI_TYPE_FREE(DATATYPE, IERROR)
INTEGER DATATYPE, IERROR
β¨ Fortran 2008 Syntax β¨
USE mpi_f08
MPI_Type_free(datatype, ierror)
TYPE(MPI_Datatype), INTENT(INOUT) :: datatype
INTEGER, OPTIONAL, INTENT(OUT) :: ierror
π¦ INPUT/OUTPUT PARAMETER π¦
datatypeβ the datatype getting freed (it's a handle, babes). πβ‘οΈβ¨
π¦ OUTPUT PARAMETER π¦
ierrorβ Fortran only, bestie: the error status (an integer). π
π DESCRIPTION π
So what actually happens? The datatype object chillin' behind datatype gets marked for de-allocation, and then datatype gets set to MPI_DATATYPE_NULL. Periodt. π
And the tea β: any communication that's currently using this datatype? It'll complete normally, no drama, no cap. And derived datatypes that were defined from the freed datatype? They are not affected. They're fine, they're thriving, they're living their best life π¦.
Freeing a datatype does not affect any other datatype that was built from the freed one. The system behaves as if the input datatype arguments to derived datatype constructors are passed by value. literally iconic behavior tbh.
π₯ ERRORS π₯
Okay so almost all MPI routines return an error value β C routines as the return result of the function itself, and Fortran routines in that last argument. iykyk π
Before the error value comes back to you, the current MPI error handler associated with the communication object (think: communicator, window, file) gets called. And if there's no communication object attached to the MPI call? Then the call is considered attached to MPI_COMM_SELF and it'll call the associated MPI error handler. But π β when MPI_COMM_SELF is not initialized (i.e., before MPI_Init (#mpi-init) / MPI_Init_thread (#mpi-init-thread), after MPI_Finalize (#mpi-finalize), or when you're using the Sessions Model exclusively), the error raises the initial error handler instead.
That initial error handler can be changed by calling MPI_Comm_set_errhandler (#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) / MPI_Comm_spawn_multiple (#mpi-comm-spawn-multiple). And if no other appropriate error handler has been set, then MPI_ERRORS_RETURN is the one called for MPI I/O functions, while MPI_ERRORS_ABORT gets called for all other MPI functions.
Open MPI ships with three predefined error handlers you can use, bestie:
MPI_ERRORS_ARE_FATALβ causes the program to abort all connected MPI processes. dramatic, honestly π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_Abort(#mpi-abort) was called on that communicator. If it's called on a window or file, it acts as ifMPI_Abort(#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. subtle. we love range πMPI_ERRORS_RETURNβ returns an error code to the application. the polite one π«Ά
MPI applications can also implement their own error handlers by calling:
MPI_Comm_create_errhandler(#mpi-comm-create-errhandler) thenMPI_Comm_set_errhandler(#mpi-comm-set-errhandler)MPI_File_create_errhandler(#mpi-file-create-errhandler) thenMPI_File_set_errhandler(#mpi-file-set-errhandler)MPI_Session_create_errhandler(#mpi-session-create-errhandler) thenMPI_Session_set_errhandler(#mpi-session-set-errhandler), or atMPI_Session_init(#mpi-session-init)MPI_Win_create_errhandler(#mpi-win-create-errhandler) thenMPI_Win_set_errhandler(#mpi-win-set-errhandler)
β οΈ heads up bestie: MPI does not guarantee that an MPI program can continue past an error. read that again. fr fr. π
Peep the MPI man page (#open-mpi) for a full list of MPI error codes (#open-mpi-errors), and check the Error Handling section of the MPI-3.1 standard for even more info. π
π Copyright π
2003-2026, The Open MPI Community π«Άπ
and that's the whole page bestie, we ate π β¨ Open MPI babes, dated Sep 10, 2026 β go forth and free your datatypes responsibly ππ
π¦ 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