avoid segfaults if a dump is created and followed by run pre no

This commit is contained in:
Axel Kohlmeyer
2023-06-20 13:31:16 -04:00
parent 6791651b62
commit fcc3c99e2b
7 changed files with 39 additions and 40 deletions

View File

@ -1,4 +1,3 @@
// clang-format off
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories
@ -29,8 +28,10 @@ using namespace LAMMPS_NS;
/* ---------------------------------------------------------------------- */
DumpAtom::DumpAtom(LAMMPS *lmp, int narg, char **arg) : Dump(lmp, narg, arg)
DumpAtom::DumpAtom(LAMMPS *lmp, int narg, char **arg) :
Dump(lmp, narg, arg), header_choice(nullptr), pack_choice(nullptr)
{
// clang-format off
if (narg != 5) error->all(FLERR,"Illegal dump atom command");
scale_flag = 1;
@ -146,6 +147,8 @@ int DumpAtom::modify_param(int narg, char **arg)
void DumpAtom::write_header(bigint ndump)
{
if (!header_choice) error->all(FLERR, "Must not use 'run pre no' after creating a new dump");
if (multiproc) (this->*header_choice)(ndump);
else if (me == 0) (this->*header_choice)(ndump);
}
@ -154,6 +157,8 @@ void DumpAtom::write_header(bigint ndump)
void DumpAtom::pack(tagint *ids)
{
if (!pack_choice) error->all(FLERR, "Must not use 'run pre no' after creating a new dump");
(this->*pack_choice)(ids);
}