Allow explicit reset of simulation stop condition.
authorM. Eric Irrgang <ericirrgang@gmail.com>
Fri, 24 Aug 2018 11:26:41 +0000 (14:26 +0300)
committerM. Eric Irrgang <ericirrgang@gmail.com>
Tue, 25 Sep 2018 15:25:44 +0000 (18:25 +0300)
Grant client code the ability to reset the global stop condition. This
is a necessary (but not sufficient) provision to allow multiple
simulations in the lifetime of a single process.

Change-Id: Ib755b9bffc71aef43c6e20988f2ae9994cb426b4

src/gromacs/mdlib/CMakeLists.txt
src/gromacs/mdlib/sighandler.cpp
src/gromacs/mdlib/sighandler.h
src/gromacs/mdlib/simulationsignal.h

index 346a184fe916f99b0aff1876488cd3c584441cea..7bd5081d7e6f4dc73c7d9cfd4acf584c4c1283f9 100644 (file)
@@ -1,7 +1,7 @@
 #
 # This file is part of the GROMACS molecular simulation package.
 #
-# Copyright (c) 2010,2012,2013,2014,2015, by the GROMACS development team, led by
+# Copyright (c) 2010,2012,2013,2014,2015,2018, 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.
@@ -46,3 +46,5 @@ set(MDLIB_SOURCES ${MDLIB_SOURCES} PARENT_SCOPE)
 if (BUILD_TESTING)
     add_subdirectory(tests)
 endif()
+
+gmx_install_headers(simulationsignal.h)
index 430edc29d8175df1ce65a1483dd9c9c7a1bb09e6..c0d394a1fb0478f54f03a36cc4bdf9105a82e6d1 100644 (file)
@@ -72,6 +72,12 @@ static volatile sig_atomic_t last_signal_name = 0;
 
 static volatile sig_atomic_t usr_condition = 0;
 
+void gmx_reset_stop_condition()
+{
+    stop_condition   = gmx_stop_cond_none;
+    // last_signal_name and usr_condition are left untouched by reset.
+}
+
 static void signal_handler(int n)
 {
     switch (n)
index 616dfc6c4a809851af66153ca135b7e07b68331b..6ed971178ef56280b7d2d2995f58783ecd891aa4 100644 (file)
@@ -69,6 +69,20 @@ gmx_stop_cond_t gmx_get_stop_condition();
 /* set the stop condition upon receiving a remote one */
 void gmx_set_stop_condition(gmx_stop_cond_t recvd_stop_cond);
 
+/*!
+ * \brief Reinitializes the global stop condition.
+ *
+ * Resets any stop condition currently stored in global library state as read or
+ * written with gmx_get_stop_condition() and gmx_set_stop_condition(). Does not
+ * affect the result of gmx_got_usr_signal() gmx_get_signal_name() for
+ * previously terminated simulations.
+ *
+ * The reset is necessary between simulation segments performed in the same
+ * process and should be called only while simulation is idle, such as after
+ * a gmx::Mdrunner has finished its work and simulation results have been processed.
+ */
+void gmx_reset_stop_condition();
+
 /* get the signal name that lead to the current stop condition. */
 const char *gmx_get_signal_name();
 
index 4d7ba8bc461f9ccd798da2a16d2377de7ed154ca..9b6f455d7bc48c565b3130063f6feaf9c57c6660 100644 (file)
@@ -34,7 +34,7 @@
  * To help us fund GROMACS development, we humbly ask that you cite
  * the research papers on the package. Check out http://www.gromacs.org.
  */
-/*! \libinternal \file
+/*! \file
  *
  * \brief This file declares functions for inter-rank signalling by mdrun
  *
@@ -70,7 +70,7 @@ namespace gmx
 template <typename T>
 class ArrayRef;
 
-/*! \internal
+/*!
  * \brief POD-style object used by mdrun ranks to set and
  * receive signals within and between simulations.
  *
@@ -100,7 +100,7 @@ class SimulationSignal
 //! Convenience typedef for the group of signals used.
 typedef std::array<SimulationSignal, eglsNR> SimulationSignals;
 
-/*! \internal
+/*!
  * \brief Object used by mdrun ranks to signal to each other at this step.
  *
  * This object has responsibility to read signal values from \c gs,