Bumped requirement for cppcheck in releng.
Changed the output template to make it easier to find cppcheck's
name for the error when a suppression needs to be added.
Bugs found in gmx_lapack (checked by comparing with Fortran version).
Simplified some checkpoint-reading code, since reading always does the
allocation.
Removed some unused OpenCL debug code.
Removed some suppressions no longer needed.
Change-Id: I882ea877bd489ca253b5a7f06becb7e43bb6a3d0
#
# This file is part of the GROMACS molecular simulation package.
#
-# Copyright (c) 2015, by the GROMACS development team, led by
+# Copyright (c) 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.
# TODO: Make the XMLs go directly to the desired folder.
# xml_dir = context.workspace.get_log_dir(category='cppcheck')
cmake_opts = {
- 'CPPCHECK_EXECUTABLE': context.env.get_cppcheck_command(version='1.67'),
+ 'CPPCHECK_EXECUTABLE': context.env.get_cppcheck_command(version='1.72'),
'CPPCHECK_XML_OUTPUT': 'ON',
'GMX_SIMD': 'Reference'
}
//system_error(error_code ec, const std::string& what_arg);
//system_error(error_code ec, const char* what_arg);
/*! \brief Constuctor that takes an system error number */
- system_error(error_code ec);
+ explicit system_error(error_code ec);
/*! \brief Returns the error code */
const error_code &code() const
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2010,2011,2012,2013,2014, by the GROMACS development team, led by
+ * Copyright (c) 2010,2011,2012,2013,2014,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.
* \param[in] options Options object whose options should be set.
* \throws std::bad_alloc if out of memory.
*/
- CommandLineParser(Options *options);
+ explicit CommandLineParser(Options *options);
~CommandLineParser();
/*! \brief
CommandLineProgramContext::Impl::Impl(int argc, const char *const argv[],
ExecutableEnvironmentPointer env)
- : executableEnv_(std::move(env)), bSourceLayout_(false)
+ : executableEnv_(std::move(env)), invokedName_(argc != 0 ? argv[0] : ""), bSourceLayout_(false)
{
- invokedName_ = (argc != 0 ? argv[0] : "");
programName_ = Path::getFilename(invokedName_);
programName_ = stripSuffixIfPresent(programName_, ".exe");
*
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
* Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014,2015, 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.
{
real ttt = x0 ? x0[j] : dt*j;
fprintf(fp, "%10.5e %10.5e %10.5e\n",
- x[j], y[j], lmcurves[eFitFn](ttt, fitparms));
+ x[j], y[j], (lmcurves[eFitFn])(ttt, fitparms));
}
xvgrclose(fp);
}
ma = dd->ma;
- if (tmp_ind == NULL)
+ snew(tmp_nalloc, dd->nnodes);
+ snew(tmp_ind, dd->nnodes);
+ for (i = 0; i < dd->nnodes; i++)
{
- snew(tmp_nalloc, dd->nnodes);
- snew(tmp_ind, dd->nnodes);
- for (i = 0; i < dd->nnodes; i++)
- {
- tmp_nalloc[i] = over_alloc_large(cgs->nr/dd->nnodes+1);
- snew(tmp_ind[i], tmp_nalloc[i]);
- }
+ tmp_nalloc[i] = over_alloc_large(cgs->nr/dd->nnodes+1);
+ snew(tmp_ind[i], tmp_nalloc[i]);
}
/* Clear the count */
{
fprintf(debug, "PP rank %d sending to PME rank %d: %d%s%s%s%s\n",
cr->sim_nodeid, dd->pme_nodeid, n,
- flags & PP_PME_CHARGE ? " charges" : "",
- flags & PP_PME_SQRTC6 ? " sqrtC6" : "",
- flags & PP_PME_SIGMA ? " sigma" : "",
- flags & PP_PME_COORD ? " coordinates" : "");
+ (flags & PP_PME_CHARGE) ? " charges" : "",
+ (flags & PP_PME_SQRTC6) ? " sqrtC6" : "",
+ (flags & PP_PME_SIGMA) ? " sigma" : "",
+ (flags & PP_PME_COORD) ? " coordinates" : "");
}
#ifdef GMX_PME_DELAYED_WAIT
int xs[3], xl[3], xc[3], NG[3];
int ll = (plan->flags&FFT5D_REALCOMPLEX) ? 1 : 2;
compute_offsets(plan, xs, xl, xc, NG, s);
- fprintf(debug, txt, coor[0], coor[1], s);
+ fprintf(debug, txt, coor[0], coor[1]);
/*printf("xs: %d %d %d, xl: %d %d %d\n",xs[0],xs[1],xs[2],xl[0],xl[1],xl[2]);*/
for (z = 0; z < xl[2]; z++)
{
int nval, int *nptr, real **v,
FILE *list, int erealtype)
{
- bool_t res = 0;
-#if !GMX_DOUBLE
- int dtc = xdr_datatype_float;
-#else
- int dtc = xdr_datatype_double;
-#endif
- real *vp, *va = NULL;
- float *vf;
- double *vd;
- int nf, dt, i;
+ bool_t res = 0;
+ const bool useDouble = GMX_DOUBLE;
+ int dtc = useDouble ? xdr_datatype_double : xdr_datatype_float;
+ real *vp, *va = NULL;
+ float *vf;
+ double *vd;
+ int nf, dt, i;
if (list == NULL)
{
}
if (dt == xdr_datatype_float)
{
- if (dtc == xdr_datatype_float)
+ if (!useDouble)
{
+ // This branch is not reached unless vp is already float *.
vf = reinterpret_cast<float *>(vp);
}
else
{
return -1;
}
- if (dtc != xdr_datatype_float)
+ if (useDouble)
{
for (i = 0; i < nf; i++)
{
}
else
{
- if (dtc == xdr_datatype_double)
+ if (useDouble)
{
- /* cppcheck-suppress invalidPointerCast
- * Only executed if real is anyhow double */
- vd = (double *)vp;
+ // This branch is not reached unless vp is already double *.
+ vd = reinterpret_cast<double *>(vp);
}
else
{
{
return -1;
}
- if (dtc != xdr_datatype_double)
+ if (!useDouble)
{
for (i = 0; i < nf; i++)
{
}
ret = do_cpt_files(gmx_fio_getxdr(fp), TRUE,
- outputfiles != NULL ? outputfiles : &files_loc,
- outputfiles != NULL ? nfiles : &nfiles_loc,
+ &files_loc,
+ &nfiles_loc,
NULL, file_version);
- if (files_loc != NULL)
+ if (outputfiles != nullptr)
+ {
+ *outputfiles = files_loc;
+ }
+ else
{
sfree(files_loc);
}
+ if (nfiles != nullptr)
+ {
+ *nfiles = nfiles_loc;
+ }
if (ret)
{
* This file is part of the GROMACS molecular simulation package.
*
* Copyright (c) 2005, The GROMACS development team.
- * Copyright (c) 2013,2014,2015, 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.
}
}
/* Generate an atom name from the particle type */
- sprintf(buf, "T%d", atoms->atom[i].type);
+ sprintf(buf, "T%u", atoms->atom[i].type);
atoms->atomname[i] = put_symtab(&top->symtab, buf);
if (bMol)
{
{
j = i;
}
- fprintf(out, "\t{%d %f %f %f %d %g",
+ fprintf(out, "\t{%d %f %f %f %u %g",
j, x[j][XX], x[j][YY], x[j][ZZ],
atoms->atom[j].type, atoms->atom[j].q);
if (v)
*
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
* Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014,2015, 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.
}
frame = xtc_get_current_frame_number(fp, xdrs, natoms, bOK);
- if (!bOK)
+ if (!*bOK)
{
return -1;
}
#include "gromacs/utility/fatalerror.h"
#include "gromacs/utility/futil.h"
#include "gromacs/utility/smalloc.h"
+#include "gromacs/utility/snprintf.h"
typedef struct {
int ai, aj;
std::strcpy(anm_copy, atoms->pdbinfo[i].atomnm);
bool atomNumberSet = false;
len = strlen(anm);
- if ((anm[0] != ' ') && ((len <= 2) || ((len > 2) && !std::isdigit(anm[2]))))
+ if ((anm[0] != ' ') && ((len <= 2) || !std::isdigit(anm[2])))
{
anm_copy[2] = nc;
if (gmx_atomprop_query(aps, epropElement, "???", anm_copy, &eval))
{
start_name_in_col13 = (std::strlen(atom_name) >= 4);
}
- sprintf(tmp_atomname, start_name_in_col13 ? "" : " ");
+ snprintf(tmp_atomname, sizeof(tmp_atomname), start_name_in_col13 ? "" : " ");
std::strncat(tmp_atomname, atom_name, 4);
tmp_atomname[5] = '\0';
}
const int nValues,
const char datatype)
{
- int i, j;
+ int i, j;
+ const bool useDouble = GMX_DOUBLE;
switch (datatype)
{
case TNG_FLOAT_DATA:
- if (sizeof(real) == sizeof(float))
+ if (!useDouble)
{
if (fact == 1)
{
*
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
* Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014,2015, 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.
bBfac = bBfac && (atoms->pdbinfo[index[n]].bfac <= bfac_max);
bOccup = bOccup && (atoms->pdbinfo[index[n]].occup == 1);
}
- if (bOccup && ((bfac_max <= 0) || ((bfac_max > 0) && bBfac)))
+ if (bOccup && ((bfac_max <= 0) || bBfac))
{
hindex = static_cast<int>(((dih[j][0]+M_PI)*nbin)/(2*M_PI));
range_check(hindex, 0, nbin);
*
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
* Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014,2015, 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.
{
n1 = static_cast<int>(2*amax/bin + 0.5);
nradial = static_cast<int>(rmax/bin + 0.5);
- /* cppcheck-suppress zerodiv fixed in 1.68-dev */
invspa = n1/(2*amax);
- /* cppcheck-suppress zerodiv fixed in 1.68-dev */
invspz = nradial/rmax;
if (bMirror)
{
*
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
* Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014,2015, 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.
nrestr = 0;
for (i = 0; (i < ndr); i++)
{
- if (!bCore || (bCore && drs[i].bCore))
+ if (!bCore || drs[i].bCore)
{
switch (kkk)
{
*
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
* Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014,2015, 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.
fro->step = lastfilestep + fr->step - startstep_file;
fro->t = tadjust + fr->t;
- bWrite = ((begin < 0 || (begin >= 0 && (fro->t >= begin-GMX_REAL_EPS))) &&
- (end < 0 || (end >= 0 && (fro->t <= end +GMX_REAL_EPS))) &&
+ bWrite = ((begin < 0 || (fro->t >= begin-GMX_REAL_EPS)) &&
+ (end < 0 || (fro->t <= end +GMX_REAL_EPS)) &&
(fro->t <= settime[f+1]+0.5*timestep));
if (debug)
*
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
* Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014,2015, 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.
double *native_lambda_vec = NULL;
const char **lambda_components = NULL;
int n_lambda_vec = 0;
+ bool firstPass = true;
/* now count the blocks & handle the global dh data */
for (i = 0; i < fr->nblock; i++)
start_lambda = fr->block[i].sub[0].dval[3];
if (fr->block[i].nsub > 1)
{
- if (n_lambda_vec == 0)
+ if (firstPass)
{
n_lambda_vec = fr->block[i].sub[1].ival[1];
+ snew(lambda_components, n_lambda_vec);
+ snew(native_lambda_vec, n_lambda_vec);
+ firstPass = false;
}
else
{
"Unexpected change of basis set in lambda");
}
}
- if (lambda_components == NULL)
- {
- snew(lambda_components, n_lambda_vec);
- }
- if (native_lambda_vec == NULL)
- {
- snew(native_lambda_vec, n_lambda_vec);
- }
for (j = 0; j < n_lambda_vec; j++)
{
native_lambda_vec[j] = fr->block[i].sub[0].dval[5+j];
rha2 = iprod(r_ha, r_ha);
}
- if (bDA || (!bDA && (rha2 <= rc2)))
+ if (bDA || (rha2 <= rc2))
{
rvec_sub(x[d], x[hh], r_dh);
if (bBox)
}
}
}
- if (bDA || (!bDA && HAinrange))
+ if (bDA || HAinrange)
{
return hbDist;
}
ia = hb->a.acc[j];
jj = hb->d.dptr[ia];
if ((id != ia) && (ii != NOTSET) && (jj != NOTSET) &&
- (!bTwo || (bTwo && (hb->d.grp[i] != hb->a.grp[j]))))
+ (!bTwo || (hb->d.grp[i] != hb->a.grp[j])))
{
hb0 = hb->hbmap[i][j];
hb1 = hb->hbmap[jj][ii];
*/
#include "gmxpre.h"
+#include <cassert>
#include <cmath>
#include <cstring>
}
else
{
+ assert(sparse_hessian);
/* Sparse memory storage, allocate memory for eigenvectors */
snew(eigenvectors, ncol*end);
nma_sparse_hessian(sparse_hessian, bM, &top, atom_index, end, eigenvalues, eigenvectors);
create_info(&info);
info.fourier_sp[0] = fs;
- /* Read in the tpr file and open logfile for reading */
if (MASTER(cr))
{
+ /* Read in the tpr file */
snew(ir, 1);
read_tpr_file(opt2fn("-s", NFILE, fnm), &info, &state, &mtop, ir, user_beta, fracself);
-
+ /* Open logfile for reading */
fp = fopen(opt2fn("-o", NFILE, fnm), "w");
+
+ /* Determine the volume of the simulation box */
+ info.volume = det(state.box);
+ calc_recipbox(state.box, info.recipbox);
+ info.natoms = mtop.natoms;
+ info.bTUNE = bTUNE;
}
/* Check consistency if the user provided fourierspacing */
/* Estimate (S)PME force error */
- /* Determine the volume of the simulation box */
- if (MASTER(cr))
- {
- info.volume = det(state.box);
- calc_recipbox(state.box, info.recipbox);
- info.natoms = mtop.natoms;
- info.bTUNE = bTUNE;
- }
-
if (PAR(cr))
{
bcast_info(&info, cr);
*
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
* Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014,2015, 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.
*/
#include "gmxpre.h"
+#include <cassert>
#include <cmath>
#include <cstdlib>
#include <cstring>
snew(bE, n);
if (bGE || nenerT == 2)
{
+ assert(enerT);
Emin = 1e8;
for (j = 0; (j < n); j++)
{
*
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
* Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014,2015, 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.
*/
#include "gmxpre.h"
+#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
dhh += psr->X.fontsize+2*DDD;
}
if ( /* fool emacs auto-indent */
- (elegend == elBoth && (mat[0].legend[0] || mat2[0].legend[0])) ||
+ (elegend == elBoth && (mat[0].legend[0] || (mat2 && mat2[0].legend[0]))) ||
(elegend == elFirst && mat[0].legend[0]) ||
- (elegend == elSecond && mat2[0].legend[0]) )
+ (elegend == elSecond && (mat2 && mat2[0].legend[0])) )
{
dhh += 2*(psr->legfontsize*FUDGE+2*DDD);
}
}
else
{
+ assert(mat2);
ps_rgb_nbox(out, &(mat2[i].map[col].rgb), nexty-y);
}
}
}
else
{
+ assert(mat2);
leg_bicontinuous(out, x0+w/2, w, DDD, mat[0].legend, mat2[0].legend,
psr->legfontsize, psr->legfont, nmap1, map1, nmap2, map2);
}
if (debug)
{
char sbuf[STRLEN];
- if (cr->duty & DUTY_PP && cr->duty & DUTY_PME)
+ if ((cr->duty & DUTY_PP) && (cr->duty & DUTY_PME))
{
sprintf(sbuf, "PP+PME");
}
else
{
- sprintf(sbuf, "%s", cr->duty & DUTY_PP ? "PP" : "PME");
+ sprintf(sbuf, "%s", (cr->duty & DUTY_PP) ? "PP" : "PME");
}
fprintf(debug, "On %3s rank %d: nrank_intranode=%d, rank_intranode=%d, "
"nrank_pp_intranode=%d, rank_pp_intranode=%d\n",
*
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
* Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014,2015, 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.
#include <stdlib.h>
#include <string.h>
+#include <cassert>
#include <cmath>
#include <sys/types.h>
{
int i;
+ assert(param);
for (i = 0; i < nr; i++)
{
+ assert(param[i]);
sfree(param[i]);
}
sfree(param);
{
for (j = 0; j <= i; j++)
{
+ assert(param);
if (param[i][j].bSet)
{
for (f = 0; f < nrfp; f++)
for (mb = 0; mb < nmolb; mb++)
{
+ assert(molb);
mol_atoms = &molinfo[molb[mb].type].atoms;
srenew(atoms->atom, atoms->nr + molb[mb].nmol*mol_atoms->nr);
gmx_fatal(FARGS, "Invalid particle type %s on line %s",
ptype, line);
}
- /* cppcheck-suppress arrayIndexOutOfBounds #6329 */
pt = xl[j].ptype;
if (debug)
{
* This file is part of the GROMACS molecular simulation package.
*
* Copyright (c) 1991-2004 David van der Spoel, Erik Lindahl, University of Groningen.
- * Copyright (c) 2012,2013,2014,2015, by the GROMACS development team, led by
+ * Copyright (c) 2012,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.
if (*n == 1)
{
- if (icompz == 2)
- {
- z__[1] = 1.;
- }
+ z__[1] = 1.;
return;
}
ssfmax = std::sqrt(safmax) / 3.;
ssfmin = std::sqrt(safmin) / eps2;
- if (icompz == 2)
+ i__1 = *n - 1;
+ for (j = 1; j <= i__1; ++j)
{
- i__1 = *n - 1;
- for (j = 1; j <= i__1; ++j)
- {
- z__[j] = 0.;
+ z__[j] = 0.;
- }
- z__[*n] = 1.;
}
+ z__[*n] = 1.;
nmaxit = *n * 30;
jtot = 0;
if (*n == 1)
{
- if (icompz == 2)
- {
- z__[1] = 1.;
- }
+ z__[1] = 1.;
return;
}
ssfmax = std::sqrt(safmax) / 3.;
ssfmin = std::sqrt(safmin) / eps2;
- if (icompz == 2)
+ i__1 = *n - 1;
+ for (j = 1; j <= i__1; ++j)
{
- i__1 = *n - 1;
- for (j = 1; j <= i__1; ++j)
- {
- z__[j] = 0.;
+ z__[j] = 0.;
- }
- z__[*n] = 1.;
}
+ z__[*n] = 1.;
nmaxit = *n * 30;
jtot = 0;
if (std::abs(l)<GMX_DOUBLE_MIN) {
t = ( (ft>0) ? 2.0 : -2.0) * ( (gt>0) ? 1.0 : -1.0);
} else {
- t = gt / ( (ft>0) ? d__ : d__) + m / t;
+ t = gt / ( (ft>0) ? d__ : -d__) + m / t;
}
} else {
t = (m / (s + t) + m / (r__ + l)) * (a + 1.);
if (std::abs(l)<GMX_FLOAT_MIN) {
t = ( (ft>0) ? 2.0 : -2.0) * ( (gt>0) ? 1.0 : -1.0);
} else {
- t = gt / ( (ft>0) ? d__ : d__) + m / t;
+ t = gt / ( (ft>0) ? d__ : -d__) + m / t;
}
} else {
t = (m / (s + t) + m / (r__ + l)) * (a + 1.);
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2013,2014,2015, 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.
const t_inputrec *ir, gmx_mtop_t *top_global,
const gmx_output_env_t *oenv, gmx_wallcycle_t wcycle)
{
- gmx_mdoutf_t of;
- char filemode[3];
- gmx_bool bAppendFiles, bCiteTng = FALSE;
- int i;
+ gmx_mdoutf_t of;
+ const char *appendMode = "a+", *writeMode = "w+", *filemode;
+ gmx_bool bAppendFiles, bCiteTng = FALSE;
+ int i;
snew(of, 1);
of->bKeepAndNumCPT = (mdrun_flags & MD_KEEPANDNUMCPT);
- sprintf(filemode, bAppendFiles ? "a+" : "w+");
+ filemode = bAppendFiles ? appendMode : writeMode;
if (EI_DYNAMICS(ir->eI) &&
ir->nstxout_compressed > 0)
* we either converge or reach the max number of steps.
*/
converged = FALSE;
- for (step = 0; (number_steps < 0 || (number_steps >= 0 && step <= number_steps)) && !converged; step++)
+ for (step = 0; (number_steps < 0 || step <= number_steps) && !converged; step++)
{
/* start taking steps in a new direction
/* Set the gradient from the force */
converged = FALSE;
- for (step = 0; (number_steps < 0 || (number_steps >= 0 && step <= number_steps)) && !converged; step++)
+ for (step = 0; (number_steps < 0 || step <= number_steps) && !converged; step++)
{
/* Write coordinates if necessary */
}
#endif
}
-
-/*! \brief Debugging helper function */
-void dump_compare_results_cj4(nbnxn_cj4_t* results, int cnt, char* out_file, char* ref_file)
-{
- FILE *pf;
-
- pf = fopen(out_file, "wt");
- assert(pf != NULL);
-
- fprintf(pf, "%20s%20s%20s%20s%20s%20s%20s%20s\n",
- "cj[0]", "cj[1]", "cj[2]", "cj[3]",
- "imei[0].excl_ind", "imei[0].imask",
- "imei[1].excl_ind", "imei[1].imask");
-
- for (int index = 0; index < cnt; index++)
- {
- fprintf(pf, "%20d%20d%20d%20d%20d%20u%20d%20u\n",
- results[index].cj[0], results[index].cj[1], results[index].cj[2], results[index].cj[3],
- results[index].imei[0].excl_ind, results[index].imei[0].imask,
- results[index].imei[1].excl_ind, results[index].imei[1].imask);
- }
-
- fclose(pf);
-
- printf("\nWrote results to %s", out_file);
-
- pf = fopen(ref_file, "rt");
- if (pf)
- {
- char c;
- int diff = 0;
- printf("\n%s file found. Comparing results...", ref_file);
-
- /* Skip the first line */
- c = 0;
- while (c != '\n')
- {
- if (1 != fscanf(pf, "%c", &c))
- {
- break;
- }
- }
-
- for (int index = 0; index < cnt; index++)
- {
- int ref_val;
- unsigned int u_ref_val;
-
- for (int j = 0; j < 4; j++)
- {
- if (1 != fscanf(pf, "%20d", &ref_val))
- {
- break;
- }
-
- if (ref_val != results[index].cj[j])
- {
- printf("\nDifference for cj[%d] at index %d computed value = %d reference value = %d",
- j, index, results[index].cj[j], ref_val);
-
- diff++;
- }
- }
-
- for (int j = 0; j < 2; j++)
- {
- if (1 != fscanf(pf, "%20d", &ref_val))
- {
- break;
- }
-
- if (ref_val != results[index].imei[j].excl_ind)
- {
- printf("\nDifference for imei[%d].excl_ind at index %d computed value = %d reference value = %d",
- j, index, results[index].imei[j].excl_ind, ref_val);
-
- diff++;
- }
-
- if (1 != fscanf(pf, "%20u", &u_ref_val))
- {
- break;
- }
-
- if (u_ref_val != results[index].imei[j].imask)
- {
- printf("\nDifference for imei[%d].imask at index %d computed value = %u reference value = %u",
- j, index, results[index].imei[j].imask, u_ref_val);
-
- diff++;
- }
-
- }
- }
-
- printf("\nFinished comparing results. Total number of differences: %d", diff);
- fclose(pf);
- }
- else
- {
- printf("\n%s file not found. No comparison performed.", ref_file);
- }
-}
-
-/*! \brief Debugging helper function */
-void dump_compare_results_f(float* results, int cnt, char* out_file, char* ref_file)
-{
- FILE *pf;
- float cmp_eps = 0.001f;
-
- pf = fopen(out_file, "wt");
- assert(pf != NULL);
-
- for (int index = 0; index < cnt; index++)
- {
- fprintf(pf, "%15.5f\n", results[index]);
- }
-
- fclose(pf);
-
- printf("\nWrote results to %s", out_file);
-
- pf = fopen(ref_file, "rt");
- if (pf)
- {
- int diff = 0;
- printf("\n%s file found. Comparing results...", ref_file);
- for (int index = 0; index < cnt; index++)
- {
- float ref_val;
- if (1 != fscanf(pf, "%20f", &ref_val))
- {
- break;
- }
-
- if (((ref_val - results[index]) > cmp_eps) ||
- ((ref_val - results[index]) < -cmp_eps))
- {
- printf("\nDifference at index %d computed value = %15.5f reference value = %15.5f",
- index, results[index], ref_val);
-
- diff++;
- }
- }
-
- printf("\nFinished comparing results. Total number of differences: %d", diff);
- fclose(pf);
- }
- else
- {
- printf("\n%s file not found. No comparison performed.", ref_file);
- }
-}
-
-/*! \brief
- * Debug function for dumping cj4, f and fshift buffers.
- * By default this function does nothing. To enable debugging for any of these
- * buffers, uncomment the corresponding definition inside the function:
- * DEBUG_DUMP_CJ4_OCL, DEBUG_DUMP_F_OCL, DEBUG_DUMP_FSHIFT_OCL.
- */
-static
-void debug_dump_cj4_f_fshift(gmx_nbnxn_ocl_t gmx_unused *nb,
- const struct nbnxn_atomdata_t gmx_unused *nbatom,
- cl_command_queue gmx_unused stream,
- int gmx_unused adat_begin,
- int gmx_unused adat_len)
-{
-/* Uncomment this define to enable cj4 debugging for the first kernel run */
-//#define DEBUG_DUMP_CJ4_OCL
-#ifdef DEBUG_DUMP_CJ4_OCL
- {
- static int run_step = 1;
-
- if (DEBUG_RUN_STEP == run_step)
- {
- nbnxn_cj4_t *temp_cj4;
- int cnt;
- size_t size;
- char ocl_file_name[256] = {0};
- char cuda_file_name[256] = {0};
-
- cnt = nb->plist[0]->ncj4;
- size = cnt * sizeof(nbnxn_cj4_t);
- temp_cj4 = (nbnxn_cj4_t*)malloc(size);
-
- ocl_copy_D2H_async(temp_cj4, nb->plist[0]->cj4, 0,
- size, stream, NULL);
-
- // Make sure all data has been transfered back from device
- clFinish(stream);
-
- sprintf(ocl_file_name, "ocl_cj4_%d.txt", DEBUG_RUN_STEP);
- sprintf(cuda_file_name, "cuda_cj4_%d.txt", DEBUG_RUN_STEP);
- dump_compare_results_cj4(temp_cj4, cnt, ocl_file_name, cuda_file_name);
-
- free(temp_cj4);
- }
-
- run_step++;
- }
-#endif
-
-/* Uncomment this define to enable f debugging for the first kernel run */
-//#define DEBUG_DUMP_F_OCL
-#ifdef DEBUG_DUMP_F_OCL
- {
- static int run_step = 1;
-
- if (DEBUG_RUN_STEP == run_step)
- {
- char ocl_file_name[256] = {0};
- char cuda_file_name[256] = {0};
-
- // Make sure all data has been transfered back from device
- clFinish(stream);
-
- sprintf(ocl_file_name, "ocl_f_%d.txt", DEBUG_RUN_STEP);
- sprintf(cuda_file_name, "cuda_f_%d.txt", DEBUG_RUN_STEP);
-
- dump_compare_results_f(nbatom->out[0].f + adat_begin * 3, (adat_len) * 3,
- ocl_file_name, cuda_file_name);
- }
-
- run_step++;
- }
-#endif
-
-/* Uncomment this define to enable fshift debugging for the first kernel run */
-//#define DEBUG_DUMP_FSHIFT_OCL
-#ifdef DEBUG_DUMP_FSHIFT_OCL
- {
- static int run_step = 1;
-
- if (DEBUG_RUN_STEP == run_step)
- {
- char ocl_file_name[256] = {0};
- char cuda_file_name[256] = {0};
-
- // Make sure all data has been transfered back from device
- clFinish(stream);
-
- sprintf(ocl_file_name, "ocl_fshift_%d.txt", DEBUG_RUN_STEP);
- sprintf(cuda_file_name, "cuda_fshift_%d.txt", DEBUG_RUN_STEP);
-
- dump_compare_results_f((float*)(nb->nbst.fshift), SHIFTS * 3,
- ocl_file_name, cuda_file_name);
- }
-
- run_step++;
- }
-#endif
-}
-
/*! \brief
* Launch asynchronously the download of nonbonded forces from the GPU
* (and energies/shift forces if required).
sizeof(float), stream, bDoTime ? &(t->nb_d2h_e_el[iloc]) : NULL);
}
}
-
- debug_dump_cj4_f_fshift(nb, nbatom, stream, adat_begin, adat_len);
}
/*! \brief
nbs->search_count++;
}
if (nbs->print_cycles &&
- (!nbs->DomDec || (nbs->DomDec && !LOCAL_I(iloc))) &&
+ (!nbs->DomDec || !LOCAL_I(iloc)) &&
nbs->search_count % 100 == 0)
{
nbs_cycle_print(stderr, nbs);
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2010,2011,2012,2013,2014,2015, by the GROMACS development team, led by
+ * Copyright (c) 2010,2011,2012,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.
template <typename T>
+// cppcheck-suppress uninitMemberVar
OptionStorageTemplate<T>::OptionStorageTemplate(const AbstractOption &settings)
: AbstractOptionStorage(settings, OptionFlags()),
store_(NULL), countptr_(NULL),
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2009,2010,2011,2012,2013,2014,2015, by the GROMACS development team, led by
+ * Copyright (c) 2009,2010,2011,2012,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.
case '/': sel->u.arith.type = ARITH_DIV; break;
case '^': sel->u.arith.type = ARITH_EXP; break;
}
- char buf[2];
- buf[0] = op;
- buf[1] = 0;
+ char buf[2] {
+ op, 0
+ };
sel->setName(buf);
sel->u.arith.opstr = gmx_strdup(buf);
sel->child = left;
SelectionTreeElementPointer
_gmx_sel_init_const_position(real x, real y, real z, yyscan_t scanner)
{
- rvec pos;
+ rvec pos {
+ x, y, z
+ };
SelectionTreeElementPointer sel(
new SelectionTreeElement(
SEL_CONST, _gmx_sel_lexer_get_current_location(scanner)));
_gmx_selelem_set_vtype(sel, POS_VALUE);
_gmx_selvalue_reserve(&sel->v, 1);
- pos[XX] = x;
- pos[YY] = y;
- pos[ZZ] = z;
gmx_ana_pos_init_const(sel->v.u.p, pos);
return sel;
}
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2009,2010,2011,2012,2014,2015, by the GROMACS development team, led by
+ * Copyright (c) 2009,2010,2011,2012,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.
gmx_sel_lexer_t *state = new gmx_sel_lexer_t;
+ // cppcheck-suppress uninitdata
state->sc = sc;
+ // cppcheck-suppress uninitdata
state->bGroups = bGroups;
+ // cppcheck-suppress uninitdata
state->grps = grps;
+ // cppcheck-suppress uninitdata
state->nexpsel = (maxnr > 0 ? static_cast<int>(sc->sel.size()) + maxnr : -1);
state->statusWriter = statusWriter;
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2009,2010,2011,2012,2013,2014,2015, by the GROMACS development team, led by
+ * Copyright (c) 2009,2010,2011,2012,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.
init_data_insolidangle(int /* npar */, gmx_ana_selparam_t *param)
{
t_methoddata_insolidangle *data = new t_methoddata_insolidangle();
+ // cppcheck-suppress uninitdata
data->angcut = 5.0;
+ // cppcheck-suppress uninitdata
data->cfrac = 0.0;
+ // cppcheck-suppress uninitdata
data->distccut = 0.0;
+ // cppcheck-suppress uninitdata
data->targetbinsize = 0.0;
+ // cppcheck-suppress uninitdata
data->ntbins = 0;
+ // cppcheck-suppress uninitdata
data->tbinsize = 0.0;
+ // cppcheck-suppress uninitdata
data->tbin = NULL;
+ // cppcheck-suppress uninitdata
data->maxbins = 0;
+ // cppcheck-suppress uninitdata
data->nbins = 0;
+ // cppcheck-suppress uninitdata
data->bin = NULL;
param[0].val.u.p = &data->center;
for (i = 0; i < n; i++)
{
pr_indent(fp, indent);
- fprintf(fp, "%s[%6d]={type=%3d, typeB=%3d, ptype=%8s, m=%12.5e, "
+ fprintf(fp, "%s[%6d]={type=%3u, typeB=%3u, ptype=%8s, m=%12.5e, "
"q=%12.5e, mB=%12.5e, qB=%12.5e, resind=%5d, atomnumber=%3d}\n",
title, i, atom[i].type, atom[i].typeB, ptype_str[atom[i].ptype],
atom[i].m, atom[i].q, atom[i].mB, atom[i].qB,
*
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
* Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014,2015, 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.
for (l = 0; (l < nrestp); l++)
{
+ assert(restp);
if (strcmp(restp[l].rname, rname) == 0)
{
break;
snew(restype, atoms->nres);
ntypes = 0;
p_typename = NULL;
- for (i = 0; i < atoms->nres; i++)
+ if (atoms->nres > 0)
{
+ int i = 0;
+
resnm = *atoms->resinfo[i].name;
gmx_residuetype_get_type(rt, resnm, &(restype[i]));
+ snew(p_typename, ntypes+1);
+ p_typename[ntypes] = gmx_strdup(restype[i]);
+ ntypes++;
- /* Note that this does not lead to a N*N loop, but N*K, where
- * K is the number of residue _types_, which is small and independent of N.
- */
- found = 0;
- for (k = 0; k < ntypes && !found; k++)
- {
- assert(p_typename != NULL);
- found = !strcmp(restype[i], p_typename[k]);
- }
- if (!found)
+ for (i = 1; i < atoms->nres; i++)
{
- srenew(p_typename, ntypes+1);
- p_typename[ntypes++] = gmx_strdup(restype[i]);
+ resnm = *atoms->resinfo[i].name;
+ gmx_residuetype_get_type(rt, resnm, &(restype[i]));
+
+ /* Note that this does not lead to a N*N loop, but N*K, where
+ * K is the number of residue _types_, which is small and independent of N.
+ */
+ found = 0;
+ for (k = 0; k < ntypes && !found; k++)
+ {
+ found = !strcmp(restype[i], p_typename[k]);
+ }
+ if (!found)
+ {
+ srenew(p_typename, ntypes+1);
+ p_typename[ntypes] = gmx_strdup(restype[i]);
+ ntypes++;
+ }
}
}
{
if (mb >= 0)
{
- /* cppcheck-suppress nullPointer #6330*/
+ /* cppcheck-suppress nullPointer #6330 will be fixed in cppcheck 1.73 */
if (atoms->nres <= mtop->maxres_renum)
{
/* Single residue molecule, keep counting */
- /* cppcheck-suppress nullPointer #6330*/
+ /* cppcheck-suppress nullPointer #6330 will be fixed in cppcheck 1.73 */
maxresnr += mtop->molblock[mb].nmol*atoms->nres;
}
}
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2010,2013,2014,2015, by the GROMACS development team, led by
+ * Copyright (c) 2010,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.
const char *** p_typenames,
int * ntypes)
{
- int i, n;
- const char ** my_typename;
+ int n = 0;
+ const char **my_typename = NULL;
- n = 0;
- my_typename = NULL;
- for (i = 0; i < rt->n; i++)
+ if (rt->n > 0)
{
- const char *const p = rt->restype[i];
- bool bFound = false;
- for (int j = 0; j < n && !bFound; j++)
- {
- assert(my_typename != NULL);
- bFound = !gmx_strcasecmp(p, my_typename[j]);
- }
- if (!bFound)
+ int i = 0;
+ const char *p = rt->restype[i];
+ snew(my_typename, n+1);
+ my_typename[n] = p;
+ n = 1;
+
+ for (i = 1; i < rt->n; i++)
{
- srenew(my_typename, n+1);
- my_typename[n] = p;
- n++;
+ p = rt->restype[i];
+ bool bFound = false;
+ for (int j = 0; j < n && !bFound; j++)
+ {
+ bFound = !gmx_strcasecmp(p, my_typename[j]);
+ }
+ if (!bFound)
+ {
+ srenew(my_typename, n+1);
+ my_typename[n] = p;
+ n++;
+ }
}
}
*ntypes = n;
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2011,2012,2013,2014,2015, by the GROMACS development team, led by
+ * Copyright (c) 2011,2012,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.
rvec dx[3];
if (pbc)
{
+ // cppcheck-suppress uninitvar
pbc_dx(pbc, x[0], x[1], dx[0]);
+ // cppcheck-suppress uninitvar
pbc_dx(pbc, x[2], x[1], dx[1]);
+ // cppcheck-suppress uninitvar
pbc_dx(pbc, x[2], x[3], dx[2]);
}
else
{
+ // cppcheck-suppress uninitvar
rvec_sub(x[0], x[1], dx[0]);
+ // cppcheck-suppress uninitvar
rvec_sub(x[2], x[1], dx[1]);
+ // cppcheck-suppress uninitvar
rvec_sub(x[2], x[3], dx[2]);
}
cprod(dx[0], dx[1], v1);
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2013,2014,2015, 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.
for (int m = 0; (m < DIM); m++)
{
// Generate random number between 0 and 1
+ // cppcheck-suppress uninitvar
rand[m] = gmx_rng_uniform_real(rng_);
}
// Generate random 3D position within the box
class TrajectoryAnalysisRunnerCommon::Impl : public ITopologyProvider
{
public:
- Impl(TrajectoryAnalysisSettings *settings);
+ explicit Impl(TrajectoryAnalysisSettings *settings);
~Impl();
bool hasTrajectory() const { return !trjfile_.empty(); }
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2015, by the GROMACS development team, led by
+ * Copyright (c) 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.
class InteractiveSession
{
public:
- InteractiveSession(gmx::test::ReferenceDataMode mode)
+ explicit InteractiveSession(gmx::test::ReferenceDataMode mode)
: data_(mode), helper_(data_.rootChecker()), nextInputLine_(0)
{
}
#
# This file is part of the GROMACS molecular simulation package.
#
-# Copyright (c) 2013,2014,2015, 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.
${CMAKE_SOURCE_DIR}/src/external/*.cu
${CMAKE_SOURCE_DIR}/src/gromacs/selection/scanner.cpp
${CMAKE_SOURCE_DIR}/src/gromacs/selection/parser.cpp
+ ${CMAKE_SOURCE_DIR}/src/gromacs/gpu_utils/ocl_compiler.cpp
)
list(REMOVE_ITEM _inputfiles ${_files_to_ignore})
# Set flags for cppcheck
set(_outputext txt)
- set(_outputopt --template=gcc)
+ set(_outputopt "--template={file}:{line}:{id}: {severity}: {message}")
if (CPPCHECK_XML_OUTPUT)
set(_outputext xml)
set(_outputopt --xml --xml-version=2)
--suppress=invalidPointerCast:src/gromacs/mdlib/nbnxn_cuda/nbnxn_cuda_kernel.cuh
--suppress=passedByValue:src/gromacs/mdlib/nbnxn_cuda/nbnxn_cuda_kernel.cuh
--suppress=passedByValue:src/gromacs/mdlib/nbnxn_cuda/nbnxn_cuda_kernel_utils.cuh
+ --suppress=shiftTooManyBits:src/gromacs/gpu_utils/gpu_utils.cu
)
set(_cxx_flags
-D__cplusplus
--suppress=invalidscanf_libc #seems only important for security on non-std libc
--suppress=invalidscanf #same as last (style and portability checker have the same warning)
--suppress=passedByValue:src/gromacs/simd/tests/*
- --suppress=redundantAssignment:src/gromacs/simd/simd_math.h #sees to be a bug in cppcheck
+ --suppress=redundantAssignment:src/gromacs/simd/simd_math.h #seems to be a bug in cppcheck
+ --suppress=noExplicitConstructor # can't be selective about this, see http://sourceforge.net/p/cppcheck/discussion/general/thread/db1e4ba7/
)
# This list will hold the list of all files with cppcheck errors