From dc99e204d3b0fb7d55b9eb90ce884c39ff4fab02 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Wed, 26 Feb 2025 13:40:19 -0500 Subject: [PATCH] bugfix from Trung to avoid problems with read_dump when not all MPI ranks have atoms --- src/read_dump.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/read_dump.cpp b/src/read_dump.cpp index 5972b369c8..59fe6c6767 100644 --- a/src/read_dump.cpp +++ b/src/read_dump.cpp @@ -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++;