diff --git a/src/core/Atoms.cpp b/src/core/Atoms.cpp
index f4777d2a60ba80e7622be50847566243a675186d..80afd2709cbd2898f15b17904ae177421046095e 100644
--- a/src/core/Atoms.cpp
+++ b/src/core/Atoms.cpp
@@ -339,6 +339,11 @@ void Atoms::setAtomsNlocal(int n){
   gatindex.resize(n);
   if(dd){
     dd.g2l.resize(natoms,-1);
+// Since these vectors are sent with MPI by using e.g.
+// &dd.positionsToBeSent[0]
+// we make sure they are non-zero-sized so as to
+// avoid errors when doing boundary check
+    if(n==0) n++;
     dd.positionsToBeSent.resize(n*5,0.0);
     dd.positionsToBeReceived.resize(natoms*5,0.0);
     dd.indexToBeSent.resize(n,0);