Ensure the modular simulator runs only when it should
authorMark Abraham <mark.j.abraham@gmail.com>
Fri, 25 Sep 2020 15:21:43 +0000 (17:21 +0200)
committerMark Abraham <mark.j.abraham@gmail.com>
Fri, 25 Sep 2020 15:21:43 +0000 (17:21 +0200)
Previous checks were ineffective if an unsupported inputrec
was accompanied by GMX_USE_MODULAR_SIMULATOR.

Change-Id: I74e4c177b6b4d7dc25bb3ca32a7dff5a6027276e

src/gromacs/modularsimulator/modularsimulator.cpp

index bc49d4665cb1145941880b23a426d2c988f728c5..823b545558cfa947fc796e28b22e670eb4848354 100644 (file)
@@ -177,16 +177,6 @@ bool ModularSimulator::isInputCompatible(bool                             exitOn
                                          bool                             doEssentialDynamics,
                                          bool                             doMembed)
 {
-    auto conditionalAssert = [exitOnFailure](bool condition, const char* message) {
-        if (exitOnFailure)
-        {
-            GMX_RELEASE_ASSERT(condition, message);
-        }
-        return condition;
-    };
-
-    bool isInputCompatible = true;
-
     // GMX_USE_MODULAR_SIMULATOR allows to use modular simulator also for non-standard uses,
     // such as the leap-frog integrator
     const auto modularSimulatorExplicitlyTurnedOn = (getenv("GMX_USE_MODULAR_SIMULATOR") != nullptr);
@@ -209,6 +199,20 @@ bool ModularSimulator::isInputCompatible(bool                             exitOn
             "as the Parrinello-Rahman barostat is not implemented in the legacy simulator. Unset "
             "GMX_DISABLE_MODULAR_SIMULATOR or use a different pressure control algorithm.");
 
+    // If the user has asked for the modular simulator, then we must
+    // exit when the modular simulator can't run their simulation.
+    exitOnFailure = exitOnFailure || modularSimulatorExplicitlyTurnedOn;
+
+    auto conditionalAssert = [exitOnFailure](bool condition, const char* message) {
+        if (exitOnFailure)
+        {
+            GMX_RELEASE_ASSERT(condition, message);
+        }
+        return condition;
+    };
+
+    bool isInputCompatible = true;
+
     isInputCompatible =
             isInputCompatible
             && conditionalAssert(