From: Roland Schulz Date: Tue, 14 Aug 2018 04:21:09 +0000 (-0700) Subject: readability-implicit-bool-conversion 1/2 X-Git-Url: http://biod.pnpi.spb.ru/gitweb/?a=commitdiff_plain;h=1d92bc583e009c1e29693e00aed6979726b52bfe;p=alexxy%2Fgromacs.git readability-implicit-bool-conversion 1/2 manual changes Change-Id: Iad9d6d301b526f79c25e56e7dfdf42144319ed80 --- diff --git a/src/gromacs/domdec/domdec.cpp b/src/gromacs/domdec/domdec.cpp index 58ce797fb5..de012d0b26 100644 --- a/src/gromacs/domdec/domdec.cpp +++ b/src/gromacs/domdec/domdec.cpp @@ -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(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(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. diff --git a/src/gromacs/essentialdynamics/edsam.cpp b/src/gromacs/essentialdynamics/edsam.cpp index 2eb01c63f1..3b35f9a00e 100644 --- a/src/gromacs/essentialdynamics/edsam.cpp +++ b/src/gromacs/essentialdynamics/edsam.cpp @@ -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 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 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 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 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++) { diff --git a/src/gromacs/ewald/pme-redistribute.cpp b/src/gromacs/ewald/pme-redistribute.cpp index e0b8defda5..bbef6bf975 100644 --- a/src/gromacs/ewald/pme-redistribute.cpp +++ b/src/gromacs/ewald/pme-redistribute.cpp @@ -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]; diff --git a/src/gromacs/fft/fft.cpp b/src/gromacs/fft/fft.cpp index 849947d9df..3769247de4 100644 --- a/src/gromacs/fft/fft.cpp +++ b/src/gromacs/fft/fft.cpp @@ -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; } } } diff --git a/src/gromacs/fft/fft5d.cpp b/src/gromacs/fft/fft5d.cpp index 3e0cb78577..d7755c653d 100644 --- a/src/gromacs/fft/fft5d.cpp +++ b/src/gromacs/fft/fft5d.cpp @@ -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) diff --git a/src/gromacs/fft/fft_fftw3.cpp b/src/gromacs/fft/fft_fftw3.cpp index 155ca0dcfa..69f314cfe2 100644 --- a/src/gromacs/fft/fft_fftw3.cpp +++ b/src/gromacs/fft/fft_fftw3.cpp @@ -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) || diff --git a/src/gromacs/fileio/checkpoint.cpp b/src/gromacs/fileio/checkpoint.cpp index 3c2b275b75..ecf02b9a34 100644 --- a/src/gromacs/fileio/checkpoint.cpp +++ b/src/gromacs/fileio/checkpoint.cpp @@ -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(*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: diff --git a/src/gromacs/fileio/groio.cpp b/src/gromacs/fileio/groio.cpp index 8833b4b3d7..8038330369 100644 --- a/src/gromacs/fileio/groio.cpp +++ b/src/gromacs/fileio/groio.cpp @@ -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) diff --git a/src/gromacs/fileio/tpxio.cpp b/src/gromacs/fileio/tpxio.cpp index 714a00033d..3c79f26038 100644 --- a/src/gromacs/fileio/tpxio.cpp +++ b/src/gromacs/fileio/tpxio.cpp @@ -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; } diff --git a/src/gromacs/fileio/tpxio.h b/src/gromacs/fileio/tpxio.h index 1e06ad67ba..071bcab760 100644 --- a/src/gromacs/fileio/tpxio.h +++ b/src/gromacs/fileio/tpxio.h @@ -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 */ diff --git a/src/gromacs/gmxana/gmx_anadock.cpp b/src/gromacs/gmxana/gmx_anadock.cpp index f108e95935..f9fa53e033 100644 --- a/src/gromacs/gmxana/gmx_anadock.cpp +++ b/src/gromacs/gmxana/gmx_anadock.cpp @@ -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; diff --git a/src/gromacs/gmxana/gmx_bar.cpp b/src/gromacs/gmxana/gmx_bar.cpp index af0530c08d..76bd921c05 100644 --- a/src/gromacs/gmxana/gmx_bar.cpp +++ b/src/gromacs/gmxana/gmx_bar.cpp @@ -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, diff --git a/src/gromacs/gmxana/gmx_chi.cpp b/src/gromacs/gmxana/gmx_chi.cpp index 93c2a5d235..eaa94f475b 100644 --- a/src/gromacs/gmxana/gmx_chi.cpp +++ b/src/gromacs/gmxana/gmx_chi.cpp @@ -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(!bAllowed(dih[Phi][j], RAD2DEG*dih[Psi][j])) ); } if (bOm) { diff --git a/src/gromacs/gmxana/gmx_hbond.cpp b/src/gromacs/gmxana/gmx_hbond.cpp index 157d53da35..b2bf4057c5 100644 --- a/src/gromacs/gmxana/gmx_hbond.cpp +++ b/src/gromacs/gmxana/gmx_hbond.cpp @@ -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; diff --git a/src/gromacs/gmxana/gmx_msd.cpp b/src/gromacs/gmxana/gmx_msd.cpp index 9a13ea7238..3d4e240a2f 100644 --- a/src/gromacs/gmxana/gmx_msd.cpp +++ b/src/gromacs/gmxana/gmx_msd.cpp @@ -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); diff --git a/src/gromacs/gmxana/gmx_rotacf.cpp b/src/gromacs/gmxana/gmx_rotacf.cpp index 771efcaf65..be825a4103 100644 --- a/src/gromacs/gmxana/gmx_rotacf.cpp +++ b/src/gromacs/gmxana/gmx_rotacf.cpp @@ -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++) { diff --git a/src/gromacs/gmxana/gmx_trjconv.cpp b/src/gromacs/gmxana/gmx_trjconv.cpp index 55771c8e17..ebce1d37e6 100644 --- a/src/gromacs/gmxana/gmx_trjconv.cpp +++ b/src/gromacs/gmxana/gmx_trjconv.cpp @@ -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"); } diff --git a/src/gromacs/gmxana/gmx_tune_pme.cpp b/src/gromacs/gmxana/gmx_tune_pme.cpp index 15e63965b3..3378600db8 100644 --- a/src/gromacs/gmxana/gmx_tune_pme.cpp +++ b/src/gromacs/gmxana/gmx_tune_pme.cpp @@ -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 "); } diff --git a/src/gromacs/gmxana/gmx_wham.cpp b/src/gromacs/gmxana/gmx_wham.cpp index d9f171f943..1b8929506f 100644 --- a/src/gromacs/gmxana/gmx_wham.cpp +++ b/src/gromacs/gmxana/gmx_wham.cpp @@ -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 = ( jbins/20 ); + bBoundary = jbins/20; /* check for bins with no data */ if (count[j] == 0) { diff --git a/src/gromacs/gmxana/nsfactor.cpp b/src/gromacs/gmxana/nsfactor.cpp index 92e216526e..cbcd25ab3b 100644 --- a/src/gromacs/gmxana/nsfactor.cpp +++ b/src/gromacs/gmxana/nsfactor.cpp @@ -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]"); } diff --git a/src/gromacs/gmxlib/nonbonded/nonbonded.cpp b/src/gromacs/gmxlib/nonbonded/nonbonded.cpp index 470c61763e..1ba0e3d241 100644 --- a/src/gromacs/gmxlib/nonbonded/nonbonded.cpp +++ b/src/gromacs/gmxlib/nonbonded/nonbonded.cpp @@ -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. diff --git a/src/gromacs/gmxpreprocess/convparm.cpp b/src/gromacs/gmxpreprocess/convparm.cpp index 185a7f709a..aaea388177 100644 --- a/src/gromacs/gmxpreprocess/convparm.cpp +++ b/src/gromacs/gmxpreprocess/convparm.cpp @@ -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) diff --git a/src/gromacs/gmxpreprocess/gen_ad.cpp b/src/gromacs/gmxpreprocess/gen_ad.cpp index 780ee80f4a..464fc80348 100644 --- a/src/gromacs/gmxpreprocess/gen_ad.cpp +++ b/src/gromacs/gmxpreprocess/gen_ad.cpp @@ -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; diff --git a/src/gromacs/gmxpreprocess/gen_vsite.cpp b/src/gromacs/gmxpreprocess/gen_vsite.cpp index abedc9cef0..77f7cd2839 100644 --- a/src/gromacs/gmxpreprocess/gen_vsite.cpp +++ b/src/gromacs/gmxpreprocess/gen_vsite.cpp @@ -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(vsiteconflist[i-1].isplanar); } else { diff --git a/src/gromacs/gmxpreprocess/gmxcpp.cpp b/src/gromacs/gmxpreprocess/gmxcpp.cpp index 5e9c584807..3ce10af034 100644 --- a/src/gromacs/gmxpreprocess/gmxcpp.cpp +++ b/src/gromacs/gmxpreprocess/gmxcpp.cpp @@ -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"); diff --git a/src/gromacs/gmxpreprocess/gpp_nextnb.cpp b/src/gromacs/gmxpreprocess/gpp_nextnb.cpp index e9ac0563eb..1e445b6c99 100644 --- a/src/gromacs/gmxpreprocess/gpp_nextnb.cpp +++ b/src/gromacs/gmxpreprocess/gpp_nextnb.cpp @@ -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]; } } diff --git a/src/gromacs/gmxpreprocess/grompp.cpp b/src/gromacs/gmxpreprocess/grompp.cpp index 960834afa2..298e67b62d 100644 --- a/src/gromacs/gmxpreprocess/grompp.cpp +++ b/src/gromacs/gmxpreprocess/grompp.cpp @@ -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++) diff --git a/src/gromacs/gmxpreprocess/pdb2top.cpp b/src/gromacs/gmxpreprocess/pdb2top.cpp index f74c9c3d76..f0dc2ceeb3 100644 --- a/src/gromacs/gmxpreprocess/pdb2top.cpp +++ b/src/gromacs/gmxpreprocess/pdb2top.cpp @@ -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); } diff --git a/src/gromacs/gmxpreprocess/readir.cpp b/src/gromacs/gmxpreprocess/readir.cpp index 3a3873782b..3387f60fda 100644 --- a/src/gromacs/gmxpreprocess/readir.cpp +++ b/src/gromacs/gmxpreprocess/readir.cpp @@ -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) { diff --git a/src/gromacs/gmxpreprocess/resall.cpp b/src/gromacs/gmxpreprocess/resall.cpp index 30aa182e26..05263a9d20 100644 --- a/src/gromacs/gmxpreprocess/resall.cpp +++ b/src/gromacs/gmxpreprocess/resall.cpp @@ -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(rtp[0].bKeepAllGeneratedDihedrals), rtp[0].nrexcl, - int{rtp[0].bGenerateHH14Interactions}, - int{rtp[0].bRemoveDihedralIfWithImproper}); + static_cast(rtp[0].bGenerateHH14Interactions), + static_cast(rtp[0].bRemoveDihedralIfWithImproper)); } void print_resall(FILE *out, int nrtp, t_restp rtp[], diff --git a/src/gromacs/gmxpreprocess/topio.cpp b/src/gromacs/gmxpreprocess/topio.cpp index cd918f3d74..d1201e4b54 100644 --- a/src/gromacs/gmxpreprocess/topio.cpp +++ b/src/gromacs/gmxpreprocess/topio.cpp @@ -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]; diff --git a/src/gromacs/gmxpreprocess/toppush.cpp b/src/gromacs/gmxpreprocess/toppush.cpp index 02d4c9f2bd..46cf9f3bbd 100644 --- a/src/gromacs/gmxpreprocess/toppush.cpp +++ b/src/gromacs/gmxpreprocess/toppush.cpp @@ -1645,7 +1645,7 @@ static bool default_params(int ftype, t_params bt[], } } - if (bFound == TRUE) + if (bFound) { int j; diff --git a/src/gromacs/hardware/identifyavx512fmaunits.cpp b/src/gromacs/hardware/identifyavx512fmaunits.cpp index 705dcea8a7..045d6ce6fd 100644 --- a/src/gromacs/hardware/identifyavx512fmaunits.cpp +++ b/src/gromacs/hardware/identifyavx512fmaunits.cpp @@ -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 diff --git a/src/gromacs/imd/imd.cpp b/src/gromacs/imd/imd.cpp index 7b3ae87f21..3656dd8391 100644 --- a/src/gromacs/imd/imd.cpp +++ b/src/gromacs/imd/imd.cpp @@ -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; } diff --git a/src/gromacs/listed-forces/pairs.cpp b/src/gromacs/listed-forces/pairs.cpp index 1531114f26..ee35355118 100644 --- a/src/gromacs/listed-forces/pairs.cpp +++ b/src/gromacs/listed-forces/pairs.cpp @@ -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; diff --git a/src/gromacs/listed-forces/position-restraints.cpp b/src/gromacs/listed-forces/position-restraints.cpp index f8f83bddd6..280bcd4aeb 100644 --- a/src/gromacs/listed-forces/position-restraints.cpp +++ b/src/gromacs/listed-forces/position-restraints.cpp @@ -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); diff --git a/src/gromacs/math/utilities.cpp b/src/gromacs/math/utilities.cpp index 6110b3e13d..aff1c7a203 100644 --- a/src/gromacs/math/utilities.cpp +++ b/src/gromacs/math/utilities.cpp @@ -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); diff --git a/src/gromacs/math/utilities.h b/src/gromacs/math/utilities.h index ef1de46d6a..1a22a76ea9 100644 --- a/src/gromacs/math/utilities.h +++ b/src/gromacs/math/utilities.h @@ -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 diff --git a/src/gromacs/mdlib/forcerec.cpp b/src/gromacs/mdlib/forcerec.cpp index f3f8e5458e..9c85e0ba56 100644 --- a/src/gromacs/mdlib/forcerec.cpp +++ b/src/gromacs/mdlib/forcerec.cpp @@ -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; diff --git a/src/gromacs/mdlib/lincs.cpp b/src/gromacs/mdlib/lincs.cpp index 95b8ef17ce..d8b1d96b62 100644 --- a/src/gromacs/mdlib/lincs.cpp +++ b/src/gromacs/mdlib/lincs.cpp @@ -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(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) diff --git a/src/gromacs/mdlib/membed.cpp b/src/gromacs/mdlib/membed.cpp index 915f1f1da8..02252b17e9 100644 --- a/src/gromacs/mdlib/membed.cpp +++ b/src/gromacs/mdlib/membed.cpp @@ -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]) diff --git a/src/gromacs/mdlib/ns.cpp b/src/gromacs/mdlib/ns.cpp index fde2b42344..fc6b1d2948 100644 --- a/src/gromacs/mdlib/ns.cpp +++ b/src/gromacs/mdlib/ns.cpp @@ -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 */ } diff --git a/src/gromacs/mdlib/sim_util.cpp b/src/gromacs/mdlib/sim_util.cpp index d2904a0531..48db5570e0 100644 --- a/src/gromacs/mdlib/sim_util.cpp +++ b/src/gromacs/mdlib/sim_util.cpp @@ -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; } diff --git a/src/gromacs/mdlib/sim_util.h b/src/gromacs/mdlib/sim_util.h index d3db440379..eedfd21f84 100644 --- a/src/gromacs/mdlib/sim_util.h +++ b/src/gromacs/mdlib/sim_util.h @@ -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 */ diff --git a/src/gromacs/mdlib/stat.cpp b/src/gromacs/mdlib/stat.cpp index f6ff68069f..5179ffd0d9 100644 --- a/src/gromacs/mdlib/stat.cpp +++ b/src/gromacs/mdlib/stat.cpp @@ -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; } } diff --git a/src/gromacs/mdlib/vsite.cpp b/src/gromacs/mdlib/vsite.cpp index 64c5d46b8a..11d68e01db 100644 --- a/src/gromacs/mdlib/vsite.cpp +++ b/src/gromacs/mdlib/vsite.cpp @@ -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(vsite->tData[0]->useInterdependentTask)); for (int th = 0; th < vsite->nthreads + 1; th++) { fprintf(debug, " %4d", vsite->tData[th]->idTask.nuse); diff --git a/src/gromacs/mdtypes/awh-history.h b/src/gromacs/mdtypes/awh-history.h index 5b26d7613b..ad00f270d0 100644 --- a/src/gromacs/mdtypes/awh-history.h +++ b/src/gromacs/mdtypes/awh-history.h @@ -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), diff --git a/src/gromacs/mdtypes/inputrec.cpp b/src/gromacs/mdtypes/inputrec.cpp index 8ca68dfafa..9b6434d9c6 100644 --- a/src/gromacs/mdtypes/inputrec.cpp +++ b/src/gromacs/mdtypes/inputrec.cpp @@ -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); diff --git a/src/gromacs/mdtypes/inputrec.h b/src/gromacs/mdtypes/inputrec.h index 9183e3c167..56eb94bfdf 100644 --- a/src/gromacs/mdtypes/inputrec.h +++ b/src/gromacs/mdtypes/inputrec.h @@ -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 diff --git a/src/gromacs/swap/swapcoords.cpp b/src/gromacs/swap/swapcoords.cpp index d1340d1d3f..ab7f5992be 100644 --- a/src/gromacs/swap/swapcoords.cpp +++ b/src/gromacs/swap/swapcoords.cpp @@ -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()); diff --git a/src/gromacs/topology/index.cpp b/src/gromacs/topology/index.cpp index 76f3a24e15..beca6b0355 100644 --- a/src/gromacs/topology/index.cpp +++ b/src/gromacs/topology/index.cpp @@ -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) { diff --git a/src/gromacs/topology/residuetypes.cpp b/src/gromacs/topology/residuetypes.cpp index ac8f2ac453..349d3cbf0c 100644 --- a/src/gromacs/topology/residuetypes.cpp +++ b/src/gromacs/topology/residuetypes.cpp @@ -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); diff --git a/src/gromacs/trajectoryanalysis/modules/freevolume.cpp b/src/gromacs/trajectoryanalysis/modules/freevolume.cpp index 93f0738f4d..c6d9923184 100644 --- a/src/gromacs/trajectoryanalysis/modules/freevolume.cpp +++ b/src/gromacs/trajectoryanalysis/modules/freevolume.cpp @@ -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_)