Use more MDLogger in preprocessing
[alexxy/gromacs.git] / src / gromacs / gmxpreprocess / gen_maxwell_velocities.cpp
index eb28f8a142fa04f1b31884406cd5968ce10d0c0d..41d53a1d3c4d589b2e9d90da34a091f2e8cea082 100644 (file)
 #include "gromacs/topology/mtop_util.h"
 #include "gromacs/topology/topology.h"
 #include "gromacs/utility/fatalerror.h"
+#include "gromacs/utility/logger.h"
 #include "gromacs/utility/smalloc.h"
 
-static void low_mspeed(real tempi, gmx_mtop_t* mtop, rvec v[], gmx::ThreeFry2x64<>* rng)
+static void low_mspeed(real tempi, gmx_mtop_t* mtop, rvec v[], gmx::ThreeFry2x64<>* rng, const gmx::MDLogger& logger)
 {
     int                                    nrdf;
     real                                   boltz;
@@ -90,7 +91,9 @@ static void low_mspeed(real tempi, gmx_mtop_t* mtop, rvec v[], gmx::ThreeFry2x64
             }
         }
     }
-    fprintf(stderr, "Velocities were taken from a Maxwell distribution at %g K\n", tempi);
+    GMX_LOG(logger.info)
+            .asParagraph()
+            .appendTextFormatted("Velocities were taken from a Maxwell distribution at %g K", tempi);
     if (debug)
     {
         fprintf(debug,
@@ -100,17 +103,19 @@ static void low_mspeed(real tempi, gmx_mtop_t* mtop, rvec v[], gmx::ThreeFry2x64
     }
 }
 
-void maxwell_speed(real tempi, unsigned int seed, gmx_mtop_t* mtop, rvec v[])
+void maxwell_speed(real tempi, unsigned int seed, gmx_mtop_t* mtop, rvec v[], const gmx::MDLogger& logger)
 {
 
     if (seed == 0)
     {
         seed = static_cast<int>(gmx::makeRandomSeed());
-        fprintf(stderr, "Using random seed %u for generating velocities\n", seed);
+        GMX_LOG(logger.info)
+                .asParagraph()
+                .appendTextFormatted("Using random seed %u for generating velocities", seed);
     }
     gmx::ThreeFry2x64<> rng(seed, gmx::RandomDomain::MaxwellVelocities);
 
-    low_mspeed(tempi, mtop, v, &rng);
+    low_mspeed(tempi, mtop, v, &rng, logger);
 }
 
 static real calc_cm(int natoms, const real mass[], rvec x[], rvec v[], rvec xcm, rvec vcm, rvec acm, matrix L)
@@ -175,14 +180,14 @@ static real calc_cm(int natoms, const real mass[], rvec x[], rvec v[], rvec xcm,
     return tm;
 }
 
-void stop_cm(FILE gmx_unused* log, int natoms, real mass[], rvec x[], rvec v[])
+void stop_cm(const gmx::MDLogger gmx_unused& logger, int natoms, real mass[], rvec x[], rvec v[])
 {
     rvec   xcm, vcm, acm;
     tensor L;
     int    i, m;
 
 #ifdef DEBUG
-    fprintf(log, "stopping center of mass motion...\n");
+    GMX_LOG(logger.info).asParagraph().appendTextFormatted("stopping center of mass motion...");
 #endif
     (void)calc_cm(natoms, mass, x, v, xcm, vcm, acm, L);
 
@@ -194,8 +199,4 @@ void stop_cm(FILE gmx_unused* log, int natoms, real mass[], rvec x[], rvec v[])
             v[i][m] -= vcm[m];
         }
     }
-
-#ifdef DEBUG
-    (void)calc_cm(log, natoms, mass, x, v, xcm, vcm, acm, L);
-#endif
 }