*/
#include "gmxpre.h"
-#include <assert.h>
-#include <math.h>
-#include <stdlib.h>
-#include <string.h>
+#include <cmath>
+#include <cstdlib>
+#include <cstring>
#include "gromacs/commandline/pargs.h"
#include "gromacs/fileio/confio.h"
#include "gromacs/topology/index.h"
#include "gromacs/utility/cstringutil.h"
#include "gromacs/utility/futil.h"
+#include "gromacs/utility/gmxassert.h"
#include "gromacs/utility/smalloc.h"
int ePBC;
matrix boxtop, box, *sbox, avbox, corr;
rvec *xtop, *x, **sx;
- int isize, nalloc, nallocn, natom;
+ int isize, nalloc, nallocn;
t_trxstatus *status;
atom_id *index;
char *grpname;
sx = NULL;
clear_mat(avbox);
- natom = read_first_x(oenv, &status, ftp2fn(efTRX, NFILE, fnm), &t, &x, box);
+ read_first_x(oenv, &status, ftp2fn(efTRX, NFILE, fnm), &t, &x, box);
nfr = 0;
do
{
srenew(sbox, nalloc);
srenew(sx, nalloc);
}
- assert(time != NULL); assert(sbox != NULL);
+ GMX_RELEASE_ASSERT(time != NULL, "Memory allocation failure; time array is NULL");
+ GMX_RELEASE_ASSERT(sbox != NULL, "Memory allocation failure; sbox array is NULL");
time[nfr] = t;
copy_mat(box, sbox[nfr]);
dt = (time[nfr-1] - time[0])/(nfr - 1);
/* Some ugly rounding to get nice nice times in the output */
- dt = (int)(10000.0*dt + 0.5)/10000.0;
+ dt = static_cast<int>((10000.0*dt + 0.5)/10000.0);
invbin = 1.0/rbin;
fmmax = nfr - 1;
}
snew(mcount, fmmax);
- nbin = (int)(rmax*invbin + 0.5);
+ nbin = static_cast<int>(rmax*invbin + 0.5);
if (sbin == 0)
{
mat_nx = fmmax + 1;
else
{
invsbin = 1.0/sbin;
- mat_nx = sqrt(fmmax*dt)*invsbin + 1;
+ mat_nx = static_cast<int>(std::sqrt(fmmax*dt)*invsbin + 1);
}
snew(mat, mat_nx);
for (f = 0; f < mat_nx; f++)
}
else
{
- mbin = (int)(sqrt(fbin*dt)*invsbin + 0.5);
+ mbin = static_cast<int>(std::sqrt(fbin*dt)*invsbin + 0.5);
}
for (i = 0; i < isize; i++)
{
d2 = distance2(sx[f][i], sx[ff][i]);
if (mbin < mat_nx && d2 < rmax2)
{
- bin = (int)(sqrt(d2)*invbin + 0.5);
+ bin = static_cast<int>(std::sqrt(d2)*invbin + 0.5);
if (bin < nbin)
{
mat[mbin][bin] += 1;
for (i = 0; i < isize; i++)
{
d2 = distance2(sx[f][i], sx[ff][i]);
- bin = (int)(sqrt(d2)*invbin + 0.5);
+ bin = static_cast<int>(std::sqrt(d2)*invbin + 0.5);
if (bin >= nalloc)
{
nallocn = 10*(bin/10) + 11;
fprintf(fp, "%g", i*rbin);
for (fbin = 0; fbin < nr; fbin++)
{
- fprintf(fp, " %g",
- (real)pr[fbin][i]/(rcount[fbin]*isize*rbin*(i == 0 ? 0.5 : 1)));
+ fprintf(fp, " %g", static_cast<real>(pr[fbin][i])/(rcount[fbin]*isize*rbin*(i == 0 ? 0.5 : 1.0)));
}
fprintf(fp, "\n");
}
}
for (f = 0; f <= ftmax; f++)
{
- fprintf(fp, "%g %g\n", f*dt, (real)pt[f]/(tcount[f]*isize));
+ fprintf(fp, "%g %g\n", f*dt, static_cast<real>(pt[f])/(tcount[f]*isize));
}
xvgrclose(fp);
}