Refactor t_params to InteractionTypeParameters
authorPaul Bauer <paul.bauer.q@gmail.com>
Wed, 20 Feb 2019 15:25:05 +0000 (16:25 +0100)
committerDavid van der Spoel <spoel@xray.bmc.uu.se>
Wed, 27 Feb 2019 19:26:31 +0000 (20:26 +0100)
Part of preprocessing clean up.

Refs #2833

Change-Id: I4514edde34c978c2756f1c17471e0adde0736896

29 files changed:
src/gromacs/gmxpreprocess/add_par.cpp
src/gromacs/gmxpreprocess/add_par.h
src/gromacs/gmxpreprocess/convparm.cpp
src/gromacs/gmxpreprocess/convparm.h
src/gromacs/gmxpreprocess/gen_ad.cpp
src/gromacs/gmxpreprocess/gen_ad.h
src/gromacs/gmxpreprocess/gen_vsite.cpp
src/gromacs/gmxpreprocess/gen_vsite.h
src/gromacs/gmxpreprocess/gpp_atomtype.cpp
src/gromacs/gmxpreprocess/gpp_atomtype.h
src/gromacs/gmxpreprocess/gpp_nextnb.cpp
src/gromacs/gmxpreprocess/gpp_nextnb.h
src/gromacs/gmxpreprocess/grompp.cpp
src/gromacs/gmxpreprocess/grompp_impl.h
src/gromacs/gmxpreprocess/nm2type.cpp
src/gromacs/gmxpreprocess/nm2type.h
src/gromacs/gmxpreprocess/pdb2top.cpp
src/gromacs/gmxpreprocess/pdb2top.h
src/gromacs/gmxpreprocess/topio.cpp
src/gromacs/gmxpreprocess/topio.h
src/gromacs/gmxpreprocess/toppush.cpp
src/gromacs/gmxpreprocess/toppush.h
src/gromacs/gmxpreprocess/topshake.cpp
src/gromacs/gmxpreprocess/topshake.h
src/gromacs/gmxpreprocess/toputil.cpp
src/gromacs/gmxpreprocess/toputil.h
src/gromacs/gmxpreprocess/vsite_parm.cpp
src/gromacs/gmxpreprocess/vsite_parm.h
src/gromacs/gmxpreprocess/x2top.cpp

index 81171461055e484e1fc5c5352daecd1aeb6246fa..a3b8283c65cbdf1ba2c466f1092d394b263142a7 100644 (file)
@@ -72,7 +72,7 @@ static void clear_force_param(int i0, real c[])
     }
 }
 
-void add_param(t_params *ps, int ai, int aj, const real *c, const char *s)
+void add_param(InteractionTypeParameters *ps, int ai, int aj, const real *c, const char *s)
 {
     int i;
 
@@ -99,7 +99,7 @@ void add_param(t_params *ps, int ai, int aj, const real *c, const char *s)
     ps->nr++;
 }
 
-void add_imp_param(t_params *ps, int ai, int aj, int ak, int al, real c0, real c1,
+void add_imp_param(InteractionTypeParameters *ps, int ai, int aj, int ak, int al, real c0, real c1,
                    const char *s)
 {
     pr_alloc(1, ps);
@@ -115,7 +115,7 @@ void add_imp_param(t_params *ps, int ai, int aj, int ak, int al, real c0, real c
     ps->nr++;
 }
 
-void add_dih_param(t_params *ps, int ai, int aj, int ak, int al, real c0, real c1,
+void add_dih_param(InteractionTypeParameters *ps, int ai, int aj, int ak, int al, real c0, real c1,
                    real c2, const char *s)
 {
     pr_alloc(1, ps);
@@ -132,7 +132,7 @@ void add_dih_param(t_params *ps, int ai, int aj, int ak, int al, real c0, real c
     ps->nr++;
 }
 
-void add_cmap_param(t_params *ps, int ai, int aj, int ak, int al, int am, const char *s)
+void add_cmap_param(InteractionTypeParameters *ps, int ai, int aj, int ak, int al, int am, const char *s)
 {
     pr_alloc(1, ps);
     ps->param[ps->nr].ai() = ai;
@@ -146,7 +146,7 @@ void add_cmap_param(t_params *ps, int ai, int aj, int ak, int al, int am, const
     ps->nr++;
 }
 
-void add_vsite2_atoms(t_params *ps, int ai, int aj, int ak)
+void add_vsite2_atoms(InteractionTypeParameters *ps, int ai, int aj, int ak)
 {
     pr_alloc(1, ps);
     ps->param[ps->nr].ai() = ai;
@@ -158,7 +158,7 @@ void add_vsite2_atoms(t_params *ps, int ai, int aj, int ak)
     ps->nr++;
 }
 
-void add_vsite2_param(t_params *ps, int ai, int aj, int ak, real c0)
+void add_vsite2_param(InteractionTypeParameters *ps, int ai, int aj, int ak, real c0)
 {
     pr_alloc(1, ps);
     ps->param[ps->nr].ai() = ai;
@@ -171,7 +171,7 @@ void add_vsite2_param(t_params *ps, int ai, int aj, int ak, real c0)
     ps->nr++;
 }
 
-void add_vsite3_param(t_params *ps, int ai, int aj, int ak, int al,
+void add_vsite3_param(InteractionTypeParameters *ps, int ai, int aj, int ak, int al,
                       real c0, real c1)
 {
     pr_alloc(1, ps);
@@ -187,7 +187,7 @@ void add_vsite3_param(t_params *ps, int ai, int aj, int ak, int al,
     ps->nr++;
 }
 
-void add_vsite3_atoms(t_params *ps, int ai, int aj, int ak, int al, bool bSwapParity)
+void add_vsite3_atoms(InteractionTypeParameters *ps, int ai, int aj, int ak, int al, bool bSwapParity)
 {
     pr_alloc(1, ps);
     ps->param[ps->nr].ai() = ai;
@@ -204,7 +204,7 @@ void add_vsite3_atoms(t_params *ps, int ai, int aj, int ak, int al, bool bSwapPa
     ps->nr++;
 }
 
-void add_vsite4_atoms(t_params *ps, int ai, int aj, int ak, int al, int am)
+void add_vsite4_atoms(InteractionTypeParameters *ps, int ai, int aj, int ak, int al, int am)
 {
     pr_alloc(1, ps);
     ps->param[ps->nr].ai() = ai;
index 999e122238e7c991fda67dbb297255aeec6f3725..de35358e4b371416ec9fd1404af3b2c4787aa20a 100644 (file)
 
 #include "gromacs/utility/real.h"
 
-struct t_params;
+struct InteractionTypeParameters;
 struct PreprocessResidue;
 
-void add_param(t_params *ps, int ai, int aj, const real *c, const char *s);
+void add_param(InteractionTypeParameters *ps, int ai, int aj, const real *c, const char *s);
 
-void add_imp_param(t_params *ps, int ai, int aj, int ak, int al,
+void add_imp_param(InteractionTypeParameters *ps, int ai, int aj, int ak, int al,
                    real c0, real c1, const char *s);
 
-void add_dih_param(t_params *ps, int ai, int aj, int ak, int al,
+void add_dih_param(InteractionTypeParameters *ps, int ai, int aj, int ak, int al,
                    real c0, real c1, real c2, const char *s);
 
-void add_cmap_param(t_params *ps, int ai, int aj, int ak, int al, int am,
+void add_cmap_param(InteractionTypeParameters *ps, int ai, int aj, int ak, int al, int am,
                     const char *s);
 
-void add_vsite2_atoms(t_params *ps, int ai, int aj, int ak);
+void add_vsite2_atoms(InteractionTypeParameters *ps, int ai, int aj, int ak);
 
-void add_vsite3_atoms(t_params *ps, int ai, int aj, int ak, int al,
+void add_vsite3_atoms(InteractionTypeParameters *ps, int ai, int aj, int ak, int al,
                       bool bSwapParity);
 
-void add_vsite2_param(t_params *ps, int ai, int aj, int ak, real c0);
+void add_vsite2_param(InteractionTypeParameters *ps, int ai, int aj, int ak, real c0);
 
-void add_vsite3_param(t_params *ps, int ai, int aj, int ak, int al,
+void add_vsite3_param(InteractionTypeParameters *ps, int ai, int aj, int ak, int al,
                       real c0, real c1);
 
-void add_vsite4_atoms(t_params *ps, int ai, int aj, int ak, int al,
+void add_vsite4_atoms(InteractionTypeParameters *ps, int ai, int aj, int ak, int al,
                       int am);
 
 int search_jtype(const PreprocessResidue &localPpResidue, const char *name, bool bFirstRes);
index 1ea48876c9bf4f220b20a5bcedb0de92d7c1a070..63f7aca8f805b1f51079a6ff128b21726efb883e 100644 (file)
@@ -497,7 +497,7 @@ static void append_interaction(InteractionList *ilist,
     }
 }
 
-static void enter_function(const t_params *p, t_functype ftype, int comb, real reppow,
+static void enter_function(const InteractionTypeParameters *p, t_functype ftype, int comb, real reppow,
                            gmx_ffparams_t *ffparams, InteractionList *il,
                            bool bNB, bool bAppend)
 {
@@ -519,11 +519,11 @@ static void enter_function(const t_params *p, t_functype ftype, int comb, real r
     }
 }
 
-void convert_params(int atnr, t_params nbtypes[],
-                    gmx::ArrayRef<const MoleculeInformation> mi,
-                    const MoleculeInformation *intermolecular_interactions,
-                    int comb, double reppow, real fudgeQQ,
-                    gmx_mtop_t *mtop)
+void convertInteractionTypeParameters(int atnr, gmx::ArrayRef<const InteractionTypeParameters> nbtypes,
+                                      gmx::ArrayRef<const MoleculeInformation> mi,
+                                      const MoleculeInformation *intermolecular_interactions,
+                                      int comb, double reppow, real fudgeQQ,
+                                      gmx_mtop_t *mtop)
 {
     int             i;
     unsigned long   flags;
@@ -548,7 +548,7 @@ void convert_params(int atnr, t_params nbtypes[],
         {
             molt->ilist[i].iatoms.clear();
 
-            const t_params *plist = mi[mt].plist;
+            gmx::ArrayRef<const InteractionTypeParameters> plist = mi[mt].plist;
 
             flags = interaction_function[i].flags;
             if ((i != F_LJ) && (i != F_BHAM) && ((flags & IF_BOND) ||
@@ -572,7 +572,7 @@ void convert_params(int atnr, t_params nbtypes[],
         {
             (*mtop->intermolecular_ilist)[i].iatoms.clear();
 
-            const t_params *plist = intermolecular_interactions->plist;
+            gmx::ArrayRef<const InteractionTypeParameters> plist = intermolecular_interactions->plist;
 
             if (plist[i].nr > 0)
             {
index 2b61d6fcfd152844a0196df5679f36c0b4992c53..bcc82b83c532471c400a39810995cb62dd59a741 100644 (file)
 
 struct gmx_mtop_t;
 struct MoleculeInformation;
-struct t_params;
+struct InteractionTypeParameters;
 
-void convert_params(int atnr, t_params nbtypes[],
-                    gmx::ArrayRef<const MoleculeInformation> mi,
-                    const MoleculeInformation *intermolecular_interactions,
-                    int comb, double reppow, real fudgeQQ,
-                    gmx_mtop_t *mtop);
+void convertInteractionTypeParameters(int atnr, gmx::ArrayRef<const InteractionTypeParameters> nbtypes,
+                                      gmx::ArrayRef<const MoleculeInformation> mi,
+                                      const MoleculeInformation *intermolecular_interactions,
+                                      int comb, double reppow, real fudgeQQ,
+                                      gmx_mtop_t *mtop);
 
 #endif
index 365b2e577cc427ab566460014b531fe670f9d3c1..9cb2eb7ffa76832c22b7da9bdf052329c7a58f18 100644 (file)
@@ -216,12 +216,11 @@ static void rm2par(t_param p[], int *np, peq eq)
     sfree(index);
 }
 
-static void cppar(t_param p[], int np, t_params plist[], int ftype)
+static void cppar(t_param p[], int np, gmx::ArrayRef<InteractionTypeParameters> plist, int ftype)
 {
-    int       i, j, nral, nrfp;
-    t_params *ps;
+    int                        i, j, nral, nrfp;
 
-    ps   = &plist[ftype];
+    InteractionTypeParameters *ps   = &plist[ftype];
     nral = NRAL(ftype);
     nrfp = NRFP(ftype);
 
@@ -726,7 +725,7 @@ void generate_excls(t_nextnb *nnb, int nrexcl, t_excls excls[])
 
 /* Generate pairs, angles and dihedrals from .rtp settings */
 void gen_pad(t_nextnb *nnb, t_atoms *atoms, gmx::ArrayRef<const PreprocessResidue> rtpFFDB,
-             t_params plist[], t_excls excls[], gmx::ArrayRef<MoleculePatchDatabase> globalPatches,
+             gmx::ArrayRef<InteractionTypeParameters> plist, t_excls excls[], gmx::ArrayRef<MoleculePatchDatabase> globalPatches,
              bool bAllowMissing)
 {
     t_param    *ang, *dih, *pai, *improper;
index d27f6725f33f3eb762b55f47e686c41ff48794f7..f4b2456141c9459b4939bdbf097f079abc576578 100644 (file)
@@ -44,14 +44,18 @@ struct t_atoms;
 struct t_excls;
 struct MoleculePatchDatabase;
 struct t_nextnb;
-struct t_params;
+struct InteractionTypeParameters;
 struct PreprocessResidue;
 
 void generate_excls(t_nextnb *nnb, int nrexcl, t_excls excls[]);
 void clean_excls(t_nextnb *nnb, int nrexcl, t_excls excls[]);
 
-void gen_pad(t_nextnb *nnb, t_atoms *atoms, gmx::ArrayRef<const PreprocessResidue> rtpFFDB,
-             t_params plist[], t_excls excls[], gmx::ArrayRef<MoleculePatchDatabase> globalPatches,
-             bool bAllowMissing);
+void gen_pad(t_nextnb                                       *nnb,
+             t_atoms                                        *atoms,
+             gmx::ArrayRef<const PreprocessResidue>          rtpFFDB,
+             gmx::ArrayRef<InteractionTypeParameters>        plist,
+             t_excls                                         excls[],
+             gmx::ArrayRef<MoleculePatchDatabase>            globalPatches,
+             bool                                            bAllowMissing);
 
 #endif
index 9d9fd1b1e2004f0d752490be254f3e84ac2f4425..c5ce5f54db14263f2ea13908c4a947feb70dc24b 100644 (file)
@@ -469,15 +469,15 @@ static real get_ddb_angle(gmx::ArrayRef<const VirtualSiteTopology> vsitetop,
 }
 
 
-static void count_bonds(int atom, t_params *psb, char ***atomname,
+static void count_bonds(int atom, InteractionTypeParameters *psb, char ***atomname,
                         int *nrbonds, int *nrHatoms, int Hatoms[], int *Heavy,
                         int *nrheavies, int heavies[])
 {
-    int i, heavy, other, nrb, nrH, nrhv;
+    int heavy, other, nrb, nrH, nrhv;
 
     /* find heavy atom bound to this hydrogen */
     heavy = NOTSET;
-    for (i = 0; (i < psb->nr) && (heavy == NOTSET); i++)
+    for (int i = 0; (i < psb->nr) && (heavy == NOTSET); i++)
     {
         if (psb->param[i].ai() == atom)
         {
@@ -497,7 +497,7 @@ static void count_bonds(int atom, t_params *psb, char ***atomname,
     nrb   = 0;
     nrH   = 0;
     nrhv  = 0;
-    for (i = 0; i < psb->nr; i++)
+    for (int i = 0; i < psb->nr; i++)
     {
         if (psb->param[i].ai() == heavy)
         {
@@ -606,7 +606,7 @@ static real get_amass(int atom, t_atoms *at, gmx::ArrayRef<const PreprocessResid
     return mass;
 }
 
-static void my_add_param(t_params *plist, int ai, int aj, real b)
+static void my_add_param(InteractionTypeParameters *plist, int ai, int aj, real b)
 {
     static real c[MAXFORCEPARAM] =
     { NOTSET, NOTSET, NOTSET, NOTSET, NOTSET, NOTSET };
@@ -615,16 +615,15 @@ static void my_add_param(t_params *plist, int ai, int aj, real b)
     add_param(plist, ai, aj, c, nullptr);
 }
 
-static void add_vsites(t_params plist[], int vsite_type[],
+static void add_vsites(gmx::ArrayRef<InteractionTypeParameters> plist, int vsite_type[],
                        int Heavy, int nrHatoms, int Hatoms[],
                        int nrheavies, int heavies[])
 {
-    int      i, j, ftype, other, moreheavy;
-    bool     bSwapParity;
+    int      other, moreheavy;
 
-    for (i = 0; i < nrHatoms; i++)
+    for (int i = 0; i < nrHatoms; i++)
     {
-        ftype = vsite_type[Hatoms[i]];
+        int ftype = vsite_type[Hatoms[i]];
         /* Errors in setting the vsite_type should really be caugth earlier,
          * because here it's not possible to print any useful error message.
          * But it's still better to print a message than to segfault.
@@ -633,7 +632,7 @@ static void add_vsites(t_params plist[], int vsite_type[],
         {
             gmx_incons("Undetected error in setting up virtual sites");
         }
-        bSwapParity           = (ftype < 0);
+        bool bSwapParity           = (ftype < 0);
         vsite_type[Hatoms[i]] = ftype = abs(ftype);
         if (ftype == F_BONDS)
         {
@@ -670,7 +669,7 @@ static void add_vsites(t_params plist[], int vsite_type[],
                     {
                         /* find more heavy atoms */
                         other = moreheavy = NOTSET;
-                        for (j = 0; (j < plist[F_BONDS].nr) && (moreheavy == NOTSET); j++)
+                        for (int j = 0; (j < plist[F_BONDS].nr) && (moreheavy == NOTSET); j++)
                         {
                             if (plist[F_BONDS].param[j].ai() == heavies[0])
                             {
@@ -722,7 +721,7 @@ static void add_vsites(t_params plist[], int vsite_type[],
 /* get cos(alpha) when a, b and c are given: */
 #define acosrule(a, b, c) ( (gmx::square(b)+gmx::square(c)-gmx::square(a))/(2*(b)*(c)) )
 
-static int gen_vsites_6ring(t_atoms *at, int *vsite_type[], t_params plist[],
+static int gen_vsites_6ring(t_atoms *at, int *vsite_type[], gmx::ArrayRef<InteractionTypeParameters> plist,
                             int nrfound, int *ats, real bond_cc, real bond_ch,
                             real xcom, bool bDoZ)
 {
@@ -813,7 +812,7 @@ static int gen_vsites_6ring(t_atoms *at, int *vsite_type[], t_params plist[],
     return nvsite;
 }
 
-static int gen_vsites_phe(t_atoms *at, int *vsite_type[], t_params plist[],
+static int gen_vsites_phe(t_atoms *at, int *vsite_type[], gmx::ArrayRef<InteractionTypeParameters> plist,
                           int nrfound, int *ats, gmx::ArrayRef<const VirtualSiteTopology> vsitetop)
 {
     real bond_cc, bond_ch;
@@ -878,7 +877,8 @@ static int gen_vsites_trp(gpp_atomtype *atype,
                           int *o2n[], int *newvsite_type[], int *newcgnr[],
                           t_symtab *symtab, int *nadd,
                           gmx::ArrayRef<const gmx::RVec> x, int *cgnr[],
-                          t_atoms *at, int *vsite_type[], t_params plist[],
+                          t_atoms *at, int *vsite_type[],
+                          gmx::ArrayRef<InteractionTypeParameters> plist,
                           int nrfound, int *ats, int add_shift,
                           gmx::ArrayRef<const VirtualSiteTopology> vsitetop)
 {
@@ -1151,7 +1151,8 @@ static int gen_vsites_tyr(gpp_atomtype *atype,
                           int *o2n[], int *newvsite_type[], int *newcgnr[],
                           t_symtab *symtab, int *nadd,
                           gmx::ArrayRef<const gmx::RVec> x, int *cgnr[],
-                          t_atoms *at, int *vsite_type[], t_params plist[],
+                          t_atoms *at, int *vsite_type[],
+                          gmx::ArrayRef<InteractionTypeParameters> plist,
                           int nrfound, int *ats, int add_shift,
                           gmx::ArrayRef<const VirtualSiteTopology> vsitetop)
 {
@@ -1295,7 +1296,8 @@ static int gen_vsites_tyr(gpp_atomtype *atype,
     return nvsite;
 }
 
-static int gen_vsites_his(t_atoms *at, int *vsite_type[], t_params plist[],
+static int gen_vsites_his(t_atoms *at, int *vsite_type[],
+                          gmx::ArrayRef<InteractionTypeParameters> plist,
                           int nrfound, int *ats, gmx::ArrayRef<const VirtualSiteTopology> vsitetop)
 {
     int  nvsite, i;
@@ -1550,27 +1552,27 @@ static char atomnamesuffix[] = "1234";
 void do_vsites(gmx::ArrayRef<const PreprocessResidue> rtpFFDB, gpp_atomtype *atype,
                t_atoms *at, t_symtab *symtab,
                std::vector<gmx::RVec> *x,
-               t_params plist[], int *vsite_type[], int *cgnr[],
+               gmx::ArrayRef<InteractionTypeParameters> plist, int *vsite_type[], int *cgnr[],
                real mHmult, bool bVsiteAromatics,
                const char *ffdir)
 {
 #define MAXATOMSPERRESIDUE 16
-    int               i, j, k, m, i0, ni0, whatres, resind, add_shift, ftype, nvsite, nadd;
-    int               ai, aj, ak, al;
-    int               nrfound = 0, needed, nrbonds, nrHatoms, Heavy, nrheavies, tpM, tpHeavy;
-    int               Hatoms[4], heavies[4];
-    bool              bWARNING, bAddVsiteParam, bFirstWater;
-    matrix            tmpmat;
-    real              mHtot, mtot, fact, fact2;
-    rvec              rpar, rperp, temp;
-    char              tpname[32], nexttpname[32];
-    int              *o2n, *newvsite_type, *newcgnr, ats[MAXATOMSPERRESIDUE];
-    t_atom           *newatom;
-    t_params         *params;
-    char           ***newatomname;
-    char             *resnm = nullptr;
-    int               cmplength;
-    bool              isN, planarN, bFound;
+    int                        k, m, i0, ni0, whatres, resind, add_shift, nvsite, nadd;
+    int                        ai, aj, ak, al;
+    int                        nrfound = 0, needed, nrbonds, nrHatoms, Heavy, nrheavies, tpM, tpHeavy;
+    int                        Hatoms[4], heavies[4];
+    bool                       bWARNING, bAddVsiteParam, bFirstWater;
+    matrix                     tmpmat;
+    real                       mHtot, mtot, fact, fact2;
+    rvec                       rpar, rperp, temp;
+    char                       tpname[32], nexttpname[32];
+    int                       *o2n, *newvsite_type, *newcgnr, ats[MAXATOMSPERRESIDUE];
+    t_atom                    *newatom;
+    InteractionTypeParameters *params;
+    char                    ***newatomname;
+    char                      *resnm = nullptr;
+    int                        cmplength;
+    bool                       isN, planarN, bFound;
 
     /* if bVsiteAromatics=TRUE do_vsites will specifically convert atoms in
        PHE, TRP, TYR and HIS to a construction of virtual sites */
@@ -1648,7 +1650,7 @@ void do_vsites(gmx::ArrayRef<const PreprocessResidue> rtpFFDB, gpp_atomtype *aty
     snew(newcgnr, at->nr);
     /* make index array to tell where the atoms go to when masses are inserted */
     snew(o2n, at->nr);
-    for (i = 0; i < at->nr; i++)
+    for (int i = 0; i < at->nr; i++)
     {
         o2n[i] = i;
     }
@@ -1660,7 +1662,7 @@ void do_vsites(gmx::ArrayRef<const PreprocessResidue> rtpFFDB, gpp_atomtype *aty
     /* generate vsite constructions */
     /* loop over all atoms */
     resind = -1;
-    for (i = 0; (i < at->nr); i++)
+    for (int i = 0; (i < at->nr); i++)
     {
         if (at->atom[i].resind != resind)
         {
@@ -1682,7 +1684,7 @@ void do_vsites(gmx::ArrayRef<const PreprocessResidue> rtpFFDB, gpp_atomtype *aty
             bResProcessed[resind] = TRUE;
             /* find out if this residue needs converting */
             whatres = NOTSET;
-            for (j = 0; j < resNR && whatres == NOTSET; j++)
+            for (int j = 0; j < resNR && whatres == NOTSET; j++)
             {
 
                 cmplength = bPartial[j] ? strlen(resnm)-1 : strlen(resnm);
@@ -1860,7 +1862,7 @@ void do_vsites(gmx::ArrayRef<const PreprocessResidue> rtpFFDB, gpp_atomtype *aty
                 if ((nrHatoms == 2) && ((*at->atomname[Heavy])[0] == 'N'))
                 {
                     isN = TRUE;
-                    j   = nitrogen_is_planar(vsiteconflist, tpname);
+                    int j   = nitrogen_is_planar(vsiteconflist, tpname);
                     if (j < 0)
                     {
                         gmx_fatal(FARGS, "No vsite database NH2 entry for type %s\n", tpname);
@@ -1888,7 +1890,7 @@ void do_vsites(gmx::ArrayRef<const PreprocessResidue> rtpFFDB, gpp_atomtype *aty
                     bAddVsiteParam = FALSE; /* we'll do this ourselves! */
                     /* -NH2 (umbrella), -NH3+ or -CH3 */
                     (*vsite_type)[Heavy]       = F_VSITE3;
-                    for (j = 0; j < nrHatoms; j++)
+                    for (int j = 0; j < nrHatoms; j++)
                     {
                         (*vsite_type)[Hatoms[j]] = Hat_vsite_type[j];
                     }
@@ -1923,7 +1925,7 @@ void do_vsites(gmx::ArrayRef<const PreprocessResidue> rtpFFDB, gpp_atomtype *aty
                         fprintf(stderr, "Inserting %d dummy masses at %d\n", NMASS, o2n[i0]+1);
                     }
                     nadd += NMASS;
-                    for (j = i0; j < at->nr; j++)
+                    for (int j = i0; j < at->nr; j++)
                     {
                         o2n[j] = j+nadd;
                     }
@@ -1934,7 +1936,7 @@ void do_vsites(gmx::ArrayRef<const PreprocessResidue> rtpFFDB, gpp_atomtype *aty
                     srenew(newvsite_type, at->nr+nadd);
                     srenew(newcgnr, at->nr+nadd);
 
-                    for (j = 0; j < NMASS; j++)
+                    for (int j = 0; j < NMASS; j++)
                     {
                         newatomname[at->nr+nadd-1-j] = nullptr;
                     }
@@ -1942,7 +1944,7 @@ void do_vsites(gmx::ArrayRef<const PreprocessResidue> rtpFFDB, gpp_atomtype *aty
                     /* calculate starting position for the masses */
                     mHtot = 0;
                     /* get atom masses, and set Heavy and Hatoms mass to zero */
-                    for (j = 0; j < nrHatoms; j++)
+                    for (int j = 0; j < nrHatoms; j++)
                     {
                         mHtot                += get_amass(Hatoms[j], at, rtpFFDB, &rt);
                         at->atom[Hatoms[j]].m = at->atom[Hatoms[j]].mB = 0;
@@ -1959,7 +1961,7 @@ void do_vsites(gmx::ArrayRef<const PreprocessResidue> rtpFFDB, gpp_atomtype *aty
                      * rpar  = Heavy -> Hcom
                      * rperp = Hcom  -> H1   */
                     clear_rvec(rpar);
-                    for (j = 0; j < nrHatoms; j++)
+                    for (int j = 0; j < nrHatoms; j++)
                     {
                         rvec_inc(rpar, (*x)[Hatoms[j]]);
                     }
@@ -1969,7 +1971,7 @@ void do_vsites(gmx::ArrayRef<const PreprocessResidue> rtpFFDB, gpp_atomtype *aty
                     rvec_dec(rperp, rpar);           /* rperp = H1 - Heavy - rpar */
                     /* calc mass positions */
                     svmul(fact2, rpar, temp);
-                    for (j = 0; (j < NMASS); j++) /* xM = xN + fact2 * rpar +/- fact * rperp */
+                    for (int j = 0; (j < NMASS); j++) /* xM = xN + fact2 * rpar +/- fact * rperp */
                     {
                         rvec_add((*x)[Heavy], temp, newx[ni0+j]);
                     }
@@ -1977,10 +1979,11 @@ void do_vsites(gmx::ArrayRef<const PreprocessResidue> rtpFFDB, gpp_atomtype *aty
                     rvec_inc(newx[ni0  ], temp);
                     rvec_dec(newx[ni0+1], temp);
                     /* set atom parameters for the masses */
-                    for (j = 0; (j < NMASS); j++)
+                    for (int j = 0; (j < NMASS); j++)
                     {
                         /* make name: "M??#" or "M?#" (? is atomname, # is number) */
                         name[0] = 'M';
+                        int k;
                         for (k = 0; (*at->atomname[Heavy])[k] && ( k < NMASS ); k++)
                         {
                             name[k+1] = (*at->atomname[Heavy])[k];
@@ -2009,7 +2012,7 @@ void do_vsites(gmx::ArrayRef<const PreprocessResidue> rtpFFDB, gpp_atomtype *aty
                     add_vsite3_atoms  (&plist[(*vsite_type)[Heavy]],
                                        Heavy,     heavies[0], add_shift+ni0, add_shift+ni0+1,
                                        FALSE);
-                    for (j = 0; j < nrHatoms; j++)
+                    for (int j = 0; j < nrHatoms; j++)
                     {
                         add_vsite3_atoms(&plist[(*vsite_type)[Hatoms[j]]],
                                          Hatoms[j], heavies[0], add_shift+ni0, add_shift+ni0+1,
@@ -2038,7 +2041,7 @@ void do_vsites(gmx::ArrayRef<const PreprocessResidue> rtpFFDB, gpp_atomtype *aty
                 add_vsites(plist, (*vsite_type), Heavy, nrHatoms, Hatoms,
                            nrheavies, heavies);
                 /* transfer mass of virtual site to Heavy atom */
-                for (j = 0; j < nrHatoms; j++)
+                for (int j = 0; j < nrHatoms; j++)
                 {
                     if (is_vsite((*vsite_type)[Hatoms[j]]))
                     {
@@ -2061,7 +2064,7 @@ void do_vsites(gmx::ArrayRef<const PreprocessResidue> rtpFFDB, gpp_atomtype *aty
     if (debug)
     {
         fprintf(debug, "Before inserting new atoms:\n");
-        for (i = 0; i < at->nr; i++)
+        for (int i = 0; i < at->nr; i++)
         {
             fprintf(debug, "%4d %4d %4s %4d %4s %6d %-10s\n", i+1, o2n[i]+1,
                     at->atomname[i] ? *(at->atomname[i]) : "(NULL)",
@@ -2073,7 +2076,7 @@ void do_vsites(gmx::ArrayRef<const PreprocessResidue> rtpFFDB, gpp_atomtype *aty
                     "NOTSET" : interaction_function[(*vsite_type)[i]].name);
         }
         fprintf(debug, "new atoms to be inserted:\n");
-        for (i = 0; i < at->nr+nadd; i++)
+        for (int i = 0; i < at->nr+nadd; i++)
         {
             if (newatomname[i])
             {
@@ -2087,7 +2090,7 @@ void do_vsites(gmx::ArrayRef<const PreprocessResidue> rtpFFDB, gpp_atomtype *aty
     }
 
     /* add all original atoms to the new arrays, using o2n index array */
-    for (i = 0; i < at->nr; i++)
+    for (int i = 0; i < at->nr; i++)
     {
         newatomname  [o2n[i]] = at->atomname [i];
         newatom      [o2n[i]] = at->atom     [i];
@@ -2116,7 +2119,7 @@ void do_vsites(gmx::ArrayRef<const PreprocessResidue> rtpFFDB, gpp_atomtype *aty
     if (debug)
     {
         fprintf(debug, "After inserting new atoms:\n");
-        for (i = 0; i < at->nr; i++)
+        for (int i = 0; i < at->nr; i++)
         {
             fprintf(debug, "%4d %4s %4d %4s %6d %-10s\n", i+1,
                     at->atomname[i] ? *(at->atomname[i]) : "(NULL)",
@@ -2130,17 +2133,17 @@ void do_vsites(gmx::ArrayRef<const PreprocessResidue> rtpFFDB, gpp_atomtype *aty
     }
 
     /* now renumber all the interactions because of the added atoms */
-    for (ftype = 0; ftype < F_NRE; ftype++)
+    for (int ftype = 0; ftype < F_NRE; ftype++)
     {
-        params = &(plist[ftype]);
+        InteractionTypeParameters *params = &(plist[ftype]);
         if (debug)
         {
             fprintf(debug, "Renumbering %d %s\n", params->nr,
                     interaction_function[ftype].longname);
         }
-        for (i = 0; i < params->nr; i++)
+        for (int i = 0; i < params->nr; i++)
         {
-            for (j = 0; j < NRAL(ftype); j++)
+            for (int j = 0; j < NRAL(ftype); j++)
             {
                 if (params->param[i].a[j] >= add_shift)
                 {
@@ -2169,11 +2172,11 @@ void do_vsites(gmx::ArrayRef<const PreprocessResidue> rtpFFDB, gpp_atomtype *aty
     }
     /* now check if atoms in the added constraints are in increasing order */
     params = &(plist[F_CONSTRNC]);
-    for (i = 0; i < params->nr; i++)
+    for (int i = 0; i < params->nr; i++)
     {
         if (params->param[i].ai() > params->param[i].aj())
         {
-            j                     = params->param[i].aj();
+            int j                     = params->param[i].aj();
             params->param[i].aj() = params->param[i].ai();
             params->param[i].ai() = j;
         }
@@ -2188,20 +2191,18 @@ void do_vsites(gmx::ArrayRef<const PreprocessResidue> rtpFFDB, gpp_atomtype *aty
     fprintf(stderr, "Added %d new constraints\n", plist[F_CONSTRNC].nr);
 }
 
-void do_h_mass(t_params *psb, int vsite_type[], t_atoms *at, real mHmult,
+void do_h_mass(InteractionTypeParameters *psb, int vsite_type[], t_atoms *at, real mHmult,
                bool bDeuterate)
 {
-    int i, j, a;
-
     /* loop over all atoms */
-    for (i = 0; i < at->nr; i++)
+    for (int i = 0; i < at->nr; i++)
     {
         /* adjust masses if i is hydrogen and not a virtual site */
         if (!is_vsite(vsite_type[i]) && is_hydrogen(*(at->atomname[i])) )
         {
             /* find bonded heavy atom */
-            a = NOTSET;
-            for (j = 0; (j < psb->nr) && (a == NOTSET); j++)
+            int a = NOTSET;
+            for (int j = 0; (j < psb->nr) && (a == NOTSET); j++)
             {
                 /* if other atom is not a virtual site, it is the one we want */
                 if ( (psb->param[j].ai() == i) &&
index 66246efa8c6a73d780403de28567b1dce8649040..a5d89a1f11d264f2de5fb51cf5d6a8d48422772e 100644 (file)
@@ -44,7 +44,7 @@
 
 struct gpp_atomtype;
 struct t_atoms;
-struct t_params;
+struct InteractionTypeParameters;
 struct PreprocessResidue;
 struct t_symtab;
 
@@ -52,11 +52,11 @@ struct t_symtab;
 
 void do_vsites(gmx::ArrayRef<const PreprocessResidue> rtpFFDB, gpp_atomtype *atype,
                t_atoms *at, t_symtab *symtab, std::vector<gmx::RVec> *x,
-               t_params plist[], int *dummy_type[], int *cgnr[],
+               gmx::ArrayRef<InteractionTypeParameters> plist, int *dummy_type[], int *cgnr[],
                real mHmult, bool bVSiteAromatics,
                const char *ffdir);
 
-void do_h_mass(t_params *psb, int vsite_type[], t_atoms *at, real mHmult,
+void do_h_mass(InteractionTypeParameters *psb, int vsite_type[], t_atoms *at, real mHmult,
                bool bDeuterate);
 
 #endif
index 3fe7003ccd3575b4749e33ca0235d7ec6d706c18..c43d6bf0f9cd476b26bfc2679a571f60c8ca2b4e 100644 (file)
@@ -326,7 +326,7 @@ static int search_atomtypes(gpp_atomtype *ga, int *n, int typelist[],
     return i;
 }
 
-void renum_atype(t_params plist[], gmx_mtop_t *mtop,
+void renum_atype(gmx::ArrayRef<InteractionTypeParameters> plist, gmx_mtop_t *mtop,
                  int *wall_atomtype,
                  gpp_atomtype *ga, bool bVerbose)
 {
index 38bc3c08245abc2eb068d16570d418f965f00209..075f7c895a37756ac78deb51824891903a1caeda 100644 (file)
@@ -40,6 +40,7 @@
 
 #include <cstdio>
 
+#include "gromacs/utility/arrayref.h"
 #include "gromacs/utility/real.h"
 
 struct gmx_mtop_t;
@@ -47,7 +48,7 @@ struct gpp_atomtype;
 struct t_atom;
 struct t_atomtypes;
 struct t_param;
-struct t_params;
+struct InteractionTypeParameters;
 struct t_symtab;
 
 int get_atomtype_type(const char *str, gpp_atomtype *at);
@@ -94,7 +95,7 @@ int add_atomtype(gpp_atomtype *at, t_symtab *tab,
 void print_at (FILE * out, gpp_atomtype *at);
 /* Print an atomtype record to a text file */
 
-void renum_atype(t_params plist[], gmx_mtop_t *mtop,
+void renum_atype(gmx::ArrayRef<InteractionTypeParameters> plist, gmx_mtop_t *mtop,
                  int *wall_atomtype,
                  gpp_atomtype *at, bool bVerbose);
 
index 74c2fa32261712dfdd061869a382a4fa22375a0f..d793d94958d3053a9c89f658358228e1836ac9ff 100644 (file)
@@ -340,15 +340,12 @@ static void do_gen(int       nrbonds, /* total number of bonds in s       */
 
 }
 
-static void add_b(t_params *bonds, int *nrf, sortable *s)
+static void add_b(InteractionTypeParameters *bonds, int *nrf, sortable *s)
 {
-    int i;
-    int ai, aj;
-
-    for (i = 0; (i < bonds->nr); i++)
+    for (int i = 0; (i < bonds->nr); i++)
     {
-        ai = bonds->param[i].ai();
-        aj = bonds->param[i].aj();
+        int ai = bonds->param[i].ai();
+        int aj = bonds->param[i].aj();
         if ((ai < 0) || (aj < 0))
         {
             gmx_fatal(FARGS, "Impossible atom numbers in bond %d: ai=%d, aj=%d",
@@ -362,13 +359,13 @@ static void add_b(t_params *bonds, int *nrf, sortable *s)
     }
 }
 
-void gen_nnb(t_nextnb *nnb, t_params plist[])
+void gen_nnb(t_nextnb *nnb, gmx::ArrayRef<InteractionTypeParameters> plist)
 {
     sortable *s;
-    int       i, nrbonds, nrf;
+    int       nrbonds, nrf;
 
     nrbonds = 0;
-    for (i = 0; (i < F_NRE); i++)
+    for (int i = 0; (i < F_NRE); i++)
     {
         if (IS_CHEMBOND(i))
         {
@@ -380,7 +377,7 @@ void gen_nnb(t_nextnb *nnb, t_params plist[])
     snew(s, nrbonds);
 
     nrf = 0;
-    for (i = 0; (i < F_NRE); i++)
+    for (int i = 0; (i < F_NRE); i++)
     {
         if (IS_CHEMBOND(i))
         {
@@ -441,7 +438,9 @@ sort_and_purge_nnb(t_nextnb *nnb)
 }
 
 
-void generate_excl (int nrexcl, int nratoms, t_params plist[], t_nextnb *nnb, t_blocka *excl)
+void generate_excl (int nrexcl,
+                    int nratoms,
+                    gmx::ArrayRef<InteractionTypeParameters> plist, t_nextnb *nnb, t_blocka *excl)
 {
     if (nrexcl < 0)
     {
index 569c079e8e96b4b58d4c150c1505e404a2c14099..1e6f8a420aeb37621679b0692a1d8f7bc6916480 100644 (file)
 #ifndef GMX_GMXPREPROCESS_GPP_NEXTNB_H
 #define GMX_GMXPREPROCESS_GPP_NEXTNB_H
 
+#include "gromacs/utility/arrayref.h"
+
 struct t_blocka;
-struct t_params;
+struct InteractionTypeParameters;
 
 struct t_nextnb
 {
@@ -66,7 +68,7 @@ void print_nnb(t_nextnb *nnb, char *s);
 #define print_nnb(nnb, s)
 #endif
 
-void gen_nnb(t_nextnb *nnb, t_params plist[]);
+void gen_nnb(t_nextnb *nnb, gmx::ArrayRef<InteractionTypeParameters> plist);
 /* Generate a t_nextnb structure from bond information.
  * With the structure you can either generate exclusions
  * or generate angles and dihedrals. The structure must be
@@ -74,7 +76,7 @@ void gen_nnb(t_nextnb *nnb, t_params plist[]);
  */
 
 void generate_excl (int nrexcl, int nratoms,
-                    t_params plist[], t_nextnb *nnb, t_blocka *excl);
+                    gmx::ArrayRef<InteractionTypeParameters> plist, t_nextnb *nnb, t_blocka *excl);
 /* Generate an exclusion block from bonds and constraints in
  * plist.
  */
index c7d7ffa6eb9df677e8a8db13c116d07e12192c51..f669c50b44b051faa0b9b159aa7a0e66dac17ba4 100644 (file)
@@ -509,7 +509,7 @@ new_status(const char *topfile, const char *topppfile, const char *confin,
            gpp_atomtype *atype, gmx_mtop_t *sys,
            std::vector<MoleculeInformation> *mi,
            std::unique_ptr<MoleculeInformation> *intermolecular_interactions,
-           t_params plist[],
+           gmx::ArrayRef<InteractionTypeParameters> plist,
            int *comb, double *reppow, real *fudgeQQ,
            gmx_bool bMorse,
            warninp *wi)
@@ -870,8 +870,8 @@ static void read_posres(gmx_mtop_t *mtop,
     for (gmx_molblock_t &molb : mtop->molblock)
     {
         nat_molb = molb.nmol*mtop->moltype[molb.type].atoms.nr;
-        const t_params *pr   = &(molinfo[molb.type].plist[F_POSRES]);
-        const t_params *prfb = &(molinfo[molb.type].plist[F_FBPOSRES]);
+        const InteractionTypeParameters *pr   = &(molinfo[molb.type].plist[F_POSRES]);
+        const InteractionTypeParameters *prfb = &(molinfo[molb.type].plist[F_FBPOSRES]);
         if (pr->nr > 0 || prfb->nr > 0)
         {
             atom = mtop->moltype[molb.type].atoms.atom;
@@ -1111,10 +1111,10 @@ interpolate1d( double           xmin,
 
 
 static void
-setup_cmap (int                    grid_spacing,
-            int                    nc,
-            const real *           grid,
-            gmx_cmap_t       *     cmap_grid)
+setup_cmap (int                       grid_spacing,
+            int                       nc,
+            gmx::ArrayRef<const real> grid,
+            gmx_cmap_t          *     cmap_grid)
 {
     int                 i, j, k, ii, jj, kk, idx;
     int                 offset;
@@ -1213,7 +1213,7 @@ static int count_constraints(const gmx_mtop_t                        *mtop,
     for (const gmx_molblock_t &molb : mtop->molblock)
     {
         count_mol = 0;
-        const t_params *plist = mi[molb.type].plist;
+        gmx::ArrayRef<const InteractionTypeParameters> plist = mi[molb.type].plist;
 
         for (i = 0; i < F_NRE; i++)
         {
@@ -1694,7 +1694,6 @@ int gmx_grompp(int argc, char *argv[])
     std::unique_ptr<MoleculeInformation> intermolecular_interactions;
     gpp_atomtype                        *atype;
     int                                  nvsite, comb;
-    t_params                            *plist;
     real                                 fudgeQQ;
     double                               reppow;
     const char                          *mdparin;
@@ -1799,7 +1798,7 @@ int gmx_grompp(int argc, char *argv[])
         warning_error(wi, warn_buf);
     }
 
-    snew(plist, F_NRE);
+    std::array<InteractionTypeParameters, F_NRE> plist;
     init_plist(plist);
     gmx_mtop_t sys;
     atype = init_atomtype();
@@ -1955,10 +1954,10 @@ int gmx_grompp(int argc, char *argv[])
     }
 
     /* If we are using CMAP, setup the pre-interpolation grid */
-    if (plist[F_CMAP].ncmap > 0)
+    if (plist[F_CMAP].ncmap() > 0)
     {
-        init_cmap_grid(&sys.ffparams.cmap_grid, plist[F_CMAP].nc, plist[F_CMAP].grid_spacing);
-        setup_cmap(plist[F_CMAP].grid_spacing, plist[F_CMAP].nc, plist[F_CMAP].cmap, &sys.ffparams.cmap_grid);
+        init_cmap_grid(&sys.ffparams.cmap_grid, plist[F_CMAP].cmapAngles, plist[F_CMAP].cmakeGridSpacing);
+        setup_cmap(plist[F_CMAP].cmakeGridSpacing, plist[F_CMAP].cmapAngles, plist[F_CMAP].cmap, &sys.ffparams.cmap_grid);
     }
 
     set_wall_atomtype(atype, opts, ir, wi);
@@ -1987,12 +1986,12 @@ int gmx_grompp(int argc, char *argv[])
     }
 
     ntype = get_atomtype_ntypes(atype);
-    convert_params(ntype, plist, mi, intermolecular_interactions.get(),
-                   comb, reppow, fudgeQQ, &sys);
+    convertInteractionTypeParameters(ntype, plist, mi, intermolecular_interactions.get(),
+                                     comb, reppow, fudgeQQ, &sys);
 
     if (debug)
     {
-        pr_symtab(debug, 0, "After convert_params", &sys.symtab);
+        pr_symtab(debug, 0, "After converInteractionTypeParameters", &sys.symtab);
     }
 
     /* set ptype to VSite for virtual sites */
@@ -2324,7 +2323,6 @@ int gmx_grompp(int argc, char *argv[])
     sfree(opts->include);
     sfree(opts);
     done_plist(plist);
-    sfree(plist);
     for (auto &mol : mi)
     {
         // Some of the contents of molinfo have been stolen, so
index 8c6489a15ff1221e3137e2a4d34497fcce57625c..e2b3c55fe641823e20e3cce7f5bf33dd912db3d1 100644 (file)
 
 struct t_param
 {
-    int        a[MAXATOMLIST];   /* The atom list (eg. bonds: particle */
-    /* i = a[0] (ai), j = a[1] (aj))   */
-    real       c[MAXFORCEPARAM]; /* Force parameters (eg. b0 = c[0])   */
-    char       s[MAXSLEN];       /* A string (instead of parameters),    *
-                                  * read from the .rtp file in pdb2gmx   */
-    const int &ai() const { return a[0]; }
-    int       &ai() { return a[0]; }
-    const int &aj() const { return a[1]; }
-    int       &aj() { return a[1]; }
-    const int &ak() const { return a[2]; }
-    int       &ak() { return a[2]; }
-    const int &al() const { return a[3]; }
-    int       &al() { return a[3]; }
-    const int &am() const { return a[4]; }
-    int       &am() { return a[4]; }
-
-    real      &c0() { return c[0]; }
-    real      &c1() { return c[1]; }
-    real      &c2() { return c[2]; }
+    int         a[MAXATOMLIST];   /* The atom list (eg. bonds: particle        */
+                                  /* i = a[0] (ai), j = a[1] (aj))     */
+    real        c[MAXFORCEPARAM]; /* Force parameters (eg. b0 = c[0])  */
+    char        s[MAXSLEN];       /* A string (instead of parameters),    *
+                                   * read from the .rtp file in pdb2gmx   */
+    const int  &ai() const { return a[0]; }
+    int        &ai() { return a[0]; }
+    const int  &aj() const { return a[1]; }
+    int        &aj() { return a[1]; }
+    const int  &ak() const { return a[2]; }
+    int        &ak() { return a[2]; }
+    const int  &al() const { return a[3]; }
+    int        &al() { return a[3]; }
+    const int  &am() const { return a[4]; }
+    int        &am() { return a[4]; }
+
+    const real &c0() const { return c[0]; }
+    real       &c0() { return c[0]; }
+    const real &c1() const { return c[1]; }
+    real       &c1() { return c[1]; }
+    const real &c2() const { return c[2]; }
+    real       &c2() { return c[2]; }
 };
 
-struct t_params
+/*! \libinternal \brief
+ * The parameters for a set of interactions of a given
+ * (unspecified) type found in the enumeration in ifunc.h.
+ *
+ * This is used for containing the data obtained from the
+ * lists of interactions of a given type in a [moleculetype]
+ * topology file definition.
+ *
+ * \todo Remove manual memory management.
+ */
+struct InteractionTypeParameters
 {                       // NOLINT (clang-analyzer-optin.performance.Padding)
-    int          nr;    /* The number of bonds in this record   */
-    int          maxnr; /* The amount of elements in the array  */
-    t_param     *param; /* Array of parameters (dim: nr or nr*nr) */
-
-    /* CMAP tmp data, there are probably better places for this */
-    int         grid_spacing; /* Cmap grid spacing */
-    int         nc;           /* Number of cmap angles */
-
-    real       *cmap;         /* Temporary storage of the raw cmap grid data */
-    int         ncmap;        /* Number of allocated elements in cmap grid*/
-
-    int        *cmap_types;   /* Store the five atomtypes followed by a number that identifies the type */
-    int         nct;          /* Number of allocated elements in cmap_types */
+    //! Number of parameters.
+    int                  nr = 0;
+    //! Maximum number of parameters.
+    int                  maxnr = 0;
+    //! The parameters of the interactions
+    t_param             *param;
+    //! CMAP grid spacing.
+    int                  cmakeGridSpacing = -1;
+    //! Number of cmap angles.
+    int                  cmapAngles = -1;
+    //! CMAP grid data.
+    std::vector<real>    cmap;
+    //! The five atomtypes followed by a number that identifies the type.
+    std::vector<int>     cmapAtomTypes;
+
+    //! Elements in cmap grid data.
+    int ncmap() const { return cmap.size(); }
+    //! Number of elements in cmapAtomTypes.
+    int nct() const { return cmapAtomTypes.size(); }
 };
 
 struct t_excls
@@ -101,23 +120,23 @@ struct t_excls
 struct MoleculeInformation
 {
     //! Name of the molecule.
-    char            **name = nullptr;
+    char                                       **name = nullptr;
     //!Number of exclusions per atom.
-    int               nrexcl = 0;
+    int                                          nrexcl = 0;
     //! Have exclusions been generated?.
-    bool              excl_set = false;
+    bool                                         excl_set = false;
     //! Has the mol been processed.
-    bool              bProcessed = false;
+    bool                                         bProcessed = false;
     //! Atoms in the moelcule.
-    t_atoms           atoms;
+    t_atoms                                      atoms;
     //! Charge groups in the molecule
-    t_block           cgs;
+    t_block                                      cgs;
     //! Molecules separated in datastructure.
-    t_block           mols;
+    t_block                                      mols;
     //! Exclusions in the molecule.
-    t_blocka          excls;
+    t_blocka                                     excls;
     //! Parameters in old style.
-    t_params          plist[F_NRE];
+    std::array<InteractionTypeParameters, F_NRE> plist;
 
     /*! \brief
      * Initializer.
index 3926d6137abc65f9f74031c22a563dfcc517be2b..748e435b02328aab690fd77794e51d1126fd9876 100644 (file)
@@ -192,7 +192,7 @@ static int match_str(const char *atom, const char *template_string)
 }
 
 int nm2type(int nnm, t_nm2type nm2t[], t_symtab *tab, t_atoms *atoms,
-            gpp_atomtype *atype, int *nbonds, t_params *bonds)
+            gpp_atomtype *atype, int *nbonds, InteractionTypeParameters *bonds)
 {
     int      cur = 0;
 #define prev (1-cur)
index d9973d57eede4253c2739ca0ad4349f5cae35fae..5d6fa3d0b4d2c733a797915a6ecf1c8783a77c90 100644 (file)
@@ -41,7 +41,7 @@
 
 struct gpp_atomtype;
 struct t_atoms;
-struct t_params;
+struct InteractionTypeParameters;
 struct t_symtab;
 
 struct t_nm2type
@@ -62,7 +62,7 @@ void dump_nm2type(FILE *fp, int nnm, t_nm2type nm2t[]);
 /* Dump the database for debugging. Can be reread by the program */
 
 int nm2type(int nnm, t_nm2type nm2t[], t_symtab *tab, t_atoms *atoms,
-            gpp_atomtype *atype, int *nbonds, t_params *bond);
+            gpp_atomtype *atype, int *nbonds, InteractionTypeParameters *bond);
 /* Try to determine the atomtype (force field dependent) for the atoms
  * with help of the bond list
  */
index aebbbe31508a1ce3e30a6e06a601b381b132ad56..ed6a9c7d4db9468c94d9b4552b1ac9f95d60bd6d 100644 (file)
@@ -672,7 +672,7 @@ void print_top_mols(FILE *out,
 
 void write_top(FILE *out, const char *pr, const char *molname,
                t_atoms *at, bool bRTPresname,
-               int bts[], t_params plist[], t_excls excls[],
+               int bts[], gmx::ArrayRef<const InteractionTypeParameters> plist, t_excls excls[],
                gpp_atomtype *atype, int *cgnr, int nrexcl)
 /* NOTE: nrexcl is not the size of *excl! */
 {
@@ -711,7 +711,7 @@ void write_top(FILE *out, const char *pr, const char *molname,
 
 
 
-static void do_ssbonds(t_params *ps, t_atoms *atoms,
+static void do_ssbonds(InteractionTypeParameters *ps, t_atoms *atoms,
                        gmx::ArrayRef<const DisulfideBond> ssbonds, bool bAllowMissing)
 {
     for (const auto &bond : ssbonds)
@@ -731,7 +731,7 @@ static void do_ssbonds(t_params *ps, t_atoms *atoms,
     }
 }
 
-static void at2bonds(t_params *psb, gmx::ArrayRef<MoleculePatchDatabase> globalPatches,
+static void at2bonds(InteractionTypeParameters *psb, gmx::ArrayRef<MoleculePatchDatabase> globalPatches,
                      t_atoms *atoms,
                      gmx::ArrayRef<const gmx::RVec> x,
                      real long_bond_dist, real short_bond_dist)
@@ -835,7 +835,7 @@ static int pcompar(const void *a, const void *b)
     }
 }
 
-static void clean_bonds(t_params *ps)
+static void clean_bonds(InteractionTypeParameters *ps)
 {
     int     i, j;
     int     a;
@@ -879,7 +879,7 @@ static void clean_bonds(t_params *ps)
     }
 }
 
-void print_sums(t_atoms *atoms, bool bSystem)
+void print_sums(const t_atoms *atoms, bool bSystem)
 {
     double      m, qtot;
     int         i;
@@ -1348,7 +1348,7 @@ void match_atomnames_with_rtp(gmx::ArrayRef<PreprocessResidue>     usedPpResidue
 }
 
 #define NUM_CMAP_ATOMS 5
-static void gen_cmap(t_params *psb, gmx::ArrayRef<const PreprocessResidue> usedPpResidues, t_atoms *atoms)
+static void gen_cmap(InteractionTypeParameters *psb, gmx::ArrayRef<const PreprocessResidue> usedPpResidues, t_atoms *atoms)
 {
     int         residx;
     const char *ptr;
@@ -1478,13 +1478,13 @@ void pdb2top(FILE *top_file, const char *posre_fn, const char *molname,
              bool bDeuterate, bool bChargeGroups, bool bCmap,
              bool bRenumRes, bool bRTPresname)
 {
-    t_params          plist[F_NRE];
-    t_excls          *excls;
-    t_nextnb          nnb;
-    int              *cgnr;
-    int              *vsite_type;
-    int               i, nmissat;
-    int               bts[ebtsNR];
+    std::array<InteractionTypeParameters, F_NRE> plist;
+    t_excls                                     *excls;
+    t_nextnb                                     nnb;
+    int                                         *cgnr;
+    int                                         *vsite_type;
+    int                                          i, nmissat;
+    int                                          bts[ebtsNR];
 
     init_plist(plist);
     ResidueType rt;
index 99991788624d9fed8b532511541f2726e142b44c..b9c625c3a4eba2e0fcb25e87f6b00e2eab8f2a47 100644 (file)
@@ -50,7 +50,7 @@ struct t_atoms;
 struct t_excls;
 struct MoleculePatchDatabase;
 struct t_mols;
-struct t_params;
+struct InteractionTypeParameters;
 struct t_resinfo;
 struct PreprocessResidue;
 struct DisulfideBond;
@@ -113,7 +113,7 @@ void print_top_mols(FILE *out,
 
 void write_top(FILE *out, const char *pr, const char *molname,
                t_atoms *at, bool bRTPresname,
-               int bts[], t_params plist[], t_excls excls[],
+               int bts[], gmx::ArrayRef<const InteractionTypeParameters> plist, t_excls excls[],
                gpp_atomtype *atype, int *cgnr, int nrexcl);
 /* NOTE: nrexcl is not the size of *excl! */
 
@@ -134,6 +134,6 @@ void pdb2top(FILE *top_file, const char *posre_fn, const char *molname,
              bool bRenumRes, bool bRTPresname);
 /* Create a topology ! */
 
-void print_sums(t_atoms *atoms, bool bSystem);
+void print_sums(const t_atoms *atoms, bool bSystem);
 
 #endif
index 94903e99acdc6ff51ccaefbc3ec7712a3430fc41..ae0f82e37d2707818afeedc29c28c54629dd92eb 100644 (file)
@@ -85,7 +85,7 @@
 #define OPENDIR     '[' /* starting sign for directive */
 #define CLOSEDIR    ']' /* ending sign for directive   */
 
-static void gen_pairs(t_params *nbs, t_params *pairs, real fudge, int comb)
+static void gen_pairs(InteractionTypeParameters *nbs, InteractionTypeParameters *pairs, real fudge, int comb)
 {
     int     i, j, ntp, nrfp, nrfpA, nrfpB, nnn;
     real    scaling;
@@ -381,7 +381,7 @@ static char **read_topol(const char *infile, const char *outfile,
                          int         *nrmols,
                          std::vector<MoleculeInformation> *molinfo,
                          std::unique_ptr<MoleculeInformation> *intermolecular_interactions,
-                         t_params    plist[],
+                         gmx::ArrayRef<InteractionTypeParameters> plist,
                          int         *combination_rule,
                          double      *reppow,
                          t_gromppopts *opts,
@@ -453,8 +453,8 @@ static char **read_topol(const char *infile, const char *outfile,
     *reppow  = 12.0;      /* Default value for repulsion power     */
 
     /* Init the number of CMAP torsion angles  and grid spacing */
-    plist[F_CMAP].grid_spacing = 0;
-    plist[F_CMAP].nc           = 0;
+    plist[F_CMAP].cmakeGridSpacing = 0;
+    plist[F_CMAP].cmapAngles       = 0;
 
     bWarn_copy_A_B = bFEP;
 
@@ -737,10 +737,12 @@ static char **read_topol(const char *infile, const char *outfile,
                             break;
 
                         case Directive::d_pairs:
+                            GMX_RELEASE_ASSERT(mi0, "Need to have a valid MoleculeInformation object to work on");
                             push_bond(d, plist, mi0->plist, &(mi0->atoms), atype, pline, FALSE,
                                       bGenPairs, *fudgeQQ, bZero, &bWarn_copy_A_B, wi);
                             break;
                         case Directive::d_pairs_nb:
+                            GMX_RELEASE_ASSERT(mi0, "Need to have a valid MoleculeInformation object to work on");
                             push_bond(d, plist, mi0->plist, &(mi0->atoms), atype, pline, FALSE,
                                       FALSE, 1.0, bZero, &bWarn_copy_A_B, wi);
                             break;
@@ -762,14 +764,17 @@ static char **read_topol(const char *infile, const char *outfile,
                         case Directive::d_polarization:
                         case Directive::d_water_polarization:
                         case Directive::d_thole_polarization:
+                            GMX_RELEASE_ASSERT(mi0, "Need to have a valid MoleculeInformation object to work on");
                             push_bond(d, plist, mi0->plist, &(mi0->atoms), atype, pline, TRUE,
                                       bGenPairs, *fudgeQQ, bZero, &bWarn_copy_A_B, wi);
                             break;
                         case Directive::d_cmap:
+                            GMX_RELEASE_ASSERT(mi0, "Need to have a valid MoleculeInformation object to work on");
                             push_cmap(d, plist, mi0->plist, &(mi0->atoms), atype, pline, wi);
                             break;
 
                         case Directive::d_vsitesn:
+                            GMX_RELEASE_ASSERT(mi0, "Need to have a valid MoleculeInformation object to work on");
                             push_vsitesn(d, mi0->plist, &(mi0->atoms), pline, wi);
                             break;
                         case Directive::d_exclusions:
@@ -933,24 +938,24 @@ static char **read_topol(const char *infile, const char *outfile,
     return title;
 }
 
-char **do_top(bool                                  bVerbose,
-              const char                           *topfile,
-              const char                           *topppfile,
-              t_gromppopts                         *opts,
-              bool                                  bZero,
-              t_symtab                             *symtab,
-              t_params                              plist[],
-              int                                  *combination_rule,
-              double                               *repulsion_power,
-              real                                 *fudgeQQ,
-              gpp_atomtype                         *atype,
-              int                                  *nrmols,
-              std::vector<MoleculeInformation>     *molinfo,
-              std::unique_ptr<MoleculeInformation> *intermolecular_interactions,
-              const t_inputrec                     *ir,
-              std::vector<gmx_molblock_t>          *molblock,
-              bool                                 *ffParametrizedWithHBondConstraints,
-              warninp                              *wi)
+char **do_top(bool                                           bVerbose,
+              const char                                    *topfile,
+              const char                                    *topppfile,
+              t_gromppopts                                  *opts,
+              bool                                           bZero,
+              t_symtab                                      *symtab,
+              gmx::ArrayRef<InteractionTypeParameters>       plist,
+              int                                           *combination_rule,
+              double                                        *repulsion_power,
+              real                                          *fudgeQQ,
+              gpp_atomtype                                  *atype,
+              int                                           *nrmols,
+              std::vector<MoleculeInformation>              *molinfo,
+              std::unique_ptr<MoleculeInformation>          *intermolecular_interactions,
+              const t_inputrec                              *ir,
+              std::vector<gmx_molblock_t>                   *molblock,
+              bool                                          *ffParametrizedWithHBondConstraints,
+              warninp                                       *wi)
 {
     /* Tmpfile might contain a long path */
     const char *tmpfile;
index c71d5b7a38e9187d5770b89d7e6252a680dfb590..746aafe3a282b820e0e0cb4029d1756a66bb581e 100644 (file)
@@ -41,6 +41,7 @@
 #include <memory>
 #include <vector>
 
+#include "gromacs/utility/arrayref.h"
 #include "gromacs/utility/real.h"
 
 struct gmx_molblock_t;
@@ -49,7 +50,7 @@ struct gpp_atomtype;
 struct t_gromppopts;
 struct t_inputrec;
 struct MoleculeInformation;
-struct t_params;
+struct InteractionTypeParameters;
 struct t_symtab;
 struct warninp;
 enum struct GmxQmmmMode;
@@ -58,24 +59,24 @@ typedef warninp *warninp_t;
 double check_mol(const gmx_mtop_t *mtop, warninp_t wi);
 /* Check mass and charge */
 
-char **do_top(bool                                               bVerbose,
-              const char                                        *topfile,
-              const char                                        *topppfile,
-              t_gromppopts                                      *opts,
-              bool                                               bZero,
-              t_symtab                                          *symtab,
-              t_params                                           plist[],
-              int                                               *combination_rule,
-              double                                            *repulsion_power,
-              real                                              *fudgeQQ,
-              gpp_atomtype                                      *atype,
-              int                                               *nrmols,
-              std::vector<MoleculeInformation>                  *molinfo,
-              std::unique_ptr<MoleculeInformation>              *intermolecular_interactions,
-              const t_inputrec                                  *ir,
-              std::vector<gmx_molblock_t>                       *molblock,
-              bool                                              *ffParametrizedWithHBondConstraints,
-              warninp_t                                          wi);
+char **do_top(bool                                                        bVerbose,
+              const char                                                 *topfile,
+              const char                                                 *topppfile,
+              t_gromppopts                                               *opts,
+              bool                                                        bZero,
+              t_symtab                                                   *symtab,
+              gmx::ArrayRef<InteractionTypeParameters>                    plist,
+              int                                                        *combination_rule,
+              double                                                     *repulsion_power,
+              real                                                       *fudgeQQ,
+              gpp_atomtype                                               *atype,
+              int                                                        *nrmols,
+              std::vector<MoleculeInformation>                           *molinfo,
+              std::unique_ptr<MoleculeInformation>                       *intermolecular_interactions,
+              const t_inputrec                                           *ir,
+              std::vector<gmx_molblock_t>                                *molblock,
+              bool                                                       *ffParametrizedWithHBondConstraints,
+              warninp_t                                                   wi);
 
 /* This routine expects sys->molt[m].ilist to be of size F_NRE and ordered. */
 void generate_qmexcl(gmx_mtop_t *sys, t_inputrec *ir, warninp_t wi, GmxQmmmMode qmmmMode);
index d529057a6b1acada146a865fd2d2518a99553768..ca06defb24117d84261541b169c6d71850b22bce 100644 (file)
@@ -66,7 +66,7 @@
 #include "gromacs/utility/smalloc.h"
 #include "gromacs/utility/stringutil.h"
 
-void generate_nbparams(int comb, int ftype, t_params *plist, gpp_atomtype *atype,
+void generate_nbparams(int comb, int ftype, InteractionTypeParameters *plist, gpp_atomtype *atype,
                        warninp *wi)
 {
     int   i, j, k = -1, nf;
@@ -192,7 +192,7 @@ void generate_nbparams(int comb, int ftype, t_params *plist, gpp_atomtype *atype
 }
 
 /*! \brief Used to temporarily store the explicit non-bonded parameter
- * combinations, which will be copied to t_params. */
+ * combinations, which will be copied to InteractionTypeParameters. */
 struct t_nbparam
 {
     //! Has this combination been set.
@@ -215,7 +215,7 @@ static void realloc_nb_params(gpp_atomtype *at,
     }
 }
 
-int copy_nbparams(t_nbparam **param, int ftype, t_params *plist, int nr)
+int copy_nbparams(t_nbparam **param, int ftype, InteractionTypeParameters *plist, int nr)
 {
     int i, j, f;
     int nrfp, ncopy;
@@ -581,13 +581,13 @@ static bool equalEitherForwardOrBackward(gmx::ArrayRef<const T> a, gmx::ArrayRef
             std::equal(a.begin(), a.end(), b.rbegin()));
 }
 
-static void push_bondtype(t_params     *       bt,
-                          const t_param *      b,
-                          int                  nral,
-                          int                  ftype,
-                          bool                 bAllowRepeat,
-                          const char *         line,
-                          warninp             *wi)
+static void push_bondtype(InteractionTypeParameters     *       bt,
+                          const t_param                  *      b,
+                          int                                   nral,
+                          int                                   ftype,
+                          bool                                  bAllowRepeat,
+                          const char                  *         line,
+                          warninp                              *wi)
 {
     int      nr   = bt->nr;
     int      nrfp = NRFP(ftype);
@@ -715,7 +715,7 @@ static void push_bondtype(t_params     *       bt,
     }
 }
 
-void push_bt(Directive d, t_params bt[], int nral,
+void push_bt(Directive d, gmx::ArrayRef<InteractionTypeParameters> bt, int nral,
              gpp_atomtype *at,
              gpp_bond_atomtype *bat, char *line,
              warninp *wi)
@@ -815,7 +815,7 @@ void push_bt(Directive d, t_params bt[], int nral,
 }
 
 
-void push_dihedraltype(Directive d, t_params bt[],
+void push_dihedraltype(Directive d, gmx::ArrayRef<InteractionTypeParameters> bt,
                        gpp_bond_atomtype *bat, char *line,
                        warninp *wi)
 {
@@ -1111,7 +1111,7 @@ void push_nbt(Directive d, t_nbparam **nbt, gpp_atomtype *atype,
 }
 
 void
-push_cmaptype(Directive d, t_params bt[], int nral, gpp_atomtype *at,
+push_cmaptype(Directive d, gmx::ArrayRef<InteractionTypeParameters> bt, int nral, gpp_atomtype *at,
               gpp_bond_atomtype *bat, char *line,
               warninp *wi)
 {
@@ -1155,10 +1155,6 @@ push_cmaptype(Directive d, t_params bt[], int nral, gpp_atomtype *at,
     nrfpB  = strtol(alc[7], nullptr, 10)*strtol(alc[7], nullptr, 10);
     nrfp   = nrfpA+nrfpB;
 
-    /* Allocate memory for the CMAP grid */
-    bt[F_CMAP].ncmap += nrfp;
-    srenew(bt[F_CMAP].cmap, bt[F_CMAP].ncmap);
-
     /* Read in CMAP parameters */
     sl = 0;
     for (i = 0; i < ncmap; i++)
@@ -1169,7 +1165,7 @@ push_cmaptype(Directive d, t_params bt[], int nral, gpp_atomtype *at,
         }
         nn  = sscanf(line+start+sl, " %s ", s);
         sl += strlen(s);
-        bt[F_CMAP].cmap[i+(bt[F_CMAP].ncmap)-nrfp] = strtod(s, nullptr);
+        bt[F_CMAP].cmap.emplace_back(strtod(s, nullptr));
 
         if (nn == 1)
         {
@@ -1188,7 +1184,7 @@ push_cmaptype(Directive d, t_params bt[], int nral, gpp_atomtype *at,
     {
         for (i = 0; i < ncmap; i++)
         {
-            bt[F_CMAP].cmap[i+ncmap] = bt[F_CMAP].cmap[i];
+            bt[F_CMAP].cmap.emplace_back(bt[F_CMAP].cmap[i]);
         }
     }
     else
@@ -1211,12 +1207,9 @@ push_cmaptype(Directive d, t_params bt[], int nral, gpp_atomtype *at,
     /* Set grid spacing and the number of grids (we assume these numbers to be the same for all grids
      * so we can safely assign them each time
      */
-    bt[F_CMAP].grid_spacing = nxcmap;            /* Or nycmap, they need to be equal */
-    bt[F_CMAP].nc           = bt[F_CMAP].nc + 1; /* Since we are incrementing here, we need to subtract later, see (*****) */
-    nct                     = (nral+1) * bt[F_CMAP].nc;
-
-    /* Allocate memory for the cmap_types information */
-    srenew(bt[F_CMAP].cmap_types, nct);
+    bt[F_CMAP].cmakeGridSpacing = nxcmap; /* Or nycmap, they need to be equal */
+    bt[F_CMAP].cmapAngles++;              /* Since we are incrementing here, we need to subtract later, see (*****) */
+    nct                     = (nral+1) * bt[F_CMAP].cmapAngles;
 
     for (i = 0; (i < nral); i++)
     {
@@ -1232,16 +1225,16 @@ push_cmaptype(Directive d, t_params bt[], int nral, gpp_atomtype *at,
         }
 
         /* Assign a grid number to each cmap_type */
-        bt[F_CMAP].cmap_types[bt[F_CMAP].nct++] = get_bond_atomtype_type(alc[i], bat);
+        bt[F_CMAP].cmapAtomTypes.emplace_back(get_bond_atomtype_type(alc[i], bat));
     }
 
     /* Assign a type number to this cmap */
-    bt[F_CMAP].cmap_types[bt[F_CMAP].nct++] = bt[F_CMAP].nc-1; /* Since we inremented earlier, we need to subtrac here, to get the types right (****) */
+    bt[F_CMAP].cmapAtomTypes.emplace_back(bt[F_CMAP].cmapAngles-1); /* Since we inremented earlier, we need to subtrac here, to get the types right (****) */
 
     /* Check for the correct number of atoms (again) */
-    if (bt[F_CMAP].nct != nct)
+    if (bt[F_CMAP].nct() != nct)
     {
-        auto message = gmx::formatString("Incorrect number of atom types (%d) in cmap type %d\n", nct, bt[F_CMAP].nc);
+        auto message = gmx::formatString("Incorrect number of atom types (%d) in cmap type %d\n", nct, bt[F_CMAP].cmapAngles);
         warning_error(wi, message);
     }
 
@@ -1469,7 +1462,7 @@ void push_molt(t_symtab                         *symtab,
     mol->back().excl_set = false;
 }
 
-static bool default_nb_params(int ftype, t_params bt[], t_atoms *at,
+static bool default_nb_params(int ftype, gmx::ArrayRef<InteractionTypeParameters> bt, t_atoms *at,
                               t_param *p, int c_start, bool bB, bool bGenPairs)
 {
     int          i, j, ti, tj, ntype;
@@ -1564,7 +1557,7 @@ static bool default_nb_params(int ftype, t_params bt[], t_atoms *at,
     return bFound;
 }
 
-static bool default_cmap_params(t_params bondtype[],
+static bool default_cmap_params(gmx::ArrayRef<InteractionTypeParameters> bondtype,
                                 t_atoms *at, gpp_atomtype *atype,
                                 t_param *p, bool bB,
                                 int *cmap_type, int *nparam_def,
@@ -1578,7 +1571,7 @@ static bool default_cmap_params(t_params bondtype[],
     ct           = 0;
 
     /* Match the current cmap angle against the list of cmap_types */
-    for (i = 0; i < bondtype[F_CMAP].nct && !bFound; i += 6)
+    for (i = 0; i < bondtype[F_CMAP].nct() && !bFound; i += 6)
     {
         if (bB)
         {
@@ -1587,15 +1580,15 @@ static bool default_cmap_params(t_params bondtype[],
         else
         {
             if (
-                (get_atomtype_batype(at->atom[p->a[0]].type, atype) == bondtype[F_CMAP].cmap_types[i])   &&
-                (get_atomtype_batype(at->atom[p->a[1]].type, atype) == bondtype[F_CMAP].cmap_types[i+1]) &&
-                (get_atomtype_batype(at->atom[p->a[2]].type, atype) == bondtype[F_CMAP].cmap_types[i+2]) &&
-                (get_atomtype_batype(at->atom[p->a[3]].type, atype) == bondtype[F_CMAP].cmap_types[i+3]) &&
-                (get_atomtype_batype(at->atom[p->a[4]].type, atype) == bondtype[F_CMAP].cmap_types[i+4]))
+                (get_atomtype_batype(at->atom[p->a[0]].type, atype) == bondtype[F_CMAP].cmapAtomTypes[i])   &&
+                (get_atomtype_batype(at->atom[p->a[1]].type, atype) == bondtype[F_CMAP].cmapAtomTypes[i+1]) &&
+                (get_atomtype_batype(at->atom[p->a[2]].type, atype) == bondtype[F_CMAP].cmapAtomTypes[i+2]) &&
+                (get_atomtype_batype(at->atom[p->a[3]].type, atype) == bondtype[F_CMAP].cmapAtomTypes[i+3]) &&
+                (get_atomtype_batype(at->atom[p->a[4]].type, atype) == bondtype[F_CMAP].cmapAtomTypes[i+4]))
             {
                 /* Found cmap torsion */
                 bFound       = TRUE;
-                ct           = bondtype[F_CMAP].cmap_types[i+5];
+                ct           = bondtype[F_CMAP].cmapAtomTypes[i+5];
                 nparam_found = 1;
             }
         }
@@ -1639,11 +1632,11 @@ static int natom_match(t_param *pi,
     }
 }
 
-static bool default_params(int ftype, t_params bt[],
-                           t_atoms *at, gpp_atomtype *atype,
-                           t_param *p, bool bB,
-                           t_param **param_def,
-                           int *nparam_def)
+static bool defaultInteractionTypeParameters(int ftype, gmx::ArrayRef<InteractionTypeParameters> bt,
+                                             t_atoms *at, gpp_atomtype *atype,
+                                             t_param *p, bool bB,
+                                             t_param **param_def,
+                                             int *nparam_def)
 {
     int          nparam_found;
     bool         bFound, bSame;
@@ -1758,7 +1751,8 @@ static bool default_params(int ftype, t_params bt[],
 
 
 
-void push_bond(Directive d, t_params bondtype[], t_params bond[],
+void push_bond(Directive d, gmx::ArrayRef<InteractionTypeParameters> bondtype,
+               gmx::ArrayRef<InteractionTypeParameters> bond,
                t_atoms *at, gpp_atomtype *atype, char *line,
                bool bBonded, bool bGenPairs, real fudgeQQ,
                bool bZero, bool *bWarn_copy_A_B,
@@ -1904,7 +1898,7 @@ void push_bond(Directive d, t_params bondtype[], t_params bond[],
 
     if (bBonded)
     {
-        bFoundA = default_params(ftype, bondtype, at, atype, &param, FALSE, &param_defA, &nparam_defA);
+        bFoundA = defaultInteractionTypeParameters(ftype, bondtype, at, atype, &param, FALSE, &param_defA, &nparam_defA);
         if (bFoundA)
         {
             /* Copy the A-state and B-state default parameters. */
@@ -1914,7 +1908,7 @@ void push_bond(Directive d, t_params bondtype[], t_params bond[],
                 param.c[j] = param_defA->c[j];
             }
         }
-        bFoundB = default_params(ftype, bondtype, at, atype, &param, TRUE, &param_defB, &nparam_defB);
+        bFoundB = defaultInteractionTypeParameters(ftype, bondtype, at, atype, &param, TRUE, &param_defB, &nparam_defB);
         if (bFoundB)
         {
             /* Copy only the B-state default parameters */
@@ -2166,7 +2160,8 @@ void push_bond(Directive d, t_params bondtype[], t_params bond[],
     }
 }
 
-void push_cmap(Directive d, t_params bondtype[], t_params bond[],
+void push_cmap(Directive d, gmx::ArrayRef<InteractionTypeParameters> bondtype,
+               gmx::ArrayRef<InteractionTypeParameters> bond,
                t_atoms *at, gpp_atomtype *atype, char *line,
                warninp *wi)
 {
@@ -2259,7 +2254,7 @@ void push_cmap(Directive d, t_params bondtype[], t_params bond[],
 
 
 
-void push_vsitesn(Directive d, t_params bond[],
+void push_vsitesn(Directive d, gmx::ArrayRef<InteractionTypeParameters> bond,
                   t_atoms *at, char *line,
                   warninp *wi)
 {
@@ -2508,7 +2503,7 @@ int add_atomtype_decoupled(t_symtab *symtab, gpp_atomtype *at,
     return nr;
 }
 
-static void convert_pairs_to_pairsQ(t_params *plist,
+static void convert_pairs_to_pairsQ(gmx::ArrayRef<InteractionTypeParameters> plist,
                                     real fudgeQQ, t_atoms *atoms)
 {
     t_param *paramp1, *paramp2, *paramnew;
@@ -2573,7 +2568,7 @@ static void convert_pairs_to_pairsQ(t_params *plist,
     plist[F_LJ14].param = nullptr;
 }
 
-static void generate_LJCpairsNB(MoleculeInformation *mol, int nb_funct, t_params *nbp, warninp *wi)
+static void generate_LJCpairsNB(MoleculeInformation *mol, int nb_funct, InteractionTypeParameters *nbp, warninp *wi)
 {
     int       n, ntype, i, j, k;
     t_atom   *atom;
@@ -2695,7 +2690,7 @@ static void decouple_atoms(t_atoms *atoms, int atomtype_decouple,
 
 void convert_moltype_couple(MoleculeInformation *mol, int atomtype_decouple, real fudgeQQ,
                             int couple_lam0, int couple_lam1,
-                            bool bCoupleIntra, int nb_funct, t_params *nbp,
+                            bool bCoupleIntra, int nb_funct, InteractionTypeParameters *nbp,
                             warninp *wi)
 {
     convert_pairs_to_pairsQ(mol->plist, fudgeQQ, &mol->atoms);
index 1bb0078a37a90f6803772bcbaee96e032c829aa7..48d706871afdd16d3a7d66ebc2335c5f1de1234f 100644 (file)
@@ -51,7 +51,7 @@ struct t_block;
 struct MoleculeInformation;
 struct t_nbparam;
 struct t_param;
-struct t_params;
+struct InteractionTypeParameters;
 struct PreprocessResidue;
 struct warninp;
 
@@ -60,7 +60,7 @@ namespace gmx
 struct ExclusionBlock;
 } // namespace gmx
 
-void generate_nbparams(int comb, int funct, t_params plist[],
+void generate_nbparams(int comb, int funct, InteractionTypeParameters *plist,
                        gpp_atomtype *atype,
                        warninp *wi);
 
@@ -69,15 +69,15 @@ void push_at (struct t_symtab *symtab, gpp_atomtype *at,
               t_nbparam ***nbparam, t_nbparam ***pair,
               warninp *wi);
 
-void push_bt(Directive d, t_params bt[], int nral,
+void push_bt(Directive d, gmx::ArrayRef<InteractionTypeParameters> bt, int nral,
              gpp_atomtype *at, gpp_bond_atomtype *bat, char *line,
              warninp *wi);
 
-void push_dihedraltype(Directive d, t_params bt[],
+void push_dihedraltype(Directive d, gmx::ArrayRef<InteractionTypeParameters> bt,
                        gpp_bond_atomtype *bat, char *line,
                        warninp *wi);
 
-void push_cmaptype(Directive d, t_params bt[], int nral, gpp_atomtype *at,
+void push_cmaptype(Directive d, gmx::ArrayRef<InteractionTypeParameters> bt, int nral, gpp_atomtype *at,
                    gpp_bond_atomtype *bat, char *line,
                    warninp *wi);
 
@@ -93,17 +93,20 @@ void push_atom(struct t_symtab *symtab,
                int             *lastcg,
                warninp         *wi);
 
-void push_bond(Directive d, t_params bondtype[], t_params bond[],
+void push_bond(Directive d, gmx::ArrayRef<InteractionTypeParameters> bondtype,
+               gmx::ArrayRef<InteractionTypeParameters> bond,
                t_atoms *at, gpp_atomtype *atype, char *line,
                bool bBonded, bool bGenPairs, real fudgeQQ,
                bool bZero, bool *bWarn_copy_A_B,
                warninp *wi);
 
-void push_cmap(Directive d, t_params bondtype[], t_params bond[],
+void push_cmap(Directive d,
+               gmx::ArrayRef<InteractionTypeParameters> bondtype,
+               gmx::ArrayRef<InteractionTypeParameters> bond,
                t_atoms *at, gpp_atomtype *atype, char *line,
                warninp *wi);
 
-void push_vsitesn(Directive d, t_params bond[],
+void push_vsitesn(Directive d, gmx::ArrayRef<InteractionTypeParameters> bond,
                   t_atoms *at, char *line,
                   warninp *wi);
 
@@ -116,7 +119,7 @@ void push_molt(struct t_symtab *symtab, std::vector<MoleculeInformation> *mol, c
 
 void push_excl(char *line, gmx::ArrayRef<gmx::ExclusionBlock> b2, warninp *wi);
 
-int copy_nbparams(t_nbparam **param, int ftype, t_params *plist, int nr);
+int copy_nbparams(t_nbparam **param, int ftype, InteractionTypeParameters *plist, int nr);
 
 void free_nbparam(t_nbparam **param, int nr);
 
@@ -130,7 +133,7 @@ void convert_moltype_couple(MoleculeInformation *mol, int atomtype_decouple,
                             real fudgeQQ,
                             int couple_lam0, int couple_lam1,
                             bool bCoupleIntra,
-                            int nb_funct, t_params *nbp,
+                            int nb_funct, InteractionTypeParameters *nbp,
                             warninp *wi);
 /* Setup mol such that the B-state has no interaction with the rest
  * of the system, but full interaction with itself.
index 5c54f19db79fd6335059ab12e65474659c39b3e0..49dea59eeec68632c6e27efc5d0e00ce516d7f7e 100644 (file)
@@ -53,7 +53,7 @@
 #include "gromacs/utility/fatalerror.h"
 #include "gromacs/utility/smalloc.h"
 
-static void copy_bond (t_params *pr, int to, int from)
+static void copy_bond (InteractionTypeParameters *pr, int to, int from)
 /* copies an entry in a bond list to another position.
  * does no allocing or freeing of memory
  */
@@ -103,15 +103,15 @@ static int count_hydrogens (char ***atomname, int nra, const int a[])
     return nh;
 }
 
-void make_shake (t_params plist[], t_atoms *atoms, int nshake)
+void make_shake(gmx::ArrayRef<InteractionTypeParameters> plist, t_atoms *atoms, int nshake)
 {
-    char          ***info = atoms->atomname;
-    t_params        *pr;
-    t_params        *bonds;
-    t_param          p, *bond, *ang;
-    real             b_ij, b_jk;
-    int              i, j, ftype, ftype_a;
-    bool             bFound;
+    char                           ***info = atoms->atomname;
+    InteractionTypeParameters        *pr;
+    InteractionTypeParameters        *bonds;
+    t_param                           p, *bond, *ang;
+    real                              b_ij, b_jk;
+    int                               i, j, ftype, ftype_a;
+    bool                              bFound;
 
     if (nshake != eshNONE)
     {
index 6573aed28c2563eae3495566efe75357eed565a2..f9163f50db88f744c7d0f29ae957dc7d256d4479 100644 (file)
 #ifndef GMX_GMXPREPROCESS_TOPSHAKE_H
 #define GMX_GMXPREPROCESS_TOPSHAKE_H
 
+#include "gromacs/utility/arrayref.h"
+
 struct t_atoms;
-struct t_params;
+struct InteractionTypeParameters;
 
-void make_shake (t_params plist[], t_atoms *atoms, int nshake);
+void make_shake (gmx::ArrayRef<InteractionTypeParameters> plist, t_atoms *atoms, int nshake);
 
 #endif
index ae1a78e340e50a8a177b82da2707c0d3eee4f857..ecde0d9fa8966ccfc084e570fad7d6a244b660ae 100644 (file)
@@ -78,7 +78,7 @@ void set_p_string(t_param *p, const char *s)
     }
 }
 
-void pr_alloc (int extra, t_params *pr)
+void pr_alloc (int extra, InteractionTypeParameters *pr)
 {
     int i, j;
 
@@ -91,7 +91,7 @@ void pr_alloc (int extra, t_params *pr)
     {
         return;
     }
-    GMX_ASSERT(pr->nr != 0 || pr->param == nullptr, "Invalid t_params object");
+    GMX_ASSERT(pr->nr != 0 || pr->param == nullptr, "Invalid InteractionTypeParameters object");
     if (pr->nr+extra > pr->maxnr)
     {
         pr->maxnr = std::max(static_cast<int>(1.2*pr->maxnr), pr->maxnr + extra);
@@ -111,7 +111,7 @@ void pr_alloc (int extra, t_params *pr)
     }
 }
 
-void init_plist(t_params plist[])
+void init_plist(gmx::ArrayRef<InteractionTypeParameters> plist)
 {
     int i;
 
@@ -120,25 +120,14 @@ void init_plist(t_params plist[])
         plist[i].nr    = 0;
         plist[i].maxnr = 0;
         plist[i].param = nullptr;
-
-        /* CMAP */
-        plist[i].ncmap        = 0;
-        plist[i].cmap         = nullptr;
-        plist[i].grid_spacing = 0;
-        plist[i].nc           = 0;
-        plist[i].nct          = 0;
-        plist[i].cmap_types   = nullptr;
     }
 }
 
-void done_plist(t_params *plist)
+void done_plist(gmx::ArrayRef<InteractionTypeParameters> plist)
 {
     for (int i = 0; i < F_NRE; i++)
     {
-        t_params *pl = &plist[i];
-        sfree(pl->param);
-        sfree(pl->cmap);
-        sfree(pl->cmap_types);
+        sfree(plist[i].param);
     }
 }
 
@@ -157,7 +146,7 @@ void cp_param(t_param *dest, t_param *src)
     strncpy(dest->s, src->s, sizeof(dest->s));
 }
 
-void add_param_to_list(t_params *list, t_param *b)
+void add_param_to_list(InteractionTypeParameters *list, t_param *b)
 {
     int j;
 
@@ -181,18 +170,17 @@ void add_param_to_list(t_params *list, t_param *b)
 /* PRINTING STRUCTURES */
 
 static void print_bt(FILE *out, Directive d, gpp_atomtype *at,
-                     int ftype, int fsubtype, t_params plist[],
+                     int ftype, int fsubtype, gmx::ArrayRef<const InteractionTypeParameters> plist,
                      bool bFullDih)
 {
     /* This dihp is a DIRTY patch because the dih-types do not use
      * all four atoms to determine the type.
      */
-    const int    dihp[2][2] = { { 1, 2 }, { 0, 3 } };
-    t_params    *bt;
-    int          i, j, f, nral, nrfp;
-    bool         bDih = FALSE, bSwapParity;
+    const int                        dihp[2][2] = { { 1, 2 }, { 0, 3 } };
+    int                              i, j, f, nral, nrfp;
+    bool                             bDih = FALSE, bSwapParity;
 
-    bt = &(plist[ftype]);
+    const InteractionTypeParameters *bt = &(plist[ftype]);
 
     if (!bt->nr)
     {
@@ -501,7 +489,7 @@ void print_atoms(FILE *out, gpp_atomtype *atype, t_atoms *at, int *cgnr,
 }
 
 void print_bondeds(FILE *out, int natoms, Directive d,
-                   int ftype, int fsubtype, t_params plist[])
+                   int ftype, int fsubtype, gmx::ArrayRef<const InteractionTypeParameters> plist)
 {
     t_symtab       stab;
     gpp_atomtype  *atype;
index 5664d606b11fe238d70dd95bef8ad5f639eab4f7..068225238e05e1455042d97d68230bcf915a7eb9 100644 (file)
@@ -40,6 +40,8 @@
 
 #include <cstdio>
 
+#include "gromacs/utility/arrayref.h"
+
 enum class Directive : int;
 struct gpp_atomtype;
 struct t_atoms;
@@ -47,24 +49,24 @@ struct t_blocka;
 struct t_excls;
 struct MoleculeInformation;
 struct t_param;
-struct t_params;
+struct InteractionTypeParameters;
 
 /* UTILITIES */
 
 int name2index(char *str, char ***typenames, int ntypes);
 
-void pr_alloc (int extra, t_params *pr);
+void pr_alloc (int extra, InteractionTypeParameters *pr);
 
 void set_p_string(t_param *p, const char *s);
 
 void cp_param(t_param *dest, t_param *src);
 
-void add_param_to_list(t_params *list, t_param *b);
+void add_param_to_list(InteractionTypeParameters *list, t_param *b);
 
 /* INITIATE */
 
-void init_plist(t_params plist[]);
-void done_plist(t_params *plist);
+void init_plist(gmx::ArrayRef<InteractionTypeParameters> plist);
+void done_plist(gmx::ArrayRef<InteractionTypeParameters> plist);
 
 
 /* PRINTING */
@@ -76,7 +78,7 @@ void print_atoms(FILE *out, gpp_atomtype *atype, t_atoms *at, int *cgnr,
                  bool bRTPresname);
 
 void print_bondeds(FILE *out, int natoms, Directive d,
-                   int ftype, int fsubtype, t_params plist[]);
+                   int ftype, int fsubtype, gmx::ArrayRef<const InteractionTypeParameters> plist);
 
 void print_excl(FILE *out, int natoms, t_excls excls[]);
 
index 02e18a23137af9cb4cb0f2c1b190cf5de0b33342..d047c3bb9530cd12dfb8403535e2fa16075ee255 100644 (file)
@@ -150,7 +150,7 @@ static void get_bondeds(int nrat, const t_iatom atoms[],
     }
 }
 
-static at2vsitebond_t *make_at2vsitebond(int natoms, t_params plist[])
+static at2vsitebond_t *make_at2vsitebond(int natoms, gmx::ArrayRef<InteractionTypeParameters> plist)
 {
     bool           *bVSI;
     int             ftype, i, j, nrcheck, nr;
@@ -218,7 +218,7 @@ static void done_at2vsitebond(int natoms, at2vsitebond_t *at2vb)
     sfree(at2vb);
 }
 
-static at2vsitecon_t *make_at2vsitecon(int natoms, t_params plist[])
+static at2vsitecon_t *make_at2vsitecon(int natoms, gmx::ArrayRef<InteractionTypeParameters> plist)
 {
     bool          *bVSI;
     int            ftype, i, j, ai, aj, nr;
@@ -768,7 +768,7 @@ calc_vsite4fdn_param(t_param *param,
 
 
 int set_vsites(bool bVerbose, t_atoms *atoms, gpp_atomtype *atype,
-               t_params plist[])
+               gmx::ArrayRef<InteractionTypeParameters> plist)
 {
     int             i, j, ftype;
     int             nvsite, nrbond, nrang, nridih, nrset;
@@ -934,12 +934,12 @@ typedef struct {
     int ftype, parnr;
 } t_pindex;
 
-static void check_vsite_constraints(t_params *plist,
+static void check_vsite_constraints(gmx::ArrayRef<InteractionTypeParameters> plist,
                                     int cftype, const int vsite_type[])
 {
-    int       i, k, n;
-    int       atom;
-    t_params *ps;
+    int                        i, k, n;
+    int                        atom;
+    InteractionTypeParameters *ps;
 
     n  = 0;
     ps = &(plist[cftype]);
@@ -962,14 +962,14 @@ static void check_vsite_constraints(t_params *plist,
     }
 }
 
-static void clean_vsite_bonds(t_params *plist, t_pindex pindex[],
+static void clean_vsite_bonds(gmx::ArrayRef<InteractionTypeParameters> plist, t_pindex pindex[],
                               int cftype, const int vsite_type[])
 {
-    int          ftype, i, j, k, m, n, nvsite, nOut, kept_i;
-    int          nconverted, nremoved;
-    int          atom, oatom, at1, at2;
-    bool         bKeep, bRemove, bUsed, bPresent, bThisFD, bThisOUT, bAllFD, bFirstTwo;
-    t_params    *ps;
+    int                           ftype, i, j, k, m, n, nvsite, nOut, kept_i;
+    int                           nconverted, nremoved;
+    int                           atom, oatom, at1, at2;
+    bool                          bKeep, bRemove, bUsed, bPresent, bThisFD, bThisOUT, bAllFD, bFirstTwo;
+    InteractionTypeParameters    *ps;
 
     if (cftype == F_CONNBONDS)
     {
@@ -1186,14 +1186,14 @@ static void clean_vsite_bonds(t_params *plist, t_pindex pindex[],
     ps->nr = kept_i;
 }
 
-static void clean_vsite_angles(t_params *plist, t_pindex pindex[],
+static void clean_vsite_angles(gmx::ArrayRef<InteractionTypeParameters> plist, t_pindex pindex[],
                                int cftype, const int vsite_type[],
                                at2vsitecon_t *at2vc)
 {
-    int          i, j, k, m, n, nvsite, kept_i;
-    int          atom, at1, at2;
-    bool         bKeep, bUsed, bPresent, bAll3FAD, bFirstTwo;
-    t_params    *ps;
+    int                           i, j, k, m, n, nvsite, kept_i;
+    int                           atom, at1, at2;
+    bool                          bKeep, bUsed, bPresent, bAll3FAD, bFirstTwo;
+    InteractionTypeParameters    *ps;
 
     ps     = &(plist[cftype]);
     kept_i = 0;
@@ -1323,11 +1323,11 @@ static void clean_vsite_angles(t_params *plist, t_pindex pindex[],
     ps->nr = kept_i;
 }
 
-static void clean_vsite_dihs(t_params *plist, t_pindex pindex[],
+static void clean_vsite_dihs(gmx::ArrayRef<InteractionTypeParameters> plist, t_pindex pindex[],
                              int cftype, const int vsite_type[])
 {
-    int       i, kept_i;
-    t_params *ps;
+    int                        i, kept_i;
+    InteractionTypeParameters *ps;
 
     ps = &(plist[cftype]);
 
@@ -1435,7 +1435,7 @@ static void clean_vsite_dihs(t_params *plist, t_pindex pindex[],
     ps->nr = kept_i;
 }
 
-void clean_vsite_bondeds(t_params *plist, int natoms, bool bRmVSiteBds)
+void clean_vsite_bondeds(gmx::ArrayRef<InteractionTypeParameters> plist, int natoms, bool bRmVSiteBds)
 {
     int            i, k, nvsite, ftype, vsite, parnr;
     int           *vsite_type;
index 986908ebaf363013bc9c4ee75740369bab8e6677..81005a0fe42df6e4e49b02251352a848031a5ac3 100644 (file)
 #ifndef GMX_GMXPREPROCESS_VSITE_PARM_H
 #define GMX_GMXPREPROCESS_VSITE_PARM_H
 
+#include "gromacs/utility/arrayref.h"
+
 struct gpp_atomtype;
 struct gmx_moltype_t;
 struct t_atoms;
-struct t_params;
+struct InteractionTypeParameters;
 
 int set_vsites(bool bVerbose, t_atoms *atoms,  gpp_atomtype *atype,
-               t_params plist[]);
+               gmx::ArrayRef<InteractionTypeParameters> plist);
 /* set parameters for virtual sites, return number of virtual sites */
 
 void set_vsites_ptype(bool bVerbose,  gmx_moltype_t *molt);
@@ -54,6 +56,6 @@ void set_vsites_ptype(bool bVerbose,  gmx_moltype_t *molt);
  *
  * Throw away all obsolete bonds, angles and dihedrals.
  * Throw away all constraints. */
-void clean_vsite_bondeds(t_params *ps, int natoms, bool bRmVSiteBds);
+void clean_vsite_bondeds(gmx::ArrayRef<InteractionTypeParameters> ps, int natoms, bool bRmVSiteBds);
 
 #endif
index ada52a8a6c1ada098b4ab8c4fcc2957c17055a86..a120b4292570e49ef41ff29e08b6c4a01feac844 100644 (file)
@@ -94,7 +94,7 @@ static bool is_bond(int nnm, t_nm2type nmt[], char *ai, char *aj, real blen)
 }
 
 static void mk_bonds(int nnm, t_nm2type nmt[],
-                     t_atoms *atoms, const rvec x[], t_params *bond, int nbond[],
+                     t_atoms *atoms, const rvec x[], InteractionTypeParameters *bond, int nbond[],
                      bool bPBC, matrix box)
 {
     t_param b;
@@ -178,7 +178,7 @@ static int *set_cgnr(t_atoms *atoms, bool bUsePDBcharge, real *qtot, real *mtot)
     return cgnr;
 }
 
-static gpp_atomtype *set_atom_type(t_symtab *tab, t_atoms *atoms, t_params *bonds,
+static gpp_atomtype *set_atom_type(t_symtab *tab, t_atoms *atoms, InteractionTypeParameters *bonds,
                                    int *nbonds, int nnm, t_nm2type nm2t[])
 {
     gpp_atomtype  *atype;
@@ -199,18 +199,17 @@ static gpp_atomtype *set_atom_type(t_symtab *tab, t_atoms *atoms, t_params *bond
     return atype;
 }
 
-static void lo_set_force_const(t_params *plist, real c[], int nrfp, bool bRound,
+static void lo_set_force_const(InteractionTypeParameters *plist, real c[], int nrfp, bool bRound,
                                bool bDih, bool bParam)
 {
-    int    i, j;
     double cc;
     char   buf[32];
 
-    for (i = 0; (i < plist->nr); i++)
+    for (int i = 0; (i < plist->nr); i++)
     {
         if (!bParam)
         {
-            for (j = 0; j < nrfp; j++)
+            for (int j = 0; j < nrfp; j++)
             {
                 c[j] = NOTSET;
             }
@@ -240,7 +239,7 @@ static void lo_set_force_const(t_params *plist, real c[], int nrfp, bool bRound,
             }
         }
         GMX_ASSERT(nrfp <= MAXFORCEPARAM/2, "Only 6 parameters may be used for an interaction");
-        for (j = 0; (j < nrfp); j++)
+        for (int j = 0; (j < nrfp); j++)
         {
             plist->param[i].c[j]      = c[j];
             plist->param[i].c[nrfp+j] = c[j];
@@ -249,7 +248,7 @@ static void lo_set_force_const(t_params *plist, real c[], int nrfp, bool bRound,
     }
 }
 
-static void set_force_const(t_params plist[], real kb, real kt, real kp, bool bRound,
+static void set_force_const(gmx::ArrayRef<InteractionTypeParameters> plist, real kb, real kt, real kp, bool bRound,
                             bool bParam)
 {
     real c[MAXFORCEPARAM];
@@ -264,35 +263,35 @@ static void set_force_const(t_params plist[], real kb, real kt, real kp, bool bR
     lo_set_force_const(&plist[F_PDIHS], c, 3, bRound, TRUE, bParam);
 }
 
-static void calc_angles_dihs(t_params *ang, t_params *dih, const rvec x[], bool bPBC,
+static void calc_angles_dihs(InteractionTypeParameters *ang, InteractionTypeParameters *dih, const rvec x[], bool bPBC,
                              matrix box)
 {
-    int    i, ai, aj, ak, al, t1, t2, t3;
+    int    t1, t2, t3;
     rvec   r_ij, r_kj, r_kl, m, n;
-    real   th, costh, ph;
+    real   costh;
     t_pbc  pbc;
 
     if (bPBC)
     {
         set_pbc(&pbc, epbcXYZ, box);
     }
-    for (i = 0; (i < ang->nr); i++)
+    for (int i = 0; (i < ang->nr); i++)
     {
-        ai = ang->param[i].ai();
-        aj = ang->param[i].aj();
-        ak = ang->param[i].ak();
-        th = RAD2DEG*bond_angle(x[ai], x[aj], x[ak], bPBC ? &pbc : nullptr,
-                                r_ij, r_kj, &costh, &t1, &t2);
+        int  ai = ang->param[i].ai();
+        int  aj = ang->param[i].aj();
+        int  ak = ang->param[i].ak();
+        real th = RAD2DEG*bond_angle(x[ai], x[aj], x[ak], bPBC ? &pbc : nullptr,
+                                     r_ij, r_kj, &costh, &t1, &t2);
         ang->param[i].c0() = th;
     }
-    for (i = 0; (i < dih->nr); i++)
+    for (int i = 0; (i < dih->nr); i++)
     {
-        ai = dih->param[i].ai();
-        aj = dih->param[i].aj();
-        ak = dih->param[i].ak();
-        al = dih->param[i].al();
-        ph = RAD2DEG*dih_angle(x[ai], x[aj], x[ak], x[al], bPBC ? &pbc : nullptr,
-                               r_ij, r_kj, r_kl, m, n, &t1, &t2, &t3);
+        int  ai = dih->param[i].ai();
+        int  aj = dih->param[i].aj();
+        int  ak = dih->param[i].ak();
+        int  al = dih->param[i].al();
+        real ph = RAD2DEG*dih_angle(x[ai], x[aj], x[ak], x[al], bPBC ? &pbc : nullptr,
+                                    r_ij, r_kj, r_kl, m, n, &t1, &t2, &t3);
         dih->param[i].c0() = ph;
     }
 }
@@ -307,24 +306,22 @@ static void dump_hybridization(FILE *fp, t_atoms *atoms, int nbonds[])
     }
 }
 
-static void print_pl(FILE *fp, t_params plist[], int ftp, const char *name,
+static void print_pl(FILE *fp, gmx::ArrayRef<const InteractionTypeParameters> plist, int ftp, const char *name,
                      char ***atomname)
 {
-    int i, j, nral, nrfp;
-
     if (plist[ftp].nr > 0)
     {
         fprintf(fp, "\n");
         fprintf(fp, "[ %s ]\n", name);
-        nral = interaction_function[ftp].nratoms;
-        nrfp = interaction_function[ftp].nrfpA;
-        for (i = 0; (i < plist[ftp].nr); i++)
+        int nral = interaction_function[ftp].nratoms;
+        int nrfp = interaction_function[ftp].nrfpA;
+        for (int i = 0; (i < plist[ftp].nr); i++)
         {
-            for (j = 0; (j < nral); j++)
+            for (int j = 0; (j < nral); j++)
             {
                 fprintf(fp, "  %5s", *atomname[plist[ftp].param[i].a[j]]);
             }
-            for (j = 0; (j < nrfp); j++)
+            for (int j = 0; (j < nrfp); j++)
             {
                 if (plist[ftp].param[i].c[j] != NOTSET)
                 {
@@ -337,7 +334,7 @@ static void print_pl(FILE *fp, t_params plist[], int ftp, const char *name,
 }
 
 static void print_rtp(const char *filenm, const char *title, t_atoms *atoms,
-                      t_params plist[], gpp_atomtype *atype, int cgnr[])
+                      gmx::ArrayRef<const InteractionTypeParameters> plist, gpp_atomtype *atype, int cgnr[])
 {
     FILE *fp;
     int   i, tp;
@@ -370,7 +367,7 @@ static void print_rtp(const char *filenm, const char *title, t_atoms *atoms,
 
 int gmx_x2top(int argc, char *argv[])
 {
-    const char        *desc[] = {
+    const char                                  *desc[] = {
         "[THISMODULE] generates a primitive topology from a coordinate file.",
         "The program assumes all hydrogens are present when defining",
         "the hybridization from the atom name and the number of bonds.",
@@ -391,51 +388,51 @@ int gmx_x2top(int argc, char *argv[])
         "one of the short names above on the command line instead. In that",
         "case [THISMODULE] just looks for the corresponding file.[PAR]",
     };
-    const char        *bugs[] = {
+    const char                                  *bugs[] = {
         "The atom type selection is primitive. Virtually no chemical knowledge is used",
         "Periodic boundary conditions screw up the bonding",
         "No improper dihedrals are generated",
         "The atoms to atomtype translation table is incomplete ([TT]atomname2type.n2t[tt] file in the data directory). Please extend it and send the results back to the GROMACS crew."
     };
-    FILE              *fp;
-    t_params           plist[F_NRE];
-    t_excls           *excls;
-    gpp_atomtype      *atype;
-    t_nextnb           nnb;
-    t_nm2type         *nm2t;
-    t_mols             mymol;
-    int                nnm;
-    char               forcefield[32], ffdir[STRLEN];
-    rvec              *x; /* coordinates? */
-    int               *nbonds, *cgnr;
-    int                bts[] = { 1, 1, 1, 2 };
-    matrix             box;    /* box length matrix */
-    int                natoms; /* number of atoms in one molecule  */
-    int                epbc;
-    bool               bRTP, bTOP, bOPLS;
-    t_symtab           symtab;
-    real               qtot, mtot;
-    char               n2t[STRLEN];
-    gmx_output_env_t  *oenv;
-
-    t_filenm           fnm[] = {
+    FILE                                        *fp;
+    std::array<InteractionTypeParameters, F_NRE> plist;
+    t_excls                                     *excls;
+    gpp_atomtype                                *atype;
+    t_nextnb                                     nnb;
+    t_nm2type                                   *nm2t;
+    t_mols                                       mymol;
+    int                                          nnm;
+    char                                         forcefield[32], ffdir[STRLEN];
+    rvec                                        *x; /* coordinates? */
+    int                                         *nbonds, *cgnr;
+    int                                          bts[] = { 1, 1, 1, 2 };
+    matrix                                       box;    /* box length matrix */
+    int                                          natoms; /* number of atoms in one molecule  */
+    int                                          epbc;
+    bool                                         bRTP, bTOP, bOPLS;
+    t_symtab                                     symtab;
+    real                                         qtot, mtot;
+    char                                         n2t[STRLEN];
+    gmx_output_env_t                            *oenv;
+
+    t_filenm                                     fnm[] = {
         { efSTX, "-f", "conf", ffREAD  },
         { efTOP, "-o", "out",  ffOPTWR },
         { efRTP, "-r", "out",  ffOPTWR }
     };
 #define NFILE asize(fnm)
-    real               kb                            = 4e5, kt = 400, kp = 5;
-    PreprocessResidue  rtp_header_settings;
-    bool               bRemoveDihedralIfWithImproper = FALSE;
-    bool               bGenerateHH14Interactions     = TRUE;
-    bool               bKeepAllGeneratedDihedrals    = FALSE;
-    int                nrexcl                        = 3;
-    bool               bParam                        = TRUE, bRound = TRUE;
-    bool               bPairs                        = TRUE, bPBC = TRUE;
-    bool               bUsePDBcharge                 = FALSE, bVerbose = FALSE;
-    const char        *molnm                         = "ICE";
-    const char        *ff                            = "oplsaa";
-    t_pargs            pa[]                          = {
+    real                                         kb                            = 4e5, kt = 400, kp = 5;
+    PreprocessResidue                            rtp_header_settings;
+    bool                                         bRemoveDihedralIfWithImproper = FALSE;
+    bool                                         bGenerateHH14Interactions     = TRUE;
+    bool                                         bKeepAllGeneratedDihedrals    = FALSE;
+    int                                          nrexcl                        = 3;
+    bool                                         bParam                        = TRUE, bRound = TRUE;
+    bool                                         bPairs                        = TRUE, bPBC = TRUE;
+    bool                                         bUsePDBcharge                 = FALSE, bVerbose = FALSE;
+    const char                                  *molnm                         = "ICE";
+    const char                                  *ff                            = "oplsaa";
+    t_pargs                                      pa[]                          = {
         { "-ff",     FALSE, etSTR, {&ff},
           "Force field for your simulation. Type \"select\" for interactive selection." },
         { "-v",      FALSE, etBOOL, {&bVerbose},
@@ -498,9 +495,6 @@ int gmx_x2top(int argc, char *argv[])
     mymol.name = gmx_strdup(molnm);
     mymol.nr   = 1;
 
-    /* Init parameter lists */
-    init_plist(plist);
-
     /* Read coordinates */
     t_topology *top;
     snew(top, 1);