readability-implicit-bool-conversion 1/2
authorRoland Schulz <roland.schulz@intel.com>
Tue, 14 Aug 2018 04:21:09 +0000 (21:21 -0700)
committerRoland Schulz <roland.schulz@intel.com>
Sat, 18 Aug 2018 08:34:11 +0000 (01:34 -0700)
manual changes

Change-Id: Iad9d6d301b526f79c25e56e7dfdf42144319ed80

53 files changed:
src/gromacs/domdec/domdec.cpp
src/gromacs/essentialdynamics/edsam.cpp
src/gromacs/ewald/pme-redistribute.cpp
src/gromacs/fft/fft.cpp
src/gromacs/fft/fft5d.cpp
src/gromacs/fft/fft_fftw3.cpp
src/gromacs/fileio/checkpoint.cpp
src/gromacs/fileio/groio.cpp
src/gromacs/fileio/tpxio.cpp
src/gromacs/fileio/tpxio.h
src/gromacs/gmxana/gmx_anadock.cpp
src/gromacs/gmxana/gmx_bar.cpp
src/gromacs/gmxana/gmx_chi.cpp
src/gromacs/gmxana/gmx_hbond.cpp
src/gromacs/gmxana/gmx_msd.cpp
src/gromacs/gmxana/gmx_rotacf.cpp
src/gromacs/gmxana/gmx_trjconv.cpp
src/gromacs/gmxana/gmx_tune_pme.cpp
src/gromacs/gmxana/gmx_wham.cpp
src/gromacs/gmxana/nsfactor.cpp
src/gromacs/gmxlib/nonbonded/nonbonded.cpp
src/gromacs/gmxpreprocess/convparm.cpp
src/gromacs/gmxpreprocess/gen_ad.cpp
src/gromacs/gmxpreprocess/gen_vsite.cpp
src/gromacs/gmxpreprocess/gmxcpp.cpp
src/gromacs/gmxpreprocess/gpp_nextnb.cpp
src/gromacs/gmxpreprocess/grompp.cpp
src/gromacs/gmxpreprocess/pdb2top.cpp
src/gromacs/gmxpreprocess/readir.cpp
src/gromacs/gmxpreprocess/resall.cpp
src/gromacs/gmxpreprocess/topio.cpp
src/gromacs/gmxpreprocess/toppush.cpp
src/gromacs/hardware/identifyavx512fmaunits.cpp
src/gromacs/imd/imd.cpp
src/gromacs/listed-forces/pairs.cpp
src/gromacs/listed-forces/position-restraints.cpp
src/gromacs/math/utilities.cpp
src/gromacs/math/utilities.h
src/gromacs/mdlib/forcerec.cpp
src/gromacs/mdlib/lincs.cpp
src/gromacs/mdlib/membed.cpp
src/gromacs/mdlib/ns.cpp
src/gromacs/mdlib/sim_util.cpp
src/gromacs/mdlib/sim_util.h
src/gromacs/mdlib/stat.cpp
src/gromacs/mdlib/vsite.cpp
src/gromacs/mdtypes/awh-history.h
src/gromacs/mdtypes/inputrec.cpp
src/gromacs/mdtypes/inputrec.h
src/gromacs/swap/swapcoords.cpp
src/gromacs/topology/index.cpp
src/gromacs/topology/residuetypes.cpp
src/gromacs/trajectoryanalysis/modules/freevolume.cpp

index 58ce797fb5aac9d1b797c0a9c6c3f6cee9b3b768..de012d0b26e95c7db27b16dbbb311fa011e325a9 100644 (file)
@@ -2815,7 +2815,7 @@ static void setup_neighbor_relations(gmx_domdec_t *dd)
 static void make_pp_communicator(FILE                 *fplog,
                                  gmx_domdec_t         *dd,
                                  t_commrec gmx_unused *cr,
-                                 int gmx_unused        reorder)
+                                 bool gmx_unused       reorder)
 {
 #if GMX_MPI
     gmx_domdec_comm_t *comm;
@@ -2838,7 +2838,7 @@ static void make_pp_communicator(FILE                 *fplog,
         {
             periods[i] = TRUE;
         }
-        MPI_Cart_create(cr->mpi_comm_mygroup, DIM, dd->nc, periods, reorder,
+        MPI_Cart_create(cr->mpi_comm_mygroup, DIM, dd->nc, periods, static_cast<int>(reorder),
                         &comm_cart);
         /* We overwrite the old communicator with the new cartesian one */
         cr->mpi_comm_mygroup = comm_cart;
@@ -2964,7 +2964,7 @@ static void receive_ddindex2simnodeid(gmx_domdec_t         *dd,
 
 static void split_communicator(FILE *fplog, t_commrec *cr, gmx_domdec_t *dd,
                                DdRankOrder gmx_unused rankOrder,
-                               int gmx_unused reorder)
+                               bool gmx_unused reorder)
 {
     gmx_domdec_comm_t *comm;
     int                i;
@@ -3027,7 +3027,7 @@ static void split_communicator(FILE *fplog, t_commrec *cr, gmx_domdec_t *dd,
         {
             periods[i] = TRUE;
         }
-        MPI_Cart_create(cr->mpi_comm_mysim, DIM, comm->ntot, periods, reorder,
+        MPI_Cart_create(cr->mpi_comm_mysim, DIM, comm->ntot, periods, static_cast<int>(reorder),
                         &comm_cart);
         MPI_Comm_rank(comm_cart, &rank);
         if (MASTER(cr) && rank != 0)
@@ -3120,7 +3120,7 @@ static void make_dd_communicators(FILE *fplog, t_commrec *cr,
                                   gmx_domdec_t *dd, DdRankOrder ddRankOrder)
 {
     gmx_domdec_comm_t *comm;
-    int                CartReorder;
+    bool               CartReorder;
 
     comm = dd->comm;
 
@@ -3133,7 +3133,7 @@ static void make_dd_communicators(FILE *fplog, t_commrec *cr,
      * Real reordering is only supported on very few architectures,
      * Blue Gene is one of them.
      */
-    CartReorder = (getenv("GMX_NO_CART_REORDER") == nullptr);
+    CartReorder = getenv("GMX_NO_CART_REORDER") == nullptr;
 
     if (cr->npmenodes > 0)
     {
@@ -4551,7 +4551,7 @@ static void dd_dlb_set_should_check_whether_to_turn_dlb_on(gmx_domdec_t *dd, gmx
     {
         dd->comm->bCheckWhetherToTurnDlbOn = bValue;
 
-        if (bValue == TRUE)
+        if (bValue)
         {
             /* Store the DD partitioning count, so we can ignore cycle counts
              * over the next nstlist steps, which are often slower.
index 2eb01c63f1d0c97cba77e22c55f7f00ebd302793..3b35f9a00e743420351cc4a6202e11c1b78fd006 100644 (file)
@@ -887,7 +887,7 @@ static void do_single_flood(
     /* Project fitted structure onto supbspace -> store in edi->flood.vecs.xproj */
     project_to_eigvectors(buf->xcoll, &edi->flood.vecs, *edi);
 
-    if (FALSE == edi->flood.bConstForce)
+    if (!edi->flood.bConstForce)
     {
         /* Compute Vfl(x) from flood.xproj */
         edi->flood.Vfl = flood_energy(edi, step);
@@ -1339,6 +1339,10 @@ static int read_checked_edint(FILE *file, const char *label)
     return idum;
 }
 
+static bool read_checked_edbool(FILE *file, const char *label)
+{
+    return read_checked_edint(file, label) != 0;
+}
 
 static int read_edint(FILE *file, bool *bEOF)
 {
@@ -1661,8 +1665,8 @@ void read_edi(FILE* in, t_edpar *edi, int nr_mdatoms, bool hasConstForceFlooding
     }
 
     /* Done checking. For the rest we blindly trust the input */
-    edi->fitmas          = read_checked_edint(in, "FITMAS");
-    edi->pcamas          = read_checked_edint(in, "ANALYSIS_MAS");
+    edi->fitmas          = read_checked_edbool(in, "FITMAS");
+    edi->pcamas          = read_checked_edbool(in, "ANALYSIS_MAS");
     edi->outfrq          = read_checked_edint(in, "OUTFRQ");
     edi->maxedsteps      = read_checked_edint(in, "MAXLEN");
     edi->slope           = read_checked_edreal(in, "SLOPECRIT");
@@ -1674,10 +1678,10 @@ void read_edi(FILE* in, t_edpar *edi, int nr_mdatoms, bool hasConstForceFlooding
     edi->flood.constEfl  = read_checked_edreal(in, "EFL_NULL");
     edi->flood.alpha2    = read_checked_edreal(in, "ALPHA2");
     edi->flood.kT        = read_checked_edreal(in, "KT");
-    edi->flood.bHarmonic = read_checked_edint(in, "HARMONIC");
+    edi->flood.bHarmonic = read_checked_edbool(in, "HARMONIC");
     if (hasConstForceFlooding)
     {
-        edi->flood.bConstForce = read_checked_edint(in, "CONST_FORCE_FLOODING");
+        edi->flood.bConstForce = read_checked_edbool(in, "CONST_FORCE_FLOODING");
     }
     else
     {
@@ -2813,7 +2817,7 @@ std::unique_ptr<gmx::EssentialDynamics> init_edsam(
             }
 
             /* process structure that will serve as origin of expansion circle */
-            if ( (eEDflood == ed->eEDtype) && (FALSE == edi->flood.bConstForce) )
+            if (eEDflood == ed->eEDtype && !edi->flood.bConstForce)
             {
                 fprintf(stderr, "ED: Setting center of flooding potential (0 = average structure)\n");
             }
@@ -2838,7 +2842,7 @@ std::unique_ptr<gmx::EssentialDynamics> init_edsam(
 
                 rad_project(*edi, &edi->sori.x[avindex], &edi->vecs.radacc);
                 rad_project(*edi, &edi->sori.x[avindex], &edi->vecs.radfix);
-                if ( (eEDflood == ed->eEDtype) && (FALSE == edi->flood.bConstForce) )
+                if (eEDflood == ed->eEDtype && !edi->flood.bConstForce)
                 {
                     fprintf(stderr, "ED: The ORIGIN structure will define the flooding potential center.\n");
                     /* Set center of flooding potential to the ORIGIN structure */
@@ -2852,7 +2856,7 @@ std::unique_ptr<gmx::EssentialDynamics> init_edsam(
             {
                 rad_project(*edi, xstart, &edi->vecs.radacc);
                 rad_project(*edi, xstart, &edi->vecs.radfix);
-                if ( (eEDflood == ed->eEDtype) && (FALSE == edi->flood.bConstForce) )
+                if (eEDflood == ed->eEDtype && !edi->flood.bConstForce)
                 {
                     if (edi->flood.bHarmonic)
                     {
@@ -2875,7 +2879,7 @@ std::unique_ptr<gmx::EssentialDynamics> init_edsam(
                 }
             }
             /* For convenience, output the center of the flooding potential for the eigenvectors */
-            if ( (eEDflood == ed->eEDtype) && (FALSE == edi->flood.bConstForce) )
+            if (eEDflood == ed->eEDtype && !edi->flood.bConstForce)
             {
                 for (i = 0; i < edi->flood.vecs.neig; i++)
                 {
index e0b8defda5f6de75c167384ede589e2e2696edf0..bbef6bf975ae20594779900ba36e1e1be0afd84c 100644 (file)
@@ -223,7 +223,7 @@ static void pme_dd_sendrecv(pme_atomcomm_t gmx_unused *atc,
     int        dest, src;
     MPI_Status stat;
 
-    if (bBackward == FALSE)
+    if (!bBackward)
     {
         dest = atc->node_dest[shift];
         src  = atc->node_src[shift];
index 849947d9df692bd8b47ee3218d09f74cfeaffea7..3769247de4cb73e313eaa652141c65a4420a9f39 100644 (file)
@@ -181,7 +181,8 @@ int gmx_fft_transpose_2d(t_complex *          in_data,
                          int                  nx,
                          int                  ny)
 {
-    int        i, j, k, im, n, ncount, done1, done2;
+    int        i, j, k, im, n, ncount;
+    bool       done1, done2;
     int        i1, i1c, i2, i2c, kmi, max;
 
     t_complex  tmp1, tmp2, tmp3;
@@ -263,7 +264,7 @@ int gmx_fft_transpose_2d(t_complex *          in_data,
     i  = 1;
     im = ny;
 
-    done1 = 0;
+    done1 = false;
     do
     {
         i1      = i;
@@ -274,7 +275,7 @@ int gmx_fft_transpose_2d(t_complex *          in_data,
         tmp2.re = data[i1c].re;
         tmp2.im = data[i1c].im;
 
-        done2 = 0;
+        done2 = false;
         do
         {
             i2  = ny*i1-k*(i1/nx);
@@ -290,7 +291,7 @@ int gmx_fft_transpose_2d(t_complex *          in_data,
             ncount += 2;
             if (i2 == i)
             {
-                done2 = 1;
+                done2 = true;
             }
             else if (i2 == kmi)
             {
@@ -300,7 +301,7 @@ int gmx_fft_transpose_2d(t_complex *          in_data,
                 tmp1.im = tmp2.im;
                 tmp2.re = tmp3.re;
                 tmp2.im = tmp3.im;
-                done2   = 1;
+                done2   = true;
             }
             else
             {
@@ -321,11 +322,11 @@ int gmx_fft_transpose_2d(t_complex *          in_data,
 
         if (ncount >= n)
         {
-            done1 = 1;
+            done1 = true;
         }
         else
         {
-            done2 = 0;
+            done2 = false;
             do
             {
                 max = k-i;
@@ -347,12 +348,12 @@ int gmx_fft_transpose_2d(t_complex *          in_data,
                         }
                         if (i2 == i)
                         {
-                            done2 = 1;
+                            done2 = true;
                         }
                     }
                     else if (!move[i])
                     {
-                        done2 = 1;
+                        done2 = true;
                     }
                 }
             }
index 3e0cb7857777ffbd7af8105123c4e509fd31fd59..d7755c653d057815f811b0a28c946cbe3818a980 100644 (file)
@@ -146,7 +146,8 @@ static int vmax(const int* a, int s)
 fft5d_plan fft5d_plan_3d(int NG, int MG, int KG, MPI_Comm comm[2], int flags, t_complex** rlin, t_complex** rlout, t_complex** rlout2, t_complex** rlout3, int nthreads, gmx::PinningPolicy realGridAllocationPinningPolicy)
 {
 
-    int        P[2], bMaster, prank[2], i, t;
+    int        P[2], prank[2], i, t;
+    bool       bMaster;
     int        rNG, rMG, rKG;
     int       *N0 = nullptr, *N1 = nullptr, *M0 = nullptr, *M1 = nullptr, *K0 = nullptr, *K1 = nullptr, *oN0 = nullptr, *oN1 = nullptr, *oM0 = nullptr, *oM1 = nullptr, *oK0 = nullptr, *oK1 = nullptr;
     int        N[3], M[3], K[3], pN[3], pM[3], pK[3], oM[3], oK[3], *iNin[3] = {nullptr}, *oNin[3] = {nullptr}, *iNout[3] = {nullptr}, *oNout[3] = {nullptr};
@@ -182,7 +183,7 @@ fft5d_plan fft5d_plan_3d(int NG, int MG, int KG, MPI_Comm comm[2], int flags, t_
         prank[1] = 0;
     }
 
-    bMaster = (prank[0] == 0 && prank[1] == 0);
+    bMaster = prank[0] == 0 && prank[1] == 0;
 
 
     if (debug)
index 155ca0dcfa740399de7a86d7f811a1b1767aa636..69f314cfe2fba5753fbc347740914afc913a252a 100644 (file)
@@ -442,9 +442,9 @@ gmx_fft_1d               (gmx_fft_t                  fft,
                           void *                     in_data,
                           void *                     out_data)
 {
-    int           aligned   = (((size_t(in_data) | size_t(out_data)) & 0xf) == 0);
-    int           inplace   = (in_data == out_data);
-    int           isforward = (dir == GMX_FFT_FORWARD);
+    bool          aligned   = (((size_t(in_data) | size_t(out_data)) & 0xf) == 0);
+    bool          inplace   = (in_data == out_data);
+    bool          isforward = (dir == GMX_FFT_FORWARD);
 
     /* Some checks */
     if ( (fft->real_transform == 1) || (fft->ndim != 1) ||
@@ -476,9 +476,9 @@ gmx_fft_1d_real          (gmx_fft_t                  fft,
                           void *                     in_data,
                           void *                     out_data)
 {
-    int           aligned   = (((size_t(in_data) | size_t(out_data)) & 0xf) == 0);
-    int           inplace   = (in_data == out_data);
-    int           isforward = (dir == GMX_FFT_REAL_TO_COMPLEX);
+    bool          aligned   = (((size_t(in_data) | size_t(out_data)) & 0xf) == 0);
+    bool          inplace   = (in_data == out_data);
+    bool          isforward = (dir == GMX_FFT_REAL_TO_COMPLEX);
 
     /* Some checks */
     if ( (fft->real_transform != 1) || (fft->ndim != 1) ||
@@ -517,9 +517,9 @@ gmx_fft_2d_real          (gmx_fft_t                  fft,
                           void *                     in_data,
                           void *                     out_data)
 {
-    int           aligned   = (((size_t(in_data) | size_t(out_data)) & 0xf) == 0);
-    int           inplace   = (in_data == out_data);
-    int           isforward = (dir == GMX_FFT_REAL_TO_COMPLEX);
+    bool          aligned   = (((size_t(in_data) | size_t(out_data)) & 0xf) == 0);
+    bool          inplace   = (in_data == out_data);
+    bool          isforward = (dir == GMX_FFT_REAL_TO_COMPLEX);
 
     /* Some checks */
     if ( (fft->real_transform != 1) || (fft->ndim != 2) ||
index 3c2b275b75a2ddb55d9c0a2300b6c0de6a3bd107..ecf02b9a346daa3fa637d4cfb30d46752ce6e87d 100644 (file)
@@ -294,6 +294,18 @@ static void do_cpt_int_err(XDR *xd, const char *desc, int *i, FILE *list)
     }
 }
 
+static void do_cpt_bool_err(XDR *xd, const char *desc, bool *b, FILE *list)
+{
+    int i   = static_cast<int>(*b);
+
+    if (do_cpt_int(xd, desc, &i, list) < 0)
+    {
+        cp_error();
+    }
+
+    *b = (i != 0);
+}
+
 static void do_cpt_step_err(XDR *xd, const char *desc, int64_t *i, FILE *list)
 {
     char   buf[STEPSTRSIZE];
@@ -1573,9 +1585,9 @@ static int do_cpt_awh_bias(XDR *xd, gmx_bool bRead,
             switch (i)
             {
                 case eawhhIN_INITIAL:
-                    do_cpt_int_err(xd, eawhh_names[i], &state->in_initial, list); break;
+                    do_cpt_bool_err(xd, eawhh_names[i], &state->in_initial, list); break;
                 case eawhhEQUILIBRATEHISTOGRAM:
-                    do_cpt_int_err(xd, eawhh_names[i], &state->equilibrateHistogram, list); break;
+                    do_cpt_bool_err(xd, eawhh_names[i], &state->equilibrateHistogram, list); break;
                 case eawhhHISTSIZE:
                     do_cpt_double_err(xd, eawhh_names[i], &state->histSize, list); break;
                 case eawhhNPOINTS:
index 8833b4b3d708dff2ae7f163083952887aa494e93..8038330369f3f0f434f1ad80583f722b48d0e931 100644 (file)
@@ -325,13 +325,13 @@ void gmx_gro_read_conf(const char *infile,
 static gmx_bool gmx_one_before_eof(FILE *fp)
 {
     char     data[4];
-    gmx_bool beof;
+    gmx_bool beof = fread(data, 1, 1, fp) != 1;
 
-    if ((beof = fread(data, 1, 1, fp)) == 1)
+    if (!beof)
     {
         gmx_fseek(fp, -1, SEEK_CUR);
     }
-    return !beof;
+    return beof;
 }
 
 gmx_bool gro_next_x_or_v(FILE *status, t_trxframe *fr)
index 714a00033def8717366fc84eb06fc115a1f8cade..3c79f2603872d2d9246acf96fcdf6beb31432668 100644 (file)
@@ -1465,7 +1465,7 @@ static void do_inputrec(t_fileio *fio, t_inputrec *ir, gmx_bool bRead,
     if (file_version >= 74)
     {
         gmx_fio_do_gmx_bool(fio, ir->bRot);
-        if (ir->bRot == TRUE)
+        if (ir->bRot)
         {
             if (bRead)
             {
@@ -1483,7 +1483,7 @@ static void do_inputrec(t_fileio *fio, t_inputrec *ir, gmx_bool bRead,
     if (file_version >= tpxv_InteractiveMolecularDynamics)
     {
         gmx_fio_do_gmx_bool(fio, ir->bIMD);
-        if (TRUE == ir->bIMD)
+        if (ir->bIMD)
         {
             if (bRead)
             {
@@ -2694,12 +2694,12 @@ static void do_tpxheader(t_fileio *fio, gmx_bool bRead, t_tpxheader *tpx,
         gmx_fio_do_int(fio, tpx->fep_state);
     }
     gmx_fio_do_real(fio, tpx->lambda);
-    gmx_fio_do_int(fio, tpx->bIr);
-    gmx_fio_do_int(fio, tpx->bTop);
-    gmx_fio_do_int(fio, tpx->bX);
-    gmx_fio_do_int(fio, tpx->bV);
-    gmx_fio_do_int(fio, tpx->bF);
-    gmx_fio_do_int(fio, tpx->bBox);
+    gmx_fio_do_gmx_bool(fio, tpx->bIr);
+    gmx_fio_do_gmx_bool(fio, tpx->bTop);
+    gmx_fio_do_gmx_bool(fio, tpx->bX);
+    gmx_fio_do_gmx_bool(fio, tpx->bV);
+    gmx_fio_do_gmx_bool(fio, tpx->bF);
+    gmx_fio_do_gmx_bool(fio, tpx->bBox);
 
     if ((fileGeneration > tpx_generation))
     {
@@ -2726,10 +2726,10 @@ static int do_tpx(t_fileio *fio, gmx_bool bRead,
         tpx.ngtc      = state->ngtc;
         tpx.fep_state = state->fep_state;
         tpx.lambda    = state->lambda[efptFEP];
-        tpx.bIr       = (ir       != nullptr);
-        tpx.bTop      = (mtop     != nullptr);
-        tpx.bX        = (state->flags & (1 << estX));
-        tpx.bV        = (state->flags & (1 << estV));
+        tpx.bIr       = ir       != nullptr;
+        tpx.bTop      = mtop     != nullptr;
+        tpx.bX        = (state->flags & (1 << estX)) != 0;
+        tpx.bV        = (state->flags & (1 << estV)) != 0;
         tpx.bF        = FALSE;
         tpx.bBox      = TRUE;
     }
index 1e06ad67bac6c9c535dd1cdf0bac928e3c30411d..071bcab760477c89ce320528fe2ca559d7a52b08 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, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2015,2016,2017,2018, 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.
@@ -52,12 +52,12 @@ struct t_topology;
 
 struct t_tpxheader
 {
-    int   bIr;       /* Non zero if input_rec is present               */
-    int   bBox;      /* Non zero if a box is present                   */
-    int   bTop;      /* Non zero if a topology is present              */
-    int   bX;        /* Non zero if coordinates are present            */
-    int   bV;        /* Non zero if velocities are present             */
-    int   bF;        /* Non zero if forces are present (no longer
+    bool  bIr;       /* Non zero if input_rec is present               */
+    bool  bBox;      /* Non zero if a box is present                   */
+    bool  bTop;      /* Non zero if a topology is present              */
+    bool  bX;        /* Non zero if coordinates are present            */
+    bool  bV;        /* Non zero if velocities are present             */
+    bool  bF;        /* Non zero if forces are present (no longer
                         supported, but retained so old .tpr can be read) */
 
     int   natoms;    /* The total number of atoms                      */
index f108e95935bf4844f307a1ec5357cdb6524d223d..f9fa53e03340a32fc4b5e11e933acf7bd5872274 100644 (file)
@@ -112,7 +112,7 @@ static t_pdbfile **read_em_all(const char *fn, int *npdbf)
     do
     {
         sprintf(name, "%s_%d.pdb", buf, i+1);
-        if ((bExist = gmx_fexist(name)) == TRUE)
+        if ((bExist = gmx_fexist(name)))
         {
             pdbf[i]        = read_pdbf(name);
             pdbf[i]->index = i+1;
index af0530c08dd026f1991c0479fcbaff1124ca12c7..76bd921c055289747464bfc57b94518f2a361a67 100644 (file)
@@ -477,7 +477,7 @@ static int lambda_vec_cmp_foreign(const lambda_vec_t *a,
         {
             return (a->dhdl >= 0) ? 1 : -1;
         }
-        return a->dhdl > b->dhdl;
+        return 0;
     }
 
     /* neither has an index, so we can only sort on the lambda components,
index 93c2a5d235c61128ce469fc5fc6f8a3a7438d054..eaa94f475b78df3f04e41c39ef492763a8498377 100644 (file)
@@ -927,7 +927,7 @@ static void do_rama(int nf, int nlist, t_dlist dlist[], real **dih,
                 fprintf(fp, "%10g  %10g\n", phi, psi);
                 if (bViol)
                 {
-                    fprintf(gp, "%d\n", int{(bAllowed(dih[Phi][j], RAD2DEG*dih[Psi][j]) == FALSE)} );
+                    fprintf(gp, "%d\n", static_cast<int>(!bAllowed(dih[Phi][j], RAD2DEG*dih[Psi][j])) );
                 }
                 if (bOm)
                 {
index 157d53da359a49946d0e1556a489106ea9d62800..b2bf4057c5e6d102238e402766dc9e1fe0d74148 100644 (file)
@@ -1357,7 +1357,7 @@ static int is_hbond(t_hbdata *hb, int grpd, int grpa, int d, int a,
  * Will do some more testing before removing the function entirely.
  * - Erik Marklund, MAY 10 2010 */
 static void do_merge(t_hbdata *hb, int ntmp,
-                     unsigned int htmp[], unsigned int gtmp[],
+                     bool htmp[], bool gtmp[],
                      t_hbond *hb0, t_hbond *hb1)
 {
     /* Here we need to make sure we're treating periodicity in
@@ -1373,8 +1373,8 @@ static void do_merge(t_hbdata *hb, int ntmp,
     /* Initiate tmp arrays */
     for (m = 0; (m < ntmp); m++)
     {
-        htmp[m] = 0;
-        gtmp[m] = 0;
+        htmp[m] = false;
+        gtmp[m] = false;
     }
     /* Fill tmp arrays with values due to first HB */
     /* Once again '<' had to be replaced with '<='
@@ -1420,7 +1420,7 @@ static void do_merge(t_hbdata *hb, int ntmp,
 static void merge_hb(t_hbdata *hb, gmx_bool bTwo, gmx_bool bContact)
 {
     int           i, inrnew, indnew, j, ii, jj, id, ia, ntmp;
-    unsigned int *htmp, *gtmp;
+    bool         *htmp, *gtmp;
     t_hbond      *hb0, *hb1;
 
     inrnew = hb->nrhb;
@@ -2507,7 +2507,7 @@ int gmx_hbond(int argc, char *argv[])
     t_rgb                 hbrgb [HB_NR] = { {1, 1, 1}, {1, 0, 0},   {0, 0, 1},    {1, 0, 1} };
 
     t_trxstatus          *status;
-    int                   trrStatus = 1;
+    bool                  trrStatus = true;
     t_topology            top;
     t_pargs              *ppa;
     int                   npargs, natoms, nframes = 0, shatom;
index 9a13ea723815fe54e4a9a5fe87da2dc075907f1a..3d4e240a2f77977eac6bdcc73f60310f9ee51faf 100644 (file)
@@ -917,7 +917,7 @@ static void do_corr(const char *trx_file, const char *ndx_file, const char *msd_
                     beginfit, endfit);
 
     nat_trx =
-        corr_loop(msd, trx_file, top, ePBC, mol_file ? gnx[0] : false, gnx, index,
+        corr_loop(msd, trx_file, top, ePBC, mol_file ? gnx[0] != 0 : false, gnx, index,
                   (mol_file != nullptr) ? calc1_mol : (bMW ? calc1_mw : calc1_norm),
                   bTen, gnx_com, index_com, dt, t_pdb,
                   pdb_file ? &x : nullptr, box, oenv);
index 771efcaf656333dc1ce68581ce12d9bc8d1473ff..be825a4103cf526ac76a83b58705db42f3278852 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, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2015,2016,2017,2018, 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.
@@ -176,7 +176,7 @@ int gmx_rotacf(int argc, char *argv[])
         /* Compute crossproducts for all vectors, if triplets.
          * else, just get the vectors in case of doublets.
          */
-        if (bVec == FALSE)
+        if (!bVec)
         {
             for (i = 0; (i < nvec); i++)
             {
index 55771c8e17bccb0378c6208a2d69dbaaeedff215..ebce1d37e643fc9c03dae9b844aa9f2a7b649941 100644 (file)
@@ -1442,7 +1442,7 @@ int gmx_trjconv(int argc, char *argv[])
                 if (bSetBox)
                 {
                     /* generate new box */
-                    if (fr.bBox == FALSE)
+                    if (!fr.bBox)
                     {
                         clear_mat(fr.box);
                     }
@@ -1454,7 +1454,7 @@ int gmx_trjconv(int argc, char *argv[])
                         }
                         else
                         {
-                            if (fr.bBox == FALSE)
+                            if (!fr.bBox)
                             {
                                 gmx_fatal(FARGS, "Cannot preserve a box that does not exist.\n");
                             }
index 15e63965b3c56c02bddc6e536208c88bc987d976..3378600db8b1c1415368b85aa29518a5e27ab1b3 100644 (file)
@@ -858,7 +858,7 @@ static void make_benchmark_tprs(
         int64_t               statesteps,      /* Step counter in checkpoint file               */
         real                  rmin,            /* Minimal Coulomb radius                        */
         real                  rmax,            /* Maximal Coulomb radius                        */
-        real                  bScaleRvdw,      /* Scale rvdw along with rcoulomb                */
+        bool                  bScaleRvdw,      /* Scale rvdw along with rcoulomb                */
         const int            *ntprs,           /* No. of TPRs to write, each with a different
                                                   rcoulomb and fourierspacing                   */
         t_inputinfo          *info,            /* Contains information about mdp file options   */
@@ -1905,7 +1905,7 @@ static void create_command_line_snippets(
         sprintf(strbuf, "-deffnm %s ", deffnm);
         add_to_string(cmd_args_launch, strbuf);
     }
-    if (FALSE == bAppendFiles)
+    if (!bAppendFiles)
     {
         add_to_string(cmd_args_launch, "-noappend ");
     }
index d9f171f94373b7353de060011704397ebaeee88c..1b8929506f901cc3aacb8bad77b08bc15c55e14b 100644 (file)
@@ -900,7 +900,7 @@ static void setup_acc_wham(const double *profile, t_UmbrellaWindow * window, int
                 contrib1                 = profile[k]*std::exp(-U/(BOLTZ*opt->Temperature));
                 contrib2                 = window[i].N[j]*std::exp(-U/(BOLTZ*opt->Temperature) + window[i].z[j]);
                 window[i].bContrib[j][k] = (contrib1 > wham_contrib_lim || contrib2 > wham_contrib_lim);
-                bAnyContrib              = (bAnyContrib | window[i].bContrib[j][k]);
+                bAnyContrib              = bAnyContrib || window[i].bContrib[j][k];
                 if (window[i].bContrib[j][k])
                 {
                     nContrib++;
@@ -2205,7 +2205,7 @@ static void read_pull_xf(const char *fn, t_UmbrellaHeader * header,
     snew(nColCOMCrd,  header->npullcrds);
     snew(nColRefCrd,  header->npullcrds);
 
-    if (opt->bPullx == FALSE)
+    if (!opt->bPullx)
     {
         /* pullf reading: simply one column per coordinate */
         for (g = 0; g < header->npullcrds; g++)
@@ -2332,7 +2332,7 @@ static void read_pull_xf(const char *fn, t_UmbrellaHeader * header,
            all pull groups from header (tpr file) may be used in window variable */
         for (g = 0, gUsed = 0; g < header->npullcrds; ++g)
         {
-            if (coordsel && (coordsel->bUse[g] == FALSE))
+            if (coordsel && !coordsel->bUse[g])
             {
                 continue;
             }
@@ -2392,7 +2392,7 @@ static void read_pull_xf(const char *fn, t_UmbrellaHeader * header,
             for (g = 0; g < header->npullcrds; ++g)
             {
                 /* was this group selected for application in WHAM? */
-                if (coordsel && (coordsel->bUse[g] == FALSE))
+                if (coordsel && !coordsel->bUse[g])
                 {
                     continue;
                 }
@@ -2969,7 +2969,8 @@ static void computeAverageForce(t_UmbrellaWindow *window, int nWindows, t_Umbrel
 static void  checkReactionCoordinateCovered(t_UmbrellaWindow *window, int nwins,
                                             t_UmbrellaOptions *opt)
 {
-    int  i, ig, j, bins = opt->bins, bBoundary;
+    int  i, ig, j, bins = opt->bins;
+    bool bBoundary;
     real avcount = 0, z, relcount, *count;
     snew(count, opt->bins);
 
@@ -2989,7 +2990,7 @@ static void  checkReactionCoordinateCovered(t_UmbrellaWindow *window, int nwins,
     {
         relcount  = count[j]/avcount;
         z         = (j+0.5)*opt->dz+opt->min;
-        bBoundary = ( j<bins/20 || (bins-j)>bins/20 );
+        bBoundary = j<bins/20 || (bins-j)>bins/20;
         /* check for bins with no data */
         if (count[j] == 0)
         {
index 92e216526ea61d87ce244c4b974eedfd00dfd3cf..cbcd25ab3bb729e1bbae7641c358d9201c7ec914 100644 (file)
@@ -68,7 +68,7 @@ void check_mcover(real mcover)
     {
         gmx_fatal(FARGS, "mcover should be -1 or (0,1]");
     }
-    else if ((mcover < 0)&(mcover != -1))
+    else if ((mcover < 0) && (mcover != -1))
     {
         gmx_fatal(FARGS, "mcover should be -1 or (0,1]");
     }
index 470c61763e84eb36eab48b7a346aea7b4793de44..1ba0e3d24122d6b839bab718f8b630245045d6ef 100644 (file)
@@ -111,14 +111,14 @@ gmx_nonbonded_setup(t_forcerec *   fr,
 {
     tMPI_Thread_mutex_lock(&nonbonded_setup_mutex);
     /* Here we are guaranteed only one thread made it. */
-    if (nonbonded_setup_done == FALSE)
+    if (!nonbonded_setup_done)
     {
-        if (bGenericKernelOnly == FALSE)
+        if (!bGenericKernelOnly)
         {
             /* Add the generic kernels to the structure stored statically in nb_kernel.c */
             nb_kernel_list_add_kernels(kernellist_c, kernellist_c_size);
 
-            if (!(fr != nullptr && fr->use_simd_kernels == FALSE))
+            if (!(fr != nullptr && !fr->use_simd_kernels))
             {
                 /* Add interaction-specific kernels for different architectures */
                 /* Single precision */
@@ -221,7 +221,7 @@ gmx_nonbonded_set_kernel_pointers(FILE *log, t_nblist *nl, gmx_bool bElecAndVdwS
     int              narch = asize(arch_and_padding);
     int              i;
 
-    if (nonbonded_setup_done == FALSE)
+    if (!nonbonded_setup_done)
     {
         /* We typically call this setup routine before starting timers,
          * but if that has not been done for whatever reason we do it now.
index 185a7f709a7962bf1dce9a62cf0e24be7e03236e..aaea388177ab2b9bbb999e4adae5f9839a439b6b 100644 (file)
@@ -127,10 +127,10 @@ assign_param(t_functype ftype, t_iparams *newparam,
          * zero parameters (e.g. an index to a Cmap interaction, or LJ parameters), but
          * we use it for angles and torsions that are typically generated automatically.
          */
-        all_param_zero = (all_param_zero == TRUE) && fabs(old[j]) < GMX_REAL_MIN;
+        all_param_zero = all_param_zero && fabs(old[j]) < GMX_REAL_MIN;
     }
 
-    if (all_param_zero == TRUE)
+    if (all_param_zero)
     {
         if (IS_ANGLE(ftype) || IS_RESTRAINT_TYPE(ftype) || ftype == F_IDIHS ||
             ftype == F_PDIHS || ftype == F_PIDIHS || ftype == F_RBDIHS || ftype == F_FOURDIHS)
index 780ee80f4a7da1c8496eed3b053192cbdf0c8164..464fc803486e2d971491a8c125a08adae3cc9809 100644 (file)
@@ -999,7 +999,7 @@ void gen_pad(t_nextnb *nnb, t_atoms *atoms, t_restp rtp[],
             hbang = &hb[i].rb[ebtsANGLES];
             for (j = 0; j < hbang->nb; j++)
             {
-                if (hbang->b[j].match == TRUE)
+                if (hbang->b[j].match)
                 {
                     /* We already used this entry, continue to the next */
                     continue;
@@ -1044,7 +1044,7 @@ void gen_pad(t_nextnb *nnb, t_atoms *atoms, t_restp rtp[],
             hbdih = &hb[i].rb[ebtsPDIHS];
             for (j = 0; j < hbdih->nb; j++)
             {
-                if (hbdih->b[j].match == TRUE)
+                if (hbdih->b[j].match)
                 {
                     /* We already used this entry, continue to the next */
                     continue;
index abedc9cef0e7b4523af7dec6d2af721310d00a00..77f7cd2839222dfd7a2a077b0fd43370da628e8a 100644 (file)
@@ -335,7 +335,7 @@ static int nitrogen_is_planar(t_vsiteconf vsiteconflist[], int nvsiteconf, char
     }
     if (found)
     {
-        res = (vsiteconflist[i-1].isplanar == TRUE);
+        res = static_cast<int>(vsiteconflist[i-1].isplanar);
     }
     else
     {
index 5e9c584807762a5be48fad792c9c87b40c5c1279..3ce10af03452aa33e6ba2c5cf8289a6ca58633fc 100644 (file)
@@ -365,11 +365,11 @@ process_directive(gmx_cpp_t *handlep, const char *dname, const char *dval)
     unsigned int i1;
     char        *inc_fn, *name;
     const char  *ptr;
-    int          bIfdef, bIfndef;
+    bool         bIfdef, bIfndef;
 
     /* #ifdef or ifndef statement */
-    bIfdef  = (strcmp(dname, "ifdef") == 0);
-    bIfndef = (strcmp(dname, "ifndef") == 0);
+    bIfdef  = strcmp(dname, "ifdef") == 0;
+    bIfndef = strcmp(dname, "ifndef") == 0;
     if (bIfdef || bIfndef)
     {
         GMX_RELEASE_ASSERT(dval, "#ifdef/#ifndef requires an argument");
index e9ac0563ebc2ebd99d5e8ab131323214501fec5b..1e445b6c990e50beebfe170239813853e8e07e00 100644 (file)
@@ -402,7 +402,8 @@ void gen_nnb(t_nextnb *nnb, t_params plist[])
 static void
 sort_and_purge_nnb(t_nextnb *nnb)
 {
-    int i, j, k, m, n, cnt, found, prev, idx;
+    int  i, j, k, m, n, cnt, prev, idx;
+    bool found;
 
     for (i = 0; (i < nnb->nr); i++)
     {
@@ -417,12 +418,12 @@ sort_and_purge_nnb(t_nextnb *nnb)
             {
                 idx = nnb->a[i][n][j];
 
-                found = 0;
+                found = false;
                 for (m = 0; m < n && !found; m++)
                 {
                     for (k = 0; k < nnb->nrexcl[i][m] && !found; k++)
                     {
-                        found = (idx == nnb->a[i][m][k]);
+                        found = idx == nnb->a[i][m][k];
                     }
                 }
 
index 960834afa203011eaba2750f44225df6fb4b262c..298e67b62d8b7b6488645b67bf958e11d0258d0f 100644 (file)
@@ -561,7 +561,7 @@ new_status(const char *topfile, const char *topppfile, const char *confin,
             warning_note(wi, warn_buf);
         }
     }
-    if (opts->bOrire == FALSE)
+    if (!opts->bOrire)
     {
         i = rm_interactions(F_ORIRES, nrmols, molinfo);
         if (i > 0)
@@ -648,9 +648,9 @@ new_status(const char *topfile, const char *topppfile, const char *confin,
         fprintf(stderr, "double-checking input for internal consistency...\n");
     }
     {
-        int bHasNormalConstraints = 0 < (nint_ftype(sys, molinfo, F_CONSTR) +
-                                         nint_ftype(sys, molinfo, F_CONSTRNC));
-        int bHasAnyConstraints = bHasNormalConstraints || 0 < nint_ftype(sys, molinfo, F_SETTLE);
+        bool bHasNormalConstraints = 0 < (nint_ftype(sys, molinfo, F_CONSTR) +
+                                          nint_ftype(sys, molinfo, F_CONSTRNC));
+        bool bHasAnyConstraints = bHasNormalConstraints || 0 < nint_ftype(sys, molinfo, F_SETTLE);
         double_check(ir, state->box,
                      bHasNormalConstraints,
                      bHasAnyConstraints,
@@ -898,7 +898,7 @@ static void read_posres(gmx_mtop_t *mtop, t_molinfo *molinfo, gmx_bool bTopB,
                     gmx_fatal(FARGS, "Position restraint atom index (%d) in moltype '%s' is larger than number of atoms in %s (%d).\n",
                               ai+1, *molinfo[molb.type].name, fn, natoms);
                 }
-                if (rc_scaling == erscCOM && hadAtom[ai] == FALSE)
+                if (rc_scaling == erscCOM && !hadAtom[ai])
                 {
                     /* Determine the center of mass of the posres reference coordinates */
                     for (j = 0; j < npbcdim; j++)
index f74c9c3d7692b2114de4137f7af1a705ab09e161..f0dc2ceeb3ae466fa9edde41cea7db2b9d945b64 100644 (file)
@@ -1595,7 +1595,7 @@ void pdb2top(FILE *top_file, char *posre_fn, char *molname,
     done_nnb(&nnb);
 
     /* Make CMAP */
-    if (TRUE == bCmap)
+    if (bCmap)
     {
         gen_cmap(&(plist[F_CMAP]), restp, atoms);
         if (plist[F_CMAP].nr > 0)
@@ -1630,7 +1630,7 @@ void pdb2top(FILE *top_file, char *posre_fn, char *molname,
 
     print_sums(atoms, FALSE);
 
-    if (FALSE == bChargeGroups)
+    if (!bChargeGroups)
     {
         scrub_charge_groups(cgnr, atoms->nr);
     }
index 3a3873782b3834463778af7d1b40a7c42c60cb39..3387f60fda17d60f852a976c85889d984b096765 100644 (file)
@@ -1899,7 +1899,7 @@ void get_ir(const char *mdparin, const char *mdparout,
     ir->ns_type = get_eeenum(&inp, "ns-type",    ens_names, wi);
     printStringNoNewline(&inp, "Periodic boundary conditions: xyz, no, xy");
     ir->ePBC          = get_eeenum(&inp, "pbc",       epbc_names, wi);
-    ir->bPeriodicMols = get_eeenum(&inp, "periodic-molecules", yesno_names, wi);
+    ir->bPeriodicMols = get_eeenum(&inp, "periodic-molecules", yesno_names, wi) != 0;
     printStringNoNewline(&inp, "Allowed energy error due to the Verlet buffer in kJ/mol/ps per atom,");
     printStringNoNewline(&inp, "a value of -1 means: use rlist");
     ir->verletbuf_tol = get_ereal(&inp, "verlet-buffer-tolerance",    0.005, wi);
@@ -3919,14 +3919,14 @@ check_combination_rule_differences(const gmx_mtop_t *mtop, int state,
                 bCanDoLBRules = gmx_within_tol(c6_LB, c6, tol);
             }
 
-            if (FALSE == bCanDoLBRules)
+            if (!bCanDoLBRules)
             {
                 *bC6ParametersWorkWithLBRules = FALSE;
             }
 
             bCanDoGeometricRules = gmx_within_tol(c6_geometric, c6, tol);
 
-            if (FALSE == bCanDoGeometricRules)
+            if (!bCanDoGeometricRules)
             {
                 *bC6ParametersWorkWithGeometricRules = FALSE;
             }
@@ -3947,7 +3947,7 @@ check_combination_rules(const t_inputrec *ir, const gmx_mtop_t *mtop,
                                        &bLBRulesPossible);
     if (ir->ljpme_combination_rule == eljpmeLB)
     {
-        if (FALSE == bC6ParametersWorkWithLBRules || FALSE == bLBRulesPossible)
+        if (!bC6ParametersWorkWithLBRules || !bLBRulesPossible)
         {
             warning(wi, "You are using arithmetic-geometric combination rules "
                     "in LJ-PME, but your non-bonded C6 parameters do not "
@@ -3956,7 +3956,7 @@ check_combination_rules(const t_inputrec *ir, const gmx_mtop_t *mtop,
     }
     else
     {
-        if (FALSE == bC6ParametersWorkWithGeometricRules)
+        if (!bC6ParametersWorkWithGeometricRules)
         {
             if (ir->eDispCorr != edispcNO)
             {
index 30aa182e2624cd8f2bf211abe8e45e47ebaedf27..05263a9d2049e2430caaa79e648a446e023d9e9e 100644 (file)
@@ -289,10 +289,10 @@ static void print_resall_header(FILE *out, t_restp rtp[])
             rtp[0].rb[1].type,
             rtp[0].rb[2].type,
             rtp[0].rb[3].type,
-            int{rtp[0].bKeepAllGeneratedDihedrals},
+            static_cast<int>(rtp[0].bKeepAllGeneratedDihedrals),
             rtp[0].nrexcl,
-            int{rtp[0].bGenerateHH14Interactions},
-            int{rtp[0].bRemoveDihedralIfWithImproper});
+            static_cast<int>(rtp[0].bGenerateHH14Interactions),
+            static_cast<int>(rtp[0].bRemoveDihedralIfWithImproper));
 }
 
 void print_resall(FILE *out, int nrtp, t_restp rtp[],
index cd918f3d7436169cfb9ebdd6a8cf575c75936c46..d1201e4b5476808a763e892c2d8f14b8eaa7ec85 100644 (file)
@@ -449,7 +449,8 @@ static char **read_topol(const char *infile, const char *outfile,
     int             lastcg = -1;
     int             dcatt  = -1, nmol_couple;
     /* File handling variables */
-    int             status, done;
+    int             status;
+    bool            done;
     gmx_cpp_t       handle;
     char           *tmp_line = nullptr;
     char            warn_buf[STRLEN];
index 02d4c9f2bd865685f3810638029be83d41701998..46cf9f3bbd164e228ed2bf02bf4c2d4d19cd25bd 100644 (file)
@@ -1645,7 +1645,7 @@ static bool default_params(int ftype, t_params bt[],
             }
         }
 
-        if (bFound == TRUE)
+        if (bFound)
         {
             int j;
 
index 705dcea8a7f8f3f36cb7fada3dd6e4521f296d74..045d6ce6fdb447b4a344ef9b7f01c39f6e837dd5 100644 (file)
@@ -224,7 +224,7 @@ timeFmaOnlyLoop(uint64_t loopCount)
     return cycles;
 }
 
-int
+bool
 checkDualAvx512FmaUnits()
 {
     uint64_t timeFmaAndShuf = 1e9;             // Large value
@@ -241,7 +241,7 @@ checkDualAvx512FmaUnits()
         timeFmaOnly    = std::min(timeFmaOnly, timeFmaOnlyLoop(1000) );
     }
 
-    return (timeFmaAndShuf > 1.5 * timeFmaOnly);
+    return timeFmaAndShuf > 1.5 * timeFmaOnly;
 }
 
 #endif  // GMX_X86_GCC_INLINE_ASM && SIMD_AVX_512_CXX_SUPPORTED
index 7b3ae87f2172be2512a8320f07f6934778fc2008..3656dd839165f18edd9ce433e5826a18d25fe937 100644 (file)
@@ -1302,7 +1302,7 @@ void init_IMD(t_inputrec             *ir,
 
 
     /* We will allow IMD sessions only if explicitly enabled in the .tpr file */
-    if (FALSE == ir->bIMD)
+    if (!ir->bIMD)
     {
         return;
     }
index 1531114f26f39b13f61a278d55468c43e35930eb..ee35355118ca8b6cbe2a7efe7cfb8dd1d75cbaac 100644 (file)
@@ -463,7 +463,7 @@ do_pairs_general(int ftype, int nbonds,
         c12 *= 12.0;
 
         /* Do we need to apply full periodic boundary conditions? */
-        if (fr->bMolPBC == TRUE)
+        if (fr->bMolPBC)
         {
             fshift_index = pbc_dx_aiuc(pbc, x[ai], x[aj], dx);
         }
@@ -478,7 +478,7 @@ do_pairs_general(int ftype, int nbonds,
         {
             /* This check isn't race free. But it doesn't matter because if a race occurs the only
              * disadvantage is that the warning is printed twice */
-            if (warned_rlimit == FALSE)
+            if (!warned_rlimit)
             {
                 warning_rlimit(x, ai, aj, global_atom_index, sqrt(r2), fr->pairsTable->r);
                 warned_rlimit = TRUE;
index f8f83bddd6135bc0ef8623baea9d2866e9339e4b..280bcd4aeb59ab358c9697f9d450756c964f30b3 100644 (file)
@@ -161,7 +161,7 @@ real do_fbposres_cylinder(int fbdim, rvec fm, rvec dx, real rfb, real kk, gmx_bo
     }
 
     if  (dr2 > 0.0 &&
-         ( (dr2 > rfb2 && bInvert == FALSE ) || (dr2 < rfb2 && bInvert == TRUE ) )
+         ( (dr2 > rfb2 && !bInvert ) || (dr2 < rfb2 && bInvert ) )
          )
     {
         dr     = std::sqrt(dr2);
@@ -249,7 +249,7 @@ real fbposres(int nbonds,
                 /* spherical flat-bottom posres */
                 dr2 = norm2(dx);
                 if (dr2 > 0.0 &&
-                    ( (dr2 > rfb2 && bInvert == FALSE ) || (dr2 < rfb2 && bInvert == TRUE ) )
+                    ( (dr2 > rfb2 && !bInvert ) || (dr2 < rfb2 && bInvert ) )
                     )
                 {
                     dr   = std::sqrt(dr2);
@@ -281,12 +281,12 @@ real fbposres(int nbonds,
                 /* 1D flat-bottom potential */
                 fbdim = pr->fbposres.geom - efbposresX;
                 dr    = dx[fbdim];
-                if ( ( dr > rfb && bInvert == FALSE ) || ( 0 < dr && dr < rfb && bInvert == TRUE )  )
+                if ( ( dr > rfb && !bInvert ) || ( 0 < dr && dr < rfb && bInvert )  )
                 {
                     v         = 0.5*kk*gmx::square(dr - rfb);
                     fm[fbdim] = -kk*(dr - rfb);
                 }
-                else if ( (dr < (-rfb) && bInvert == FALSE ) || ( (-rfb) < dr && dr < 0 && bInvert == TRUE ))
+                else if ( (dr < (-rfb) && !bInvert ) || ( (-rfb) < dr && dr < 0 && bInvert ))
                 {
                     v         = 0.5*kk*gmx::square(dr + rfb);
                     fm[fbdim] = -kk*(dr + rfb);
index 6110b3e13daa96c8eb4cbced42ec0d65d5776ff2..aff1c7a203d78c8c15f8ef7a9b3ad451a95a0adc 100644 (file)
@@ -60,7 +60,7 @@ gmx_within_tol(double   f1,
     return fabs(f1-f2) <= tol*0.5*(fabs(f1)+fabs(f2));
 }
 
-int
+bool
 gmx_numzero(double a)
 {
     return gmx_within_tol(a, 0.0, GMX_REAL_MIN/GMX_REAL_EPS);
index ef1de46d6a840b5a3878d45d40088674819c37cc..1a22a76ea9d4d9623c367f37d2f107f586b7d30d 100644 (file)
@@ -139,7 +139,7 @@ gmx_within_tol(double   f1,
  *
  * \return 1  if 'almost' numerically zero, 0 otherwise.
  */
-int
+bool
 gmx_numzero(double a);
 
 /*! \brief Multiply two large ints
index f3f8e5458e4c5f465d4a3feb9a7fac83dbb9e30a..9c85e0ba56a35d71af0154a5a55aacd9c26bdeb8 100644 (file)
@@ -382,7 +382,7 @@ check_solvent_cg(const gmx_moltype_t    *molt,
         }
 
         /* Check that types & charges match for all atoms in molecule */
-        for (j = 0; j < nj && match == TRUE; j++)
+        for (j = 0; j < nj && match; j++)
         {
             if (tmp_vdwtype[j] != solvent_parameters[k].vdwtype[j])
             {
@@ -393,7 +393,7 @@ check_solvent_cg(const gmx_moltype_t    *molt,
                 match = FALSE;
             }
         }
-        if (match == TRUE)
+        if (match)
         {
             /* Congratulations! We have a matched solvent.
              * Flag it with this type for later processing.
@@ -419,7 +419,7 @@ check_solvent_cg(const gmx_moltype_t    *molt,
         /* Go through all other tpes and see if any have non-zero
          * VdW parameters when combined with this one.
          */
-        for (k = 0; k < fr->ntype && (has_vdw[j] == FALSE); k++)
+        for (k = 0; k < fr->ntype && (!has_vdw[j]); k++)
         {
             /* We already checked that the atoms weren't perturbed,
              * so we only need to check state A now.
@@ -449,8 +449,8 @@ check_solvent_cg(const gmx_moltype_t    *molt,
          * the charges on atom 2 & 3 should be the same, and only
          * atom 1 might have VdW.
          */
-        if (has_vdw[1] == FALSE &&
-            has_vdw[2] == FALSE &&
+        if (!has_vdw[1] &&
+            !has_vdw[2] &&
             tmp_charge[0]  != 0 &&
             tmp_charge[1]  != 0 &&
             tmp_charge[2]  == tmp_charge[1])
@@ -474,9 +474,9 @@ check_solvent_cg(const gmx_moltype_t    *molt,
          * For this we require thatn atoms 2,3,4 have charge, but not atom 1.
          * Only atom 1 mght have VdW.
          */
-        if (has_vdw[1] == FALSE &&
-            has_vdw[2] == FALSE &&
-            has_vdw[3] == FALSE &&
+        if (!has_vdw[1] &&
+            !has_vdw[2] &&
+            !has_vdw[3] &&
             tmp_charge[0]  == 0 &&
             tmp_charge[1]  != 0 &&
             tmp_charge[2]  == tmp_charge[1] &&
@@ -2440,7 +2440,7 @@ void init_forcerec(FILE                             *fp,
         bGenericKernelOnly = TRUE;
     }
 
-    if (bGenericKernelOnly == TRUE)
+    if (bGenericKernelOnly)
     {
         bNoSolvOpt         = TRUE;
     }
@@ -2669,7 +2669,7 @@ void init_forcerec(FILE                             *fp,
          */
         if (fr->nbkernel_elec_modifier == eintmodPOTSWITCH &&
             fr->nbkernel_vdw_modifier == eintmodPOTSWITCH &&
-            bGenericKernelOnly == FALSE)
+            !bGenericKernelOnly)
         {
             if ((ic->rcoulomb_switch != ic->rvdw_switch) || (ic->rcoulomb != ic->rvdw))
             {
@@ -2684,7 +2684,7 @@ void init_forcerec(FILE                             *fp,
                    fr->nbkernel_elec_modifier == eintmodEXACTCUTOFF &&
                    (fr->nbkernel_vdw_modifier == eintmodPOTSWITCH || fr->nbkernel_vdw_modifier == eintmodPOTSHIFT))))
         {
-            if ((ic->rcoulomb != ic->rvdw) && (bGenericKernelOnly == FALSE))
+            if ((ic->rcoulomb != ic->rvdw) && (!bGenericKernelOnly))
             {
                 fr->bcoultab = TRUE;
             }
@@ -2713,12 +2713,12 @@ void init_forcerec(FILE                             *fp,
                     gmx::boolToString(fr->bvdwtab));
         }
 
-        if (fr->bvdwtab == TRUE)
+        if (fr->bvdwtab)
         {
             fr->nbkernel_vdw_interaction = GMX_NBKERNEL_VDW_CUBICSPLINETABLE;
             fr->nbkernel_vdw_modifier    = eintmodNONE;
         }
-        if (fr->bcoultab == TRUE)
+        if (fr->bcoultab)
         {
             fr->nbkernel_elec_interaction = GMX_NBKERNEL_ELEC_CUBICSPLINETABLE;
             fr->nbkernel_elec_modifier    = eintmodNONE;
index 95b8ef17ce1938a420c9ab3c106bc0932eb3ea86..d8b1d96b62d13a6c122e5dee8c808483b4c6ae2e 100644 (file)
@@ -1543,7 +1543,7 @@ Lincs *init_lincs(FILE *fplog, const gmx_mtop_t &mtop,
     if (debug && bPLINCS)
     {
         fprintf(debug, "PLINCS communication before each iteration: %d\n",
-                int{li->bCommIter});
+                static_cast<int>(li->bCommIter));
     }
 
     /* LINCS can run on any number of threads.
@@ -1774,7 +1774,7 @@ static void assign_constraint(Lincs *li,
 static void check_assign_connected(Lincs *li,
                                    const t_iatom *iatom,
                                    const t_idef &idef,
-                                   int bDynamics,
+                                   bool bDynamics,
                                    int a1, int a2,
                                    const t_blocka *at2con)
 {
@@ -1823,7 +1823,7 @@ static void check_assign_connected(Lincs *li,
 static void check_assign_triangle(Lincs *li,
                                   const t_iatom *iatom,
                                   const t_idef &idef,
-                                  int bDynamics,
+                                  bool bDynamics,
                                   int constraint_index,
                                   int a1, int a2,
                                   const t_blocka *at2con)
index 915f1f1da838b335c02472d38b6f8c5221575dab..02252b17e9d2b895efa78c6c67c809a486a9185c 100644 (file)
@@ -163,7 +163,7 @@ static int get_mtype_list(t_block *at, gmx_mtop_t *mtop, t_block *tlist)
             }
         }
 
-        if (bNEW == TRUE)
+        if (bNEW)
         {
             tlist->index[nr] = type;
             nr++;
@@ -838,13 +838,13 @@ static int rm_bonded(t_block *ins_at, gmx_mtop_t *mtop)
         natom        = mtop->moltype[type].atoms.nr;
         nmol         = mtop->molblock[i].nmol;
 
-        for (j = 0; j < natom*nmol && bRM[type] == TRUE; j++)
+        for (j = 0; j < natom*nmol && bRM[type]; j++)
         {
             /*loop over atoms in the block*/
             at   = j+atom1; /*atom index = block index + offset*/
             bINS = FALSE;
 
-            for (m = 0; (m < ins_at->nr) && (bINS == FALSE); m++)
+            for (m = 0; (m < ins_at->nr) && (!bINS); m++)
             {
                 /*loop over atoms in insertion index group to determine if we're inserting one*/
                 if (at == ins_at->index[m])
index fde2b423447f668b793d3850f3770f610b2857bb..fc6b1d29483078146ad42efe30af37d8901897a9 100644 (file)
@@ -1844,7 +1844,7 @@ static int nsgrid_core(const t_commrec *cr,
             /* Skip this charge group if it is not a QM atom while making a
              * QM/MM neighbourlist
              */
-            if (md->bQM[i0] == FALSE)
+            if (!md->bQM[i0])
             {
                 continue; /* MM particle, go to next particle */
             }
index d2904a05318859c834ccce0ef8f255506ae8223a..48db5570e06d6c1124cac9aa2615a62662105c82 100644 (file)
@@ -1084,8 +1084,8 @@ static void do_force_cutsVERLET(FILE *fplog,
     float               cycles_pme, cycles_wait_gpu;
     nonbonded_verlet_t *nbv = fr->nbv;
 
-    bStateChanged = (flags & GMX_FORCE_STATECHANGED);
-    bNS           = (flags & GMX_FORCE_NS) && (fr->bAllvsAll == FALSE);
+    bStateChanged = ((flags & GMX_FORCE_STATECHANGED) != 0);
+    bNS           = ((flags & GMX_FORCE_NS) != 0) && (!fr->bAllvsAll);
     bFillGrid     = (bNS && bStateChanged);
     bCalcCGCM     = (bFillGrid && !DOMAINDECOMP(cr));
     bDoForces     = (flags & GMX_FORCE_FORCES);
@@ -1800,8 +1800,8 @@ static void do_force_cutsGROUP(FILE *fplog,
         cg1--;
     }
 
-    bStateChanged  = (flags & GMX_FORCE_STATECHANGED);
-    bNS            = (flags & GMX_FORCE_NS) && (fr->bAllvsAll == FALSE);
+    bStateChanged  = ((flags & GMX_FORCE_STATECHANGED) != 0);
+    bNS            = ((flags & GMX_FORCE_NS) != 0) && (!fr->bAllvsAll);
     /* Should we perform the long-range nonbonded evaluation inside the neighborsearching? */
     bFillGrid      = (bNS && bStateChanged);
     bCalcCGCM      = (bFillGrid && !DOMAINDECOMP(cr));
@@ -2838,7 +2838,7 @@ extern void initialize_lambdas(FILE *fplog, t_inputrec *ir, int *fep_state, gmx:
     /* this function works, but could probably use a logic rewrite to keep all the different
        types of efep straight. */
 
-    if ((ir->efep == efepNO) && (ir->bSimTemp == FALSE))
+    if ((ir->efep == efepNO) && (!ir->bSimTemp))
     {
         return;
     }
index d3db44037969354bb12af85854fe932832a61e97..eedfd21f84fe18bababc1b189a22600fa539fa17 100644 (file)
@@ -99,7 +99,7 @@ void global_stat(gmx_global_stat_t gs,
                  gmx_bool bSumEkinhOld, int flags);
 /* All-reduce energy-like quantities over cr->mpi_comm_mysim */
 
-int do_per_step(int64_t step, int64_t nstep);
+bool do_per_step(int64_t step, int64_t nstep);
 /* Return TRUE if io should be done */
 
 /* ROUTINES from sim_util.c */
index f6ff68069ff4c8f563ebb21ffb3b8b2640061495..5179ffd0d9edc625b2bca9e196f97f84f880dfcb 100644 (file)
@@ -380,14 +380,14 @@ void global_stat(gmx_global_stat_t gs,
     }
 }
 
-int do_per_step(int64_t step, int64_t nstep)
+bool do_per_step(int64_t step, int64_t nstep)
 {
     if (nstep != 0)
     {
-        return ((step % nstep) == 0);
+        return (step % nstep) == 0;
     }
     else
     {
-        return 0;
+        return false;
     }
 }
index 64c5d46b8aac6e4dcfab3e02a371ee680f2d88ed..11d68e01db2d83946f1c7123bb4b8b74328e4059 100644 (file)
@@ -2554,7 +2554,7 @@ void split_vsites_over_threads(const t_ilist   *ilist,
     if (debug && vsite->nthreads > 1)
     {
         fprintf(debug, "virtual site useInterdependentTask %d, nuse:\n",
-                int{vsite->tData[0]->useInterdependentTask});
+                static_cast<int>(vsite->tData[0]->useInterdependentTask));
         for (int th = 0; th < vsite->nthreads + 1; th++)
         {
             fprintf(debug, " %4d", vsite->tData[th]->idTask.nuse);
index 5b26d7613b232b12beae7a95a2d6654593a67c2b..ad00f270d0855394603788a816aa53c3a804d2db 100644 (file)
@@ -79,8 +79,8 @@ struct AwhBiasStateHistory
     int         umbrellaGridpoint;        /**< Index for the current umbrella reference coordinate point (for umbrella potential type) */
     int         origin_index_updatelist;  /**< Point index of the origin of the subgrid that has been touched since last update. */
     int         end_index_updatelist;     /**< Point index of the end of the subgrid that has been touched since last update. */
-    int         in_initial;               /**< True if in the intial stage. */
-    int         equilibrateHistogram;     /**< True if histogram needs equilibration. */
+    bool        in_initial;               /**< True if in the intial stage. */
+    bool        equilibrateHistogram;     /**< True if histogram needs equilibration. */
     double      histSize;                 /**< Size of reference weight histogram. */
     double      logScaledSampleWeight;    /**< The log of the current sample weight, scaled because of the histogram rescaling. */
     double      maxLogScaledSampleWeight; /**< Maximum sample weight obtained for previous (smaller) histogram sizes. */
@@ -90,8 +90,8 @@ struct AwhBiasStateHistory
     AwhBiasStateHistory() : umbrellaGridpoint(0),
                             origin_index_updatelist(0),
                             end_index_updatelist(0),
-                            in_initial(0),
-                            equilibrateHistogram(0),
+                            in_initial(false),
+                            equilibrateHistogram(false),
                             histSize(0),
                             logScaledSampleWeight(0),
                             maxLogScaledSampleWeight(0),
index 8ca68dfafa6ce2dc347fc0365359d746a7f8db7e..9b6434d9c6e50967d8f21a1b6e36806c4015c290 100644 (file)
@@ -1272,7 +1272,7 @@ void cmp_inputrec(FILE *fp, const t_inputrec *ir1, const t_inputrec *ir2, real f
     cmp_int64(fp, "inputrec->init_step", ir1->init_step, ir2->init_step);
     cmp_int(fp, "inputrec->simulation_part", -1, ir1->simulation_part, ir2->simulation_part);
     cmp_int(fp, "inputrec->ePBC", -1, ir1->ePBC, ir2->ePBC);
-    cmp_int(fp, "inputrec->bPeriodicMols", -1, ir1->bPeriodicMols, ir2->bPeriodicMols);
+    cmp_bool(fp, "inputrec->bPeriodicMols", -1, ir1->bPeriodicMols, ir2->bPeriodicMols);
     cmp_int(fp, "inputrec->cutoff_scheme", -1, ir1->cutoff_scheme, ir2->cutoff_scheme);
     cmp_int(fp, "inputrec->ns_type", -1, ir1->ns_type, ir2->ns_type);
     cmp_int(fp, "inputrec->nstlist", -1, ir1->nstlist, ir2->nstlist);
index 9183e3c167a09d185786f52f7482ef7db9c945fa..56eb94bfdf4a9990cb047249676889f34f4f3025 100644 (file)
@@ -400,7 +400,7 @@ struct t_inputrec // NOLINT (clang-analyzer-optin.performance.Padding)
     //! Type of periodic boundary conditions
     int                         ePBC;
     //! Periodic molecules
-    int                         bPeriodicMols;
+    bool                        bPeriodicMols;
     //! Continuation run: starting state is correct (ie. constrained)
     gmx_bool                    bContinuation;
     //! Temperature coupling
index d1340d1d3f0e9dced11cb8a5701d8ee28704bf1e..ab7f5992beebd0501bb42bd257ad5d0d5fb25f84 100644 (file)
@@ -1606,7 +1606,7 @@ void init_swapcoords(
     for (int j = eGrpSplit0; j <= eGrpSplit1; j++)
     {
         g = &(s->group[j]);
-        if (TRUE == sc->massw_split[j])
+        if (sc->massw_split[j])
         {
             /* Save the split group masses if mass-weighting is requested */
             snew(g->m, g->atomset.numAtomsGlobal());
index 76f3a24e15d472edfbeeb5bfa9e708646036e9d4..beca6b0355a0f277c69d4664170e8f61b7275955 100644 (file)
@@ -200,14 +200,14 @@ mk_aid(const t_atoms *atoms, const char ** restype, const char * typestring, int
 {
     int     *a;
     int      i;
-    int      res;
+    bool     res;
 
     snew(a, atoms->nr);
     *nra = 0;
     for (i = 0; (i < atoms->nr); i++)
     {
-        res = !gmx_strcasecmp(restype[atoms->atom[i].resind], typestring);
-        if (bMatch == FALSE)
+        res = gmx_strcasecmp(restype[atoms->atom[i].resind], typestring) == 0;
+        if (!bMatch)
         {
             res = !res;
         }
@@ -579,7 +579,7 @@ void analyse(const t_atoms *atoms, t_blocka *gb, char ***gn, gmx_bool bASK, gmx_
     char           ** p_typename;
     int               iwater, iion;
     int               nwater, nion;
-    int               found;
+    bool              found;
 
     if (bVerb)
     {
@@ -619,10 +619,10 @@ void analyse(const t_atoms *atoms, t_blocka *gb, char ***gn, gmx_bool bASK, gmx_
             /* Note that this does not lead to a N*N loop, but N*K, where
              * K is the number of residue _types_, which is small and independent of N.
              */
-            found = 0;
+            found = false;
             for (k = 0; k < ntypes && !found; k++)
             {
-                found = !strcmp(restype[i], p_typename[k]);
+                found = strcmp(restype[i], p_typename[k]) == 0;
             }
             if (!found)
             {
index ac8f2ac453c955d58efe73ed606c048770ddd77d..349d3cbf0ccb388b0df26bf731d31795f4a93c72 100644 (file)
@@ -129,7 +129,7 @@ gmx_residuetype_get_type(gmx_residuetype_t *rt, const char * resname, const char
 int
 gmx_residuetype_add(gmx_residuetype_t *rt, const char *newresname, const char *newrestype)
 {
-    int           found;
+    bool          found;
     const char *  p_oldtype;
 
     found = !gmx_residuetype_get_type(rt, newresname, &p_oldtype);
@@ -140,7 +140,7 @@ gmx_residuetype_add(gmx_residuetype_t *rt, const char *newresname, const char *n
                 newresname, p_oldtype, newrestype);
     }
 
-    if (found == 0)
+    if (!found)
     {
         srenew(rt->resname, rt->n+1);
         srenew(rt->restype, rt->n+1);
index 93f0738f4daac59192a5ac3d097a5589f1e4fa3f..c6d9923184e406ceb201e26622d3a06ece45aed3 100644 (file)
@@ -257,10 +257,10 @@ FreeVolume::initAnalysis(const TrajectoryAnalysisSettings &settings,
 
         // Lookup the Van der Waals radius of this atom
         int resnr = atoms->atom[i].resind;
-        if (TRUE == gmx_atomprop_query(aps, epropVDW,
-                                       *(atoms->resinfo[resnr].name),
-                                       *(atoms->atomname[i]),
-                                       &value))
+        if (gmx_atomprop_query(aps, epropVDW,
+                               *(atoms->resinfo[resnr].name),
+                               *(atoms->atomname[i]),
+                               &value))
         {
             vdw_radius_.push_back(value);
             if (value > cutoff_)