Supported quiet trajectory-handling I/O
authorChristoph Junghans <junghans@votca.org>
Sun, 13 Aug 2017 15:52:18 +0000 (09:52 -0600)
committerMark Abraham <mark.j.abraham@gmail.com>
Tue, 5 Sep 2017 16:30:44 +0000 (18:30 +0200)
Permits GMX_TRAJECTORY_IO_VERBOSITY=0 to be set to keep frame-reading
code quiet, which is convenient for tools using libgromacs.

Change-Id: I873dcf229d9c20c8dd3b5097784236c2c2c478c1

docs/user-guide/environment-variables.rst
src/gromacs/fileio/oenv.cpp
src/gromacs/fileio/oenv.h
src/gromacs/fileio/trxio.cpp

index 15e1be8166af7ecea0553aa9b5d498018ea35519..597ed8f900e9f36f5ebd5cf9bf01568ee4c42213 100644 (file)
@@ -74,6 +74,10 @@ Output Control
         :ref:`pdb` file, which allows to check whether multimeric channels have
         the correct PBC representation.
 
+``GMX_TRAJECTORY_IO_VERBOSITY``
+        Defaults to 1, which prints frame count e.g. when reading trajectory
+        files. Set to 0 for quiet operation.
+
 Debugging
 ---------
 ``GMX_PRINT_DEBUG_LINES``
index a00699208499f533fd58515c998aab96a414fadf..9a9c6c2d44cd15674f806c8800e5960ae17aa522 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.
@@ -47,10 +47,11 @@ struct gmx_output_env_t
     explicit gmx_output_env_t(const gmx::IProgramContext &context)
         : programContext(context)
     {
-        time_unit   = time_ps;
-        view        = FALSE;
-        xvg_format  = exvgNONE;
-        verbosity   = 0;
+        time_unit               = time_ps;
+        view                    = FALSE;
+        xvg_format              = exvgNONE;
+        verbosity               = 0;
+        trajectory_io_verbosity = 1;
     }
 
     const gmx::IProgramContext  &programContext;
@@ -63,6 +64,8 @@ struct gmx_output_env_t
     xvg_format_t                         xvg_format;
     /* The level of verbosity for this program */
     int                                  verbosity;
+    /* The level of verbosity during trajectory I/O. Default=1, quiet=0. */
+    int                                  trajectory_io_verbosity;
 };
 
 /* The source code in this file should be thread-safe.
@@ -103,6 +106,9 @@ void output_env_init(gmx_output_env_t **oenvp,
         oenv->view        = view;
         oenv->xvg_format  = xvg_format;
         oenv->verbosity   = verbosity;
+        const char *env = getenv("GMX_TRAJECTORY_IO_VERBOSITY");
+        oenv->trajectory_io_verbosity = (env != nullptr ? strtol(env, NULL, 10) : 1);
+
     }
     GMX_CATCH_ALL_AND_EXIT_WITH_FATAL_ERROR;
 }
@@ -128,6 +134,11 @@ int output_env_get_verbosity(const gmx_output_env_t *oenv)
     return oenv->verbosity;
 }
 
+int output_env_get_trajectory_io_verbosity(const gmx_output_env_t *oenv)
+{
+    return oenv->trajectory_io_verbosity;
+}
+
 const char *output_env_get_time_unit(const gmx_output_env_t *oenv)
 {
     return time_units_str[oenv->time_unit];
index e3dcecc4032b4c99876df6a68dda65640d652b6b..58ec84ec972181688640e6d84f6443ba90995658 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) 2012,2014,2015, by the GROMACS development team, led by
+ * Copyright (c) 2012,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.
@@ -48,8 +48,9 @@ struct gmx_output_env_t;
 
 /* output_env member functions */
 
-/* The output_env structure holds information about program name, cmd line,
-   default times, etc.
+/* The output_env structure holds information about program name, cmd
+   line, default times, etc. along with verbosity levels for code
+   components that use this structure for regulating output.
 
    There are still legacy functions for the program name, and the command
    line, but the output_env versions are now preferred.*/
@@ -77,6 +78,9 @@ void output_env_done(gmx_output_env_t *oenv);
 int output_env_get_verbosity(const gmx_output_env_t *oenv);
 /* return the verbosity */
 
+int output_env_get_trajectory_io_verbosity(const gmx_output_env_t *oenv);
+/* return the verbosity for trajectory IO handling */
+
 const char *output_env_get_time_unit(const gmx_output_env_t *oenv);
 /* return time unit (e.g. ps or ns) */
 
index 94432e65f9fc9e85a7c3fc4d25efded40d4fc565..f25eaa1e01aa3833ef80a661983446d755682915 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.
@@ -191,7 +191,8 @@ static void printcount_(t_trxstatus *status, const gmx_output_env_t *oenv,
 {
     if ((status->__frame < 2*SKIP1 || status->__frame % SKIP1 == 0) &&
         (status->__frame < 2*SKIP2 || status->__frame % SKIP2 == 0) &&
-        (status->__frame < 2*SKIP3 || status->__frame % SKIP3 == 0))
+        (status->__frame < 2*SKIP3 || status->__frame % SKIP3 == 0) &&
+        output_env_get_trajectory_io_verbosity(oenv) != 0)
     {
         fprintf(stderr, "\r%-14s %6d time %8.3f   ", l, status->__frame,
                 output_env_conv_time(oenv, t));