MPI_COMM_GET_ATTR(3)
π MPI_COMM_GET_ATTR(3) β like, the Open MPI glow-up edition π
okay bestie, so this is a page from the Open MPI manual, and it's literally about MPI_COMM_GET_ATTR β the little function that goes "hey, what's the attribute attached to this key?" and hands it to you. no cap, it's giving detective energy πβ¨
πΈ NAME πΈ
MPI_Comm_get_attr β retrieves attribute value by key. that's it, that's the whole vibe π
β¨ SYNTAX β¨
π©΅ C Syntax
#include <mpi.h>
int MPI_Comm_get_attr(MPI_Comm comm, int comm_keyval,
void *attribute_val, int *flag)
π Fortran Syntax
USE MPI
! or the older form: INCLUDE 'mpif.h'
MPI_COMM_GET_ATTR(COMM, COMM_KEYVAL, ATTRIBUTE_VAL, FLAG, IERROR)
INTEGER COMM, COMM_KEYVAL, IERROR
INTEGER(KIND=MPI_ADDRESS_KIND) ATTRIBUTE_VAL
LOGICAL FLAG
π¦ Fortran 2008 Syntax
USE mpi_f08
MPI_Comm_get_attr(comm, comm_keyval, attribute_val, flag, ierror)
TYPE(MPI_Comm), INTENT(IN) :: comm
INTEGER, INTENT(IN) :: comm_keyval
INTEGER(KIND=MPI_ADDRESS_KIND), INTENT(OUT) :: attribute_val
LOGICAL, INTENT(OUT) :: flag
INTEGER, OPTIONAL, INTENT(OUT) :: ierror
π INPUT PARAMETERS π
commβ the communicator that the attribute is attached to (handle). your main character object π«comm_keyvalβ the key value (integer). like the little name tag on the attribute π·οΈ
π OUTPUT PARAMETER π
attribute_valβ the attribute value, unlessflag = false. so ifflagsays no, don't go trusting this, bestie πflagβfalseif no attribute is associated with the key (logical). it's the vibe check of this whole call βierrorβ Fortran only: error status (integer).
π DESCRIPTION π
MPI_Comm_get_attr retrieves an attribute value by key. literally its whole job π
but here's the tea: the call is erroneous if there is no key with value keyval. like, you can't just make up a key, that's not the move π
on the other hand, the call is correct if the key value exists but no attribute is attached on comm for that key β in that case, the call returns flag = false. so "no attribute here" is a perfectly valid answer, it's just the shy one π«Ά
in particular, MPI_KEYVAL_INVALID is an erroneous key value. so don't do that. periodt π
this function replaces MPI_Attr_get, the use of which is deprecated. so like, move on, we don't do that anymore π the C binding is identical. the Fortran binding differs in that attribute_val is an address-sized integer. noted β¨
π₯ 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 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. 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. big yikes but okay, we love documentation π
Open MPI includes three predefined error handlers that can be used:
MPI_ERRORS_ARE_FATALβ causes the program to abort all connected MPI processes. dramatic much? but yes π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, acts as ifMPI_Abortwas called on a communicator containing the group of processes in the corresponding window or file. if called on a session, aborts only the local process. very "it depends on the context" of it π₯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. fr fr, this is not a drill π
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. iykyk πβ¨
π COPYRIGHT π
and that's the whole page, bestie π«Ά
2003-2026, The Open MPI Community π β documented with love, dated Sep 11, 2026, and yes the manual page title is still MPI_COMM_GET_ATTR(3) in case you forgot where you were β¨ slay π¦
π¦ 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