MPI_CART_RANK(3)
MPI_CART_RANK π
okay bestie, welcome to the Open MPI manual page for MPI_Cart_rank β yes that's the title AND the manual name, we're already iconic β¨
NAME πΈ
MPI_Cart_rank β figures out a process's rank in a communicator when you hand it a Cartesian location. that's it, that's the job π
SYNTAX β¨
C Syntax
#include <mpi.h>
int MPI_Cart_rank(MPI_Comm comm, int coords[], int *rank)
Fortran Syntax
USE MPI
! or the older form: INCLUDE 'mpif.h'
MPI_CART_RANK(COMM, COORDS, RANK, IERROR)
INTEGER COMM, COORDS(*), RANK, IERROR
Fortran 2008 Syntax
USE mpi_f08
MPI_Cart_rank(comm, coords, rank, ierror)
TYPE(MPI_Comm), INTENT(IN) :: comm
INTEGER, INTENT(IN) :: coords(*)
INTEGER, INTENT(OUT) :: rank
INTEGER, OPTIONAL, INTENT(OUT) :: ierror
INPUT PARAMETERS π
commβ the communicator, and it's gotta have that Cartesian structure (it's a handle).coordsβ Integer array (of sizendims, which was defined by theMPI_Cart_createcall) specifying the Cartesian coordinates of a process.
OUTPUT PARAMETER π
rankβ the rank of the specified process (integer). the moment we've all been waiting for π«Άierrorβ Fortran only: error status (integer).
DESCRIPTION π
so here's the tea: if your process group has a Cartesian structure, MPI_Cart_rank translates those cute logical process coordinates into actual process ranks β the exact ranks the point-to-point routines use. it's giving translator, it's giving middleman, and it ate.
now, for dimension i where periods(i) = true, if the coordinate coords(i) is out of range β like, coords(i) < 0 or coords(i) >= dims(i) β it gets shifted back into the interval 0 =< coords(i) < dims(i) all on its own, automatically, no cap β¨
β οΈ but for nonperiodic dimensions? out-of-range coordinates are erroneous. do not pass go, do not collect $200, bestie π
ERRORS π
almost every MPI routine returns an error value β in C it's the return result of the function, and in Fortran it's the last argument. so yeah, check it.
before that error value comes back to you, the current MPI error handler tied to the communication object (think: communicator, window, file) gets called. and if there's no communication object attached to the MPI call? then the call counts as attached to MPI_COMM_SELF and it'll call the error handler associated with that. but when MPI_COMM_SELF isn't initialized β like 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 instead. you can change that initial error handler by calling MPI_Comm_set_errhandler on MPI_COMM_SELF when you're using the World model, or via the mpi_initial_errhandler CLI argument to mpiexec or the info key to MPI_Comm_spawn/MPI_Comm_spawn_multiple. and if literally no other appropriate error handler has been set, then MPI_ERRORS_RETURN gets called for MPI I/O functions, and MPI_ERRORS_ABORT gets called for all the other MPI functions. periodt.
Open MPI ships three predefined error handlers you can use:
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. chill vibes, honestly π¦
MPI applications can also cook up 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
π heads up: MPI does not guarantee that an MPI program can continue past an error. like, at all. not me finding out the hard way π
check the MPI man page for the full list of MPI error codes, and the Error Handling section of the MPI-3.1 standard if you want the deep lore π
See also:
MPI_Cart_create
COPYRIGHT β
2003-2026, The Open MPI Community
and that's the whole page, bestie π that was MPI_CART_RANK(3) from the Open MPI crew, dated Sep 10, 2026 β go forth and translate your coords, you absolute main character πβ¨
π¦ 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