Fix bug introduced by uninitialized moloffset

This commit is contained in:
Richard Berger
2020-11-23 18:36:28 -05:00
parent d59aba43e7
commit af0df870f4
2 changed files with 4 additions and 4 deletions

View File

@ -446,7 +446,7 @@ void CreateAtoms::command(int narg, char **arg)
// molcreate = # of molecules I created // 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 // 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 // moloffset = max molecule ID for all molecules owned by previous procs
// including molecules existing before this creation // including molecules existing before this creation
tagint moloffset; tagint moloffset = 0;
if (molecule_flag) { if (molecule_flag) {
tagint max = 0; tagint max = 0;
for (int i = 0; i < nlocal_previous; i++) max = MAX(max,molecule[i]); for (int i = 0; i < nlocal_previous; i++) max = MAX(max,molecule[i]);
tagint maxmol; tagint maxmol;
MPI_Allreduce(&max,&maxmol,1,MPI_LMP_TAGINT,MPI_MAX,world); 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; moloffset = moloffset - molcreate + maxmol;
} }

View File

@ -760,7 +760,7 @@ void Molecule::molecules(char *line)
int iatom = values.next_int() - 1; int iatom = values.next_int() - 1;
if (iatom < 0 || iatom >= natoms) error->one(FLERR,"Invalid Molecules section in molecule file"); if (iatom < 0 || iatom >= natoms) error->one(FLERR,"Invalid Molecules section in molecule file");
count[iatom]++; count[iatom]++;
molecule[iatom] = values.next_int(); molecule[iatom] = values.next_tagint();
// molecule[iatom] += moffset; // placeholder for possible molecule offset // molecule[iatom] += moffset; // placeholder for possible molecule offset
} }
} catch (TokenizerException &e) { } catch (TokenizerException &e) {