Combine two booleans in md loop
authorArtem Zhmurov <zhmurov@gmail.com>
Wed, 27 Nov 2019 22:23:33 +0000 (23:23 +0100)
committerArtem Zhmurov <zhmurov@gmail.com>
Wed, 27 Nov 2019 22:23:33 +0000 (23:23 +0100)
Two booleans that were supposed to have identical meaning have being
created in the md loop. This patch conbines them into one. Note that
the scope of the boolean that is responsible for the D2H coordinates
copy have expanded, which represents correct behavior.

Change-Id: I421b18ee81f4cf9cce19cdd60023cb097d85a5d7

src/gromacs/mdrun/md.cpp

index da1278b19ed5f0e5ffe4f35ad618912ef14c0999..5994e40f8346e2d6396aadb7dca016c9dcf1e352 100644 (file)
@@ -1235,7 +1235,8 @@ void gmx::LegacySimulator::do_md()
          * energies of two subsequent steps. Therefore we need to compute the
          * half step kinetic energy also if we need energies at the next step.
          */
-        const bool needHalfStepKineticEnergy = (!EI_VV(ir->eI) && do_per_step(step + 1, nstglobalcomm));
+        const bool needHalfStepKineticEnergy =
+                (!EI_VV(ir->eI) && (do_per_step(step + 1, nstglobalcomm) || step_rel + 1 == ir->nsteps));
 
         if (useGpuForUpdate)
         {
@@ -1372,13 +1373,7 @@ void gmx::LegacySimulator::do_md()
             // and when algorithms require it.
             const bool doInterSimSignal = (simulationsShareState && do_per_step(step, nstSignalComm));
 
-            // With leap-frog we also need to compute the half-step
-            // kinetic energy at the step before we need to write
-            // the full-step kinetic energy
-            const bool needEkinAtNextStep =
-                    (!EI_VV(ir->eI) && (do_per_step(step + 1, nstglobalcomm) || step_rel + 1 == ir->nsteps));
-
-            if (bGStat || needEkinAtNextStep || doInterSimSignal)
+            if (bGStat || needHalfStepKineticEnergy || doInterSimSignal)
             {
                 // Copy coordinates when needed to stop the CM motion.
                 if (useGpuForUpdate && !EI_VV(ir->eI) && bStopCM)