make sure a dump with ID WRITE_DUMP does not exist (e.g. as a leftover from a previous crash)
This commit is contained in:
@ -50,15 +50,21 @@ void WriteDump::command(int narg, char **arg)
|
||||
int dumpfreq = MAX(1, update->nsteps);
|
||||
dumpfreq += update->ntimestep % dumpfreq;
|
||||
|
||||
std::string dump_id = "WRITE_DUMP";
|
||||
auto dumpargs = new char *[modindex + 2];
|
||||
dumpargs[0] = (char *) "WRITE_DUMP"; // dump id
|
||||
dumpargs[0] = (char *) dump_id.c_str(); // dump id
|
||||
dumpargs[1] = arg[0]; // group
|
||||
dumpargs[2] = arg[1]; // dump style
|
||||
dumpargs[3] = utils::strdup(std::to_string(dumpfreq)); // dump frequency
|
||||
|
||||
// delete existing dump with same ID to avoid re-use of dump-ID error
|
||||
|
||||
auto *dump = output->get_dump_by_id(dump_id);
|
||||
if (dump) output->delete_dump(dump_id);
|
||||
|
||||
for (int i = 2; i < modindex; ++i) dumpargs[i + 2] = arg[i];
|
||||
|
||||
Dump *dump = output->add_dump(modindex + 2, dumpargs);
|
||||
dump = output->add_dump(modindex + 2, dumpargs);
|
||||
if (modindex < narg) dump->modify_params(narg - modindex - 1, &arg[modindex + 1]);
|
||||
|
||||
// write out one frame and then delete the dump again
|
||||
@ -74,7 +80,7 @@ void WriteDump::command(int narg, char **arg)
|
||||
|
||||
// delete the Dump instance and local storage
|
||||
|
||||
output->delete_dump(dumpargs[0]);
|
||||
output->delete_dump(dump_id);
|
||||
delete[] dumpargs[3];
|
||||
delete[] dumpargs;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user