Finding neighbors


Up: Topologies Next: Who am I? Previous: Defining a Cartesian Topology

MPI_Cart_create creates a new communicator with the same processes as the input communicator, but with the specified topology.

The question, Who are my neighbors, can now be answered with MPI_Cart_shift:


call MPI_CART_SHIFT( comm2d, 0,  1,  
                     nbrleft, nbrright, ierr ) 
call MPI_CART_SHIFT( comm2d, 1,  1,  
                     nbrbottom, nbrtop, ierr ) 
The values returned are the ranks, in the communicator comm2d, of the neighbors shifted by in the two dimensions.



Up: Topologies Next: Who am I? Previous: Defining a Cartesian Topology