From af0df870f4ef067d4fd0969aaa9fa801f75fb601 Mon Sep 17 00:00:00 2001 From: Richard Berger Date: Mon, 23 Nov 2020 18:36:28 -0500 Subject: [PATCH] Fix bug introduced by uninitialized moloffset --- src/create_atoms.cpp | 6 +++--- src/molecule.cpp | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/create_atoms.cpp b/src/create_atoms.cpp index e461e4928a..4abb2c4696 100644 --- a/src/create_atoms.cpp +++ b/src/create_atoms.cpp @@ -446,7 +446,7 @@ void CreateAtoms::command(int narg, char **arg) // molcreate = # of molecules I created - int molcreate = (atom->nlocal - nlocal_previous) / onemol->natoms; + tagint molcreate = (atom->nlocal - nlocal_previous) / onemol->natoms; // increment total bonds,angles,etc @@ -463,13 +463,13 @@ void CreateAtoms::command(int narg, char **arg) // moloffset = max molecule ID for all molecules owned by previous procs // including molecules existing before this creation - tagint moloffset; + tagint moloffset = 0; if (molecule_flag) { tagint max = 0; for (int i = 0; i < nlocal_previous; i++) max = MAX(max,molecule[i]); tagint maxmol; MPI_Allreduce(&max,&maxmol,1,MPI_LMP_TAGINT,MPI_MAX,world); - MPI_Scan(&molcreate,&moloffset,1,MPI_INT,MPI_SUM,world); + MPI_Scan(&molcreate,&moloffset,1,MPI_LMP_TAGINT,MPI_SUM,world); moloffset = moloffset - molcreate + maxmol; } diff --git a/src/molecule.cpp b/src/molecule.cpp index 77fa9c82df..d85cf47c71 100644 --- a/src/molecule.cpp +++ b/src/molecule.cpp @@ -760,7 +760,7 @@ void Molecule::molecules(char *line) int iatom = values.next_int() - 1; if (iatom < 0 || iatom >= natoms) error->one(FLERR,"Invalid Molecules section in molecule file"); count[iatom]++; - molecule[iatom] = values.next_int(); + molecule[iatom] = values.next_tagint(); // molecule[iatom] += moffset; // placeholder for possible molecule offset } } catch (TokenizerException &e) {