Get rid of clang-tidy warning in do_md/rerun/mimic
authorPascal Merz <pascal.merz@me.com>
Mon, 1 Jul 2019 05:45:18 +0000 (23:45 -0600)
committerPaul Bauer <paul.bauer.q@gmail.com>
Thu, 11 Jul 2019 06:21:15 +0000 (08:21 +0200)
This change silences most of the clang-tidy warnings
"Clang-Tidy: Use of a signed integer operand with a binary
bitwise operator" in do_md, do_rerun and do_mimic. This warning
is triggered when using a signed integer with a binary bitwise
operator, as we do all over the code when encoding / decoding
flags. Such warnings are popping up in other parts of the code,
but this change takes only care of the ones which can be
silenced by changes in the simulator functions and the bit shift
definitions.

Change-Id: I7345e987e91051c9688cb2e8a96026682f025b6b

src/gromacs/fileio/trxio.h
src/gromacs/mdlib/force_flags.h
src/gromacs/mdlib/md_support.h
src/gromacs/mdrun/md.cpp
src/gromacs/mdrun/mimic.cpp
src/gromacs/mdrun/rerun.cpp
src/gromacs/mdtypes/commrec.h

index 9961260a70b68c87bf3d1ccd40e274f3ed66b330..ff65d3e31033a811b58621fefe35c5aa746fc86d 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,2016,2017,2018, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2015,2016,2017,2018,2019, 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.
@@ -194,18 +194,18 @@ int check_times(real t);
  * but a frame might be returned which does not contain the field.
  * When a NEED flag is set, frames not containing the field will be skipped.
  */
-#define TRX_READ_X    (1<<0)
-#define TRX_NEED_X    (1<<1)
-#define TRX_READ_V    (1<<2)
-#define TRX_NEED_V    (1<<3)
-#define TRX_READ_F    (1<<4)
-#define TRX_NEED_F    (1<<5)
+#define TRX_READ_X    (1u<<0u)
+#define TRX_NEED_X    (1u<<1u)
+#define TRX_READ_V    (1u<<2u)
+#define TRX_NEED_V    (1u<<3u)
+#define TRX_READ_F    (1u<<4u)
+#define TRX_NEED_F    (1u<<5u)
 /* Useful for reading natoms from a trajectory without skipping */
-#define TRX_DONT_SKIP (1<<6)
+#define TRX_DONT_SKIP (1u<<6u)
 
 /* For trxframe.not_ok */
-#define HEADER_NOT_OK (1<<0)
-#define DATA_NOT_OK   (1<<1)
+#define HEADER_NOT_OK (1u<<0u)
+#define DATA_NOT_OK   (1u<<1u)
 #define FRAME_NOT_OK  (HEADER_NOT_OK | DATA_NOT_OK)
 
 bool read_first_frame(const gmx_output_env_t *oenv, t_trxstatus **status,
index b90f14503c16eea513949ddb65705be34a3d244a..4b97cca5174fad3163674d05098fe09a86235765 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2012, The GROMACS development team.
- * Copyright (c) 2012,2014,2015,2017, by the GROMACS development team, led by
+ * Copyright (c) 2012,2014,2015,2017,2019, 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.
 /* Flags to tell the force calculation routines what (not) to do */
 
 /* The state has changed, always set unless TPI is used. */
-#define GMX_FORCE_STATECHANGED (1<<0)
+#define GMX_FORCE_STATECHANGED (1u<<0u)
 /* The box might have changed */
-#define GMX_FORCE_DYNAMICBOX   (1<<1)
+#define GMX_FORCE_DYNAMICBOX   (1u<<1u)
 /* Do neighbor searching */
-#define GMX_FORCE_NS           (1<<2)
+#define GMX_FORCE_NS           (1u<<2u)
 /* Calculate listed energies/forces (e.g. bonds, restraints, 1-4, FEP non-bonded) */
-#define GMX_FORCE_LISTED       (1<<4)
+#define GMX_FORCE_LISTED       (1u<<4u)
 /* Calculate non-bonded energies/forces */
-#define GMX_FORCE_NONBONDED    (1<<6)
+#define GMX_FORCE_NONBONDED    (1u<<6u)
 /* Calculate forces (not only energies) */
-#define GMX_FORCE_FORCES       (1<<7)
+#define GMX_FORCE_FORCES       (1u<<7u)
 /* Calculate the virial */
-#define GMX_FORCE_VIRIAL       (1<<8)
+#define GMX_FORCE_VIRIAL       (1u<<8u)
 /* Calculate energies */
-#define GMX_FORCE_ENERGY       (1<<9)
+#define GMX_FORCE_ENERGY       (1u<<9u)
 /* Calculate dHdl */
-#define GMX_FORCE_DHDL         (1<<10)
+#define GMX_FORCE_DHDL         (1u<<10u)
 
 /* Normally one want all energy terms and forces */
 #define GMX_FORCE_ALLFORCES    (GMX_FORCE_LISTED | GMX_FORCE_NONBONDED | GMX_FORCE_FORCES)
index 6a2ca1d059905521f7ba67fd5079a6d1b92b4c57..1ed48e542ce8babea35eb70dd5af2c0bf243775b 100644 (file)
@@ -66,29 +66,29 @@ class SimulationSignaller;
  */
 
 /* we are initializing and not yet in the actual MD loop */
-#define CGLO_INITIALIZATION (1<<1)
+#define CGLO_INITIALIZATION (1u<<1u)
 /* we are computing the kinetic energy from average velocities */
-#define CGLO_EKINAVEVEL     (1<<2)
+#define CGLO_EKINAVEVEL     (1u<<2u)
 /* we are removing the center of mass momenta */
-#define CGLO_STOPCM         (1<<3)
+#define CGLO_STOPCM         (1u<<3u)
 /* bGStat is defined in do_md */
-#define CGLO_GSTAT          (1<<4)
+#define CGLO_GSTAT          (1u<<4u)
 /* Sum the energy terms in global computation */
-#define CGLO_ENERGY         (1<<6)
+#define CGLO_ENERGY         (1u<<6u)
 /* Sum the kinetic energy terms in global computation */
-#define CGLO_TEMPERATURE    (1<<7)
+#define CGLO_TEMPERATURE    (1u<<7u)
 /* Sum the kinetic energy terms in global computation */
-#define CGLO_PRESSURE       (1<<8)
+#define CGLO_PRESSURE       (1u<<8u)
 /* Sum the constraint term in global computation */
-#define CGLO_CONSTRAINT     (1<<9)
+#define CGLO_CONSTRAINT     (1u<<9u)
 /* Reading ekin from the trajectory */
-#define CGLO_READEKIN       (1<<10)
+#define CGLO_READEKIN       (1u<<10u)
 /* we need to reset the ekin rescaling factor here */
-#define CGLO_SCALEEKIN      (1<<11)
+#define CGLO_SCALEEKIN      (1u<<11u)
 /* After a new DD partitioning, we need to set a flag to schedule
  * global reduction of the total number of bonded interactions that
  * will be computed, to check none are missing. */
-#define CGLO_CHECK_NUMBER_OF_BONDED_INTERACTIONS (1<<12)
+#define CGLO_CHECK_NUMBER_OF_BONDED_INTERACTIONS (1u<<12u)
 
 
 /*! \brief Return the number of steps that will take place between
index 4a210e5b151ba0c479a88260f6d3576ab7ce0177..d2e44dbc6090b2ffe0222a32213813cc0aca23e6 100644 (file)
@@ -167,7 +167,7 @@ void gmx::Simulator::do_md()
     gmx_bool                bDoDHDL = FALSE, bDoFEP = FALSE, bDoExpanded = FALSE;
     gmx_bool                do_ene, do_log, do_verbose;
     gmx_bool                bMasterState;
-    int                     force_flags, cglo_flags;
+    unsigned int            force_flags;
     tensor                  force_vir = {{0}}, shake_vir = {{0}}, total_vir = {{0}},
                             tmp_vir   = {{0}}, pres = {{0}};
     int                     i, m;
@@ -437,7 +437,7 @@ void gmx::Simulator::do_md()
 
     if (!ir->bContinuation)
     {
-        if (state->flags & (1 << estV))
+        if (state->flags & (1u << estV))
         {
             auto v = makeArrayRef(state->v);
             /* Set the velocities of vsites, shells and frozen atoms to zero */
@@ -516,10 +516,10 @@ void gmx::Simulator::do_md()
         restore_ekinstate_from_state(cr, ekind, &state_global->ekinstate);
     }
 
-    cglo_flags = (CGLO_INITIALIZATION | CGLO_TEMPERATURE | CGLO_GSTAT
-                  | (EI_VV(ir->eI) ? CGLO_PRESSURE : 0)
-                  | (EI_VV(ir->eI) ? CGLO_CONSTRAINT : 0)
-                  | (hasReadEkinState ? CGLO_READEKIN : 0));
+    unsigned int cglo_flags = (CGLO_INITIALIZATION | CGLO_TEMPERATURE | CGLO_GSTAT
+                               | (EI_VV(ir->eI) ? CGLO_PRESSURE : 0)
+                               | (EI_VV(ir->eI) ? CGLO_CONSTRAINT : 0)
+                               | (hasReadEkinState ? CGLO_READEKIN : 0));
 
     bSumEkinhOld = FALSE;
 
@@ -533,7 +533,7 @@ void gmx::Simulator::do_md()
      */
     for (int cgloIteration = 0; cgloIteration < (bStopCM ? 2 : 1); cgloIteration++)
     {
-        int cglo_flags_iteration = cglo_flags;
+        unsigned int cglo_flags_iteration = cglo_flags;
         if (bStopCM && cgloIteration == 0)
         {
             cglo_flags_iteration |= CGLO_STOPCM;
@@ -1525,7 +1525,7 @@ void gmx::Simulator::do_md()
         /* With all integrators, except VV, we need to retain the pressure
          * at the current step for coupling at the next step.
          */
-        if ((state->flags & (1<<estPRES_PREV)) &&
+        if ((state->flags & (1u<<estPRES_PREV)) &&
             (bGStatEveryStep ||
              (ir->nstpcouple > 0 && step % ir->nstpcouple == 0)))
         {
index cfb472eac69a16ed9675be099167fea5de7a7201..26477d2e28dcd7dac84a21b8abf325e809f3424d 100644 (file)
@@ -146,7 +146,7 @@ void gmx::Simulator::do_mimic()
     double                   t, lam0[efptNR];
     bool                     isLastStep               = false;
     bool                     doFreeEnergyPerturbation = false;
-    int                      force_flags;
+    unsigned int             force_flags;
     tensor                   force_vir, shake_vir, total_vir, pres;
     rvec                     mu_tot;
     gmx_localtop_t           top;
index 53db42363e54ee21a677623d45e3d08886825c81..5694b71524a6fb90272779f3255833ad33712766 100644 (file)
@@ -199,7 +199,7 @@ void gmx::Simulator::do_rerun()
     double                  t, lam0[efptNR];
     bool                    isLastStep               = false;
     bool                    doFreeEnergyPerturbation = false;
-    int                     force_flags;
+    unsigned int            force_flags;
     tensor                  force_vir, shake_vir, total_vir, pres;
     t_trxstatus            *status;
     rvec                    mu_tot;
index 41b5ed9f05bbb967273b5e43f28f5d6f2b4f0c63..2625e5026d79a1efd14b674930df8473b9024ac0 100644 (file)
@@ -46,8 +46,8 @@
 struct mpi_in_place_buf_t;
 struct gmx_domdec_t;
 
-#define DUTY_PP  (1<<0)
-#define DUTY_PME (1<<1)
+#define DUTY_PP  (1u<<0u)
+#define DUTY_PME (1u<<1u)
 
 typedef struct {
     int      bUse;