Merge branch release-5-1 into release-2016
[alexxy/gromacs.git] / src / gromacs / gmxana / gmx_order.cpp
index d48e5d4f907440308c864e991419cb9bc9678126..1f1bad24f57028e9b7fcabefccfd91f75b857dba 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014,2015,2016, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2015,2016,2017, 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.
@@ -637,16 +637,13 @@ void calc_order(const char *fn, int *index, int *a, rvec **order,
                     z1    = x1[a[index[i-1]+j]][axis];
                     z2    = x1[a[index[i+1]+j]][axis];
                     z_ave = 0.5 * (z1 + z2);
-                    if (z_ave < 0)
+                    slice = (int)((nslices*z_ave)/box[axis][axis]);
+                    while (slice < 0)
                     {
-                        z_ave += box[axis][axis];
-                    }
-                    if (z_ave > box[axis][axis])
-                    {
-                        z_ave -= box[axis][axis];
+                        slice += nslices;
                     }
+                    slice =  slice % nslices;
 
-                    slice  = static_cast<int>((0.5 + (z_ave / (*slWidth))) - 1);
                     slCount[slice]++;     /* determine slice, increase count */
 
                     slFrameorder[slice] += 0.5 * (3 * cossum[axis] - 1);