From bc7109d6e24f5787f81d261b218839ea5f9205ea Mon Sep 17 00:00:00 2001
From: Carlo Camilloni <carlo.camilloni@gmail.com>
Date: Mon, 27 Oct 2014 18:01:30 +0100
Subject: [PATCH] CS2BACKBONE: more prinout fixes

---
 CHANGES/v2.1.txt           |  1 +
 src/colvar/CS2Backbone.cpp | 16 ++++++++--------
 2 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/CHANGES/v2.1.txt b/CHANGES/v2.1.txt
index f6a90c05c..24d99aca9 100644
--- a/CHANGES/v2.1.txt
+++ b/CHANGES/v2.1.txt
@@ -133,5 +133,6 @@ This release will include all the fixes available in branch 2.0.
 For users:
 - Small fixes in documentation.
 - CS2Backbone: fixed a bug that resulted in only a fraction of the chemical shifts being printed with WRITE_CS and parallel simulations
+  (requires to get the last almost updated from SVN)
 
 */
diff --git a/src/colvar/CS2Backbone.cpp b/src/colvar/CS2Backbone.cpp
index 2b2374578..e2811128f 100644
--- a/src/colvar/CS2Backbone.cpp
+++ b/src/colvar/CS2Backbone.cpp
@@ -353,6 +353,14 @@ void CS2Backbone::calculate()
   cam_list[0].ens_return_shifts(coor, sh);
   if(!serial) comm.Sum(&sh[0][0], numResidues*6);
 
+  bool printout=false;
+  if(pperiod>0&&comm.Get_rank()==0) printout = (!(getStep()%pperiod));
+  if(printout) {
+    char tmp1[21]; sprintf(tmp1, "%ld", getStep()); 
+    string csfile = string("cs-")+getLabel()+"-"+tmp1+string(".dat");;
+    cam_list[0].printout_chemical_shifts(csfile.c_str(), sh);
+  }
+
   double fact=1.0;
   if(ensemble) {
     fact = 1./((double) ens_dim);
@@ -369,14 +377,6 @@ void CS2Backbone::calculate()
   double energy = cam_list[0].ens_energy_force(coor, csforces, sh);
   if(!serial) comm.Sum(&csforces[0][0], N*4);
 
-  bool printout=false;
-  if(pperiod>0&&comm.Get_rank()==0) printout = (!(getStep()%pperiod));
-  if(printout) {
-    char tmp1[21]; sprintf(tmp1, "%ld", getStep()); 
-    string csfile = string("cs-")+getLabel()+"-"+tmp1+string(".dat");;
-    cam_list[0].printout_chemical_shifts(csfile.c_str());
-  }
-
   Tensor virial;
   virial.zero();
   double ff=fact*for_pl2alm;
-- 
GitLab