Fixed an initialization issue in gmx_dipoles.
authorSander Pronk <pronk@kth.se>
Fri, 15 Feb 2013 12:12:53 +0000 (13:12 +0100)
committerSander Pronk <pronk@kth.se>
Fri, 15 Feb 2013 12:22:22 +0000 (13:22 +0100)
This fixes a warning in gcc 4.7

Change-Id: Ief8a057dff24c9a61c20301215a7009c2a16e74a

src/tools/gmx_dipoles.c

index 656cf533f49496e66c4a428d4a59589d2cc2eb5c..fe436dff021bfd494a485f60d71c7f5372e34159 100644 (file)
@@ -812,6 +812,9 @@ static void do_dip(t_topology *top, int ePBC, real volume,
     vol_aver = 0.0;
 
     iVol = -1;
+
+    /* initialize to a negative value so we can see that it wasn't picked up */
+    iMu[XX] = iMu[YY] = iMu[ZZ] = -1;
     if (bMU)
     {
         fmu = open_enx(mufn, "r");
@@ -837,13 +840,16 @@ static void do_dip(t_topology *top, int ePBC, real volume,
                 iMu[ZZ] = i;
             }
         }
+        if (iMu[XX] < 0 || iMu[YY] < 0 || iMu[ZZ] < 0)
+        {
+            gmx_fatal(FARGS,"No index for Mu-X, Mu-Y or Mu-Z energy group.");
+        }
     }
     else
     {
         atom = top->atoms.atom;
         mols = &(top->mols);
     }
-
     if ((iVol == -1) && bMU)
     {
         printf("Using Volume from topology: %g nm^3\n", volume);