diff --git a/src/atom.cpp b/src/atom.cpp index 785012d57a..6578016208 100644 --- a/src/atom.cpp +++ b/src/atom.cpp @@ -145,11 +145,8 @@ Atom::Atom(LAMMPS *lmp) : Pointers(lmp) map_bucket = NULL; map_hash = NULL; - // default atom style = atomic - atom_style = NULL; avec = NULL; - create_avec("atomic",0,NULL,lmp->suffix); datamask = ALL_MASK; datamask_ext = ALL_MASK; @@ -277,6 +274,7 @@ void Atom::create_avec(const char *style, int narg, char **arg, char *suffix) int sflag; avec = new_avec(style,suffix,sflag); avec->settings(narg,arg); + avec->grow(1); if (sflag) { char estyle[256]; diff --git a/src/input.cpp b/src/input.cpp index 2631113ad1..edea3342f3 100644 --- a/src/input.cpp +++ b/src/input.cpp @@ -1007,7 +1007,7 @@ void Input::atom_style() // use grow to initialize atom-based arrays to length 1 // so that x[0][0] can be referenced even if proc has no atoms - atom->avec->grow(1); + //atom->avec->grow(1); } /* ---------------------------------------------------------------------- */ diff --git a/src/lammps.cpp b/src/lammps.cpp index acaf2041f5..97376a4951 100644 --- a/src/lammps.cpp +++ b/src/lammps.cpp @@ -449,14 +449,15 @@ LAMMPS::~LAMMPS() void LAMMPS::create() { - atom = new Atom(this); - - if (cuda) neighbor = new NeighborCuda(this); - else neighbor = new Neighbor(this); + // Comm class must be created before Atom + // so that nthreads is defined when create_avec invokes grow() if (cuda) comm = new CommCuda(this); else comm = new Comm(this); + if (cuda) neighbor = new NeighborCuda(this); + else neighbor = new Neighbor(this); + if (cuda) domain = new DomainCuda(this); #ifdef LMP_USER_OMP else domain = new DomainOMP(this); @@ -464,11 +465,8 @@ void LAMMPS::create() else domain = new Domain(this); #endif - // use grow to initialize atom-based arrays to length 1 - // so that x[0][0] can be referenced even if proc has no atoms - // must be done after nthreads is defined by Comm class - - atom->avec->grow(1); + atom = new Atom(this); + atom->create_avec("atomic",0,NULL,suffix); group = new Group(this); force = new Force(this); // must be after group, to create temperature