Check for contradicting environment variables (modular simulator)
authorPascal Merz <pascal.merz@me.com>
Thu, 31 Oct 2019 04:51:56 +0000 (22:51 -0600)
committerMark Abraham <mark.j.abraham@gmail.com>
Thu, 31 Oct 2019 15:03:56 +0000 (16:03 +0100)
Having both environment variables GMX_USE_MODULAR_SIMULATOR=ON and
GMX_DISABLE_MODULAR_SIMULATOR=ON set has no defined behavior and
should therefore yield an error. This change adds a release assert
to ensure this.

Change-Id: I1df0d94da7312d6c31e7e520db6c0186707b3cac

src/gromacs/modularsimulator/modularsimulator.cpp

index 0be4093d8a3a8c427f02b8a6b3d02077f14ab9bb..605267669d09672f2c0352c9228258e97bcfe66b 100644 (file)
@@ -832,6 +832,12 @@ bool ModularSimulator::isInputCompatible(
     const auto modularSimulatorExplicitlyTurnedOff =
         (getenv("GMX_DISABLE_MODULAR_SIMULATOR") != nullptr);
 
+    GMX_RELEASE_ASSERT(
+            !(modularSimulatorExplicitlyTurnedOn && modularSimulatorExplicitlyTurnedOff),
+            "Cannot have both GMX_USE_MODULAR_SIMULATOR=ON and GMX_DISABLE_MODULAR_SIMULATOR=ON. "
+            "Unset one of the two environment variables to explicitly chose which simulator to use, "
+            "or unset both to recover default behavior.");
+
     GMX_RELEASE_ASSERT(
             !(modularSimulatorExplicitlyTurnedOff && inputrec->eI == eiVV && inputrec->epc == epcPARRINELLORAHMAN),
             "Cannot use a Parrinello-Rahman barostat with md-vv and GMX_DISABLE_MODULAR_SIMULATOR=ON, "