*/
#include "gmxpre.h"
-#include <math.h>
-#include <stdlib.h>
-#include <string.h>
+#include <cmath>
+#include <cstdlib>
+#include <cstring>
+
+#include <algorithm>
#include "gromacs/commandline/pargs.h"
#include "gromacs/fileio/confio.h"
gmx_bool *bMol, *bTmp;
rvec *m_com, *m_shift;
t_pbc pbc;
- real *com_dist2;
int *cluster;
int *added;
int ncluster, nadded;
calc_box_center(ecenter, box, box_center);
/* Initiate the pbc structure */
- memset(&pbc, 0, sizeof(pbc));
+ std::memset(&pbc, 0, sizeof(pbc));
set_pbc(&pbc, ePBC, box);
/* Convert atom index to molecular */
{
atom_id i, j;
int d;
- rvec com, new_com, shift, dx, box_center;
+ rvec com, new_com, shift, box_center;
real m;
double mtot;
t_pbc pbc;
int natoms, t_atom atom[],
int ePBC, matrix box, rvec x[])
{
- atom_id i, j, res_start, res_end, res_nat;
+ atom_id i, j, res_start, res_end;
int d, presnr;
real m;
double mtot;
{
/* calculate final COM */
res_end = i;
- res_nat = res_end - res_start;
svmul(1.0/mtot, com, com);
/* check if COM is outside box */
char nbuf[128];
int nd = 0, fnr;
- strcpy(out_file, base);
+ std::strcpy(out_file, base);
fnr = file_nr;
do
{
if (nd < ndigit)
{
- strncat(out_file, "00000000000", ndigit-nd);
+ std::strncat(out_file, "00000000000", ndigit-nd);
}
sprintf(nbuf, "%d.", file_nr);
- strcat(out_file, nbuf);
- strcat(out_file, ext);
+ std::strcat(out_file, nbuf);
+ std::strcat(out_file, ext);
}
void check_trr(const char *fn)
{
gmx_fatal(FARGS, "Error reading user input");
}
- if (strcmp(yesno, "YES") == 0)
+ if (std::strcmp(yesno, "YES") == 0)
{
fprintf(stderr, "Once again, I'm gonna DO this...\n");
gmx_trr_close(in);
};
#define NPA asize(pa)
- FILE *out = NULL;
- t_trxstatus *trxout = NULL;
- t_trxstatus *trxin;
- int ftp, ftpin = 0, file_nr;
- t_trxframe fr, frout;
- int flags;
- rvec *xmem = NULL, *vmem = NULL, *fmem = NULL;
- rvec *xp = NULL, x_shift, hbox, box_center, dx;
- real xtcpr, lambda, *w_rls = NULL;
- int m, i, d, frame, outframe, natoms, nout, ncent, nre, newstep = 0, model_nr;
+ FILE *out = NULL;
+ t_trxstatus *trxout = NULL;
+ t_trxstatus *trxin;
+ int ftp, ftpin = 0, file_nr;
+ t_trxframe fr, frout;
+ int flags;
+ rvec *xmem = NULL, *vmem = NULL, *fmem = NULL;
+ rvec *xp = NULL, x_shift, hbox;
+ real *w_rls = NULL;
+ int m, i, d, frame, outframe, natoms, nout, ncent, newstep = 0, model_nr;
#define SKIP 10
- t_topology top;
- gmx_mtop_t *mtop = NULL;
- gmx_conect gc = NULL;
- int ePBC = -1;
- t_atoms *atoms = NULL, useatoms;
- matrix top_box;
- atom_id *index, *cindex;
- char *grpnm;
- int *frindex, nrfri;
- char *frname;
- int ifit, irms, my_clust = -1;
- atom_id *ind_fit, *ind_rms;
- char *gn_fit, *gn_rms;
- t_cluster_ndx *clust = NULL;
- t_trxstatus **clust_status = NULL;
- int *clust_status_id = NULL;
- int ntrxopen = 0;
- int *nfwritten = NULL;
- int ndrop = 0, ncol, drop0 = 0, drop1 = 0, dropuse = 0;
- double **dropval;
- real tshift = 0, t0 = -1, dt = 0.001, prec;
- gmx_bool bFit, bFitXY, bPFit, bReset;
- int nfitdim;
- gmx_rmpbc_t gpbc = NULL;
- gmx_bool bRmPBC, bPBCWhole, bPBCcomRes, bPBCcomMol, bPBCcomAtom, bPBC, bNoJump, bCluster;
- gmx_bool bCopy, bDoIt, bIndex, bTDump, bSetTime, bTPS = FALSE, bDTset = FALSE;
- gmx_bool bExec, bTimeStep = FALSE, bDumpFrame = FALSE, bSetPrec, bNeedPrec;
- gmx_bool bHaveFirstFrame, bHaveNextFrame, bSetBox, bSetUR, bSplit = FALSE;
- gmx_bool bSubTraj = FALSE, bDropUnder = FALSE, bDropOver = FALSE, bTrans = FALSE;
- gmx_bool bWriteFrame, bSplitHere;
- const char *top_file, *in_file, *out_file = NULL;
- char out_file2[256], *charpt;
- char *outf_base = NULL;
- const char *outf_ext = NULL;
- char top_title[256], title[256], command[256], filemode[5];
- int xdr = 0;
- gmx_bool bWarnCompact = FALSE;
- const char *warn;
- output_env_t oenv;
-
- t_filenm fnm[] = {
+ t_topology top;
+ gmx_mtop_t *mtop = NULL;
+ gmx_conect gc = NULL;
+ int ePBC = -1;
+ t_atoms *atoms = NULL, useatoms;
+ matrix top_box;
+ atom_id *index, *cindex;
+ char *grpnm;
+ int *frindex, nrfri;
+ char *frname;
+ int ifit, my_clust = -1;
+ atom_id *ind_fit;
+ char *gn_fit;
+ t_cluster_ndx *clust = NULL;
+ t_trxstatus **clust_status = NULL;
+ int *clust_status_id = NULL;
+ int ntrxopen = 0;
+ int *nfwritten = NULL;
+ int ndrop = 0, ncol, drop0 = 0, drop1 = 0, dropuse = 0;
+ double **dropval;
+ real tshift = 0, t0 = -1, dt = 0.001, prec;
+ gmx_bool bFit, bPFit, bReset;
+ int nfitdim;
+ gmx_rmpbc_t gpbc = NULL;
+ gmx_bool bRmPBC, bPBCWhole, bPBCcomRes, bPBCcomMol, bPBCcomAtom, bPBC, bNoJump, bCluster;
+ gmx_bool bCopy, bDoIt, bIndex, bTDump, bSetTime, bTPS = FALSE, bDTset = FALSE;
+ gmx_bool bExec, bTimeStep = FALSE, bDumpFrame = FALSE, bSetPrec, bNeedPrec;
+ gmx_bool bHaveFirstFrame, bHaveNextFrame, bSetBox, bSetUR, bSplit = FALSE;
+ gmx_bool bSubTraj = FALSE, bDropUnder = FALSE, bDropOver = FALSE, bTrans = FALSE;
+ gmx_bool bWriteFrame, bSplitHere;
+ const char *top_file, *in_file, *out_file = NULL;
+ char out_file2[256], *charpt;
+ char *outf_base = NULL;
+ const char *outf_ext = NULL;
+ char top_title[256], title[256], filemode[5];
+ gmx_bool bWarnCompact = FALSE;
+ const char *warn;
+ output_env_t oenv;
+
+ t_filenm fnm[] = {
{ efTRX, "-f", NULL, ffREAD },
{ efTRO, "-o", NULL, ffWRITE },
{ efTPS, NULL, NULL, ffOPTRD },
/* parse enum options */
fit_enum = nenum(fit);
bFit = (fit_enum == efFit || fit_enum == efFitXY);
- bFitXY = fit_enum == efFitXY;
bReset = (fit_enum == efReset || fit_enum == efResetXY);
bPFit = fit_enum == efPFit;
pbc_enum = nenum(pbc_opt);
" only has effect in combination with -pbc %s, %s or %s.\n"
" Ingoring unitcell representation.\n\n",
unitcell_opt[0], pbc_opt[2], pbc_opt[3], pbc_opt[4]);
- bSetUR = FALSE;
}
}
if (bFit && bPBC)
}
if (bSeparate || bSplit)
{
- outf_ext = strrchr(out_file, '.');
+ outf_ext = std::strrchr(out_file, '.');
if (outf_ext == NULL)
{
gmx_fatal(FARGS, "Output file name '%s' does not contain a '.'", out_file);
* the header in such a file is top_title t= ...
* to prevent a double t=, remove it from top_title
*/
- if ((charpt = strstr(top_title, " t= ")))
+ if ((charpt = std::strstr(top_title, " t= ")))
{
charpt[0] = '\0';
}
{
useatoms.pdbinfo[i] = atoms->pdbinfo[index[i]];
}
- useatoms.nres = max(useatoms.nres, useatoms.atom[i].resind+1);
+ useatoms.nres = std::max(useatoms.nres, useatoms.atom[i].resind+1);
}
useatoms.nr = nout;
}
}
/* open output for writing */
- strcpy(filemode, "w");
+ std::strcpy(filemode, "w");
switch (ftp)
{
case efTNG:
drop0 = drop1;
drop1++;
}
- if (fabs(dropval[0][drop0] - fr.time)
- < fabs(dropval[0][drop1] - fr.time))
+ if (std::abs(dropval[0][drop0] - fr.time)
+ < std::abs(dropval[0][drop1] - fr.time))
{
dropuse = drop0;
}
else
{
/* round() is not C89 compatible, so we do this: */
- bDoIt = bRmod(floor(frout_time+0.5), floor(tzero+0.5),
- floor(delta_t+0.5));
+ bDoIt = bRmod(std::floor(frout_time+0.5), std::floor(tzero+0.5),
+ std::floor(delta_t+0.5));
}
}
else
{
/* round() is not C89 compatible, so we do this: */
- bSplitHere = bSplit && bRmod(floor(frout.time+0.5),
- floor(tzero+0.5),
- floor(split_t+0.5));
+ bSplitHere = bSplit && bRmod(std::floor(frout.time+0.5),
+ std::floor(tzero+0.5),
+ std::floor(split_t+0.5));
}
if (bSeparate || bSplitHere)
{