From 9c1c10e1c43efcb52ac2f45e39a0ab571a284687 Mon Sep 17 00:00:00 2001 From: sjplimp Date: Mon, 22 Oct 2007 23:26:34 +0000 Subject: [PATCH] git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@1091 f3b2605a-c512-4ea7-a41b-209d697bcdaa --- src/input.cpp | 4 +--- src/output.cpp | 3 ++- src/update.cpp | 20 ++++++++++++++++++++ src/update.h | 1 + 4 files changed, 24 insertions(+), 4 deletions(-) diff --git a/src/input.cpp b/src/input.cpp index 9e71f1b3ad..db125b1f9e 100644 --- a/src/input.cpp +++ b/src/input.cpp @@ -1039,9 +1039,7 @@ void Input::region() void Input::reset_timestep() { - if (narg != 1) error->all("Illegal reset_timestep command"); - update->ntimestep = atoi(arg[0]); - if (update->ntimestep < 0) error->all("Timestep must be >= 0"); + update->reset_timestep(narg,arg); } /* ---------------------------------------------------------------------- */ diff --git a/src/output.cpp b/src/output.cpp index a123c04e72..fb23291bf6 100644 --- a/src/output.cpp +++ b/src/output.cpp @@ -79,6 +79,7 @@ Output::Output(LAMMPS *lmp) : Pointers(lmp) restart = NULL; restart1 = restart2 = NULL; restart_every = 0; + last_restart = -1; } /* ---------------------------------------------------------------------- @@ -357,6 +358,7 @@ void Output::create_restart(int narg, char **arg) delete [] restart2; restart = NULL; restart1 = restart2 = NULL; + last_restart = -1; restart_every = atoi(arg[0]); if (restart_every == 0) { @@ -365,7 +367,6 @@ void Output::create_restart(int narg, char **arg) } restart = new WriteRestart(lmp); - last_restart = -1; int n = strlen(arg[1]) + 3; restart1 = new char[n]; diff --git a/src/update.cpp b/src/update.cpp index d5aef9c9ad..06816edaf3 100644 --- a/src/update.cpp +++ b/src/update.cpp @@ -12,6 +12,7 @@ ------------------------------------------------------------------------- */ #include "string.h" +#include "stdlib.h" #include "update.h" #include "neighbor.h" #include "force.h" @@ -179,6 +180,25 @@ void Update::create_minimize(int narg, char **arg) strcpy(minimize_style,arg[0]); } +/* ---------------------------------------------------------------------- + reset timestep from input script + do not allow dump files or a restart to be defined +------------------------------------------------------------------------- */ + +void Update::reset_timestep(int narg, char **arg) +{ + if (narg != 1) error->all("Illegal reset_timestep command"); + + for (int i = 0; i < output->ndump; i++) + if (output->last_dump[i] >= 0) + error->all("Cannot reset timestep with dump file already written to"); + if (output->restart && output->last_restart >= 0) + error->all("Cannot reset timestep with restart file already written"); + + ntimestep = atoi(arg[0]); + if (ntimestep < 0) error->all("Timestep must be >= 0"); +} + /* ---------------------------------------------------------------------- memory usage of update and integrate/minimize ------------------------------------------------------------------------- */ diff --git a/src/update.h b/src/update.h index c0a9612f1d..4f0a8556ad 100644 --- a/src/update.h +++ b/src/update.h @@ -44,6 +44,7 @@ class Update : protected Pointers { void set_units(const char *); void create_integrate(int, char **); void create_minimize(int, char **); + void reset_timestep(int, char **); double memory_usage(); };