bugfix from Trung to avoid problems with read_dump when not all MPI ranks have atoms

This commit is contained in:
Axel Kohlmeyer
2025-02-26 13:40:19 -05:00
parent a99a567f0c
commit dc99e204d3

View File

@ -710,12 +710,14 @@ void ReadDump::read_atoms()
while (nsend < nread) {
lo = MAX(ofirst,rfirst);
hi = MIN(olast,rlast);
if (otherproc) // send to otherproc or copy to self
MPI_Send(&buf[nsend][0],(hi-lo)*nfield,MPI_DOUBLE,
int numel = (hi-lo)*nfield;
if (otherproc && numel > 0) { // send to otherproc or copy to self
MPI_Send(&buf[nsend][0],numel,MPI_DOUBLE,
otherproc,0,clustercomm);
}
else
memcpy(&fields[rfirst][0],&buf[nsend][0],
(hi-lo)*nfield*sizeof(double));
numel*sizeof(double));
nsend += hi-lo;
if (hi == olast) {
otherproc++;