Merge release-5-0 into release-5-1
[alexxy/gromacs.git] / src / gromacs / mdlib / stat.cpp
similarity index 79%
rename from src/gromacs/mdlib/stat.c
rename to src/gromacs/mdlib/stat.cpp
index 31bfe06b43883b946a82a0278fae9e0f5394383d..8e3e368159d848692df5fce147fb4031b28f62e8 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014,2016, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2015,2016, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
  * To help us fund GROMACS development, we humbly ask that you cite
  * the research papers on the package. Check out http://www.gromacs.org.
  */
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "gmxpre.h"
 
-#include <string.h>
 #include <stdio.h>
-#include "typedefs.h"
-#include "types/commrec.h"
-#include "sysstuff.h"
-#include "gmx_fatal.h"
-#include "network.h"
-#include "txtdump.h"
-#include "names.h"
-#include "physics.h"
-#include "vec.h"
-#include "gromacs/math/utilities.h"
-#include "main.h"
-#include "force.h"
-#include "vcm.h"
-#include "gromacs/utility/smalloc.h"
-#include "gromacs/fileio/futil.h"
-#include "network.h"
-#include "rbin.h"
-#include "tgroup.h"
-#include "gromacs/fileio/xtcio.h"
+#include <string.h>
+
+#include "gromacs/domdec/domdec.h"
 #include "gromacs/fileio/gmxfio.h"
 #include "gromacs/fileio/trnio.h"
-#include "domdec.h"
-#include "constr.h"
-#include "checkpoint.h"
-#include "xvgr.h"
-#include "md_support.h"
-#include "mdrun.h"
-#include "sim_util.h"
+#include "gromacs/fileio/xtcio.h"
+#include "gromacs/legacyheaders/checkpoint.h"
+#include "gromacs/legacyheaders/constr.h"
+#include "gromacs/legacyheaders/force.h"
+#include "gromacs/legacyheaders/md_support.h"
+#include "gromacs/legacyheaders/mdrun.h"
+#include "gromacs/legacyheaders/names.h"
+#include "gromacs/legacyheaders/network.h"
+#include "gromacs/legacyheaders/rbin.h"
+#include "gromacs/legacyheaders/sim_util.h"
+#include "gromacs/legacyheaders/tgroup.h"
+#include "gromacs/legacyheaders/txtdump.h"
+#include "gromacs/legacyheaders/typedefs.h"
+#include "gromacs/legacyheaders/vcm.h"
+#include "gromacs/legacyheaders/types/commrec.h"
+#include "gromacs/math/utilities.h"
+#include "gromacs/math/vec.h"
+#include "gromacs/utility/fatalerror.h"
+#include "gromacs/utility/futil.h"
+#include "gromacs/utility/smalloc.h"
 
 typedef struct gmx_global_stat
 {
@@ -165,14 +159,13 @@ void global_stat(FILE *fplog, gmx_global_stat_t gs,
     int        nener, j;
     real      *rmsd_data = NULL;
     double     nb;
-    gmx_bool   bVV, bTemp, bEner, bPres, bConstrVir, bEkinAveVel, bFirstIterate, bReadEkin;
+    gmx_bool   bVV, bTemp, bEner, bPres, bConstrVir, bEkinAveVel, bReadEkin;
 
     bVV           = EI_VV(inputrec->eI);
     bTemp         = flags & CGLO_TEMPERATURE;
     bEner         = flags & CGLO_ENERGY;
     bPres         = (flags & CGLO_PRESSURE);
     bConstrVir    = (flags & CGLO_CONSTRAINT);
-    bFirstIterate = (flags & CGLO_FIRSTITERATE);
     bEkinAveVel   = (inputrec->eI == eiVV || (inputrec->eI == eiVVAK && bPres));
     bReadEkin     = (flags & CGLO_READEKIN);
 
@@ -235,7 +228,7 @@ void global_stat(FILE *fplog, gmx_global_stat_t gs,
     }
     where();
 
-    if ((bPres || !bVV) && bFirstIterate)
+    if (bPres)
     {
         ifv = add_binr(rb, DIM*DIM, fvir[0]);
     }
@@ -244,10 +237,7 @@ void global_stat(FILE *fplog, gmx_global_stat_t gs,
     if (bEner)
     {
         where();
-        if (bFirstIterate)
-        {
-            ie  = add_binr(rb, nener, copyenerd);
-        }
+        ie  = add_binr(rb, nener, copyenerd);
         where();
         if (constr)
         {
@@ -263,21 +253,18 @@ void global_stat(FILE *fplog, gmx_global_stat_t gs,
             where();
         }
 
-        if (bFirstIterate)
+        for (j = 0; (j < egNR); j++)
         {
-            for (j = 0; (j < egNR); j++)
+            inn[j] = add_binr(rb, enerd->grpp.nener, enerd->grpp.ener[j]);
+        }
+        where();
+        if (inputrec->efep != efepNO)
+        {
+            idvdll  = add_bind(rb, efptNR, enerd->dvdl_lin);
+            idvdlnl = add_bind(rb, efptNR, enerd->dvdl_nonlin);
+            if (enerd->n_lambda > 0)
             {
-                inn[j] = add_binr(rb, enerd->grpp.nener, enerd->grpp.ener[j]);
-            }
-            where();
-            if (inputrec->efep != efepNO)
-            {
-                idvdll  = add_bind(rb, efptNR, enerd->dvdl_lin);
-                idvdlnl = add_bind(rb, efptNR, enerd->dvdl_nonlin);
-                if (enerd->n_lambda > 0)
-                {
-                    iepl = add_bind(rb, enerd->n_lambda, enerd->enerpart_lambda);
-                }
+                iepl = add_bind(rb, enerd->n_lambda, enerd->enerpart_lambda);
             }
         }
     }
@@ -354,50 +341,47 @@ void global_stat(FILE *fplog, gmx_global_stat_t gs,
             where();
         }
     }
-    if ((bPres || !bVV) && bFirstIterate)
+    if (bPres)
     {
         extract_binr(rb, ifv, DIM*DIM, fvir[0]);
     }
 
     if (bEner)
     {
-        if (bFirstIterate)
+        extract_binr(rb, ie, nener, copyenerd);
+        if (rmsd_data)
         {
-            extract_binr(rb, ie, nener, copyenerd);
-            if (rmsd_data)
-            {
-                extract_binr(rb, irmsd, inputrec->eI == eiSD2 ? 3 : 2, rmsd_data);
-            }
-            if (!NEED_MUTOT(*inputrec))
-            {
-                extract_binr(rb, imu, DIM, mu_tot);
-            }
+            extract_binr(rb, irmsd, inputrec->eI == eiSD2 ? 3 : 2, rmsd_data);
+        }
+        if (!NEED_MUTOT(*inputrec))
+        {
+            extract_binr(rb, imu, DIM, mu_tot);
+        }
 
-            for (j = 0; (j < egNR); j++)
+        for (j = 0; (j < egNR); j++)
+        {
+            extract_binr(rb, inn[j], enerd->grpp.nener, enerd->grpp.ener[j]);
+        }
+        if (inputrec->efep != efepNO)
+        {
+            extract_bind(rb, idvdll, efptNR, enerd->dvdl_lin);
+            extract_bind(rb, idvdlnl, efptNR, enerd->dvdl_nonlin);
+            if (enerd->n_lambda > 0)
             {
-                extract_binr(rb, inn[j], enerd->grpp.nener, enerd->grpp.ener[j]);
+                extract_bind(rb, iepl, enerd->n_lambda, enerd->enerpart_lambda);
             }
-            if (inputrec->efep != efepNO)
-            {
-                extract_bind(rb, idvdll, efptNR, enerd->dvdl_lin);
-                extract_bind(rb, idvdlnl, efptNR, enerd->dvdl_nonlin);
-                if (enerd->n_lambda > 0)
-                {
-                    extract_bind(rb, iepl, enerd->n_lambda, enerd->enerpart_lambda);
-                }
-            }
-            if (DOMAINDECOMP(cr))
+        }
+        if (DOMAINDECOMP(cr))
+        {
+            extract_bind(rb, inb, 1, &nb);
+            if ((int)(nb + 0.5) != cr->dd->nbonded_global)
             {
-                extract_bind(rb, inb, 1, &nb);
-                if ((int)(nb + 0.5) != cr->dd->nbonded_global)
-                {
-                    dd_print_missing_interactions(fplog, cr, (int)(nb + 0.5), top_global, state_local);
-                }
+                dd_print_missing_interactions(fplog, cr, (int)(nb + 0.5), top_global, state_local);
             }
-            where();
-
-            filter_enerdterm(copyenerd, FALSE, enerd->term, bTemp, bPres, bEner);
         }
+        where();
+
+        filter_enerdterm(copyenerd, FALSE, enerd->term, bTemp, bPres, bEner);
     }
 
     if (vcm)