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
// 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);
}
{
if (ftp == fnm[i].ftp)
{
- return (gmx_bool) IS_SET(fnm[i]);
+ return static_cast<gmx_bool>(IS_SET(fnm[i]));
}
}
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");
/* 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)
sfree(cfour);
for (j = 0; (j < nframes); j++)
{
- c1[j] = csum[j]/(real)(nframes-j);
+ c1[j] = csum[j]/static_cast<real>(nframes-j);
}
}
}
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)
{
{
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)
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);
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) ||
{
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) ||
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);
}
}
* 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,
}
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;
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)
{
}
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])
{
* 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
{
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);
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)
{
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))
{
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);
/*! \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 */
{
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
{
}
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;
}
* 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
{
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;
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 */
}
rmsd += distance2(s->x[i], x[i]);
}
- rmsd /= (real) s->nr;
+ rmsd /= static_cast<real>(s->nr);
rmsd = sqrt(rmsd);
return rmsd;
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");
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]++;
}
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]++;
}
/* 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 */
" 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);
}
/*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++)
{
}
}
- plan = (fft5d_plan)calloc(1, sizeof(struct fft5d_plan_t));
+ plan = static_cast<fft5d_plan>(calloc(1, sizeof(struct fft5d_plan_t)));
if (debug)
{
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
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)
#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");
* 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.
*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);
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);
*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);
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);
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++)
{
*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);
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);
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++)
}
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;
}
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;
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));
}
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;
}
*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);
}
}
}
/* 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);
}
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);
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;
}
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))
}
else
{
- word[nc++] = (char)i;
+ word[nc++] = static_cast<char>(i);
}
}
}
{
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++)
{
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:
{
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];
}
}
}
{
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];
}
}
}
{
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++)
{
{
if (!fio->bRead)
{
- slen = strlen((char *) item) + 1;
+ slen = strlen(static_cast<char *>(item)) + 1;
}
else
{
}
else
{
- cptr = (char *)item;
+ cptr = static_cast<char *>(item);
}
if (cptr)
{
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
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)
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)
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
{
*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)
{
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)
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)
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
{
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)
{
/* 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);
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));
}
}
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;
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++)
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);*/
}
tng_num_particles_get(tng, &nParticles);
- if (nAtoms != (int)nParticles)
+ if (nAtoms != static_cast<int>(nParticles))
{
tng_implicit_num_particles_set(tng, nAtoms);
}
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,
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
{
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);
}
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)
/*
* 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.
if (strcmp(key, vmdplugin->filetype) == 0)
{
- vmdplugin->api = (molfile_plugin_t *)p;
+ vmdplugin->api = reinterpret_cast<molfile_plugin_t *>(p);
}
return VMDPLUGIN_SUCCESS;
}
}
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);
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 */
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
*
* 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.
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)
return ret;
#else
- return xdr_float(xdrs, (float *)r);
+ return xdr_float(xdrs, static_cast<float *>(r));
#endif
}
return ret;
#else
- return xdr_float(xdrs, (float *)r);
+ return xdr_float(xdrs, static_cast<float *>(r));
#endif
}
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++;
}
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
{
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;
{
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));
/* 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;
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);
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);
}
/* 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;
}
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)
{
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;
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);
}
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;
}
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;
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;
{
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");
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++)
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 */
/********************/
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 */
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));
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");
}
*/
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;
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;
fclose(fp);
- return (gmx_structurefactors_t *) gsf;
+ return static_cast<gmx_structurefactors_t *>(gsf);
}
{
int i;
- reduced_atom *pos = (reduced_atom *)positions;
+ reduced_atom *pos = static_cast<reduced_atom *>(positions);
if (flag)
{
int fndx = 0;
int NCMT;
- gmx_structurefactors *gsft = (gmx_structurefactors *)gsf;
+ gmx_structurefactors *gsft = static_cast<gmx_structurefactors *>(gsf);
NCMT = gsft->nratoms;
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];
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++)
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 */
{
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);
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);
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;
int i;
gmx_structurefactors *sf;
- sf = (gmx_structurefactors *) gsf;
+ sf = static_cast<gmx_structurefactors *>(gsf);
for (i = 0; i < sf->nratoms; i++)
{
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 */
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
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;
}
}
*/
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)
{
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))
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)
{
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;
}
{
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;
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++)
(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));
}
}
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);
{
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);
}
else
{
- return (int) (pa->a[2]-pb->a[2]);
+ return (pa->a[2]-pb->a[2]);
}
}
/* 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);
}
}
{
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')
{
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);
}
}
}
/* 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)
{
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))
{
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;
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;
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);
}
/* 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)
{
"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))
*
* 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.
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;
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))
{
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);
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;
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);
}
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);
}
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);
}
}
{
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);
}
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;
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;
}
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);
}
/* 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;
{
if (anm[i] && gmx_strcasecmp(type, *(anm[i])) == 0)
{
- return (int) i;
+ return i;
}
}
if (!(bNext && at[start].resind == at[natoms-1].resind))
{
if (gmx_strcasecmp(type, *(anm[i])) == 0)
{
- return (int) i;
+ return i;
}
}
if (start > 0)
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);
{
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]);
}
}
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 */
}
{
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];
}
}
{
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 &&
/* 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)
{
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);
}
}
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;
}
trim (pline);
/* if there is something left... */
- if ((int)strlen(pline) > 0)
+ if (static_cast<int>(strlen(pline)) > 0)
{
if (pline[0] == OPENDIR)
{
break;
}
default:
- fprintf (stderr, "case: %d\n", (int)d);
+ fprintf (stderr, "case: %d\n", static_cast<int>(d));
gmx_incons("unknown directive");
}
}
{
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);
}
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++)
{
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);
}
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)
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;
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];
}
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);
}
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);
}
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);
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);
}
/* 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;
/* 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;
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);
}
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;
}
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
/* 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 */
* 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
/*
* 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.
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
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)
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);
/* 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;
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));
}
}
/*
* 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.
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))
{
/* 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.
/* 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;
/* 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;
}
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
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)
{
}
else
{
- invmm = (1.0/(double)m)/((double)m+1.0);
+ invmm = (1.0/m)/(m+1.0);
for (i = 0; (i < nener); i++)
{
bIfFlat = FALSE;
return bIfFlat;
}
- nmean /= (real)nhisto;
+ nmean /= static_cast<real>(nhisto);
bIfFlat = TRUE;
for (i = 0; i < nhisto; i++)
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) */
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! */
/*
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)
{
{
if (expand->elamstats == elamstatsWL)
{
- fprintf(outfile, " %8d", (int)dfhist->wl_histo[ifep]);
+ fprintf(outfile, " %8d", static_cast<int>(dfhist->wl_histo[ifep]));
}
else
{
{
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]);
}
}
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]);
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;
*/
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);
}
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,
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;
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
{
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;
/*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;
}
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)
"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"
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);
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);
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
{
* 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++)
{
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.
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;
{
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)
{
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);
}
{
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",
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));
}
}
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)
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);
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);
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);
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++)
{
}
}
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)
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;
{
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));
}
}
}
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);
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);
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);
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);
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;
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.
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);
/* 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
{
/* 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
{
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]));
}
}
* 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;
* 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)
{
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 */
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
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 */
{
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;
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;
}
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]);
}
}
}
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);
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);
}
fprintf(debug, "Going to sort constraints\n");
}
- qsort(sb, ncons, (size_t)sizeof(*sb), pcomp);
+ qsort(sb, ncons, sizeof(*sb), pcomp);
if (debug)
{
}
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]");
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];
}
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)
{
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';
}
else
{
- fprintf(out, ", remaining wall clock time: %5d s ", (int)dt);
+ fprintf(out, ", remaining wall clock time: %5d s ", static_cast<int>(dt));
}
}
else
{
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++)
* 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.
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
"\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) &&
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);
}
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);
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);
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);
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);
}
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)] */
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);
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);
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;
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
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)
{
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;
}
}
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;
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);
}
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);
}
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;
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;
}
sfree(eigvec);
- return (real) opt_angle;
+ return static_cast<real>(opt_angle);
}
/*
* 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.
}
else
{
- fprintf(fp, "%p", (void*)(evalfunc));
+ fprintf(fp, "%p", reinterpret_cast<void*>(evalfunc));
}
}
/*
* 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.
mp->currsize -= size;
if (mp->buffer)
{
- mp->freeptr = (char *)ptr;
+ mp->freeptr = static_cast<char *>(ptr);
mp->freesize += size;
}
else
{
size = mp->maxsize;
}
- mp->buffer = (char *)malloc(size);
+ mp->buffer = static_cast<char *>(malloc(size));
if (!mp->buffer)
{
throw std::bad_alloc();
_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);
}
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 */
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);
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 */
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)
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;
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;
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))
{
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)
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)
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;
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)
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);
/*
* 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.
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;
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;
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;
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;
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)
{
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)
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);
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);
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;
}
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;
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;
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;
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;
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;
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;
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
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)
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)
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))
{
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);
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;
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);
}
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);
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);
}
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;
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);
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. */
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;
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.
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;
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;
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);
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);
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);
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;
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
{
"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));
}
}
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));
}
}
/* 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));
}
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));
}
}
}
- *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)));
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;
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 };
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)
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)
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];
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);
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);
}
}
/* 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++)
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))
{
int i;
- for (i = 0; (i < (int)strlen(str)); i++)
+ for (i = 0; (i < static_cast<int>(strlen(str))); i++)
{
if (str[i] == '-')
{
/* 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])));
}
}
{
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);
{
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);
}
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;
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");
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");
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;
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)
{
#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");
{
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]);
}
char ch1, ch2;
char *stri1, *stri2;
- stri1 = (char *)str1;
- stri2 = (char *)str2;
+ stri1 = const_cast<char *>(str1);
+ stri2 = const_cast<char *>(str2);
do
{
do
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;
}
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;
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)
{
{
/* 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 */
}
else
{
- v = *(int *)pm;
- pv = (char*)(void*)&v;
+ v = *reinterpret_cast<int *>(pm);
+ pv = static_cast<char*>((void*)&v);
}
pa = pb = cbase;
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);
}
}
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
}
#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;
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;
}