Convert some mdrun utility code to C++
authorMark Abraham <mark.j.abraham@gmail.com>
Tue, 7 Jul 2015 10:03:30 +0000 (12:03 +0200)
committerErik Lindahl <erik@kth.se>
Sun, 26 Jul 2015 17:42:35 +0000 (19:42 +0200)
Eliminated unused variables, used std::min/max, renamed "try" variable
to "attempt" to avoid reserved word, moved declaration of MPI-specific
variables, added space between string literals intended for
concatenation, moved some variable declarations inside matching
preprocessor regions.

Change-Id: Id16fea81d90f15de9a8e8e6eadeb364df954fff7

19 files changed:
src/gromacs/gmxlib/calcgrid.cpp [moved from src/gromacs/gmxlib/calcgrid.c with 94% similarity]
src/gromacs/gmxlib/chargegroup.cpp [moved from src/gromacs/gmxlib/chargegroup.c with 99% similarity]
src/gromacs/gmxlib/disre.cpp [moved from src/gromacs/gmxlib/disre.c with 97% similarity]
src/gromacs/gmxlib/ifunc.cpp [moved from src/gromacs/gmxlib/ifunc.c with 99% similarity]
src/gromacs/gmxlib/inputrec.cpp [moved from src/gromacs/gmxlib/inputrec.c with 97% similarity]
src/gromacs/gmxlib/md_logging.cpp [moved from src/gromacs/gmxlib/md_logging.c with 97% similarity]
src/gromacs/gmxlib/names.cpp [moved from src/gromacs/gmxlib/names.c with 100% similarity]
src/gromacs/gmxlib/network.cpp [moved from src/gromacs/gmxlib/network.c with 99% similarity]
src/gromacs/gmxlib/orires.cpp [moved from src/gromacs/gmxlib/orires.c with 99% similarity]
src/gromacs/gmxlib/rbin.cpp [moved from src/gromacs/gmxlib/rbin.c with 100% similarity]
src/gromacs/gmxlib/sighandler.cpp [moved from src/gromacs/gmxlib/sighandler.c with 100% similarity]
src/gromacs/gmxlib/txtdump.cpp [moved from src/gromacs/gmxlib/txtdump.c with 98% similarity]
src/gromacs/gmxlib/typedefs.cpp [moved from src/gromacs/gmxlib/typedefs.c with 99% similarity]
src/gromacs/mdlib/compute_io.cpp [moved from src/gromacs/mdlib/compute_io.c with 98% similarity]
src/gromacs/mdlib/ebin.cpp [moved from src/gromacs/mdlib/ebin.c with 99% similarity]
src/gromacs/mdlib/mdebin.cpp [moved from src/gromacs/mdlib/mdebin.c with 98% similarity]
src/gromacs/mdlib/mdebin_bar.cpp [moved from src/gromacs/mdlib/mdebin_bar.c with 99% similarity]
src/gromacs/mdlib/perf_est.cpp [moved from src/gromacs/mdlib/perf_est.c with 94% similarity]
src/gromacs/mdlib/tgroup.cpp [moved from src/gromacs/mdlib/tgroup.c with 98% similarity]

similarity index 94%
rename from src/gromacs/gmxlib/calcgrid.c
rename to src/gromacs/gmxlib/calcgrid.cpp
index 7bbee76f1260ad0a81493ba9ee3ed1e0f5bf7eb9..80da0e1a396ae58606c4d38242c81ed5cadfe1d2 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) 2012,2014, by the GROMACS development team, led by
+ * Copyright (c) 2012,2014,2015, 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.
@@ -65,7 +65,7 @@ real calc_grid(FILE *fp, matrix box, real gr_sp,
     int  d, n[DIM];
     int  i;
     rvec box_size;
-    int  nmin, fac2, try;
+    int  nmin, fac2, attempt;
     rvec spacing;
     real max_spacing;
 
@@ -143,12 +143,12 @@ real calc_grid(FILE *fp, matrix box, real gr_sp,
                 /* Find the smallest grid that is >= nmin */
                 do
                 {
-                    try = fac2*grid_base[i];
+                    attempt = fac2*grid_base[i];
                     /* We demand a factor of 4, avoid 140, allow 90 */
-                    if (((try % 4 == 0 && try != 140) || try == 90) &&
-                        try >= nmin)
+                    if (((attempt % 4 == 0 && attempt != 140) || attempt == 90) &&
+                        attempt >= nmin)
                     {
-                        n[d] = try;
+                        n[d] = attempt;
                     }
                     i--;
                 }
similarity index 99%
rename from src/gromacs/gmxlib/chargegroup.c
rename to src/gromacs/gmxlib/chargegroup.cpp
index 41e152518dda92a4a98f119b3f0cf06aa6256170..aaf9d131671e377f77f2e60b86837b8e3fe5a533 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, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2015, 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.
similarity index 97%
rename from src/gromacs/gmxlib/disre.c
rename to src/gromacs/gmxlib/disre.cpp
index 8e2fefd24f61135c711984d5bee998eadba38eb0..cecfb04bfac6acd65981e5b725034f47d261c33d 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, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2015, 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.
@@ -44,6 +44,8 @@
 #include <math.h>
 #include <stdlib.h>
 
+#include <algorithm>
+
 #include "gromacs/legacyheaders/copyrite.h"
 #include "gromacs/legacyheaders/macros.h"
 #include "gromacs/legacyheaders/main.h"
@@ -62,8 +64,7 @@ void init_disres(FILE *fplog, const gmx_mtop_t *mtop,
                  t_inputrec *ir, const t_commrec *cr,
                  t_fcdata *fcd, t_state *state, gmx_bool bIsREMD)
 {
-    int                  fa, nmol, i, npair, np;
-    t_iparams           *ip;
+    int                  fa, nmol, npair, np;
     t_disresdata        *dd;
     history_t           *hist;
     gmx_mtop_ilistloop_t iloop;
@@ -112,8 +113,6 @@ void init_disres(FILE *fplog, const gmx_mtop_t *mtop,
     }
     dd->ETerm1        = 1.0 - dd->ETerm;
 
-    ip = mtop->ffparams.iparams;
-
     dd->nres  = 0;
     dd->npair = 0;
     iloop     = gmx_mtop_ilistloop_init(mtop);
@@ -222,7 +221,7 @@ void init_disres(FILE *fplog, const gmx_mtop_t *mtop,
         if (fplog)
         {
             fprintf(fplog, "Our ensemble consists of systems:");
-            for (i = 0; i < dd->nsystems; i++)
+            for (int i = 0; i < dd->nsystems; i++)
             {
                 fprintf(fplog, " %d",
                         (cr->ms->sim/dd->nsystems)*dd->nsystems+i);
@@ -266,12 +265,11 @@ void calc_disres_R_6(int nfa, const t_iatom forceatoms[], const t_iparams ip[],
                      t_fcdata *fcd, history_t *hist)
 {
     atom_id         ai, aj;
-    int             fa, res, i, pair, ki, kj, m;
+    int             fa, res, pair;
     int             type, npair, np;
     rvec            dx;
     real           *rt, *rm3tav, *Rtl_6, *Rt_6, *Rtav_6;
     real            rt_1, rt_3, rt2;
-    ivec            it, jt, dt;
     t_disresdata   *dd;
     real            ETerm, ETerm1, cf1 = 0, cf2 = 0, invn = 0;
     gmx_bool        bTav;
@@ -387,7 +385,7 @@ real ta_disres(int nfa, const t_iatom forceatoms[], const t_iparams ip[],
     real            tav_viol_Rtav7, instant_viol_Rtav7;
     real            up1, up2, low;
     gmx_bool        bConservative, bMixed, bViolation;
-    ivec            it, jt, dt;
+    ivec            dt;
     t_disresdata   *dd;
     int             dr_weighting;
     gmx_bool        dr_bMixed;
@@ -516,7 +514,7 @@ real ta_disres(int nfa, const t_iatom forceatoms[], const t_iparams ip[],
             /* Correct the force for the number of restraints */
             if (bConservative)
             {
-                f_scal  = max(f_scal, fmax_scal);
+                f_scal  = std::max(f_scal, fmax_scal);
                 if (!bMixed)
                 {
                     f_scal *= Rtav/Rtav_6[res];
@@ -531,7 +529,7 @@ real ta_disres(int nfa, const t_iatom forceatoms[], const t_iparams ip[],
             else
             {
                 f_scal /= (real)npair;
-                f_scal  = max(f_scal, fmax_scal);
+                f_scal  = std::max(f_scal, fmax_scal);
             }
 
             /* Exert the force ... */
similarity index 99%
rename from src/gromacs/gmxlib/ifunc.c
rename to src/gromacs/gmxlib/ifunc.cpp
index e7e42f66447e97fc1cf81582805fb4dc9f98b186..09a91e2d346cf3d44d9eca19b546ff70818b5d58 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, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2015, 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.
similarity index 97%
rename from src/gromacs/gmxlib/inputrec.c
rename to src/gromacs/gmxlib/inputrec.cpp
index ad48b85814f6b411515fe72a08af9b275188caa0..cf642041c354f4552a2556fee1dfdbc0cfd8d7e8 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2010, The GROMACS development team.
- * Copyright (c) 2012,2014, by the GROMACS development team, led by
+ * Copyright (c) 2012,2014,2015, 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.
@@ -38,6 +38,8 @@
 
 #include "gromacs/legacyheaders/inputrec.h"
 
+#include <algorithm>
+
 #include "gromacs/legacyheaders/macros.h"
 #include "gromacs/legacyheaders/typedefs.h"
 #include "gromacs/utility/fatalerror.h"
@@ -116,7 +118,7 @@ int ir_optimal_nsttcouple(const t_inputrec *ir)
         {
             if (ir->opts.tau_t[g] > 0)
             {
-                tau_min = min(tau_min, ir->opts.tau_t[g]);
+                tau_min = std::min(tau_min, ir->opts.tau_t[g]);
             }
         }
     }
similarity index 97%
rename from src/gromacs/gmxlib/md_logging.c
rename to src/gromacs/gmxlib/md_logging.cpp
index cee3c06ba60857198e07f177b20e004692e186d9..23ac56230cd2f5679ecdf2c415fd6e0aee1e4196 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) 2012,2014, by the GROMACS development team, led by
+ * Copyright (c) 2012,2014,2015, 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.
similarity index 99%
rename from src/gromacs/gmxlib/network.c
rename to src/gromacs/gmxlib/network.cpp
index 94905661e1c4b89bc11b4cc88c76f18b043f9d62..5ac06a00aeb7eb5b251b9dc024422acae8cc587b 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, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2015, 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.
@@ -138,7 +138,6 @@ t_commrec *reinitialize_commrec_for_this_thread(const t_commrec gmx_unused *cro)
 void gmx_setup_nodecomm(FILE gmx_unused *fplog, t_commrec *cr)
 {
     gmx_nodecomm_t *nc;
-    int             n, rank, nodehash, ng, ni;
 
     /* Many MPI implementations do not optimize MPI_Allreduce
      * (and probably also other global communication calls)
@@ -156,6 +155,8 @@ void gmx_setup_nodecomm(FILE gmx_unused *fplog, t_commrec *cr)
     nc->bUse = FALSE;
 #ifndef GMX_THREAD_MPI
 #ifdef GMX_MPI
+    int n, rank, nodehash, ng, ni;
+
     MPI_Comm_size(cr->mpi_comm_mygroup, &n);
     MPI_Comm_rank(cr->mpi_comm_mygroup, &rank);
 
similarity index 99%
rename from src/gromacs/gmxlib/orires.c
rename to src/gromacs/gmxlib/orires.cpp
index 1d15a6a4cced171f4ff07036b3507da8aec92670..f67d2bb5426ae7a5f478fcbf20f5267e7ba62b05 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, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2015, 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.
similarity index 98%
rename from src/gromacs/gmxlib/txtdump.c
rename to src/gromacs/gmxlib/txtdump.cpp
index db4b587bbb4e8c791380b973f5c310e6cb2e9b68..c39508d05dbd7df312e7abd584a83181ea727bb6 100644 (file)
@@ -43,6 +43,8 @@
 #include <stdio.h>
 #include <stdlib.h>
 
+#include <algorithm>
+
 #include "gromacs/legacyheaders/macros.h"
 #include "gromacs/legacyheaders/names.h"
 #include "gromacs/legacyheaders/typedefs.h"
@@ -438,8 +440,6 @@ static void pr_str(FILE *fp, int indent, const char *title, const char *s)
 
 void pr_qm_opts(FILE *fp, int indent, const char *title, t_grpopts *opts)
 {
-    int i, m, j;
-
     fprintf(fp, "%s:\n", title);
 
     pr_int(fp, indent, "ngQM", opts->ngQM);
@@ -822,7 +822,7 @@ static void pr_rot(FILE *fp, int indent, t_rot *rot)
 
 static void pr_swap(FILE *fp, int indent, t_swapcoords *swap)
 {
-    int  i, j;
+    int  j;
     char str[STRLEN];
 
 
@@ -865,7 +865,6 @@ void pr_inputrec(FILE *fp, int indent, const char *title, t_inputrec *ir,
                  gmx_bool bMDPformat)
 {
     const char *infbuf = "inf";
-    int         i;
 
     if (available(fp, ir, indent, title))
     {
@@ -1477,7 +1476,7 @@ void pr_ffparams(FILE *fp, int indent, const char *title,
                  gmx_ffparams_t *ffparams,
                  gmx_bool bShowNumbers)
 {
-    int i, j;
+    int i;
 
     indent = pr_title(fp, indent, title);
     (void) pr_indent(fp, indent);
@@ -1528,8 +1527,6 @@ void pr_idef(FILE *fp, int indent, const char *title, t_idef *idef, gmx_bool bSh
 
 static int pr_block_title(FILE *fp, int indent, const char *title, t_block *block)
 {
-    int i;
-
     if (available(fp, block, indent, title))
     {
         indent = pr_title(fp, indent, title);
@@ -1541,8 +1538,6 @@ static int pr_block_title(FILE *fp, int indent, const char *title, t_block *bloc
 
 static int pr_blocka_title(FILE *fp, int indent, const char *title, t_blocka *block)
 {
-    int i;
-
     if (available(fp, block, indent, title))
     {
         indent = pr_title(fp, indent, title);
@@ -1578,14 +1573,13 @@ static void low_pr_blocka(FILE *fp, int indent, const char *title, t_blocka *blo
 
 void pr_block(FILE *fp, int indent, const char *title, t_block *block, gmx_bool bShowNumbers)
 {
-    int i, j, ok, size, start, end;
+    int i, start;
 
     if (available(fp, block, indent, title))
     {
         indent = pr_block_title(fp, indent, title, block);
         start  = 0;
-        end    = start;
-        if ((ok = (block->index[start] == 0)) == 0)
+        if (block->index[start] != 0)
         {
             (void) fprintf(fp, "block->index[%d] should be 0\n", start);
         }
@@ -1593,17 +1587,17 @@ void pr_block(FILE *fp, int indent, const char *title, t_block *block, gmx_bool
         {
             for (i = 0; i < block->nr; i++)
             {
-                end  = block->index[i+1];
-                size = pr_indent(fp, indent);
+                int end  = block->index[i+1];
+                pr_indent(fp, indent);
                 if (end <= start)
                 {
-                    size += fprintf(fp, "%s[%d]={}\n", title, i);
+                    fprintf(fp, "%s[%d]={}\n", title, i);
                 }
                 else
                 {
-                    size += fprintf(fp, "%s[%d]={%d..%d}\n",
-                                    title, bShowNumbers ? i : -1,
-                                    bShowNumbers ? start : -1, bShowNumbers ? end-1 : -1);
+                    fprintf(fp, "%s[%d]={%d..%d}\n",
+                            title, bShowNumbers ? i : -1,
+                            bShowNumbers ? start : -1, bShowNumbers ? end-1 : -1);
                 }
                 start = end;
             }
@@ -1719,7 +1713,7 @@ static void pr_resinfo(FILE *fp, int indent, const char *title, t_resinfo *resin
 
 static void pr_atom(FILE *fp, int indent, const char *title, t_atom *atom, int n)
 {
-    int i, j;
+    int i;
 
     if (available(fp, atom, indent, title))
     {
@@ -1755,7 +1749,6 @@ static void pr_groups(FILE *fp, int indent,
                       gmx_groups_t *groups,
                       gmx_bool bShowNumbers)
 {
-    int grpnr[egcNR];
     int nat_max, i, g;
 
     pr_grps(fp, "grp", groups->grps, groups->grpname);
@@ -1775,7 +1768,7 @@ static void pr_groups(FILE *fp, int indent,
     for (g = 0; g < egcNR; g++)
     {
         printf(" %5d", groups->ngrpnr[g]);
-        nat_max = max(nat_max, groups->ngrpnr[g]);
+        nat_max = std::max(nat_max, groups->ngrpnr[g]);
     }
     printf("\n");
 
@@ -1936,8 +1929,6 @@ void pr_top(FILE *fp, int indent, const char *title, t_topology *top, gmx_bool b
 
 void pr_header(FILE *fp, int indent, const char *title, t_tpxheader *sh)
 {
-    char buf[22];
-
     if (available(fp, sh, indent, title))
     {
         indent = pr_title(fp, indent, title);
similarity index 99%
rename from src/gromacs/gmxlib/typedefs.c
rename to src/gromacs/gmxlib/typedefs.cpp
index 12c413d79e2ab4c9fad8ed474dc70bfbd1161bf9..000a30bd194d09d383fdc21297337bb38a6256be 100644 (file)
@@ -41,6 +41,8 @@
 
 #include <string.h>
 
+#include <algorithm>
+
 #include "gromacs/legacyheaders/macros.h"
 #include "gromacs/math/vec.h"
 #include "gromacs/pbcutil/pbc.h"
@@ -60,7 +62,7 @@ int gmx_int64_to_int(gmx_int64_t step, const char *warn)
     {
         fprintf(stderr, "\nWARNING during %s:\n", warn);
         fprintf(stderr, "step value ");
-        fprintf(stderr, "%"GMX_PRId64, step);
+        fprintf(stderr, "%" GMX_PRId64, step);
         fprintf(stderr, " does not fit in int, converted to %d\n\n", i);
     }
 
@@ -461,7 +463,7 @@ real max_cutoff(real cutoff1, real cutoff2)
     }
     else
     {
-        return max(cutoff1, cutoff2);
+        return std::max(cutoff1, cutoff2);
     }
 }
 
similarity index 98%
rename from src/gromacs/mdlib/compute_io.c
rename to src/gromacs/mdlib/compute_io.cpp
index 825447dba8a4ab34d664c0e7444f14171200766d..7e205cf317be5a07f5a3ca21b6db66d8e97e817e 100644 (file)
@@ -61,7 +61,7 @@ double compute_io(t_inputrec *ir, int natoms, gmx_groups_t *groups,
 
     int    nsteps = ir->nsteps;
     int    i, nxtcatoms = 0;
-    int    nstx, nstv, nstf, nste, nstlog, nstxtc, nfep = 0;
+    int    nstx, nstv, nstf, nste, nstlog, nstxtc;
     double cio;
 
     nstx   = div_nsteps(nsteps, ir->nstxout);
similarity index 99%
rename from src/gromacs/mdlib/ebin.c
rename to src/gromacs/mdlib/ebin.cpp
index 0fa41a72f6f7716d173810a5d4aba0028f10fbc2..f77fa07cbf5af574a4b1f6c2feec20e353ddeb4a 100644 (file)
@@ -118,7 +118,7 @@ int get_ebin_space(t_ebin *eb, int nener, const char *enm[], const char *unit)
 void add_ebin(t_ebin *eb, int index, int nener, real ener[], gmx_bool bSum)
 {
     int       i, m;
-    double    e, sum, sigma, invmm, diff;
+    double    e, invmm, diff;
     t_energy *eg, *egs;
 
     if ((index+nener > eb->nener) || (index < 0))
similarity index 98%
rename from src/gromacs/mdlib/mdebin.c
rename to src/gromacs/mdlib/mdebin.cpp
index 437f1a3b56e38aba8f8174d60822b052e844274b..8ffbaadc3fb0e57fe8a6c5854ea74789273f268b 100644 (file)
@@ -134,8 +134,8 @@ t_mdebin *init_mdebin(ener_file_t       fp_ene,
     char                buf[256];
     const char         *bufi;
     t_mdebin           *md;
-    int                 i, j, ni, nj, n, nh, k, kk, ncon, nset;
-    gmx_bool            bBHAM, bNoseHoover, b14;
+    int                 i, j, ni, nj, n, k, kk, ncon, nset;
+    gmx_bool            bBHAM, b14;
 
     snew(md, 1);
 
@@ -687,7 +687,6 @@ static void print_lambda_vector(t_lambda *fep, int i,
                                 gmx_bool get_native_lambda, gmx_bool get_names,
                                 char *str)
 {
-    size_t nps = 0, np;
     int    j, k = 0;
     int    Nsep = 0;
 
@@ -707,7 +706,6 @@ static void print_lambda_vector(t_lambda *fep, int i,
     {
         if (fep->separate_dvdl[j])
         {
-            double lam;
             if (!get_names)
             {
                 if (get_native_lambda && fep->init_lambda >= 0)
@@ -744,9 +742,9 @@ extern FILE *open_dhdl(const char *filename, const t_inputrec *ir,
 {
     FILE       *fp;
     const char *dhdl = "dH/d\\lambda", *deltag = "\\DeltaH", *lambda = "\\lambda",
-    *lambdastate     = "\\lambda state", *remain = "remaining";
+    *lambdastate     = "\\lambda state";
     char        title[STRLEN], label_x[STRLEN], label_y[STRLEN];
-    int         i, np, nps, nsets, nsets_de, nsetsbegin;
+    int         i, nps, nsets, nsets_de, nsetsbegin;
     int         n_lambda_terms = 0;
     t_lambda   *fep            = ir->fepvals; /* for simplicity */
     t_expanded *expand         = ir->expandedvals;
@@ -941,7 +939,7 @@ extern FILE *open_dhdl(const char *filename, const t_inputrec *ir,
         }
         if (write_pV)
         {
-            np                     = sprintf(buf, "pV (%s)", unit_energy);
+            sprintf(buf, "pV (%s)", unit_energy);
             setname[nsetsextend-1] = gmx_strdup(buf);  /* the first entry after
                                                           nsets */
         }
@@ -993,7 +991,7 @@ void upd_mdebin(t_mdebin       *md,
                 rvec            mu_tot,
                 gmx_constr_t    constr)
 {
-    int    i, j, k, kk, m, n, gid;
+    int    i, j, k, kk, n, gid;
     real   crmsd[2], tmp6[6];
     real   bs[NTRICLBOXS], vol, dens, pv, enthalpy;
     real   eee[egNR];
@@ -1341,7 +1339,7 @@ void print_ebin(ener_file_t fp_ene, gmx_bool bEne, gmx_bool bDR, gmx_bool bOR,
 {
     /*static char **grpnms=NULL;*/
     char         buf[246];
-    int          i, j, n, ni, nj, ndr, nor, b;
+    int          i, j, n, ni, nj, b;
     int          ndisre = 0;
     real        *disre_rm3tav, *disre_rt;
 
@@ -1351,10 +1349,7 @@ void print_ebin(ener_file_t fp_ene, gmx_bool bEne, gmx_bool bDR, gmx_bool bOR,
     int          id[enxNR];
     real        *block[enxNR];
 
-    /* temporary arrays for the lambda values to write out */
-    double      enxlambda_data[2];
-
-    t_enxframe  fr;
+    t_enxframe   fr;
 
     switch (mode)
     {
similarity index 99%
rename from src/gromacs/mdlib/mdebin_bar.c
rename to src/gromacs/mdlib/mdebin_bar.cpp
index c2a596d9b26d8ff5dafeee428a0d97b971d72f07..a6d7c2ce8c1fe8709afaebbe5f4af7f771b91949 100644 (file)
@@ -362,7 +362,6 @@ void mde_delta_h_handle_block(t_mde_delta_h *dh, t_enxblock *blk)
 void mde_delta_h_coll_init(t_mde_delta_h_coll *dhc, const t_inputrec *ir)
 {
     int       i, j, n;
-    double    lambda;
     double   *lambda_vec;
     int       ndhmax = ir->nstenergy/ir->nstcalcenergy;
     t_lambda *fep    = ir->fepvals;
@@ -722,9 +721,13 @@ void mde_delta_h_coll_restore_energyhistory(t_mde_delta_h_coll *dhc,
     int          i;
     unsigned int j;
 
-    if (dhc && !enerhist->dht)
+    if (!dhc)
     {
-        gmx_incons("No delta_h histograms in energy history");
+        gmx_incons("No delta_h histograms found");
+    }
+    if (!enerhist->dht)
+    {
+        gmx_incons("No delta_h histograms found in energy history");
     }
     if (enerhist->dht->nndh != dhc->ndh)
     {
similarity index 94%
rename from src/gromacs/mdlib/perf_est.c
rename to src/gromacs/mdlib/perf_est.cpp
index 0951875dd3475965f04d473e4ae9362045d896f4..7f48a9ad1722e70f26e93e58e3cca70c256f1798 100644 (file)
@@ -38,7 +38,7 @@
 
 #include "gromacs/legacyheaders/perf_est.h"
 
-#include <math.h>
+#include <cmath>
 
 #include "gromacs/legacyheaders/types/commrec.h"
 #include "gromacs/math/vec.h"
@@ -149,7 +149,7 @@ static void pp_group_load(gmx_mtop_t *mtop, t_inputrec *ir, matrix box,
     int            mb, nmol, atnr, cg, a, a0, ncqlj, ncq, nclj;
     gmx_bool       bBHAM, bLJcut, bWater, bQ, bLJ;
     int            nw, nqlj, nq, nlj;
-    float          fq, fqlj, flj, fljtab, fqljw, fqw;
+    float          fq, fqlj, flj, fqljw, fqw;
     t_iparams     *iparams;
     gmx_moltype_t *molt;
 
@@ -270,7 +270,7 @@ static void pp_verlet_load(gmx_mtop_t *mtop, t_inputrec *ir, matrix box,
                            gmx_bool *bChargePerturbed, gmx_bool *bTypePerturbed)
 {
     t_atom        *atom;
-    int            mb, nmol, atnr, cg, a, a0, nqlj, nq, nlj;
+    int            mb, nmol, atnr, a, nqlj, nq, nlj;
     gmx_bool       bQRF;
     t_iparams     *iparams;
     gmx_moltype_t *molt;
@@ -299,7 +299,6 @@ static void pp_verlet_load(gmx_mtop_t *mtop, t_inputrec *ir, matrix box,
         molt = &mtop->moltype[mtop->molblock[mb].type];
         atom = molt->atoms.atom;
         nmol = mtop->molblock[mb].nmol;
-        a    = 0;
         for (a = 0; a < molt->atoms.nr; a++)
         {
             if (atom[a].q != 0 || atom[a].qB != 0)
@@ -367,14 +366,10 @@ static void pp_verlet_load(gmx_mtop_t *mtop, t_inputrec *ir, matrix box,
 
 float pme_load_estimate(gmx_mtop_t *mtop, t_inputrec *ir, matrix box)
 {
-    t_atom        *atom;
-    int            mb, nmol, atnr, cg, a, a0, nq_tot, nlj_tot, f;
-    gmx_bool       bBHAM, bLJcut, bChargePerturbed, bTypePerturbed;
-    gmx_bool       bWater, bQ, bLJ;
+    int            nq_tot, nlj_tot, f;
+    gmx_bool       bChargePerturbed, bTypePerturbed;
     double         cost_bond, cost_pp, cost_redist, cost_spread, cost_fft, cost_solve, cost_pme;
     float          ratio;
-    t_iparams     *iparams;
-    gmx_moltype_t *molt;
 
     /* Computational cost of bonded, non-bonded and PME calculations.
      * This will be machine dependent.
@@ -383,9 +378,6 @@ float pme_load_estimate(gmx_mtop_t *mtop, t_inputrec *ir, matrix box)
      * although not so much that the numbers need to be adjusted.
      */
 
-    iparams = mtop->ffparams.iparams;
-    atnr    = mtop->ffparams.atnr;
-
     cost_bond = C_BOND*n_bonded_dx(mtop, TRUE);
 
     if (ir->cutoff_scheme == ecutsGROUP)
@@ -410,8 +402,8 @@ float pme_load_estimate(gmx_mtop_t *mtop, t_inputrec *ir, matrix box)
     {
         f            = ((ir->efep != efepNO && bChargePerturbed) ? 2 : 1);
         cost_redist +=   C_PME_REDIST*nq_tot;
-        cost_spread += f*C_PME_SPREAD*nq_tot*pow(ir->pme_order, 3);
-        cost_fft    += f*C_PME_FFT*ir->nkx*ir->nky*ir->nkz*log(ir->nkx*ir->nky*ir->nkz);
+        cost_spread += f*C_PME_SPREAD*nq_tot*std::pow(static_cast<real>(ir->pme_order), static_cast<real>(3.0));
+        cost_fft    += f*C_PME_FFT*ir->nkx*ir->nky*ir->nkz*std::log(static_cast<real>(ir->nkx*ir->nky*ir->nkz));
         cost_solve  += f*C_PME_SOLVE*ir->nkx*ir->nky*ir->nkz;
     }
 
@@ -424,8 +416,8 @@ float pme_load_estimate(gmx_mtop_t *mtop, t_inputrec *ir, matrix box)
             f       *= 7;
         }
         cost_redist +=   C_PME_REDIST*nlj_tot;
-        cost_spread += f*C_PME_SPREAD*nlj_tot*pow(ir->pme_order, 3);
-        cost_fft    += f*C_PME_FFT*ir->nkx*ir->nky*ir->nkz*log(ir->nkx*ir->nky*ir->nkz);
+        cost_spread += f*C_PME_SPREAD*nlj_tot*std::pow(static_cast<real>(ir->pme_order), static_cast<real>(3.0));
+        cost_fft    += f*C_PME_FFT*ir->nkx*ir->nky*ir->nkz*std::log(static_cast<real>(ir->nkx*ir->nky*ir->nkz));
         cost_solve  += f*C_PME_SOLVE*ir->nkx*ir->nky*ir->nkz;
     }
 
similarity index 98%
rename from src/gromacs/mdlib/tgroup.c
rename to src/gromacs/mdlib/tgroup.cpp
index 1baec82abd2d0075fe51910e871d8fb50f309b88..7640a3cc47c29fd4a4a3aa3c868aa9b152957171 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, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2015, 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.
@@ -53,7 +53,7 @@
 
 static void init_grptcstat(int ngtc, t_grp_tcstat tcstat[])
 {
-    int i, j;
+    int i;
 
     for (i = 0; (i < ngtc); i++)
     {
@@ -237,7 +237,7 @@ real sum_ekin(t_grpopts *opts, gmx_ekindata_t *ekind, real *dekindlambda,
               gmx_bool bEkinAveVel, gmx_bool bScaleEkin)
 {
     int           i, j, m, ngtc;
-    real          T, ek;
+    real          T;
     t_grp_tcstat *tcstat;
     real          nrdf, nd, *ndf;