avoid memory leak with MPI-IO

This commit is contained in:
Axel Kohlmeyer
2021-08-13 06:25:21 -04:00
parent eaedd9ad48
commit cba8e8237a

View File

@ -44,7 +44,7 @@ using namespace LAMMPS_NS;
/* ---------------------------------------------------------------------- */
ReadRestart::ReadRestart(LAMMPS *lmp) : Command(lmp) {}
ReadRestart::ReadRestart(LAMMPS *lmp) : Command(lmp), mpiio(nullptr) {}
/* ---------------------------------------------------------------------- */
@ -110,8 +110,7 @@ void ReadRestart::command(int narg, char **arg)
}
fp = fopen(hfile.c_str(),"rb");
if (fp == nullptr)
error->one(FLERR,"Cannot open restart file {}: {}",
hfile, utils::getsyserror());
error->one(FLERR,"Cannot open restart file {}: {}", hfile, utils::getsyserror());
}
// read magic string, endian flag, format revision
@ -336,8 +335,7 @@ void ReadRestart::command(int narg, char **arg)
procfile.replace(procfile.find("%"),1,fmt::format("{}",icluster));
fp = fopen(procfile.c_str(),"rb");
if (fp == nullptr)
error->one(FLERR,"Cannot open restart file {}: {}",
procfile, utils::getsyserror());
error->one(FLERR,"Cannot open restart file {}: {}", procfile, utils::getsyserror());
}
int procsperfile;
@ -525,8 +523,9 @@ void ReadRestart::command(int narg, char **arg)
MPI_Barrier(world);
if (comm->me == 0)
utils::logmesg(lmp," read_restart CPU = {:.3f} seconds\n",
MPI_Wtime()-time1);
utils::logmesg(lmp," read_restart CPU = {:.3f} seconds\n",MPI_Wtime()-time1);
delete mpiio;
}
/* ----------------------------------------------------------------------