MPI_GROUP_TRANSLATE_RANKS(3)

πŸ’… MPI_GROUP_TRANSLATE_RANKS β€” Open MPI, bestie edition ✨

okay so listen, this is MPI_GROUP_TRANSLATE_RANKS(3) from the Open MPI manual, and it does exactly one gorgeous thing: it translates the ranks of processes in one group to those in another group. that's it. that's the whole girl. πŸŽ€


✨ SYNTAX ✨

🌸 C Syntax

#include <mpi.h>

int MPI_Group_translate_ranks(MPI_Group group1, int n,
     const int ranks1[], MPI_Group group2, int ranks2[])

🌸 Fortran Syntax

USE MPI
! or the older form: INCLUDE 'mpif.h'
MPI_GROUP_TRANSLATE_RANKS(GROUP1, N, RANKS1, GROUP2, RANKS2,
             IERROR)
     INTEGER GROUP1, N, RANKS1(*), GROUP2, RANKS2(*), IERROR

🌸 Fortran 2008 Syntax

USE mpi_f08
MPI_Group_translate_ranks(group1, n, ranks1, group2, ranks2, ierror)
     TYPE(MPI_Group), INTENT(IN) :: group1, group2
     INTEGER, INTENT(IN) :: n, ranks1(n)
     INTEGER, INTENT(OUT) :: ranks2(n)
     INTEGER, OPTIONAL, INTENT(OUT) :: ierror

🌈 INPUT PARAMETERS 🌈

  • group1 β€” the first group, as a handle. your home base, your origin story πŸ’–
  • n β€” how many ranks live in the ranks1 and ranks2 arrays (integer, bestie).
  • ranks1 β€” array of zero or more valid ranks in group1. zero! yes! an empty array is valid, she contains multitudes ✨
  • group2 β€” the second group, also a handle. your destination, your glow-up πŸ¦‹

🫢 OUTPUT PARAMETERS 🫢

  • ranks2 β€” array of corresponding ranks in group2, and it's MPI_UNDEFINED when no correspondence exists. so if a process from group1 simply is not in group2? she's MPI_UNDEFINED. not lost, just unmatched 😭
  • ierror β€” Fortran only: the error status (integer).

πŸ’œ DESCRIPTION πŸ’œ

okay so this function is important for figuring out the relative numbering of the same processes across two different groups. it's giving translator, it's giving "who are you in this other friend group" energy.

for instance β€” and this is the example straight from the source, no cap β€” if you know the ranks of certain processes in the group of MPI_COMM_WORLD, you might want to know their ranks in a subset of that group. same girlies, different group chat. periodt. πŸ‘‘


πŸ’€ ERRORS πŸ’€

almost all MPI routines return an error value. C routines hand it back as the return result of the function, and Fortran routines drop it in the last argument. iykyk.

before that error value comes back, the current MPI error handler associated with the communication object (think: communicator, window, file) gets called. and if there's no communication object associated with the MPI call, then the call is considered attached to MPI_COMM_SELF and will call the associated MPI error handler. and when MPI_COMM_SELF is not initialized β€” meaning 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 by 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_RETURN error handler is called for MPI I/O functions, and the MPI_ERRORS_ABORT error handler is called for all other MPI functions. drama, but make it specified πŸ’…

Open MPI ships three predefined error handlers you can absolutely use:

  • MPI_ERRORS_ARE_FATAL β€” causes the program to abort all connected MPI processes. she said everyone is coming with her πŸ’€
  • 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 if MPI_Abort was called on that communicator. if called on a window or file, it acts as if MPI_Abort was 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. context-aware queen πŸŽ€
  • MPI_ERRORS_RETURN β€” returns an error code to the application. polite. respectful. hands you the receipt 🧾

MPI applications can also implement their own error handlers by calling:

  • MPI_Comm_create_errhandler then MPI_Comm_set_errhandler
  • MPI_File_create_errhandler then MPI_File_set_errhandler
  • MPI_Session_create_errhandler then MPI_Session_set_errhandler or at MPI_Session_init
  • MPI_Win_create_errhandler then MPI_Win_set_errhandler
⚠️ note that MPI does not guarantee that an MPI program can continue past an error. like, at all. plan accordingly, gorgeous.

see the MPI man page for a full list of MPI error codes, and see the Error Handling section of the MPI-3.1 standard for more information. go read, it's good for you πŸ“š


2003-2026, The Open MPI Community


and that's the whole page, bestie!! πŸ¦‹ it's MPI_GROUP_TRANSLATE_RANKS(3) from Open MPI, dated Sep 10, 2026, and you now know her better than she knows herself. slay, go translate some ranks, and remember: MPI_UNDEFINED is a valid answer, not a personal failure. πŸ’–βœ¨

πŸ“¦ where this page comes from