#include "grompp.h"
-#include <assert.h>
#include <errno.h>
#include <limits.h>
-#include <math.h>
#include <string.h>
+#include <cmath>
+
+#include <algorithm>
+
#include <sys/types.h>
#include "gromacs/commandline/pargs.h"
#include "gromacs/fileio/confio.h"
#include "gromacs/fileio/enxio.h"
-#include "gromacs/fileio/gmxfio.h"
#include "gromacs/fileio/tpxio.h"
-#include "gromacs/fileio/trnio.h"
#include "gromacs/fileio/trxio.h"
#include "gromacs/gmxpreprocess/add_par.h"
#include "gromacs/gmxpreprocess/convparm.h"
#include "gromacs/utility/cstringutil.h"
#include "gromacs/utility/fatalerror.h"
#include "gromacs/utility/futil.h"
+#include "gromacs/utility/gmxassert.h"
#include "gromacs/utility/smalloc.h"
#include "gromacs/utility/snprintf.h"
maxsize = 0;
for (cg = 0; cg < cgs->nr; cg++)
{
- maxsize = max(maxsize, cgs->index[cg+1]-cgs->index[cg]);
+ maxsize = std::max(maxsize, cgs->index[cg+1]-cgs->index[cg]);
}
if (maxsize > MAX_CHARGEGROUP_SIZE)
if (debug)
{
fprintf(debug, "fc %g m1 %g m2 %g period %g\n",
- fc, m1, m2, sqrt(period2));
+ fc, m1, m2, std::sqrt(period2));
}
if (period2 < limit2)
{
*w_moltype->name,
w_a1+1, *w_moltype->atoms.atomname[w_a1],
w_a2+1, *w_moltype->atoms.atomname[w_a2],
- sqrt(w_period2), bWarn ? min_steps_warn : min_steps_note, dt,
+ std::sqrt(w_period2), bWarn ? min_steps_warn : min_steps_note, dt,
bWater ?
"Maybe you asked for fexible water." :
"Maybe you forgot to change the constraints mdp option.");
rvec com,
warninp_t wi)
{
- gmx_bool bFirst = TRUE, *hadAtom;
+ gmx_bool *hadAtom;
rvec *x, *v, *xp;
dvec sum;
double totmass;
get_stx_coordnum(fn, &natoms);
if (natoms != mtop->natoms)
{
- sprintf(warn_buf, "The number of atoms in %s (%d) does not match the number of atoms in the topology (%d). Will assume that the first %d atoms in the topology and %s match.", fn, natoms, mtop->natoms, min(mtop->natoms, natoms), fn);
+ sprintf(warn_buf, "The number of atoms in %s (%d) does not match the number of atoms in the topology (%d). Will assume that the first %d atoms in the topology and %s match.", fn, natoms, mtop->natoms, std::min(mtop->natoms, natoms), fn);
warning(wi, warn_buf);
}
snew(x, natoms);
if (rc_scaling != erscNO)
{
- assert(npbcdim <= DIM);
+ GMX_ASSERT(npbcdim <= DIM, "Only DIM dimensions can have PBC");
for (mb = 0; mb < mtop->nmolblock; mb++)
{
rvec com, rvec comB,
warninp_t wi)
{
- int i, j;
-
read_posres (mtop, mi, FALSE, fnA, rc_scaling, ePBC, com, wi);
/* It is safer to simply read the b-state posres rather than trying
* to be smart and copy the positions.
int ix;
double a, b;
- ix = (x-xmin)/dx;
+ ix = static_cast<int>((x-xmin)/dx);
a = (xmin+(ix+1)*dx-x)/dx;
b = (x-xmin-ix*dx)/dx;
void init_cmap_grid(gmx_cmap_t *cmap_grid, int ngrid, int grid_spacing)
{
- int i, k, nelem;
+ int i, nelem;
cmap_grid->ngrid = ngrid;
cmap_grid->grid_spacing = grid_spacing;
const t_inputrec *ir,
rvec *v)
{
- double sum_mv2;
gmx_mtop_atomloop_all_t aloop;
t_atom *atom;
int a;
- int nrdf, g;
-
- sum_mv2 = 0;
+ double sum_mv2 = 0;
aloop = gmx_mtop_atomloop_all_init(mtop);
while (gmx_mtop_atomloop_all_next(aloop, &a, &atom))
{
sum_mv2 += atom->m*norm2(v[a]);
}
- nrdf = 0;
- for (g = 0; g < ir->opts.ngtc; g++)
+ double nrdf = 0;
+ for (int g = 0; g < ir->opts.ngtc; g++)
{
nrdf += ir->opts.nrdf[g];
}
}
else
{
- ref_t = max(ref_t, ir->opts.ref_t[i]);
+ ref_t = std::max(ref_t, ir->opts.ref_t[i]);
}
}
matrix box,
warninp_t wi)
{
- int i;
verletbuf_list_setup_t ls;
real rlist_1x1;
int n_nonlin_vsite;
}
printf("Calculated rlist for %dx%d atom pair-list as %.3f nm, buffer size %.3f nm\n",
- 1, 1, rlist_1x1, rlist_1x1-max(ir->rvdw, ir->rcoulomb));
+ 1, 1, rlist_1x1, rlist_1x1-std::max(ir->rvdw, ir->rcoulomb));
ir->rlistlong = ir->rlist;
printf("Set rlist, assuming %dx%d atom pair-list, to %.3f nm, buffer size %.3f nm\n",
ls.cluster_size_i, ls.cluster_size_j,
- ir->rlist, ir->rlist-max(ir->rvdw, ir->rcoulomb));
+ ir->rlist, ir->rlist-std::max(ir->rvdw, ir->rcoulomb));
printf("Note that mdrun will redetermine rlist based on the actual pair-list setup\n");
if (sqr(ir->rlistlong) >= max_cutoff2(ir->ePBC, box))
{
- gmx_fatal(FARGS, "The pair-list cut-off (%g nm) is longer than half the shortest box vector or longer than the smallest box diagonal element (%g nm). Increase the box size or decrease nstlist or increase verlet-buffer-tolerance.", ir->rlistlong, sqrt(max_cutoff2(ir->ePBC, box)));
+ gmx_fatal(FARGS, "The pair-list cut-off (%g nm) is longer than half the shortest box vector or longer than the smallest box diagonal element (%g nm). Increase the box size or decrease nstlist or increase verlet-buffer-tolerance.", ir->rlistlong, std::sqrt(max_cutoff2(ir->ePBC, box)));
}
}
t_molinfo *mi, *intermolecular_interactions;
gpp_atomtype_t atype;
t_inputrec *ir;
- int natoms, nvsite, comb, mt;
+ int nvsite, comb, mt;
t_params *plist;
t_state *state;
matrix box;
- real max_spacing, fudgeQQ;
+ real fudgeQQ;
double reppow;
char fn[STRLEN], fnB[STRLEN];
const char *mdparin;
int ntype;
gmx_bool bNeedVel, bGenVel;
gmx_bool have_atomnumber;
- int n12, n13, n14;
- t_params *gb_plist = NULL;
- gmx_genborn_t *born = NULL;
output_env_t oenv;
gmx_bool bVerbose = FALSE;
warninp_t wi;
char warn_buf[STRLEN];
- unsigned int useed;
- t_atoms IMDatoms; /* Atoms to be operated on interactively (IMD) */
t_filenm fnm[] = {
{ efMDP, NULL, NULL, ffREAD },
if (ir->ld_seed == -1)
{
ir->ld_seed = (gmx_int64_t)gmx_rng_make_seed();
- fprintf(stderr, "Setting the LD random seed to %"GMX_PRId64 "\n", ir->ld_seed);
+ fprintf(stderr, "Setting the LD random seed to %" GMX_PRId64 "\n", ir->ld_seed);
}
if (ir->expandedvals->lmc_seed == -1)
if (bRenum)
{
renum_atype(plist, sys, ir->wall_atomtype, atype, bVerbose);
- ntype = get_atomtype_ntypes(atype);
+ get_atomtype_ntypes(atype);
}
if (ir->implicit_solvent != eisNO)
}
do_index(mdparin, ftp2fn_null(efNDX, NFILE, fnm),
sys, bVerbose, ir,
- bGenVel ? state->v : NULL,
wi);
if (ir->cutoff_scheme == ecutsVERLET && ir->verletbuf_tol > 0 &&
set_warning_line(wi, mdparin, -1);
warning_error(wi, "Some of the Fourier grid sizes are set, but all of them need to be set.");
}
- max_spacing = calc_grid(stdout, box, ir->fourier_spacing,
- &(ir->nkx), &(ir->nky), &(ir->nkz));
+ calc_grid(stdout, box, ir->fourier_spacing,
+ &(ir->nkx), &(ir->nky), &(ir->nkz));
}
/* MRS: eventually figure out better logic for initializing the fep