fixed array index out of bounds in EM force trr storage
authorBerk Hess <hess@kth.se>
Mon, 27 Feb 2012 14:05:25 +0000 (15:05 +0100)
committerBerk Hess <hess@kth.se>
Tue, 28 Feb 2012 17:20:32 +0000 (18:20 +0100)
The partially implemented force copy was a leftover from a different way
of copying, which should never have been committed.

Change-Id: I026aa79158afcc327185f2f0cf6167d040eccede

src/mdlib/minimize.c

index 588544caf74446180f237dbc56dd5150a9cfae10..690f0d98e6f683fea6334b5a9f6a7339451aa2a1 100644 (file)
@@ -438,14 +438,14 @@ static void swap_em_state(em_state_t *ems1,em_state_t *ems2)
   *ems2 = tmp;
 }
 
-static void copy_em_coords_back(em_state_t *ems,t_state *state,rvec *f)
+static void copy_em_coords(em_state_t *ems,t_state *state)
 {
-  int i;
+    int i;
 
-  for(i=0; (i<state->natoms); i++)
-    copy_rvec(ems->s.x[i],state->x[i]);
-  if (f != NULL)
-    copy_rvec(ems->f[i],f[i]);
+    for(i=0; (i<state->natoms); i++)
+    {
+        copy_rvec(ems->s.x[i],state->x[i]);
+    }
 }
 
 static void write_em_traj(FILE *fplog,t_commrec *cr,
@@ -460,8 +460,8 @@ static void write_em_traj(FILE *fplog,t_commrec *cr,
 
     if ((bX || bF || confout != NULL) && !DOMAINDECOMP(cr))
     {
+        copy_em_coords(state,state_global);
         f_global = state->f;
-        copy_em_coords_back(state,state_global,bF ? f_global : NULL);
     }
     
     mdof_flags = 0;