diff --git a/src/core/Action.cpp b/src/core/Action.cpp index 27e3bb8272..0e1e24c8a4 100644 --- a/src/core/Action.cpp +++ b/src/core/Action.cpp @@ -79,8 +79,7 @@ Action::Action(const ActionOptions&ao): keywords(ao.keys) { // Retrieve the timestep and save it - ActionWithValue* ts = plumed.getActionSet().selectWithLabel("timestep"); - if( ts ) timestep = (ts->copyOutput(0))->get(); + resetStoredTimestep(); line.erase(line.begin()); if( !keywords.exists("NO_ACTION_LOG") ) { @@ -116,6 +115,11 @@ Action::Action(const ActionOptions&ao): } } +void Action::resetStoredTimestep() { + ActionWithValue* ts = plumed.getActionSet().selectWithLabel("timestep"); + if( ts ) timestep = (ts->copyOutput(0))->get(); +} + Action::~Action() { if(files.size()!=0) { std::cerr<<"WARNING: some files open in action "+getLabel()+" where not properly closed. This could lead to data loss!!\n"; diff --git a/src/core/Action.h b/src/core/Action.h index eb6ba11b65..08a5172190 100644 --- a/src/core/Action.h +++ b/src/core/Action.h @@ -329,6 +329,9 @@ class Action { /// Get the defaults std::string getDefaultString() const ; +/// Set the timestep that is stored in the action to the correct value + void resetStoredTimestep(); + /// Get the info on what to calculate virtual std::string writeInGraph() const ; /// Specialized casts, to make PlumedMain run faster diff --git a/src/core/PlumedMain.cpp b/src/core/PlumedMain.cpp index 487650bd65..a5f888088d 100644 --- a/src/core/PlumedMain.cpp +++ b/src/core/PlumedMain.cpp @@ -1406,6 +1406,7 @@ void PlumedMain::setUnits( const bool& natural, const Units& u ) { passtools->usingNaturalUnits = natural; passtools->units=u; std::vector idata = actionSet.select(); for(const auto & ip : idata) ip->updateUnits( passtools.get() ); + for(const auto & p : actionSet ) p->resetStoredTimestep(); } void PlumedMain::startStep() {