Tidy: modernize-use-nullptr
[alexxy/gromacs.git] / src / gromacs / essentialdynamics / edsam.cpp
index df8e76e4452ee820192d4545ea039e559fcdc5d1..2f14c359ab0fad850fe9a563b78474d75d2621d0 100644 (file)
@@ -3,7 +3,7 @@
  *
  * 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.
@@ -573,7 +573,7 @@ static void do_edfit(int natoms, rvec *xp, rvec *x, matrix R, t_edpar *edi)
     struct t_do_edfit *loc;
     gmx_bool           bFirst;
 
-    if (edi->buf->do_edfit != NULL)
+    if (edi->buf->do_edfit != nullptr)
     {
         bFirst = FALSE;
     }
@@ -1189,7 +1189,7 @@ gmx_edsam_t ed_open(int natoms, edsamstate_t **EDstatePtr, int nfile, const t_fi
     /* Allocate space for the ED data structure */
     snew(ed, 1);
 
-    if (*EDstatePtr == NULL)
+    if (*EDstatePtr == nullptr)
     {
         snew(*EDstatePtr, 1);
     }
@@ -1465,13 +1465,13 @@ static int read_edint(FILE *file, gmx_bool *bEOF)
 
 
     eof = fgets2 (line, STRLEN, file);
-    if (eof == NULL)
+    if (eof == nullptr)
     {
         *bEOF = TRUE;
         return -1;
     }
     eof = fgets2 (line, STRLEN, file);
-    if (eof == NULL)
+    if (eof == nullptr)
     {
         *bEOF = TRUE;
         return -1;
@@ -1720,7 +1720,7 @@ static int read_edi(FILE* in, t_edpar *edi, int nr_mdatoms, const char *fn)
     snew(edi->sref.anrs, edi->sref.nr);
     snew(edi->sref.x, edi->sref.nr);
     snew(edi->sref.x_old, edi->sref.nr);
-    edi->sref.sqrtm    = NULL;
+    edi->sref.sqrtm    = nullptr;
     read_edx(in, edi->sref.nr, edi->sref.anrs, edi->sref.x);
 
     /* average positions. they define which atoms will be used for ED sampling */
@@ -1743,7 +1743,7 @@ static int read_edi(FILE* in, t_edpar *edi, int nr_mdatoms, const char *fn)
     {
         snew(edi->star.anrs, edi->star.nr);
         snew(edi->star.x, edi->star.nr);
-        edi->star.sqrtm    = NULL;
+        edi->star.sqrtm    = nullptr;
         read_edx(in, edi->star.nr, edi->star.anrs, edi->star.x);
     }
 
@@ -1760,7 +1760,7 @@ static int read_edi(FILE* in, t_edpar *edi, int nr_mdatoms, const char *fn)
         }
         snew(edi->sori.anrs, edi->sori.nr);
         snew(edi->sori.x, edi->sori.nr);
-        edi->sori.sqrtm    = NULL;
+        edi->sori.sqrtm    = nullptr;
         read_edx(in, edi->sori.nr, edi->sori.anrs, edi->sori.x);
     }
 
@@ -1810,7 +1810,7 @@ static int read_edi_file(const char *fn, t_edpar *edi, int nr_mdatoms)
     }
 
     /* Terminate the edi group list with a NULL pointer: */
-    last_edi->next_edi = NULL;
+    last_edi->next_edi = nullptr;
 
     fprintf(stderr, "ED: Found %d ED group%s.\n", edi_nr, edi_nr > 1 ? "s" : "");
 
@@ -1840,7 +1840,7 @@ static void fit_to_reference(rvec      *xcoll,    /* The positions to be fitted
 
 
     /* Allocate memory the first time this routine is called for each edi group */
-    if (NULL == edi->buf->fit_to_ref)
+    if (nullptr == edi->buf->fit_to_ref)
     {
         snew(edi->buf->fit_to_ref, 1);
         snew(edi->buf->fit_to_ref->xcopy, edi->sref.nr);
@@ -2140,7 +2140,7 @@ static void do_radcon(rvec *xcoll, t_edpar *edi)
     rvec                vec_dum;
 
 
-    if (edi->buf->do_radcon != NULL)
+    if (edi->buf->do_radcon != nullptr)
     {
         bFirst = FALSE;
     }
@@ -2303,7 +2303,7 @@ static void copyEvecReference(t_eigvec* floodvecs)
     int i;
 
 
-    if (NULL == floodvecs->refproj0)
+    if (nullptr == floodvecs->refproj0)
     {
         snew(floodvecs->refproj0, floodvecs->neig);
     }
@@ -2319,11 +2319,11 @@ static void copyEvecReference(t_eigvec* floodvecs)
  * groups of the checkpoint file are consistent with the provided .edi file. */
 static void crosscheck_edi_file_vs_checkpoint(gmx_edsam_t ed, edsamstate_t *EDstate)
 {
-    t_edpar *edi = NULL;    /* points to a single edi data set */
+    t_edpar *edi = nullptr;    /* points to a single edi data set */
     int      edinum;
 
 
-    if (NULL == EDstate->nref || NULL == EDstate->nav)
+    if (nullptr == EDstate->nref || nullptr == EDstate->nav)
     {
         gmx_fatal(FARGS, "Essential dynamics and flooding can only be switched on (or off) at the\n"
                   "start of a new simulation. If a simulation runs with/without ED constraints,\n"
@@ -2334,7 +2334,7 @@ static void crosscheck_edi_file_vs_checkpoint(gmx_edsam_t ed, edsamstate_t *EDst
 
     edi    = ed->edpar;
     edinum = 0;
-    while (edi != NULL)
+    while (edi != nullptr)
     {
         /* Check number of atoms in the reference and average structures */
         if (EDstate->nref[edinum] != edi->sref.nr)
@@ -2470,12 +2470,12 @@ static void nice_legend_evec(const char ***setname, int *nsets, char **LegendStr
 /* Makes a legend for the xvg output file. Call on MASTER only! */
 static void write_edo_legend(gmx_edsam_t ed, int nED, const gmx_output_env_t *oenv)
 {
-    t_edpar     *edi = NULL;
+    t_edpar     *edi = nullptr;
     int          i;
     int          nr_edi, nsets, n_flood, n_edsam;
     const char **setname;
     char         buf[STRLEN];
-    char        *LegendStr = NULL;
+    char        *LegendStr = nullptr;
 
 
     edi         = ed->edpar;
@@ -2653,19 +2653,19 @@ void init_edsam(const gmx_mtop_t *mtop,
                 matrix            box,
                 edsamstate_t     *EDstate)
 {
-    t_edpar *edi = NULL;                    /* points to a single edi data set */
+    t_edpar *edi = nullptr;                       /* points to a single edi data set */
     int      i, nr_edi, avindex;
-    rvec    *x_pbc  = NULL;                 /* positions of the whole MD system with pbc removed  */
-    rvec    *xfit   = NULL, *xstart = NULL; /* dummy arrays to determine initial RMSDs  */
-    rvec     fit_transvec;                  /* translation ... */
-    matrix   fit_rotmat;                    /* ... and rotation from fit to reference structure */
-    rvec    *ref_x_old = NULL;              /* helper pointer */
+    rvec    *x_pbc  = nullptr;                    /* positions of the whole MD system with pbc removed  */
+    rvec    *xfit   = nullptr, *xstart = nullptr; /* dummy arrays to determine initial RMSDs  */
+    rvec     fit_transvec;                        /* translation ... */
+    matrix   fit_rotmat;                          /* ... and rotation from fit to reference structure */
+    rvec    *ref_x_old = nullptr;                 /* helper pointer */
 
     if (MASTER(cr))
     {
         fprintf(stderr, "ED: Initializing essential dynamics constraints.\n");
 
-        if (NULL == ed)
+        if (nullptr == ed)
         {
             gmx_fatal(FARGS, "The checkpoint file you provided is from an essential dynamics or\n"
                       "flooding simulation. Please also provide the correct .edi file with -ei.\n");
@@ -2685,7 +2685,7 @@ void init_edsam(const gmx_mtop_t *mtop,
          * as well, but will be done in the order given in the edi file, so
          * expect different results for different order of edi file concatenation! */
         edi = ed->edpar;
-        while (edi != NULL)
+        while (edi != nullptr)
         {
             init_edi(mtop, edi);
             init_flood(edi, ed, ir->delta_t);
@@ -2702,7 +2702,7 @@ void init_edsam(const gmx_mtop_t *mtop,
             /* Remove PBC, make molecule(s) subject to ED whole. */
             snew(x_pbc, mtop->natoms);
             copy_rvecn(x, x_pbc, 0, mtop->natoms);
-            do_pbc_first_mtop(NULL, ir->ePBC, box, mtop, x_pbc);
+            do_pbc_first_mtop(nullptr, ir->ePBC, box, mtop, x_pbc);
         }
         /* Reset pointer to first ED data set which contains the actual ED data */
         edi = ed->edpar;
@@ -3025,7 +3025,7 @@ void do_edsam(const t_inputrec *ir,
     /* Loop over all ED groups (usually one) */
     edi   = ed->edpar;
     edinr = 0;
-    while (edi != NULL)
+    while (edi != nullptr)
     {
         edinr++;
         if (bNeedDoEdsam(edi))
@@ -3156,7 +3156,7 @@ void do_edsam(const t_inputrec *ir,
                     /* dx is the ED correction to the positions: */
                     rvec_sub(x_unsh, xs[edi->sav.anrs_loc[i]], dx);
 
-                    if (v != NULL)
+                    if (v != nullptr)
                     {
                         /* dv is the ED correction to the velocity: */
                         svmul(dt_1, dx, dv);