* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
* Copyright (c) 2001-2004, The GROMACS development team.
* Copyright (c) 2013,2014,2015,2017,2018 by the GROMACS development team.
- * Copyright (c) 2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 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.
real propValue,
int line)
{
- bool bExact;
- int j = findPropertyIndex(ap, restype, residueName, atomName, &bExact);
+ bool bExact = false;
+ int j = findPropertyIndex(ap, restype, residueName, atomName, &bExact);
if (!bExact)
{
while (get_a_line(fp.get(), line, STRLEN))
{
line_no++;
- double pp;
+ double pp = 0.0;
if (sscanf(line, "%31s %31s %20lf", resnm, atomnm, &pp) == 3)
{
pp *= factor;
const std::string& atomName,
real* value)
{
- int j;
std::string tmpAtomName, tmpResidueName;
- gmx_bool bExact;
+ bool bExact = false;
if (setProperties(prop(eprop), restype(), eprop, impl_->bWarned))
{
{
tmpAtomName = atomName;
}
- j = findPropertyIndex(&(impl_->prop[eprop]), &impl_->restype, residueName, tmpAtomName, &bExact);
+ const int j = findPropertyIndex(
+ &(impl_->prop[eprop]), &impl_->restype, residueName, tmpAtomName, &bExact);
if (eprop == epropVDW && !impl_->bWarnVDW)
{
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
* Copyright (c) 2001-2004, The GROMACS development team.
* Copyright (c) 2013,2014,2015,2016,2017 by the GROMACS development team.
- * Copyright (c) 2018,2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 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.
void add_t_atoms(t_atoms* atoms, int natom_extra, int nres_extra)
{
- int i;
-
if (natom_extra > 0)
{
srenew(atoms->atomname, atoms->nr + natom_extra);
{
srenew(atoms->atomtypeB, atoms->nr + natom_extra);
}
- for (i = atoms->nr; (i < atoms->nr + natom_extra); i++)
+ for (int i = atoms->nr; (i < atoms->nr + natom_extra); i++)
{
atoms->atomname[i] = nullptr;
memset(&atoms->atom[i], 0, sizeof(atoms->atom[i]));
if (nres_extra > 0)
{
srenew(atoms->resinfo, atoms->nres + nres_extra);
- for (i = atoms->nres; (i < atoms->nres + nres_extra); i++)
+ for (int i = atoms->nres; (i < atoms->nres + nres_extra); i++)
{
std::memset(&atoms->resinfo[i], 0, sizeof(atoms->resinfo[i]));
}
t_atoms* copy_t_atoms(const t_atoms* src)
{
- t_atoms* dst;
- int i;
+ t_atoms* dst = nullptr;
snew(dst, 1);
init_t_atoms(dst, src->nr, (nullptr != src->pdbinfo));
{
snew(dst->atomtypeB, src->nr);
}
- for (i = 0; (i < src->nr); i++)
+ for (int i = 0; (i < src->nr); i++)
{
dst->atom[i] = src->atom[i];
if (nullptr != src->pdbinfo)
dst->havePdbInfo = src->havePdbInfo;
dst->haveType = src->haveType;
dst->nres = src->nres;
- for (i = 0; (i < src->nres); i++)
+ for (int i = 0; (i < src->nres); i++)
{
dst->resinfo[i] = src->resinfo[i];
}
int chainnum,
char chainid)
{
- t_resinfo* ri;
-
- ri = &atoms->resinfo[atoms->atom[atom_ind].resind];
- ri->name = put_symtab(symtab, resname);
- ri->rtp = nullptr;
- ri->nr = resnr;
- ri->ic = ic;
- ri->chainnum = chainnum;
- ri->chainid = chainid;
+ t_resinfo* ri = &atoms->resinfo[atoms->atom[atom_ind].resind];
+ ri->name = put_symtab(symtab, resname);
+ ri->rtp = nullptr;
+ ri->nr = resnr;
+ ri->ic = ic;
+ ri->chainnum = chainnum;
+ ri->chainid = chainid;
}
static void pr_atom(FILE* fp, int indent, const char* title, const t_atom* atom, int n)
{
- int i;
-
if (available(fp, atom, indent, title))
{
indent = pr_title_n(fp, indent, title, n);
- for (i = 0; i < n; i++)
+ for (int i = 0; i < n; i++)
{
pr_indent(fp, indent);
fprintf(fp,
static void pr_strings2(FILE* fp, int indent, const char* title, char*** nm, char*** nmB, int n, gmx_bool bShowNumbers)
{
- int i;
-
if (available(fp, nm, indent, title))
{
indent = pr_title_n(fp, indent, title, n);
- for (i = 0; i < n; i++)
+ for (int i = 0; i < n; i++)
{
pr_indent(fp, indent);
fprintf(fp, "%s[%d]={name=\"%s\",nameB=\"%s\"}\n", title, bShowNumbers ? i : -1, *(nm[i]), *(nmB[i]));
static void pr_resinfo(FILE* fp, int indent, const char* title, const t_resinfo* resinfo, int n, gmx_bool bShowNumbers)
{
- int i;
-
if (available(fp, resinfo, indent, title))
{
indent = pr_title_n(fp, indent, title, n);
- for (i = 0; i < n; i++)
+ for (int i = 0; i < n; i++)
{
pr_indent(fp, indent);
fprintf(fp,
void pr_atomtypes(FILE* fp, int indent, const char* title, const t_atomtypes* atomtypes, gmx_bool bShowNumbers)
{
- int i;
if (available(fp, atomtypes, indent, title))
{
indent = pr_title(fp, indent, title);
- for (i = 0; i < atomtypes->nr; i++)
+ for (int i = 0; i < atomtypes->nr; i++)
{
pr_indent(fp, indent);
fprintf(fp, "atomtype[%3d]={atomnumber=%4d}\n", bShowNumbers ? i : -1, atomtypes->atomnumber[i]);
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
* Copyright (c) 2001-2004, The GROMACS development team.
* Copyright (c) 2013,2014,2015,2017,2018 by the GROMACS development team.
- * Copyright (c) 2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 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.
t_blocka* new_blocka()
{
- t_blocka* block;
+ t_blocka* block = nullptr;
snew(block, 1);
snew(block->index, 1);
static void low_pr_blocka(FILE* fp, int indent, const char* title, const t_blocka* block, gmx_bool bShowNumbers)
{
- int i;
-
if (available(fp, block, indent, title))
{
indent = pr_blocka_title(fp, indent, title, block);
- for (i = 0; i <= block->nr; i++)
+ for (int i = 0; i <= block->nr; i++)
{
pr_indent(fp, indent + INDENT);
fprintf(fp, "%s->index[%d]=%d\n", title, bShowNumbers ? i : -1, block->index[i]);
}
- for (i = 0; i < block->nra; i++)
+ for (int i = 0; i < block->nra; i++)
{
pr_indent(fp, indent + INDENT);
fprintf(fp, "%s->a[%d]=%d\n", title, bShowNumbers ? i : -1, block->a[i]);
void pr_block(FILE* fp, int indent, const char* title, const t_block* block, gmx_bool bShowNumbers)
{
- int i, start;
-
if (available(fp, block, indent, title))
{
- indent = pr_block_title(fp, indent, title, block);
- start = 0;
+ indent = pr_block_title(fp, indent, title, block);
+ int start = 0;
if (block->index[start] != 0)
{
fprintf(fp, "block->index[%d] should be 0\n", start);
}
else
{
- for (i = 0; i < block->nr; i++)
+ for (int i = 0; i < block->nr; i++)
{
int end = block->index[i + 1];
pr_indent(fp, indent);
void pr_blocka(FILE* fp, int indent, const char* title, const t_blocka* block, gmx_bool bShowNumbers)
{
- int i, j, ok, size, start, end;
+ bool ok = false;
if (available(fp, block, indent, title))
{
- indent = pr_blocka_title(fp, indent, title, block);
- start = 0;
- end = start;
- if ((ok = static_cast<int>(block->index[start] == 0)) == 0)
+ indent = pr_blocka_title(fp, indent, title, block);
+ int start = 0;
+ int end = start;
+ ok = (block->index[start] == 0);
+ if (!ok)
{
fprintf(fp, "block->index[%d] should be 0\n", start);
}
else
{
- for (i = 0; i < block->nr; i++)
+ for (int i = 0; i < block->nr; i++)
{
- end = block->index[i + 1];
- size = pr_indent(fp, indent);
+ end = block->index[i + 1];
+ int size = pr_indent(fp, indent);
if (end <= start)
{
size += fprintf(fp, "%s[%d]={", title, i);
bShowNumbers ? start : -1,
bShowNumbers ? end - 1 : -1);
}
- for (j = start; j < end; j++)
+ for (int j = start; j < end; j++)
{
if (j > start)
{
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
* Copyright (c) 2001-2004, The GROMACS development team.
* Copyright (c) 2013,2014,2015,2016,2018 by the GROMACS development team.
- * Copyright (c) 2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 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.
static void pr_cmap(FILE* fp, int indent, const char* title, const gmx_cmap_t* cmap_grid, gmx_bool bShowNumbers)
{
- int j, nelem;
- real dx, idx;
+ const real dx = cmap_grid->grid_spacing != 0 ? 360.0 / cmap_grid->grid_spacing : 0;
- if (cmap_grid->grid_spacing != 0)
- {
- dx = 360.0 / cmap_grid->grid_spacing;
- }
- else
- {
- dx = 0;
- }
- nelem = cmap_grid->grid_spacing * cmap_grid->grid_spacing;
+ const int nelem = cmap_grid->grid_spacing * cmap_grid->grid_spacing;
if (available(fp, cmap_grid, indent, title))
{
for (gmx::index i = 0; i < gmx::ssize(cmap_grid->cmapdata); i++)
{
- idx = -180.0;
+ real idx = -180.0;
fprintf(fp, "%8s %8s %8s %8s\n", "V", "dVdx", "dVdy", "d2dV");
fprintf(fp, "grid[%3zd]={\n", bShowNumbers ? i : -1);
- for (j = 0; j < nelem; j++)
+ for (int j = 0; j < nelem; j++)
{
if ((j % cmap_grid->grid_spacing) == 0)
{
void pr_ffparams(FILE* fp, int indent, const char* title, const gmx_ffparams_t* ffparams, gmx_bool bShowNumbers)
{
- int i;
-
indent = pr_title(fp, indent, title);
pr_indent(fp, indent);
fprintf(fp, "atnr=%d\n", ffparams->atnr);
pr_indent(fp, indent);
fprintf(fp, "ntypes=%d\n", ffparams->numTypes());
- for (i = 0; i < ffparams->numTypes(); i++)
+ for (int i = 0; i < ffparams->numTypes(); i++)
{
pr_indent(fp, indent + INDENT);
fprintf(fp,
gmx_bool bShowParameters,
const t_iparams* iparams)
{
- int i, j, k, type, ftype;
-
indent = pr_title(fp, indent, title);
pr_indent(fp, indent);
fprintf(fp, "nr: %d\n", ilist.size());
{
pr_indent(fp, indent);
fprintf(fp, "iatoms:\n");
- for (i = j = 0; i < ilist.size();)
+ int j = 0;
+ for (int i = 0; i < ilist.size();)
{
pr_indent(fp, indent + INDENT);
- type = ilist.iatoms[i];
- ftype = functype[type];
+ const int type = ilist.iatoms[i];
+ const int ftype = functype[type];
if (bShowNumbers)
{
fprintf(fp, "%d type=%d ", j, type);
}
j++;
printf("(%s)", interaction_function[ftype].name);
- for (k = 0; k < interaction_function[ftype].nratoms; k++)
+ for (int k = 0; k < interaction_function[ftype].nratoms; k++)
{
fprintf(fp, " %3d", ilist.iatoms[i + 1 + k]);
}
void pr_idef(FILE* fp, int indent, const char* title, const t_idef* idef, gmx_bool bShowNumbers, gmx_bool bShowParameters)
{
- int i, j;
-
if (available(fp, idef, indent, title))
{
indent = pr_title(fp, indent, title);
fprintf(fp, "atnr=%d\n", idef->atnr);
pr_indent(fp, indent);
fprintf(fp, "ntypes=%d\n", idef->ntypes);
- for (i = 0; i < idef->ntypes; i++)
+ for (int i = 0; i < idef->ntypes; i++)
{
pr_indent(fp, indent + INDENT);
fprintf(fp,
}
pr_real(fp, indent, "fudgeQQ", idef->fudgeQQ);
- for (j = 0; (j < F_NRE); j++)
+ for (int j = 0; (j < F_NRE); j++)
{
printIlist(fp,
indent,
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
* Copyright (c) 2001-2004, The GROMACS development team.
* Copyright (c) 2013,2014,2015,2016,2017 by the GROMACS development team.
- * Copyright (c) 2018,2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 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.
#include <cstring>
#include <algorithm>
+#include <numeric>
#include "gromacs/topology/atoms.h"
#include "gromacs/topology/block.h"
static gmx_bool gmx_ask_yesno(gmx_bool bASK)
{
- char c;
+ char c = 0;
if (bASK)
{
void write_index(const char* outf, t_blocka* b, char** gnames, gmx_bool bDuplicate, int natoms)
{
- FILE* out;
- int i, j, k;
-
- out = gmx_ffopen(outf, "w");
+ FILE* out = gmx_ffopen(outf, "w");
/* fprintf(out,"%5d %5d\n",b->nr,b->nra); */
- for (i = 0; (i < b->nr); i++)
+ for (int i = 0; (i < b->nr); i++)
{
fprintf(out, "[ %s ]", gnames[i]);
- for (k = 0, j = b->index[i]; j < b->index[i + 1]; j++, k++)
+ for (int k = 0, j = b->index[i]; j < b->index[i + 1]; j++, k++)
{
const char sep = (k % 15 == 0 ? '\n' : ' ');
fprintf(out, "%c%4d", sep, b->a[j] + 1);
if (bDuplicate)
{
fprintf(stderr, "Duplicating the whole system with an atom offset of %d atoms.\n", natoms);
- for (i = 0; (i < b->nr); i++)
+ for (int i = 0; (i < b->nr); i++)
{
fprintf(out, "[ %s_copy ]", gnames[i]);
- for (k = 0, j = b->index[i]; j < b->index[i + 1]; j++, k++)
+ for (int k = 0, j = b->index[i]; j < b->index[i + 1]; j++, k++)
{
const char sep = (k % 15 == 0 ? '\n' : ' ');
fprintf(out, "%c%4d", sep, b->a[j] + 1 + natoms);
gmx_bool bASK,
gmx_bool bVerb)
{
- restp_t* restp = nullptr;
- char** attp = nullptr;
- char * rname, *aname;
- int i, resind, natp, nrestp = 0;
+ std::vector<restp_t> restp;
+ int i = 0;
- for (i = 0; (i < atoms->nres); i++)
+ for (; (i < atoms->nres); i++)
{
if (gmx_strcasecmp(restype[i].c_str(), "Protein")
&& gmx_strcasecmp(restype[i].c_str(), "DNA") && gmx_strcasecmp(restype[i].c_str(), "RNA")
}
for (int k = 0; (k < atoms->nr); k++)
{
- resind = atoms->atom[k].resind;
- rname = *atoms->resinfo[resind].name;
+ int resind = atoms->atom[k].resind;
+ const char* rname = *atoms->resinfo[resind].name;
if (gmx_strcasecmp(restype[resind].c_str(), "Protein")
&& gmx_strcasecmp(restype[resind].c_str(), "DNA")
&& gmx_strcasecmp(restype[resind].c_str(), "RNA")
&& gmx_strcasecmp(restype[resind].c_str(), "Water"))
{
- int l;
- for (l = 0; (l < nrestp); l++)
- {
- assert(restp);
- if (strcmp(restp[l].rname, rname) == 0)
- {
- break;
- }
- }
- if (l == nrestp)
+ auto found = std::find_if(restp.begin(), restp.end(), [rname](const auto& entry) {
+ return strcmp(entry.rname, rname) == 0;
+ });
+ if (found == restp.end())
{
- srenew(restp, nrestp + 1);
- restp[nrestp].rname = gmx_strdup(rname);
- restp[nrestp].bNeg = FALSE;
- restp[nrestp].gname = gmx_strdup(rname);
- nrestp++;
+ restp.emplace_back();
+ auto& last = restp.back();
+ last.rname = gmx_strdup(rname);
+ last.bNeg = false;
+ last.gname = gmx_strdup(rname);
}
}
}
- for (int i = 0; (i < nrestp); i++)
+ for (int i = 0; (i < gmx::ssize(restp)); i++)
{
std::vector<int> aid;
for (int j = 0; (j < atoms->nr); j++)
{
- rname = *atoms->resinfo[atoms->atom[j].resind].name;
+ const char* rname = *atoms->resinfo[atoms->atom[j].resind].name;
if ((strcmp(restp[i].rname, rname) == 0 && !restp[i].bNeg)
|| (strcmp(restp[i].rname, rname) != 0 && restp[i].bNeg))
{
fflush(stdout);
if (gmx_ask_yesno(bASK))
{
- natp = 0;
+ std::vector<const char*> attp;
for (size_t k = 0; (k < aid.size()); k++)
{
- aname = *atoms->atomname[aid[k]];
- int l;
- for (l = 0; (l < natp); l++)
- {
- if (strcmp(aname, attp[l]) == 0)
- {
- break;
- }
- }
- if (l == natp)
+ const char* aname = *atoms->atomname[aid[k]];
+ auto found = std::find_if(attp.begin(), attp.end(), [aname](const char* entry) {
+ return strcmp(aname, entry) == 0;
+ });
+ if (found == attp.end())
{
- srenew(attp, ++natp);
- attp[natp - 1] = aname;
+ attp.emplace_back(aname);
}
}
- if (natp > 1)
+ if (attp.size() > 1)
{
+ const int natp = attp.size();
for (int l = 0; (l < natp); l++)
{
std::vector<int> aaid;
for (size_t k = 0; (k < aid.size()); k++)
{
- aname = *atoms->atomname[aid[k]];
+ const char* aname = *atoms->atomname[aid[k]];
if (strcmp(aname, attp[l]) == 0)
{
aaid.push_back(aid[k]);
add_grp(gb, gn, aaid, attp[l]);
}
}
- sfree(attp);
- attp = nullptr;
}
}
sfree(restp[i].rname);
sfree(restp[i].gname);
}
- sfree(restp);
}
}
};
const int num_index_groups = asize(constructing_data);
- int n, j;
- int npres;
- gmx_bool match;
- char ndx_name[STRLEN], *atnm;
- int i;
+ char ndx_name[STRLEN];
if (bVerb)
{
std::vector<int> aid;
/* calculate the number of protein residues */
- npres = 0;
- for (i = 0; (i < atoms->nres); i++)
+ int npres = 0;
+ for (int i = 0; (i < atoms->nres); i++)
{
if (0 == gmx_strcasecmp(restype[i].c_str(), "Protein"))
{
}
}
/* find matching or complement atoms */
- for (i = 0; (i < num_index_groups); i++)
+ for (int i = 0; (i < num_index_groups); i++)
{
- for (n = 0; (n < atoms->nr); n++)
+ for (int n = 0; (n < atoms->nr); n++)
{
if (0 == gmx_strcasecmp(restype[atoms->atom[n].resind].c_str(), "Protein"))
{
- match = FALSE;
- for (j = 0; (j < constructing_data[i].num_defining_atomnames); j++)
+ bool match = false;
+ for (int j = 0; (j < constructing_data[i].num_defining_atomnames); j++)
{
/* skip digits at beginning of atomname, e.g. 1H */
- atnm = *atoms->atomname[n];
+ char* atnm = *atoms->atomname[n];
while (isdigit(atnm[0]))
{
atnm++;
{
if (0 == gmx_strcasecmp(constructing_data[i].defining_atomnames[j], atnm))
{
- match = TRUE;
+ match = true;
}
}
else
atnm,
strlen(constructing_data[i].defining_atomnames[j])))
{
- match = TRUE;
+ match = true;
}
}
}
if (bASK)
{
- for (i = 0; (i < num_index_groups); i++)
+ for (int i = 0; (i < num_index_groups); i++)
{
printf("Split %12s into %5d residues (y/n) ? ", constructing_data[i].group_name, npres);
if (gmx_ask_yesno(bASK))
{
- int resind;
aid.clear();
- for (n = 0; ((atoms->atom[n].resind < npres) && (n < atoms->nr));)
+ for (int n = 0; ((atoms->atom[n].resind < npres) && (n < atoms->nr));)
{
- resind = atoms->atom[n].resind;
+ int resind = atoms->atom[n].resind;
for (; ((atoms->atom[n].resind == resind) && (n < atoms->nr)); n++)
{
- match = FALSE;
- for (j = 0; (j < constructing_data[i].num_defining_atomnames); j++)
+ bool match = false;
+ for (int j = 0; (j < constructing_data[i].num_defining_atomnames); j++)
{
if (0
== gmx_strcasecmp(constructing_data[i].defining_atomnames[j],
*atoms->atomname[n]))
{
- match = TRUE;
+ match = true;
}
}
if (constructing_data[i].bTakeComplement != match)
/* copy the residuename to the tail of the groupname */
if (!aid.empty())
{
- t_resinfo* ri;
- ri = &atoms->resinfo[resind];
+ t_resinfo* ri = &atoms->resinfo[resind];
sprintf(ndx_name,
"%s_%s%d%c",
constructing_data[i].group_name,
void analyse(const t_atoms* atoms, t_blocka* gb, char*** gn, gmx_bool bASK, gmx_bool bVerb)
{
- char* resnm;
- int i;
- int iwater, iion;
- int nwater, nion;
-
if (bVerb)
{
printf("Analysing residue names:\n");
}
/* Create system group, every single atom */
std::vector<int> aid(atoms->nr);
- for (i = 0; i < atoms->nr; i++)
- {
- aid[i] = i;
- }
+ std::iota(aid.begin(), aid.end(), 0);
add_grp(gb, gn, aid, "System");
/* For every residue, get a pointer to the residue type name */
std::vector<std::string> previousTypename;
if (atoms->nres > 0)
{
- int i = 0;
-
- resnm = *atoms->resinfo[i].name;
+ const char* resnm = *atoms->resinfo[0].name;
restype.emplace_back(rt.typeOfNamedDatabaseResidue(resnm));
previousTypename.push_back(restype.back());
- for (i = 1; i < atoms->nres; i++)
+ for (int i = 1; i < atoms->nres; i++)
{
- resnm = *atoms->resinfo[i].name;
+ const char* resnm = *atoms->resinfo[i].name;
restype.emplace_back(rt.typeOfNamedDatabaseResidue(resnm));
/* Note that this does not lead to a N*N loop, but N*K, where
for (gmx::index k = 0; k < gmx::ssize(previousTypename); k++)
{
- aid = mk_aid(atoms, restype, previousTypename[k], TRUE);
+ std::vector<int> aid = mk_aid(atoms, restype, previousTypename[k], TRUE);
/* Check for special types to do fancy stuff with */
analyse_prot(restype, atoms, gb, gn, bASK, bVerb);
/* Create a Non-Protein group */
- aid = mk_aid(atoms, restype, "Protein", FALSE);
+ std::vector<int> aid = mk_aid(atoms, restype, "Protein", FALSE);
if ((!aid.empty()) && (gmx::ssize(aid) < atoms->nr))
{
add_grp(gb, gn, aid, "non-Protein");
/* Solvent, create a negated group too */
- aid = mk_aid(atoms, restype, "Water", FALSE);
+ std::vector<int> aid = mk_aid(atoms, restype, "Water", FALSE);
if ((!aid.empty()) && (gmx::ssize(aid) < atoms->nr))
{
add_grp(gb, gn, aid, "non-Water");
/* Create a merged water_and_ions group */
- iwater = -1;
- iion = -1;
- nwater = 0;
- nion = 0;
+ int iwater = -1;
+ int iion = -1;
+ int nwater = 0;
+ int nion = 0;
- for (i = 0; i < gb->nr; i++)
+ for (int i = 0; i < gb->nr; i++)
{
if (!gmx_strcasecmp((*gn)[i], "Water"))
{
srenew(gb->a, gb->nra + nwater + nion);
if (nwater > 0)
{
- for (i = gb->index[iwater]; i < gb->index[iwater + 1]; i++)
+ for (int i = gb->index[iwater]; i < gb->index[iwater + 1]; i++)
{
gb->a[gb->nra++] = gb->a[i];
}
}
if (nion > 0)
{
- for (i = gb->index[iion]; i < gb->index[iion + 1]; i++)
+ for (int i = gb->index[iion]; i < gb->index[iion + 1]; i++)
{
gb->a[gb->nra++] = gb->a[i];
}
void check_index(const char* gname, int n, int index[], const char* traj, int natoms)
{
- int i;
-
- for (i = 0; i < n; i++)
+ for (int i = 0; i < n; i++)
{
if (index[i] >= natoms)
{
t_blocka* init_index(const char* gfile, char*** grpname)
{
- FILE* in;
- t_blocka* b;
- int maxentries;
- int i, j;
- char line[STRLEN], *pt, str[STRLEN];
+ t_blocka* b = nullptr;
+ char line[STRLEN], str[STRLEN];
- in = gmx_ffopen(gfile, "r");
+ FILE* in = gmx_ffopen(gfile, "r");
snew(b, 1);
- b->nr = 0;
- b->index = nullptr;
- b->nra = 0;
- b->a = nullptr;
- *grpname = nullptr;
- maxentries = 0;
+ b->nr = 0;
+ b->index = nullptr;
+ b->nra = 0;
+ b->a = nullptr;
+ *grpname = nullptr;
+ int maxentries = 0;
while (get_a_line(in, line, STRLEN))
{
if (get_header(line, str))
{
gmx_fatal(FARGS, "The first header of your indexfile is invalid");
}
- pt = line;
+ char* pt = line;
while (sscanf(pt, "%s", str) == 1)
{
- i = b->index[b->nr];
+ int i = b->index[b->nr];
if (i >= maxentries)
{
maxentries += 1024;
}
gmx_ffclose(in);
- for (i = 0; (i < b->nr); i++)
+ for (int i = 0; (i < b->nr); i++)
{
assert(b->a != nullptr); // for clang analyzer
- for (j = b->index[i]; (j < b->index[i + 1]); j++)
+ for (int j = b->index[i]; (j < b->index[i + 1]); j++)
{
if (b->a[j] < 0)
{
static void minstring(char* str)
{
- int i;
-
- for (i = 0; (i < static_cast<int>(strlen(str))); i++)
+ for (int i = 0; (i < static_cast<int>(strlen(str))); i++)
{
if (str[i] == '-')
{
int find_group(const char* s, int ngrps, char** grpname)
{
- int aa, i, n;
- char string[STRLEN];
- gmx_bool bMultiple;
- bMultiple = FALSE;
- n = strlen(s);
- aa = -1;
+ char string[STRLEN];
+ bool bMultiple = false;
+ const int n = strlen(s);
+ int aa = -1;
/* first look for whole name match */
{
- for (i = 0; i < ngrps; i++)
+ for (int i = 0; i < ngrps; i++)
{
if (gmx_strcasecmp_min(s, grpname[i]) == 0)
{
if (aa != -1)
{
- bMultiple = TRUE;
+ bMultiple = true;
}
aa = i;
}
/* second look for first string match */
if (aa == -1)
{
- for (i = 0; i < ngrps; i++)
+ for (int i = 0; i < ngrps; i++)
{
if (gmx_strncasecmp_min(s, grpname[i], n) == 0)
{
key[STRLEN - 1] = '\0';
upstring(key);
minstring(key);
- for (i = 0; i < ngrps; i++)
+ for (int i = 0; i < ngrps; i++)
{
strncpy(string, grpname[i], STRLEN - 1);
upstring(string);
static int qgroup(int* a, int ngrps, char** grpname)
{
- char s[STRLEN];
- int aa;
- gmx_bool bInRange;
- char* end;
+ char s[STRLEN];
+ int aa = 0;
+ bool bInRange = false;
+ char* end = nullptr;
do
{
static void
rd_groups(t_blocka* grps, char** grpname, char* gnames[], int ngrps, int isize[], int* index[], int grpnr[])
{
- int i, j, gnr1;
-
if (grps->nr == 0)
{
gmx_fatal(FARGS, "Error: no groups in indexfile");
}
- for (i = 0; (i < grps->nr); i++)
+ for (int i = 0; (i < grps->nr); i++)
{
fprintf(stderr, "Group %5d (%15s) has %5d elements\n", i, grpname[i], grps->index[i + 1] - grps->index[i]);
}
- for (i = 0; (i < ngrps); i++)
+ for (int i = 0; (i < ngrps); i++)
{
+ int gnr1 = 0;
if (grps->nr > 1)
{
do
gnames[i] = gmx_strdup(grpname[gnr1]);
isize[i] = grps->index[gnr1 + 1] - grps->index[gnr1];
snew(index[i], isize[i]);
- for (j = 0; (j < isize[i]); j++)
+ for (int j = 0; (j < isize[i]); j++)
{
index[i][j] = grps->a[grps->index[gnr1] + j];
}
void rd_index(const char* statfile, int ngrps, int isize[], int* index[], char* grpnames[])
{
- char** gnames;
- t_blocka* grps;
- int* grpnr;
+ char** gnames = nullptr;
+ int* grpnr = nullptr;
snew(grpnr, ngrps);
if (!statfile)
{
gmx_fatal(FARGS, "No index file specified");
}
- grps = init_index(statfile, &gnames);
+ t_blocka* grps = init_index(statfile, &gnames);
rd_groups(grps, gnames, grpnames, ngrps, isize, index, grpnr);
for (int i = 0; i < grps->nr; i++)
{
void get_index(const t_atoms* atoms, const char* fnm, int ngrps, int isize[], int* index[], char* grpnames[])
{
- char*** gnames;
- t_blocka* grps = nullptr;
- int* grpnr;
+ char*** gnames = nullptr;
+ t_blocka* grps = nullptr;
+ int* grpnr = nullptr;
snew(grpnr, ngrps);
snew(gnames, 1);
t_cluster_ndx* cluster_index(FILE* fplog, const char* ndx)
{
- t_cluster_ndx* c;
- int i;
+ t_cluster_ndx* c = nullptr;
snew(c, 1);
c->clust = init_index(ndx, &c->grpname);
c->maxframe = -1;
- for (i = 0; (i < c->clust->nra); i++)
+ for (int i = 0; (i < c->clust->nra); i++)
{
c->maxframe = std::max(c->maxframe, c->clust->a[i]);
}
if (debug)
{
pr_blocka(debug, 0, "clust", c->clust, TRUE);
- for (i = 0; (i < c->clust->nra); i++)
+ for (int i = 0; (i < c->clust->nra); i++)
{
if ((c->clust->a[i] < 0) || (c->clust->a[i] > c->maxframe))
{
*
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
* Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2010,2014,2015,2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 2010,2014,2015,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.
int* make_invblock(const t_block* block, int nr)
{
- int i, j;
- int* invblock;
+ int* invblock = nullptr;
snew(invblock, nr + 1);
/* Mark unused numbers */
- for (i = 0; i <= nr; i++)
+ for (int i = 0; i <= nr; i++)
{
invblock[i] = -1;
}
- for (i = 0; (i < block->nr); i++)
+ for (int i = 0; (i < block->nr); i++)
{
- for (j = block->index[i]; (j < block->index[i + 1]); j++)
+ for (int j = block->index[i]; (j < block->index[i + 1]); j++)
{
if (invblock[j] == -1)
{
int* make_invblocka(const t_blocka* block, int nr)
{
- int i, j;
- int* invblock;
+ int* invblock = nullptr;
snew(invblock, nr + 1);
/* Mark unused numbers */
- for (i = 0; i <= nr; i++)
+ for (int i = 0; i <= nr; i++)
{
invblock[i] = -1;
}
- for (i = 0; (i < block->nr); i++)
+ for (int i = 0; (i < block->nr); i++)
{
- for (j = block->index[i]; (j < block->index[i + 1]); j++)
+ for (int j = block->index[i]; (j < block->index[i + 1]); j++)
{
if (invblock[block->a[j]] == -1)
{
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2016,2017,2018,2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 2016,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.
int molBlock0 = -1;
int molBlock1 = mtop->molblock.size();
- int globalAtomStart;
+ int globalAtomStart = 0;
while (TRUE)
{
globalAtomStart = mtop->moleculeBlockIndices[*moleculeBlock].globalAtomStart;
*/
static inline int mtopGetMoleculeIndex(const gmx_mtop_t* mtop, int globalAtomIndex, int* moleculeBlock)
{
- int localMoleculeIndex;
+ int localMoleculeIndex = 0;
mtopGetMolblockIndex(mtop, globalAtomIndex, moleculeBlock, &localMoleculeIndex, nullptr);
return mtop->moleculeBlockIndices[*moleculeBlock].moleculeIndexStart + localMoleculeIndex;
*/
static inline const t_atom& mtopGetAtomParameters(const gmx_mtop_t* mtop, int globalAtomIndex, int* moleculeBlock)
{
- int atomIndexInMolecule;
+ int atomIndexInMolecule = 0;
mtopGetMolblockIndex(mtop, globalAtomIndex, moleculeBlock, nullptr, &atomIndexInMolecule);
const gmx_moltype_t& moltype = mtop->moltype[mtop->molblock[*moleculeBlock].type];
return moltype.atoms.atom[atomIndexInMolecule];
const char** residueName,
int* globalResidueIndex)
{
- int moleculeIndex;
- int atomIndexInMolecule;
+ int moleculeIndex = 0;
+ int atomIndexInMolecule = 0;
mtopGetMolblockIndex(mtop, globalAtomIndex, moleculeBlock, &moleculeIndex, &atomIndexInMolecule);
const gmx_molblock_t& molb = mtop->molblock[*moleculeBlock];
*/
static inline const t_resinfo& mtopGetResidueInfo(const gmx_mtop_t* mtop, int globalAtomIndex, int* moleculeBlock)
{
- int atomIndexInMolecule;
+ int atomIndexInMolecule = 0;
mtopGetMolblockIndex(mtop, globalAtomIndex, moleculeBlock, nullptr, &atomIndexInMolecule);
const gmx_moltype_t& moltype = mtop->moltype[mtop->molblock[*moleculeBlock].type];
const int resind = moltype.atoms.atom[atomIndexInMolecule].resind;
*/
static inline const t_pdbinfo& mtopGetAtomPdbInfo(const gmx_mtop_t* mtop, int globalAtomIndex, int* moleculeBlock)
{
- int atomIndexInMolecule;
+ int atomIndexInMolecule = 0;
mtopGetMolblockIndex(mtop, globalAtomIndex, moleculeBlock, nullptr, &atomIndexInMolecule);
const gmx_moltype_t& moltype = mtop->moltype[mtop->molblock[*moleculeBlock].type];
GMX_ASSERT(moltype.atoms.havePdbInfo, "PDB information not present when requested");
*
* 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");
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
* Copyright (c) 2001-2004, The GROMACS development team.
* Copyright (c) 2013,2014,2015,2016,2017 by the GROMACS development team.
- * Copyright (c) 2018,2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 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.
*/
static char* trim_string(const char* s, char* out, int maxlen)
{
- int len, i;
+ int len = 0, i = 0;
if (strlen(s) > static_cast<size_t>(maxlen - 1))
{
int lookup_symtab(t_symtab* symtab, char** name)
{
- int base;
- t_symbuf* symbuf;
-
- base = 0;
- symbuf = symtab->symbuf;
+ int base = 0;
+ t_symbuf* symbuf = symtab->symbuf;
while (symbuf != nullptr)
{
const int index = name - symbuf->buf;
char** get_symtab_handle(t_symtab* symtab, int name)
{
- t_symbuf* symbuf;
-
- symbuf = symtab->symbuf;
+ t_symbuf* symbuf = symtab->symbuf;
while (symbuf != nullptr)
{
if (name < symbuf->bufsize)
//! Returns a new initialized entry into the symtab linked list.
static t_symbuf* new_symbuf()
{
- t_symbuf* symbuf;
+ t_symbuf* symbuf = nullptr;
snew(symbuf, 1);
symbuf->bufsize = c_maxBufSize;
*/
static char** enter_buf(t_symtab* symtab, char* name)
{
- int i;
- t_symbuf* symbuf;
- gmx_bool bCont;
+ bool bCont = false;
if (symtab->symbuf == nullptr)
{
symtab->symbuf = new_symbuf();
}
- symbuf = symtab->symbuf;
+ t_symbuf* symbuf = symtab->symbuf;
do
{
- for (i = 0; (i < symbuf->bufsize); i++)
+ for (int i = 0; (i < symbuf->bufsize); i++)
{
if (symbuf->buf[i] == nullptr)
{
// std::list<std::vector<std::string>>> for t_symtab.
t_symtab* duplicateSymtab(const t_symtab* symtab)
{
- t_symtab* copySymtab;
+ t_symtab* copySymtab = nullptr;
snew(copySymtab, 1);
open_symtab(copySymtab);
t_symbuf* symbuf = symtab->symbuf;
void done_symtab(t_symtab* symtab)
{
- int i;
- t_symbuf *symbuf, *freeptr;
-
close_symtab(symtab);
- symbuf = symtab->symbuf;
+ t_symbuf* symbuf = symtab->symbuf;
while (symbuf != nullptr)
{
- for (i = 0; (i < symbuf->bufsize) && (i < symtab->nr); i++)
+ int i = 0;
+ for (; (i < symbuf->bufsize) && (i < symtab->nr); i++)
{
sfree(symbuf->buf[i]);
}
symtab->nr -= i;
sfree(symbuf->buf);
- freeptr = symbuf;
- symbuf = symbuf->next;
+ t_symbuf* freeptr = symbuf;
+ symbuf = symbuf->next;
sfree(freeptr);
}
symtab->symbuf = nullptr;
void free_symtab(t_symtab* symtab)
{
- t_symbuf *symbuf, *freeptr;
-
close_symtab(symtab);
- symbuf = symtab->symbuf;
+ t_symbuf* symbuf = symtab->symbuf;
while (symbuf != nullptr)
{
symtab->nr -= std::min(symbuf->bufsize, symtab->nr);
- freeptr = symbuf;
- symbuf = symbuf->next;
+ t_symbuf* freeptr = symbuf;
+ symbuf = symbuf->next;
sfree(freeptr);
}
symtab->symbuf = nullptr;
void pr_symtab(FILE* fp, int indent, const char* title, t_symtab* symtab)
{
- int i, j, nr;
- t_symbuf* symbuf;
-
if (available(fp, symtab, indent, title))
{
- indent = pr_title_n(fp, indent, title, symtab->nr);
- i = 0;
- nr = symtab->nr;
- symbuf = symtab->symbuf;
+ indent = pr_title_n(fp, indent, title, symtab->nr);
+ int i = 0;
+ int nr = symtab->nr;
+ t_symbuf* symbuf = symtab->symbuf;
while (symbuf != nullptr)
{
- for (j = 0; (j < symbuf->bufsize) && (j < nr); j++)
+ int j = 0;
+ for (; (j < symbuf->bufsize) && (j < nr); j++)
{
pr_indent(fp, indent);
(void)fprintf(fp, "%s[%d]=\"%s\"\n", title, i++, symbuf->buf[j]);
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 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.
int pos = 0;
while (symbuf != nullptr)
{
- int i;
- for (i = 0; (i < symbuf->bufsize) && (i < nr); i++)
+ int i = 0;
+ for (; (i < symbuf->bufsize) && (i < nr); i++)
{
symtabDump.emplace_back(formatString("Symtab[%d]=\"%s\"", pos++, symbuf->buf[i]));
}
TEST_F(LegacySymtabTest, AddSingleEntry)
{
- auto fooSymbol = put_symtab(symtab(), "Foo");
+ auto* fooSymbol = put_symtab(symtab(), "Foo");
ASSERT_EQ(1, symtab()->nr);
compareSymtabLookupAndHandle(symtab(), fooSymbol);
EXPECT_STREQ("Foo", *fooSymbol);
TEST_F(LegacySymtabTest, AddTwoDistinctEntries)
{
- auto fooSymbol = put_symtab(symtab(), "Foo");
- auto barSymbol = put_symtab(symtab(), "Bar");
+ auto* fooSymbol = put_symtab(symtab(), "Foo");
+ auto* barSymbol = put_symtab(symtab(), "Bar");
ASSERT_EQ(2, symtab()->nr);
compareSymtabLookupAndHandle(symtab(), fooSymbol);
TEST_F(LegacySymtabTest, TryToAddDuplicates)
{
- auto fooSymbol = put_symtab(symtab(), "Foo");
- auto barSymbol = put_symtab(symtab(), "Bar");
+ auto* fooSymbol = put_symtab(symtab(), "Foo");
+ auto* barSymbol = put_symtab(symtab(), "Bar");
ASSERT_EQ(2, symtab()->nr);
compareSymtabLookupAndHandle(symtab(), fooSymbol);
EXPECT_STREQ("Bar", *barSymbol);
// Insert a duplicate element
- auto anotherFooSymbol = put_symtab(symtab(), "Foo");
+ auto* anotherFooSymbol = put_symtab(symtab(), "Foo");
ASSERT_EQ(2, symtab()->nr);
// Check for correct post-conditions
compareSymtabLookupAndHandle(symtab(), symbolsAdded[i]);
}
// Add something unrelated and check that indices still work afterward.
- auto foobarSymbol = put_symtab(symtab(), "foobar");
+ auto* foobarSymbol = put_symtab(symtab(), "foobar");
ASSERT_EQ(numStringsToAdd + 1, symtab()->nr);
for (int i = 0; i < numStringsToAdd; ++i)
{
ASSERT_EQ(halfOfStringsToAdd, symtab()->nr);
// We now try to mess around in the symtab.
- auto bazSymbol = put_symtab(symtab(), "baz");
+ auto* bazSymbol = put_symtab(symtab(), "baz");
ASSERT_EQ(halfOfStringsToAdd + 1, symtab()->nr);
compareSymtabLookupAndHandle(symtab(), bazSymbol);
gmx_bool bShowNumbers,
gmx_bool bShowParameters)
{
- int j;
-
indent = pr_title_n(fp, indent, title, n);
pr_indent(fp, indent);
fprintf(fp, "name=\"%s\"\n", *(molt->name));
pr_atoms(fp, indent, "atoms", &(molt->atoms), bShowNumbers);
pr_listoflists(fp, indent, "excls", &molt->excls, bShowNumbers);
- for (j = 0; (j < F_NRE); j++)
+ for (int j = 0; (j < F_NRE); j++)
{
pr_ilist(fp,
indent,
real relativeTolerance,
real absoluteTolerance)
{
- int i;
- gmx_bool bDiff;
-
- bDiff = FALSE;
- for (i = 0; i < MAXFORCEPARAM && !bDiff; i++)
+ bool bDiff = false;
+ for (int i = 0; i < MAXFORCEPARAM && !bDiff; i++)
{
bDiff = !equal_real(ip1.generic.buf[i], ip2.generic.buf[i], relativeTolerance, absoluteTolerance);
}
static void cmp_iparm_AB(FILE* fp, const char* s, t_functype ft, const t_iparams& ip1, real relativeTolerance, real absoluteTolerance)
{
- int nrfpA, nrfpB, p0, i;
- gmx_bool bDiff;
-
/* Normally the first parameter is perturbable */
- p0 = 0;
- nrfpA = interaction_function[ft].nrfpA;
- nrfpB = interaction_function[ft].nrfpB;
+ int p0 = 0;
+ int nrfpA = interaction_function[ft].nrfpA;
+ int nrfpB = interaction_function[ft].nrfpB;
if (ft == F_PDIHS)
{
nrfpB = 2;
p0 = 1;
nrfpB = 1;
}
- bDiff = FALSE;
- for (i = 0; i < nrfpB && !bDiff; i++)
+ bool bDiff = false;
+ for (int i = 0; i < nrfpB && !bDiff; i++)
{
bDiff = !equal_real(
ip1.generic.buf[p0 + i], ip1.generic.buf[nrfpA + i], relativeTolerance, absoluteTolerance);
{
for (size_t g = 0; g < cmap1->cmapdata.size(); g++)
{
- int i;
-
fprintf(fp, "comparing cmap %zu\n", g);
- for (i = 0; i < 4 * cmap1->grid_spacing * cmap1->grid_spacing; i++)
+ for (int i = 0; i < 4 * cmap1->grid_spacing * cmap1->grid_spacing; i++)
{
cmp_real(fp, "", i, cmap1->cmapdata[g].cmap[i], cmap2->cmapdata[g].cmap[i], relativeTolerance, absoluteTolerance);
}
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
* Copyright (c) 2001-2008, The GROMACS development team.
* Copyright (c) 2013,2014,2015,2017,2018 by the GROMACS development team.
- * Copyright (c) 2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 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.
static gmx_bool ip_pert(int ftype, const t_iparams* ip)
{
- gmx_bool bPert;
- int i;
-
if (NRFPB(ftype) == 0)
{
return FALSE;
}
+ bool bPert = false;
switch (ftype)
{
case F_BONDS:
break;
case F_RBDIHS:
bPert = FALSE;
- for (i = 0; i < NR_RBDIHS; i++)
+ for (int i = 0; i < NR_RBDIHS; i++)
{
if (ip->rbdihs.rbcA[i] != ip->rbdihs.rbcB[i])
{
case F_TABDIHS: bPert = (ip->tab.kA != ip->tab.kB); break;
case F_POSRES:
bPert = FALSE;
- for (i = 0; i < DIM; i++)
+ for (int i = 0; i < DIM; i++)
{
if (ip->posres.pos0A[i] != ip->posres.pos0B[i] || ip->posres.fcA[i] != ip->posres.fcB[i])
{
void gmx_sort_ilist_fe(InteractionDefinitions* idef, const real* qA, const real* qB)
{
- int ftype, nral, i, ic, ib, a;
- t_iatom* iabuf;
- int iabuf_nalloc;
-
if (qB == nullptr)
{
qB = qA;
bool havePerturbedInteractions = false;
- iabuf_nalloc = 0;
- iabuf = nullptr;
+ int iabuf_nalloc = 0;
+ t_iatom* iabuf = nullptr;
- for (ftype = 0; ftype < F_NRE; ftype++)
+ for (int ftype = 0; ftype < F_NRE; ftype++)
{
if (interaction_function[ftype].flags & IF_BOND)
{
InteractionList* ilist = &idef->il[ftype];
int* iatoms = ilist->iatoms.data();
- nral = NRAL(ftype);
- ic = 0;
- ib = 0;
- i = 0;
+ const int nral = NRAL(ftype);
+ int ic = 0;
+ int ib = 0;
+ int i = 0;
while (i < ilist->size())
{
/* Check if this interaction is perturbed */
iabuf_nalloc = over_alloc_large(ib + 1 + nral);
srenew(iabuf, iabuf_nalloc);
}
- for (a = 0; a < 1 + nral; a++)
+ for (int a = 0; a < 1 + nral; a++)
{
iabuf[ib++] = iatoms[i++];
}
else
{
/* Copy in place */
- for (a = 0; a < 1 + nral; a++)
+ for (int a = 0; a < 1 + nral; a++)
{
iatoms[ic++] = iatoms[i++];
}
idef->numNonperturbedInteractions[ftype] = ic;
/* Copy the buffer with perturbed interactions to the ilist */
- for (a = 0; a < ib; a++)
+ for (int a = 0; a < ib; a++)
{
iatoms[ic++] = iabuf[a];
}