Merge branch release-5-1 into release-2016
authorMark Abraham <mark.j.abraham@gmail.com>
Wed, 15 Feb 2017 02:46:23 +0000 (03:46 +0100)
committerMark Abraham <mark.j.abraham@gmail.com>
Wed, 15 Feb 2017 03:21:03 +0000 (04:21 +0100)
There's an awkward clash with a bug fix from release-5-1 from
subsequent cleanup in release-2016 while it was still
master. Fortunately, the code path for bExchanged only happens when
!bTrotter, and all the other code paths require bTrotter (which has
several sub cases), so those two groups of code commute. (And the
implementation of checking what the inputrec requires has changed
between branches only in name.)

Change-Id: I2382dad5c484452d023524884c025e77c2a624c4

1  2 
src/programs/mdrun/md.cpp

index 4c4d069ef4f0712d010b4ca666c4c7bd618e180a,340d692c2abceebe83ad9c9c67ccc5814fba1c31..8cf13863611a9927aea73f5f5e7d6303901a20da
@@@ -1192,28 -1195,40 +1192,35 @@@ double gmx::do_md(FILE *fplog, t_commre
                  {
                      m_add(force_vir, shake_vir, total_vir);     /* we need the un-dispersion corrected total vir here */
                      trotter_update(ir, step, ekind, enerd, state, total_vir, mdatoms, &MassQ, trotter_seq, ettTSEQ2);
 -                }
 -                else
 -                {
 -                    if (bExchanged)
 +
-                     copy_mat(shake_vir, state->svir_prev);
-                     copy_mat(force_vir, state->fvir_prev);
++                    /* TODO This is only needed when we're about to write
++                     * a checkpoint, because we use it after the restart
++                     * (in a kludge?). But what should we be doing if
++                     * startingFromCheckpoint or bInitStep are true? */
++                    if (inputrecNptTrotter(ir) || inputrecNphTrotter(ir))
+                     {
 -                        wallcycle_stop(wcycle, ewcUPDATE);
 -                        /* We need the kinetic energy at minus the half step for determining
 -                         * the full step kinetic energy and possibly for T-coupling.*/
 -                        /* This may not be quite working correctly yet . . . . */
 -                        compute_globals(fplog, gstat, cr, ir, fr, ekind, state, state_global, mdatoms, nrnb, vcm,
 -                                        wcycle, enerd, NULL, NULL, NULL, NULL, mu_tot,
 -                                        constr, NULL, FALSE, state->box,
 -                                        top_global, &bSumEkinhOld,
 -                                        CGLO_RERUNMD | CGLO_GSTAT | CGLO_TEMPERATURE);
 -                        wallcycle_start(wcycle, ewcUPDATE);
++                        copy_mat(shake_vir, state->svir_prev);
++                        copy_mat(force_vir, state->fvir_prev);
++                    }
 +                    if (inputrecNvtTrotter(ir) && ir->eI == eiVV)
 +                    {
 +                        /* update temperature and kinetic energy now that step is over - this is the v(t+dt) point */
 +                        enerd->term[F_TEMP] = sum_ekin(&(ir->opts), ekind, NULL, (ir->eI == eiVV), FALSE);
 +                        enerd->term[F_EKIN] = trace(ekind->ekin);
                      }
                  }
 -            }
 -            if (bTrotter && !bInitStep)
 -            {
 -                /* TODO This is only needed when we're about to write
 -                 * a checkpoint, because we use it after the restart
 -                 * (in a kludge?). But what should we be doing if
 -                 * startingFromCheckpoint or bInitStep are true? */
 -                if (IR_NPT_TROTTER(ir) || IR_NPH_TROTTER(ir))
 -                {
 -                    copy_mat(shake_vir, state->svir_prev);
 -                    copy_mat(force_vir, state->fvir_prev);
 -                }
 -                if (IR_NVT_TROTTER(ir) && ir->eI == eiVV)
 +                else if (bExchanged)
                  {
 -                    /* update temperature and kinetic energy now that step is over - this is the v(t+dt) point */
 -                    enerd->term[F_TEMP] = sum_ekin(&(ir->opts), ekind, NULL, (ir->eI == eiVV), FALSE);
 -                    enerd->term[F_EKIN] = trace(ekind->ekin);
 +                    wallcycle_stop(wcycle, ewcUPDATE);
 +                    /* We need the kinetic energy at minus the half step for determining
 +                     * the full step kinetic energy and possibly for T-coupling.*/
 +                    /* This may not be quite working correctly yet . . . . */
 +                    compute_globals(fplog, gstat, cr, ir, fr, ekind, state, mdatoms, nrnb, vcm,
 +                                    wcycle, enerd, NULL, NULL, NULL, NULL, mu_tot,
 +                                    constr, &nullSignaller, state->box,
 +                                    NULL, &bSumEkinhOld,
 +                                    CGLO_GSTAT | CGLO_TEMPERATURE);
 +                    wallcycle_start(wcycle, ewcUPDATE);
                  }
              }
              /* if it's the initial step, we performed this first step just to get the constraint virial */
          bIMDstep = do_IMD(ir->bIMD, step, cr, bNS, state->box, state->x, ir, t, wcycle);
  
          /* kludge -- virial is lost with restart for MTTK NPT control. Must reload (saved earlier). */
-         if (startingFromCheckpoint && bTrotter)
 -        if (bStartingFromCpt && (IR_NPT_TROTTER(ir) || IR_NPH_TROTTER(ir)))
++        if (startingFromCheckpoint && (inputrecNptTrotter(ir) || inputrecNphTrotter(ir)))
          {
              copy_mat(state->svir_prev, shake_vir);
              copy_mat(state->fvir_prev, force_vir);