1 | The routine MPI_Cart_shift finds the neighbors in each direction of the new communicator. |
2 | dir = 0; // in C 0 for columns, 1 for rows |
3 | // in Fortran, it's 1 and 2 |
4 | disp = 1; // specifies first neighbor to the right and left |
5 | ierr = MPI_Cart_shift (comm2d, dir, disp, &nbrbottom, |
6 | &nbrtop): |
7 | This returns the process numbers (ranks) for a communication of the bottom and top neighbors. |
8 | If a process in a non-periodic mesh is on the border and has no neighbor, then the value MPI_PROCNULL is returned. This process value can be used in a send/recv, but it will have no effect. |