*
* Copyright (c) 2008,2009,2010, The GROMACS development team.
* Copyright (c) 2012,2013,2014,2015,2016 The GROMACS development team.
- * Copyright (c) 2017,2018,2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 2017,2018,2019,2020,2021, 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_atoms& atoms = mtop->moltype[molb.type].atoms;
for (int i = 0; i < atoms.nr; ++i)
{
- int tpi;
- if (state == 0)
- {
- tpi = atoms.atom[i].type;
- }
- else
- {
- tpi = atoms.atom[i].typeB;
- }
+ const int tpi = (state == 0) ? atoms.atom[i].type : atoms.atom[i].typeB;
typecount[tpi] += molb.nmol;
}
}
gmx_mtop_atomloop_block_t gmx_mtop_atomloop_block_init(const gmx_mtop_t* mtop)
{
- struct gmx_mtop_atomloop_block* aloop;
+ struct gmx_mtop_atomloop_block* aloop = nullptr;
snew(aloop, 1);
gmx_mtop_ilistloop_t gmx_mtop_ilistloop_init(const gmx_mtop_t* mtop)
{
- struct gmx_mtop_ilistloop* iloop;
+ struct gmx_mtop_ilistloop* iloop = nullptr;
snew(iloop, 1);
int gmx_mtop_ftype_count(const gmx_mtop_t* mtop, int ftype)
{
- gmx_mtop_ilistloop_t iloop;
- int n, nmol;
-
- n = 0;
+ int nmol = 0;
+ int n = 0;
- iloop = gmx_mtop_ilistloop_init(mtop);
+ gmx_mtop_ilistloop_t iloop = gmx_mtop_ilistloop_init(mtop);
while (const InteractionLists* il = gmx_mtop_ilistloop_next(iloop, &nmol))
{
n += nmol * (*il)[ftype].size() / (1 + NRAL(ftype));
int n = 0;
gmx_mtop_ilistloop_t iloop = gmx_mtop_ilistloop_init(mtop);
- int nmol;
+ int nmol = 0;
while (const InteractionLists* il = gmx_mtop_ilistloop_next(iloop, &nmol))
{
for (int ftype = 0; ftype < F_NRE; ftype++)
static void atomcat(t_atoms* dest, const t_atoms* src, int copies, int maxres_renum, int* maxresnr)
{
- int i, j, l, size;
+ int i = 0, j = 0, l = 0, size = 0;
int srcnr = src->nr;
int destnr = dest->nr;
static void ilistcat(int ftype, InteractionList* dest, const InteractionList& src, int copies, int dnum, int snum)
{
- int nral, c, i, a;
-
- nral = NRAL(ftype);
+ const int nral = NRAL(ftype);
size_t destIndex = dest->iatoms.size();
dest->iatoms.resize(dest->iatoms.size() + copies * src.size());
- for (c = 0; c < copies; c++)
+ for (int c = 0; c < copies; c++)
{
- for (i = 0; i < src.size();)
+ for (int i = 0; i < src.size();)
{
dest->iatoms[destIndex++] = src.iatoms[i++];
- for (a = 0; a < nral; a++)
+ for (int a = 0; a < nral; a++)
{
dest->iatoms[destIndex++] = dnum + src.iatoms[i++];
}
static void ilistcat(int ftype, t_ilist* dest, const InteractionList& src, int copies, int dnum, int snum)
{
- int nral, c, i, a;
-
- nral = NRAL(ftype);
+ const int nral = NRAL(ftype);
dest->nalloc = dest->nr + copies * src.size();
srenew(dest->iatoms, dest->nalloc);
- for (c = 0; c < copies; c++)
+ for (int c = 0; c < copies; c++)
{
- for (i = 0; i < src.size();)
+ for (int i = 0; i < src.size();)
{
dest->iatoms[dest->nr++] = src.iatoms[i++];
- for (a = 0; a < nral; a++)
+ for (int a = 0; a < nral; a++)
{
dest->iatoms[dest->nr++] = dnum + src.iatoms[i++];
}
template<typename IdefType>
static void set_posres_params(IdefType* idef, const gmx_molblock_t* molb, int i0, int a_offset)
{
- int i1, i, a_molb;
- t_iparams* ip;
-
auto* il = &idef->il[F_POSRES];
- i1 = il->size() / 2;
+ int i1 = il->size() / 2;
resizeIParams(&idef->iparams_posres, i1);
- for (i = i0; i < i1; i++)
+ for (int i = i0; i < i1; i++)
{
- ip = &idef->iparams_posres[i];
+ t_iparams* ip = &idef->iparams_posres[i];
/* Copy the force constants */
- *ip = getIparams(*idef, il->iatoms[i * 2]);
- a_molb = il->iatoms[i * 2 + 1] - a_offset;
+ *ip = getIparams(*idef, il->iatoms[i * 2]);
+ int a_molb = il->iatoms[i * 2 + 1] - a_offset;
if (molb->posres_xA.empty())
{
gmx_incons("Position restraint coordinates are missing");
template<typename IdefType>
static void set_fbposres_params(IdefType* idef, const gmx_molblock_t* molb, int i0, int a_offset)
{
- int i1, i, a_molb;
- t_iparams* ip;
-
auto* il = &idef->il[F_FBPOSRES];
- i1 = il->size() / 2;
+ int i1 = il->size() / 2;
resizeIParams(&idef->iparams_fbposres, i1);
- for (i = i0; i < i1; i++)
+ for (int i = i0; i < i1; i++)
{
- ip = &idef->iparams_fbposres[i];
+ t_iparams* ip = &idef->iparams_fbposres[i];
/* Copy the force constants */
- *ip = getIparams(*idef, il->iatoms[i * 2]);
- a_molb = il->iatoms[i * 2 + 1] - a_offset;
+ *ip = getIparams(*idef, il->iatoms[i * 2]);
+ int a_molb = il->iatoms[i * 2 + 1] - a_offset;
if (molb->posres_xA.empty())
{
gmx_incons("Position restraint coordinates are missing");