Fix part of old-style casting
authorRoland Schulz <roland.schulz@intel.com>
Mon, 2 Jul 2018 04:58:10 +0000 (21:58 -0700)
committerRoland Schulz <roland.schulz@intel.com>
Wed, 8 Aug 2018 02:01:27 +0000 (19:01 -0700)
Part clang-tidy google-readability-casting is able to do.
Manual fixes in:
fileio/vmdio.cpp
gmxlib/nonbonded/nonbonded.cpp
selection/sm_same.cpp
gmxana/gmx_anadock.cpp
gmxana/gmx_cluster.cpp

Change-Id: Iad15ea205ac56b29f8ecaea6556fabedec975736

125 files changed:
src/gromacs/analysisdata/modules/displacement.cpp
src/gromacs/commandline/filenm.cpp
src/gromacs/commandline/pargs.cpp
src/gromacs/correlationfunctions/autocorr.cpp
src/gromacs/correlationfunctions/expfit.cpp
src/gromacs/domdec/cellsizes.cpp
src/gromacs/domdec/domdec.cpp
src/gromacs/domdec/domdec_box.cpp
src/gromacs/domdec/domdec_setup.cpp
src/gromacs/essentialdynamics/edsam.cpp
src/gromacs/ewald/pme-load-balancing.cpp
src/gromacs/ewald/pme-redistribute.cpp
src/gromacs/ewald/pme.cpp
src/gromacs/fft/fft5d.cpp
src/gromacs/fft/fft_fftw3.cpp
src/gromacs/fft/parallel_3dfft.cpp
src/gromacs/fileio/enxio.cpp
src/gromacs/fileio/espio.cpp
src/gromacs/fileio/gmxfio-xdr.cpp
src/gromacs/fileio/gmxfio.cpp
src/gromacs/fileio/libxdrf.cpp
src/gromacs/fileio/matio.cpp
src/gromacs/fileio/md5.cpp
src/gromacs/fileio/pdbio.cpp
src/gromacs/fileio/tngio.cpp
src/gromacs/fileio/trxio.cpp
src/gromacs/fileio/vmdio.cpp
src/gromacs/fileio/writeps.cpp
src/gromacs/fileio/xdrd.cpp
src/gromacs/fileio/xtcio.cpp
src/gromacs/fileio/xvgr.cpp
src/gromacs/gmxana/gmx_anadock.cpp
src/gromacs/gmxana/gmx_awh.cpp
src/gromacs/gmxana/gmx_bar.cpp
src/gromacs/gmxana/gmx_cluster.cpp
src/gromacs/gmxana/gmx_density.cpp
src/gromacs/gmxana/gmx_dipoles.cpp
src/gromacs/gmxana/gmx_do_dssp.cpp
src/gromacs/gmxana/gmx_msd.cpp
src/gromacs/gmxana/gmx_order.cpp
src/gromacs/gmxana/gmx_trjconv.cpp
src/gromacs/gmxana/gmx_tune_pme.cpp
src/gromacs/gmxana/gmx_velacc.cpp
src/gromacs/gmxana/sfactor.cpp
src/gromacs/gmxlib/nonbonded/nonbonded.cpp
src/gromacs/gmxpreprocess/convparm.cpp
src/gromacs/gmxpreprocess/fflibutil.cpp
src/gromacs/gmxpreprocess/gen_ad.cpp
src/gromacs/gmxpreprocess/genconf.cpp
src/gromacs/gmxpreprocess/gmxcpp.cpp
src/gromacs/gmxpreprocess/gpp_bond_atomtype.cpp
src/gromacs/gmxpreprocess/gpp_nextnb.cpp
src/gromacs/gmxpreprocess/grompp.cpp
src/gromacs/gmxpreprocess/h_db.cpp
src/gromacs/gmxpreprocess/pdb2gmx.cpp
src/gromacs/gmxpreprocess/pdb2top.cpp
src/gromacs/gmxpreprocess/pgutil.cpp
src/gromacs/gmxpreprocess/readir.cpp
src/gromacs/gmxpreprocess/resall.cpp
src/gromacs/gmxpreprocess/topdirs.cpp
src/gromacs/gmxpreprocess/topio.cpp
src/gromacs/gmxpreprocess/toppush.cpp
src/gromacs/gmxpreprocess/toputil.cpp
src/gromacs/gmxpreprocess/x2top.cpp
src/gromacs/gmxpreprocess/xlate.cpp
src/gromacs/imd/imd.cpp
src/gromacs/imd/imdsocket.cpp
src/gromacs/listed-forces/listed-forces.cpp
src/gromacs/listed-forces/manage-threading.cpp
src/gromacs/math/invertmatrix.cpp
src/gromacs/mdlib/calc_verletbuf.cpp
src/gromacs/mdlib/calcmu.cpp
src/gromacs/mdlib/coupling.cpp
src/gromacs/mdlib/ebin.cpp
src/gromacs/mdlib/expanded.cpp
src/gromacs/mdlib/forcerec.cpp
src/gromacs/mdlib/md_support.cpp
src/gromacs/mdlib/mdebin.cpp
src/gromacs/mdlib/mdebin_bar.cpp
src/gromacs/mdlib/membed.cpp
src/gromacs/mdlib/nbnxn_atomdata.cpp
src/gromacs/mdlib/nbnxn_grid.cpp
src/gromacs/mdlib/nbnxn_kernels/nbnxn_kernel_gpu_ref.cpp
src/gromacs/mdlib/nbnxn_search.cpp
src/gromacs/mdlib/ns.cpp
src/gromacs/mdlib/nsgrid.cpp
src/gromacs/mdlib/qmmm.cpp
src/gromacs/mdlib/repl_ex.cpp
src/gromacs/mdlib/rf_util.cpp
src/gromacs/mdlib/shake.cpp
src/gromacs/mdlib/shellfc.cpp
src/gromacs/mdlib/sighandler.cpp
src/gromacs/mdlib/sim_util.cpp
src/gromacs/mdrun/md.cpp
src/gromacs/mdrun/minimize.cpp
src/gromacs/mdrun/runner.cpp
src/gromacs/mdrun/tpi.cpp
src/gromacs/mdtypes/inputrec.cpp
src/gromacs/pbcutil/mshift.cpp
src/gromacs/pulling/pull_rotation.cpp
src/gromacs/selection/evaluate.cpp
src/gromacs/selection/mempool.cpp
src/gromacs/selection/parsetree.cpp
src/gromacs/selection/sm_compare.cpp
src/gromacs/selection/sm_insolidangle.cpp
src/gromacs/selection/sm_keywords.cpp
src/gromacs/selection/sm_merge.cpp
src/gromacs/selection/sm_permute.cpp
src/gromacs/selection/sm_position.cpp
src/gromacs/selection/sm_same.cpp
src/gromacs/statistics/statistics.cpp
src/gromacs/swap/swapcoords.cpp
src/gromacs/tables/forcetable.cpp
src/gromacs/timing/wallcycle.cpp
src/gromacs/tools/convert_tpr.cpp
src/gromacs/topology/atomprop.cpp
src/gromacs/topology/index.cpp
src/gromacs/topology/mtop_util.cpp
src/gromacs/topology/symtab.cpp
src/gromacs/topology/topology.cpp
src/gromacs/trajectoryanalysis/modules/surfacearea.cpp
src/gromacs/utility/binaryinformation.cpp
src/gromacs/utility/cstringutil.cpp
src/gromacs/utility/qsort_threadsafe.cpp
src/gromacs/utility/smalloc.cpp

index ae8a05ed212e20bd2ea10e40c1cc6b12e808c35a..310572c3df222846da494376ac408b5928a02997 100644 (file)
@@ -212,7 +212,7 @@ AnalysisDataDisplacementModule::frameStarted(const AnalysisDataFrameHeader &head
     // Allocate memory for all the positions once it is possible.
     if (_impl->max_store == -1 && !_impl->bFirst)
     {
-        _impl->max_store = _impl->nmax * (int)(_impl->tmax/_impl->dt + 1);
+        _impl->max_store = _impl->nmax * static_cast<int>(_impl->tmax/_impl->dt + 1);
         srenew(_impl->oldval, _impl->max_store);
     }
 
index e3461b35249025dc381fd8ee655ce80a81442c66..274661287d68e9d30ca62fec0a0f73589ef267bc 100644 (file)
@@ -158,7 +158,7 @@ gmx_bool ftp2bSet(int ftp, int nfile, const t_filenm fnm[])
     {
         if (ftp == fnm[i].ftp)
         {
-            return (gmx_bool) IS_SET(fnm[i]);
+            return static_cast<gmx_bool>(IS_SET(fnm[i]));
         }
     }
 
@@ -173,7 +173,7 @@ gmx_bool opt2bSet(const char *opt, int nfile, const t_filenm fnm[])
 
     if (fileOption)
     {
-        return (gmx_bool) IS_SET(*fileOption);
+        return static_cast<gmx_bool>(IS_SET(*fileOption));
     }
 
     GMX_RELEASE_ASSERT(false, "opt2bSet should be called with a valid option");
index 20975cb5fba20b7d23652a29839f8426ad85df2b..87a602ca65324869995b98fd2e81c8e4f777f584 100644 (file)
@@ -566,8 +566,8 @@ gmx_bool parse_common_args(int *argc, char *argv[], unsigned long Flags,
 
         /* set program name, command line, and default values for output options */
         output_env_init(oenv, gmx::getProgramContext(),
-                        (time_unit_t)(timeUnit + 1), bView, // NOLINT(misc-misplaced-widening-cast)
-                        (xvg_format_t)(xvgFormat + 1), 0);
+                        static_cast<time_unit_t>(timeUnit + 1), bView, // NOLINT(misc-misplaced-widening-cast)
+                        static_cast<xvg_format_t>(xvgFormat + 1), 0);
 
         /* Extract Time info from arguments */
         if (bBeginTimeSet)
index 61dc522a28222d2b64019cc21b65958219c0664c..63560a924ae639de95fb8659cada326f7c78f3df 100644 (file)
@@ -525,7 +525,7 @@ static void do_four_core(unsigned long mode, int nframes,
     sfree(cfour);
     for (j = 0; (j < nframes); j++)
     {
-        c1[j] = csum[j]/(real)(nframes-j);
+        c1[j] = csum[j]/static_cast<real>(nframes-j);
     }
 }
 
index 61070fbee6e55c91208b5dc938bfe8b95ad582a6..b8c3176c17aa379efe5ee101cba7aa2583f477ab 100644 (file)
@@ -626,7 +626,7 @@ real do_lmfit(int ndata, const real c1[], real sig[], real dt, const real *x0,
             }
             else
             {
-                dy[j] = std::max(1.0e-7, (double)sig[i]);
+                dy[j] = std::max(1.0e-7, static_cast<double>(sig[i]));
             }
             if (debug)
             {
@@ -756,7 +756,7 @@ real fit_acf(int ncorr, int fitfn, const gmx_output_env_t *oenv, gmx_bool bVerbo
     {
         tendfit = ncorr*dt;
     }
-    nf_int = std::min(ncorr, (int)(tendfit/dt));
+    nf_int = std::min(ncorr, static_cast<int>(tendfit/dt));
     sum    = print_and_integrate(debug, nf_int, dt, c1, nullptr, 1);
 
     if (bPrint)
@@ -841,7 +841,7 @@ real fit_acf(int ncorr, int fitfn, const gmx_output_env_t *oenv, gmx_bool bVerbo
             sig[i] = sqrt(ct_estimate+dt*i);
         }
 
-        nf_int    = std::min(ncorr, (int)((tStart+1e-4)/dt));
+        nf_int    = std::min(ncorr, static_cast<int>((tStart+1e-4)/dt));
         sum       = print_and_integrate(debug, nf_int, dt, c1, nullptr, 1);
         tail_corr = do_lmfit(ncorr, c1, sig, dt, nullptr, tStart, tendfit, oenv,
                              bDebugMode(), fitfn, fitparm, 0, nullptr);
index e85f2e726fef7c5c490850bc6c5e297f7b0f1eb9..1a776ebf384e60ec975f6d55006ec0a472615c5e 100644 (file)
@@ -101,7 +101,7 @@ static void set_pme_maxshift(gmx_domdec_t *dd, gmx_ddpme_t *ddpme,
         for (s = 0; s < ns; s++)
         {
             /* PME slab s spreads atoms between box frac. s/ns and (s+1)/ns */
-            pme_boundary = (real)s/ns;
+            pme_boundary = static_cast<real>(s)/ns;
             while (sh + 1 < ns &&
                    ((s - (sh + 1) >= 0 &&
                      cellFrac[xmax[s - (sh + 1)     ] + 1]     + range > pme_boundary) ||
@@ -110,7 +110,7 @@ static void set_pme_maxshift(gmx_domdec_t *dd, gmx_ddpme_t *ddpme,
             {
                 sh++;
             }
-            pme_boundary = (real)(s+1)/ns;
+            pme_boundary = static_cast<real>(s+1)/ns;
             while (sh + 1 < ns &&
                    ((s + (sh + 1) <  ns &&
                      cellFrac[xmin[s + (sh + 1)    ]  ]     - range < pme_boundary) ||
@@ -759,10 +759,10 @@ static void distribute_dd_cell_sizes_dlb(gmx_domdec_t *dd,
         relative_to_absolute_cell_bounds(dd, ddbox, d1);
     }
     /* Convert the communicated shift from float to int */
-    comm.ddpme[0].maxshift = (int)(cellFracRow[pos++] + 0.5);
+    comm.ddpme[0].maxshift = static_cast<int>(cellFracRow[pos++] + 0.5);
     if (d >= 1)
     {
-        comm.ddpme[1].maxshift = (int)(cellFracRow[pos++] + 0.5);
+        comm.ddpme[1].maxshift = static_cast<int>(cellFracRow[pos++] + 0.5);
     }
 }
 
index b89a53f46d1f62a095090a7587ec77b43b6bdc46..2866d86fcb6f2692b42b3eedcf8731137b78908f 100644 (file)
@@ -1841,7 +1841,7 @@ static float dd_force_load(gmx_domdec_comm_t *comm)
                  * is spurious CPU activity or MPI time, so we don't expect
                  * that changes in the GPU wait time matter a lot here.
                  */
-                gpu_wait *= (comm->cycl_n[ddCyclF] - 1)/(float)comm->cycl_n[ddCyclF];
+                gpu_wait *= (comm->cycl_n[ddCyclF] - 1)/static_cast<float>(comm->cycl_n[ddCyclF]);
             }
             /* Sum the wait times over the ranks that share the same GPU */
             MPI_Allreduce(&gpu_wait, &gpu_wait_sum, 1, MPI_FLOAT, MPI_SUM,
@@ -1872,7 +1872,7 @@ static void set_slb_pme_dim_f(gmx_domdec_t *dd, int dim, real **dim_f)
         }
         else
         {
-            (*dim_f)[i] = (real)i/(real)dd->nc[dim];
+            (*dim_f)[i] = static_cast<real>(i)/static_cast<real>(dd->nc[dim]);
         }
     }
     (*dim_f)[dd->nc[dim]] = 1;
@@ -2223,7 +2223,7 @@ static void get_load_distribution(gmx_domdec_t *dd, gmx_wallcycle_t wcycle)
                         pos++;
                         if (d < dd->ndim-1)
                         {
-                            load->flags = (int)(load->load[pos++] + 0.5);
+                            load->flags = static_cast<int>(load->load[pos++] + 0.5);
                         }
                         if (d > 0)
                         {
@@ -2532,7 +2532,7 @@ static void dd_print_load_verbose(gmx_domdec_t *dd)
     }
     if (dd->nnodes > 1)
     {
-        fprintf(stderr, "imb F %2d%% ", (int)(dd_f_imbal(dd)*100+0.5));
+        fprintf(stderr, "imb F %2d%% ", static_cast<int>(dd_f_imbal(dd)*100+0.5));
     }
     if (dd->comm->cycl_n[ddCyclPME])
     {
@@ -4185,7 +4185,7 @@ static void set_cell_limits_dlb(gmx_domdec_t      *dd,
          * Later cellsize_limit is redetermined,
          * so we can not miss interactions due to this rounding.
          */
-        npulse = (int)(0.96 + comm->cutoff/comm->cellsize_limit);
+        npulse = static_cast<int>(0.96 + comm->cutoff/comm->cellsize_limit);
     }
     else
     {
@@ -4200,8 +4200,8 @@ static void set_cell_limits_dlb(gmx_domdec_t      *dd,
         for (d = 0; d < dd->ndim; d++)
         {
             dim      = dd->dim[d];
-            npulse_d = (int)(1 + dd->nc[dim]*comm->cutoff
-                             /(ddbox->box_size[dim]*ddbox->skew_fac[dim]*dlb_scale));
+            npulse_d = static_cast<int>(1 + dd->nc[dim]*comm->cutoff
+                                        /(ddbox->box_size[dim]*ddbox->skew_fac[dim]*dlb_scale));
             npulse_d_max = std::max(npulse_d_max, npulse_d);
         }
         npulse = std::min(npulse, npulse_d_max);
@@ -4319,12 +4319,12 @@ static void set_ddgrid_parameters(FILE *fplog, gmx_domdec_t *dd, real dlb_scale,
 
     if (ir->ePBC == epbcNONE)
     {
-        vol_frac = 1 - 1/(double)dd->nnodes;
+        vol_frac = 1 - 1/static_cast<double>(dd->nnodes);
     }
     else
     {
         vol_frac =
-            (1 + comm_box_frac(dd->nc, comm->cutoff, ddbox))/(double)dd->nnodes;
+            (1 + comm_box_frac(dd->nc, comm->cutoff, ddbox))/static_cast<double>(dd->nnodes);
     }
     if (debug)
     {
@@ -4465,7 +4465,7 @@ static gmx_bool test_dd_cutoff(t_commrec *cr,
             inv_cell_size *= DD_PRES_SCALE_MARGIN;
         }
 
-        np = 1 + (int)(cutoff_req*inv_cell_size*ddbox.skew_fac[dim]);
+        np = 1 + static_cast<int>(cutoff_req*inv_cell_size*ddbox.skew_fac[dim]);
 
         if (!isDlbDisabled(dd->comm) && (dim < ddbox.npbcdim) && (dd->comm->cd[d].np_dlb > 0))
         {
index 96240bdd313ca9375124d1810e00e5a42a915b4b..ebd4de8d1b8f10ecb1120e2d42b0f7a03bd29f26 100644 (file)
@@ -103,7 +103,7 @@ static void calc_pos_av_stddev(int n, const rvec *x,
             s1[d] = receiveBuffer[d];
             s2[d] = receiveBuffer[DIM + d];
         }
-        n = (int)(receiveBuffer[6] + 0.5);
+        n = static_cast<int>(receiveBuffer[6] + 0.5);
     }
 #else  // GMX_MPI
     GMX_UNUSED_VALUE(mpiCommunicator);
index 6be8f7971d8e4be805dab52cee8e07307097747e..84f1b0534e5ba413f490f81e725105a9444d9fba 100644 (file)
@@ -134,7 +134,7 @@ static int lcd(int n1, int n2)
 /*! \brief Returns TRUE when there are enough PME ranks for the ratio */
 static gmx_bool fits_pme_ratio(int nrank_tot, int nrank_pme, float ratio)
 {
-    return ((double)nrank_pme/(double)nrank_tot > 0.95*ratio);
+    return (static_cast<double>(nrank_pme)/static_cast<double>(nrank_tot) > 0.95*ratio);
 }
 
 /*! \brief Returns TRUE when npme out of ntot ranks doing PME is expected to give reasonable performance */
@@ -238,7 +238,7 @@ static int guess_npme(FILE *fplog, const gmx_mtop_t *mtop, const t_inputrec *ir,
     {
         gmx_fatal(FARGS, "Could not find an appropriate number of separate PME ranks. i.e. >= %5f*#ranks (%d) and <= #ranks/2 (%d) and reasonable performance wise (grid_x=%d, grid_y=%d).\n"
                   "Use the -npme option of mdrun or change the number of ranks or the PME grid dimensions, see the manual for details.",
-                  ratio, (int)(0.95*ratio*nrank_tot + 0.5), nrank_tot/2, ir->nkx, ir->nky);
+                  ratio, static_cast<int>(0.95*ratio*nrank_tot + 0.5), nrank_tot/2, ir->nkx, ir->nky);
     }
     else
     {
@@ -491,7 +491,7 @@ static float comm_cost_est(real limit, real cutoff,
             }
             else
             {
-                comm_vol_xf = 1.0 - lcd(nc[i], npme[i])/(double)npme[i];
+                comm_vol_xf = 1.0 - lcd(nc[i], npme[i])/static_cast<double>(npme[i]);
             }
             comm_pme += 3*natoms*comm_vol_xf;
         }
@@ -646,7 +646,7 @@ static real optimize_ncells(FILE *fplog,
          * Here we ignore SIMD bondeds as they always do (fast) PBC.
          */
         count_bonded_distances(mtop, ir, &pbcdxr, nullptr);
-        pbcdxr /= (double)mtop->natoms;
+        pbcdxr /= static_cast<double>(mtop->natoms);
     }
     else
     {
@@ -689,7 +689,7 @@ static real optimize_ncells(FILE *fplog,
             fprintf(fplog, "The maximum allowed number of cells is:");
             for (d = 0; d < DIM; d++)
             {
-                nmax = (int)(ddbox->box_size[d]*ddbox->skew_fac[d]/limit);
+                nmax = static_cast<int>(ddbox->box_size[d]*ddbox->skew_fac[d]/limit);
                 if (d >= ddbox->npbcdim && nmax < 2)
                 {
                     nmax = 2;
index e535c5f5cc87b022f8b2193851e7a7942b67e102..e5b3e322f801c9a491ce69f4b37b79218cf323f8 100644 (file)
@@ -1421,7 +1421,7 @@ static real read_checked_edreal(FILE *file, const char *label)
     check(line, label);
     fgets2 (line, STRLEN, file);
     sscanf (line, max_ev_fmt_lf, &rdum);
-    return (real) rdum; /* always read as double and convert to single */
+    return static_cast<real>(rdum); /* always read as double and convert to single */
 }
 
 
@@ -1873,7 +1873,7 @@ static real rmsd_from_structure(rvec           *x,  /* The positions under consi
         rmsd += distance2(s->x[i], x[i]);
     }
 
-    rmsd /= (real) s->nr;
+    rmsd /= static_cast<real>(s->nr);
     rmsd  = sqrt(rmsd);
 
     return rmsd;
index 6aa4e512b7bbd965f6bcf502ff6c707bcbb2503e..971a47e3e522df1edf919d30fc1956cca2018eec 100644 (file)
@@ -1084,7 +1084,7 @@ static void print_pme_loadbal_settings(pme_load_balancing_t *pme_lb,
     pp_ratio_temporary = pme_lb->setup[pme_lb->cur].rlistInner / pme_lb->setup[0].rlistInner;
     pp_ratio           = gmx::power3(pp_ratio_temporary);
     grid_ratio         = pme_grid_points(&pme_lb->setup[pme_lb->cur])/
-        (double)pme_grid_points(&pme_lb->setup[0]);
+        static_cast<double>(pme_grid_points(&pme_lb->setup[0]));
 
     fprintf(fplog, "\n");
     fprintf(fplog, "       P P   -   P M E   L O A D   B A L A N C I N G\n");
index 045646a4ad4cad7b103a3e9636672fdad0f8bda3..e0b8defda5f6de75c167384ede589e2e2696edf0 100644 (file)
@@ -87,7 +87,7 @@ static void pme_calc_pidx(int start, int end,
             xptr   = x[i];
             /* Fractional coordinates along box vectors */
             s     = nslab*(xptr[XX]*rxx + xptr[YY]*ryx + xptr[ZZ]*rzx);
-            si    = (int)(s + 2*nslab) % nslab;
+            si    = static_cast<int>(s + 2*nslab) % nslab;
             pd[i] = si;
             count[si]++;
         }
@@ -102,7 +102,7 @@ static void pme_calc_pidx(int start, int end,
             xptr   = x[i];
             /* Fractional coordinates along box vectors */
             s     = nslab*(xptr[YY]*ryy + xptr[ZZ]*rzy);
-            si    = (int)(s + 2*nslab) % nslab;
+            si    = static_cast<int>(s + 2*nslab) % nslab;
             pd[i] = si;
             count[si]++;
         }
index ccb6e7af3527e6f88ca21c296fbc4eaf24dcb179..3d3f9220d43359e208cd055e87b2aefbef1b7d3b 100644 (file)
@@ -301,7 +301,7 @@ static double estimate_pme_load_imbalance(struct gmx_pme_t *pme)
 
     /* pme_solve is roughly double the cost of an fft */
 
-    return (n1 + n2 + 3*n3)/(double)(6*pme->nkx*pme->nky*pme->nkz);
+    return (n1 + n2 + 3*n3)/static_cast<double>(6*pme->nkx*pme->nky*pme->nkz);
 }
 
 /*! \brief Initialize atom communication data structure */
@@ -809,7 +809,7 @@ gmx_pme_t *gmx_pme_init(const t_commrec     *cr,
                     "      PME grid_x (%d) and grid_y (%d) should be divisible by #PME_ranks_x (%d)\n"
                     "      and PME grid_y (%d) and grid_z (%d) should be divisible by #PME_ranks_y (%d)\n"
                     "\n",
-                    (int)((imbal-1)*100 + 0.5),
+                    static_cast<int>((imbal-1)*100 + 0.5),
                     pme->nkx, pme->nky, pme->nnodes_major,
                     pme->nky, pme->nkz, pme->nnodes_minor);
         }
index a355672c1306b2857255786e217a409291d1dad2..12c1e010f800de5bdcac40c154cf98fb1849079c 100644 (file)
@@ -241,12 +241,12 @@ fft5d_plan fft5d_plan_3d(int NG, int MG, int KG, MPI_Comm comm[2], int flags, t_
 
     /*for transpose we need to know the size for each processor not only our own size*/
 
-    N0  = (int*)malloc(P[0]*sizeof(int)); N1 = (int*)malloc(P[1]*sizeof(int));
-    M0  = (int*)malloc(P[0]*sizeof(int)); M1 = (int*)malloc(P[1]*sizeof(int));
-    K0  = (int*)malloc(P[0]*sizeof(int)); K1 = (int*)malloc(P[1]*sizeof(int));
-    oN0 = (int*)malloc(P[0]*sizeof(int)); oN1 = (int*)malloc(P[1]*sizeof(int));
-    oM0 = (int*)malloc(P[0]*sizeof(int)); oM1 = (int*)malloc(P[1]*sizeof(int));
-    oK0 = (int*)malloc(P[0]*sizeof(int)); oK1 = (int*)malloc(P[1]*sizeof(int));
+    N0  = static_cast<int*>(malloc(P[0]*sizeof(int))); N1 = static_cast<int*>(malloc(P[1]*sizeof(int)));
+    M0  = static_cast<int*>(malloc(P[0]*sizeof(int))); M1 = static_cast<int*>(malloc(P[1]*sizeof(int)));
+    K0  = static_cast<int*>(malloc(P[0]*sizeof(int))); K1 = static_cast<int*>(malloc(P[1]*sizeof(int)));
+    oN0 = static_cast<int*>(malloc(P[0]*sizeof(int))); oN1 = static_cast<int*>(malloc(P[1]*sizeof(int)));
+    oM0 = static_cast<int*>(malloc(P[0]*sizeof(int))); oM1 = static_cast<int*>(malloc(P[1]*sizeof(int)));
+    oK0 = static_cast<int*>(malloc(P[0]*sizeof(int))); oK1 = static_cast<int*>(malloc(P[1]*sizeof(int)));
 
     for (i = 0; i < P[0]; i++)
     {
@@ -430,7 +430,7 @@ fft5d_plan fft5d_plan_3d(int NG, int MG, int KG, MPI_Comm comm[2], int flags, t_
         }
     }
 
-    plan = (fft5d_plan)calloc(1, sizeof(struct fft5d_plan_t));
+    plan = static_cast<fft5d_plan>(calloc(1, sizeof(struct fft5d_plan_t)));
 
 
     if (debug)
@@ -542,21 +542,21 @@ fft5d_plan fft5d_plan_3d(int NG, int MG, int KG, MPI_Comm comm[2], int flags, t_
         {
             plan->p3d = FFTW(plan_guru_dft_r2c)(/*rank*/ 3, dims,
                                                          /*howmany*/ 0, /*howmany_dims*/ nullptr,
-                                                         (real*)lin, (FFTW(complex) *) lout,
+                                                         reinterpret_cast<real*>(lin), reinterpret_cast<FFTW(complex) *>(lout),
                                                          /*flags*/ fftwflags);
         }
         else if ((flags&FFT5D_REALCOMPLEX) && (flags&FFT5D_BACKWARD))
         {
             plan->p3d = FFTW(plan_guru_dft_c2r)(/*rank*/ 3, dims,
                                                          /*howmany*/ 0, /*howmany_dims*/ nullptr,
-                                                         (FFTW(complex) *) lin, (real*)lout,
+                                                         reinterpret_cast<FFTW(complex) *>(lin), reinterpret_cast<real*>(lout),
                                                          /*flags*/ fftwflags);
         }
         else
         {
             plan->p3d = FFTW(plan_guru_dft)(/*rank*/ 3, dims,
                                                      /*howmany*/ 0, /*howmany_dims*/ nullptr,
-                                                     (FFTW(complex) *) lin, (FFTW(complex) *) lout,
+                                                     reinterpret_cast<FFTW(complex) *>(lin), reinterpret_cast<FFTW(complex) *>(lout),
                                                      /*sign*/ (flags&FFT5D_BACKWARD) ? 1 : -1, /*flags*/ fftwflags);
         }
 #ifdef FFT5D_THREADS
@@ -576,7 +576,7 @@ fft5d_plan fft5d_plan_3d(int NG, int MG, int KG, MPI_Comm comm[2], int flags, t_
             fprintf(debug, "FFT5D: Plan s %d rC %d M %d pK %d C %d lsize %d\n",
                     s, rC[s], M[s], pK[s], C[s], lsize);
         }
-        plan->p1d[s] = (gmx_fft_t*)malloc(sizeof(gmx_fft_t)*nthreads);
+        plan->p1d[s] = static_cast<gmx_fft_t*>(malloc(sizeof(gmx_fft_t)*nthreads));
 
         /* Make sure that the init routines are only called by one thread at a time and in order
            (later is only important to not confuse valgrind)
@@ -1113,11 +1113,11 @@ void fft5d_execute(fft5d_plan plan, int thread, fft5d_time times)
 #if GMX_MPI
                 if ((s == 0 && !(plan->flags&FFT5D_ORDER_YZ)) || (s == 1 && (plan->flags&FFT5D_ORDER_YZ)))
                 {
-                    MPI_Alltoall((real *)lout2, N[s]*pM[s]*K[s]*sizeof(t_complex)/sizeof(real), GMX_MPI_REAL, (real *)lout3, N[s]*pM[s]*K[s]*sizeof(t_complex)/sizeof(real), GMX_MPI_REAL, cart[s]);
+                    MPI_Alltoall(reinterpret_cast<real *>(lout2), N[s]*pM[s]*K[s]*sizeof(t_complex)/sizeof(real), GMX_MPI_REAL, reinterpret_cast<real *>(lout3), N[s]*pM[s]*K[s]*sizeof(t_complex)/sizeof(real), GMX_MPI_REAL, cart[s]);
                 }
                 else
                 {
-                    MPI_Alltoall((real *)lout2, N[s]*M[s]*pK[s]*sizeof(t_complex)/sizeof(real), GMX_MPI_REAL, (real *)lout3, N[s]*M[s]*pK[s]*sizeof(t_complex)/sizeof(real), GMX_MPI_REAL, cart[s]);
+                    MPI_Alltoall(reinterpret_cast<real *>(lout2), N[s]*M[s]*pK[s]*sizeof(t_complex)/sizeof(real), GMX_MPI_REAL, reinterpret_cast<real *>(lout3), N[s]*M[s]*pK[s]*sizeof(t_complex)/sizeof(real), GMX_MPI_REAL, cart[s]);
                 }
 #else
                 gmx_incons("fft5d MPI call without MPI configuration");
index b8eceda133a12dc447ac5dc5c9dc98c910bfce30..75a0f80e94a7c9ee3194e6974ceb4cd9203b6b25 100644 (file)
@@ -2,7 +2,7 @@
  * This file is part of the GROMACS molecular simulation package.
  *
  * Copyright (c) 1991-2003 David van der Spoel, Erik Lindahl, University of Groningen.
- * Copyright (c) 2013,2014,2015,2017, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2015,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.
@@ -128,14 +128,14 @@ gmx_fft_init_many_1d(gmx_fft_t *        pfft,
     *pfft = nullptr;
 
     FFTW_LOCK;
-    if ( (fft = (gmx_fft_t)FFTWPREFIX(malloc)(sizeof(struct gmx_fft))) == nullptr)
+    if ( (fft = static_cast<gmx_fft_t>(FFTWPREFIX(malloc)(sizeof(struct gmx_fft)))) == nullptr)
     {
         FFTW_UNLOCK;
         return ENOMEM;
     }
 
     /* allocate aligned, and extra memory to make it unaligned */
-    p1  = (FFTWPREFIX(complex) *) FFTWPREFIX(malloc)(sizeof(FFTWPREFIX(complex))*(nx+2)*howmany);
+    p1  = static_cast<FFTWPREFIX(complex) *>(FFTWPREFIX(malloc)(sizeof(FFTWPREFIX(complex))*(nx+2)*howmany));
     if (p1 == nullptr)
     {
         FFTWPREFIX(free)(fft);
@@ -143,7 +143,7 @@ gmx_fft_init_many_1d(gmx_fft_t *        pfft,
         return ENOMEM;
     }
 
-    p2  = (FFTWPREFIX(complex) *) FFTWPREFIX(malloc)(sizeof(FFTWPREFIX(complex))*(nx+2)*howmany);
+    p2  = static_cast<FFTWPREFIX(complex) *>(FFTWPREFIX(malloc)(sizeof(FFTWPREFIX(complex))*(nx+2)*howmany));
     if (p2 == nullptr)
     {
         FFTWPREFIX(free)(p1);
@@ -245,14 +245,14 @@ gmx_fft_init_many_1d_real(gmx_fft_t *        pfft,
     *pfft = nullptr;
 
     FFTW_LOCK;
-    if ( (fft = (gmx_fft_t) FFTWPREFIX(malloc)(sizeof(struct gmx_fft))) == nullptr)
+    if ( (fft = static_cast<gmx_fft_t>(FFTWPREFIX(malloc)(sizeof(struct gmx_fft)))) == nullptr)
     {
         FFTW_UNLOCK;
         return ENOMEM;
     }
 
     /* allocate aligned, and extra memory to make it unaligned */
-    p1  = (real *) FFTWPREFIX(malloc)(sizeof(real)*(nx/2+1)*2*howmany + 8);
+    p1  = static_cast<real *>(FFTWPREFIX(malloc)(sizeof(real)*(nx/2+1)*2*howmany + 8));
     if (p1 == nullptr)
     {
         FFTWPREFIX(free)(fft);
@@ -260,7 +260,7 @@ gmx_fft_init_many_1d_real(gmx_fft_t *        pfft,
         return ENOMEM;
     }
 
-    p2  = (real *) FFTWPREFIX(malloc)(sizeof(real)*(nx/2+1)*2*howmany + 8);
+    p2  = static_cast<real *>(FFTWPREFIX(malloc)(sizeof(real)*(nx/2+1)*2*howmany + 8));
     if (p2 == nullptr)
     {
         FFTWPREFIX(free)(p1);
@@ -287,15 +287,15 @@ gmx_fft_init_many_1d_real(gmx_fft_t *        pfft,
                                       fftw_complex *out, const int *onembed,
                                       int ostride, int odist,
                                       unsigned flag    */
-    fft->plan[0][0][1] = FFTWPREFIX(plan_many_dft_r2c)(1, &nx, howmany, up1, nullptr, 1, (nx/2+1) *2, (FFTWPREFIX(complex) *) up2, nullptr, 1, (nx/2+1), fftw_flags);
-    fft->plan[0][1][1] = FFTWPREFIX(plan_many_dft_r2c)(1, &nx, howmany, up1, nullptr, 1, (nx/2+1) *2, (FFTWPREFIX(complex) *) up1, nullptr, 1, (nx/2+1), fftw_flags);
-    fft->plan[1][0][1] = FFTWPREFIX(plan_many_dft_r2c)(1, &nx, howmany, p1, nullptr, 1, (nx/2+1) *2, (FFTWPREFIX(complex) *) p2, nullptr, 1, (nx/2+1), fftw_flags);
-    fft->plan[1][1][1] = FFTWPREFIX(plan_many_dft_r2c)(1, &nx, howmany, p1, nullptr, 1, (nx/2+1) *2, (FFTWPREFIX(complex) *) p1, nullptr, 1, (nx/2+1), fftw_flags);
+    fft->plan[0][0][1] = FFTWPREFIX(plan_many_dft_r2c)(1, &nx, howmany, up1, nullptr, 1, (nx/2+1) *2, reinterpret_cast<FFTWPREFIX(complex) *>(up2), nullptr, 1, (nx/2+1), fftw_flags);
+    fft->plan[0][1][1] = FFTWPREFIX(plan_many_dft_r2c)(1, &nx, howmany, up1, nullptr, 1, (nx/2+1) *2, reinterpret_cast<FFTWPREFIX(complex) *>(up1), nullptr, 1, (nx/2+1), fftw_flags);
+    fft->plan[1][0][1] = FFTWPREFIX(plan_many_dft_r2c)(1, &nx, howmany, p1, nullptr, 1, (nx/2+1) *2, reinterpret_cast<FFTWPREFIX(complex) *>(p2), nullptr, 1, (nx/2+1), fftw_flags);
+    fft->plan[1][1][1] = FFTWPREFIX(plan_many_dft_r2c)(1, &nx, howmany, p1, nullptr, 1, (nx/2+1) *2, reinterpret_cast<FFTWPREFIX(complex) *>(p1), nullptr, 1, (nx/2+1), fftw_flags);
 
-    fft->plan[0][0][0] = FFTWPREFIX(plan_many_dft_c2r)(1, &nx, howmany, (FFTWPREFIX(complex) *) up1, nullptr, 1, (nx/2+1), up2, nullptr, 1, (nx/2+1) *2, fftw_flags);
-    fft->plan[0][1][0] = FFTWPREFIX(plan_many_dft_c2r)(1, &nx, howmany, (FFTWPREFIX(complex) *) up1, nullptr, 1, (nx/2+1), up1, nullptr, 1, (nx/2+1) *2, fftw_flags);
-    fft->plan[1][0][0] = FFTWPREFIX(plan_many_dft_c2r)(1, &nx, howmany, (FFTWPREFIX(complex) *) p1, nullptr, 1, (nx/2+1), p2, nullptr, 1, (nx/2+1) *2, fftw_flags);
-    fft->plan[1][1][0] = FFTWPREFIX(plan_many_dft_c2r)(1, &nx, howmany, (FFTWPREFIX(complex) *) p1, nullptr, 1, (nx/2+1), p1, nullptr, 1, (nx/2+1) *2, fftw_flags);
+    fft->plan[0][0][0] = FFTWPREFIX(plan_many_dft_c2r)(1, &nx, howmany, reinterpret_cast<FFTWPREFIX(complex) *>(up1), nullptr, 1, (nx/2+1), up2, nullptr, 1, (nx/2+1) *2, fftw_flags);
+    fft->plan[0][1][0] = FFTWPREFIX(plan_many_dft_c2r)(1, &nx, howmany, reinterpret_cast<FFTWPREFIX(complex) *>(up1), nullptr, 1, (nx/2+1), up1, nullptr, 1, (nx/2+1) *2, fftw_flags);
+    fft->plan[1][0][0] = FFTWPREFIX(plan_many_dft_c2r)(1, &nx, howmany, reinterpret_cast<FFTWPREFIX(complex) *>(p1), nullptr, 1, (nx/2+1), p2, nullptr, 1, (nx/2+1) *2, fftw_flags);
+    fft->plan[1][1][0] = FFTWPREFIX(plan_many_dft_c2r)(1, &nx, howmany, reinterpret_cast<FFTWPREFIX(complex) *>(p1), nullptr, 1, (nx/2+1), p1, nullptr, 1, (nx/2+1) *2, fftw_flags);
 
     for (i = 0; i < 2; i++)
     {
@@ -356,14 +356,14 @@ gmx_fft_init_2d_real(gmx_fft_t *        pfft,
     *pfft = nullptr;
 
     FFTW_LOCK;
-    if ( (fft = (gmx_fft_t) FFTWPREFIX(malloc)(sizeof(struct gmx_fft))) == nullptr)
+    if ( (fft = static_cast<gmx_fft_t>(FFTWPREFIX(malloc)(sizeof(struct gmx_fft)))) == nullptr)
     {
         FFTW_UNLOCK;
         return ENOMEM;
     }
 
     /* allocate aligned, and extra memory to make it unaligned */
-    p1  = (real *) FFTWPREFIX(malloc)(sizeof(real) *( nx*(ny/2+1)*2 + 2) );
+    p1  = static_cast<real *>(FFTWPREFIX(malloc)(sizeof(real) *( nx*(ny/2+1)*2 + 2) ));
     if (p1 == nullptr)
     {
         FFTWPREFIX(free)(fft);
@@ -371,7 +371,7 @@ gmx_fft_init_2d_real(gmx_fft_t *        pfft,
         return ENOMEM;
     }
 
-    p2  = (real *) FFTWPREFIX(malloc)(sizeof(real) *( nx*(ny/2+1)*2 + 2) );
+    p2  = static_cast<real *>(FFTWPREFIX(malloc)(sizeof(real) *( nx*(ny/2+1)*2 + 2) ));
     if (p2 == nullptr)
     {
         FFTWPREFIX(free)(p1);
@@ -393,15 +393,15 @@ gmx_fft_init_2d_real(gmx_fft_t *        pfft,
     up2 = (real *)pc;
 
 
-    fft->plan[0][0][0] = FFTWPREFIX(plan_dft_c2r_2d)(nx, ny, (FFTWPREFIX(complex) *) up1, up2, fftw_flags);
-    fft->plan[0][0][1] = FFTWPREFIX(plan_dft_r2c_2d)(nx, ny, up1, (FFTWPREFIX(complex) *) up2, fftw_flags);
-    fft->plan[0][1][0] = FFTWPREFIX(plan_dft_c2r_2d)(nx, ny, (FFTWPREFIX(complex) *) up1, up1, fftw_flags);
-    fft->plan[0][1][1] = FFTWPREFIX(plan_dft_r2c_2d)(nx, ny, up1, (FFTWPREFIX(complex) *) up1, fftw_flags);
+    fft->plan[0][0][0] = FFTWPREFIX(plan_dft_c2r_2d)(nx, ny, reinterpret_cast<FFTWPREFIX(complex) *>(up1), up2, fftw_flags);
+    fft->plan[0][0][1] = FFTWPREFIX(plan_dft_r2c_2d)(nx, ny, up1, reinterpret_cast<FFTWPREFIX(complex) *>(up2), fftw_flags);
+    fft->plan[0][1][0] = FFTWPREFIX(plan_dft_c2r_2d)(nx, ny, reinterpret_cast<FFTWPREFIX(complex) *>(up1), up1, fftw_flags);
+    fft->plan[0][1][1] = FFTWPREFIX(plan_dft_r2c_2d)(nx, ny, up1, reinterpret_cast<FFTWPREFIX(complex) *>(up1), fftw_flags);
 
-    fft->plan[1][0][0] = FFTWPREFIX(plan_dft_c2r_2d)(nx, ny, (FFTWPREFIX(complex) *) p1, p2, fftw_flags);
-    fft->plan[1][0][1] = FFTWPREFIX(plan_dft_r2c_2d)(nx, ny, p1, (FFTWPREFIX(complex) *) p2, fftw_flags);
-    fft->plan[1][1][0] = FFTWPREFIX(plan_dft_c2r_2d)(nx, ny, (FFTWPREFIX(complex) *) p1, p1, fftw_flags);
-    fft->plan[1][1][1] = FFTWPREFIX(plan_dft_r2c_2d)(nx, ny, p1, (FFTWPREFIX(complex) *) p1, fftw_flags);
+    fft->plan[1][0][0] = FFTWPREFIX(plan_dft_c2r_2d)(nx, ny, reinterpret_cast<FFTWPREFIX(complex) *>(p1), p2, fftw_flags);
+    fft->plan[1][0][1] = FFTWPREFIX(plan_dft_r2c_2d)(nx, ny, p1, reinterpret_cast<FFTWPREFIX(complex) *>(p2), fftw_flags);
+    fft->plan[1][1][0] = FFTWPREFIX(plan_dft_c2r_2d)(nx, ny, reinterpret_cast<FFTWPREFIX(complex) *>(p1), p1, fftw_flags);
+    fft->plan[1][1][1] = FFTWPREFIX(plan_dft_r2c_2d)(nx, ny, p1, reinterpret_cast<FFTWPREFIX(complex) *>(p1), fftw_flags);
 
 
     for (i = 0; i < 2; i++)
@@ -455,8 +455,8 @@ gmx_fft_1d               (gmx_fft_t                  fft,
     }
 
     FFTWPREFIX(execute_dft)(fft->plan[aligned][inplace][isforward],
-                            (FFTWPREFIX(complex) *) in_data,
-                            (FFTWPREFIX(complex) *) out_data);
+                            static_cast<FFTWPREFIX(complex) *>(in_data),
+                            static_cast<FFTWPREFIX(complex) *>(out_data));
 
     return 0;
 }
@@ -491,12 +491,12 @@ gmx_fft_1d_real          (gmx_fft_t                  fft,
     if (isforward)
     {
         FFTWPREFIX(execute_dft_r2c)(fft->plan[aligned][inplace][isforward],
-                                    (real *)in_data, (FFTWPREFIX(complex) *) out_data);
+                                    static_cast<real *>(in_data), static_cast<FFTWPREFIX(complex) *>(out_data));
     }
     else
     {
         FFTWPREFIX(execute_dft_c2r)(fft->plan[aligned][inplace][isforward],
-                                    (FFTWPREFIX(complex) *) in_data, (real *)out_data);
+                                    static_cast<FFTWPREFIX(complex) *>(in_data), static_cast<real *>(out_data));
     }
 
     return 0;
@@ -532,14 +532,14 @@ gmx_fft_2d_real          (gmx_fft_t                  fft,
     if (isforward)
     {
         FFTWPREFIX(execute_dft_r2c)(fft->plan[aligned][inplace][isforward],
-                                    (real *)in_data,
-                                    (FFTWPREFIX(complex) *) out_data);
+                                    static_cast<real *>(in_data),
+                                    static_cast<FFTWPREFIX(complex) *>(out_data));
     }
     else
     {
         FFTWPREFIX(execute_dft_c2r)(fft->plan[aligned][inplace][isforward],
-                                    (FFTWPREFIX(complex) *) in_data,
-                                    (real *)out_data);
+                                    static_cast<FFTWPREFIX(complex) *>(in_data),
+                                    static_cast<real *>(out_data));
     }
 
 
index 64f97b6b9942574d7cea98ce2ce9120255b4c6fd..f32feca9a59ba972397c4872fc80f0c9465ec953 100644 (file)
@@ -83,10 +83,10 @@ gmx_parallel_3dfft_init   (gmx_parallel_3dfft_t           *    pfft_setup,
         Nb = K; Mb = rN; Kb = M;  /* currently always true because ORDER_YZ always set */
     }
 
-    (*pfft_setup)->p1 = fft5d_plan_3d(rN, M, K, rcomm, flags, (t_complex**)real_data, complex_data, &buf1, &buf2, nthreads, realGridAllocation);
+    (*pfft_setup)->p1 = fft5d_plan_3d(rN, M, K, rcomm, flags, reinterpret_cast<t_complex**>(real_data), complex_data, &buf1, &buf2, nthreads, realGridAllocation);
 
     (*pfft_setup)->p2 = fft5d_plan_3d(Nb, Mb, Kb, rcomm,
-                                      (flags|FFT5D_BACKWARD|FFT5D_NOMALLOC)^FFT5D_ORDER_YZ, complex_data, (t_complex**)real_data, &buf1, &buf2, nthreads);
+                                      (flags|FFT5D_BACKWARD|FFT5D_NOMALLOC)^FFT5D_ORDER_YZ, complex_data, reinterpret_cast<t_complex**>(real_data), &buf1, &buf2, nthreads);
 
     return (*pfft_setup)->p1 != nullptr && (*pfft_setup)->p2 != nullptr;
 }
index 57dbd834696e705ce9f109077b70a9f4a11eb2ab..02858e076484f48dbd0bff2c1bfe2aafa4a01871 100644 (file)
@@ -695,7 +695,7 @@ static gmx_bool do_eheader(ener_file_t ef, int *file_version, t_enxframe *fr,
                 *bOK = *bOK && gmx_fio_do_int(ef->fio, typenr);
                 *bOK = *bOK && gmx_fio_do_int(ef->fio, sub->nr);
 
-                sub->type = (xdr_datatype)typenr;
+                sub->type = static_cast<xdr_datatype>(typenr);
             }
         }
     }
@@ -821,7 +821,7 @@ ener_file_t open_enx(const char *fn, const char *mode)
         /* Now check whether this file is in single precision */
         if (!bWrongPrecision &&
             ((fr->e_size && (fr->nre == nre) &&
-              (nre*4*(long int)sizeof(float) == fr->e_size)) ) )
+              (nre*4*static_cast<long int>(sizeof(float)) == fr->e_size)) ) )
         {
             fprintf(stderr, "Opened %s as single precision energy file\n", fn);
             free_enxnms(nre, nms);
@@ -838,7 +838,7 @@ ener_file_t open_enx(const char *fn, const char *mode)
             }
 
             if (((fr->e_size && (fr->nre == nre) &&
-                  (nre*4*(long int)sizeof(double) == fr->e_size)) ))
+                  (nre*4*static_cast<long int>(sizeof(double)) == fr->e_size)) ))
             {
                 fprintf(stderr, "Opened %s as double precision energy file\n",
                         fn);
@@ -918,7 +918,7 @@ static void convert_full_sums(ener_old_t *ener_old, t_enxframe *fr)
             fr->ener[i].eav  = eav_all  - ener_old->ener_prev[i].eav
                 - gmx::square(ener_old->ener_prev[i].esum/(nstep_all - fr->nsum)
                               - esum_all/nstep_all)*
-                (nstep_all - fr->nsum)*nstep_all/(double)fr->nsum;
+                (nstep_all - fr->nsum)*nstep_all/static_cast<double>(fr->nsum);
             ener_old->ener_prev[i].esum = esum_all;
             ener_old->ener_prev[i].eav  = eav_all;
         }
@@ -1431,7 +1431,7 @@ static void cmp_eblocks(t_enxframe *fr1, t_enxframe *fr2, real ftol, real abstol
                     s1 = &(b1->sub[i]);
                     s2 = &(b2->sub[i]);
 
-                    cmp_int(stdout, buf, -1, (int)s1->type, (int)s2->type);
+                    cmp_int(stdout, buf, -1, static_cast<int>(s1->type), static_cast<int>(s2->type));
                     cmp_int64(stdout, buf, s1->nr, s2->nr);
 
                     if ((s1->type == s2->type) && (s1->nr == s2->nr))
index f254eb0459663af64bab5fabf2e441bc814b97d9..6e146861b7f0e74bdf09cf86361a23e131ce5533 100644 (file)
@@ -88,7 +88,7 @@ static int get_espresso_word(FILE *fp, char word[])
             }
             else
             {
-                word[nc++] = (char)i;
+                word[nc++] = static_cast<char>(i);
             }
         }
     }
index cd8789d7ac14866f10f3d6b31449b57fae48c4e7..11a4add8ffd5171e1daf59d70054dd0bbaa0e223 100644 (file)
@@ -127,84 +127,84 @@ static gmx_bool do_xdr(t_fileio *fio, void *item, int nitem, int eio,
             {
                 if (item && !fio->bRead)
                 {
-                    d = *((real *) item);
+                    d = *(static_cast<real *>(item));
                 }
                 res = xdr_double(fio->xdr, &d);
                 if (item)
                 {
-                    *((real *) item) = d;
+                    *(static_cast<real *>(item)) = d;
                 }
             }
             else
             {
                 if (item && !fio->bRead)
                 {
-                    f = *((real *) item);
+                    f = *(static_cast<real *>(item));
                 }
                 res = xdr_float(fio->xdr, &f);
                 if (item)
                 {
-                    *((real *) item) = f;
+                    *(static_cast<real *>(item)) = f;
                 }
             }
             break;
         case eioFLOAT:
             if (item && !fio->bRead)
             {
-                f = *((float *) item);
+                f = *(static_cast<float *>(item));
             }
             res = xdr_float(fio->xdr, &f);
             if (item)
             {
-                *((float *) item) = f;
+                *(static_cast<float *>(item)) = f;
             }
             break;
         case eioDOUBLE:
             if (item && !fio->bRead)
             {
-                d = *((double *) item);
+                d = *(static_cast<double *>(item));
             }
             res = xdr_double(fio->xdr, &d);
             if (item)
             {
-                *((double *) item) = d;
+                *(static_cast<double *>(item)) = d;
             }
             break;
         case eioINT:
             if (item && !fio->bRead)
             {
-                idum = *(int *) item;
+                idum = *static_cast<int *>(item);
             }
             res = xdr_int(fio->xdr, &idum);
             if (item)
             {
-                *(int *) item = idum;
+                *static_cast<int *>(item) = idum;
             }
             break;
         case eioINT64:
             if (item && !fio->bRead)
             {
-                sdum = *(int64_t *) item;
+                sdum = *static_cast<int64_t *>(item);
             }
             res = xdr_int64(fio->xdr, &sdum);
             if (item)
             {
-                *(int64_t *) item = sdum;
+                *static_cast<int64_t *>(item) = sdum;
             }
             break;
         case eioUCHAR:
             if (item && !fio->bRead)
             {
-                ucdum = *(unsigned char *) item;
+                ucdum = *static_cast<unsigned char *>(item);
             }
             res = xdr_u_char(fio->xdr, &ucdum);
             if (item)
             {
-                *(unsigned char *) item = ucdum;
+                *static_cast<unsigned char *>(item) = ucdum;
             }
             break;
         case eioNUCHAR:
-            ucptr = (unsigned char *) item;
+            ucptr = static_cast<unsigned char *>(item);
             res   = 1;
             for (j = 0; (j < nitem) && res; j++)
             {
@@ -214,12 +214,12 @@ static gmx_bool do_xdr(t_fileio *fio, void *item, int nitem, int eio,
         case eioUSHORT:
             if (item && !fio->bRead)
             {
-                us = *(unsigned short *) item;
+                us = *static_cast<unsigned short *>(item);
             }
-            res = xdr_u_short(fio->xdr, (unsigned short *) &us);
+            res = xdr_u_short(fio->xdr, &us);
             if (item)
             {
-                *(unsigned short *) item = us;
+                *static_cast<unsigned short *>(item) = us;
             }
             break;
         case eioRVEC:
@@ -229,17 +229,17 @@ static gmx_bool do_xdr(t_fileio *fio, void *item, int nitem, int eio,
                 {
                     for (m = 0; (m < DIM); m++)
                     {
-                        dvec[m] = ((real *) item)[m];
+                        dvec[m] = (static_cast<real *>(item))[m];
                     }
                 }
-                res = xdr_vector(fio->xdr, (char *) dvec, DIM,
+                res = xdr_vector(fio->xdr, reinterpret_cast<char *>(dvec), DIM,
                                  static_cast<unsigned int>(sizeof(double)),
-                                 (xdrproc_t) xdr_double);
+                                 reinterpret_cast<xdrproc_t>(xdr_double));
                 if (item)
                 {
                     for (m = 0; (m < DIM); m++)
                     {
-                        ((real *) item)[m] = dvec[m];
+                        (static_cast<real *>(item))[m] = dvec[m];
                     }
                 }
             }
@@ -249,17 +249,17 @@ static gmx_bool do_xdr(t_fileio *fio, void *item, int nitem, int eio,
                 {
                     for (m = 0; (m < DIM); m++)
                     {
-                        fvec[m] = ((real *) item)[m];
+                        fvec[m] = (static_cast<real *>(item))[m];
                     }
                 }
-                res = xdr_vector(fio->xdr, (char *) fvec, DIM,
+                res = xdr_vector(fio->xdr, reinterpret_cast<char *>(fvec), DIM,
                                  static_cast<unsigned int>(sizeof(float)),
-                                 (xdrproc_t) xdr_float);
+                                 reinterpret_cast<xdrproc_t>(xdr_float));
                 if (item)
                 {
                     for (m = 0; (m < DIM); m++)
                     {
-                        ((real *) item)[m] = fvec[m];
+                        (static_cast<real *>(item))[m] = fvec[m];
                     }
                 }
             }
@@ -271,13 +271,13 @@ static gmx_bool do_xdr(t_fileio *fio, void *item, int nitem, int eio,
             {
                 if (item)
                 {
-                    ptr = ((rvec *) item)[j];
+                    ptr = (static_cast<rvec *>(item))[j];
                 }
                 res = do_xdr(fio, ptr, 1, eioRVEC, desc, srcfile, line);
             }
             break;
         case eioIVEC:
-            iptr = (int *) item;
+            iptr = static_cast<int *>(item);
             res  = 1;
             for (m = 0; (m < DIM) && res; m++)
             {
@@ -301,7 +301,7 @@ static gmx_bool do_xdr(t_fileio *fio, void *item, int nitem, int eio,
             {
                 if (!fio->bRead)
                 {
-                    slen = strlen((char *) item) + 1;
+                    slen = strlen(static_cast<char *>(item)) + 1;
                 }
                 else
                 {
@@ -324,7 +324,7 @@ static gmx_bool do_xdr(t_fileio *fio, void *item, int nitem, int eio,
             }
             else
             {
-                cptr = (char *)item;
+                cptr = static_cast<char *>(item);
             }
             if (cptr)
             {
index 71a01324957e0e762671b91b7a8bb867bbde0f51..993fe341ddb82c44f767006f03dd732dd0658239 100644 (file)
@@ -478,7 +478,7 @@ static int gmx_fio_int_get_file_md5(t_fileio *fio, gmx_off_t offset,
 
     snew(buf, CPT_CHK_LEN);
     /* the read puts the file position back to offset */
-    if ((gmx_off_t)fread(buf, 1, read_len, fio->fp) != read_len)
+    if (static_cast<gmx_off_t>(fread(buf, 1, read_len, fio->fp)) != read_len)
     {
         /* not fatal: md5sum check to prevent overwriting files
          * works (less safe) without
@@ -517,7 +517,7 @@ static int gmx_fio_int_get_file_md5(t_fileio *fio, gmx_off_t offset,
 
     if (debug)
     {
-        fprintf(debug, "chksum %s readlen %ld\n", fio->fn, (long int)read_len);
+        fprintf(debug, "chksum %s readlen %ld\n", fio->fn, static_cast<long int>(read_len));
     }
 
     if (!ret)
index 1aa2ed272060254cdc1f6e783711c0b5e821b0be..a5e35d94e232b05380b10ec380e66a73dbdd2daf 100644 (file)
@@ -449,7 +449,7 @@ int xdr3dfcoord(XDR *xdrs, float *fp, int *size, float *precision)
         if (*size <= 9)
         {
             return (xdr_vector(xdrs, reinterpret_cast<char *>(fp), static_cast<unsigned int>(size3),
-                               static_cast<unsigned int>(sizeof(*fp)), (xdrproc_t)xdr_float));
+                               static_cast<unsigned int>(sizeof(*fp)), reinterpret_cast<xdrproc_t>(xdr_float)));
         }
 
         if (xdr_float(xdrs, precision) == 0)
@@ -582,9 +582,9 @@ int xdr3dfcoord(XDR *xdrs, float *fp, int *size, float *precision)
             return 0;
         }
 
-        if ((float)maxint[0] - (float)minint[0] >= MAXABS ||
-            (float)maxint[1] - (float)minint[1] >= MAXABS ||
-            (float)maxint[2] - (float)minint[2] >= MAXABS)
+        if (static_cast<float>(maxint[0]) - static_cast<float>(minint[0]) >= MAXABS ||
+            static_cast<float>(maxint[1]) - static_cast<float>(minint[1]) >= MAXABS ||
+            static_cast<float>(maxint[2]) - static_cast<float>(minint[2]) >= MAXABS)
         {
             /* turning value in unsigned by subtracting minint
              * would cause overflow
@@ -796,7 +796,7 @@ int xdr3dfcoord(XDR *xdrs, float *fp, int *size, float *precision)
         {
             *precision = -1;
             return (xdr_vector(xdrs, reinterpret_cast<char *>(fp), static_cast<unsigned int>(size3),
-                               static_cast<unsigned int>(sizeof(*fp)), (xdrproc_t)xdr_float));
+                               static_cast<unsigned int>(sizeof(*fp)), reinterpret_cast<xdrproc_t>(xdr_float)));
         }
         if (xdr_float(xdrs, precision) == 0)
         {
index c125394cf95172427e1667f9e148cad4706e34fd..a9190bc3591ab5a68b8a85afe6563a5ac2c94ff9 100644 (file)
@@ -667,7 +667,7 @@ static void write_xpm_map3(FILE *out, int n_x, int n_y, int *nlevels,
     if (*nlevels > NMAP*NMAP)
     {
         fprintf(stderr, "Warning, too many levels (%d) in matrix, using %d only\n",
-                *nlevels, (int)(NMAP*NMAP));
+                *nlevels, static_cast<int>(NMAP*NMAP));
         *nlevels = NMAP*NMAP;
     }
     else if (*nlevels < 2)
@@ -817,7 +817,7 @@ static void write_xpm_map(FILE *out, int n_x, int n_y, int *nlevels,
     if (*nlevels > NMAP*NMAP)
     {
         fprintf(stderr, "Warning, too many levels (%d) in matrix, using %d only\n",
-                *nlevels, (int)(NMAP*NMAP));
+                *nlevels, static_cast<int>(NMAP*NMAP));
         *nlevels = NMAP*NMAP;
     }
     else if (*nlevels < 2)
index 9b9e6e88ab1056d0fb1a914f189887bb2e49a84b..ab63444073a2835f7ebb06177152d21fd926bf37 100644 (file)
@@ -212,7 +212,7 @@ md5_process(md5_state_t *pms, const md5_byte_t *data /*[64]*/)
             if (!((data - reinterpret_cast<const md5_byte_t *>(0)) & 3))
             {
                 /* data are properly aligned */
-                X = (const md5_word_t *)data;
+                X = reinterpret_cast<const md5_word_t *>(data);
             }
             else
             {
@@ -378,7 +378,7 @@ gmx_md5_append(md5_state_t *pms, const md5_byte_t *data, int nbytes)
     const md5_byte_t *p = data;
     int left            = nbytes;
     int offset          = (pms->count[0] >> 3) & 63;
-    md5_word_t nbits    = (md5_word_t)(nbytes << 3);
+    md5_word_t nbits    = static_cast<md5_word_t>(nbytes << 3);
 
     if (nbytes <= 0)
     {
@@ -436,7 +436,7 @@ gmx_md5_finish(md5_state_t *pms, md5_byte_t digest[16])
     /* Save the length before padding. */
     for (i = 0; i < 8; ++i)
     {
-        data[i] = (md5_byte_t)(pms->count[i >> 2] >> ((i & 3) << 3));
+        data[i] = static_cast<md5_byte_t>(pms->count[i >> 2] >> ((i & 3) << 3));
     }
     /* Pad to 56 bytes mod 64. */
     gmx_md5_append(pms, pad, ((55 - (pms->count[0] >> 3)) & 63) + 1);
@@ -444,6 +444,6 @@ gmx_md5_finish(md5_state_t *pms, md5_byte_t digest[16])
     gmx_md5_append(pms, data, 8);
     for (i = 0; i < 16; ++i)
     {
-        digest[i] = (md5_byte_t)(pms->abcd[i >> 2] >> ((i & 3) << 3));
+        digest[i] = static_cast<md5_byte_t>(pms->abcd[i >> 2] >> ((i & 3) << 3));
     }
 }
index 1b3fc05daa53652b26a2bbafe60f63c53b73177e..9b79e6385f2d15f152f65f31be15e159649de835 100644 (file)
@@ -310,7 +310,7 @@ void write_pdbfile_indexed(FILE *out, const char *title,
                            gmx_conect conect, gmx_bool bTerSepChains,
                            bool usePqrFormat)
 {
-    gmx_conect_t     *gc = (gmx_conect_t *)conect;
+    gmx_conect_t     *gc = static_cast<gmx_conect_t *>(conect);
     char              resnm[6], nm[6];
     int               i, ii;
     int               resind, resnr;
@@ -840,7 +840,7 @@ static void gmx_conect_addline(gmx_conect_t *con, char *line)
 
 void gmx_conect_dump(FILE *fp, gmx_conect conect)
 {
-    gmx_conect_t *gc = (gmx_conect_t *)conect;
+    gmx_conect_t *gc = static_cast<gmx_conect_t *>(conect);
     int           i;
 
     for (i = 0; (i < gc->nconect); i++)
@@ -889,7 +889,7 @@ gmx_bool gmx_conect_exist(gmx_conect conect, int ai, int aj)
 
 void gmx_conect_add(gmx_conect conect, int ai, int aj)
 {
-    gmx_conect_t *gc = (gmx_conect_t *)conect;
+    gmx_conect_t *gc = static_cast<gmx_conect_t *>(conect);
 
     /* if (!gc->bSorted)
        sort_conect(gc);*/
index 268b4fbd428245e3175cab28b65fc1bdf27f1593..1df209b6398b5e823939360e8cdf067c2f35773c 100644 (file)
@@ -874,7 +874,7 @@ void gmx_fwrite_tng(gmx_tng_trajectory_t gmx_tng,
     }
 
     tng_num_particles_get(tng, &nParticles);
-    if (nAtoms != (int)nParticles)
+    if (nAtoms != static_cast<int>(nParticles))
     {
         tng_implicit_num_particles_set(tng, nAtoms);
     }
@@ -1539,7 +1539,7 @@ gmx_bool gmx_read_next_tng_frame(gmx_tng_trajectory_t        gmx_tng_input,
             case TNG_TRAJ_VELOCITIES:
                 srenew(fr->v, fr->natoms);
                 convert_array_to_real_array(values,
-                                            (real *) fr->v,
+                                            reinterpret_cast<real *>(fr->v),
                                             getDistanceScaleFactor(gmx_tng_input),
                                             fr->natoms,
                                             DIM,
@@ -1635,11 +1635,11 @@ void gmx_print_tng_molecule_system(gmx_tng_trajectory_t gmx_tng_input,
         tng_molecule_name_get(input, molecule, str, 256);
         if (varNAtoms == TNG_CONSTANT_N_ATOMS)
         {
-            if ((int)molCntList[i] == 0)
+            if (static_cast<int>(molCntList[i]) == 0)
             {
                 continue;
             }
-            fprintf(stream, "Molecule: %s, count: %d\n", str, (int)molCntList[i]);
+            fprintf(stream, "Molecule: %s, count: %d\n", str, static_cast<int>(molCntList[i]));
         }
         else
         {
index b4ce57ed8a67af47273b68043f28bc78b7e2fdad..d7e37cdd4e6ed7e29713210fa7d46b765adccb35 100644 (file)
@@ -107,7 +107,7 @@ gmx_bool bRmod_fd(double a, double b, double c, gmx_bool bDouble)
 
     tol = 2*(bDouble ? GMX_DOUBLE_EPS : GMX_FLOAT_EPS);
 
-    iq = (int)((a - b + tol*a)/c);
+    iq = static_cast<int>((a - b + tol*a)/c);
 
     return fabs(a - b - c*iq) <= tol*fabs(a);
 }
@@ -226,7 +226,7 @@ int prec2ndec(real prec)
         gmx_fatal(FARGS, "DEATH HORROR prec (%g) <= 0 in prec2ndec", prec);
     }
 
-    return (int)(log(prec)/log(10.0)+0.5);
+    return static_cast<int>(log(prec)/log(10.0)+0.5);
 }
 
 real ndec2prec(int ndec)
index cc42a28af7b762057a8f340060c2a2347c62a963..4b587df7ef453416b3f21eec4416e50bd58bb8e5 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2009,2010,2012,2013,2014,2015,2016,2017, by the GROMACS development team, led by
+ * Copyright (c) 2009,2010,2012,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.
@@ -129,7 +129,7 @@ static int register_cb(void *v, vmdplugin_t *p)
 
     if (strcmp(key, vmdplugin->filetype) == 0)
     {
-        vmdplugin->api = (molfile_plugin_t *)p;
+        vmdplugin->api = reinterpret_cast<molfile_plugin_t *>(p);
     }
     return VMDPLUGIN_SUCCESS;
 }
@@ -149,7 +149,7 @@ static int load_sharedlibrary_plugins(const char *fullpath, gmx_vmdplugin_t *vmd
     }
 
     ifunc = vmddlsym(handle, "vmdplugin_init");
-    if (!ifunc || ((initfunc)(ifunc))())
+    if (!ifunc || (reinterpret_cast<initfunc>(ifunc))())
     {
         printf("\nvmdplugin_init() for %s returned an error; plugin(s) not loaded.\n", fullpath);
         vmddlclose(handle);
@@ -166,7 +166,7 @@ static int load_sharedlibrary_plugins(const char *fullpath, gmx_vmdplugin_t *vmd
     else
     {
         /* Load plugins from the library.*/
-        ((regfunc)registerfunc)(vmdplugin, register_cb);
+        (reinterpret_cast<regfunc>(registerfunc))(vmdplugin, register_cb);
     }
 
     /* in case this library does not support the filetype, close it */
@@ -195,10 +195,10 @@ gmx_bool read_next_vmd_frame(gmx_vmdplugin_t *vmdplugin, t_trxframe *fr)
         snew(ts.velocities, fr->natoms*3);
     }
 #else
-    ts.coords = (float*)fr->x;
+    ts.coords = reinterpret_cast<float*>(fr->x);
     if (fr->bV)
     {
-        ts.velocities = (float*)fr->v;
+        ts.velocities = reinterpret_cast<float*>(fr->v);
     }
 #endif
 
index 761036da75633d652e4344ba75fd22420b7c6166..9a7f29c05690aad98def49d4d83f82838b20d44e 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,2017, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2015,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.
@@ -228,10 +228,10 @@ void ps_line(t_psdata ps, real x1, real y1, real x2, real y2)
 static void do_box(t_psdata ps, real x1, real y1, real x2, real y2)
 {
     ps_moveto(ps, x1, y1);
-    ps_linerel(ps, 0, (real)(y2-y1));
-    ps_linerel(ps, (real)(x2-x1), 0);
-    ps_linerel(ps, 0, (real)(y1-y2));
-    ps_linerel(ps, (real)(x1-x2), 0);
+    ps_linerel(ps, 0, static_cast<real>(y2-y1));
+    ps_linerel(ps, static_cast<real>(x2-x1), 0);
+    ps_linerel(ps, 0, static_cast<real>(y1-y2));
+    ps_linerel(ps, static_cast<real>(x1-x2), 0);
 }
 
 void ps_box(t_psdata ps, real x1, real y1, real x2, real y2)
index cceda7c3027c6404f1f4e8e4d84893d8750c5f6f..d6576199314e60d26e2e3e0214453dd40fccfb2e 100644 (file)
@@ -53,7 +53,7 @@ int xdr_real(XDR *xdrs, real *r)
 
     return ret;
 #else
-    return xdr_float(xdrs, (float *)r);
+    return xdr_float(xdrs, static_cast<float *>(r));
 #endif
 }
 
index 86bd6027b706ed8fb33211e9e27eb61c99d63c11..13c3365a9d9dd9ca4ef4d0c8552e8c90f8419ed4 100644 (file)
@@ -69,7 +69,7 @@ static int xdr_r2f(XDR *xdrs, real *r, gmx_bool gmx_unused bRead)
 
     return ret;
 #else
-    return xdr_float(xdrs, (float *)r);
+    return xdr_float(xdrs, static_cast<float *>(r));
 #endif
 }
 
index 149ff854a553193cd0be6b2e4303a60255c6f4d0..01e8b13c9994da99361768e0069159227bb3fa1b 100644 (file)
@@ -888,7 +888,7 @@ real **read_xvg_time(const char *fn,
                                 val_nalloc[set] = over_alloc_small(n);
                                 srenew(val[set], val_nalloc[set]);
                             }
-                            val[set][n] = (real)dbl;
+                            val[set][n] = static_cast<real>(dbl);
                         }
                     }
                     a++;
@@ -934,7 +934,7 @@ real **read_xvg_time(const char *fn,
             }
             if (n > 1)
             {
-                *dt = (real)((*t)[n-1]-(*t)[0])/(n-1.0);
+                *dt = static_cast<real>((*t)[n-1]-(*t)[0])/(n-1.0);
             }
             else
             {
index 65a7d0e7e18dd133818167f14901f909fe6acd3b..f108e95935bf4844f307a1ec5357cdb6524d223d 100644 (file)
@@ -137,12 +137,12 @@ static gmx_bool bFreeSort = FALSE;
 
 static int pdbf_comp(const void *a, const void *b)
 {
-    t_pdbfile *pa, *pb;
-    real       x;
-    int        dc;
+    const t_pdbfile *pa, *pb;
+    real             x;
+    int              dc;
 
-    pa = *(t_pdbfile **)a;
-    pb = *(t_pdbfile **)b;
+    pa = *static_cast<t_pdbfile *const*>(a);
+    pb = *static_cast<t_pdbfile *const*>(b);
 
     dc = pa->cluster_id - pb->cluster_id;
 
index 9b0f14d39752b293f442c4d6d3c3e158ee58e70f..3751698121dca083431a08aaf21a36671dee5ab0 100644 (file)
@@ -430,7 +430,7 @@ AwhReader::AwhReader(const AwhParams  *awhParams,
     {
         AwhBiasParams              *awhBiasParams = &awhParams->awhBiasParams[k];
 
-        int                         numSubBlocks  = (int)block->sub[subblockStart].fval[0];
+        int                         numSubBlocks  = static_cast<int>(block->sub[subblockStart].fval[0]);
 
         std::unique_ptr<OutputFile> awhOutputFile(new OutputFile(opt2fn("-o", numFileOptions, filenames), "AWH", awhParams->numBias, k));
 
index dec2c4bf9811912ced3665636693db62c6a398d6..f7e1db88ea871e7aeee090429c3abfa11b80caf9 100644 (file)
@@ -2968,7 +2968,7 @@ static void read_edr_rawdh_block(samples_t **smp, int *ndu, t_enxblock *blk,
     /* make room for the data */
     if (gmx::index(s->ndu_alloc) < s->ndu + blk->sub[2].nr)
     {
-        s->ndu_alloc += (s->ndu_alloc < (size_t)blk->sub[2].nr) ?
+        s->ndu_alloc += (s->ndu_alloc < static_cast<size_t>(blk->sub[2].nr)) ?
             blk->sub[2].nr*2 : s->ndu_alloc;
         srenew(s->du_alloc, s->ndu_alloc);
         s->du = s->du_alloc;
index f95a299f9df782f05085166c6301a4e3be244b96..20df5cf59224e6510c8baad03505a88213f7fda8 100644 (file)
@@ -795,8 +795,8 @@ static rvec **read_whole_trj(const char *fn, int isize, const int index[], int s
         i++;
     }
     while (read_next_x(oenv, status, &t, x, box));
-    fprintf(stderr, "Allocated %lu bytes for frames\n",
-            (unsigned long) (max_nf*isize*sizeof(**xx)));
+    fprintf(stderr, "Allocated %zu bytes for frames\n",
+            (max_nf*isize*sizeof(**xx)));
     fprintf(stderr, "Read %d frames from trajectory %s\n", i0, fn);
     *nframe = i0;
     sfree(x);
index 918ebd6c4e7cfee8bbef47f4ec7a6a50e0a6bd40..e750d1d694575de7df829fe4863d3fc4b805fd2b 100644 (file)
@@ -74,7 +74,7 @@ typedef struct {
 static int compare(void *a, void *b)
 {
     t_electron *tmp1, *tmp2;
-    tmp1 = (t_electron *)a; tmp2 = (t_electron *)b;
+    tmp1 = static_cast<t_electron *>(a); tmp2 = static_cast<t_electron *>(b);
 
     return std::strcmp(tmp1->atomname, tmp2->atomname);
 }
@@ -124,7 +124,7 @@ static int get_electrons(t_electron **eltab, const char *fn)
     /* sort the list */
     fprintf(stderr, "Sorting list..\n");
     qsort ((void*)*eltab, nr, sizeof(t_electron),
-           (int(*)(const void*, const void*))compare);
+           reinterpret_cast<int(*)(const void*, const void*)>(compare));
 
     return nr;
 }
@@ -276,10 +276,9 @@ static void calc_electron_density(const char *fn, int **index, const int gnx[],
                 sought.atomname = gmx_strdup(*(top->atoms.atomname[index[n][i]]));
 
                 /* now find the number of electrons. This is not efficient. */
-                found = (t_electron *)
-                    bsearch((const void *)&sought,
-                            (const void *)eltab, nr, sizeof(t_electron),
-                            (int(*)(const void*, const void*))compare);
+                found = static_cast<t_electron *>(bsearch((const void *)&sought,
+                                                          (const void *)eltab, nr, sizeof(t_electron),
+                                                          reinterpret_cast<int(*)(const void*, const void*)>(compare)));
 
                 if (found == nullptr)
                 {
index 94aea2f132b8462b7878f08e35f3b4d21533ac75..b6ac920a9047d17e143a714d38eb91bd211506cb 100644 (file)
@@ -945,11 +945,11 @@ static void do_dip(const t_topology *top, int ePBC, real volume,
         snew(dipsp, gnx_tot);
 
         /* we need a dummy file for gnuplot */
-        dip3d = (FILE *)gmx_ffopen("dummy.dat", "w");
+        dip3d = gmx_ffopen("dummy.dat", "w");
         fprintf(dip3d, "%f %f %f", 0.0, 0.0, 0.0);
         gmx_ffclose(dip3d);
 
-        dip3d = (FILE *)gmx_ffopen(fndip3d, "w");
+        dip3d = gmx_ffopen(fndip3d, "w");
         try
         {
             gmx::BinaryInformationSettings settings;
index 1d62dd050245cd1d1cdbbbc2eb7077b51f78064e..a1e9c2a63cca2d42fb0959a13e3283a4d6c762e5 100644 (file)
@@ -355,7 +355,7 @@ static void analyse_ss(const char *outfile, t_matrix *mat, const char *ss_string
     snew(total, mat->nmap);
     snew(leg, mat->nmap+1);
     leg[0] = "Structure";
-    for (s = 0; s < (size_t)mat->nmap; s++)
+    for (s = 0; s < static_cast<size_t>(mat->nmap); s++)
     {
         leg[s+1] = gmx_strdup(map[s].desc);
     }
@@ -384,7 +384,7 @@ static void analyse_ss(const char *outfile, t_matrix *mat, const char *ss_string
     xvgr_legend(fp, mat->nmap+1, leg, oenv);
 
     total_count = 0;
-    for (s = 0; s < (size_t)mat->nmap; s++)
+    for (s = 0; s < static_cast<size_t>(mat->nmap); s++)
     {
         total[s] = 0;
     }
index 6818ac285589168ab1f1c93aaeb13c95d9507512..9f23157d2fed8ee14aefddc64f52d0cd7c453ef1 100644 (file)
@@ -117,7 +117,7 @@ static t_corr *init_corr(int nrgrp, int type, int axis, real dim_factor,
     int      i;
 
     snew(curr, 1);
-    curr->type       = (msd_type)type;
+    curr->type       = static_cast<msd_type>(type);
     curr->axis       = axis;
     curr->ngrp       = nrgrp;
     curr->nrestart   = 0;
index fe804b62e6c61357c4a8346bd23a5d5b8c223c7e..1c0ee1af42f52a08259f3517af688a32c619c020 100644 (file)
@@ -637,7 +637,7 @@ static void calc_order(const char *fn, const int *index, int *a, rvec **order,
                     z1    = x1[a[index[i-1]+j]][axis];
                     z2    = x1[a[index[i+1]+j]][axis];
                     z_ave = 0.5 * (z1 + z2);
-                    slice = (int)((nslices*z_ave)/box[axis][axis]);
+                    slice = static_cast<int>((nslices*z_ave)/box[axis][axis]);
                     while (slice < 0)
                     {
                         slice += nslices;
index 43deb7c96ecbfa0cbf05e1806afb7444fc9f5df3..f2e2125e5949d65975f6ded83741a2c135c5cbd7 100644 (file)
@@ -523,7 +523,7 @@ static void do_trunc(const char *fn, real t0)
         {
             fprintf(stderr, "Do you REALLY want to truncate this trajectory (%s) at:\n"
                     "frame %d, time %g, bytes %ld ??? (type YES if so)\n",
-                    fn, j, t, (long int)fpos);
+                    fn, j, t, static_cast<long int>(fpos));
             if (1 != scanf("%s", yesno))
             {
                 gmx_fatal(FARGS, "Error reading user input");
@@ -1137,7 +1137,7 @@ int gmx_trjconv(int argc, char *argv[])
         if (opt2bSet("-fr", NFILE, fnm))
         {
             printf("Select groups of frame number indices:\n");
-            rd_index(opt2fn("-fr", NFILE, fnm), 1, &nrfri, (int **)&frindex, &frname);
+            rd_index(opt2fn("-fr", NFILE, fnm), 1, &nrfri, &frindex, &frname);
             if (debug)
             {
                 for (i = 0; i < nrfri; i++)
index ac3a4a42ce089a098611aaed732b80a1fd92039c..15e63965b3c56c02bddc6e536208c88bc987d976 100644 (file)
@@ -1139,7 +1139,7 @@ static void cleanup(const t_filenm *fnm, int nfile, int k, int nnodes,
 
     for (i = 0; i < nfile; i++)
     {
-        opt = (char *)fnm[i].opt;
+        opt = const_cast<char *>(fnm[i].opt);
         if (std::strcmp(opt, "-p") == 0)
         {
             /* do nothing; keep this file */
@@ -1923,7 +1923,7 @@ static void create_command_line_snippets(
     /********************/
     for (i = 0; i < nfile; i++)
     {
-        opt  = (char *)fnm[i].opt;
+        opt  = const_cast<char *>(fnm[i].opt);
         name = opt2fn(opt, nfile, fnm);
 
         /* Strbuf contains the options, now let's sort out where we need that */
@@ -2034,7 +2034,7 @@ static void couple_files_options(int nfile, t_filenm fnm[])
 
     for (i = 0; i < nfile; i++)
     {
-        opt    = (char *)fnm[i].opt;
+        opt    = const_cast<char *>(fnm[i].opt);
         bSet   = ((fnm[i].flag & ffSET) != 0);
         bBench = (0 == std::strncmp(opt, "-b", 2));
 
index f9b9f07120309a25dbb7755112823f5307d161fb..c4e33254e5e73e0afa6e707ac2aefa9bbe9daf1c 100644 (file)
@@ -362,7 +362,7 @@ int gmx_velacc(int argc, char *argv[])
 
         if (opt2bSet("-os", NFILE, fnm))
         {
-            calc_spectrum(counter/2, (real *) (c1[0]), (t1-t0)/2, opt2fn("-os", NFILE, fnm),
+            calc_spectrum(counter/2, (c1[0]), (t1-t0)/2, opt2fn("-os", NFILE, fnm),
                           oenv, bRecip);
             do_view(oenv, opt2fn("-os", NFILE, fnm), "-nxy");
         }
index 14d903e616a24bde52c8d0c5a184e8fcf5ef7ba1..4432f906065b5303735197c2f12fa214ba68d91b 100644 (file)
@@ -104,7 +104,7 @@ extern int * create_indexed_atom_type (reduced_atom_t * atm, int size)
  */
     int          *index_atp, i, i_tmp, j;
 
-    reduced_atom *att = (reduced_atom *)atm;
+    reduced_atom *att = static_cast<reduced_atom *>(atm);
 
     snew (index_atp, 1);
     i_tmp        = 1;
@@ -163,8 +163,8 @@ extern void compute_structure_factor (structure_factor_t * sft, matrix box,
                                       reduced_atom_t * red, int isize, real start_q,
                                       real end_q, int group, real **sf_table)
 {
-    structure_factor *sf   = (structure_factor *)sft;
-    reduced_atom     *redt = (reduced_atom *)red;
+    structure_factor *sf   = static_cast<structure_factor *>(sft);
+    reduced_atom     *redt = static_cast<reduced_atom *>(red);
 
     t_complex      ***tmpSF;
     rvec              k_factor;
@@ -330,7 +330,7 @@ extern gmx_structurefactors_t *gmx_structurefactors_init(const char *datfn)
 
     fclose(fp);
 
-    return (gmx_structurefactors_t *) gsf;
+    return static_cast<gmx_structurefactors_t *>(gsf);
 
 }
 
@@ -341,7 +341,7 @@ extern void rearrange_atoms (reduced_atom_t * positions, t_trxframe *fr, const i
 {
     int           i;
 
-    reduced_atom *pos = (reduced_atom *)positions;
+    reduced_atom *pos = static_cast<reduced_atom *>(positions);
 
     if (flag)
     {
@@ -375,7 +375,7 @@ extern int return_atom_type (const char *name, gmx_structurefactors_t *gsf)
     int                   fndx = 0;
     int                   NCMT;
 
-    gmx_structurefactors *gsft = (gmx_structurefactors *)gsf;
+    gmx_structurefactors *gsft = static_cast<gmx_structurefactors *>(gsf);
 
     NCMT = gsft->nratoms;
 
@@ -408,7 +408,7 @@ extern int return_atom_type (const char *name, gmx_structurefactors_t *gsf)
         nrc = 0;
         for (i = 0; i < cnt; i++)
         {
-            if (std::strlen(gsft->atomnm[tndx[i]]) > (size_t)nrc)
+            if (std::strlen(gsft->atomnm[tndx[i]]) > static_cast<size_t>(nrc))
             {
                 nrc  = std::strlen(gsft->atomnm[tndx[i]]);
                 fndx = tndx[i];
@@ -424,7 +424,7 @@ extern int gmx_structurefactors_get_sf(gmx_structurefactors_t *gsf, int elem, re
 
     int                   success;
     int                   i;
-    gmx_structurefactors *gsft = (gmx_structurefactors *)gsf;
+    gmx_structurefactors *gsft = static_cast<gmx_structurefactors *>(gsf);
     success = 0;
 
     for (i = 0; i < 4; i++)
@@ -519,7 +519,7 @@ extern int do_scattering_intensity (const char* fnTPS, const char* fnNDX,
         index_atp[i] = create_indexed_atom_type (red[i], isize[i]);
     }
 
-    sf_table = compute_scattering_factor_table (gmx_sf, (structure_factor_t *)sf);
+    sf_table = compute_scattering_factor_table (gmx_sf, static_cast<structure_factor_t *>(sf));
 
 
     /* This is the main loop over frames */
@@ -531,14 +531,14 @@ extern int do_scattering_intensity (const char* fnTPS, const char* fnNDX,
         {
             rearrange_atoms (red[i], &fr, index[i], isize[i], &top, FALSE, gmx_sf);
 
-            compute_structure_factor ((structure_factor_t *)sf, box, red[i], isize[i],
+            compute_structure_factor (static_cast<structure_factor_t *>(sf), box, red[i], isize[i],
                                       start_q, end_q, i, sf_table);
         }
     }
 
     while (read_next_frame (oenv, status, &fr));
 
-    save_data ((structure_factor_t *)sf, fnXVG, ng, start_q, end_q, oenv);
+    save_data (static_cast<structure_factor_t *>(sf), fnXVG, ng, start_q, end_q, oenv);
 
 
     sfree(a);
@@ -558,7 +558,7 @@ extern void save_data (structure_factor_t *sft, const char *file, int ngrps,
     int               i, g = 0;
     double           *tmp, polarization_factor, A;
 
-    structure_factor *sf = (structure_factor *)sft;
+    structure_factor *sf = static_cast<structure_factor *>(sft);
 
     fp = xvgropen (file, "Scattering Intensity", "q (1/nm)",
                    "Intensity (a.u.)", oenv);
@@ -655,7 +655,7 @@ extern real **gmx_structurefactors_table(gmx_structurefactors_t *gsf, real momen
     int                   i, j;
     double                q, sin_theta;
     real                **sf_table;
-    gmx_structurefactors *gsft = (gmx_structurefactors *)gsf;
+    gmx_structurefactors *gsft = static_cast<gmx_structurefactors *>(gsf);
 
     NCMT     = gsft->nratoms;
     nsftable = NCMT+3;
@@ -688,7 +688,7 @@ extern void gmx_structurefactors_done(gmx_structurefactors_t *gsf)
 
     int                   i;
     gmx_structurefactors *sf;
-    sf = (gmx_structurefactors *) gsf;
+    sf = static_cast<gmx_structurefactors *>(gsf);
 
     for (i = 0; i < sf->nratoms; i++)
     {
@@ -717,7 +717,7 @@ extern real **compute_scattering_factor_table (gmx_structurefactors_t *gsf, stru
     double            hc = 1239.842;
     real           ** sf_table;
 
-    structure_factor *sf = (structure_factor *)sft;
+    structure_factor *sf = static_cast<structure_factor *>(sft);
 
 
     /* \hbar \omega \lambda = hc = 1239.842 eV * nm */
index 002ef95e1c167875d820d091b48d913522fda628..dd1b6b3f4cffa8bfeba750ce81c83f85daa563d5 100644 (file)
@@ -244,14 +244,14 @@ gmx_nonbonded_set_kernel_pointers(FILE *log, t_nblist *nl, gmx_bool bElecAndVdwS
 
     if (nl->type == GMX_NBLIST_INTERACTION_FREE_ENERGY)
     {
-        nl->kernelptr_vf       = (void *) gmx_nb_free_energy_kernel;
-        nl->kernelptr_f        = (void *) gmx_nb_free_energy_kernel;
+        nl->kernelptr_vf       = reinterpret_cast<void *>(gmx_nb_free_energy_kernel);
+        nl->kernelptr_f        = reinterpret_cast<void *>(gmx_nb_free_energy_kernel);
         nl->simd_padding_width = 1;
     }
     else if (!gmx_strcasecmp_min(geom, "CG-CG"))
     {
-        nl->kernelptr_vf       = (void *) gmx_nb_generic_cg_kernel;
-        nl->kernelptr_f        = (void *) gmx_nb_generic_cg_kernel;
+        nl->kernelptr_vf       = reinterpret_cast<void *>(gmx_nb_generic_cg_kernel);
+        nl->kernelptr_f        = reinterpret_cast<void *>(gmx_nb_generic_cg_kernel);
         nl->simd_padding_width = 1;
     }
     else
@@ -260,18 +260,18 @@ gmx_nonbonded_set_kernel_pointers(FILE *log, t_nblist *nl, gmx_bool bElecAndVdwS
 
         for (i = 0; i < narch && nl->kernelptr_vf == nullptr; i++)
         {
-            nl->kernelptr_vf       = (void *) nb_kernel_list_findkernel(log, arch_and_padding[i].arch, elec, elec_mod, vdw, vdw_mod, geom, other, "PotentialAndForce");
+            nl->kernelptr_vf       = reinterpret_cast<void *>(nb_kernel_list_findkernel(log, arch_and_padding[i].arch, elec, elec_mod, vdw, vdw_mod, geom, other, "PotentialAndForce"));
             nl->simd_padding_width = arch_and_padding[i].simd_padding_width;
         }
         for (i = 0; i < narch && nl->kernelptr_f == nullptr; i++)
         {
-            nl->kernelptr_f        = (void *) nb_kernel_list_findkernel(log, arch_and_padding[i].arch, elec, elec_mod, vdw, vdw_mod, geom, other, "Force");
+            nl->kernelptr_f        = reinterpret_cast<void *>(nb_kernel_list_findkernel(log, arch_and_padding[i].arch, elec, elec_mod, vdw, vdw_mod, geom, other, "Force"));
             nl->simd_padding_width = arch_and_padding[i].simd_padding_width;
 
             /* If there is not force-only optimized kernel, is there a potential & force one? */
             if (nl->kernelptr_f == nullptr)
             {
-                nl->kernelptr_f        = (void *) nb_kernel_list_findkernel(nullptr, arch_and_padding[i].arch, elec, elec_mod, vdw, vdw_mod, geom, other, "PotentialAndForce");
+                nl->kernelptr_f        = reinterpret_cast<void *>(nb_kernel_list_findkernel(nullptr, arch_and_padding[i].arch, elec, elec_mod, vdw, vdw_mod, geom, other, "PotentialAndForce"));
                 nl->simd_padding_width = arch_and_padding[i].simd_padding_width;
             }
         }
@@ -301,8 +301,8 @@ gmx_nonbonded_set_kernel_pointers(FILE *log, t_nblist *nl, gmx_bool bElecAndVdwS
          */
         if (nl->kernelptr_vf == nullptr && !gmx_strcasecmp_min(geom, "Particle-Particle"))
         {
-            nl->kernelptr_vf       = (void *) gmx_nb_generic_kernel;
-            nl->kernelptr_f        = (void *) gmx_nb_generic_kernel;
+            nl->kernelptr_vf       = reinterpret_cast<void *>(gmx_nb_generic_kernel);
+            nl->kernelptr_f        = reinterpret_cast<void *>(gmx_nb_generic_kernel);
             nl->simd_padding_width = 1;
             if (debug)
             {
@@ -405,12 +405,12 @@ void do_nonbonded(const t_forcerec  *fr,
                     if (flags & GMX_NONBONDED_DO_POTENTIAL)
                     {
                         /* Potential and force */
-                        kernelptr = (nb_kernel_t *)nlist[i].kernelptr_vf;
+                        kernelptr = reinterpret_cast<nb_kernel_t *>(nlist[i].kernelptr_vf);
                     }
                     else
                     {
                         /* Force only, no potential */
-                        kernelptr = (nb_kernel_t *)nlist[i].kernelptr_f;
+                        kernelptr = reinterpret_cast<nb_kernel_t *>(nlist[i].kernelptr_f);
                     }
 
                     if (nlist[i].type != GMX_NBLIST_INTERACTION_FREE_ENERGY && (flags & GMX_NONBONDED_DO_FOREIGNLAMBDA))
index c6e2f3ccbc421704c93ca0ee16fca625fb3e693e..ff4a568384394835fd88fc7ebd54a3c1f6bf4c6d 100644 (file)
@@ -63,11 +63,11 @@ static int round_check(real r, int limit, int ftype, const char *name)
 
     if (r >= 0)
     {
-        i = (int)(r + 0.5);
+        i = static_cast<int>(r + 0.5);
     }
     else
     {
-        i = (int)(r - 0.5);
+        i = static_cast<int>(r - 0.5);
     }
 
     if (r-i > 0.01 || r-i < -0.01)
@@ -473,7 +473,7 @@ static int enter_params(gmx_ffparams_t *ffparams, t_functype ftype,
         {
             if (ffparams->functype[type] == ftype)
             {
-                if (memcmp(&newparam, &ffparams->iparams[type], (size_t)sizeof(newparam)) == 0)
+                if (memcmp(&newparam, &ffparams->iparams[type], static_cast<size_t>(sizeof(newparam))) == 0)
                 {
                     return type;
                 }
@@ -484,7 +484,7 @@ static int enter_params(gmx_ffparams_t *ffparams, t_functype ftype,
     {
         type = ffparams->ntypes;
     }
-    memcpy(&ffparams->iparams[type], &newparam, (size_t)sizeof(newparam));
+    memcpy(&ffparams->iparams[type], &newparam, static_cast<size_t>(sizeof(newparam)));
 
     ffparams->ntypes++;
     ffparams->functype[type] = ftype;
@@ -558,9 +558,9 @@ void convert_params(int atnr, t_params nbtypes[],
     ffp->iparams  = nullptr;
     ffp->reppow   = reppow;
 
-    enter_function(&(nbtypes[F_LJ]),  (t_functype)F_LJ,    comb, reppow, ffp, nullptr,
+    enter_function(&(nbtypes[F_LJ]),  static_cast<t_functype>(F_LJ),    comb, reppow, ffp, nullptr,
                    &maxtypes, TRUE, TRUE);
-    enter_function(&(nbtypes[F_BHAM]), (t_functype)F_BHAM,  comb, reppow, ffp, nullptr,
+    enter_function(&(nbtypes[F_BHAM]), static_cast<t_functype>(F_BHAM),  comb, reppow, ffp, nullptr,
                    &maxtypes, TRUE, TRUE);
 
     for (size_t mt = 0; mt < mtop->moltype.size(); mt++)
@@ -578,7 +578,7 @@ void convert_params(int atnr, t_params nbtypes[],
                                                  (flags & IF_VSITE) ||
                                                  (flags & IF_CONSTRAINT)))
             {
-                enter_function(&(plist[i]), (t_functype)i, comb, reppow,
+                enter_function(&(plist[i]), static_cast<t_functype>(i), comb, reppow,
                                ffp, &molt->ilist[i],
                                &maxtypes, FALSE, (i == F_POSRES  || i == F_FBPOSRES));
             }
@@ -620,7 +620,7 @@ void convert_params(int atnr, t_params nbtypes[],
                 }
                 else
                 {
-                    enter_function(&(plist[i]), (t_functype)i, comb, reppow,
+                    enter_function(&(plist[i]), static_cast<t_functype>(i), comb, reppow,
                                    ffp, &mtop->intermolecular_ilist[i],
                                    &maxtypes, FALSE, FALSE);
 
index 555bf9b09ac2dd6d6878868acc495393074f237b..f8897302e206a1a74f719890d4eb8a3b47d8b0a7 100644 (file)
@@ -82,7 +82,7 @@ void fflib_filename_base(const char *filename, char *filebase, int maxlen)
     {
         cptr = filename;
     }
-    if (strlen(filename) >= (size_t)maxlen)
+    if (strlen(filename) >= static_cast<size_t>(maxlen))
     {
         gmx_fatal(FARGS, "filename is longer (%zu) than maxlen (%d)",
                   strlen(filename), maxlen);
index 581f17d1177975048967532f0744bafc3be2b1ec..dcdeba36071a6f80419db9d01f623c049da4f20c 100644 (file)
@@ -310,7 +310,7 @@ static int idcomp(const void *a, const void *b)
     }
     else
     {
-        return (int) (pa->a[2]-pb->a[2]);
+        return (pa->a[2]-pb->a[2]);
     }
 }
 
@@ -330,7 +330,7 @@ static void sort_id(int nr, t_param ps[])
     /* Now sort it */
     if (nr > 1)
     {
-        qsort(ps, nr, (size_t)sizeof(ps[0]), idcomp);
+        qsort(ps, nr, static_cast<size_t>(sizeof(ps[0])), idcomp);
     }
 }
 
@@ -347,7 +347,7 @@ static int n_hydro(const int a[], char ***atomname)
         {
             nh++;
         }
-        else if (((int)strlen(aname) > 1) && (c0 >= '0') && (c0 <= '9'))
+        else if ((static_cast<int>(strlen(aname)) > 1) && (c0 >= '0') && (c0 <= '9'))
         {
             c1 = toupper(aname[1]);
             if (c1 == 'H')
@@ -625,7 +625,7 @@ static void gen_excls(t_atoms *atoms, t_excls *excls, t_hackblock hb[],
     {
         if (excls[a].nr > 1)
         {
-            qsort(excls[a].e, excls[a].nr, (size_t)sizeof(int), int_comp);
+            qsort(excls[a].e, excls[a].nr, static_cast<size_t>(sizeof(int)), int_comp);
         }
     }
 }
@@ -1098,19 +1098,19 @@ void gen_pad(t_nextnb *nnb, t_atoms *atoms, t_restp rtp[],
     /* Sort angles with respect to j-i-k (middle atom first) */
     if (nang > 1)
     {
-        qsort(ang, nang, (size_t)sizeof(ang[0]), acomp);
+        qsort(ang, nang, static_cast<size_t>(sizeof(ang[0])), acomp);
     }
 
     /* Sort dihedrals with respect to j-k-i-l (middle atoms first) */
     if (ndih > 1)
     {
-        qsort(dih, ndih, (size_t)sizeof(dih[0]), dcomp);
+        qsort(dih, ndih, static_cast<size_t>(sizeof(dih[0])), dcomp);
     }
 
     /* Sort the pairs */
     if (npai > 1)
     {
-        qsort(pai, npai, (size_t)sizeof(pai[0]), pcomp);
+        qsort(pai, npai, static_cast<size_t>(sizeof(pai[0])), pcomp);
     }
     if (npai > 0)
     {
index c38392663aa33643cdd07d92ae736065b2911a89..70849f1e643eca7d062675211595ceee7d948493 100644 (file)
@@ -169,9 +169,9 @@ int gmx_genconf(int argc, char *argv[])
     gmx::DefaultRandomEngine rng(seed);
 
     bTRX = ftp2bSet(efTRX, NFILE, fnm);
-    nx   = (int)(nrbox[XX]+0.5);
-    ny   = (int)(nrbox[YY]+0.5);
-    nz   = (int)(nrbox[ZZ]+0.5);
+    nx   = static_cast<int>(nrbox[XX]+0.5);
+    ny   = static_cast<int>(nrbox[YY]+0.5);
+    nz   = static_cast<int>(nrbox[ZZ]+0.5);
 
     if ((nx <= 0) || (ny <= 0) || (nz <= 0))
     {
index 15eb3b997d85f23d607cda390259cca668e4d169..a771394479c18060e2e2a5a528925c21437a9526 100644 (file)
@@ -361,7 +361,7 @@ int cpp_open_file(const char *filenm, gmx_cpp_t *handle, char **cppopts)
 static int
 process_directive(gmx_cpp_t *handlep, const char *dname, const char *dval)
 {
-    gmx_cpp_t    handle = (gmx_cpp_t)*handlep;
+    gmx_cpp_t    handle = *handlep;
     int          i, i0, len, status;
     unsigned int i1;
     char        *inc_fn, *name;
@@ -567,7 +567,7 @@ process_directive(gmx_cpp_t *handlep, const char *dname, const char *dval)
    recursively and no cpp directives are printed. */
 int cpp_read_line(gmx_cpp_t *handlep, int n, char buf[])
 {
-    gmx_cpp_t   handle = (gmx_cpp_t)*handlep;
+    gmx_cpp_t   handle = *handlep;
     int         i, nn, len, status;
     const char *ptr, *ptr2;
     char       *name;
@@ -669,7 +669,7 @@ int cpp_read_line(gmx_cpp_t *handlep, int n, char buf[])
                 ptr = buf;
                 while ((ptr2 = strstrw(ptr, defs[i].name)) != nullptr)
                 {
-                    strncat(name, ptr, (int)(ptr2-ptr));
+                    strncat(name, ptr, static_cast<int>(ptr2-ptr));
                     strcat(name, defs[i].def);
                     ptr = ptr2 + strlen(defs[i].name);
                 }
@@ -696,7 +696,7 @@ int cpp_cur_linenr(const gmx_cpp_t *handlep)
 /* Close the file! Return integer status. */
 int cpp_close_file(gmx_cpp_t *handlep)
 {
-    gmx_cpp_t handle = (gmx_cpp_t)*handlep;
+    gmx_cpp_t handle = *handlep;
 
     if (!handle)
     {
@@ -773,11 +773,11 @@ char *cpp_error(gmx_cpp_t *handlep, int status)
         "Invalid file handle",
         "File not open", "Unknown error", "Error status out of range"
     };
-    gmx_cpp_t   handle = (gmx_cpp_t)*handlep;
+    gmx_cpp_t   handle = *handlep;
 
     if (!handle)
     {
-        return (char *)ecpp[eCPP_INVALID_HANDLE];
+        return const_cast<char *>(ecpp[eCPP_INVALID_HANDLE]);
     }
 
     if ((status < 0) || (status >= eCPP_NR))
index 2d79963270a12666b2676a957d49e8e3a3b72ac3..ce31d32f8b6bb512f01fa3b11d9433f17ee1394c 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) 2011,2014,2015,2017, by the GROMACS development team, led by
+ * Copyright (c) 2011,2014,2015,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,7 +52,7 @@ typedef struct {
 
 int get_bond_atomtype_type(char *str, t_bond_atomtype at)
 {
-    gpp_bond_atomtype *ga = (gpp_bond_atomtype *) at;
+    gpp_bond_atomtype *ga = reinterpret_cast<gpp_bond_atomtype *>(at);
 
     int                i;
 
@@ -70,7 +70,7 @@ int get_bond_atomtype_type(char *str, t_bond_atomtype at)
 
 char *get_bond_atomtype_name(int nt, t_bond_atomtype at)
 {
-    gpp_bond_atomtype *ga = (gpp_bond_atomtype *) at;
+    gpp_bond_atomtype *ga = reinterpret_cast<gpp_bond_atomtype *>(at);
 
     if ((nt < 0) || (nt >= ga->nr))
     {
@@ -86,13 +86,13 @@ t_bond_atomtype init_bond_atomtype(void)
 
     snew(ga, 1);
 
-    return (t_bond_atomtype ) ga;
+    return reinterpret_cast<t_bond_atomtype>(ga);
 }
 
 void add_bond_atomtype(t_bond_atomtype at, t_symtab *tab,
                        char *name)
 {
-    gpp_bond_atomtype *ga = (gpp_bond_atomtype *) at;
+    gpp_bond_atomtype *ga = reinterpret_cast<gpp_bond_atomtype *>(at);
 
     ga->nr++;
     srenew(ga->atomname, ga->nr);
@@ -101,7 +101,7 @@ void add_bond_atomtype(t_bond_atomtype at, t_symtab *tab,
 
 void done_bond_atomtype(t_bond_atomtype *at)
 {
-    gpp_bond_atomtype *ga = (gpp_bond_atomtype *) *at;
+    gpp_bond_atomtype *ga = reinterpret_cast<gpp_bond_atomtype *>(*at);
 
     sfree(ga->atomname);
     ga->nr = 0;
index d567cdea346a365f699f73f6fa57e972cd4fdda4..47826b54f03489b3d63c34172d43bc041185547a 100644 (file)
@@ -210,7 +210,7 @@ static void nnb2excl(t_nextnb *nnb, t_blocka *excl)
         prints("nnb2excl before qsort", nr_of_sortables, s);
         if (nr_of_sortables > 1)
         {
-            qsort ((void *)s, nr_of_sortables, (size_t)sizeof(s[0]), bond_sort);
+            qsort ((void *)s, nr_of_sortables, static_cast<size_t>(sizeof(s[0])), bond_sort);
             prints("nnb2excl after qsort", nr_of_sortables, s);
         }
 
@@ -391,7 +391,7 @@ void gen_nnb(t_nextnb *nnb, t_params plist[])
     prints("gen_excl before qsort", nrbonds, s);
     if (nrbonds > 1)
     {
-        qsort((void *) s, nrbonds, (size_t)sizeof(sortable), bond_sort);
+        qsort((void *) s, nrbonds, static_cast<size_t>(sizeof(sortable)), bond_sort);
         prints("gen_excl after qsort", nrbonds, s);
     }
 
index 31ab064463da616713fd6d1bc69633aaf307174b..c3fe8e350d5521f7e5acf53a4684de07d841215c 100644 (file)
@@ -2062,7 +2062,7 @@ int gmx_grompp(int argc, char *argv[])
                 else
                 {
                     sprintf(warn_buf, "NVE simulation with an initial temperature of zero: will use a Verlet buffer of %d%%. Check your energy drift!",
-                            (int)(verlet_buffer_ratio_NVE_T0*100 + 0.5));
+                            static_cast<int>(verlet_buffer_ratio_NVE_T0*100 + 0.5));
                     warning_note(wi, warn_buf);
                 }
             }
@@ -2100,8 +2100,8 @@ int gmx_grompp(int argc, char *argv[])
                     {
                         sprintf(warn_buf, "You are using a Verlet buffer tolerance of %g kJ/mol/ps for an NVE simulation of length %g ps, which can give a final drift of %d%%. For conserving energy to %d%% when using constraints, you might need to set verlet-buffer-tolerance to %.1e.",
                                 ir->verletbuf_tol, ir->nsteps*ir->delta_t,
-                                (int)(ir->verletbuf_tol/totalEnergyDriftPerAtomPerPicosecond*100 + 0.5),
-                                (int)(100*driftTolerance + 0.5),
+                                static_cast<int>(ir->verletbuf_tol/totalEnergyDriftPerAtomPerPicosecond*100 + 0.5),
+                                static_cast<int>(100*driftTolerance + 0.5),
                                 driftTolerance*totalEnergyDriftPerAtomPerPicosecond);
                         warning_note(wi, warn_buf);
                     }
index 52c634696d1d7d91818d412750c7095afb15a211..d21ff1094f9231217b35bdcc7f1de5480365b212 100644 (file)
@@ -188,7 +188,7 @@ static void read_h_db_file(const char *hfn, int *nahptr, t_hackblock **ah)
     if (nah > 0)
     {
         /* Sort the list (necessary to be able to use bsearch */
-        qsort(aah, nah, (size_t)sizeof(**ah), compaddh);
+        qsort(aah, nah, static_cast<size_t>(sizeof(**ah)), compaddh);
     }
 
     *nahptr = nah;
@@ -228,7 +228,7 @@ t_hackblock *search_h_db(int nh, t_hackblock ah[], char *key)
 
     ahkey.name = key;
 
-    result = static_cast<t_hackblock *>(bsearch(&ahkey, ah, nh, (size_t)sizeof(ah[0]), compaddh));
+    result = static_cast<t_hackblock *>(bsearch(&ahkey, ah, nh, static_cast<size_t>(sizeof(ah[0])), compaddh));
 
     return result;
 }
index f2d8cb564c8a52fc86007ae14ccad77ec8ee4723..49add7cf883ad6be3cd3c44d3a87e06751238a35 100644 (file)
@@ -759,7 +759,7 @@ static void sort_pdbatoms(t_restp restp[],
         pdbi[i].anm1   = atomnm[1];
         pdbi[i].altloc = pdba->pdbinfo[i].altloc;
     }
-    qsort(pdbi, natoms, (size_t)sizeof(pdbi[0]), pdbicomp);
+    qsort(pdbi, natoms, static_cast<size_t>(sizeof(pdbi[0])), pdbicomp);
 
     /* pdba is sorted in pdbnew using the pdbi index */
     snew(a, natoms);
index 793eb0c666d65ec1e25634310b66df3b6ce3f49e..913d227827cad1612dbbd71c55aee8ea4cae7e01 100644 (file)
@@ -874,7 +874,7 @@ static void clean_bonds(t_params *ps)
         }
 
         /* Sort bonds */
-        qsort(ps->param, ps->nr, (size_t)sizeof(ps->param[0]), pcompar);
+        qsort(ps->param, ps->nr, static_cast<size_t>(sizeof(ps->param[0])), pcompar);
 
         /* remove doubles, keep the first one always. */
         j = 1;
index 89ca70ff6ccd5e3f580426f07a9f646450743858..1dfd29551f8d698803fc4720c5af7308abd17146 100644 (file)
@@ -120,7 +120,7 @@ int search_atom(const char *type, int start,
         {
             if (anm[i] && gmx_strcasecmp(type, *(anm[i])) == 0)
             {
-                return (int) i;
+                return i;
             }
         }
         if (!(bNext && at[start].resind == at[natoms-1].resind))
@@ -140,7 +140,7 @@ int search_atom(const char *type, int start,
         {
             if (gmx_strcasecmp(type, *(anm[i])) == 0)
             {
-                return (int) i;
+                return i;
             }
         }
         if (start > 0)
index 5e39a38bef5fb6a5f45351a719483f3e053f6ee4..27e30adbcbadf4979603b6aace4b566d082164b8 100644 (file)
@@ -630,7 +630,7 @@ void check_ir(const char *mdparin, t_inputrec *ir, t_gromppopts *opts,
         CHECK(fep->sc_alpha != 0 && fep->sc_power != 1 && fep->sc_power != 2);
 
         sprintf(err_buf, "The soft-core sc-r-power is %d and can only be 6 or 48",
-                (int)fep->sc_r_power);
+                static_cast<int>(fep->sc_r_power));
         CHECK(fep->sc_alpha != 0 && fep->sc_r_power != 6.0 && fep->sc_r_power != 48.0);
 
         sprintf(err_buf, "Can't use positive delta-lambda (%g) if initial state/lambda does not start at zero", fep->delta_lambda);
@@ -1492,7 +1492,7 @@ static void do_fep_params(t_inputrec *ir, char fep_lambda[][STRLEN], char weight
         {
             for (j = 0; j < fep->n_lambda; j++)
             {
-                fep->all_lambda[i][j] = (double)count_fep_lambdas[i][j];
+                fep->all_lambda[i][j] = static_cast<double>(count_fep_lambdas[i][j]);
             }
             sfree(count_fep_lambdas[i]);
         }
@@ -1575,7 +1575,7 @@ static void do_fep_params(t_inputrec *ir, char fep_lambda[][STRLEN], char weight
     }
     if ((expand->nstexpanded < 0) && ir->bSimTemp)
     {
-        expand->nstexpanded = 2*(int)(ir->opts.tau_t[0]/ir->delta_t);
+        expand->nstexpanded = 2*static_cast<int>(ir->opts.tau_t[0]/ir->delta_t);
         /* if you don't specify nstexpanded when doing expanded ensemble simulated tempering, it is set to
            2*tau_t just to be careful so it's not to frequent  */
     }
@@ -2978,7 +2978,7 @@ static void calc_nrdf(const gmx_mtop_t *mtop, t_inputrec *ir, char **gnames)
             {
                 if (nrdf_vcm[j] > nrdf_vcm_sub[j])
                 {
-                    nrdf_tc[i] += nrdf_uc*((double)na_vcm[j]/(double)na_tot)*
+                    nrdf_tc[i] += nrdf_uc*(static_cast<double>(na_vcm[j])/static_cast<double>(na_tot))*
                         (nrdf_vcm[j] - nrdf_vcm_sub[j])/nrdf_vcm[j];
                 }
             }
index c87b8edba6ceb53d2e2619f5af37652ddf6e6a59..510525dcfa41a5111553e7455d06d6c429c90100 100644 (file)
@@ -547,8 +547,8 @@ static int neq_str_sign(const char *a1, const char *a2)
 {
     int l1, l2, lm;
 
-    l1 = (int)strlen(a1);
-    l2 = (int)strlen(a2);
+    l1 = static_cast<int>(strlen(a1));
+    l2 = static_cast<int>(strlen(a2));
     lm = std::min(l1, l2);
 
     if (lm >= 1 &&
@@ -586,8 +586,8 @@ char *search_rtp(const char *key, int nrtp, t_restp rtp[])
             /* Allow a mismatch of at most a sign character (with warning) */
             n = neq_str_sign(key, rtp[i].resname);
             if (n >= best &&
-                n+1 >= (int)strlen(key) &&
-                n+1 >= (int)strlen(rtp[i].resname))
+                n+1 >= static_cast<int>(strlen(key)) &&
+                n+1 >= static_cast<int>(strlen(rtp[i].resname)))
             {
                 if (n == best)
                 {
index bd8bb4d093c357956dc10a633a86ec94c90c0456..a57275f2a06d62c09a41d0ba362de711c79f2b37 100644 (file)
@@ -310,9 +310,9 @@ directive str2dir (char *dstr)
 
     for (d = 0; (d < d_maxdir); d++)
     {
-        if (gmx_strcasecmp_min(ptr, dir2str((directive)d)) == 0)
+        if (gmx_strcasecmp_min(ptr, dir2str(static_cast<directive>(d))) == 0)
         {
-            return (directive)d;
+            return static_cast<directive>(d);
         }
     }
 
@@ -331,7 +331,7 @@ static void set_nec(directive **n, ...)
     va_start(ap, n);
     do
     {
-        d = (directive)va_arg(ap, int);
+        d = static_cast<directive>(va_arg(ap, int));
         srenew(*n, ++ind);
         (*n)[ind-1] = d;
     }
index 1ff2a1ac5c62f85efa38f0f5eaeaab5e427ee676..4354a3f05e1c9bdf7659020e95df30aa94422db6 100644 (file)
@@ -569,7 +569,7 @@ static char **read_topol(const char *infile, const char *outfile,
             trim (pline);
 
             /* if there is something left... */
-            if ((int)strlen(pline) > 0)
+            if (static_cast<int>(strlen(pline)) > 0)
             {
                 if (pline[0] == OPENDIR)
                 {
@@ -891,7 +891,7 @@ static char **read_topol(const char *infile, const char *outfile,
                             break;
                         }
                         default:
-                            fprintf (stderr, "case: %d\n", (int)d);
+                            fprintf (stderr, "case: %d\n", static_cast<int>(d));
                             gmx_incons("unknown directive");
                     }
                 }
index 08268223351cf3fdfbee2b29a173ee70219941fa..8783264b18a509f574bfdf36e5d84b712a72a53a 100644 (file)
@@ -2071,7 +2071,7 @@ void push_bond(directive d, t_params bondtype[], t_params bond[],
     {
         sprintf(errbuf, "%s table number can not be perturbed %d!=%d",
                 interaction_function[ftype].longname,
-                (int)(param.c[0]+0.5), (int)(param.c[2]+0.5));
+                static_cast<int>(param.c[0]+0.5), static_cast<int>(param.c[2]+0.5));
         warning_error_and_exit(wi, errbuf, FARGS);
     }
 
@@ -2525,7 +2525,7 @@ void merge_excl(t_blocka *excl, t_block2 *b2, warninp_t wi)
         if (b2->nra[i] > 0)
         {
             /* remove double entries */
-            qsort(b2->a[i], (size_t)b2->nra[i], (size_t)sizeof(b2->a[i][0]), icomp);
+            qsort(b2->a[i], static_cast<size_t>(b2->nra[i]), static_cast<size_t>(sizeof(b2->a[i][0])), icomp);
             k = 1;
             for (j = 1; (j < b2->nra[i]); j++)
             {
index 0b92f80ecd101ebde801bcedbddbcc99bc4e14bf..5a38d4d7a1d3032f1205cef323e03c85349f5ddf 100644 (file)
@@ -372,7 +372,7 @@ void print_blocka(FILE *out, const char *szName,
         for (i = 0; (i < block->nr); i++)
         {
             fprintf (out, "%6d", i+1);
-            for (j = block->index[i]; (j < ((int)block->index[i+1])); j++)
+            for (j = block->index[i]; (j < (block->index[i+1])); j++)
             {
                 fprintf (out, "%5d", block->a[j]+1);
             }
@@ -499,7 +499,7 @@ void print_atoms(FILE *out, gpp_atomtype_t atype, t_atoms *at, int *cgnr,
                         tpnmB, at->atom[i].qB, at->atom[i].mB);
             }
             // Accumulate the total charge to help troubleshoot issues.
-            qtot += (double)at->atom[i].q;
+            qtot += static_cast<double>(at->atom[i].q);
             // Round it to zero if it is close to zero, because
             // printing -9.34e-5 confuses users.
             if (fabs(qtot) < 0.0001)
index a92f0a9546a252e80b54f305b77f99d26ffd9089..44d90618613e6d2250c21102a0e319b002c1c367 100644 (file)
@@ -226,7 +226,7 @@ static void lo_set_force_const(t_params *plist, real c[], int nrfp, bool bRound,
             if (bDih)
             {
                 c[0] *= c[2];
-                c[0]  = ((int)(c[0] + 3600)) % 360;
+                c[0]  = (static_cast<int>(c[0] + 3600)) % 360;
                 if (c[0] > 180)
                 {
                     c[0] -= 360;
index bf2a7d635a33fc1d41a7cde0c43d9fa748025438..44acfaae35f0075a57d6c87d8146b47b8dd46166 100644 (file)
@@ -191,7 +191,7 @@ void rename_atoms(const char *xlfile, const char *ffdir,
             if (isdigit(atombuf[0]))
             {
                 c = atombuf[0];
-                for (i = 0; ((size_t)i < strlen(atombuf)-1); i++)
+                for (i = 0; (static_cast<size_t>(i) < strlen(atombuf)-1); i++)
                 {
                     atombuf[i] = atombuf[i+1];
                 }
index 764fe57a961ccb9b3f9e3e5f80012d4cb223e4b2..a9c9458e66fd76d4423bd3bca5217b4c6babb164 100644 (file)
@@ -246,7 +246,7 @@ static const char *eIMDType_names[IMD_NR + 1] = {
 static void fill_header(IMDHeader *header, IMDMessageType type, int32_t length)
 {
     /* We (ab-)use htonl network function for the correct endianness */
-    header->type   = htonl((int32_t) type);
+    header->type   = htonl(static_cast<int32_t>(type));
     header->length = htonl(length);
 }
 
@@ -335,7 +335,7 @@ static int imd_handshake(IMDSocket *socket)
     fill_header(&header, IMD_HANDSHAKE, 1);
     header.length = IMDVERSION; /* client wants unswapped version */
 
-    return (imd_write_multiple(socket, (char *) &header, HEADERSIZE) != HEADERSIZE);
+    return (imd_write_multiple(socket, reinterpret_cast<char *>(&header), HEADERSIZE) != HEADERSIZE);
 }
 
 
@@ -346,7 +346,7 @@ static int imd_send_energies(IMDSocket *socket, const IMDEnergyBlock *energies,
 
 
     recsize = HEADERSIZE + sizeof(IMDEnergyBlock);
-    fill_header((IMDHeader *) buffer, IMD_ENERGIES, 1);
+    fill_header(reinterpret_cast<IMDHeader *>(buffer), IMD_ENERGIES, 1);
     memcpy(buffer + HEADERSIZE, energies, sizeof(IMDEnergyBlock));
 
     return (imd_write_multiple(socket, buffer, recsize) != recsize);
@@ -359,14 +359,14 @@ static IMDMessageType imd_recv_header(IMDSocket *socket, int32_t *length)
     IMDHeader header;
 
 
-    if (imd_read_multiple(socket, (char *) &header, HEADERSIZE) != HEADERSIZE)
+    if (imd_read_multiple(socket, reinterpret_cast<char *>(&header), HEADERSIZE) != HEADERSIZE)
     {
         return IMD_IOERROR;
     }
     swap_header(&header);
     *length = header.length;
 
-    return (IMDMessageType) header.type;
+    return static_cast<IMDMessageType>(header.type);
 }
 
 
@@ -381,7 +381,7 @@ static int imd_recv_mdcomm(IMDSocket *socket, int32_t nforces, int32_t *forcendx
 
     /* reading indices */
     retsize  = sizeof(int32_t) * nforces;
-    retbytes = imd_read_multiple(socket, (char *) forcendx, retsize);
+    retbytes = imd_read_multiple(socket, reinterpret_cast<char *>(forcendx), retsize);
     if (retbytes != retsize)
     {
         return FALSE;
@@ -389,7 +389,7 @@ static int imd_recv_mdcomm(IMDSocket *socket, int32_t nforces, int32_t *forcendx
 
     /* reading forces as float array */
     retsize  = 3 * sizeof(float) * nforces;
-    retbytes = imd_read_multiple(socket, (char *) forces, retsize);
+    retbytes = imd_read_multiple(socket, reinterpret_cast<char *>(forces), retsize);
     if (retbytes != retsize)
     {
         return FALSE;
@@ -450,12 +450,12 @@ static int imd_send_rvecs(IMDSocket *socket, int nat, rvec *x, char *buffer)
     size = HEADERSIZE + 3 * sizeof(float) * nat;
 
     /* Prepare header */
-    fill_header((IMDHeader *) buffer, IMD_FCOORDS, (int32_t) nat);
+    fill_header(reinterpret_cast<IMDHeader *>(buffer), IMD_FCOORDS, static_cast<int32_t>(nat));
     for (i = 0; i < nat; i++)
     {
-        sendx[0] = (float) x[i][0] * NM2A;
-        sendx[1] = (float) x[i][1] * NM2A;
-        sendx[2] = (float) x[i][2] * NM2A;
+        sendx[0] = static_cast<float>(x[i][0]) * NM2A;
+        sendx[1] = static_cast<float>(x[i][1]) * NM2A;
+        sendx[2] = static_cast<float>(x[i][2]) * NM2A;
         memcpy(buffer + HEADERSIZE + i * tuplesize, sendx, tuplesize);
     }
 
@@ -618,7 +618,7 @@ static gmx_bool imd_tryconnect(t_gmx_IMD_setup *IMDsetup)
 static void imd_blockconnect(t_gmx_IMD_setup *IMDsetup)
 {
     /* do not wait for connection, when e.g. ctrl+c is pressed and we will terminate anyways. */
-    if (!((int) gmx_get_stop_condition() == gmx_stop_cond_none))
+    if (!(static_cast<int>(gmx_get_stop_condition()) == gmx_stop_cond_none))
     {
         return;
     }
@@ -626,7 +626,7 @@ static void imd_blockconnect(t_gmx_IMD_setup *IMDsetup)
     fprintf(stderr, "%s Will wait until I have a connection and IMD_GO orders.\n", IMDstr);
 
     /* while we have no clientsocket... 2nd part: we should still react on ctrl+c */
-    while ((!IMDsetup->clientsocket) && ((int) gmx_get_stop_condition() == gmx_stop_cond_none))
+    while ((!IMDsetup->clientsocket) && (static_cast<int>(gmx_get_stop_condition()) == gmx_stop_cond_none))
     {
         imd_tryconnect(IMDsetup);
 #if GMX_NATIVE_WINDOWS
@@ -966,7 +966,7 @@ static void imd_readcommand(t_gmx_IMD_setup *IMDsetup)
 
             /* Catch all rule for the remaining IMD types which we don't expect */
             default:
-                fprintf(stderr, " %s Received unexpected %s.\n", IMDstr, enum_name((int)itype, IMD_NR, eIMDType_names));
+                fprintf(stderr, " %s Received unexpected %s.\n", IMDstr, enum_name(static_cast<int>(itype), IMD_NR, eIMDType_names));
                 imd_fatal(IMDsetup, "Terminating connection\n");
                 break;
         } /* end switch */
@@ -1582,15 +1582,15 @@ void IMD_fill_energy_record(gmx_bool bIMD, t_IMD *imd, gmx_enerdata_t *enerd,
              * last global communication step are still on display in the viewer. */
             if (bHaveNewEnergies)
             {
-                ene->T_abs   = (float)  enerd->term[F_TEMP   ];
-                ene->E_pot   = (float)  enerd->term[F_EPOT   ];
-                ene->E_tot   = (float)  enerd->term[F_ETOT   ];
-                ene->E_bond  = (float)  enerd->term[F_BONDS  ];
-                ene->E_angle = (float)  enerd->term[F_ANGLES ];
-                ene->E_dihe  = (float)  enerd->term[F_PDIHS  ];
-                ene->E_impr  = (float)  enerd->term[F_IDIHS  ];
-                ene->E_vdw   = (float)  enerd->term[F_LJ     ];
-                ene->E_coul  = (float)  enerd->term[F_COUL_SR];
+                ene->T_abs   = static_cast<float>(enerd->term[F_TEMP   ]);
+                ene->E_pot   = static_cast<float>(enerd->term[F_EPOT   ]);
+                ene->E_tot   = static_cast<float>(enerd->term[F_ETOT   ]);
+                ene->E_bond  = static_cast<float>(enerd->term[F_BONDS  ]);
+                ene->E_angle = static_cast<float>(enerd->term[F_ANGLES ]);
+                ene->E_dihe  = static_cast<float>(enerd->term[F_PDIHS  ]);
+                ene->E_impr  = static_cast<float>(enerd->term[F_IDIHS  ]);
+                ene->E_vdw   = static_cast<float>(enerd->term[F_LJ     ]);
+                ene->E_coul  = static_cast<float>(enerd->term[F_COUL_SR]);
             }
         }
 #else
index afaa54dc9ccb94f8f00d3138f9768cd8eed0c422..d5a5cfb4184d58c3592758fbf6dcb6d247368397 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2014,2015,2016,2017, by the GROMACS development team, led by
+ * Copyright (c) 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.
@@ -147,7 +147,7 @@ extern int imdsock_bind(IMDSocket *sock, int port)
     sock->address.sin_port   = htons(port);
 
     /* Try to bind to address and port ...*/
-    ret = bind(sock->sockfd, (struct sockaddr *) &sock->address, sizeof(sock->address));
+    ret = bind(sock->sockfd, reinterpret_cast<struct sockaddr *>(&sock->address), sizeof(sock->address));
 #else
     ret = -1;
 #endif
@@ -191,7 +191,7 @@ extern IMDSocket* imdsock_accept(IMDSocket *sock)
 
 
     length = sizeof(sock->address);
-    ret    = accept(sock->sockfd, (struct sockaddr *) &sock->address, &length);
+    ret    = accept(sock->sockfd, reinterpret_cast<struct sockaddr *>(&sock->address), &length);
 
     /* successful, redirect to distinct clientsocket */
     if (ret >= 0)
@@ -222,7 +222,7 @@ extern int imdsock_getport(IMDSocket *sock, int *port)
 
 
     len = sizeof(struct sockaddr_in);
-    ret = getsockname(sock->sockfd, (struct sockaddr *) &(sock->address), &len);
+    ret = getsockname(sock->sockfd, reinterpret_cast<struct sockaddr *>(&(sock->address)), &len);
     if (ret)
     {
         fprintf(stderr, "%s getsockname failed with error %d.\n", IMDstr, ret);
index 33ee488b6ca2dfb4207c88172e8e607672826928..23dbbd1d41ca33b4cc01d3f90aeba1592ef2f16c 100644 (file)
@@ -367,7 +367,7 @@ calc_one_bond(int thread,
             /* No energies, shift forces, dvdl */
             rbdihs_noener_simd(nbn, idef->il[ftype].iatoms+nb0,
                                idef->iparams,
-                               (const rvec*)x, f,
+                               static_cast<const rvec*>(x), f,
                                pbc, g, lambda[efptFTYPE], md, fcd,
                                global_atom_index);
             v = 0;
index 8312e98d3c45ae6e53fe0d0b0543eee132687fe2..82885e4af5ef3815ac11bdd022b59b798eee5b4d 100644 (file)
@@ -466,8 +466,8 @@ void setup_bonded_threading(bonded_threading_t *bt,
         fprintf(debug, "Number of %d atom blocks to reduce: %d\n",
                 reduction_block_size, bt->nblock_used);
         fprintf(debug, "Reduction density %.2f for touched blocks only %.2f\n",
-                ctot*reduction_block_size/(double)numAtoms,
-                ctot/(double)bt->nblock_used);
+                ctot*reduction_block_size/static_cast<double>(numAtoms),
+                ctot/static_cast<double>(bt->nblock_used));
     }
 }
 
index 87100100d0af611977aa940f99057c83b43212b6..d4b3cefa1dc5401703422108ff8f0f59013b5511 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2015, by the GROMACS development team, led by
+ * Copyright (c) 2015,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.
@@ -73,12 +73,12 @@ void invertBoxMatrix(const matrix src, matrix dest)
 
 void invertMatrix(const matrix src, matrix dest)
 {
-    const real smallreal = (real)1.0e-24;
-    const real largereal = (real)1.0e24;
+    const real smallreal = static_cast<real>(1.0e-24);
+    const real largereal = static_cast<real>(1.0e24);
 
     real       determinant = det(src);
-    real       c           = (real)1.0/determinant;
-    real       fc          = (real)std::fabs(c);
+    real       c           = static_cast<real>(1.0)/determinant;
+    real       fc          = static_cast<real>(std::fabs(c));
 
     if ((fc <= smallreal) || (fc >= largereal))
     {
index f40fbff9f4f2e5f96d130956b7de824ea3489c22..56ab300b2bc22b5a95b145b9f22080f377f7c182 100644 (file)
@@ -714,11 +714,11 @@ static real energyDrift(const verletbuf_atomtype_t *att, int natt,
             /* Multiply by the number of atom pairs */
             if (j == i)
             {
-                pot *= (double)att[i].n*(att[i].n - 1)/2;
+                pot *= static_cast<double>(att[i].n)*(att[i].n - 1)/2;
             }
             else
             {
-                pot *= (double)att[i].n*att[j].n;
+                pot *= static_cast<double>(att[i].n)*att[j].n;
             }
             /* We need the line density to get the energy drift of the system.
              * The effective average r^2 is close to (rlist+sigma)^2.
@@ -1074,7 +1074,7 @@ void calc_verlet_buffer_size(const gmx_mtop_t *mtop, real boxvol,
     /* Search using bisection */
     ib0 = -1;
     /* The drift will be neglible at 5 times the max sigma */
-    ib1 = (int)(5*2*std::sqrt(kT_fac/mass_min)/resolution) + 1;
+    ib1 = static_cast<int>(5*2*std::sqrt(kT_fac/mass_min)/resolution) + 1;
     while (ib1 - ib0 > 1)
     {
         ib = (ib0 + ib1)/2;
index 8d04914175f2f2e058da9a52352d6ca08bf9ee3f..f9d4979d9cec8d10eb8a8989ca2a9f84b0749381 100644 (file)
@@ -102,7 +102,7 @@ gmx_bool read_mu(FILE *fp, rvec mu, real *vol)
     /* For backward compatibility */
     real mmm[4];
 
-    if (fread(mmm, (size_t)(4*sizeof(real)), 1, fp) != 1)
+    if (fread(mmm, static_cast<size_t>(4*sizeof(real)), 1, fp) != 1)
     {
         return FALSE;
     }
index 3d2590d47e944261be586707401262ac6e22ea80..061518a6b9d7a93238f26c22e85071a07da49eb2 100644 (file)
@@ -273,7 +273,7 @@ static void boxv_trotter(t_inputrec *ir, real *veta, real dt, tensor box,
         gmx_fatal(FARGS, "Barostat is coupled to a T-group with no degrees of freedom\n");
     }
     /* alpha factor for phase space volume, then multiply by the ekin scaling factor.  */
-    alpha  = 1.0 + DIM/((double)ir->opts.nrdf[0]);
+    alpha  = 1.0 + DIM/(static_cast<double>(ir->opts.nrdf[0]));
     alpha *= ekind->tcstat[0].ekinscalef_nhc;
     msmul(ekind->ekin, alpha, ekinmod);
     /* for now, we use Elr = 0, because if you want to get it right, you
@@ -1450,7 +1450,7 @@ static real vrescale_sumnoises(real                            nn,
         int  nn_int, i;
         real gauss;
 
-        nn_int = (int)(nn + 0.5);
+        nn_int = static_cast<int>(nn + 0.5);
 
         if (nn - nn_int < -ndeg_tol || nn - nn_int > ndeg_tol)
         {
index 0985f9e5dc32c12acd2ce82bb8265a9c6d404c7f..3096deb0457ad163cc815993f6b757153f54181a 100644 (file)
@@ -165,7 +165,7 @@ void add_ebin(t_ebin *eb, int index, int nener, const real ener[], gmx_bool bSum
         }
         else
         {
-            invmm = (1.0/(double)m)/((double)m+1.0);
+            invmm = (1.0/m)/(m+1.0);
 
             for (i = 0; (i < nener); i++)
             {
index fe54c240d0f72242afa11b52b483989944b579b1..dc83030e603bcf4adad8f6b7f4e3e66eebe223c0 100644 (file)
@@ -212,7 +212,7 @@ static gmx_bool CheckHistogramRatios(int nhisto, const real *histo, real ratio)
         bIfFlat = FALSE;
         return bIfFlat;
     }
-    nmean /= (real)nhisto;
+    nmean /= static_cast<real>(nhisto);
 
     bIfFlat = TRUE;
     for (i = 0; i < nhisto; i++)
@@ -387,7 +387,7 @@ static gmx_bool UpdateWeights(int nlim, t_expanded *expand, df_history_t *dfhist
             GenerateGibbsProbabilities(weighted_lamee, p_k, &pks, 0, nlim-1);
             for (i = 0; i < nlim; i++)
             {
-                dfhist->wl_histo[i] += (real)p_k[i];
+                dfhist->wl_histo[i] += static_cast<real>(p_k[i]);
             }
 
             /* then increment weights (uses count) */
@@ -396,7 +396,7 @@ static gmx_bool UpdateWeights(int nlim, t_expanded *expand, df_history_t *dfhist
 
             for (i = 0; i < nlim; i++)
             {
-                dfhist->sum_weights[i] -= dfhist->wl_delta*(real)p_k[i];
+                dfhist->sum_weights[i] -= dfhist->wl_delta*static_cast<real>(p_k[i]);
             }
             /* Alternate definition, using logarithms. Shouldn't make very much difference! */
             /*
@@ -448,7 +448,7 @@ static gmx_bool UpdateWeights(int nlim, t_expanded *expand, df_history_t *dfhist
         for (nval = 0; nval < maxc; nval++)
         {
             /* constants for later use */
-            cnval = (real)(nval-expand->c_range);
+            cnval = static_cast<real>(nval-expand->c_range);
             /* actually, should be able to rewrite it w/o exponential, for better numerical stability */
             if (fep_state > 0)
             {
@@ -1063,7 +1063,7 @@ void PrintFreeEnergyInfoToFile(FILE *outfile, t_lambda *fep, t_expanded *expand,
             {
                 if (expand->elamstats == elamstatsWL)
                 {
-                    fprintf(outfile, " %8d", (int)dfhist->wl_histo[ifep]);
+                    fprintf(outfile, " %8d", static_cast<int>(dfhist->wl_histo[ifep]));
                 }
                 else
                 {
@@ -1268,7 +1268,7 @@ int ExpandedEnsembleDynamics(FILE *log, t_inputrec *ir, gmx_enerdata_t *enerd,
     {
         if (log)
         {
-            fprintf(log, "\nStep %d: Weights have equilibrated, using criteria: %s\n", (int)step, elmceq_names[expand->elmceq]);
+            fprintf(log, "\nStep %" PRId64 ": Weights have equilibrated, using criteria: %s\n", step, elmceq_names[expand->elmceq]);
         }
     }
 
@@ -1370,7 +1370,7 @@ int ExpandedEnsembleDynamics(FILE *log, t_inputrec *ir, gmx_enerdata_t *enerd,
                 dfhist->wl_delta *= expand->wl_scale;
                 if (log)
                 {
-                    fprintf(log, "\nStep %d: weights are now:", (int)step);
+                    fprintf(log, "\nStep %d: weights are now:", static_cast<int>(step));
                     for (i = 0; i < nlim; i++)
                     {
                         fprintf(log, " %.5f", dfhist->sum_weights[i]);
index 6d2981d5e391561d3cfa9a129df2dccc11c7353a..3d30bc8f4091319233726d818e9039381cdc392e 100644 (file)
@@ -1198,8 +1198,8 @@ void set_avcsixtwelve(FILE *fplog, t_forcerec *fr, const gmx_mtop_t *mtop)
         if (debug)
         {
             fprintf(debug, "Counted %d exclusions\n", nexcl);
-            fprintf(debug, "Average C6 parameter is: %10g\n", (double)csix);
-            fprintf(debug, "Average C12 parameter is: %10g\n", (double)ctwelve);
+            fprintf(debug, "Average C6 parameter is: %10g\n", csix);
+            fprintf(debug, "Average C12 parameter is: %10g\n", ctwelve);
         }
         fr->avcsix[q]    = csix;
         fr->avctwelve[q] = ctwelve;
index 33861960345cb28ad394b3c3e7fa97d3be0e79b4..557e5cb014a289c4519e13645de23d26dda9f5a9 100644 (file)
@@ -271,7 +271,7 @@ void compute_globals(FILE *fplog, gmx_global_stat *gstat, t_commrec *cr, t_input
          */
         enerd->term[F_TEMP] = sum_ekin(&(ir->opts), ekind, &dvdl_ekin,
                                        bEkinAveVel, bScaleEkin);
-        enerd->dvdl_lin[efptMASS] = (double) dvdl_ekin;
+        enerd->dvdl_lin[efptMASS] = static_cast<double>(dvdl_ekin);
 
         enerd->term[F_EKIN] = trace(ekind->ekin);
     }
index 4b7e98650e5fb5cd213457b3a8f3577fd14d03bb..64cfab706060f8a871464dea6f2c6cf24d9195e9 100644 (file)
@@ -1195,7 +1195,7 @@ void upd_mdebin(t_mdebin               *md,
             store_energy = enerd->term[F_ETOT];
             /* store_dh is dE */
             mde_delta_h_coll_add_dh(md->dhc,
-                                    (double)state->fep_state,
+                                    static_cast<double>(state->fep_state),
                                     store_energy,
                                     pv,
                                     store_dhdl,
index 3f578a1dc126413018b9594ea72e80ad7c192eec..0597e8aaf9678756aeba3429dcefa42fa5c02a76 100644 (file)
@@ -176,7 +176,7 @@ static void mde_delta_h_make_hist(t_mde_delta_h *dh, int hi, gmx_bool invert)
        Get this start value in number of histogram dxs from zero,
        as an integer.*/
 
-    dh->x0[hi] = (int64_t)floor(min_dh/dx);
+    dh->x0[hi] = static_cast<int64_t>(floor(min_dh/dx));
 
     min_dh_hist = (dh->x0[hi])*dx;
     max_dh_hist = (dh->x0[hi] + dh->nbins + 1)*dx;
@@ -192,7 +192,7 @@ static void mde_delta_h_make_hist(t_mde_delta_h *dh, int hi, gmx_bool invert)
            might lead to overflow with unpredictable results.*/
         if ( (f*dh->dh[i] >= min_dh_hist) && (f*dh->dh[i] <= max_dh_hist ) )
         {
-            bin = (unsigned int)( (f*dh->dh[i] - min_dh_hist)/dx );
+            bin = static_cast<unsigned int>( (f*dh->dh[i] - min_dh_hist)/dx );
         }
         else
         {
@@ -269,7 +269,7 @@ static void mde_delta_h_handle_block(t_mde_delta_h *dh, t_enxblock *blk)
             blk->sub[2].type = xdr_datatype_float;
             for (i = 0; i < dh->ndh; i++)
             {
-                dh->dhf[i] = (float)dh->dh[i];
+                dh->dhf[i] = static_cast<float>(dh->dh[i]);
             }
             blk->sub[2].fval = dh->dhf;
             dh->written      = TRUE;
index 1195178d8a3b6bebb46c969084e1a4c9282b0c67..19edefaedd2a18727432288a74802170e95d34a1 100644 (file)
@@ -446,7 +446,7 @@ static int init_mem_at(mem_t *mem_p, gmx_mtop_t *mtop, rvec *r, matrix box, pos_
     /*membrane area within the box defined by the min and max coordinates of the embedded molecule*/
     mem_area = (pos_ins->xmax[XX]-pos_ins->xmin[XX])*(pos_ins->xmax[YY]-pos_ins->xmin[YY]);
     /*rough estimate of area per lipid, assuming there is only one type of lipid in the membrane*/
-    mem_p->lip_area = 2.0*mem_area/(double)nmolbox;
+    mem_p->lip_area = 2.0*mem_area/static_cast<double>(nmolbox);
 
     return mem_p->mem_at.nr;
 }
@@ -496,7 +496,7 @@ static void init_resize(t_block *ins_at, rvec *r_ins, pos_ins_t *pos_ins, mem_t
 
         if (c > 0)
         {
-            svmul(1/(double)c, pos_ins->geom_cent[i], pos_ins->geom_cent[i]);
+            svmul(1/static_cast<double>(c), pos_ins->geom_cent[i], pos_ins->geom_cent[i]);
         }
 
         if (!bALLOW_ASYMMETRY)
@@ -1227,7 +1227,7 @@ gmx_membed_t *init_membed(FILE *fplog, int nfile, const t_filenm fnm[], gmx_mtop
                "The area per lipid is %.4f nm^2.\n", mem_p->nmol, mem_p->lip_area);
 
         /* Maximum number of lipids to be removed*/
-        max_lip_rm = (int)(2*prot_area/mem_p->lip_area);
+        max_lip_rm = static_cast<int>(2*prot_area/mem_p->lip_area);
         printf("Maximum number of lipids that will be removed is %d.\n", max_lip_rm);
 
         printf("\nWill resize the protein by a factor of %.3f in the xy plane and %.3f in the z direction.\n"
@@ -1241,8 +1241,8 @@ gmx_membed_t *init_membed(FILE *fplog, int nfile, const t_filenm fnm[], gmx_mtop
         membed->fac[0] = membed->fac[1] = xy_fac;
         membed->fac[2] = z_fac;
 
-        membed->xy_step = (xy_max-xy_fac)/(double)(it_xy);
-        membed->z_step  = (z_max-z_fac)/(double)(it_z-1);
+        membed->xy_step = (xy_max-xy_fac)/static_cast<double>(it_xy);
+        membed->z_step  = (z_max-z_fac)/static_cast<double>(it_z-1);
 
         resize(r_ins, as_rvec_array(state->x.data()), pos_ins, membed->fac);
 
index 992c772695da3861fef58a1eee53fda7b2878b69..42fa2ba3ddf41256b8e3a7bdcac8eb54e523e964 100644 (file)
@@ -120,36 +120,36 @@ void nbnxn_atomdata_realloc(nbnxn_atomdata_t *nbat, int n)
 
     int t;
 
-    nbnxn_realloc_void((void **)&nbat->type,
+    nbnxn_realloc_void(reinterpret_cast<void **>(&nbat->type),
                        nbat->natoms*sizeof(*nbat->type),
                        n*sizeof(*nbat->type),
                        nbat->alloc, nbat->free);
-    nbnxn_realloc_void((void **)&nbat->lj_comb,
+    nbnxn_realloc_void(reinterpret_cast<void **>(&nbat->lj_comb),
                        nbat->natoms*2*sizeof(*nbat->lj_comb),
                        n*2*sizeof(*nbat->lj_comb),
                        nbat->alloc, nbat->free);
     if (nbat->XFormat != nbatXYZQ)
     {
-        nbnxn_realloc_void((void **)&nbat->q,
+        nbnxn_realloc_void(reinterpret_cast<void **>(&nbat->q),
                            nbat->natoms*sizeof(*nbat->q),
                            n*sizeof(*nbat->q),
                            nbat->alloc, nbat->free);
     }
     if (nbat->nenergrp > 1)
     {
-        nbnxn_realloc_void((void **)&nbat->energrp,
+        nbnxn_realloc_void(reinterpret_cast<void **>(&nbat->energrp),
                            nbat->natoms/nbat->na_c*sizeof(*nbat->energrp),
                            n/nbat->na_c*sizeof(*nbat->energrp),
                            nbat->alloc, nbat->free);
     }
-    nbnxn_realloc_void((void **)&nbat->x,
+    nbnxn_realloc_void(reinterpret_cast<void **>(&nbat->x),
                        nbat->natoms*nbat->xstride*sizeof(*nbat->x),
                        n*nbat->xstride*sizeof(*nbat->x),
                        nbat->alloc, nbat->free);
     for (t = 0; t < nbat->nout; t++)
     {
         /* Allocate one element extra for possible signaling with GPUs */
-        nbnxn_realloc_void((void **)&nbat->out[t].f,
+        nbnxn_realloc_void(reinterpret_cast<void **>(&nbat->out[t].f),
                            nbat->natoms*nbat->fstride*sizeof(*nbat->out[t].f),
                            n*nbat->fstride*sizeof(*nbat->out[t].f),
                            nbat->alloc, nbat->free);
@@ -164,18 +164,18 @@ static void nbnxn_atomdata_output_init(nbnxn_atomdata_output_t *out,
                                        nbnxn_alloc_t *ma)
 {
     out->f = nullptr;
-    ma((void **)&out->fshift, SHIFTS*DIM*sizeof(*out->fshift));
+    ma(reinterpret_cast<void **>(&out->fshift), SHIFTS*DIM*sizeof(*out->fshift));
     out->nV = nenergrp*nenergrp;
-    ma((void **)&out->Vvdw, out->nV*sizeof(*out->Vvdw));
-    ma((void **)&out->Vc, out->nV*sizeof(*out->Vc  ));
+    ma(reinterpret_cast<void **>(&out->Vvdw), out->nV*sizeof(*out->Vvdw));
+    ma(reinterpret_cast<void **>(&out->Vc), out->nV*sizeof(*out->Vc  ));
 
     if (nb_kernel_type == nbnxnk4xN_SIMD_4xN ||
         nb_kernel_type == nbnxnk4xN_SIMD_2xNN)
     {
         int cj_size  = nbnxn_kernel_to_cluster_j_size(nb_kernel_type);
         out->nVS = nenergrp*nenergrp*stride*(cj_size>>1)*cj_size;
-        ma((void **)&out->VSvdw, out->nVS*sizeof(*out->VSvdw));
-        ma((void **)&out->VSc, out->nVS*sizeof(*out->VSc  ));
+        ma(reinterpret_cast<void **>(&out->VSvdw), out->nVS*sizeof(*out->VSvdw));
+        ma(reinterpret_cast<void **>(&out->VSc), out->nVS*sizeof(*out->VSc  ));
     }
     else
     {
@@ -338,7 +338,7 @@ static void set_lj_parameter_data(nbnxn_atomdata_t *nbat, gmx_bool bSIMD)
          * when it might not be used, but introducing the conditional code is not
          * really worth it.
          */
-        nbat->alloc((void **)&nbat->nbfp_aligned,
+        nbat->alloc(reinterpret_cast<void **>(&nbat->nbfp_aligned),
                     nt*nt*c_simdBestPairAlignment*sizeof(*nbat->nbfp_aligned));
         for (int i = 0; i < nt; i++)
         {
@@ -523,9 +523,9 @@ void nbnxn_atomdata_init(const gmx::MDLogger &mdlog,
         fprintf(debug, "There are %d atom types in the system, adding one for nbnxn_atomdata_t\n", ntype);
     }
     nbat->ntype = ntype + 1;
-    nbat->alloc((void **)&nbat->nbfp,
+    nbat->alloc(reinterpret_cast<void **>(&nbat->nbfp),
                 nbat->ntype*nbat->ntype*2*sizeof(*nbat->nbfp));
-    nbat->alloc((void **)&nbat->nbfp_comb, nbat->ntype*2*sizeof(*nbat->nbfp_comb));
+    nbat->alloc(reinterpret_cast<void **>(&nbat->nbfp_comb), nbat->ntype*2*sizeof(*nbat->nbfp_comb));
 
     /* A tolerance of 1e-5 seems reasonable for (possibly hand-typed)
      * force-field floating point parameters.
@@ -720,7 +720,7 @@ void nbnxn_atomdata_init(const gmx::MDLogger &mdlog,
         nbat->neg_2log++;
     }
     nbat->energrp = nullptr;
-    nbat->alloc((void **)&nbat->shift_vec, SHIFTS*sizeof(*nbat->shift_vec));
+    nbat->alloc(reinterpret_cast<void **>(&nbat->shift_vec), SHIFTS*sizeof(*nbat->shift_vec));
     nbat->xstride = (nbat->XFormat == nbatXYZQ ? STRIDE_XYZQ : DIM);
     nbat->fstride = (nbat->FFormat == nbatXYZQ ? STRIDE_XYZQ : DIM);
     nbat->x       = nullptr;
index 619347c0e24ea8ed43c080ededc3e0118f1c0616..13aaf12ee455caa4d4c4215aa3d2e799d2107b4c 100644 (file)
@@ -1285,7 +1285,7 @@ static void calc_cell_indices(nbnxn_search         *nbs,
     {
         fprintf(debug, "ns na_sc %d na_c %d super-cells: %d x %d y %d z %.1f maxz %d\n",
                 grid->na_sc, grid->na_c, grid->nc,
-                grid->numCells[XX], grid->numCells[YY], grid->nc/((double)(grid->numCells[XX]*grid->numCells[YY])),
+                grid->numCells[XX], grid->numCells[YY], grid->nc/(static_cast<double>(grid->numCells[XX]*grid->numCells[YY])),
                 ncz_max);
         if (gmx_debug_at)
         {
@@ -1383,7 +1383,7 @@ static void calc_cell_indices(nbnxn_search         *nbs,
         else
         {
             fprintf(debug, "ns non-zero sub-cells: %d average atoms %.2f\n",
-                    grid->nsubc_tot, (atomEnd - atomStart)/(double)grid->nsubc_tot);
+                    grid->nsubc_tot, (atomEnd - atomStart)/static_cast<double>(grid->nsubc_tot));
 
             print_bbsizes_supersub(debug, grid);
         }
index 031c8e5815122a0d8026255ca4649d0f24c8fc89..11353d4720749f586a17022bdd9bf47ee1afa6ae 100644 (file)
@@ -370,7 +370,7 @@ nbnxn_kernel_gpu_ref(const nbnxn_pairlist_t     *nbl,
     {
         fprintf(debug, "number of half %dx%d atom pairs: %d after pruning: %d fraction %4.2f\n",
                 nbl->na_ci, nbl->na_ci,
-                nhwu, nhwu_pruned, nhwu_pruned/(double)nhwu);
+                nhwu, nhwu_pruned, nhwu_pruned/static_cast<double>(nhwu));
         fprintf(debug, "generic kernel pair interactions:            %d\n",
                 nhwu*nbl->na_ci/2*nbl->na_ci);
         fprintf(debug, "generic kernel post-prune pair interactions: %d\n",
@@ -378,6 +378,6 @@ nbnxn_kernel_gpu_ref(const nbnxn_pairlist_t     *nbl,
         fprintf(debug, "generic kernel non-zero pair interactions:   %d\n",
                 npair_tot);
         fprintf(debug, "ratio non-zero/post-prune pair interactions: %4.2f\n",
-                npair_tot/(double)(nhwu_pruned*gmx::exactDiv(nbl->na_ci, 2)*nbl->na_ci));
+                npair_tot/static_cast<double>(nhwu_pruned*gmx::exactDiv(nbl->na_ci, 2)*nbl->na_ci));
     }
 }
index 0248a5d1a5662f75240db12e2c5fedaf36a7b3d9..81979e6431e86d3dc603cd98d0d87eaa441e5fd7 100644 (file)
@@ -93,7 +93,7 @@ static void nbs_cycle_clear(nbnxn_cycle_t *cc)
 
 static double Mcyc_av(const nbnxn_cycle_t *cc)
 {
-    return (double)cc->c*1e-6/cc->count;
+    return static_cast<double>(cc->c)*1e-6/cc->count;
 }
 
 static void nbs_cycle_print(FILE *fp, const nbnxn_search *nbs)
@@ -737,7 +737,7 @@ static void check_excl_space(nbnxn_pairlist_t *nbl, int extra)
     if (nbl->nexcl+extra > nbl->excl_nalloc)
     {
         nbl->excl_nalloc = over_alloc_small(nbl->nexcl+extra);
-        nbnxn_realloc_void((void **)&nbl->excl,
+        nbnxn_realloc_void(reinterpret_cast<void **>(&nbl->excl),
                            nbl->nexcl*sizeof(*nbl->excl),
                            nbl->excl_nalloc*sizeof(*nbl->excl),
                            nbl->alloc, nbl->free);
@@ -755,12 +755,12 @@ static void check_cell_list_space_simple(nbnxn_pairlist_t *nbl,
     if (cj_max > nbl->cj_nalloc)
     {
         nbl->cj_nalloc = over_alloc_small(cj_max);
-        nbnxn_realloc_void((void **)&nbl->cj,
+        nbnxn_realloc_void(reinterpret_cast<void **>(&nbl->cj),
                            nbl->ncj*sizeof(*nbl->cj),
                            nbl->cj_nalloc*sizeof(*nbl->cj),
                            nbl->alloc, nbl->free);
 
-        nbnxn_realloc_void((void **)&nbl->cjOuter,
+        nbnxn_realloc_void(reinterpret_cast<void **>(&nbl->cjOuter),
                            nbl->ncj*sizeof(*nbl->cjOuter),
                            nbl->cj_nalloc*sizeof(*nbl->cjOuter),
                            nbl->alloc, nbl->free);
@@ -782,7 +782,7 @@ static void check_cell_list_space_supersub(nbnxn_pairlist_t *nbl,
     if (ncj4_max > nbl->cj4_nalloc)
     {
         nbl->cj4_nalloc = over_alloc_small(ncj4_max);
-        nbnxn_realloc_void((void **)&nbl->cj4,
+        nbnxn_realloc_void(reinterpret_cast<void **>(&nbl->cj4),
                            nbl->work->cj4_init*sizeof(*nbl->cj4),
                            nbl->cj4_nalloc*sizeof(*nbl->cj4),
                            nbl->alloc, nbl->free);
@@ -970,12 +970,12 @@ static void print_nblist_statistics_simple(FILE *fp, const nbnxn_pairlist_t *nbl
     fprintf(fp, "nbl nci %d ncj %d\n",
             nbl->nci, nbl->ncjInUse);
     fprintf(fp, "nbl na_sc %d rl %g ncp %d per cell %.1f atoms %.1f ratio %.2f\n",
-            nbl->na_sc, rl, nbl->ncjInUse, nbl->ncjInUse/(double)grid->nc,
-            nbl->ncjInUse/(double)grid->nc*grid->na_sc,
-            nbl->ncjInUse/(double)grid->nc*grid->na_sc/(0.5*4.0/3.0*M_PI*rl*rl*rl*grid->nc*grid->na_sc/(grid->size[XX]*grid->size[YY]*grid->size[ZZ])));
+            nbl->na_sc, rl, nbl->ncjInUse, nbl->ncjInUse/static_cast<double>(grid->nc),
+            nbl->ncjInUse/static_cast<double>(grid->nc)*grid->na_sc,
+            nbl->ncjInUse/static_cast<double>(grid->nc)*grid->na_sc/(0.5*4.0/3.0*M_PI*rl*rl*rl*grid->nc*grid->na_sc/(grid->size[XX]*grid->size[YY]*grid->size[ZZ])));
 
     fprintf(fp, "nbl average j cell list length %.1f\n",
-            0.25*nbl->ncjInUse/(double)std::max(nbl->nci, 1));
+            0.25*nbl->ncjInUse/static_cast<double>(std::max(nbl->nci, 1)));
 
     for (int s = 0; s < SHIFTS; s++)
     {
@@ -996,7 +996,7 @@ static void print_nblist_statistics_simple(FILE *fp, const nbnxn_pairlist_t *nbl
         }
     }
     fprintf(fp, "nbl cell pairs, total: %d excl: %d %.1f%%\n",
-            nbl->ncj, npexcl, 100*npexcl/(double)std::max(nbl->ncj, 1));
+            nbl->ncj, npexcl, 100*npexcl/static_cast<double>(std::max(nbl->ncj, 1)));
     for (int s = 0; s < SHIFTS; s++)
     {
         if (cs[s] > 0)
@@ -1022,9 +1022,9 @@ static void print_nblist_statistics_supersub(FILE *fp, const nbnxn_pairlist_t *n
     fprintf(fp, "nbl nsci %d ncj4 %d nsi %d excl4 %d\n",
             nbl->nsci, nbl->ncj4, nbl->nci_tot, nbl->nexcl);
     fprintf(fp, "nbl na_c %d rl %g ncp %d per cell %.1f atoms %.1f ratio %.2f\n",
-            nbl->na_ci, rl, nbl->nci_tot, nbl->nci_tot/(double)grid->nsubc_tot,
-            nbl->nci_tot/(double)grid->nsubc_tot*grid->na_c,
-            nbl->nci_tot/(double)grid->nsubc_tot*grid->na_c/(0.5*4.0/3.0*M_PI*rl*rl*rl*grid->nsubc_tot*grid->na_c/(grid->size[XX]*grid->size[YY]*grid->size[ZZ])));
+            nbl->na_ci, rl, nbl->nci_tot, nbl->nci_tot/static_cast<double>(grid->nsubc_tot),
+            nbl->nci_tot/static_cast<double>(grid->nsubc_tot)*grid->na_c,
+            nbl->nci_tot/static_cast<double>(grid->nsubc_tot)*grid->na_c/(0.5*4.0/3.0*M_PI*rl*rl*rl*grid->nsubc_tot*grid->na_c/(grid->size[XX]*grid->size[YY]*grid->size[ZZ])));
 
     sum_nsp  = 0;
     sum_nsp2 = 0;
@@ -1072,7 +1072,7 @@ static void print_nblist_statistics_supersub(FILE *fp, const nbnxn_pairlist_t *n
         {
             fprintf(fp, "nbl j-list #i-subcell %d %7d %4.1f\n",
                     b, c[b],
-                    100.0*c[b]/(double)(nbl->ncj4*c_nbnxnGpuJgroupSize));
+                    100.0*c[b]/static_cast<double>(nbl->ncj4*c_nbnxnGpuJgroupSize));
         }
     }
 }
@@ -2168,12 +2168,12 @@ setExclusionsForGpuIentry(const nbnxn_search   *nbs,
 static void nb_realloc_ci(nbnxn_pairlist_t *nbl, int n)
 {
     nbl->ci_nalloc = over_alloc_small(n);
-    nbnxn_realloc_void((void **)&nbl->ci,
+    nbnxn_realloc_void(reinterpret_cast<void **>(&nbl->ci),
                        nbl->nci*sizeof(*nbl->ci),
                        nbl->ci_nalloc*sizeof(*nbl->ci),
                        nbl->alloc, nbl->free);
 
-    nbnxn_realloc_void((void **)&nbl->ciOuter,
+    nbnxn_realloc_void(reinterpret_cast<void **>(&nbl->ciOuter),
                        nbl->nci*sizeof(*nbl->ciOuter),
                        nbl->ci_nalloc*sizeof(*nbl->ciOuter),
                        nbl->alloc, nbl->free);
@@ -2183,7 +2183,7 @@ static void nb_realloc_ci(nbnxn_pairlist_t *nbl, int n)
 static void nb_realloc_sci(nbnxn_pairlist_t *nbl, int n)
 {
     nbl->sci_nalloc = over_alloc_small(n);
-    nbnxn_realloc_void((void **)&nbl->sci,
+    nbnxn_realloc_void(reinterpret_cast<void **>(&nbl->sci),
                        nbl->nsci*sizeof(*nbl->sci),
                        nbl->sci_nalloc*sizeof(*nbl->sci),
                        nbl->alloc, nbl->free);
@@ -2863,7 +2863,7 @@ static void combine_nblists(int nnbl, nbnxn_pairlist_t **nbl,
     if (ncj4 > nblc->cj4_nalloc)
     {
         nblc->cj4_nalloc = over_alloc_small(ncj4);
-        nbnxn_realloc_void((void **)&nblc->cj4,
+        nbnxn_realloc_void(reinterpret_cast<void **>(&nblc->cj4),
                            nblc->ncj4*sizeof(*nblc->cj4),
                            nblc->cj4_nalloc*sizeof(*nblc->cj4),
                            nblc->alloc, nblc->free);
@@ -2871,7 +2871,7 @@ static void combine_nblists(int nnbl, nbnxn_pairlist_t **nbl,
     if (nexcl > nblc->excl_nalloc)
     {
         nblc->excl_nalloc = over_alloc_small(nexcl);
-        nbnxn_realloc_void((void **)&nblc->excl,
+        nbnxn_realloc_void(reinterpret_cast<void **>(&nblc->excl),
                            nblc->nexcl*sizeof(*nblc->excl),
                            nblc->excl_nalloc*sizeof(*nblc->excl),
                            nblc->alloc, nblc->free);
@@ -3329,7 +3329,7 @@ static void nbnxn_make_pairlist_part(const nbnxn_search *nbs,
     if (debug)
     {
         fprintf(debug, "nbl nc_i %d col.av. %.1f ci_block %d\n",
-                gridi->nc, gridi->nc/(double)(gridi->numCells[XX]*gridi->numCells[YY]), ci_block);
+                gridi->nc, gridi->nc/static_cast<double>(gridi->numCells[XX]*gridi->numCells[YY]), ci_block);
     }
 
     numDistanceChecks = 0;
@@ -3865,10 +3865,10 @@ static void print_reduction_cost(const nbnxn_buffer_flags_t *flags, int nout)
 
     fprintf(debug, "nbnxn reduction: #flag %d #list %d elem %4.2f, keep %4.2f copy %4.2f red %4.2f\n",
             flags->nflag, nout,
-            nelem/(double)(flags->nflag),
-            nkeep/(double)(flags->nflag),
-            ncopy/(double)(flags->nflag),
-            nred/(double)(flags->nflag));
+            nelem/static_cast<double>(flags->nflag),
+            nkeep/static_cast<double>(flags->nflag),
+            ncopy/static_cast<double>(flags->nflag),
+            nred/static_cast<double>(flags->nflag));
 }
 
 /* Copies the list entries from src to dest when cjStart <= *cjGlobal < cjEnd.
@@ -4074,7 +4074,7 @@ static void sort_sci(nbnxn_pairlist_t *nbl)
     if (work->sci_sort_nalloc != nbl->sci_nalloc)
     {
         work->sci_sort_nalloc = nbl->sci_nalloc;
-        nbnxn_realloc_void((void **)&work->sci_sort,
+        nbnxn_realloc_void(reinterpret_cast<void **>(&work->sci_sort),
                            0,
                            work->sci_sort_nalloc*sizeof(*work->sci_sort),
                            nbl->alloc, nbl->free);
index 2e0085a9588795149b93bb8937786267610d3eb7..46b51fd3570b984482ea62a554fcdd8efe2be289 100644 (file)
@@ -1923,7 +1923,7 @@ static int nsgrid_core(const t_commrec *cr,
                 /* Calculate range of cells in Y direction that have the shift ty */
                 if (bTriclinicY)
                 {
-                    ygi = (int)(Ny + (YI - grid_offset[YY])*grid_y) - Ny;
+                    ygi = static_cast<int>(Ny + (YI - grid_offset[YY])*grid_y) - Ny;
                 }
                 else
                 {
@@ -1941,7 +1941,7 @@ static int nsgrid_core(const t_commrec *cr,
                     /* Calculate range of cells in X direction that have the shift tx */
                     if (bTriclinicX)
                     {
-                        xgi = (int)(Nx + (XI - grid_offset[XX])*grid_x) - Nx;
+                        xgi = static_cast<int>(Nx + (XI - grid_offset[XX])*grid_x) - Nx;
                     }
                     else
                     {
@@ -2091,7 +2091,7 @@ void init_ns(FILE *fplog, const t_commrec *cr,
         const t_block *cgs = &molt.cgs;
         for (icg = 0; (icg < cgs->nr); icg++)
         {
-            nr_in_cg = std::max(nr_in_cg, (int)(cgs->index[icg+1]-cgs->index[icg]));
+            nr_in_cg = std::max(nr_in_cg, (cgs->index[icg+1]-cgs->index[icg]));
         }
     }
 
index 6f734c362c90a206359f947b84473bf3ed32100a..3c664b87a8e7d4e401f620646149e3081c940b17 100644 (file)
@@ -321,7 +321,7 @@ static void set_grid_sizes(matrix box, rvec izones_x0, rvec izones_x1, real rlis
              * we will use the normal grid ns that checks all cells
              * that are within cut-off distance of the i-particle.
              */
-            grid->n[i] = (int)(size*inv_r_ideal + 0.5);
+            grid->n[i] = static_cast<int>(size*inv_r_ideal + 0.5);
             if (grid->n[i] < 2)
             {
                 grid->n[i] = 2;
@@ -336,13 +336,13 @@ static void set_grid_sizes(matrix box, rvec izones_x0, rvec izones_x1, real rlis
              * We can then beforehand exclude certain ns grid cells
              * for non-home i-particles.
              */
-            grid->ncpddc[i] = (int)(izones_size[i]*inv_r_ideal + 0.5);
+            grid->ncpddc[i] = static_cast<int>(izones_size[i]*inv_r_ideal + 0.5);
             if (grid->ncpddc[i] < 2)
             {
                 grid->ncpddc[i] = 2;
             }
             grid->cell_size[i] = izones_size[i]/grid->ncpddc[i];
-            grid->n[i]         = grid->ncpddc[i] + (int)(radd/grid->cell_size[i]) + 1;
+            grid->n[i]         = grid->ncpddc[i] + static_cast<int>(radd/grid->cell_size[i]) + 1;
         }
         if (debug)
         {
index 1db60a41e678c494b203a3a5842c083f9aeb1e63..e6c97ebbec78a6feed8558e582f07abd3c6b75ab 100644 (file)
@@ -124,7 +124,7 @@ typedef struct {
 static int struct_comp(const void *a, const void *b)
 {
 
-    return (int)(((t_j_particle *)a)->j)-(int)(((t_j_particle *)b)->j);
+    return (((t_j_particle *)a)->j)-(((t_j_particle *)b)->j);
 
 } /* struct_comp */
 
@@ -692,13 +692,13 @@ void update_QMMMrec(const t_commrec  *cr,
 
 
             qsort(qm_i_particles, QMMMlist->nri,
-                  (size_t)sizeof(qm_i_particles[0]),
+                  static_cast<size_t>(sizeof(qm_i_particles[0])),
                   struct_comp);
             /* The mm_j_particles argument to qsort is not allowed to be NULL */
             if (mm_nr > 0)
             {
                 qsort(mm_j_particles, mm_nr,
-                      (size_t)sizeof(mm_j_particles[0]),
+                      static_cast<size_t>(sizeof(mm_j_particles[0])),
                       struct_comp);
             }
             /* remove multiples in the QM shift array, since in init_QMMM() we
index 53f8e09ec0b37f31e22e234be528924ceadb4e5d..ce2021eb70f09dbc502c5c2dba51b3bea08f349a 100644 (file)
@@ -222,7 +222,7 @@ init_replica_exchange(FILE                            *fplog,
     bTemp    = repl_quantity(ms, re, ereTEMP, re->temp);
     if (ir->efep != efepNO)
     {
-        bLambda = repl_quantity(ms, re, ereLAMBDA, (real)ir->fepvals->init_fep_state);
+        bLambda = repl_quantity(ms, re, ereLAMBDA, static_cast<real>(ir->fepvals->init_fep_state));
     }
     if (re->type == -1)  /* nothing was assigned */
     {
@@ -337,7 +337,7 @@ init_replica_exchange(FILE                            *fplog,
             fprintf(fplog, "\nReplica exchange in lambda\n");
             for (i = 0; i < re->nrepl; i++)
             {
-                fprintf(fplog, " %3d", (int)re->q[re->type][re->ind[i]]);
+                fprintf(fplog, " %3d", static_cast<int>(re->q[re->type][re->ind[i]]));
             }
             fprintf(fplog, "\n");
             break;
@@ -350,7 +350,7 @@ init_replica_exchange(FILE                            *fplog,
             fprintf(fplog, "\n");
             for (i = 0; i < re->nrepl; i++)
             {
-                fprintf(fplog, " %5d", (int)re->q[ereLAMBDA][re->ind[i]]);
+                fprintf(fplog, " %5d", static_cast<int>(re->q[ereLAMBDA][re->ind[i]]));
             }
             fprintf(fplog, "\n");
             break;
@@ -869,7 +869,7 @@ test_for_replica_exchange(FILE                 *fplog,
         }
         for (i = 0; i < re->nrepl; i++)
         {
-            re->de[i][re->repl] = (enerd->enerpart_lambda[(int)re->q[ereLAMBDA][i]+1]-enerd->enerpart_lambda[0]);
+            re->de[i][re->repl] = (enerd->enerpart_lambda[static_cast<int>(re->q[ereLAMBDA][i])+1]-enerd->enerpart_lambda[0]);
         }
     }
 
@@ -1333,7 +1333,7 @@ void print_replica_exchange_statistics(FILE *fplog, struct gmx_repl_ex *re)
             }
             else
             {
-                re->prob[i] =  ((real)re->nexchange[i])/re->nattempt[i%2];
+                re->prob[i] =  (static_cast<real>(re->nexchange[i]))/re->nattempt[i%2];
             }
         }
         print_ind(fplog, "", re->nrepl, re->ind, nullptr);
index 705a6bcbb5fdacba1f197fe604df4b8cbbeba808..94b72e6aa0ef27a4057308caa60ec3f4e4d73223 100644 (file)
@@ -253,7 +253,7 @@ void calc_rffac(FILE *fplog, int eel, real eps_r, real eps_rf, real Rc, real Tem
         else
         {
             k1   = 1 + kappa*Rc;
-            k2   = eps_rf*gmx::square((real)(kappa*Rc));
+            k2   = eps_rf*gmx::square(static_cast<real>(kappa*Rc));
 
             *krf = ((eps_rf - eps_r)*k1 + 0.5*k2)/((2*eps_rf + eps_r)*k1 + k2)/(Rc*Rc*Rc);
         }
index 232b06f648fe7037c204425d98bde5fd949d38f6..2f448ff4bc30ea7e510bc0edff8458d91c4718cb 100644 (file)
@@ -225,7 +225,7 @@ make_shake_sblock_serial(shakedata *shaked,
         fprintf(debug, "Going to sort constraints\n");
     }
 
-    qsort(sb, ncons, (size_t)sizeof(*sb), pcomp);
+    qsort(sb, ncons, sizeof(*sb), pcomp);
 
     if (debug)
     {
@@ -266,7 +266,7 @@ make_shake_sblock_serial(shakedata *shaked,
         }
         for (j = 0; (j <= shaked->nblocks); j++)
         {
-            fprintf(stderr, "sblock[%3d]=%5d\n", j, (int)shaked->sblock[j]);
+            fprintf(stderr, "sblock[%3d]=%5d\n", j, shaked->sblock[j]);
         }
         gmx_fatal(FARGS, "DEATH HORROR: "
                   "sblocks does not match idef->il[F_CONSTR]");
index ba88a2118ba16d9644fe18c4c93273c111a8f0b7..c2c5eb4c0d56d55e8efd252cfea9ceb080c80515 100644 (file)
@@ -849,7 +849,7 @@ static real rms_force(const t_commrec *cr, gmx::ArrayRef<const gmx::RVec> force,
         buf[2] = *sf_dir;
         buf[3] = *Epot;
         gmx_sumd(4, buf, cr);
-        ntot    = (int)(buf[1] + 0.5);
+        ntot    = static_cast<int>(buf[1] + 0.5);
         *sf_dir = buf[2];
         *Epot   = buf[3];
     }
index 914bbe98cf56ac44e191091849e0024dcb75c99f..a9427de077e2aedd2b7af9a6ec27c196ef0ec1b1 100644 (file)
@@ -155,7 +155,7 @@ void signal_handler_install(void)
 
 gmx_stop_cond_t gmx_get_stop_condition(void)
 {
-    return (gmx_stop_cond_t)stop_condition;
+    return static_cast<gmx_stop_cond_t>(stop_condition);
 }
 
 void gmx_set_stop_condition(gmx_stop_cond_t recvd_stop_cond)
index 9cfc324715f4728442454c5445af36227e96453b..682d342794e753ca1d452b675bdda601fa75b426 100644 (file)
@@ -155,7 +155,7 @@ void print_time(FILE                     *out,
         {
             if (dt >= 300)
             {
-                finish = (time_t) (seconds_since_epoch + dt);
+                finish = static_cast<time_t>(seconds_since_epoch + dt);
                 gmx_ctime_r(&finish, timebuf, STRLEN);
                 sprintf(buf, "%s", timebuf);
                 buf[strlen(buf)-1] = '\0';
@@ -163,7 +163,7 @@ void print_time(FILE                     *out,
             }
             else
             {
-                fprintf(out, ", remaining wall clock time: %5d s          ", (int)dt);
+                fprintf(out, ", remaining wall clock time: %5d s          ", static_cast<int>(dt));
             }
         }
         else
@@ -197,7 +197,7 @@ void print_date_and_time(FILE *fplog, int nodeid, const char *title,
     {
         int    i;
         char   timebuf[STRLEN];
-        time_t temp_time = (time_t) the_time;
+        time_t temp_time = static_cast<time_t>(the_time);
 
         gmx_ctime_r(&temp_time, timebuf, STRLEN);
         for (i = 0; timebuf[i] >= ' '; i++)
@@ -2415,13 +2415,13 @@ void calc_enervirdiff(FILE *fplog, int eDispCorr, t_forcerec *fr)
                  * Table has a scale factor since we have scaled it down to compensate
                  * for scaling-up c6/c12 with the derivative factors to save flops in analytical kernels.
                  */
-                fr->enershiftsix    = (real)(-1.0/(rc3*rc3)) - 6.0*vdwtab[8*ri0];
-                fr->enershifttwelve = (real)( 1.0/(rc9*rc3)) - 12.0*vdwtab[8*ri0 + 4];
+                fr->enershiftsix    = static_cast<real>(-1.0/(rc3*rc3)) - 6.0*vdwtab[8*ri0];
+                fr->enershifttwelve = static_cast<real>( 1.0/(rc9*rc3)) - 12.0*vdwtab[8*ri0 + 4];
             }
             else if (ic->vdw_modifier == eintmodPOTSHIFT)
             {
-                fr->enershiftsix    = (real)(-1.0/(rc3*rc3));
-                fr->enershifttwelve = (real)( 1.0/(rc9*rc3));
+                fr->enershiftsix    = static_cast<real>(-1.0/(rc3*rc3));
+                fr->enershifttwelve = static_cast<real>( 1.0/(rc9*rc3));
             }
 
             /* Add the constant part from 0 to rvdw_switch.
index a96a616a792d848f20b37ef500a2959672502670..f7ebf89795f85ca4067b0183f7690cfa0b7b190c 100644 (file)
@@ -1344,7 +1344,7 @@ void gmx::Integrator::do_md()
         elapsed_time = walltime_accounting_get_current_elapsed_time(walltime_accounting);
 
         /* Check whether everything is still allright */
-        if (((int)gmx_get_stop_condition() > handled_stop_condition)
+        if ((static_cast<int>(gmx_get_stop_condition()) > handled_stop_condition)
 #if GMX_THREAD_MPI
             && MASTER(cr)
 #endif
@@ -1385,7 +1385,7 @@ void gmx::Integrator::do_md()
                     "\n\nReceived the %s signal, stopping within %d steps\n\n",
                     gmx_get_signal_name(), nsteps_stop);
             fflush(stderr);
-            handled_stop_condition = (int)gmx_get_stop_condition();
+            handled_stop_condition = static_cast<int>(gmx_get_stop_condition());
         }
         else if (MASTER(cr) && (bNS || ir->nstlist <= 0) &&
                  (max_hours > 0 && elapsed_time > max_hours*60.0*60.0*0.99) &&
index 6ce3ec0e3494550a9682f8a6517d1cab92124844..45c35a0c6b4ef123397a214deebe500768cd07c1 100644 (file)
@@ -312,7 +312,7 @@ static void get_f_norm_max(const t_commrec *cr,
             if (sum[2*i] > fmax2)
             {
                 fmax2 = sum[2*i];
-                a_max = (int)(sum[2*i+1] + 0.5);
+                a_max = static_cast<int>(sum[2*i+1] + 0.5);
             }
         }
         sfree(sum);
@@ -549,7 +549,7 @@ static void write_em_traj(FILE *fplog, const t_commrec *cr,
     }
 
     mdoutf_write_to_trajectory_files(fplog, cr, outf, mdof_flags,
-                                     top_global, step, (double)step,
+                                     top_global, step, static_cast<double>(step),
                                      &state->s, state_global, observablesHistory,
                                      state->f);
 
@@ -1139,7 +1139,7 @@ Integrator::do_cg()
     if (MASTER(cr))
     {
         /* Copy stuff to the energy bin for easy printing etc. */
-        upd_mdebin(mdebin, FALSE, FALSE, (double)step,
+        upd_mdebin(mdebin, FALSE, FALSE, static_cast<double>(step),
                    mdatoms->tmass, enerd, &s_min->s, inputrec->fepvals, inputrec->expandedvals, s_min->s.box,
                    nullptr, nullptr, vir, pres, nullptr, mu_tot, constr);
 
@@ -1561,7 +1561,7 @@ Integrator::do_cg()
                 fflush(stderr);
             }
             /* Store the new (lower) energies */
-            upd_mdebin(mdebin, FALSE, FALSE, (double)step,
+            upd_mdebin(mdebin, FALSE, FALSE, static_cast<double>(step),
                        mdatoms->tmass, enerd, &s_min->s, inputrec->fepvals, inputrec->expandedvals, s_min->s.box,
                        nullptr, nullptr, vir, pres, nullptr, mu_tot, constr);
 
@@ -1804,7 +1804,7 @@ Integrator::do_lbfgs()
     if (MASTER(cr))
     {
         /* Copy stuff to the energy bin for easy printing etc. */
-        upd_mdebin(mdebin, FALSE, FALSE, (double)step,
+        upd_mdebin(mdebin, FALSE, FALSE, static_cast<double>(step),
                    mdatoms->tmass, enerd, state_global, inputrec->fepvals, inputrec->expandedvals, state_global->box,
                    nullptr, nullptr, vir, pres, nullptr, mu_tot, constr);
 
@@ -1889,7 +1889,7 @@ Integrator::do_lbfgs()
         }
 
         mdoutf_write_to_trajectory_files(fplog, cr, outf, mdof_flags,
-                                         top_global, step, (real)step, &ems.s, state_global, observablesHistory, ems.f);
+                                         top_global, step, static_cast<real>(step), &ems.s, state_global, observablesHistory, ems.f);
 
         /* Do the linesearching in the direction dx[point][0..(n-1)] */
 
@@ -2290,7 +2290,7 @@ Integrator::do_lbfgs()
                 fflush(stderr);
             }
             /* Store the new (lower) energies */
-            upd_mdebin(mdebin, FALSE, FALSE, (double)step,
+            upd_mdebin(mdebin, FALSE, FALSE, static_cast<double>(step),
                        mdatoms->tmass, enerd, state_global, inputrec->fepvals, inputrec->expandedvals, state_global->box,
                        nullptr, nullptr, vir, pres, nullptr, mu_tot, constr);
             do_log = do_per_step(step, inputrec->nstlog);
@@ -2506,7 +2506,7 @@ Integrator::do_steep()
             if ( (count == 0) || (s_try->epot < s_min->epot) )
             {
                 /* Store the new (lower) energies  */
-                upd_mdebin(mdebin, FALSE, FALSE, (double)count,
+                upd_mdebin(mdebin, FALSE, FALSE, static_cast<double>(count),
                            mdatoms->tmass, enerd, &s_try->s, inputrec->fepvals, inputrec->expandedvals,
                            s_try->s.box, nullptr, nullptr, vir, pres, nullptr, mu_tot, constr);
 
@@ -2729,8 +2729,8 @@ Integrator::do_nm()
 
     if (bIsMaster)
     {
-        fprintf(stderr, "starting normal mode calculation '%s'\n%d steps.\n\n",
-                *(top_global->name), (int)inputrec->nsteps);
+        fprintf(stderr, "starting normal mode calculation '%s'\n%" PRId64 " steps.\n\n",
+                *(top_global->name), inputrec->nsteps);
     }
 
     nnodes = cr->nnodes;
index 2af472700861fd301538f8dc27b7ae56f81b9085..495c89d21f10e02f1f19b627176ef8f9a611d342 100644 (file)
@@ -1398,7 +1398,7 @@ int Mdrunner::mdrunner()
         gmx_fedisableexcept();
     }
 
-    rc = (int)gmx_get_stop_condition();
+    rc = static_cast<int>(gmx_get_stop_condition());
 
 #if GMX_THREAD_MPI
     /* we need to join all threads. The sub-threads join when they
index 15eec2be09de00489e940dc23db2c3dc3c4fde07..4414c8ef295fc8c19106d4f7790fbf99637fea6f 100644 (file)
@@ -316,8 +316,8 @@ Integrator::do_tpi()
         fprintf(fplog, "\nWill insert %d atoms %s partial charges\n",
                 a_tp1-a_tp0, bCharge ? "with" : "without");
 
-        fprintf(fplog, "\nWill insert %d times in each frame of %s\n",
-                (int)nsteps, opt2fn("-rerun", nfile, fnm));
+        fprintf(fplog, "\nWill insert %" PRId64 " times in each frame of %s\n",
+                nsteps, opt2fn("-rerun", nfile, fnm));
     }
 
     if (!bCavity)
@@ -679,7 +679,7 @@ Integrator::do_tpi()
             {
                 if (debug)
                 {
-                    fprintf(debug, "\n  time %.3f, step %d: non-finite energy %f, using exp(-bU)=0\n", t, (int)step, epot);
+                    fprintf(debug, "\n  time %.3f, step %d: non-finite energy %f, using exp(-bU)=0\n", t, static_cast<int>(step), epot);
                 }
                 embU = 0;
             }
@@ -734,9 +734,9 @@ Integrator::do_tpi()
             }
             else
             {
-                i = (int)((bU_logV_bin_limit
-                           - (beta*epot - logV + refvolshift))*invbinw
-                          + 0.5);
+                i = static_cast<int>((bU_logV_bin_limit
+                                      - (beta*epot - logV + refvolshift))*invbinw
+                                     + 0.5);
                 if (i < 0)
                 {
                     i = 0;
@@ -751,13 +751,13 @@ Integrator::do_tpi()
             if (debug)
             {
                 fprintf(debug, "TPI %7d %12.5e %12.5f %12.5f %12.5f\n",
-                        (int)step, epot, x_tp[XX], x_tp[YY], x_tp[ZZ]);
+                        static_cast<int>(step), epot, x_tp[XX], x_tp[YY], x_tp[ZZ]);
             }
 
             if (dump_pdb && epot <= dump_ener)
             {
-                sprintf(str, "t%g_step%d.pdb", t, (int)step);
-                sprintf(str2, "t: %f step %d ener: %f", t, (int)step, epot);
+                sprintf(str, "t%g_step%d.pdb", t, static_cast<int>(step));
+                sprintf(str2, "t: %f step %d ener: %f", t, static_cast<int>(step), epot);
                 write_sto_conf_mtop(str, str2, top_global, as_rvec_array(state_global->x.data()), as_rvec_array(state_global->v.data()),
                                     inputrec->ePBC, state_global->box);
             }
@@ -848,7 +848,7 @@ Integrator::do_tpi()
             bUlogV = -i/invbinw + bU_logV_bin_limit - refvolshift + log(V_all/frame);
             fprintf(fp_tpi, "%6.2f %10d %12.5e\n",
                     bUlogV,
-                    (int)(bin[i]+0.5),
+                    static_cast<int>(bin[i]+0.5),
                     bin[i]*exp(-bUlogV)*V_all/VembU_all);
         }
         xvgrclose(fp_tpi);
index d4930fab39a94f8b09dba3d0687e0062667cb4fb..8ca68dfafa6ce2dc347fc0365359d746a7f8db7e 100644 (file)
@@ -159,7 +159,7 @@ int ir_optimal_nsttcouple(const t_inputrec *ir)
     }
     else
     {
-        n = (int)(tau_min/(ir->delta_t*nmin) + 0.001);
+        n = static_cast<int>(tau_min/(ir->delta_t*nmin) + 0.001);
         if (n < 1)
         {
             n = 1;
index 0ee0cd04793d114422ee74befc63194b94e419dd..d7905596b1410095470e17b6603c010f5878261f 100644 (file)
@@ -810,7 +810,7 @@ void mk_mshift(FILE *log, t_graph *g, int ePBC,
         g->negc = nnodes;
         srenew(g->egc, g->negc);
     }
-    memset(g->egc, 0, (size_t)(nnodes*sizeof(g->egc[0])));
+    memset(g->egc, 0, static_cast<size_t>(nnodes*sizeof(g->egc[0])));
 
     nW = g->nbound;
     nG = 0;
index 1febabd34b4b6141f77810a4fd093b2dbecf7acb..d199752d9060bf0e735cc6325890d66e629e3e9b 100644 (file)
@@ -1525,7 +1525,7 @@ static real opt_angle_analytic(
     }
     sfree(eigvec);
 
-    return (real) opt_angle;
+    return static_cast<real>(opt_angle);
 }
 
 
index 05a5d3853758ecd80cb6d804cf0d58098e7b2e7a..79a1d1d02081fa0fdafaa70ca8873cf96fa2f46e 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2009,2010,2011,2012,2013,2014,2015,2016,2017, by the GROMACS development team, led by
+ * Copyright (c) 2009,2010,2011,2012,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.
@@ -354,7 +354,7 @@ _gmx_sel_print_evalfunc_name(FILE *fp, gmx::sel_evalfunc evalfunc)
     }
     else
     {
-        fprintf(fp, "%p", (void*)(evalfunc));
+        fprintf(fp, "%p", reinterpret_cast<void*>(evalfunc));
     }
 }
 
index 20134991fbabc69235c14757557ebd8b9f1e9a8d..aebe432598b2679a264f7cf3e692909cde581c82 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2010,2011,2012,2014,2017, by the GROMACS development team, led by
+ * Copyright (c) 2010,2011,2012,2014,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.
@@ -186,7 +186,7 @@ _gmx_sel_mempool_free(gmx_sel_mempool_t *mp, void *ptr)
     mp->currsize -= size;
     if (mp->buffer)
     {
-        mp->freeptr   = (char *)ptr;
+        mp->freeptr   = static_cast<char *>(ptr);
         mp->freesize += size;
     }
     else
@@ -205,7 +205,7 @@ _gmx_sel_mempool_reserve(gmx_sel_mempool_t *mp, size_t size)
     {
         size = mp->maxsize;
     }
-    mp->buffer = (char *)malloc(size);
+    mp->buffer = static_cast<char *>(malloc(size));
     if (!mp->buffer)
     {
         throw std::bad_alloc();
index 9ec275098983a6612430b2706fc5e14b84e9fd4b..e9f8b49960c79aa86cfba661a3f6f9783fb9f0ed 100644 (file)
@@ -1214,5 +1214,5 @@ bool
 _gmx_sel_parser_should_finish(yyscan_t scanner)
 {
     gmx_ana_selcollection_t *sc = _gmx_sel_lexer_selcollection(scanner);
-    return (int)sc->sel.size() == _gmx_sel_lexer_exp_selcount(scanner);
+    return static_cast<int>(sc->sel.size()) == _gmx_sel_lexer_exp_selcount(scanner);
 }
index 84263f84f0a0a0a4ca703cf454f7cf455135f874..7df2342792f65687f1afdeed8c9fd552a6ab9ebe 100644 (file)
@@ -230,7 +230,7 @@ comparison_type_str(e_comparison_t cmpt)
 void
 _gmx_selelem_print_compare_info(FILE *fp, void *data)
 {
-    t_methoddata_compare *d = (t_methoddata_compare *)data;
+    t_methoddata_compare *d = static_cast<t_methoddata_compare *>(data);
 
     fprintf(fp, " \"");
     /* Print the left value */
@@ -352,7 +352,7 @@ convert_int_real(int n, t_compare_value *val)
     snew(rv, n);
     for (i = 0; i < n; ++i)
     {
-        rv[i] = (real)val->i[i];
+        rv[i] = static_cast<real>(val->i[i]);
     }
     /* Free the previous value if one is present. */
     sfree(val->r);
@@ -419,7 +419,7 @@ convert_real_int(int n, t_compare_value *val, e_comparison_t cmpt, bool bRight)
 static void
 init_compare(const gmx_mtop_t * /* top */, int /* npar */, gmx_ana_selparam_t *param, void *data)
 {
-    t_methoddata_compare *d = (t_methoddata_compare *)data;
+    t_methoddata_compare *d = static_cast<t_methoddata_compare *>(data);
     int                   n1, n2;
 
     /* Store the values */
@@ -486,7 +486,7 @@ init_compare(const gmx_mtop_t * /* top */, int /* npar */, gmx_ana_selparam_t *p
 static void
 free_data_compare(void *data)
 {
-    t_methoddata_compare *d = (t_methoddata_compare *)data;
+    t_methoddata_compare *d = static_cast<t_methoddata_compare *>(data);
 
     sfree(d->cmpop);
     if (d->left.flags & CMP_ALLOCINT)
@@ -518,7 +518,7 @@ free_data_compare(void *data)
 static void
 evaluate_compare_int(gmx_ana_index_t *g, gmx_ana_selvalue_t *out, void *data)
 {
-    t_methoddata_compare *d = (t_methoddata_compare *)data;
+    t_methoddata_compare *d = static_cast<t_methoddata_compare *>(data);
     int                   i, i1, i2, ig;
     int                   a, b;
     bool                  bAccept;
@@ -567,7 +567,7 @@ evaluate_compare_int(gmx_ana_index_t *g, gmx_ana_selvalue_t *out, void *data)
 static void
 evaluate_compare_real(gmx_ana_index_t *g, gmx_ana_selvalue_t *out, void *data)
 {
-    t_methoddata_compare *d = (t_methoddata_compare *)data;
+    t_methoddata_compare *d = static_cast<t_methoddata_compare *>(data);
     int                   i, i1, i2, ig;
     real                  a, b;
     bool                  bAccept;
@@ -607,7 +607,7 @@ static void
 evaluate_compare(const gmx::SelMethodEvalContext & /*context*/,
                  gmx_ana_index_t *g, gmx_ana_selvalue_t *out, void *data)
 {
-    t_methoddata_compare *d = (t_methoddata_compare *)data;
+    t_methoddata_compare *d = static_cast<t_methoddata_compare *>(data);
 
     if (!((d->left.flags | d->right.flags) & CMP_REALVAL))
     {
index e6835adeed2ea995aaf86879296596ca20b8eb7d..3e3890a4119c21c83f4ff8b722ca0f3cc8c9c66d 100644 (file)
@@ -405,7 +405,7 @@ init_data_insolidangle(int /* npar */, gmx_ana_selparam_t *param)
 static void
 init_insolidangle(const gmx_mtop_t * /* top */, int /* npar */, gmx_ana_selparam_t * /* param */, void *data)
 {
-    t_methoddata_insolidangle *surf = (t_methoddata_insolidangle *)data;
+    t_methoddata_insolidangle *surf = static_cast<t_methoddata_insolidangle *>(data);
     int                        i, c;
 
     if (surf->angcut <= 0)
@@ -444,7 +444,7 @@ init_insolidangle(const gmx_mtop_t * /* top */, int /* npar */, gmx_ana_selparam
 static void
 free_data_insolidangle(void *data)
 {
-    t_methoddata_insolidangle *d = (t_methoddata_insolidangle *)data;
+    t_methoddata_insolidangle *d = static_cast<t_methoddata_insolidangle *>(data);
     int                        i;
 
     if (d->tbin)
@@ -463,7 +463,7 @@ free_data_insolidangle(void *data)
 static void
 init_frame_insolidangle(const gmx::SelMethodEvalContext &context, void *data)
 {
-    t_methoddata_insolidangle *d = (t_methoddata_insolidangle *)data;
+    t_methoddata_insolidangle *d = static_cast<t_methoddata_insolidangle *>(data);
     rvec                       dx;
     int                        i;
 
@@ -495,7 +495,7 @@ init_frame_insolidangle(const gmx::SelMethodEvalContext &context, void *data)
 static bool
 accept_insolidangle(rvec x, const t_pbc *pbc, void *data)
 {
-    t_methoddata_insolidangle *d = (t_methoddata_insolidangle *)data;
+    t_methoddata_insolidangle *d = static_cast<t_methoddata_insolidangle *>(data);
     rvec                       dx;
 
     if (pbc)
@@ -594,7 +594,7 @@ _gmx_selelem_estimate_coverfrac(const gmx::SelectionTreeElement &sel)
 
     if (sel.type == SEL_EXPRESSION && sel.u.expr.method->name == sm_insolidangle.name)
     {
-        t_methoddata_insolidangle *d = (t_methoddata_insolidangle *)sel.u.expr.mdata;
+        t_methoddata_insolidangle *d = static_cast<t_methoddata_insolidangle *>(sel.u.expr.mdata);
         if (d->cfrac < 0)
         {
             d->cfrac = estimate_covered_fraction(d);
index 3e020fb4bc7440b2f07caa5a29aeabfed47e57ef..6609900c67b6e43c883103151c0f79f99149fc79 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2009,2010,2011,2012,2013,2014,2015,2016,2017, by the GROMACS development team, led by
+ * Copyright (c) 2009,2010,2011,2012,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.
@@ -443,7 +443,7 @@ init_data_kwint(int  /* npar */, gmx_ana_selparam_t * /* param */)
 static void
 init_kwint(const gmx_mtop_t * /* top */, int /* npar */, gmx_ana_selparam_t *param, void *data)
 {
-    t_methoddata_kwint *d = (t_methoddata_kwint *)data;
+    t_methoddata_kwint *d = static_cast<t_methoddata_kwint *>(data);
 
     d->v = param[0].val.u.i;
     d->n = param[1].val.nr;
@@ -462,7 +462,7 @@ static void
 evaluate_keyword_int(const gmx::SelMethodEvalContext & /*context*/,
                      gmx_ana_index_t *g, gmx_ana_selvalue_t *out, void *data)
 {
-    t_methoddata_kwint *d = (t_methoddata_kwint *)data;
+    t_methoddata_kwint *d = static_cast<t_methoddata_kwint *>(data);
     int                 n, i, j, jmin, jmax;
     int                 val;
 
@@ -518,7 +518,7 @@ init_data_kwreal(int /* npar */, gmx_ana_selparam_t * /* param */)
 static void
 init_kwreal(const gmx_mtop_t * /* top */, int /* npar */, gmx_ana_selparam_t *param, void *data)
 {
-    t_methoddata_kwreal *d = (t_methoddata_kwreal *)data;
+    t_methoddata_kwreal *d = static_cast<t_methoddata_kwreal *>(data);
 
     d->v = param[0].val.u.r;
     d->n = param[1].val.nr;
@@ -537,7 +537,7 @@ static void
 evaluate_keyword_real(const gmx::SelMethodEvalContext & /*context*/,
                       gmx_ana_index_t *g, gmx_ana_selvalue_t *out, void *data)
 {
-    t_methoddata_kwreal *d = (t_methoddata_kwreal *)data;
+    t_methoddata_kwreal *d = static_cast<t_methoddata_kwreal *>(data);
     int                  n, i, j, jmin, jmax;
     real                 val;
 
index 4066c5d931a08a04790f0000cd22b7afd546a927..26298901c1eca62048d78bb5d000afd1ef3a899f 100644 (file)
@@ -200,7 +200,7 @@ init_data_merge(int npar, gmx_ana_selparam_t *param)
 static void
 init_merge(const gmx_mtop_t * /* top */, int /* npar */, gmx_ana_selparam_t * /* param */, void *data)
 {
-    t_methoddata_merge *d = (t_methoddata_merge *)data;
+    t_methoddata_merge *d = static_cast<t_methoddata_merge *>(data);
 
     if (d->stride < 0)
     {
@@ -227,7 +227,7 @@ init_merge(const gmx_mtop_t * /* top */, int /* npar */, gmx_ana_selparam_t * /*
 static void
 init_output_common(const gmx_mtop_t *top, gmx_ana_selvalue_t *out, void *data)
 {
-    t_methoddata_merge *d = (t_methoddata_merge *)data;
+    t_methoddata_merge *d = static_cast<t_methoddata_merge *>(data);
 
     GMX_UNUSED_VALUE(top);
     if (d->p1.m.type != d->p2.m.type)
@@ -253,7 +253,7 @@ init_output_common(const gmx_mtop_t *top, gmx_ana_selvalue_t *out, void *data)
 static void
 init_output_merge(const gmx_mtop_t *top, gmx_ana_selvalue_t *out, void *data)
 {
-    t_methoddata_merge *d = (t_methoddata_merge *)data;
+    t_methoddata_merge *d = static_cast<t_methoddata_merge *>(data);
     int                 i, j;
 
     init_output_common(top, out, data);
@@ -275,7 +275,7 @@ init_output_merge(const gmx_mtop_t *top, gmx_ana_selvalue_t *out, void *data)
 static void
 init_output_plus(const gmx_mtop_t *top, gmx_ana_selvalue_t *out, void *data)
 {
-    t_methoddata_merge *d = (t_methoddata_merge *)data;
+    t_methoddata_merge *d = static_cast<t_methoddata_merge *>(data);
     int                 i;
 
     init_output_common(top, out, data);
@@ -297,7 +297,7 @@ init_output_plus(const gmx_mtop_t *top, gmx_ana_selvalue_t *out, void *data)
 static void
 free_data_merge(void *data)
 {
-    t_methoddata_merge *d = (t_methoddata_merge *)data;
+    t_methoddata_merge *d = static_cast<t_methoddata_merge *>(data);
     delete d;
 }
 
@@ -305,7 +305,7 @@ static void
 evaluate_merge(const gmx::SelMethodEvalContext & /*context*/,
                gmx_ana_pos_t * /* p */, gmx_ana_selvalue_t *out, void *data)
 {
-    t_methoddata_merge *d = (t_methoddata_merge *)data;
+    t_methoddata_merge *d = static_cast<t_methoddata_merge *>(data);
     int                 i, j;
     int                 refid;
 
@@ -335,7 +335,7 @@ static void
 evaluate_plus(const gmx::SelMethodEvalContext & /*context*/,
               gmx_ana_pos_t * /* p */, gmx_ana_selvalue_t *out, void *data)
 {
-    t_methoddata_merge *d = (t_methoddata_merge *)data;
+    t_methoddata_merge *d = static_cast<t_methoddata_merge *>(data);
     int                 i;
     int                 refid;
 
index e4b8b51510b0d01043c023ab3e47ae359b8a4da4..0b942e54451e6da51f57129047bab2b3711185e3 100644 (file)
@@ -171,7 +171,7 @@ init_data_permute(int /* npar */, gmx_ana_selparam_t *param)
 static void
 init_permute(const gmx_mtop_t * /* top */, int /* npar */, gmx_ana_selparam_t *param, void *data)
 {
-    t_methoddata_permute *d = (t_methoddata_permute *)data;
+    t_methoddata_permute *d = static_cast<t_methoddata_permute *>(data);
     int                   i;
 
     d->n    = param[1].val.nr;
@@ -204,7 +204,7 @@ init_permute(const gmx_mtop_t * /* top */, int /* npar */, gmx_ana_selparam_t *p
 static void
 init_output_permute(const gmx_mtop_t * /* top */, gmx_ana_selvalue_t *out, void *data)
 {
-    t_methoddata_permute *d = (t_methoddata_permute *)data;
+    t_methoddata_permute *d = static_cast<t_methoddata_permute *>(data);
     int                   i, j, b;
 
     out->u.p->m.type = d->p.m.type;
@@ -229,7 +229,7 @@ init_output_permute(const gmx_mtop_t * /* top */, gmx_ana_selvalue_t *out, void
 static void
 free_data_permute(void *data)
 {
-    t_methoddata_permute *d = (t_methoddata_permute *)data;
+    t_methoddata_permute *d = static_cast<t_methoddata_permute *>(data);
 
     sfree(d->rperm);
     delete d;
@@ -239,7 +239,7 @@ static void
 evaluate_permute(const gmx::SelMethodEvalContext & /*context*/,
                  gmx_ana_pos_t * /*p*/, gmx_ana_selvalue_t *out, void *data)
 {
-    t_methoddata_permute *d = (t_methoddata_permute *)data;
+    t_methoddata_permute *d = static_cast<t_methoddata_permute *>(data);
     int                   i, j, b;
     int                   refid;
 
index ad0b2c1a8d095853f75416a3c2d2fa9de97a7353..e78d79b5421e36a0d7aa2c74439a1cd1f0b5bb04 100644 (file)
@@ -224,7 +224,7 @@ init_data_pos(int npar, gmx_ana_selparam_t *param)
 static void
 set_poscoll_pos(gmx::PositionCalculationCollection *pcc, void *data)
 {
-    ((t_methoddata_pos *)data)->pcc = pcc;
+    (static_cast<t_methoddata_pos *>(data))->pcc = pcc;
 }
 
 bool
@@ -276,7 +276,7 @@ static void set_pos_method_flags(gmx_ana_selmethod_t *method,
 void
 _gmx_selelem_set_kwpos_type(gmx::SelectionTreeElement *sel, const char *type)
 {
-    t_methoddata_pos *d = (t_methoddata_pos *)sel->u.expr.mdata;
+    t_methoddata_pos *d = static_cast<t_methoddata_pos *>(sel->u.expr.mdata);
 
     if (sel->type != SEL_EXPRESSION || !sel->u.expr.method
         || sel->u.expr.method->name != sm_keyword_pos.name)
@@ -302,7 +302,7 @@ _gmx_selelem_set_kwpos_type(gmx::SelectionTreeElement *sel, const char *type)
 void
 _gmx_selelem_set_kwpos_flags(gmx::SelectionTreeElement *sel, int flags)
 {
-    t_methoddata_pos *d = (t_methoddata_pos *)sel->u.expr.mdata;
+    t_methoddata_pos *d = static_cast<t_methoddata_pos *>(sel->u.expr.mdata);
 
     if (sel->type != SEL_EXPRESSION || !sel->u.expr.method
         || sel->u.expr.method->name != sm_keyword_pos.name)
@@ -321,7 +321,7 @@ _gmx_selelem_set_kwpos_flags(gmx::SelectionTreeElement *sel, int flags)
 static void
 init_kwpos(const gmx_mtop_t * /* top */, int /* npar */, gmx_ana_selparam_t *param, void *data)
 {
-    t_methoddata_pos *d = (t_methoddata_pos *)data;
+    t_methoddata_pos *d = static_cast<t_methoddata_pos *>(data);
 
     if (!(param[0].flags & SPAR_DYNAMIC))
     {
@@ -338,7 +338,7 @@ init_kwpos(const gmx_mtop_t * /* top */, int /* npar */, gmx_ana_selparam_t *par
 static void
 init_cog(const gmx_mtop_t * /* top */, int /* npar */, gmx_ana_selparam_t *param, void *data)
 {
-    t_methoddata_pos *d = (t_methoddata_pos *)data;
+    t_methoddata_pos *d = static_cast<t_methoddata_pos *>(data);
 
     d->flags = (param[0].flags & SPAR_DYNAMIC) ? POS_DYNAMIC : 0;
     d->pc    = d->pcc->createCalculation(d->bPBC ? POS_ALL_PBC : POS_ALL, d->flags);
@@ -348,7 +348,7 @@ init_cog(const gmx_mtop_t * /* top */, int /* npar */, gmx_ana_selparam_t *param
 static void
 init_com(const gmx_mtop_t * /* top */, int /* npar */, gmx_ana_selparam_t *param, void *data)
 {
-    t_methoddata_pos *d = (t_methoddata_pos *)data;
+    t_methoddata_pos *d = static_cast<t_methoddata_pos *>(data);
 
     d->flags  = (param[0].flags & SPAR_DYNAMIC) ? POS_DYNAMIC : 0;
     d->flags |= POS_MASS;
@@ -359,7 +359,7 @@ init_com(const gmx_mtop_t * /* top */, int /* npar */, gmx_ana_selparam_t *param
 static void
 init_output_pos(const gmx_mtop_t * /* top */, gmx_ana_selvalue_t *out, void *data)
 {
-    t_methoddata_pos *d = (t_methoddata_pos *)data;
+    t_methoddata_pos *d = static_cast<t_methoddata_pos *>(data);
 
     gmx_ana_poscalc_init_pos(d->pc, out->u.p);
 }
@@ -373,7 +373,7 @@ init_output_pos(const gmx_mtop_t * /* top */, gmx_ana_selvalue_t *out, void *dat
 static void
 free_data_pos(void *data)
 {
-    t_methoddata_pos *d = (t_methoddata_pos *)data;
+    t_methoddata_pos *d = static_cast<t_methoddata_pos *>(data);
 
     sfree(d->type);
     gmx_ana_poscalc_free(d->pc);
@@ -391,7 +391,7 @@ static void
 evaluate_pos(const gmx::SelMethodEvalContext &context,
              gmx_ana_index_t * /* g */, gmx_ana_selvalue_t *out, void *data)
 {
-    t_methoddata_pos *d = (t_methoddata_pos *)data;
+    t_methoddata_pos *d = static_cast<t_methoddata_pos *>(data);
 
     gmx_ana_poscalc_update(d->pc, out->u.p, &d->g, context.fr, context.pbc);
 }
index 58210bd73675b1e51b01866185a19f94d0e767ac..b98a8e0bfb6a3687e57f89140b88e81fb89374b3 100644 (file)
@@ -284,7 +284,7 @@ _gmx_selelem_custom_init_same(gmx_ana_selmethod_t                           **me
 static void
 init_same(const gmx_mtop_t * /* top */, int /* npar */, gmx_ana_selparam_t *param, void *data)
 {
-    t_methoddata_same *d = (t_methoddata_same *)data;
+    t_methoddata_same *d = static_cast<t_methoddata_same *>(data);
 
     d->val.ptr = param[0].val.u.ptr;
     d->as.ptr  = param[1].val.u.ptr;
@@ -306,7 +306,7 @@ init_same(const gmx_mtop_t * /* top */, int /* npar */, gmx_ana_selparam_t *para
 static void
 free_data_same(void *data)
 {
-    t_methoddata_same *d = (t_methoddata_same *)data;
+    t_methoddata_same *d = static_cast<t_methoddata_same *>(data);
 
     sfree(d->as_s_sorted);
     sfree(d);
@@ -332,7 +332,7 @@ cmp_int(const void *a, const void *b)
 static void
 init_frame_same_int(const gmx::SelMethodEvalContext & /*context*/, void *data)
 {
-    t_methoddata_same *d = (t_methoddata_same *)data;
+    t_methoddata_same *d = static_cast<t_methoddata_same *>(data);
     int                i, j;
 
     /* Collapse adjacent values, and check whether the array is sorted. */
@@ -385,7 +385,7 @@ static void
 evaluate_same_int(const gmx::SelMethodEvalContext & /*context*/,
                   gmx_ana_index_t *g, gmx_ana_selvalue_t *out, void *data)
 {
-    t_methoddata_same     *d = (t_methoddata_same *)data;
+    t_methoddata_same     *d = static_cast<t_methoddata_same *>(data);
     int                    i, j;
 
     out->u.g->isize = 0;
@@ -454,13 +454,13 @@ evaluate_same_int(const gmx::SelMethodEvalContext & /*context*/,
 static int
 cmp_str(const void *a, const void *b)
 {
-    return strcmp(*(char **)a, *(char **)b);
+    return strcmp(*static_cast<char *const*>(a), *static_cast<char *const*>(b));
 }
 
 static void
 init_frame_same_str(const gmx::SelMethodEvalContext & /*context*/, void *data)
 {
-    t_methoddata_same *d = (t_methoddata_same *)data;
+    t_methoddata_same *d = static_cast<t_methoddata_same *>(data);
     int                i, j;
 
     /* Collapse adjacent values.
@@ -508,7 +508,7 @@ static void
 evaluate_same_str(const gmx::SelMethodEvalContext & /*context*/,
                   gmx_ana_index_t *g, gmx_ana_selvalue_t *out, void *data)
 {
-    t_methoddata_same     *d = (t_methoddata_same *)data;
+    t_methoddata_same     *d = static_cast<t_methoddata_same *>(data);
     int                    j;
 
     out->u.g->isize = 0;
index ac62fce847d17632e3d896fa796df54aea6850a4..9bf546a5d4ad1731ea2c374bd338bbdae73695df 100644 (file)
@@ -65,12 +65,12 @@ gmx_stats_t gmx_stats_init()
 
     snew(stats, 1);
 
-    return (gmx_stats_t) stats;
+    return static_cast<gmx_stats_t>(stats);
 }
 
 int gmx_stats_get_npoints(gmx_stats_t gstats, int *N)
 {
-    gmx_stats *stats = (gmx_stats *) gstats;
+    gmx_stats *stats = static_cast<gmx_stats *>(gstats);
 
     *N = stats->np;
 
@@ -79,7 +79,7 @@ int gmx_stats_get_npoints(gmx_stats_t gstats, int *N)
 
 void gmx_stats_free(gmx_stats_t gstats)
 {
-    gmx_stats *stats = (gmx_stats *) gstats;
+    gmx_stats *stats = static_cast<gmx_stats *>(gstats);
 
     sfree(stats->x);
     sfree(stats->y);
index bb1d94174948ba3fe76854fa2f4acbb1fbe6bd8f..5f436e41d3180c77da527de296aa794344931e6f 100644 (file)
@@ -419,7 +419,7 @@ static gmx_bool compartment_contains_atom(
         x += l;
     }
 
-    *distance_from_b = (real)fabs(x - bulkOffset*0.5*width);
+    *distance_from_b = static_cast<real>(fabs(x - bulkOffset*0.5*width));
 
     /* Return TRUE if we now are in area "????" */
     return (x >= w1) &&  (x < w2);
index 0d4d73ca6532f096c822869308a52a1345f96479..d62720a7a18ec6fd694d4cebc117124463fa7114 100644 (file)
@@ -708,7 +708,7 @@ static void read_tables(FILE *fp, const char *fn,
             if (ns > 0)
             {
                 ssd /= ns;
-                sprintf(buf, "For the %d non-zero entries for table %d in %s the forces deviate on average %lld%% from minus the numerical derivative of the potential\n", ns, k, libfn, (long long int)(100*ssd+0.5));
+                sprintf(buf, "For the %d non-zero entries for table %d in %s the forces deviate on average %lld%% from minus the numerical derivative of the potential\n", ns, k, libfn, static_cast<long long int>(100*ssd+0.5));
                 if (debug)
                 {
                     fprintf(debug, "%s", buf);
@@ -1369,7 +1369,7 @@ t_forcetable *make_tables(FILE *out,
                 gmx_fatal(FARGS, "Tables in file %s not long enough for cut-off:\n"
                           "\tshould be at least %f nm\n", fn, rtab);
             }
-            table->n = (int)(rtab*td[0].tabscale + 0.5);
+            table->n = static_cast<int>(rtab*td[0].tabscale + 0.5);
         }
         table->scale = td[0].tabscale;
         nx0          = td[0].nx0;
index 765cfdda103d8d41a77523838db462d0a886a495..2bcd5d3442f3ca6cb98a41678479c450a0142ca8 100644 (file)
@@ -1054,7 +1054,7 @@ void wallcycle_print(FILE *fplog, const gmx::MDLogger &mdlog, int nnodes, int np
             GMX_LOG(mdlog.warning).asParagraph().appendTextFormatted(
                     "NOTE: %d %% of the run time was spent in pair search,\n"
                     "      you might want to increase nstlist (this has no effect on accuracy)\n",
-                    (int)(100*cyc_sum[ewcNS]/tot+0.5));
+                    static_cast<int>(100*cyc_sum[ewcNS]/tot+0.5));
         }
         else
         {
@@ -1062,8 +1062,8 @@ void wallcycle_print(FILE *fplog, const gmx::MDLogger &mdlog, int nnodes, int np
                     "NOTE: %d %% of the run time was spent in domain decomposition,\n"
                     "      %d %% of the run time was spent in pair search,\n"
                     "      you might want to increase nstlist (this has no effect on accuracy)\n",
-                    (int)(100*cyc_sum[ewcDOMDEC]/tot+0.5),
-                    (int)(100*cyc_sum[ewcNS]/tot+0.5));
+                    static_cast<int>(100*cyc_sum[ewcDOMDEC]/tot+0.5),
+                    static_cast<int>(100*cyc_sum[ewcNS]/tot+0.5));
         }
     }
 
@@ -1072,7 +1072,7 @@ void wallcycle_print(FILE *fplog, const gmx::MDLogger &mdlog, int nnodes, int np
         GMX_LOG(mdlog.warning).asParagraph().appendTextFormatted(
                 "NOTE: %d %% of the run time was spent communicating energies,\n"
                 "      you might want to use the -gcom option of mdrun\n",
-                (int)(100*cyc_sum[ewcMoveE]/tot+0.5));
+                static_cast<int>(100*cyc_sum[ewcMoveE]/tot+0.5));
     }
 }
 
index 62c0bbaa7bb48f4151b74dbc1a1d124b3d5c09f2..d4fca39d7412845c44fd8cf7bfb44d139026e790 100644 (file)
@@ -404,7 +404,7 @@ int gmx_convert_tpr(int argc, char *argv[])
         /* Determine total number of steps remaining */
         if (bExtend)
         {
-            ir->nsteps = ir->nsteps - (run_step - ir->init_step) + (int64_t)(extend_t/ir->delta_t + 0.5);
+            ir->nsteps = ir->nsteps - (run_step - ir->init_step) + static_cast<int64_t>(extend_t/ir->delta_t + 0.5);
             printf("Extending remaining runtime of by %g ps (now %s steps)\n",
                    extend_t, gmx_step_str(ir->nsteps, buf));
         }
@@ -414,7 +414,7 @@ int gmx_convert_tpr(int argc, char *argv[])
                    gmx_step_str(ir->nsteps, buf),
                    gmx_step_str(run_step, buf2),
                    run_t, until_t);
-            ir->nsteps = (int64_t)((until_t - run_t)/ir->delta_t + 0.5);
+            ir->nsteps = static_cast<int64_t>((until_t - run_t)/ir->delta_t + 0.5);
             printf("Extending remaining runtime until %g ps (now %s steps)\n",
                    until_t, gmx_step_str(ir->nsteps, buf));
         }
index d4bffefe6e7483fbdf422da732a8cf4dd9ee654f..e9af594dd4468249095e42dca8517791bf38fb78 100644 (file)
@@ -138,8 +138,8 @@ static int get_prop_index(aprop_t *ap, gmx_residuetype_t *restype,
         }
     }
 
-    *bExact = ((malen == (long int)strlen(atomnm)) &&
-               ((mrlen == (long int)strlen(resnm)) ||
+    *bExact = ((malen == static_cast<long int>(strlen(atomnm))) &&
+               ((mrlen == static_cast<long int>(strlen(resnm))) ||
                 ((mrlen == WILDPROT) && bProtWild) ||
                 ((mrlen == WILDCARD) && !bProtein && !bProtWild)));
 
@@ -213,7 +213,7 @@ static void add_prop(aprop_t *ap, gmx_residuetype_t *restype,
 
 static void read_prop(gmx_atomprop_t aps, int eprop, double factor)
 {
-    gmx_atomprop *ap2 = (gmx_atomprop*) aps;
+    gmx_atomprop *ap2 = static_cast<gmx_atomprop*>(aps);
     FILE         *fp;
     char          line[STRLEN], resnm[32], atomnm[32];
     double        pp;
@@ -247,7 +247,7 @@ static void read_prop(gmx_atomprop_t aps, int eprop, double factor)
 
 static void set_prop(gmx_atomprop_t aps, int eprop)
 {
-    gmx_atomprop *ap2           = (gmx_atomprop*) aps;
+    gmx_atomprop *ap2           = static_cast<gmx_atomprop*>(aps);
     const char   *fns[epropNR]  = { "atommass.dat", "vdwradii.dat", "dgsolv.dat", "electroneg.dat", "elements.dat" };
     double        fac[epropNR]  = { 1.0,    1.0,  418.4, 1.0, 1.0 };
     double        def[epropNR]  = { 12.011, 0.14, 0.0, 2.2, -1 };
@@ -289,7 +289,7 @@ gmx_atomprop_t gmx_atomprop_init(void)
     aps->bWarned  = FALSE;
     aps->bWarnVDW = FALSE;
 
-    return (gmx_atomprop_t)aps;
+    return static_cast<gmx_atomprop_t>(aps);
 }
 
 static void destroy_prop(aprop_t *ap)
@@ -314,7 +314,7 @@ static void destroy_prop(aprop_t *ap)
 
 void gmx_atomprop_destroy(gmx_atomprop_t aps)
 {
-    gmx_atomprop *ap = (gmx_atomprop*) aps;
+    gmx_atomprop *ap = static_cast<gmx_atomprop*>(aps);
     int           p;
 
     if (aps == nullptr)
@@ -349,7 +349,7 @@ gmx_bool gmx_atomprop_query(gmx_atomprop_t aps,
                             int eprop, const char *resnm, const char *atomnm,
                             real *value)
 {
-    gmx_atomprop *ap = (gmx_atomprop*) aps;
+    gmx_atomprop *ap = static_cast<gmx_atomprop*>(aps);
     int           j;
 #define MAXQ 32
     char          atomname[MAXQ], resname[MAXQ];
@@ -403,7 +403,7 @@ gmx_bool gmx_atomprop_query(gmx_atomprop_t aps,
 
 char *gmx_atomprop_element(gmx_atomprop_t aps, int atomnumber)
 {
-    gmx_atomprop *ap = (gmx_atomprop*) aps;
+    gmx_atomprop *ap = static_cast<gmx_atomprop*>(aps);
     int           i;
 
     set_prop(aps, epropElement);
@@ -419,7 +419,7 @@ char *gmx_atomprop_element(gmx_atomprop_t aps, int atomnumber)
 
 int gmx_atomprop_atomnumber(gmx_atomprop_t aps, const char *elem)
 {
-    gmx_atomprop *ap = (gmx_atomprop*) aps;
+    gmx_atomprop *ap = static_cast<gmx_atomprop*>(aps);
     int           i;
 
     set_prop(aps, epropElement);
index c5bc7beb35deb14c0ddc6b4b95560d17d6e3d6c3..49a4b708d6c22b61ed72cdbbefbba90900981500 100644 (file)
@@ -423,7 +423,7 @@ static void analyse_prot(const char ** restype, const t_atoms *atoms,
         }
     }
     /* find matching or complement atoms */
-    for (i = 0; (i < (int)num_index_groups); i++)
+    for (i = 0; (i < num_index_groups); i++)
     {
         nra = 0;
         for (n = 0; (n < atoms->nr); n++)
@@ -470,7 +470,7 @@ static void analyse_prot(const char ** restype, const t_atoms *atoms,
 
     if (bASK)
     {
-        for (i = 0; (i < (int)num_index_groups); i++)
+        for (i = 0; (i < num_index_groups); i++)
         {
             printf("Split %12s into %5d residues (y/n) ? ", constructing_data[i].group_name, npres);
             if (gmx_ask_yesno(bASK))
@@ -829,7 +829,7 @@ static void minstring(char *str)
 {
     int i;
 
-    for (i = 0; (i < (int)strlen(str)); i++)
+    for (i = 0; (i < static_cast<int>(strlen(str))); i++)
     {
         if (str[i] == '-')
         {
index 0d777546b2e1ccb38813ac9f38b7a43782d004ca..2dfd10f4c13c857a301b5a7b35268a8cf59c6677 100644 (file)
@@ -610,30 +610,30 @@ static void atomcat(t_atoms *dest, const t_atoms *src, int copies,
     /* residue information */
     for (l = dest->nres, j = 0; (j < copies); j++, l += src->nres)
     {
-        memcpy((char *) &(dest->resinfo[l]), (char *) &(src->resinfo[0]),
-               (size_t)(src->nres*sizeof(src->resinfo[0])));
+        memcpy(reinterpret_cast<char *>(&(dest->resinfo[l])), reinterpret_cast<char *>(&(src->resinfo[0])),
+               static_cast<size_t>(src->nres*sizeof(src->resinfo[0])));
     }
 
     for (l = destnr, j = 0; (j < copies); j++, l += srcnr)
     {
-        memcpy((char *) &(dest->atom[l]), (char *) &(src->atom[0]),
-               (size_t)(srcnr*sizeof(src->atom[0])));
-        memcpy((char *) &(dest->atomname[l]), (char *) &(src->atomname[0]),
-               (size_t)(srcnr*sizeof(src->atomname[0])));
+        memcpy(reinterpret_cast<char *>(&(dest->atom[l])), reinterpret_cast<char *>(&(src->atom[0])),
+               static_cast<size_t>(srcnr*sizeof(src->atom[0])));
+        memcpy(reinterpret_cast<char *>(&(dest->atomname[l])), reinterpret_cast<char *>(&(src->atomname[0])),
+               static_cast<size_t>(srcnr*sizeof(src->atomname[0])));
         if (dest->haveType)
         {
-            memcpy((char *) &(dest->atomtype[l]), (char *) &(src->atomtype[0]),
-                   (size_t)(srcnr*sizeof(src->atomtype[0])));
+            memcpy(reinterpret_cast<char *>(&(dest->atomtype[l])), reinterpret_cast<char *>(&(src->atomtype[0])),
+                   static_cast<size_t>(srcnr*sizeof(src->atomtype[0])));
             if (dest->haveBState)
             {
-                memcpy((char *) &(dest->atomtypeB[l]), (char *) &(src->atomtypeB[0]),
-                       (size_t)(srcnr*sizeof(src->atomtypeB[0])));
+                memcpy(reinterpret_cast<char *>(&(dest->atomtypeB[l])), reinterpret_cast<char *>(&(src->atomtypeB[0])),
+                       static_cast<size_t>(srcnr*sizeof(src->atomtypeB[0])));
             }
         }
         if (dest->havePdbInfo)
         {
-            memcpy((char *) &(dest->pdbinfo[l]), (char *) &(src->pdbinfo[0]),
-                   (size_t)(srcnr*sizeof(src->pdbinfo[0])));
+            memcpy(reinterpret_cast<char *>(&(dest->pdbinfo[l])), reinterpret_cast<char *>(&(src->pdbinfo[0])),
+                   static_cast<size_t>(srcnr*sizeof(src->pdbinfo[0])));
         }
     }
 
index 0798390d2660e2be033ffde6b9cba139e03cbb87..eb5693e3019020f335304a0d0588a784f06d0580 100644 (file)
@@ -64,7 +64,7 @@ static char *trim_string(const char *s, char *out, int maxlen)
 {
     int len, i;
 
-    if (strlen(s) > (size_t)(maxlen-1))
+    if (strlen(s) > static_cast<size_t>(maxlen-1))
     {
         gmx_fatal(FARGS, "String '%s' (%zu) is longer than buffer (%d).\n",
                   s, strlen(s), maxlen-1);
index 5ab83dad4f6d9f6164f6c7eaf50ff4ca0a7af422..f03322256729577c2ed6cf8266b9187f08072643 100644 (file)
@@ -549,7 +549,7 @@ static void cmp_idef(FILE *fp, const t_idef *id1, const t_idef *id2, real ftol,
         {
             sprintf(buf1, "idef->functype[%d]", i);
             sprintf(buf2, "idef->iparam[%d]", i);
-            cmp_int(fp, buf1, i, (int)id1->functype[i], (int)id2->functype[i]);
+            cmp_int(fp, buf1, i, static_cast<int>(id1->functype[i]), static_cast<int>(id2->functype[i]));
             cmp_iparm(fp, buf2, id1->functype[i],
                       id1->iparams[i], id2->iparams[i], ftol, abstol);
         }
index 3f7a4249fa293a3a02a4f990a9c36bf2e91fc333..0400f388ad727317a0869d223bb2a5dbc9eb7139 100644 (file)
@@ -117,7 +117,7 @@ static void divarc(real x1, real y1, real z1,
     GMX_ASSERT(d2 >= 0.5, "Vector 2 too short");
 
     phi  = safe_asin(dd/std::sqrt(d1*d2));
-    phi  = phi*((real)div1)/((real)div2);
+    phi  = phi*(static_cast<real>(div1))/(static_cast<real>(div2));
     sphi = sin(phi); cphi = cos(phi);
     s    = (x1*xd+y1*yd+z1*zd)/dd;
 
@@ -140,8 +140,8 @@ static std::vector<real> ico_dot_arc(int densit)
           xjk, yjk, zjk, xkj, ykj, zkj;
 
     /* calculate tessalation level */
-    a = std::sqrt((((real) densit)-2.)/10.);
-    const int  tess = (int) ceil(a);
+    a = std::sqrt(((static_cast<real>(densit))-2.)/10.);
+    const int  tess = static_cast<int>(ceil(a));
     const int  ndot = 10*tess*tess+2;
     GMX_RELEASE_ASSERT(ndot >= densit, "Inconsistent surface dot formula");
 
@@ -263,8 +263,8 @@ static std::vector<real> ico_dot_dod(int densit)
           xjk, yjk, zjk, xkj, ykj, zkj;
 
     /* calculate tesselation level */
-    a     = std::sqrt((((real) densit)-2.)/30.);
-    tess  = std::max((int) ceil(a), 1);
+    a     = std::sqrt(((static_cast<real>(densit))-2.)/30.);
+    tess  = std::max(static_cast<int>(ceil(a)), 1);
     const int ndot = 30*tess*tess+2;
     GMX_RELEASE_ASSERT(ndot >= densit, "Inconsistent surface dot formula");
 
@@ -487,21 +487,21 @@ static std::vector<real> make_unsp(int densit, int cubus)
         ico_cube = std::max(i-1, 0);
     }
     ico_cube_cb = ico_cube*ico_cube*ico_cube;
-    const real del_cube = 2./((real)ico_cube);
+    const real del_cube = 2./(static_cast<real>(ico_cube));
     snew(work, ndot);
     for (l = 0; l < ndot; l++)
     {
-        i = std::max((int) floor((1.+xus[3*l])/del_cube), 0);
+        i = std::max(static_cast<int>(floor((1.+xus[3*l])/del_cube)), 0);
         if (i >= ico_cube)
         {
             i = ico_cube-1;
         }
-        j = std::max((int) floor((1.+xus[1+3*l])/del_cube), 0);
+        j = std::max(static_cast<int>(floor((1.+xus[1+3*l])/del_cube)), 0);
         if (j >= ico_cube)
         {
             j = ico_cube-1;
         }
-        k = std::max((int) floor((1.+xus[2+3*l])/del_cube), 0);
+        k = std::max(static_cast<int>(floor((1.+xus[2+3*l])/del_cube)), 0);
         if (k >= ico_cube)
         {
             k = ico_cube-1;
@@ -561,7 +561,7 @@ nsc_dclm_pbc(const rvec *coords, const ArrayRef<const real> &radius, int nat,
              int index[], AnalysisNeighborhood *nb,
              const t_pbc *pbc)
 {
-    const real dotarea = FOURPI/(real) n_dot;
+    const real dotarea = FOURPI/static_cast<real>(n_dot);
 
     if (debug)
     {
index cb138cf36bf94d8fd759abd426747e91db754d03..27be14f4b8340e0ad7afca4243e706ee9ae73ad2 100644 (file)
@@ -239,7 +239,7 @@ void gmx_print_version_info(gmx::TextWriter *writer)
 #else
     writer->writeLine("Precision:          single");
 #endif
-    writer->writeLine(formatString("Memory model:       %u bit", (unsigned)(8*sizeof(void *))));
+    writer->writeLine(formatString("Memory model:       %u bit", static_cast<unsigned>(8*sizeof(void *))));
 
 #if GMX_THREAD_MPI
     writer->writeLine("MPI library:        thread_mpi");
index c403994a3b14f96fdc7939c833b1085205502263..f92a4b8c1599ff8c14487536415ba613cf4c57e7 100644 (file)
@@ -127,7 +127,7 @@ void upstring (char *str)
 {
     int i;
 
-    for (i = 0; (i < (int)strlen(str)); i++)
+    for (i = 0; (i < static_cast<int>(strlen(str))); i++)
     {
         str[i] = toupper(str[i]);
     }
@@ -211,8 +211,8 @@ int gmx_strncasecmp_min(const char *str1, const char *str2, int n)
     char  ch1, ch2;
     char *stri1, *stri2;
 
-    stri1 = (char *)str1;
-    stri2 = (char *)str2;
+    stri1 = const_cast<char *>(str1);
+    stri2 = const_cast<char *>(str2);
     do
     {
         do
index e5a6404b38e7b15c08db97502135639b376426a4..5339b1be20d1022e1c0e2722ad1f080a02600c8f 100644 (file)
@@ -54,8 +54,8 @@ qsort_swapfunc(void *        a,
 
     if (swaptype <= 1)
     {
-        ia = (int *)a;
-        ib = (int *)b;
+        ia = static_cast<int *>(a);
+        ib = static_cast<int *>(b);
         for (; n > 0; ia += 1, ib += 1, n -= sizeof(int))
         {
             itmp      = *ia;
@@ -65,8 +65,8 @@ qsort_swapfunc(void *        a,
     }
     else
     {
-        ca = (char *)a;
-        cb = (char *)b;
+        ca = static_cast<char *>(a);
+        cb = static_cast<char *>(b);
         for (; n > 0; ca += 1, cb += 1, n -= 1)
         {
             ctmp       = *ca;
@@ -136,9 +136,9 @@ gmx_qsort(void *           base,
         return;
     }
 
-    cbase = (char *)base;
+    cbase = static_cast<char *>(base);
 
-    swaptype = (size_t)(cbase - (char *)nullptr) % sizeof(int) || size % sizeof(int) ? 2 : size == sizeof(int) ? 0 : 1;
+    swaptype = static_cast<size_t>(cbase - (char *)nullptr) % sizeof(int) || size % sizeof(int) ? 2 : size == sizeof(int) ? 0 : 1;
 
     if (nmemb < 7)
     {
@@ -164,12 +164,12 @@ gmx_qsort(void *           base,
         {
             /* Big arrays, pseudomedian of 9 */
             s  = (nmemb/8)*size;
-            pl = (char *)qsort_med3((void *)pl, (void *)((size_t)pl+s), (void *)((size_t)pl+2*s), compar);
-            pm = (char *)qsort_med3((void *)((size_t)pm-s), (void *)pm, (void *)((size_t)pm+s), compar);
-            pn = (char *)qsort_med3((void *)((size_t)pn-2*s), (void *)((size_t)pn-s), (void *)pn, compar);
+            pl = static_cast<char *>(qsort_med3((void *)pl, (void *)((size_t)pl+s), (void *)((size_t)pl+2*s), compar));
+            pm = static_cast<char *>(qsort_med3((void *)((size_t)pm-s), (void *)pm, (void *)((size_t)pm+s), compar));
+            pn = static_cast<char *>(qsort_med3((void *)((size_t)pn-2*s), (void *)((size_t)pn-s), (void *)pn, compar));
         }
         /* Mid-size, med of 3 */
-        pm = (char *)qsort_med3((void *)pl, (void *)pm, (void *)pn, compar);
+        pm = static_cast<char *>(qsort_med3((void *)pl, (void *)pm, (void *)pn, compar));
     }
 
     /* pv points to partition value */
@@ -180,8 +180,8 @@ gmx_qsort(void *           base,
     }
     else
     {
-        v  = *(int *)pm;
-        pv = (char*)(void*)&v;
+        v  = *reinterpret_cast<int *>(pm);
+        pv = static_cast<char*>((void*)&v);
     }
 
     pa = pb = cbase;
index 97f3d0a6c1806acd1a03464e9a1a514c4e9900cf..7c68694125bbc60ab4a80282379feb1c2cf6541a 100644 (file)
@@ -79,7 +79,7 @@ void *save_malloc(const char *name, const char *file, int line, size_t size)
             gmx_fatal(errno, __FILE__, __LINE__,
                       "Not enough memory. Failed to malloc %" PRId64 " bytes for %s\n"
                       "(called from file %s, line %d)",
-                      (int64_t)size, name, file, line);
+                      static_cast<int64_t>(size), name, file, line);
         }
         (void) memset(p, 0, size);
     }
@@ -120,13 +120,13 @@ void *save_calloc(const char *name, const char *file, int line,
         }
         memset(p, 0, (size_t) (nelem * elsize));
 #else
-        if ((p = calloc((size_t)nelem, (size_t)elsize)) == nullptr)
+        if ((p = calloc(nelem, elsize)) == nullptr)
         {
             gmx_fatal(errno, __FILE__, __LINE__,
                       "Not enough memory. Failed to calloc %" PRId64
                       " elements of size %" PRId64
                       " for %s\n(called from file %s, line %d)",
-                      (int64_t)nelem, (int64_t)elsize, name, file, line);
+                      static_cast<int64_t>(nelem), static_cast<int64_t>(elsize), name, file, line);
         }
 #endif
     }
@@ -156,18 +156,18 @@ void *save_realloc(const char *name, const char *file, int line, void *ptr,
 #endif
         if (ptr == nullptr)
         {
-            p = malloc((size_t)size);
+            p = malloc(size);
         }
         else
         {
-            p = realloc(ptr, (size_t)size);
+            p = realloc(ptr, size);
         }
         if (p == nullptr)
         {
             gmx_fatal(errno, __FILE__, __LINE__,
                       "Not enough memory. Failed to realloc %" PRId64 " bytes for %s, %s=%x\n"
                       "(called from file %s, line %d)",
-                      (int64_t)size, name, name, ptr, file, line);
+                      static_cast<int64_t>(size), name, name, ptr, file, line);
         }
     }
     return p;
@@ -237,7 +237,7 @@ void *save_calloc_aligned(const char *name, const char *file, int line,
     void *aligned = save_malloc_aligned(name, file, line, nelem, elsize, alignment);
     if (aligned != nullptr)
     {
-        memset(aligned, 0, (size_t)(nelem * elsize));
+        memset(aligned, 0, static_cast<size_t>(nelem * elsize));
     }
     return aligned;
 }