From c1049ce124cf51427e668e564e432db820564de9 Mon Sep 17 00:00:00 2001
From: Giovanni Bussi <giovanni.bussi@gmail.com>
Date: Fri, 2 Dec 2011 12:38:19 +0100
Subject: [PATCH] Splitting performCalc into pieces

In particular, I would like to be able to just do the
"forward" loop (calculate()) and not the "backward" loop
(apply()). In this manner, when computing foreign biases
for acceptance in replica exchange, I will only call the
forward loop, which computes colvars and biases. Clearly,
we should move printing/analysis/hills-adding stuff
outside the "calculate" method, so as to avoid doing these
things in the acceptance calculation. I wait for this further
cleaning since, until replica exchange is not actually there,
there is no practical difference. Also, we may decide to change
a bit the name of methods (calculate/apply are becoming a bit
misleading?)
---
 src/PlumedMain.cpp | 13 ++++++++++++-
 src/PlumedMain.h   |  4 ++++
 2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/src/PlumedMain.cpp b/src/PlumedMain.cpp
index 02ce20ffe..3b7bcd4be 100644
--- a/src/PlumedMain.cpp
+++ b/src/PlumedMain.cpp
@@ -401,11 +401,19 @@ void PlumedMain::shareData(){
   atoms.share();
 }
 
-
 void PlumedMain::performCalc(){
+  waitData();
+  justCalculate();
+  justApply();
+}
 
+void PlumedMain::waitData(){
   if(!active)return;
   atoms.wait();
+}
+
+
+void PlumedMain::justCalculate(){
 
 // calculate the active actions in order (assuming *backward* dependence)
   for(ActionSet::iterator p=actionSet.begin();p!=actionSet.end();++p){
@@ -424,6 +432,9 @@ void PlumedMain::performCalc(){
       else (*p)->calculate();
     }
   }
+}
+
+void PlumedMain::justApply(){
   
 // apply them in reverse order
   for(ActionSet::reverse_iterator p=actionSet.rbegin();p!=actionSet.rend();++p){
diff --git a/src/PlumedMain.h b/src/PlumedMain.h
index 1f32fa785..0b4a3835a 100644
--- a/src/PlumedMain.h
+++ b/src/PlumedMain.h
@@ -107,6 +107,10 @@ public:
   void performCalc();
 /// Shortcut for prepareCalc() + performCalc()
   void calc();
+
+  void waitData();
+  void justCalculate();
+  void justApply();
 /// Reference to atoms object
   Atoms& getAtoms();
 /// Reference to the list of Action's
-- 
GitLab