/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2010,2011,2012,2013,2014,2015, by the GROMACS development team, led by
+ * Copyright (c) 2010,2011,2012,2013,2014,2015,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.
{
return FALSE;
}
- if (name == NULL && lc->names[index] == NULL)
+ if (name == nullptr && lc->names[index] == nullptr)
{
return TRUE;
}
- if ((name == NULL) != (lc->names[index] == NULL))
+ if ((name == nullptr) != (lc->names[index] == nullptr))
{
return FALSE;
}
static void xvg_init(xvg_t *ba)
{
- ba->filename = NULL;
+ ba->filename = nullptr;
ba->nset = 0;
ba->np_alloc = 0;
- ba->np = NULL;
- ba->y = NULL;
+ ba->np = nullptr;
+ ba->y = nullptr;
}
static void samples_init(samples_t *s, lambda_vec_t *native_lambda,
s->derivative = derivative;
s->ndu = 0;
- s->du = NULL;
- s->t = NULL;
+ s->du = nullptr;
+ s->t = nullptr;
s->start_time = s->delta_time = 0;
- s->hist = NULL;
- s->du_alloc = NULL;
- s->t_alloc = NULL;
- s->hist_alloc = NULL;
+ s->hist = nullptr;
+ s->du_alloc = nullptr;
+ s->t_alloc = nullptr;
+ s->hist_alloc = nullptr;
s->ndu_alloc = 0;
s->nt_alloc = 0;
r->start = 0;
r->end = s->ndu;
r->use = TRUE;
- r->s = NULL;
+ r->s = nullptr;
}
static void sample_coll_init(sample_coll_t *sc, lambda_vec_t *native_lambda,
sc->temp = temp;
sc->nsamples = 0;
- sc->s = NULL;
- sc->r = NULL;
+ sc->s = nullptr;
+ sc->r = nullptr;
sc->nsamples_alloc = 0;
sc->ntot = 0;
- sc->next = sc->prev = NULL;
+ sc->next = sc->prev = nullptr;
}
static void sample_coll_destroy(sample_coll_t *sc)
l->lambda = native_lambda;
l->temp = temp;
- l->next = NULL;
- l->prev = NULL;
+ l->next = nullptr;
+ l->prev = nullptr;
l->sc = &(l->sc_head);
- sample_coll_init(l->sc, native_lambda, NULL, 0.);
+ sample_coll_init(l->sc, native_lambda, nullptr, 0.);
l->sc->next = l->sc;
l->sc->prev = l->sc;
}
br->dg_stddev = 0;
br->dg_stddev_err = 0;
- br->a = NULL;
- br->b = NULL;
+ br->a = nullptr;
+ br->b = nullptr;
}
sc = sc->next;
}
- return NULL;
+ return nullptr;
}
/* insert li into an ordered list of lambda_colls */
FILE *fp;
lambda_data_t *bl;
int nsets = 0;
- char **setnames = NULL;
+ char **setnames = nullptr;
gmx_bool first_set = FALSE;
/* histogram data: */
- int *hist = NULL;
+ int *hist = nullptr;
int nbin = 0;
int nbin_alloc = 0;
double dx = 0;
{
if (!first_set)
{
- xvgr_new_dataset(fp, 0, 0, NULL, oenv);
+ xvgr_new_dataset(fp, 0, 0, nullptr, oenv);
}
sample_coll_make_hist(sc, &hist, &nbin_alloc, &nbin, &dx, &minval,
gmx_bool name_end_found = FALSE;
/* if the string is a NULL pointer, return a NULL pointer. */
- if (str == NULL)
+ if (str == nullptr)
{
- return NULL;
+ return nullptr;
}
while (*str != '\0')
{
}
str++;
}
- return NULL;
+ return nullptr;
}
const char **end,
const char *fn)
{
- gmx_bool initialize_lc = FALSE; /* whether to initialize the lambda
- components, or to check them */
- gmx_bool start_reached = FALSE; /* whether the start of component names
- has been reached */
- gmx_bool vector = FALSE; /* whether there are multiple components */
- int n = 0; /* current component number */
- const char *val_start = NULL; /* start of the component name, or NULL
- if not in a value */
+ gmx_bool initialize_lc = FALSE; /* whether to initialize the lambda
+ components, or to check them */
+ gmx_bool start_reached = FALSE; /* whether the start of component names
+ has been reached */
+ gmx_bool vector = FALSE; /* whether there are multiple components */
+ int n = 0; /* current component number */
+ const char *val_start = nullptr; /* start of the component name, or NULL
+ if not in a value */
char *strtod_end;
gmx_bool OK = TRUE;
initialize_lc = TRUE;
}
- if (lc_in == NULL)
+ if (lc_in == nullptr)
{
lc_in = lc_out;
}
if (std::isspace(*str) || *str == ')' || *str == ',' || *str == '\0')
{
/* end of value */
- if (lv == NULL)
+ if (lv == nullptr)
{
if (initialize_lc)
{
}
}
/* reset for the next identifier */
- val_start = NULL;
+ val_start = nullptr;
n++;
if (!vector)
{
}
else
{
- GMX_RELEASE_ASSERT(lc_in != NULL, "Internal inconsistency? lc_in==NULL");
+ GMX_RELEASE_ASSERT(lc_in != nullptr, "Internal inconsistency? lc_in==NULL");
if (n == lc_in->N)
{
return OK;
}
- else if (lv == NULL)
+ else if (lv == nullptr)
{
return FALSE;
}
const char **end,
const char *fn)
{
- return read_lambda_compvec(str, NULL, NULL, lc, end, fn);
+ return read_lambda_compvec(str, nullptr, nullptr, lc, end, fn);
}
/* read an initialized lambda vector from a string */
const char **end,
const char *fn)
{
- return read_lambda_compvec(str, lv, lv->lc, NULL, end, fn);
+ return read_lambda_compvec(str, lv, lv->lc, nullptr, end, fn);
}
const char *legend,
lambda_vec_t *lam)
{
- const char *ptr = NULL, *ptr2 = NULL;
+ const char *ptr = nullptr, *ptr2 = nullptr;
gmx_bool ok = FALSE;
gmx_bool bdhdl = FALSE;
const char *tostr = " to ";
- if (legend == NULL)
+ if (legend == nullptr)
{
gmx_fatal(FARGS, "There is no legend in file '%s', can not deduce lambda", fn);
}
do
{
ptr2 = std::strstr(ptr2, tostr);
- if (ptr2 != NULL)
+ if (ptr2 != nullptr)
{
ptr = ptr2;
ptr2++;
}
}
- while (ptr2 != NULL && *ptr2 != '\0');
+ while (ptr2 != nullptr && *ptr2 != '\0');
if (ptr)
{
ok = TRUE;
bdhdl = TRUE;
}
- else if (std::strchr(legend, 'D') != NULL && std::strchr(legend, 'H') != NULL)
+ else if (std::strchr(legend, 'D') != nullptr && std::strchr(legend, 'H') != nullptr)
{
ok = TRUE;
bdhdl = FALSE;
if (!bdhdl)
{
ptr = find_value(ptr);
- if (!ptr || !read_lambda_vector(ptr, lam, NULL, fn))
+ if (!ptr || !read_lambda_vector(ptr, lam, nullptr, fn))
{
gmx_fatal(FARGS, "lambda vector '%s' %s faulty", legend, fn);
}
return FALSE;
}
lambda_vec_init(&(ba->native_lambda), lc);
- if (!read_lambda_vector(ptr, &(ba->native_lambda), NULL, fn))
+ if (!read_lambda_vector(ptr, &(ba->native_lambda), nullptr, fn))
{
gmx_fatal(FARGS, "lambda vector in %s faulty", fn);
}
/* compatibility mode: check for lambda in other ways. */
/* plain text lambda string */
ptr = std::strstr(subtitle, "lambda");
- if (ptr == NULL)
+ if (ptr == nullptr)
{
/* xmgrace formatted lambda string */
ptr = std::strstr(subtitle, "\\xl\\f{}");
}
- if (ptr == NULL)
+ if (ptr == nullptr)
{
/* xmgr formatted lambda string */
ptr = std::strstr(subtitle, "\\8l\\4");
}
- if (ptr != NULL)
+ if (ptr != nullptr)
{
ptr = std::strstr(ptr, "=");
}
- if (ptr != NULL)
+ if (ptr != nullptr)
{
bFound = (sscanf(ptr+1, "%lf", &(native_lambda)) == 1);
/* add the lambda component name as an empty string */
}
/* searching backward to find the second directory separator */
dirsep = 0;
- digitptr = NULL;
+ digitptr = nullptr;
while (ptr >= fn)
{
if (ptr[0] != DIR_SEPARATOR && ptr[1] == DIR_SEPARATOR)
}
ba->temp = -1;
- if (subtitle != NULL)
+ if (subtitle != nullptr)
{
/* try to extract temperature */
ptr = std::strstr(subtitle, "T =");
- if (ptr != NULL)
+ if (ptr != nullptr)
{
ptr += 3;
if (sscanf(ptr, "%lf", &ba->temp) == 1)
}
}
snew(ba->lambda, ba->nset);
- if (legend == NULL)
+ if (legend == nullptr)
{
/* Check if we have a single set, no legend, nset=1 means t and dH/dl */
if (ba->nset == 1)
gmx_fatal(FARGS, "File %s contains multiple sets but no indication of the native lambda", fn);
}
- if (legend != NULL)
+ if (legend != nullptr)
{
for (i = 0; i < ba->nset-1; i++)
{
nhist = blk->nsub-2;
if (nhist == 0)
{
- return NULL;
+ return nullptr;
}
if (nhist > 2)
{
ener_file_t fp;
t_enxframe *fr;
int nre;
- gmx_enxnm_t *enm = NULL;
+ gmx_enxnm_t *enm = nullptr;
double first_t = -1;
double last_t = -1;
- samples_t **samples_rawdh = NULL; /* contains samples for raw delta_h */
- int *nhists = NULL; /* array to keep count & print at end */
- int *npts = NULL; /* array to keep count & print at end */
- lambda_vec_t **lambdas = NULL; /* array to keep count & print at end */
+ samples_t **samples_rawdh = nullptr; /* contains samples for raw delta_h */
+ int *nhists = nullptr; /* array to keep count & print at end */
+ int *npts = nullptr; /* array to keep count & print at end */
+ lambda_vec_t **lambdas = nullptr; /* array to keep count & print at end */
lambda_vec_t *native_lambda;
int nsamples = 0;
lambda_vec_t start_lambda;
snew(fr, 1);
snew(native_lambda, 1);
- start_lambda.lc = NULL;
+ start_lambda.lc = nullptr;
while (do_enx(fp, fr))
{
{
nhists[i] = 0;
npts[i] = 0;
- lambdas[i] = NULL;
- samples_rawdh[i] = NULL; /* init to NULL so we know which
- ones contain values */
+ lambdas[i] = nullptr;
+ samples_rawdh[i] = nullptr; /* init to NULL so we know which
+ ones contain values */
}
}
else
// nsamples is always >0 here, so samples_rawdh must be a valid pointer. Unfortunately
// cppcheck does not understand the logic unless the assert is inside the loop, but
// this is not performance-sensitive code.
- GMX_RELEASE_ASSERT(samples_rawdh != NULL, "samples_rawdh==NULL with nsamples>0");
+ GMX_RELEASE_ASSERT(samples_rawdh != nullptr, "samples_rawdh==NULL with nsamples>0");
if (samples_rawdh[i])
{
/* insert it into the existing list */
samples_rawdh[i]);
/* and make sure we'll allocate a new one this time
around */
- samples_rawdh[i] = NULL;
+ samples_rawdh[i] = nullptr;
}
}
}
if (!parse_common_args(&argc, argv,
PCA_CAN_VIEW,
- NFILE, fnm, asize(pa), pa, asize(desc), desc, 0, NULL, &oenv))
+ NFILE, fnm, asize(pa), pa, asize(desc), desc, 0, nullptr, &oenv))
{
return 0;
}
- fpb = NULL;
+ fpb = nullptr;
if (opt2bSet("-o", NFILE, fnm))
{
sprintf(buf, "%s (%s)", "\\DeltaG", "kT");
"\\lambda", buf, exvggtXYDY, oenv);
}
- fpi = NULL;
+ fpi = nullptr;
if (opt2bSet("-oi", NFILE, fnm))
{
sprintf(buf, "%s (%s)", "\\DeltaG", "kT");
for (f = 0; f < nresults; f++)
{
- if (fpi != NULL)
+ if (fpi != nullptr)
{
lambda_vec_print_short(results[f].a->native_lambda, buf);
fprintf(fpi, xvg2format, buf, dg_tot);
}
- if (fpb != NULL)
+ if (fpb != nullptr)
{
lambda_vec_print_intermediate(results[f].a->native_lambda,
results[f].b->native_lambda,
printf("\n");
- if (fpi != NULL)
+ if (fpi != nullptr)
{
lambda_vec_print_short(results[nresults-1].b->native_lambda, buf);
fprintf(fpi, xvg2format, buf, dg_tot);
xvgrclose(fpi);
}
- if (fpb != NULL)
+ if (fpb != nullptr)
{
xvgrclose(fpb);
}