From 48cae2703b8ae27e9df05d3670cd19d9cc370892 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Wed, 22 Jan 2020 14:34:12 -0500 Subject: [PATCH] move memory allocation for atom style variable data where it belongs and cannot be skipped this fixes the bug reported on lammps-users on 2020-01-22 by Olivier Politano --- src/compute_global_atom.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/compute_global_atom.cpp b/src/compute_global_atom.cpp index 705d9df544..f015ec910a 100644 --- a/src/compute_global_atom.cpp +++ b/src/compute_global_atom.cpp @@ -316,6 +316,10 @@ void ComputeGlobalAtom::compute_peratom() nmax = atom->nmax; memory->destroy(indices); memory->create(indices,nmax,"global/atom:indices"); + if (whichref == VARIABLE) { + memory->destroy(varatom); + memory->create(varatom,nmax,"global/atom:varatom"); + } if (nvalues == 1) { memory->destroy(vector_atom); memory->create(vector_atom,nmax,"global/atom:vector_atom"); @@ -373,12 +377,6 @@ void ComputeGlobalAtom::compute_peratom() } } else if (whichref == VARIABLE) { - if (atom->nmax > nmax) { - nmax = atom->nmax; - memory->destroy(varatom); - memory->create(varatom,nmax,"global/atom:varatom"); - } - input->variable->compute_atom(ref2index,igroup,varatom,1,0); for (i = 0; i < nlocal; i++) if (mask[i] & groupbit)