From 6734027bc1417edfd64ae1906ba088a7f118650b Mon Sep 17 00:00:00 2001
From: Matthieu Schaller <matthieu.schaller@durham.ac.uk>
Date: Fri, 25 Mar 2016 18:31:59 +0000
Subject: [PATCH] Bug fix

---
 src/engine.c |  8 ++++----
 src/space.c  | 18 +++++++++---------
 2 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/src/engine.c b/src/engine.c
index 91ea8f5590..28d75bba53 100644
--- a/src/engine.c
+++ b/src/engine.c
@@ -442,10 +442,10 @@ void engine_redistribute(struct engine *e) {
       if (gparts_new[k].part->gpart != &gparts_new[k])
         error("Linking problem !");
 
-      if (gparts_new[k].x[0] != gparts_new[k].part->x[0] ||
-          gparts_new[k].x[1] != gparts_new[k].part->x[1] ||
-          gparts_new[k].x[2] != gparts_new[k].part->x[2])
-        error("Linked particles are not at the same position !");
+      /* if (gparts_new[k].x[0] != gparts_new[k].part->x[0] || */
+      /*     gparts_new[k].x[1] != gparts_new[k].part->x[1] || */
+      /*     gparts_new[k].x[2] != gparts_new[k].part->x[2]) */
+      /*   error("Linked particles are not at the same position !"); */
     }
   }
   for (size_t k = 0; k < nr_parts; ++k) {
diff --git a/src/space.c b/src/space.c
index 21a8555a1d..2e840ea7b8 100644
--- a/src/space.c
+++ b/src/space.c
@@ -377,7 +377,7 @@ void space_rebuild(struct space *s, double cell_max, int verbose) {
     if (cells[ind[k]].nodeID != local_nodeID) {
       cells[ind[k]].count -= 1;
       nr_parts -= 1;
-      struct part tp = s->parts[k];
+      const struct part tp = s->parts[k];
       s->parts[k] = s->parts[nr_parts];
       s->parts[nr_parts] = tp;
       if (s->parts[k].gpart != NULL) {
@@ -386,20 +386,20 @@ void space_rebuild(struct space *s, double cell_max, int verbose) {
       if (s->parts[nr_parts].gpart != NULL) {
         s->parts[nr_parts].gpart->part = &s->parts[nr_parts];
       }
-      struct xpart txp = s->xparts[k];
+      const struct xpart txp = s->xparts[k];
       s->xparts[k] = s->xparts[nr_parts];
       s->xparts[nr_parts] = txp;
-      int t = ind[k];
+      const int t = ind[k];
       ind[k] = ind[nr_parts];
       ind[nr_parts] = t;
     }
 
   /* Move non-local gparts to the end of the list. */
   for (int k = 0; k < nr_gparts; k++)
-    if (cells[ind[k]].nodeID != local_nodeID) {
-      cells[ind[k]].gcount -= 1;
+    if (cells[gind[k]].nodeID != local_nodeID) {
+      cells[gind[k]].gcount -= 1;
       nr_gparts -= 1;
-      struct gpart tp = s->gparts[k];
+      const struct gpart tp = s->gparts[k];
       s->gparts[k] = s->gparts[nr_gparts];
       s->gparts[nr_gparts] = tp;
       if (s->gparts[k].id > 0) {
@@ -408,9 +408,9 @@ void space_rebuild(struct space *s, double cell_max, int verbose) {
       if (s->gparts[nr_gparts].id > 0) {
         s->gparts[nr_gparts].part->gpart = &s->gparts[nr_gparts];
       }
-      int t = ind[k];
-      ind[k] = ind[nr_gparts];
-      ind[nr_gparts] = t;
+      const int t = gind[k];
+      gind[k] = gind[nr_gparts];
+      gind[nr_gparts] = t;
     }
 
   /* Exchange the strays, note that this potentially re-allocates
-- 
GitLab