MPI_COMM_GET_ATTR(3)
π MPI_COMM_GET_ATTR π
okay bestie, welcome to Open MPI's page for MPI_Comm_get_attr(3) β aka the little function that goes "hey, what's the value attached to this key?" and hands you the goods. it's giving detective energy, honestly πβ¨
β¨ NAME β¨
MPI_Comm_get_attr β retrieves attribute value by key. that's it, that's the whole job, and she does it flawlessly π
πΈ 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 the attribute is glued onto (it's a handle, bestie π«Ά).comm_keyvalβ the key value, and she's an integer π’.
π¦ OUTPUT PARAMETER π¦
attribute_valβ the attribute value β¨ but only ifflag = falseis NOT the case, iykyk.flagβ logical; comes back false if there's no attribute hanging out with that key π.ierrorβ Fortran only: the error status, as an integer π.
π DESCRIPTION π
MPI_Comm_get_attr retrieves an attribute value by key. simple. iconic. does exactly what it says on the tin.
But here's the plot twist π β the call is erroneous if there is no key with value keyval. like, that key genuinely does not exist, so don't even try it.
on the other hand, the call is correct if the key value totally exists, but no attribute is attached on comm for that key. in that case? the call returns flag = false and you just vibe. no drama, no error. π§
and specifically β listen up β MPI_KEYVAL_INVALID is an erroneous key value. periodt. don't pass it, bestie π
this function replaces MPI_Attr_get, whose use is deprecated (yes, deprecated, we don't do that anymore, it's so last season π«). the C binding is identical. the Fortran binding differs in that attribute_val is an address-sized integer β that's the one glow-up, no cap.
π₯ ERRORS π₯
almost all MPI routines return an error value, okurrr? for C routines it's the return result of the function, and for Fortran routines it's in the last argument. π
before that error value comes back to you, the current MPI error handler associated with the communication object (e.g., communicator, window, file) gets 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. noted π«‘
when MPI_COMM_SELF is not initialized β that's before MPI_Init / MPI_Init_thread, after MPI_Finalize, or when you're using the Sessions Model exclusively β the error raises the initial error handler. and you can change that initial error handler:
- by calling
MPI_Comm_set_errhandleronMPI_COMM_SELFwhen using the World model, or - via the
mpi_initial_errhandlerCLI argument tompiexec, or the info key toMPI_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. ok so that's the breakdown π
π Predefined error handlers π
Open MPI ships three predefined error handlers you can absolutely use:
MPI_ERRORS_ARE_FATALβ causes the program to abort all connected MPI processes. yes, all of them. it's giving scorched earth π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 (just the one, lowkey polite of her).MPI_ERRORS_RETURNβ returns an error code to the application. the chill one πΈ
π DIY error handlers π
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
build your own, make it cute, make it yours β¨
β οΈ note that MPI does not guarantee that an MPI program can continue past an error. like, at all. so don't count on it bestie π
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. go read, it's good for you π
π Copyright π
2003-2026, The Open MPI Community
and that's the whole page, bestie π₯³π you now know literally everything this manpage has to say, no details dropped, no cap. this was MPI_COMM_GET_ATTR(3) from Open MPI, and the page was dated Sep 10, 2026 β slay, go get those attributes πβ¨π¦
π¦ 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