Example
dim_sizes[0] = dim_sizes[1] = q;
wrap_around[0] = wrap_around[1] = 1;
MPI_Cart_create( MPI_COMM_WORLD,2, dim_sizes, wrap_around,
MPI_Comm_rank( grid_comm, &my_grid_rank);
MPI_Cart_coords( grid_comm, my_grid_rank, 2, coords);
(need to call MPI_Comm_rank because we’ve reordered)
MPI_Cart_rank( grid_comm, coords, &grid_rank);