exchange.c
#include "array.h"
#include "poisson.h"
void
exchange(dmatrix a, Decomposition oned, Grid grid)
{
/* exchanges the boundary values (ghost points) */
int lx, ly;
MPI_Status status;
lx = oned.lx;
ly = oned.ly;
/* extra boundary points in y are not exchanged, they are constant anyway */
MPI_Send(&INDEX(a, 1, 1), ly, MPI_DOUBLE, grid.down, TAG_DOWN, grid.comm);
MPI_Recv(&INDEX(a, lx+1, 1), ly, MPI_DOUBLE, grid.up, TAG_DOWN,
grid.comm, &status);
MPI_Send(&INDEX(a, lx, 1), ly, MPI_DOUBLE, grid.up, TAG_UP, grid.comm);
MPI_Recv(&INDEX(a, 0, 1), ly, MPI_DOUBLE, grid.down, TAG_UP,
grid.comm, &status);
}

Peter Junglas 11.5.2000