MPI_Cart_rank finds the corresponding process rank of the cartesian coordinates of a cartesian communicator.
Subroutine MPI_Cart_rank(comm, coords, rank, ierr)
int MPI_Cart_rank(MPI_Comm comm, int *coords, int *rank)
Example in Fortran
|
Once a cartesian communicator has been established, repeated applications
of MPI_Cart_rank for all
possible values of the cartesian coordinates produce
a correlation table of the cartesian coordinates and their corresponding
process ranks.
Shown in Figure a below is the resulting cartesian topology (grid) where the index pair "i,j" represent row "i" and column "j". The number in parentheses represents the rank number associated with the cartesian coordinates.
| 0,0 (0) | 0,1 (1) |
| 1,0 (2) | 1,1 (3) |
| 2,0 (4) | 2,1 (5) |
Here is the fortran code used to generate the above tables.
coords is out of bound.