Skip to content
Snippets Groups Projects
Commit 182743e6 authored by Giovanni Bussi's avatar Giovanni Bussi
Browse files

Fixed problem with DD and zero atoms

When there are zero atoms in one of the DD domains,
some arrays are allocated to be zero sized and later
accessed with &array[0].

Whereas this is harmless, it triggers an out-of-boundary
error when plumed is compiled with --enable-debug-glibcxx

The size of those arrays is now guaranteed to be at least 1.
parent 7e93deef
No related branches found
No related tags found
No related merge requests found
......@@ -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);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment