From cdce8cb62d06863219e1ce31ad296c0a1ef19329 Mon Sep 17 00:00:00 2001
From: Giovanni Bussi <giovanni.bussi@gmail.com>
Date: Fri, 2 Dec 2011 11:38:57 +0100
Subject: [PATCH] Moved deactivation of actions to the beginning of
 calculation.

Instead of deactivating actions at the end of the step, I prefer
to deactivate all of them just before activation. In this manner, all
dependencies are touched in the prepareDependencies method.
---
 src/PlumedMain.cpp | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/PlumedMain.cpp b/src/PlumedMain.cpp
index d807fa2c8..02ce20ffe 100644
--- a/src/PlumedMain.cpp
+++ b/src/PlumedMain.cpp
@@ -369,6 +369,10 @@ void PlumedMain::prepareDependencies(){
 // new/changed dependency (up to now, only useful for dependences on virtual atoms,
 // which can be dynamically changed).
 //
+
+// First switch off all actions
+  for(ActionSet::iterator p=actionSet.begin();p!=actionSet.end();p++) (*p)->deactivate();
+
 // for optimization, an "active" flag remains false if no action at all is active
   active=false;
   for(unsigned i=0;i<pilots.size();++i){
@@ -432,9 +436,6 @@ void PlumedMain::performCalc(){
 // this is updating the MD copy of the forces
   atoms.updateForces();
 
-// Finally switch off all actions (they will be switched on at next step
-  for(ActionSet::iterator p=actionSet.begin();p!=actionSet.end();p++) (*p)->deactivate();
-
 }
 
 void PlumedMain::load(std::vector<std::string> & words){
-- 
GitLab