*
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
* Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014,2015,2016, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2015,2016,2017, 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.
snew(win, nwin);
for (i = 0; i < nwin; i++)
{
- win[i].Histo = win[i].cum = 0;
- win[i].k = win[i].pos = win[i].z = 0;
- win[i].N = win[i].Ntot = 0;
- win[i].g = win[i].tau = win[i].tausmooth = 0;
- win[i].bContrib = 0;
- win[i].ztime = 0;
- win[i].forceAv = 0;
- win[i].aver = win[i].sigma = 0;
- win[i].bsWeight = 0;
+ win[i].Histo = win[i].cum = nullptr;
+ win[i].k = win[i].pos = win[i].z = nullptr;
+ win[i].N = win[i].Ntot = nullptr;
+ win[i].g = win[i].tau = win[i].tausmooth = nullptr;
+ win[i].bContrib = nullptr;
+ win[i].ztime = nullptr;
+ win[i].forceAv = nullptr;
+ win[i].aver = win[i].sigma = nullptr;
+ win[i].bsWeight = nullptr;
}
return win;
}
std::istringstream ist;
/* line 1 */
- if (fgets(line, 2048, file) == NULL)
+ if (fgets(line, 2048, file) == nullptr)
{
gmx_fatal(FARGS, "Error reading header from pdo file\n");
}
}
/* line 2 */
- if (fgets(line, 2048, file) == NULL)
+ if (fgets(line, 2048, file) == nullptr)
{
gmx_fatal(FARGS, "Error reading header from pdo file\n");
}
}
/* line3 */
- if (fgets(line, 2048, file) == NULL)
+ if (fgets(line, 2048, file) == nullptr)
{
gmx_fatal(FARGS, "Error reading header from pdo file\n");
}
ist >> Buffer0 >> Buffer1 >> header->nSkip;
/* line 4 */
- if (fgets(line, 2048, file) == NULL)
+ if (fgets(line, 2048, file) == nullptr)
{
gmx_fatal(FARGS, "Error reading header from pdo file\n");
}
ist >> Buffer0 >> Buffer1 >> Buffer2 >> header->Reference;
/* line 5 */
- if (fgets(line, 2048, file) == NULL)
+ if (fgets(line, 2048, file) == nullptr)
{
gmx_fatal(FARGS, "Error reading header from pdo file\n");
}
for (i = 0; i < header->nPull; ++i)
{
- if (fgets(line, 2048, file) == NULL)
+ if (fgets(line, 2048, file) == nullptr)
{
gmx_fatal(FARGS, "Error reading header from pdo file\n");
}
}
}
- if (fgets(line, 2048, file) == NULL)
+ if (fgets(line, 2048, file) == nullptr)
{
gmx_fatal(FARGS, "Cannot read from file\n");
}
char *p;
int slen;
- if (fgets(ptr, *len-1, fp) == NULL)
+ if (fgets(ptr, *len-1, fp) == nullptr)
{
- return NULL;
+ return nullptr;
}
p = ptr;
- while ((std::strchr(ptr, '\n') == NULL) && (!feof(fp)))
+ while ((std::strchr(ptr, '\n') == nullptr) && (!feof(fp)))
{
/* This line is longer than len characters, let's increase len! */
*len += STRLEN;
p += STRLEN;
srenew(ptr, *len);
- if (fgets(p-1, STRLEN, fp) == NULL)
+ if (fgets(p-1, STRLEN, fp) == nullptr)
{
break;
}
int i, inttemp, bins, count, ntot;
real minval, maxval, minfound = 1e20, maxfound = -1e20;
double temp, time, time0 = 0, dt;
- char *ptr = 0;
- t_UmbrellaWindow * window = 0;
+ char *ptr = nullptr;
+ t_UmbrellaWindow * window = nullptr;
gmx_bool timeok, dt_ok = 1;
- char *tmpbuf = 0, fmt[256], fmtign[256], fmtlf[5] = "%lf";
+ char *tmpbuf = nullptr, fmt[256], fmtign[256], fmtlf[5] = "%lf";
int len = STRLEN, dstep = 1;
const int blocklen = 4096;
- int *lennow = 0;
+ int *lennow = nullptr;
if (!bGetMinMax)
{
snew(window->g, window->nPull);
snew(window->bsWeight, window->nPull);
- window->bContrib = 0;
+ window->bContrib = nullptr;
if (opt->bCalcTauInt)
{
}
else
{
- window->ztime = 0;
+ window->ztime = nullptr;
}
snew(lennow, window->nPull);
window->g[i] = 1.;
if (opt->bCalcTauInt)
{
- window->ztime[i] = 0;
+ window->ztime[i] = nullptr;
}
}
count = 0;
snew(tmpbuf, len);
- while ( (ptr = fgets3(file, tmpbuf, &len)) != NULL)
+ while ( (ptr = fgets3(file, tmpbuf, &len)) != nullptr)
{
trim(ptr);
{
int i, j, k, nbin;
double last;
- char *fn = 0, *buf = 0;
- FILE *fp = 0;
+ char *fn = nullptr, *buf = nullptr;
+ FILE *fp = nullptr;
if (opt->bs_verbose)
{
void print_histograms(const char *fnhist, t_UmbrellaWindow * window, int nWindows,
int bs_index, t_UmbrellaOptions *opt, const char *xlabel)
{
- char *fn = 0, *buf = 0, title[256];
+ char *fn = nullptr, *buf = nullptr, title[256];
FILE *fp;
int bins, l, i, j;
{
t_UmbrellaWindow * synthWindow;
double *bsProfile, *bsProfiles_av, *bsProfiles_av2, maxchange = 1e20, tmp, stddev;
- int i, j, *randomArray = 0, winid, pullid, ib;
+ int i, j, *randomArray = nullptr, winid, pullid, ib;
int iAllPull, nAllPull, *allPull_winId, *allPull_pullId;
FILE *fp;
gmx_bool bExact = FALSE;
void read_wham_in(const char *fn, char ***filenamesRet, int *nfilesRet,
t_UmbrellaOptions *opt)
{
- char **filename = 0, tmp[WHAM_MAXFILELEN+2];
+ char **filename = nullptr, tmp[WHAM_MAXFILELEN+2];
int nread, sizenow, i, block = 1;
FILE *fp;
fp = gmx_ffopen(fn, "r");
nread = 0;
sizenow = 0;
- while (fgets(tmp, sizeof(tmp), fp) != NULL)
+ while (fgets(tmp, sizeof(tmp), fp) != nullptr)
{
if (std::strlen(tmp) >= WHAM_MAXFILELEN)
{
//! Open a file or a pipe to a gzipped file
FILE *open_pdo_pipe(const char *fn, t_UmbrellaOptions *opt, gmx_bool *bPipeOpen)
{
- char Buffer[1024], gunzip[1024], *Path = 0;
- FILE *pipe = 0;
+ char Buffer[1024], gunzip[1024], *Path = nullptr;
+ FILE *pipe = nullptr;
static gmx_bool bFirst = 1;
/* gzipped pdo file? */
printf("Executing command '%s'\n", Buffer);
}
#if HAVE_PIPES
- if ((pipe = popen(Buffer, "r")) == NULL)
+ if ((pipe = popen(Buffer, "r")) == nullptr)
{
gmx_fatal(FARGS, "Unable to open pipe to `%s'\n", Buffer);
}
}
read_pdo_header(file, header, opt);
/* here only determine min and max of this window */
- read_pdo_data(file, header, i, NULL, opt, TRUE, &mintmp, &maxtmp);
+ read_pdo_data(file, header, i, nullptr, opt, TRUE, &mintmp, &maxtmp);
if (maxtmp > opt->max)
{
opt->max = maxtmp;
file = open_pdo_pipe(fn[i], opt, &bPipeOpen);
read_pdo_header(file, header, opt);
/* load data into window */
- read_pdo_data(file, header, i, window, opt, FALSE, NULL, NULL);
+ read_pdo_data(file, header, i, window, opt, FALSE, nullptr, nullptr);
if ((window+i)->Ntot[0] == 0)
{
fprintf(stderr, "\nWARNING, no data points read from file %s (check -b option)\n", fn[i]);
static int first = 1;
/* printf("Reading %s \n",fn); */
- read_tpx_state(fn, ir, &state, NULL);
+ read_tpx_state(fn, ir, &state, nullptr);
if (!ir->bPull)
{
bool geometryIsSet = false;
for (int i = 0; i < ir->pull->ncoord; i++)
{
- if (coordsel == NULL || coordsel->bUse[i])
+ if (coordsel == nullptr || coordsel->bUse[i])
{
if (header->pcrd[i].pull_type != epullUMBRELLA)
{
maxlen+1);
for (int i = 0; i < ir->pull->ncoord; i++)
{
- bool use = (coordsel == NULL || coordsel->bUse[i]);
+ bool use = (coordsel == nullptr || coordsel->bUse[i]);
printf(fmt,
epullg_names[header->pcrd[i].geometry], header->pcrd[i].k, header->pcrd[i].init_dist,
int2YN(header->pcrd[i].dim[XX]), int2YN(header->pcrd[i].dim[YY]), int2YN(header->pcrd[i].dim[ZZ]),
gmx_bool bGetMinMax, real *mintmp, real *maxtmp,
t_coordselection *coordsel)
{
- double **y = 0, pos = 0., t, force, time0 = 0., dt;
+ double **y = nullptr, pos = 0., t, force, time0 = 0., dt;
int ny, nt, bins, ibin, i, g, gUsed, dstep = 1;
int nColExpect, ntot, column;
real min, max, minfound = 1e20, maxfound = -1e20;
gmx_bool dt_ok, timeok;
const char *quantity;
const int blocklen = 4096;
- int *lennow = 0;
+ int *lennow = nullptr;
static gmx_bool bFirst = TRUE;
/*
snew(window->Ntot, window->nPull);
snew(window->g, window->nPull);
snew(window->bsWeight, window->nPull);
- window->bContrib = 0;
+ window->bContrib = nullptr;
if (opt->bCalcTauInt)
{
}
else
{
- window->ztime = NULL;
+ window->ztime = nullptr;
}
snew(lennow, window->nPull);
if (opt->bCalcTauInt)
{
- window->ztime[g] = NULL;
+ window->ztime[g] = nullptr;
}
}
{
gmx_fatal(FARGS, "Expected the %d'th file in input file to be a tpr file\n", i);
}
- read_tpr_header(fnTprs[i], header, opt, (opt->nCoordsel > 0) ? &opt->coordsel[i] : NULL);
+ read_tpr_header(fnTprs[i], header, opt, (opt->nCoordsel > 0) ? &opt->coordsel[i] : nullptr);
if (whaminFileType(fnPull[i]) != whamin_pullxf)
{
gmx_fatal(FARGS, "Expected the %d'th file in input file to be a xvg (pullx/pullf) file\n", i);
}
- read_pull_xf(fnPull[i], header, NULL, opt, TRUE, &mintmp, &maxtmp,
- (opt->nCoordsel > 0) ? &opt->coordsel[i] : NULL);
+ read_pull_xf(fnPull[i], header, nullptr, opt, TRUE, &mintmp, &maxtmp,
+ (opt->nCoordsel > 0) ? &opt->coordsel[i] : nullptr);
if (maxtmp > opt->max)
{
opt->max = maxtmp;
{
gmx_fatal(FARGS, "Expected the %d'th file in input file to be a tpr file\n", i);
}
- read_tpr_header(fnTprs[i], header, opt, (opt->nCoordsel > 0) ? &opt->coordsel[i] : NULL);
+ read_tpr_header(fnTprs[i], header, opt, (opt->nCoordsel > 0) ? &opt->coordsel[i] : nullptr);
if (whaminFileType(fnPull[i]) != whamin_pullxf)
{
gmx_fatal(FARGS, "Expected the %d'th file in input file to be a xvg (pullx/pullf) file\n", i);
}
- read_pull_xf(fnPull[i], header, window+i, opt, FALSE, NULL, NULL,
- (opt->nCoordsel > 0) ? &opt->coordsel[i] : NULL);
+ read_pull_xf(fnPull[i], header, window+i, opt, FALSE, nullptr, nullptr,
+ (opt->nCoordsel > 0) ? &opt->coordsel[i] : nullptr);
if (window[i].Ntot[0] == 0)
{
fprintf(stderr, "\nWARNING, no data points read from file %s (check -b option)\n", fnPull[i]);
int i, ig, ncorr, ntot, j, k, *count, restart;
real *corr, c0, dt, tmp;
real *ztime, av, tausteps;
- FILE *fp, *fpcorr = 0;
+ FILE *fp, *fpcorr = nullptr;
if (opt->verbose)
{
{
FILE *fp;
int i, iline, n, len = STRLEN, temp;
- char *ptr = 0, *tmpbuf = 0;
+ char *ptr = nullptr, *tmpbuf = nullptr;
char fmt[1024], fmtign[1024];
int block = 1, sizenow;
fp = gmx_ffopen(opt->fnCoordSel, "r");
- opt->coordsel = NULL;
+ opt->coordsel = nullptr;
snew(tmpbuf, len);
sizenow = 0;
iline = 0;
- while ( (ptr = fgets3(fp, tmpbuf, &len)) != NULL)
+ while ( (ptr = fgets3(fp, tmpbuf, &len)) != nullptr)
{
trim(ptr);
n = wordcount(ptr);
"the histograms."
};
- const char *en_unit[] = {NULL, "kJ", "kCal", "kT", NULL};
- const char *en_unit_label[] = {"", "E (kJ mol\\S-1\\N)", "E (kcal mol\\S-1\\N)", "E (kT)", NULL};
- const char *en_bsMethod[] = { NULL, "b-hist", "hist", "traj", "traj-gauss", NULL };
+ const char *en_unit[] = {nullptr, "kJ", "kCal", "kT", nullptr};
+ const char *en_unit_label[] = {"", "E (kJ mol\\S-1\\N)", "E (kcal mol\\S-1\\N)", "E (kT)", nullptr};
+ const char *en_bsMethod[] = { nullptr, "b-hist", "hist", "traj", "traj-gauss", nullptr };
static t_UmbrellaOptions opt;
t_pargs pa[] = {
int i, j, l, nfiles, nwins, nfiles2;
t_UmbrellaHeader header;
- t_UmbrellaWindow * window = NULL;
+ t_UmbrellaWindow * window = nullptr;
double *profile, maxchange = 1e20;
gmx_bool bMinSet, bMaxSet, bAutoSet, bExact = FALSE;
char **fninTpr, **fninPull, **fninPdo;
opt.max = 0;
opt.bAuto = TRUE;
opt.nCoordsel = 0;
- opt.coordsel = NULL;
+ opt.coordsel = nullptr;
/* bootstrapping stuff */
opt.nBootStrap = 0;
opt.stepUpdateContrib = 100;
if (!parse_common_args(&argc, argv, 0,
- NFILE, fnm, asize(pa), pa, asize(desc), desc, 0, NULL, &opt.oenv))
+ NFILE, fnm, asize(pa), pa, asize(desc), desc, 0, nullptr, &opt.oenv))
{
return 0;
}
}
/* Read file that selects the pull group to be used */
- if (opt.fnCoordSel != NULL)
+ if (opt.fnCoordSel != nullptr)
{
readPullCoordSelection(&opt, fninTpr, nfiles);
}
}
else
{ /* reading pdo files */
- if (opt.fnCoordSel != NULL)
+ if (opt.fnCoordSel != nullptr)
{
gmx_fatal(FARGS, "Reading a -is file is not supported with PDO input files.\n"
"Use awk or a similar tool to pick the required pull groups from your PDO files\n");