Always write the input MDP file for testing just before the grompp call
authorAleksei Iupinov <a.yupinov@gmail.com>
Fri, 12 Jan 2018 10:55:17 +0000 (11:55 +0100)
committerAleksei Iupinov <a.yupinov@gmail.com>
Tue, 16 Jan 2018 14:01:42 +0000 (15:01 +0100)
This should hopefully help avoid the race issue that was
briefly observed with the multi-rank PME test
(the input MDP was occasionally garbled by multiple writes).

Change-Id: Ib624825f79a3dc7b6d3f5e81d8e6b5907f27b35a

src/programs/mdrun/tests/moduletest.cpp
src/programs/mdrun/tests/moduletest.h

index d5244f3fbe522a0d1993dfe93fe921e3f26d7335..54f12888c25e2b8b0bba327d545a65286cde39cd 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2013,2014,2015,2016,2017, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2015,2016,2017,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.
@@ -132,7 +132,7 @@ SimulationRunner::useStringAsMdpFile(const char *mdpString)
 void
 SimulationRunner::useStringAsMdpFile(const std::string &mdpString)
 {
-    gmx::TextWriter::writeFileFromString(mdpInputFileName_, mdpString);
+    mdpInputContents_ = mdpString;
 }
 
 void
@@ -158,6 +158,8 @@ SimulationRunner::useGroFromDatabase(const char *name)
 int
 SimulationRunner::callGromppOnThisRank(const CommandLine &callerRef)
 {
+    gmx::TextWriter::writeFileFromString(mdpInputFileName_, mdpInputContents_);
+
     CommandLine caller;
     caller.append("grompp");
     caller.merge(callerRef);
index c7649b6d47befc253b6bc30d99d5d02441e1bda9..917f70e9978040423f84ad7aa59b1d224f60f67a 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2013,2014,2015,2016,2017, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2015,2016,2017,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.
@@ -133,7 +133,9 @@ class SimulationRunner
         std::string reducedPrecisionTrajectoryFileName_;
         std::string groOutputFileName_;
         std::string ndxFileName_;
-        std::string mdpInputFileName_;
+        std::string mdpInputFileName_;    /**< This file is temporary and will be overwritten with mdpInputContents_ when calling grompp.
+                                           * TODO: remove this when the multisim tests use -multidir.
+                                           */
         std::string mdpOutputFileName_;
         std::string tprFileName_;
         std::string logFileName_;
@@ -142,6 +144,8 @@ class SimulationRunner
         std::string swapFileName_;
         int         nsteps_;
         //@}
+        //! What will be written into mdpInputFileName_ before the grompp call
+        std::string mdpInputContents_;
 
     private:
         TestFileManager &fileManager_;