Tidy: modernize-use-nullptr
[alexxy/gromacs.git] / src / gromacs / gmxana / gmx_cluster.cpp
index f8a90473237217a3d612ec00d44377a889b5ab10..6dd4946104fce0724d2ef6d0d171f06eb68f78d0 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.
@@ -154,7 +154,7 @@ void mc_optimize(FILE *log, t_mat *m, real *time,
                  int seed, real kT,
                  const char *conv, gmx_output_env_t *oenv)
 {
-    FILE      *fp = NULL;
+    FILE      *fp = nullptr;
     real       ecur, enext, emin, prob, enorm;
     int        i, j, iswap, jswap, nn, nuphill = 0;
     t_mat     *minimum;
@@ -207,7 +207,7 @@ void mc_optimize(FILE *log, t_mat *m, real *time,
     minimum->nn = nn;
     copy_t_mat(minimum, m);
 
-    if (NULL != conv)
+    if (nullptr != conv)
     {
         fp = xvgropen(conv, "Convergence of the MC optimization",
                       "Energy", "Step", oenv);
@@ -257,7 +257,7 @@ void mc_optimize(FILE *log, t_mat *m, real *time,
 
             fprintf(log, "Iter: %d Swapped %4d and %4d (energy: %g prob: %g)\n",
                     i, iswap, jswap, enext, prob);
-            if (NULL != fp)
+            if (nullptr != fp)
             {
                 fprintf(fp, "%6d  %10g\n", i, enext);
             }
@@ -285,7 +285,7 @@ void mc_optimize(FILE *log, t_mat *m, real *time,
                 (i < m->nn-1) ? m->mat[m->m_ind[i]][m->m_ind[i+1]] : 0);
     }
 
-    if (NULL != fp)
+    if (nullptr != fp)
     {
         xvgrclose(fp);
     }
@@ -484,7 +484,7 @@ static void jarvis_patrick(int n1, real **mat, int M, int P,
     int       **nnb;
     int         i, j, k, cid, diff, maxval;
     gmx_bool    bChange;
-    real      **mcpy = NULL;
+    real      **mcpy = nullptr;
 
     if (rmsdcut < 0)
     {
@@ -773,8 +773,8 @@ rvec **read_whole_trj(const char *fn, int isize, int index[], int skip,
 
 
     max_nf = 0;
-    xx     = NULL;
-    *time  = NULL;
+    xx     = nullptr;
+    *time  = nullptr;
     natom  = read_first_x(oenv, &status, fn, &t, &x, box);
     i      = 0;
     i0     = 0;
@@ -993,20 +993,20 @@ static void analyze_clusters(int nf, t_clusters *clust, real **rmsd,
                              gmx_bool bFit, FILE *log, t_rgb rlo, t_rgb rhi,
                              const gmx_output_env_t *oenv)
 {
-    FILE        *size_fp = NULL;
+    FILE        *size_fp = nullptr;
     char         buf[STRLEN], buf1[40], buf2[40], buf3[40], *trxsfn;
-    t_trxstatus *trxout  = NULL;
-    t_trxstatus *trxsout = NULL;
+    t_trxstatus *trxout  = nullptr;
+    t_trxstatus *trxsout = nullptr;
     int          i, i1, cl, nstr, *structure, first = 0, midstr;
-    gmx_bool    *bWrite = NULL;
+    gmx_bool    *bWrite = nullptr;
     real         r, clrmsd, midrmsd;
-    rvec        *xav = NULL;
+    rvec        *xav = nullptr;
     matrix       zerobox;
 
     clear_mat(zerobox);
 
     ffprintf_d(stderr, log, buf, "\nFound %d clusters\n\n", clust->ncl);
-    trxsfn = NULL;
+    trxsfn = nullptr;
     if (trxfn)
     {
         /* do we write all structures? */
@@ -1053,7 +1053,7 @@ static void analyze_clusters(int nf, t_clusters *clust, real **rmsd,
         /* Prepare a reference structure for the orientation of the clusters  */
         if (bFit)
         {
-            reset_x(ifsize, fitidx, natom, NULL, xtps, mass);
+            reset_x(ifsize, fitidx, natom, nullptr, xtps, mass);
         }
         trxout = open_trx(trxfn, "w");
         /* Calculate the average structure in each cluster,               *
@@ -1113,7 +1113,7 @@ static void analyze_clusters(int nf, t_clusters *clust, real **rmsd,
                 {
                     if (bFit)
                     {
-                        reset_x(ifsize, fitidx, natom, NULL, xx[i1], mass);
+                        reset_x(ifsize, fitidx, natom, nullptr, xx[i1], mass);
                     }
                     if (nstr == 1)
                     {
@@ -1234,7 +1234,7 @@ static void analyze_clusters(int nf, t_clusters *clust, real **rmsd,
                     if (bWrite[i])
                     {
                         write_trx(trxsout, iosize, outidx, atoms, i, time[structure[i]], zerobox,
-                                  xx[structure[i]], NULL, NULL);
+                                  xx[structure[i]], nullptr, nullptr);
                     }
                 }
                 close_trx(trxsout);
@@ -1255,14 +1255,14 @@ static void analyze_clusters(int nf, t_clusters *clust, real **rmsd,
                 }
                 if (bFit)
                 {
-                    reset_x(ifsize, fitidx, natom, NULL, xav, mass);
+                    reset_x(ifsize, fitidx, natom, nullptr, xav, mass);
                 }
             }
             if (bFit)
             {
                 do_fit(natom, mass, xtps, xav);
             }
-            write_trx(trxout, iosize, outidx, atoms, cl, time[midstr], zerobox, xav, NULL, NULL);
+            write_trx(trxout, iosize, outidx, atoms, cl, time[midstr], zerobox, xav, nullptr, nullptr);
         }
     }
     /* clean up */
@@ -1397,28 +1397,28 @@ int gmx_cluster(int argc, char *argv[])
     gmx_int64_t        nrms = 0;
 
     matrix             box;
-    rvec              *xtps, *usextps, *x1, **xx = NULL;
+    rvec              *xtps, *usextps, *x1, **xx = nullptr;
     const char        *fn, *trx_out_fn;
     t_clusters         clust;
-    t_mat             *rms, *orig = NULL;
+    t_mat             *rms, *orig = nullptr;
     real              *eigenvalues;
     t_topology         top;
     int                ePBC;
     t_atoms            useatoms;
-    t_matrix          *readmat = NULL;
+    t_matrix          *readmat = nullptr;
     real              *eigenvectors;
 
     int                isize = 0, ifsize = 0, iosize = 0;
-    int               *index = NULL, *fitidx = NULL, *outidx = NULL;
+    int               *index = nullptr, *fitidx = nullptr, *outidx = nullptr;
     char              *grpname;
-    real               rmsd, **d1, **d2, *time = NULL, time_invfac, *mass = NULL;
+    real               rmsd, **d1, **d2, *time = nullptr, time_invfac, *mass = nullptr;
     char               buf[STRLEN], buf1[80], title[STRLEN];
     gmx_bool           bAnalyze, bUseRmsdCut, bJP_RMSD = FALSE, bReadMat, bReadTraj, bPBC = TRUE;
 
     int                method, ncluster = 0;
     static const char *methodname[] = {
-        NULL, "linkage", "jarvis-patrick", "monte-carlo",
-        "diagonalization", "gromos", NULL
+        nullptr, "linkage", "jarvis-patrick", "monte-carlo",
+        "diagonalization", "gromos", nullptr
     };
     enum {
         m_null, m_linkage, m_jarvis_patrick,
@@ -1436,7 +1436,7 @@ int gmx_cluster(int argc, char *argv[])
     static real       kT       = 1e-3;
     static int        M        = 10, P = 3;
     gmx_output_env_t *oenv;
-    gmx_rmpbc_t       gpbc = NULL;
+    gmx_rmpbc_t       gpbc = nullptr;
 
     t_pargs           pa[] = {
         { "-dista", FALSE, etBOOL, {&bRMSdist},
@@ -1484,9 +1484,9 @@ int gmx_cluster(int argc, char *argv[])
           { &bPBC }, "PBC check" }
     };
     t_filenm          fnm[] = {
-        { efTRX, "-f",     NULL,        ffOPTRD },
-        { efTPS, "-s",     NULL,        ffOPTRD },
-        { efNDX, NULL,     NULL,        ffOPTRD },
+        { efTRX, "-f",     nullptr,        ffOPTRD },
+        { efTPS, "-s",     nullptr,        ffOPTRD },
+        { efNDX, nullptr,     nullptr,        ffOPTRD },
         { efXPM, "-dm",   "rmsd",       ffOPTRD },
         { efXPM, "-om",   "rmsd-raw",   ffWRITE },
         { efXPM, "-o",    "rmsd-clust", ffWRITE },
@@ -1504,7 +1504,7 @@ int gmx_cluster(int argc, char *argv[])
 
     if (!parse_common_args(&argc, argv,
                            PCA_CAN_VIEW | PCA_CAN_TIME | PCA_TIME_UNIT,
-                           NFILE, fnm, asize(pa), pa, asize(desc), desc, 0, NULL,
+                           NFILE, fnm, asize(pa), pa, asize(desc), desc, 0, nullptr,
                            &oenv))
     {
         return 0;
@@ -1523,7 +1523,7 @@ int gmx_cluster(int argc, char *argv[])
     }
     else
     {
-        trx_out_fn = NULL;
+        trx_out_fn = nullptr;
     }
     if (bReadMat && output_env_get_time_factor(oenv) != 1)
     {
@@ -1611,7 +1611,7 @@ int gmx_cluster(int argc, char *argv[])
     if (bReadTraj)
     {
         /* don't read mass-database as masses (and top) are not used */
-        read_tps_conf(ftp2fn(efTPS, NFILE, fnm), &top, &ePBC, &xtps, NULL, box,
+        read_tps_conf(ftp2fn(efTPS, NFILE, fnm), &top, &ePBC, &xtps, nullptr, box,
                       TRUE);
         if (bPBC)
         {
@@ -1686,7 +1686,7 @@ int gmx_cluster(int argc, char *argv[])
             {
                 for (i = 0; i < nf; i++)
                 {
-                    reset_x(ifsize, fitidx, isize, NULL, xx[i], mass);
+                    reset_x(ifsize, fitidx, isize, nullptr, xx[i], mass);
                 }
             }
         }
@@ -1902,7 +1902,7 @@ int gmx_cluster(int argc, char *argv[])
         useatoms.nr = isize;
         analyze_clusters(nf, &clust, rms->mat, isize, &useatoms, usextps, mass, xx, time,
                          ifsize, fitidx, iosize, outidx,
-                         bReadTraj ? trx_out_fn : NULL,
+                         bReadTraj ? trx_out_fn : nullptr,
                          opt2fn_null("-sz", NFILE, fnm),
                          opt2fn_null("-tr", NFILE, fnm),
                          opt2fn_null("-ntr", NFILE, fnm),
@@ -1956,7 +1956,7 @@ int gmx_cluster(int argc, char *argv[])
     }
     fprintf(stderr, "\n");
     gmx_ffclose(fp);
-    if (NULL != orig)
+    if (nullptr != orig)
     {
         fp = opt2FILE("-om", NFILE, fnm, "w");
         sprintf(buf, "Time (%s)", output_env_get_time_unit(oenv));
@@ -1982,7 +1982,7 @@ int gmx_cluster(int argc, char *argv[])
         do_view(oenv, opt2fn_null("-ntr", NFILE, fnm), "-nxy");
         do_view(oenv, opt2fn_null("-clid", NFILE, fnm), "-nxy");
     }
-    do_view(oenv, opt2fn_null("-conv", NFILE, fnm), NULL);
+    do_view(oenv, opt2fn_null("-conv", NFILE, fnm), nullptr);
 
     return 0;
 }