MPI_Cart_coords and MPI_Cart_rank
Given the rank of the process in MPI_COMM_WORLD, this routine gives a two element (for two dimensional topology) array (coords in example below) with the (i, j) coordinates of this process in the new cartesian communicator.
- ierr MPI_Cart_coords (comm2d, rank, ndim, coords);
- coords[0] and coords[1] will be the i and j coordinates.
Given the coords of a process, this routine gives the rank number in the communicator.
- ierr MPI_Cart_coords ( comm2d, coords, &rank);