MPI_FREE_MEM(3)
π MPI_FREE_MEM(3) β bestie, it's Open MPI and we're freeing memory π
okay so. hi. you're here because you called MPI_Alloc_mem, you got your little block of memory, and now the vibe is over and you need to let it go. this is the page for that. it's MPI_Free_mem, from Open MPI, and honestly? it's giving "cleaning up after yourself, main character energy." π
β¨ SYNTAX β¨
π C Syntax
#include <mpi.h>
int MPI_Free_mem(void *base)
π¦ Fortran Syntax
USE MPI
! or the older form: INCLUDE 'mpif.h'
MPI_FREE_MEM(BASE, IERROR)
<type> BASE(*)
INTEGER IERROR
πΈ Fortran 2008 Syntax
USE mpi_f08
MPI_Free_mem(base, ierror)
TYPE(*), DIMENSION(..), INTENT(IN), ASYNCHRONOUS :: base
INTEGER, OPTIONAL, INTENT(OUT) :: ierror
π INPUT PARAMETER
baseβ the initial address of the memory segment that got allocated byMPI_Alloc_mem <#mpi-alloc-mem>. that's it, that's the one you're handing back. (type: choice.) π«Ά
π OUTPUT PARAMETER
ierrorβ Fortran only, babes: the error status, and it's an integer. π«
π DESCRIPTION
okay so here's the whole thing, and it's not complicated:
MPI_Free_mem frees memory that has been allocated by MPI_Alloc_mem <#mpi-alloc-mem>.
that's the tea. you allocated with one, you free with the other. periodt. π
π ERRORS π
buckle up bestie, this part is long but it's important, no cap.
Almost all MPI routines return an error value β C routines hand it back as the return result of the function, and Fortran routines put it in the last argument. MPI_Free_mem is no exception, so check your ierror in Fortran. π
Before that error value ever gets returned, the current MPI error handler associated with the communication object (think: communicator, window, file) is called. and 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. when MPI_COMM_SELF is not initialized β meaning 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. and that initial error handler can be changed by:
- calling
MPI_Comm_set_errhandler <#mpi-comm-set-errhandler>onMPI_COMM_SELFwhen you're using the World model, or - the
mpi_initial_errhandlerCLI argument tompiexec, 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 handler that gets called for MPI I/O functions, and MPI_ERRORS_ABORT is the handler that gets 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. π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 a file, it acts as ifMPI_Abort <#mpi-abort>was called on a communicator containing the group of processes in the corresponding window or file. and if it's called on a session, it aborts only the local process. πMPI_ERRORS_RETURNβ returns an error code to the application. nice, gentle, we love her. π«Ά
MPI applications can also implement their own error handlers by calling:
MPI_Comm_create_errhandler <#mpi-comm-create-errhandler>and thenMPI_Comm_set_errhandler <#mpi-comm-set-errhandler>MPI_File_create_errhandler <#mpi-file-create-errhandler>and thenMPI_File_set_errhandler <#mpi-file-set-errhandler>MPI_Session_create_errhandler <#mpi-session-create-errhandler>and thenMPI_Session_set_errhandler <#mpi-session-set-errhandler>, or atMPI_Session_init <#mpi-session-init>MPI_Win_create_errhandler <#mpi-win-create-errhandler>and thenMPI_Win_set_errhandler <#mpi-win-set-errhandler>
β οΈ note that MPI does not guarantee that an MPI program can continue past an error. fr fr. plan accordingly. π
see the MPI man page <#open-mpi> for a full list of MPI error codes <#open-mpi-errors>.
and see the Error Handling section of the MPI-3.1 standard for even more info, iykyk. π
π₯ SEE ALSO π₯
MPI_Alloc_mem <#mpi-alloc-mem>β because every free needs its alloc, bestie. they're a matched set. π
π Copyright π
2003-2026, The Open MPI Community β¨
and that's the whole page!! you freed your memory, you checked your error codes, you're thriving. this was MPI_FREE_MEM(3) from Open MPI, last touched Sep 10, 2026 β mwah, sending you a big Open MPI Community kiss, go forth and MPI_Free_mem 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