Merge branch release-5-0 into release-5-1
authorMark Abraham <mark.j.abraham@gmail.com>
Mon, 8 Feb 2016 07:41:24 +0000 (08:41 +0100)
committerMark Abraham <mark.j.abraham@gmail.com>
Mon, 8 Feb 2016 07:41:24 +0000 (08:41 +0100)
Change-Id: I7795992dcc576dbe9b8cb42db0e95981c2a2e255

src/gromacs/gmxpreprocess/toppush.c
src/gromacs/tools/compare.c

index c9d7e56ead7da0250bd8e22ff3222745f79803b7..68412fe5cf39f04ba77e17f501171a52f7ccbeb4 100644 (file)
@@ -1079,10 +1079,10 @@ push_cmaptype(directive d, t_params bt[], int nral, gpp_atomtype_t at,
               t_bond_atomtype bat, char *line,
               warninp_t wi)
 {
-    const char  *formal = "%s%s%s%s%s%s%s%s";
+    const char  *formal = "%s%s%s%s%s%s%s%s%n";
 
     int          i, j, ft, ftype, nn, nrfp, nrfpA, nrfpB;
-    int          start;
+    int          start, nchar_consumed;
     int          nxcmap, nycmap, ncmap, read_cmap, sl, nct;
     char         s[20], alc[MAXATOMLIST+2][20];
     t_param      p;
@@ -1093,24 +1093,16 @@ push_cmaptype(directive d, t_params bt[], int nral, gpp_atomtype_t at,
     read_cmap = 0;
     start     = 0;
 
-    if ((nn = sscanf(line, formal, alc[0], alc[1], alc[2], alc[3], alc[4], alc[5], alc[6], alc[7])) != nral+3)
+    assert(nral == 5);
+
+    /* Here we can only check for < 8 */
+    if ((nn = sscanf(line, formal, alc[0], alc[1], alc[2], alc[3], alc[4], alc[5], alc[6], alc[7], &nchar_consumed)) < nral+3)
     {
         sprintf(errbuf, "Incorrect number of atomtypes for cmap (%d instead of 5)", nn-1);
         warning_error(wi, errbuf);
         return;
     }
-
-    /* Compute an offset for each line where the cmap parameters start
-     * ie. where the atom types and grid spacing information ends
-     */
-    for (i = 0; i < nn; i++)
-    {
-        start += (int)strlen(alc[i]);
-    }
-
-    /* There are nn-1 spaces between the atom types and the grid spacing info in the cmap.itp file */
-    /* start is the position on the line where we start to read the actual cmap grid data from the itp file */
-    start = start + nn -1;
+    start += nchar_consumed;
 
     ft     = strtol(alc[nral], NULL, 10);
     nxcmap = strtol(alc[nral+1], NULL, 10);
index 385aadce23c800c7a6d94ef4470ace87449c40b3..5edc837bbc6c3f8ec7271e69380bf66b2ad5f344 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014,2015, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2015,2016, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -337,6 +337,29 @@ void cmp_iparm_AB(FILE *fp, const char *s, t_functype ft, t_iparams ip1, real ft
     }
 }
 
+static void cmp_cmap(FILE *fp, const gmx_cmap_t *cmap1, const gmx_cmap_t *cmap2, real ftol, real abstol)
+{
+    cmp_int(fp, "cmap ngrid", -1, cmap1->ngrid, cmap2->ngrid);
+    cmp_int(fp, "cmap grid_spacing", -1, cmap1->grid_spacing, cmap2->grid_spacing);
+    if (cmap1->ngrid == cmap2->ngrid &&
+        cmap1->grid_spacing == cmap2->grid_spacing)
+    {
+        int g;
+
+        for (g = 0; g < cmap1->ngrid; g++)
+        {
+            int i;
+
+            fprintf(fp, "comparing cmap %d\n", g);
+
+            for (i = 0; i < 4*cmap1->grid_spacing*cmap1->grid_spacing; i++)
+            {
+                cmp_real(fp, "", i, cmap1->cmapdata[g].cmap[i], cmap2->cmapdata[g].cmap[i], ftol, abstol);
+            }
+        }
+    }
+}
+
 static void cmp_idef(FILE *fp, t_idef *id1, t_idef *id2, real ftol, real abstol)
 {
     int  i;
@@ -356,6 +379,7 @@ static void cmp_idef(FILE *fp, t_idef *id1, t_idef *id2, real ftol, real abstol)
                       id1->iparams[i], id2->iparams[i], ftol, abstol);
         }
         cmp_real(fp, "fudgeQQ", -1, id1->fudgeQQ, id2->fudgeQQ, ftol, abstol);
+        cmp_cmap(fp, &id1->cmap_grid, &id2->cmap_grid, ftol, abstol);
         for (i = 0; (i < F_NRE); i++)
         {
             cmp_ilist(fp, i, &(id1->il[i]), &(id2->il[i]));