From 3a9ff0b2cc55a2c7110bf4e77da6fdd8ca61907c Mon Sep 17 00:00:00 2001
From: Giovanni Bussi <giovanni.bussi@gmail.com>
Date: Mon, 18 May 2015 23:33:53 +0200
Subject: [PATCH] Revert "updated gromacs 5.0 to 5.0.5"

This reverts commit b148b715cf635bc179cdaaafa34a7a5b02dfa080.
---
 .../src/gromacs/CMakeLists.txt                |  0
 .../src/gromacs/CMakeLists.txt.preplumed      |  0
 .../src/gromacs/mdlib/force.c                 |  0
 .../src/gromacs/mdlib/force.c.preplumed       |  0
 .../src/gromacs/mdlib/minimize.c              |  0
 .../src/gromacs/mdlib/minimize.c.preplumed    |  0
 .../src/programs/mdrun/md.c                   | 30 ++++++-------------
 .../src/programs/mdrun/md.c.preplumed         | 30 ++++++-------------
 .../src/programs/mdrun/mdrun.cpp              |  0
 .../src/programs/mdrun/mdrun.cpp.preplumed    |  0
 .../src/programs/mdrun/repl_ex.c              |  4 +--
 .../src/programs/mdrun/repl_ex.c.preplumed    |  4 +--
 12 files changed, 22 insertions(+), 46 deletions(-)
 rename patches/{gromacs-5.0.5.diff => gromacs-5.0.diff}/src/gromacs/CMakeLists.txt (100%)
 rename patches/{gromacs-5.0.5.diff => gromacs-5.0.diff}/src/gromacs/CMakeLists.txt.preplumed (100%)
 rename patches/{gromacs-5.0.5.diff => gromacs-5.0.diff}/src/gromacs/mdlib/force.c (100%)
 rename patches/{gromacs-5.0.5.diff => gromacs-5.0.diff}/src/gromacs/mdlib/force.c.preplumed (100%)
 rename patches/{gromacs-5.0.5.diff => gromacs-5.0.diff}/src/gromacs/mdlib/minimize.c (100%)
 rename patches/{gromacs-5.0.5.diff => gromacs-5.0.diff}/src/gromacs/mdlib/minimize.c.preplumed (100%)
 rename patches/{gromacs-5.0.5.diff => gromacs-5.0.diff}/src/programs/mdrun/md.c (98%)
 rename patches/{gromacs-5.0.5.diff => gromacs-5.0.diff}/src/programs/mdrun/md.c.preplumed (98%)
 rename patches/{gromacs-5.0.5.diff => gromacs-5.0.diff}/src/programs/mdrun/mdrun.cpp (100%)
 rename patches/{gromacs-5.0.5.diff => gromacs-5.0.diff}/src/programs/mdrun/mdrun.cpp.preplumed (100%)
 rename patches/{gromacs-5.0.5.diff => gromacs-5.0.diff}/src/programs/mdrun/repl_ex.c (99%)
 rename patches/{gromacs-5.0.5.diff => gromacs-5.0.diff}/src/programs/mdrun/repl_ex.c.preplumed (99%)

diff --git a/patches/gromacs-5.0.5.diff/src/gromacs/CMakeLists.txt b/patches/gromacs-5.0.diff/src/gromacs/CMakeLists.txt
similarity index 100%
rename from patches/gromacs-5.0.5.diff/src/gromacs/CMakeLists.txt
rename to patches/gromacs-5.0.diff/src/gromacs/CMakeLists.txt
diff --git a/patches/gromacs-5.0.5.diff/src/gromacs/CMakeLists.txt.preplumed b/patches/gromacs-5.0.diff/src/gromacs/CMakeLists.txt.preplumed
similarity index 100%
rename from patches/gromacs-5.0.5.diff/src/gromacs/CMakeLists.txt.preplumed
rename to patches/gromacs-5.0.diff/src/gromacs/CMakeLists.txt.preplumed
diff --git a/patches/gromacs-5.0.5.diff/src/gromacs/mdlib/force.c b/patches/gromacs-5.0.diff/src/gromacs/mdlib/force.c
similarity index 100%
rename from patches/gromacs-5.0.5.diff/src/gromacs/mdlib/force.c
rename to patches/gromacs-5.0.diff/src/gromacs/mdlib/force.c
diff --git a/patches/gromacs-5.0.5.diff/src/gromacs/mdlib/force.c.preplumed b/patches/gromacs-5.0.diff/src/gromacs/mdlib/force.c.preplumed
similarity index 100%
rename from patches/gromacs-5.0.5.diff/src/gromacs/mdlib/force.c.preplumed
rename to patches/gromacs-5.0.diff/src/gromacs/mdlib/force.c.preplumed
diff --git a/patches/gromacs-5.0.5.diff/src/gromacs/mdlib/minimize.c b/patches/gromacs-5.0.diff/src/gromacs/mdlib/minimize.c
similarity index 100%
rename from patches/gromacs-5.0.5.diff/src/gromacs/mdlib/minimize.c
rename to patches/gromacs-5.0.diff/src/gromacs/mdlib/minimize.c
diff --git a/patches/gromacs-5.0.5.diff/src/gromacs/mdlib/minimize.c.preplumed b/patches/gromacs-5.0.diff/src/gromacs/mdlib/minimize.c.preplumed
similarity index 100%
rename from patches/gromacs-5.0.5.diff/src/gromacs/mdlib/minimize.c.preplumed
rename to patches/gromacs-5.0.diff/src/gromacs/mdlib/minimize.c.preplumed
diff --git a/patches/gromacs-5.0.5.diff/src/programs/mdrun/md.c b/patches/gromacs-5.0.diff/src/programs/mdrun/md.c
similarity index 98%
rename from patches/gromacs-5.0.5.diff/src/programs/mdrun/md.c
rename to patches/gromacs-5.0.diff/src/programs/mdrun/md.c
index 449bae0bd..b34d23c71 100644
--- a/patches/gromacs-5.0.5.diff/src/programs/mdrun/md.c
+++ b/patches/gromacs-5.0.diff/src/programs/mdrun/md.c
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2011,2012,2013,2014,2015, by the GROMACS development team, led by
+ * Copyright (c) 2011,2012,2013,2014, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -203,8 +203,7 @@ double do_md(FILE *fplog, t_commrec *cr, int nfile, const t_filenm fnm[],
     gmx_bool          bVV, bIterativeCase, bFirstIterate, bTemp, bPres, bTrotter;
     gmx_bool          bUpdateDoLR;
     real              dvdl_constr;
-    rvec             *cbuf        = NULL;
-    int               cbuf_nalloc = 0;
+    rvec             *cbuf = NULL;
     matrix            lastbox;
     real              veta_save, scalevir, tracevir;
     real              vetanew = 0;
@@ -260,6 +259,10 @@ double do_md(FILE *fplog, t_commrec *cr, int nfile, const t_filenm fnm[],
        md-vv-avek uses averaged half step velocities for T-control (but full step ekin for P control)
        md uses averaged half step kinetic energies to determine temperature unless defined otherwise by GMX_EKIN_AVE_VEL; */
     bVV = EI_VV(ir->eI);
+    if (bVV) /* to store the initial velocities while computing virial */
+    {
+        snew(cbuf, top_global->natoms);
+    }
     /* all the iteratative cases - only if there are constraints */
     bIterativeCase = ((IR_NPH_TROTTER(ir) || IR_NPT_TROTTER(ir)) && (constr) && (!bRerunMD));
     gmx_iterate_init(&iterate, FALSE); /* The default value of iterate->bIterationActive is set to
@@ -362,11 +365,6 @@ double do_md(FILE *fplog, t_commrec *cr, int nfile, const t_filenm fnm[],
         gmx_fatal(FARGS, "Normal Mode analysis is not supported with virtual sites.\nIf you'd like to help with adding support, we have an open discussion at http://redmine.gromacs.org/issues/879\n");
     }
 
-    if (bRerunMD && fr->cutoff_scheme == ecutsVERLET && ir->opts.ngener > 1 && fr->nbv && fr->nbv->bUseGPU)
-    {
-        gmx_fatal(FARGS, "The Verlet scheme on GPUs does not support energy groups, so your rerun should probably use a .tpr file without energy groups, or mdrun -nb auto");
-    }
-
     if (DEFORM(*ir))
     {
         tMPI_Thread_mutex_lock(&deform_init_box_mutex);
@@ -1185,8 +1183,6 @@ double do_md(FILE *fplog, t_commrec *cr, int nfile, const t_filenm fnm[],
         if (bVV && !bStartingFromCpt && !bRerunMD)
         /*  ############### START FIRST UPDATE HALF-STEP FOR VV METHODS############### */
         {
-            rvec *vbuf = NULL;
-
             wallcycle_start(wcycle, ewcUPDATE);
             if (ir->eI == eiVV && bInitStep)
             {
@@ -1196,8 +1192,7 @@ double do_md(FILE *fplog, t_commrec *cr, int nfile, const t_filenm fnm[],
                  * revert back to the initial coordinates
                  * so that the input is actually the initial step.
                  */
-                snew(vbuf, state->natoms);
-                copy_rvecn(state->v, vbuf, 0, state->natoms); /* should make this better for parallelizing? */
+                copy_rvecn(state->v, cbuf, 0, state->natoms); /* should make this better for parallelizing? */
             }
             else
             {
@@ -1379,10 +1374,9 @@ double do_md(FILE *fplog, t_commrec *cr, int nfile, const t_filenm fnm[],
                 }
             }
             /* if it's the initial step, we performed this first step just to get the constraint virial */
-            if (ir->eI == eiVV && bInitStep)
+            if (bInitStep && ir->eI == eiVV)
             {
-                copy_rvecn(vbuf, state->v, 0, state->natoms);
-                sfree(vbuf);
+                copy_rvecn(cbuf, state->v, 0, state->natoms);
             }
             wallcycle_stop(wcycle, ewcUPDATE);
         }
@@ -1638,12 +1632,6 @@ double do_md(FILE *fplog, t_commrec *cr, int nfile, const t_filenm fnm[],
 
                 if (ir->eI == eiVVAK)
                 {
-                    /* We probably only need md->homenr, not state->natoms */
-                    if (state->natoms > cbuf_nalloc)
-                    {
-                        cbuf_nalloc = state->natoms;
-                        srenew(cbuf, cbuf_nalloc);
-                    }
                     copy_rvecn(state->x, cbuf, 0, state->natoms);
                 }
                 bUpdateDoLR = (fr->bTwinRange && do_per_step(step, ir->nstcalclr));
diff --git a/patches/gromacs-5.0.5.diff/src/programs/mdrun/md.c.preplumed b/patches/gromacs-5.0.diff/src/programs/mdrun/md.c.preplumed
similarity index 98%
rename from patches/gromacs-5.0.5.diff/src/programs/mdrun/md.c.preplumed
rename to patches/gromacs-5.0.diff/src/programs/mdrun/md.c.preplumed
index 73cc2103e..3d98d597c 100644
--- a/patches/gromacs-5.0.5.diff/src/programs/mdrun/md.c.preplumed
+++ b/patches/gromacs-5.0.diff/src/programs/mdrun/md.c.preplumed
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2011,2012,2013,2014,2015, by the GROMACS development team, led by
+ * Copyright (c) 2011,2012,2013,2014, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -197,8 +197,7 @@ double do_md(FILE *fplog, t_commrec *cr, int nfile, const t_filenm fnm[],
     gmx_bool          bVV, bIterativeCase, bFirstIterate, bTemp, bPres, bTrotter;
     gmx_bool          bUpdateDoLR;
     real              dvdl_constr;
-    rvec             *cbuf        = NULL;
-    int               cbuf_nalloc = 0;
+    rvec             *cbuf = NULL;
     matrix            lastbox;
     real              veta_save, scalevir, tracevir;
     real              vetanew = 0;
@@ -248,6 +247,10 @@ double do_md(FILE *fplog, t_commrec *cr, int nfile, const t_filenm fnm[],
        md-vv-avek uses averaged half step velocities for T-control (but full step ekin for P control)
        md uses averaged half step kinetic energies to determine temperature unless defined otherwise by GMX_EKIN_AVE_VEL; */
     bVV = EI_VV(ir->eI);
+    if (bVV) /* to store the initial velocities while computing virial */
+    {
+        snew(cbuf, top_global->natoms);
+    }
     /* all the iteratative cases - only if there are constraints */
     bIterativeCase = ((IR_NPH_TROTTER(ir) || IR_NPT_TROTTER(ir)) && (constr) && (!bRerunMD));
     gmx_iterate_init(&iterate, FALSE); /* The default value of iterate->bIterationActive is set to
@@ -350,11 +353,6 @@ double do_md(FILE *fplog, t_commrec *cr, int nfile, const t_filenm fnm[],
         gmx_fatal(FARGS, "Normal Mode analysis is not supported with virtual sites.\nIf you'd like to help with adding support, we have an open discussion at http://redmine.gromacs.org/issues/879\n");
     }
 
-    if (bRerunMD && fr->cutoff_scheme == ecutsVERLET && ir->opts.ngener > 1 && fr->nbv && fr->nbv->bUseGPU)
-    {
-        gmx_fatal(FARGS, "The Verlet scheme on GPUs does not support energy groups, so your rerun should probably use a .tpr file without energy groups, or mdrun -nb auto");
-    }
-
     if (DEFORM(*ir))
     {
         tMPI_Thread_mutex_lock(&deform_init_box_mutex);
@@ -1091,8 +1089,6 @@ double do_md(FILE *fplog, t_commrec *cr, int nfile, const t_filenm fnm[],
         if (bVV && !bStartingFromCpt && !bRerunMD)
         /*  ############### START FIRST UPDATE HALF-STEP FOR VV METHODS############### */
         {
-            rvec *vbuf = NULL;
-
             wallcycle_start(wcycle, ewcUPDATE);
             if (ir->eI == eiVV && bInitStep)
             {
@@ -1102,8 +1098,7 @@ double do_md(FILE *fplog, t_commrec *cr, int nfile, const t_filenm fnm[],
                  * revert back to the initial coordinates
                  * so that the input is actually the initial step.
                  */
-                snew(vbuf, state->natoms);
-                copy_rvecn(state->v, vbuf, 0, state->natoms); /* should make this better for parallelizing? */
+                copy_rvecn(state->v, cbuf, 0, state->natoms); /* should make this better for parallelizing? */
             }
             else
             {
@@ -1285,10 +1280,9 @@ double do_md(FILE *fplog, t_commrec *cr, int nfile, const t_filenm fnm[],
                 }
             }
             /* if it's the initial step, we performed this first step just to get the constraint virial */
-            if (ir->eI == eiVV && bInitStep)
+            if (bInitStep && ir->eI == eiVV)
             {
-                copy_rvecn(vbuf, state->v, 0, state->natoms);
-                sfree(vbuf);
+                copy_rvecn(cbuf, state->v, 0, state->natoms);
             }
             wallcycle_stop(wcycle, ewcUPDATE);
         }
@@ -1544,12 +1538,6 @@ double do_md(FILE *fplog, t_commrec *cr, int nfile, const t_filenm fnm[],
 
                 if (ir->eI == eiVVAK)
                 {
-                    /* We probably only need md->homenr, not state->natoms */
-                    if (state->natoms > cbuf_nalloc)
-                    {
-                        cbuf_nalloc = state->natoms;
-                        srenew(cbuf, cbuf_nalloc);
-                    }
                     copy_rvecn(state->x, cbuf, 0, state->natoms);
                 }
                 bUpdateDoLR = (fr->bTwinRange && do_per_step(step, ir->nstcalclr));
diff --git a/patches/gromacs-5.0.5.diff/src/programs/mdrun/mdrun.cpp b/patches/gromacs-5.0.diff/src/programs/mdrun/mdrun.cpp
similarity index 100%
rename from patches/gromacs-5.0.5.diff/src/programs/mdrun/mdrun.cpp
rename to patches/gromacs-5.0.diff/src/programs/mdrun/mdrun.cpp
diff --git a/patches/gromacs-5.0.5.diff/src/programs/mdrun/mdrun.cpp.preplumed b/patches/gromacs-5.0.diff/src/programs/mdrun/mdrun.cpp.preplumed
similarity index 100%
rename from patches/gromacs-5.0.5.diff/src/programs/mdrun/mdrun.cpp.preplumed
rename to patches/gromacs-5.0.diff/src/programs/mdrun/mdrun.cpp.preplumed
diff --git a/patches/gromacs-5.0.5.diff/src/programs/mdrun/repl_ex.c b/patches/gromacs-5.0.diff/src/programs/mdrun/repl_ex.c
similarity index 99%
rename from patches/gromacs-5.0.5.diff/src/programs/mdrun/repl_ex.c
rename to patches/gromacs-5.0.diff/src/programs/mdrun/repl_ex.c
index af47b1d3b..cfb0b7f35 100644
--- a/patches/gromacs-5.0.5.diff/src/programs/mdrun/repl_ex.c
+++ b/patches/gromacs-5.0.diff/src/programs/mdrun/repl_ex.c
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2011,2012,2013,2014,2015, by the GROMACS development team, led by
+ * Copyright (c) 2011,2012,2013,2014, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -415,7 +415,7 @@ gmx_repl_ex_t init_replica_exchange(FILE *fplog,
     snew(re->order, re->nrepl);
     for (i = 0; i < re->nrepl; i++)
     {
-        snew(re->cyclic[i], re->nrepl+1);
+        snew(re->cyclic[i], re->nrepl);
         snew(re->order[i], re->nrepl);
     }
     /* allocate space for the functions storing the data for the replicas */
diff --git a/patches/gromacs-5.0.5.diff/src/programs/mdrun/repl_ex.c.preplumed b/patches/gromacs-5.0.diff/src/programs/mdrun/repl_ex.c.preplumed
similarity index 99%
rename from patches/gromacs-5.0.5.diff/src/programs/mdrun/repl_ex.c.preplumed
rename to patches/gromacs-5.0.diff/src/programs/mdrun/repl_ex.c.preplumed
index 5db5d309c..46a9bc011 100644
--- a/patches/gromacs-5.0.5.diff/src/programs/mdrun/repl_ex.c.preplumed
+++ b/patches/gromacs-5.0.diff/src/programs/mdrun/repl_ex.c.preplumed
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2011,2012,2013,2014,2015, by the GROMACS development team, led by
+ * Copyright (c) 2011,2012,2013,2014, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -400,7 +400,7 @@ gmx_repl_ex_t init_replica_exchange(FILE *fplog,
     snew(re->order, re->nrepl);
     for (i = 0; i < re->nrepl; i++)
     {
-        snew(re->cyclic[i], re->nrepl+1);
+        snew(re->cyclic[i], re->nrepl);
         snew(re->order[i], re->nrepl);
     }
     /* allocate space for the functions storing the data for the replicas */
-- 
GitLab