56 int *iproc = mpi->
iproc;
59 int neighbor_rank[2*ndims], nip[ndims], index[ndims], bounds[ndims], offset[ndims];
60 MPI_Request rcvreq[2*ndims], sndreq[2*ndims];
61 for (d=0; d<2*ndims; d++) rcvreq[d] = sndreq[d] = MPI_REQUEST_NULL;
65 for (d = 0; d < ndims; d++) {
67 if (ip[d] == 0) nip[d] = iproc[d]-1;
69 if ((ip[d] == 0) && (!bcflag[d])) neighbor_rank[2*d] = -1;
70 else neighbor_rank[2*d] =
MPIRank1D(ndims,iproc,nip);
72 if (ip[d] == (iproc[d]-1)) nip[d] = 0;
74 if ((ip[d] == (iproc[d]-1)) && (!bcflag[d])) neighbor_rank[2*d+1] = -1;
75 else neighbor_rank[2*d+1] =
MPIRank1D(ndims,iproc,nip);
83 for (d = 0; d < ndims; d++) {
86 for (i = 0; i < ndims; i++) {
87 if (i == d) bufdim[d] *= ghosts;
88 else bufdim[d] *= dim[i];
93 for (d = 0; d < ndims; d++) {
94 if (neighbor_rank[2*d ] != -1) {
95 MPI_Irecv(&recvbuf[2*d*stride],bufdim[d]*nvars,MPI_DOUBLE,neighbor_rank[2*d ],1630,
96 mpi->
world,&rcvreq[2*d]);
98 if (neighbor_rank[2*d+1] != -1) {
99 MPI_Irecv(&recvbuf[(2*d+1)*stride],bufdim[d]*nvars,MPI_DOUBLE,neighbor_rank[2*d+1],1631,
100 mpi->
world,&rcvreq[2*d+1]);
105 for (d = 0; d < ndims; d++) {
107 if (neighbor_rank[2*d] != -1) {
113 _ArrayCopy1D_((var+nvars*p1),(sendbuf+2*d*stride+nvars*p2),nvars);
117 if (neighbor_rank[2*d+1] != -1) {
123 _ArrayCopy1D_((var+nvars*p1),(sendbuf+(2*d+1)*stride+nvars*p2),nvars);
130 for (d = 0; d < ndims; d++) {
131 if (neighbor_rank[2*d ] != -1) {
132 MPI_Isend(&sendbuf[2*d*stride],bufdim[d]*nvars,MPI_DOUBLE,neighbor_rank[2*d ],1631,
133 mpi->
world,&sndreq[2*d]);
135 if (neighbor_rank[2*d+1] != -1) {
136 MPI_Isend(&sendbuf[(2*d+1)*stride],bufdim[d]*nvars,MPI_DOUBLE,neighbor_rank[2*d+1],1630,
137 mpi->
world,&sndreq[2*d+1]);
142 MPI_Status status_arr[2*ndims];
143 MPI_Waitall(2*ndims,rcvreq,status_arr);
145 for (d = 0; d < ndims; d++) {
147 if (neighbor_rank[2*d] != -1) {
153 _ArrayCopy1D_((recvbuf+2*d*stride+nvars*p2),(var+nvars*p1),nvars);
157 if (neighbor_rank[2*d+1] != -1) {
163 _ArrayCopy1D_((recvbuf+(2*d+1)*stride+nvars*p2),(var+nvars*p1),nvars);
169 MPI_Waitall(2*ndims,sndreq,status_arr);
MPI related function definitions.
Some basic definitions and macros.
int MPIRank1D(int, int *, int *)
#define _ArrayIndex1D_(N, imax, i, ghost, index)
#define _ArrayIndex1DWO_(N, imax, i, offset, ghost, index)
#define _ArraySetValue_(x, size, value)
#define _ArrayIncrementIndex_(N, imax, i, done)
int MPIExchangeBoundariesnD(int ndims, int nvars, int *dim, int ghosts, void *m, double *var)
Structure of MPI-related variables.
#define _ArrayCopy1D_(x, y, size)
Contains macros and function definitions for common array operations.