open() method not really needed.

This commit is contained in:
Axel Kohlmeyer
2021-03-03 08:43:23 -05:00
parent f02b0cf09b
commit 2db78823a0
2 changed files with 8 additions and 16 deletions

View File

@ -125,16 +125,21 @@ Molecule::Molecule(LAMMPS *lmp, int narg, char **arg, int &index) :
initialize();
// scan file for sizes of all fields and allocate them
// scan file for sizes of all fields and allocate storage for them
if (me == 0) open(arg[ifile]);
if (me == 0) {
fp = fopen(arg[ifile],"r");
if (fp == nullptr)
error->one(FLERR,fmt::format("Cannot open molecule file {}: {}",
arg[ifile], utils::getsyserror()));
}
read(0);
if (me == 0) fclose(fp);
allocate();
// read file again to populate all fields
if (me == 0) open(arg[ifile]);
if (me == 0) fp = fopen(arg[ifile],"r");
read(1);
if (me == 0) fclose(fp);
@ -1962,18 +1967,6 @@ void Molecule::deallocate()
memory->destroy(dbodyparams);
}
/* ----------------------------------------------------------------------
open molecule file
------------------------------------------------------------------------- */
void Molecule::open(char *file)
{
fp = fopen(file,"r");
if (fp == nullptr)
error->one(FLERR,fmt::format("Cannot open molecule file {}: {}",
file, utils::getsyserror()));
}
/* ----------------------------------------------------------------------
read and bcast a line
------------------------------------------------------------------------- */