diff --git a/src/molecule.cpp b/src/molecule.cpp index d2c5f6f0fe..8e067937b0 100644 --- a/src/molecule.cpp +++ b/src/molecule.cpp @@ -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 ------------------------------------------------------------------------- */ diff --git a/src/molecule.h b/src/molecule.h index f744a438bc..00b2b123a0 100644 --- a/src/molecule.h +++ b/src/molecule.h @@ -161,7 +161,6 @@ class Molecule : protected Pointers { void allocate(); void deallocate(); - void open(char *); void readline(char *); std::string parse_keyword(int, char *); void skip_lines(int, char *, const std::string &);