From: Mark Abraham Date: Tue, 7 Jul 2015 10:03:30 +0000 (+0200) Subject: Convert some mdrun utility code to C++ X-Git-Url: http://biod.pnpi.spb.ru/gitweb/?p=alexxy%2Fgromacs.git;a=commitdiff_plain;h=a04f855267ee04b810f645e184f75fe6b520b8af Convert some mdrun utility code to C++ 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 --- diff --git a/src/gromacs/gmxlib/calcgrid.c b/src/gromacs/gmxlib/calcgrid.cpp similarity index 94% rename from src/gromacs/gmxlib/calcgrid.c rename to src/gromacs/gmxlib/calcgrid.cpp index 7bbee76f12..80da0e1a39 100644 --- a/src/gromacs/gmxlib/calcgrid.c +++ b/src/gromacs/gmxlib/calcgrid.cpp @@ -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--; } diff --git a/src/gromacs/gmxlib/chargegroup.c b/src/gromacs/gmxlib/chargegroup.cpp similarity index 99% rename from src/gromacs/gmxlib/chargegroup.c rename to src/gromacs/gmxlib/chargegroup.cpp index 41e152518d..aaf9d13167 100644 --- a/src/gromacs/gmxlib/chargegroup.c +++ b/src/gromacs/gmxlib/chargegroup.cpp @@ -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. diff --git a/src/gromacs/gmxlib/disre.c b/src/gromacs/gmxlib/disre.cpp similarity index 97% rename from src/gromacs/gmxlib/disre.c rename to src/gromacs/gmxlib/disre.cpp index 8e2fefd24f..cecfb04bfa 100644 --- a/src/gromacs/gmxlib/disre.c +++ b/src/gromacs/gmxlib/disre.cpp @@ -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 #include +#include + #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 ... */ diff --git a/src/gromacs/gmxlib/ifunc.c b/src/gromacs/gmxlib/ifunc.cpp similarity index 99% rename from src/gromacs/gmxlib/ifunc.c rename to src/gromacs/gmxlib/ifunc.cpp index e7e42f6644..09a91e2d34 100644 --- a/src/gromacs/gmxlib/ifunc.c +++ b/src/gromacs/gmxlib/ifunc.cpp @@ -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. diff --git a/src/gromacs/gmxlib/inputrec.c b/src/gromacs/gmxlib/inputrec.cpp similarity index 97% rename from src/gromacs/gmxlib/inputrec.c rename to src/gromacs/gmxlib/inputrec.cpp index ad48b85814..cf642041c3 100644 --- a/src/gromacs/gmxlib/inputrec.c +++ b/src/gromacs/gmxlib/inputrec.cpp @@ -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 + #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]); } } } diff --git a/src/gromacs/gmxlib/md_logging.c b/src/gromacs/gmxlib/md_logging.cpp similarity index 97% rename from src/gromacs/gmxlib/md_logging.c rename to src/gromacs/gmxlib/md_logging.cpp index cee3c06ba6..23ac56230c 100644 --- a/src/gromacs/gmxlib/md_logging.c +++ b/src/gromacs/gmxlib/md_logging.cpp @@ -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. diff --git a/src/gromacs/gmxlib/names.c b/src/gromacs/gmxlib/names.cpp similarity index 100% rename from src/gromacs/gmxlib/names.c rename to src/gromacs/gmxlib/names.cpp diff --git a/src/gromacs/gmxlib/network.c b/src/gromacs/gmxlib/network.cpp similarity index 99% rename from src/gromacs/gmxlib/network.c rename to src/gromacs/gmxlib/network.cpp index 94905661e1..5ac06a00ae 100644 --- a/src/gromacs/gmxlib/network.c +++ b/src/gromacs/gmxlib/network.cpp @@ -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); diff --git a/src/gromacs/gmxlib/orires.c b/src/gromacs/gmxlib/orires.cpp similarity index 99% rename from src/gromacs/gmxlib/orires.c rename to src/gromacs/gmxlib/orires.cpp index 1d15a6a4cc..f67d2bb542 100644 --- a/src/gromacs/gmxlib/orires.c +++ b/src/gromacs/gmxlib/orires.cpp @@ -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. diff --git a/src/gromacs/gmxlib/rbin.c b/src/gromacs/gmxlib/rbin.cpp similarity index 100% rename from src/gromacs/gmxlib/rbin.c rename to src/gromacs/gmxlib/rbin.cpp diff --git a/src/gromacs/gmxlib/sighandler.c b/src/gromacs/gmxlib/sighandler.cpp similarity index 100% rename from src/gromacs/gmxlib/sighandler.c rename to src/gromacs/gmxlib/sighandler.cpp diff --git a/src/gromacs/gmxlib/txtdump.c b/src/gromacs/gmxlib/txtdump.cpp similarity index 98% rename from src/gromacs/gmxlib/txtdump.c rename to src/gromacs/gmxlib/txtdump.cpp index db4b587bbb..c39508d05d 100644 --- a/src/gromacs/gmxlib/txtdump.c +++ b/src/gromacs/gmxlib/txtdump.cpp @@ -43,6 +43,8 @@ #include #include +#include + #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); diff --git a/src/gromacs/gmxlib/typedefs.c b/src/gromacs/gmxlib/typedefs.cpp similarity index 99% rename from src/gromacs/gmxlib/typedefs.c rename to src/gromacs/gmxlib/typedefs.cpp index 12c413d79e..000a30bd19 100644 --- a/src/gromacs/gmxlib/typedefs.c +++ b/src/gromacs/gmxlib/typedefs.cpp @@ -41,6 +41,8 @@ #include +#include + #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); } } diff --git a/src/gromacs/mdlib/compute_io.c b/src/gromacs/mdlib/compute_io.cpp similarity index 98% rename from src/gromacs/mdlib/compute_io.c rename to src/gromacs/mdlib/compute_io.cpp index 825447dba8..7e205cf317 100644 --- a/src/gromacs/mdlib/compute_io.c +++ b/src/gromacs/mdlib/compute_io.cpp @@ -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); diff --git a/src/gromacs/mdlib/ebin.c b/src/gromacs/mdlib/ebin.cpp similarity index 99% rename from src/gromacs/mdlib/ebin.c rename to src/gromacs/mdlib/ebin.cpp index 0fa41a72f6..f77fa07cbf 100644 --- a/src/gromacs/mdlib/ebin.c +++ b/src/gromacs/mdlib/ebin.cpp @@ -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)) diff --git a/src/gromacs/mdlib/mdebin.c b/src/gromacs/mdlib/mdebin.cpp similarity index 98% rename from src/gromacs/mdlib/mdebin.c rename to src/gromacs/mdlib/mdebin.cpp index 437f1a3b56..8ffbaadc3f 100644 --- a/src/gromacs/mdlib/mdebin.c +++ b/src/gromacs/mdlib/mdebin.cpp @@ -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) { diff --git a/src/gromacs/mdlib/mdebin_bar.c b/src/gromacs/mdlib/mdebin_bar.cpp similarity index 99% rename from src/gromacs/mdlib/mdebin_bar.c rename to src/gromacs/mdlib/mdebin_bar.cpp index c2a596d9b2..a6d7c2ce8c 100644 --- a/src/gromacs/mdlib/mdebin_bar.c +++ b/src/gromacs/mdlib/mdebin_bar.cpp @@ -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) { diff --git a/src/gromacs/mdlib/perf_est.c b/src/gromacs/mdlib/perf_est.cpp similarity index 94% rename from src/gromacs/mdlib/perf_est.c rename to src/gromacs/mdlib/perf_est.cpp index 0951875dd3..7f48a9ad17 100644 --- a/src/gromacs/mdlib/perf_est.c +++ b/src/gromacs/mdlib/perf_est.cpp @@ -38,7 +38,7 @@ #include "gromacs/legacyheaders/perf_est.h" -#include +#include #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(ir->pme_order), static_cast(3.0)); + cost_fft += f*C_PME_FFT*ir->nkx*ir->nky*ir->nkz*std::log(static_cast(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(ir->pme_order), static_cast(3.0)); + cost_fft += f*C_PME_FFT*ir->nkx*ir->nky*ir->nkz*std::log(static_cast(ir->nkx*ir->nky*ir->nkz)); cost_solve += f*C_PME_SOLVE*ir->nkx*ir->nky*ir->nkz; } diff --git a/src/gromacs/mdlib/tgroup.c b/src/gromacs/mdlib/tgroup.cpp similarity index 98% rename from src/gromacs/mdlib/tgroup.c rename to src/gromacs/mdlib/tgroup.cpp index 1baec82abd..7640a3cc47 100644 --- a/src/gromacs/mdlib/tgroup.c +++ b/src/gromacs/mdlib/tgroup.cpp @@ -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;