From: Christoph Junghans Date: Sun, 13 Aug 2017 15:52:18 +0000 (-0600) Subject: Supported quiet trajectory-handling I/O X-Git-Url: http://biod.pnpi.spb.ru/gitweb/?a=commitdiff_plain;h=e8000a3a8a9f93a09fb648bd5338230b945abf1b;p=alexxy%2Fgromacs.git Supported quiet trajectory-handling I/O 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 --- diff --git a/docs/user-guide/environment-variables.rst b/docs/user-guide/environment-variables.rst index 15e1be8166..597ed8f900 100644 --- a/docs/user-guide/environment-variables.rst +++ b/docs/user-guide/environment-variables.rst @@ -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`` diff --git a/src/gromacs/fileio/oenv.cpp b/src/gromacs/fileio/oenv.cpp index a006992084..9a9c6c2d44 100644 --- a/src/gromacs/fileio/oenv.cpp +++ b/src/gromacs/fileio/oenv.cpp @@ -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]; diff --git a/src/gromacs/fileio/oenv.h b/src/gromacs/fileio/oenv.h index e3dcecc403..58ec84ec97 100644 --- a/src/gromacs/fileio/oenv.h +++ b/src/gromacs/fileio/oenv.h @@ -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) */ diff --git a/src/gromacs/fileio/trxio.cpp b/src/gromacs/fileio/trxio.cpp index 94432e65f9..f25eaa1e01 100644 --- a/src/gromacs/fileio/trxio.cpp +++ b/src/gromacs/fileio/trxio.cpp @@ -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));