git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@9416 f3b2605a-c512-4ea7-a41b-209d697bcdaa

This commit is contained in:
sjplimp
2013-02-08 21:38:50 +00:00
parent 906a57d529
commit 7a286596d8
12 changed files with 166 additions and 25 deletions

View File

@ -1454,6 +1454,56 @@ void Comm::reverse_comm_dump(Dump *dump)
}
}
/* ----------------------------------------------------------------------
forward communication of N values in array
------------------------------------------------------------------------- */
void Comm::forward_comm_array(int n, double **array)
{
int i,j,k,m,iswap,last;
double *buf;
MPI_Request request;
MPI_Status status;
// check that buf_send and buf_recv are big enough
for (iswap = 0; iswap < nswap; iswap++) {
// pack buffer
m = 0;
for (i = 0; i < sendnum[iswap]; i++) {
j = sendlist[iswap][i];
for (k = 0; k < n; k++)
buf_send[m++] = array[j][k];
}
// exchange with another proc
// if self, set recv buffer to send buffer
if (sendproc[iswap] != me) {
if (recvnum[iswap])
MPI_Irecv(buf_recv,n*recvnum[iswap],MPI_DOUBLE,recvproc[iswap],0,
world,&request);
if (sendnum[iswap])
MPI_Send(buf_send,n*sendnum[iswap],MPI_DOUBLE,sendproc[iswap],0,world);
if (recvnum[iswap]) MPI_Wait(&request,&status);
buf = buf_recv;
} else buf = buf_send;
// unpack buffer
m = 0;
last = firstrecv[iswap] + recvnum[iswap];
for (i = firstrecv[iswap]; i < last; i++)
for (k = 0; k < n; k++)
array[i][k] = buf[m++];
}
}
/* ----------------------------------------------------------------------
reverse communication invoked by a Dump
------------------------------------------------------------------------- */