Merge release-4-5-patches into release-4-6
[alexxy/gromacs.git] / src / mdlib / md_support.c
index 77b04beb2e7332572e6b7748942c0f1d024e7af9..c50f1036d2b34cd715b3123afa97b2e8d4f7f7d2 100644 (file)
@@ -337,16 +337,16 @@ void compute_globals(FILE *fplog, gmx_global_stat_t gstat, t_commrec *cr, t_inpu
         }
         
         debug_gmx();
-        
-        /* Calculate center of mass velocity if necessary, also parallellized */
-        if (bStopCM && !bRerunMD && bEner) 
-        {
-            calc_vcm_grp(fplog,mdatoms->start,mdatoms->homenr,mdatoms,
-                         state->x,state->v,vcm);
-        }
     }
 
-    if (bTemp || bPres || bEner || bConstrain) 
+    /* Calculate center of mass velocity if necessary, also parallellized */
+    if (bStopCM)
+    {
+        calc_vcm_grp(fplog,mdatoms->start,mdatoms->homenr,mdatoms,
+                     state->x,state->v,vcm);
+    }
+
+    if (bTemp || bStopCM || bPres || bEner || bConstrain)
     {
         if (!bGStat)
         {
@@ -370,7 +370,7 @@ void compute_globals(FILE *fplog, gmx_global_stat_t gstat, t_commrec *cr, t_inpu
                 wallcycle_start(wcycle,ewcMoveE);
                 GMX_MPE_LOG(ev_global_stat_start);
                 global_stat(fplog,gstat,cr,enerd,force_vir,shake_vir,mu_tot,
-                            ir,ekind,constr,vcm,
+                            ir,ekind,constr,bStopCM ? vcm : NULL,
                             gs != NULL ? eglsNR : 0,gs_buf,
                             top_global,state,
                             *bSumEkinhOld,flags);
@@ -420,16 +420,17 @@ void compute_globals(FILE *fplog, gmx_global_stat_t gstat, t_commrec *cr, t_inpu
                      mdatoms->massT,mdatoms->tmass,ekind->ekin);
     }
     
-    if (bEner) {
-        /* Do center of mass motion removal */
-        if (bStopCM && !bRerunMD) /* is this correct?  Does it get called too often with this logic? */
-        {
-            check_cm_grp(fplog,vcm,ir,1);
-            do_stopcm_grp(fplog,mdatoms->start,mdatoms->homenr,mdatoms->cVCM,
-                          state->x,state->v,vcm);
-            inc_nrnb(nrnb,eNR_STOPCM,mdatoms->homenr);
-        }
+    /* Do center of mass motion removal */
+    if (bStopCM)
+    {
+        check_cm_grp(fplog,vcm,ir,1);
+        do_stopcm_grp(fplog,mdatoms->start,mdatoms->homenr,mdatoms->cVCM,
+                      state->x,state->v,vcm);
+        inc_nrnb(nrnb,eNR_STOPCM,mdatoms->homenr);
+    }
 
+    if (bEner)
+    {
         /* Calculate the amplitude of the cosine velocity profile */
         ekind->cosacc.vcos = ekind->cosacc.mvcos/mdatoms->tmass;
     }