Fix ICC warnings
[alexxy/gromacs.git] / src / gromacs / gmxpreprocess / vsite_parm.c
index 678b3b0876bb5fcf0ff295b2262b9b1a476f7bab..5a1088711a9db6a80d32897c242eebf8ffdcbf9a 100644 (file)
@@ -1,58 +1,58 @@
 /*
+ * This file is part of the GROMACS molecular simulation package.
  *
- *                This source code is part of
- *
- *                 G   R   O   M   A   C   S
- *
- *          GROningen MAchine for Chemical Simulations
- *
- *                        VERSION 3.2.0
- * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others.
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
- * Copyright (c) 2001-2004, The GROMACS development team,
- * check out http://www.gromacs.org for more information.
-
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
+ * Copyright (c) 2001-2004, The GROMACS development team.
+ * Copyright (c) 2013,2014, 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.
+ *
+ * GROMACS is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 2.1
  * of the License, or (at your option) any later version.
  *
- * If you want to redistribute modifications, please consider that
- * scientific software is very special. Version control is crucial -
- * bugs must be traceable. We will be happy to consider code for
- * inclusion in the official distribution, but derived work must not
- * be called official GROMACS. Details are found in the README & COPYING
- * files - if they are missing, get the official version at www.gromacs.org.
+ * GROMACS is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
  *
- * To help us fund GROMACS development, we humbly ask that you cite
- * the papers on the package - you can find them in the top README file.
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with GROMACS; if not, see
+ * http://www.gnu.org/licenses, or write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA.
  *
- * For more info, check our website at http://www.gromacs.org
+ * If you want to redistribute modifications to GROMACS, please
+ * consider that scientific software is very special. Version
+ * control is crucial - bugs must be traceable. We will be happy to
+ * consider code for inclusion in the official distribution, but
+ * derived work must not be called official GROMACS. Details are found
+ * in the README & COPYING files - if they are missing, get the
+ * official version at http://www.gromacs.org.
  *
- * And Hey:
- * Gallium Rubidium Oxygen Manganese Argon Carbon Silicon
+ * To help us fund GROMACS development, we humbly ask that you cite
+ * the research papers on the package. Check out http://www.gromacs.org.
  */
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "gmxpre.h"
+
+#include "vsite_parm.h"
 
-#include <stdio.h>
-#include <math.h>
 #include <assert.h>
+#include <math.h>
+#include <stdio.h>
 #include <string.h>
-#include "vsite_parm.h"
-#include "smalloc.h"
-#include "resall.h"
-#include "add_par.h"
-#include "vec.h"
-#include "toputil.h"
-#include "physics.h"
-#include "index.h"
-#include "names.h"
-#include "gmx_fatal.h"
-#include "string2.h"
-#include "physics.h"
-#include "macros.h"
+
+#include "gromacs/gmxpreprocess/add_par.h"
+#include "gromacs/gmxpreprocess/resall.h"
+#include "gromacs/gmxpreprocess/toputil.h"
+#include "gromacs/legacyheaders/macros.h"
+#include "gromacs/legacyheaders/names.h"
+#include "gromacs/math/units.h"
+#include "gromacs/math/vec.h"
+#include "gromacs/utility/cstringutil.h"
+#include "gromacs/utility/fatalerror.h"
+#include "gromacs/utility/smalloc.h"
 
 typedef struct {
     t_iatom a[4];
@@ -289,7 +289,7 @@ static void print_bad(FILE *fp,
         fprintf(fp, "bonds:");
         for (i = 0; i < nrbond; i++)
         {
-            fprintf(fp, " %u-%u (%g)",
+            fprintf(fp, " %d-%d (%g)",
                     bonds[i].AI+1, bonds[i].AJ+1, bonds[i].c);
         }
         fprintf(fp, "\n");
@@ -299,7 +299,7 @@ static void print_bad(FILE *fp,
         fprintf(fp, "angles:");
         for (i = 0; i < nrang; i++)
         {
-            fprintf(fp, " %u-%u-%u (%g)",
+            fprintf(fp, " %d-%d-%d (%g)",
                     angles[i].AI+1, angles[i].AJ+1,
                     angles[i].AK+1, angles[i].c);
         }
@@ -310,7 +310,7 @@ static void print_bad(FILE *fp,
         fprintf(fp, "idihs:");
         for (i = 0; i < nridih; i++)
         {
-            fprintf(fp, " %u-%u-%u-%u (%g)",
+            fprintf(fp, " %d-%d-%d-%d (%g)",
                     idihs[i].AI+1, idihs[i].AJ+1,
                     idihs[i].AK+1, idihs[i].AL+1, idihs[i].c);
         }
@@ -422,7 +422,7 @@ static gmx_bool calc_vsite3_param(gpp_atomtype_t atype,
         int i;
         for (i = 0; i < 4; i++)
         {
-            fprintf(debug, "atom %u type %s ",
+            fprintf(debug, "atom %d type %s ",
                     param->a[i]+1,
                     get_atomtype_name_AB(&at->atom[param->a[i]], atype));
         }
@@ -493,7 +493,7 @@ static gmx_bool calc_vsite3_param(gpp_atomtype_t atype,
 
     if (debug)
     {
-        fprintf(debug, "params for vsite3 %u: %g %g\n",
+        fprintf(debug, "params for vsite3 %d: %g %g\n",
                 param->AI+1, param->C0, param->C1);
     }
 
@@ -527,7 +527,7 @@ static gmx_bool calc_vsite3fd_param(t_param *param,
 
     if (debug)
     {
-        fprintf(debug, "params for vsite3fd %u: %g %g\n",
+        fprintf(debug, "params for vsite3fd %d: %g %g\n",
                 param->AI+1, param->C0, param->C1);
     }
     return bError;
@@ -562,7 +562,7 @@ static gmx_bool calc_vsite3fad_param(t_param *param,
 
     if (debug)
     {
-        fprintf(debug, "params for vsite3fad %u: %g %g\n",
+        fprintf(debug, "params for vsite3fad %d: %g %g\n",
                 param->AI+1, param->C0, param->C1);
     }
     return bError;
@@ -589,7 +589,7 @@ static gmx_bool calc_vsite3out_param(gpp_atomtype_t atype,
         int i;
         for (i = 0; i < 4; i++)
         {
-            fprintf(debug, "atom %u type %s ",
+            fprintf(debug, "atom %d type %s ",
                     param->a[i]+1, get_atomtype_name_AB(&at->atom[param->a[i]], atype));
         }
         fprintf(debug, "\n");
@@ -674,7 +674,7 @@ static gmx_bool calc_vsite3out_param(gpp_atomtype_t atype,
     }
     if (debug)
     {
-        fprintf(debug, "params for vsite3out %u: %g %g %g\n",
+        fprintf(debug, "params for vsite3out %d: %g %g %g\n",
                 param->AI+1, param->C0, param->C1, param->C2);
     }
     return bError;
@@ -732,7 +732,7 @@ static gmx_bool calc_vsite4fd_param(t_param *param,
         param->C2 = -bij;
         if (debug)
         {
-            fprintf(debug, "params for vsite4fd %u: %g %g %g\n",
+            fprintf(debug, "params for vsite4fd %d: %g %g %g\n",
                     param->AI+1, param->C0, param->C1, param->C2);
         }
     }
@@ -795,7 +795,7 @@ calc_vsite4fdn_param(t_param *param,
 
         if (debug)
         {
-            fprintf(debug, "params for vsite4fdn %u: %g %g %g\n",
+            fprintf(debug, "params for vsite4fdn %d: %g %g %g\n",
                     param->AI+1, param->C0, param->C1, param->C2);
         }
     }
@@ -866,7 +866,7 @@ int set_vsites(gmx_bool bVerbose, t_atoms *atoms, gpp_atomtype_t atype,
                     if (debug)
                     {
                         fprintf(debug, "Found %d bonds, %d angles and %d idihs "
-                                "for virtual site %u (%s)\n", nrbond, nrang, nridih,
+                                "for virtual site %d (%s)\n", nrbond, nrang, nridih,
                                 plist[ftype].param[i].AI+1,
                                 interaction_function[ftype].longname);
                         print_bad(debug, nrbond, bonds, nrang, angles, nridih, idihs);
@@ -998,7 +998,7 @@ static void check_vsite_constraints(t_params *plist,
             atom = ps->param[i].a[k];
             if (vsite_type[atom] != NOTSET)
             {
-                fprintf(stderr, "ERROR: Cannot have constraint (%u-%u) with virtual site (%u)\n",
+                fprintf(stderr, "ERROR: Cannot have constraint (%d-%d) with virtual site (%d)\n",
                         ps->param[i].AI+1, ps->param[i].AJ+1, atom+1);
                 n++;
             }
@@ -1040,7 +1040,7 @@ static void clean_vsite_bonds(t_params *plist, t_pindex pindex[],
         nvsite = 0;
         if (debug)
         {
-            fprintf(debug, "constr %u %u:", ps->param[i].AI+1, ps->param[i].AJ+1);
+            fprintf(debug, "constr %d %d:", ps->param[i].AI+1, ps->param[i].AJ+1);
         }
         for (k = 0; (k < 2) && !bKeep && !bRemove; k++)
         {
@@ -1402,18 +1402,21 @@ static void clean_vsite_angles(t_params *plist, t_pindex pindex[],
 static void clean_vsite_dihs(t_params *plist, t_pindex pindex[],
                              int cftype, int vsite_type[])
 {
-    int          ftype, i, parnr, k, l, m, n, nvsite, kept_i, vsnral;
-    atom_id      atom, constr;
-    atom_id      vsiteatoms[4];
-    gmx_bool     bKeep, bUsed, bPresent;
-    t_params    *ps;
+    int       i, kept_i;
+    t_params *ps;
 
     ps = &(plist[cftype]);
 
-    vsnral = 0;
     kept_i = 0;
     for (i = 0; (i < ps->nr); i++) /* for all dihedrals in the plist */
     {
+        int      ftype, parnr, k, l, m, n, nvsite;
+        int      vsnral = 0;            /* keep the compiler happy */
+        atom_id  atom, constr;
+        atom_id  vsiteatoms[4] = { 0 }; /* init to zero to make gcc4.8 happy */
+        gmx_bool bKeep, bUsed, bPresent;
+
+
         bKeep = FALSE;
         /* check if all virtual sites are constructed from the same atoms */
         nvsite = 0;
@@ -1422,8 +1425,7 @@ static void clean_vsite_dihs(t_params *plist, t_pindex pindex[],
             atom = ps->param[i].a[k];
             if (vsite_type[atom] != NOTSET)
             {
-                nvsite++;
-                if (nvsite == 1)
+                if (nvsite == 0)
                 {
                     /* store construction atoms of first vsite */
                     vsnral = NRAL(pindex[atom].ftype)-1;
@@ -1435,35 +1437,38 @@ static void clean_vsite_dihs(t_params *plist, t_pindex pindex[],
                     }
                     if (debug)
                     {
-                        fprintf(debug, "dih w. vsite: %u %u %u %u\n",
+                        fprintf(debug, "dih w. vsite: %d %d %d %d\n",
                                 ps->param[i].AI+1, ps->param[i].AJ+1,
                                 ps->param[i].AK+1, ps->param[i].AL+1);
-                        fprintf(debug, "vsite %u from: %u %u %u\n",
+                        fprintf(debug, "vsite %d from: %d %d %d\n",
                                 atom+1, vsiteatoms[0]+1, vsiteatoms[1]+1, vsiteatoms[2]+1);
                     }
                 }
                 else
-                /* check if this vsite is constructed from the same atoms */
-                if (vsnral == NRAL(pindex[atom].ftype)-1)
                 {
-                    for (m = 0; (m < vsnral) && !bKeep; m++)
+                    /* check if this vsite is constructed from the same atoms */
+                    if (vsnral == NRAL(pindex[atom].ftype)-1)
                     {
-                        bPresent = FALSE;
-                        constr   =
-                            plist[pindex[atom].ftype].param[pindex[atom].parnr].a[m+1];
-                        for (n = 0; (n < vsnral) && !bPresent; n++)
+                        for (m = 0; (m < vsnral) && !bKeep; m++)
                         {
-                            if (constr == vsiteatoms[n])
+                            bPresent = FALSE;
+                            constr   =
+                                plist[pindex[atom].ftype].param[pindex[atom].parnr].a[m+1];
+                            for (n = 0; (n < vsnral) && !bPresent; n++)
                             {
-                                bPresent = TRUE;
+                                if (constr == vsiteatoms[n])
+                                {
+                                    bPresent = TRUE;
+                                }
+                            }
+                            if (!bPresent)
+                            {
+                                bKeep = TRUE;
                             }
-                        }
-                        if (!bPresent)
-                        {
-                            bKeep = TRUE;
                         }
                     }
                 }
+                nvsite++;
             }
         }
 
@@ -1480,6 +1485,7 @@ static void clean_vsite_dihs(t_params *plist, t_pindex pindex[],
             atom = ps->param[i].a[k];
             if (vsite_type[atom] == NOTSET)
             {
+                /* vsnral will be set here, we don't get here with nvsite==0 */
                 bUsed = FALSE;
                 for (m = 0; (m < vsnral) && !bUsed; m++)
                 {
@@ -1493,7 +1499,7 @@ static void clean_vsite_dihs(t_params *plist, t_pindex pindex[],
                     bKeep = TRUE;
                     if (debug)
                     {
-                        fprintf(debug, "unused atom in dih: %u\n", atom+1);
+                        fprintf(debug, "unused atom in dih: %d\n", atom+1);
                     }
                 }
             }