MPI_COMM_GROUP(3)
π MPI_COMM_GROUP(3) β Open MPI π
okay bestie, gather round, because today we're getting the group out of a communicator and it's honestly iconic. this is a page from the Open MPI manual set, and no cap, it's short but it matters. π
β¨ NAME β¨
MPI_Comm_group β hands you back the group that's associated with a communicator. that's it. that's the whole job. π
β¨ SYNTAX β¨
πΈ C Syntax πΈ
#include <mpi.h>
int MPI_Comm_group(MPI_Comm comm, MPI_Group *group)
πΈ Fortran Syntax πΈ
USE MPI
! or the older form: INCLUDE 'mpif.h'
MPI_COMM_GROUP(COMM, GROUP, IERROR)
INTEGER COMM, GROUP, IERROR
πΈ Fortran 2008 Syntax πΈ
USE mpi_f08
MPI_Comm_group(comm, group, ierror)
TYPE(MPI_Comm), INTENT(IN) :: comm
TYPE(MPI_Group), INTENT(OUT) :: group
INTEGER, OPTIONAL, INTENT(OUT) :: ierror
like, look at that mpi_f08 version being all typed and elegant. main character energy fr. π
π INPUT PARAMETER π
commβ the communicator. that's the thing you're pulling a group out of, bestie.
π¦ OUTPUT PARAMETERS π¦
groupβ the group that lives inside that communicator (it's a handle, so hold it gently).ierrorβ Fortran-only babes: this is your error status, and it's an integer.
π DESCRIPTION π
so here's the tea π΅: if the communicator you handed over is an intercommunicator β aka the kind that lets two separate groups of processes talk to each other β then this function gives you back the local group. only the local one. local. π«Ά
and if what you actually wanted was the other side? the remote group? then you go call MPI_Comm_remote_group instead. different function, different vibe, don't mix them up. π
π₯ ERRORS π₯
okay so basically almost every MPI routine returns an error value. in C it comes back as the return result of the function, and in Fortran it lands in the last argument. no surprises there. β¨
and before that error value ever gets returned? the current MPI error handler attached to the communication object gets called β and by "communication object" we mean stuff like a communicator, window, or file. and if there's no communication object associated with the MPI call at all, then the call counts as attached to MPI_COMM_SELF and it calls the error handler associated with that.
now here's the part where you gotta pay attention, bestie, because it's giving edge case:
when MPI_COMM_SELF isn't initialized β meaning before MPI_Init/MPI_Init_thread, after MPI_Finalize, or when you're running the Sessions Model exclusively β the error raises the initial error handler. π
and you can change that initial error handler! you do it by calling MPI_Comm_set_errhandler on MPI_COMM_SELF when you're using the World model, or by using the mpi_initial_errhandler CLI argument to mpiexec, or the info key to MPI_Comm_spawn/MPI_Comm_spawn_multiple.
and if no other appropriate error handler has been set? then:
- the
MPI_ERRORS_RETURNerror handler gets called for MPI I/O functions, and - the
MPI_ERRORS_ABORTerror handler gets called for all other MPI functions.
π the three predefined error handlers Open MPI ships with π
MPI_ERRORS_ARE_FATALβ causes the program to abort all connected MPI processes. dramatic? yes. effective? also yes. π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_Abortwas called on that communicator. if it's 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. and if it's called on a session, it aborts only the local process. β¨MPI_ERRORS_RETURNβ returns an error code to the application. polite. respectful. we love her. π«Ά
π and you can absolutely write your own π
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
DIY queen behavior honestly. π
β οΈ real talk, no cap: note that MPI does not guarantee that an MPI program can continue past an error. like, do not assume you can just keep going. that's not a thing. π
for the full list of MPI error codes, go check the MPI man page. and for even more detail, see the Error Handling section of the MPI-3.1 standard. iykyk. π
π Copyright π
2003-2026, The Open MPI Community
and that's the whole page, bestie!! ππ slay, you now know exactly how to get a group out of a communicator, and you know it was written up on Sep 10, 2026 in the Open MPI manual, page MPI_COMM_GROUP(3). go forth and group 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