From cb6878b657186f9b62021f349a745cd868457bf1 Mon Sep 17 00:00:00 2001
From: Matthieu Schaller <matthieu.schaller@durham.ac.uk>
Date: Thu, 19 Jan 2017 17:03:15 +0000
Subject: [PATCH] Only check lack of time-step assignment for local particles

---
 src/active.h | 16 +++++++++-------
 src/cell.c   | 12 ++++++------
 src/space.h  |  1 -
 3 files changed, 15 insertions(+), 14 deletions(-)

diff --git a/src/active.h b/src/active.h
index edb276c5e9..8eec56a774 100644
--- a/src/active.h
+++ b/src/active.h
@@ -41,9 +41,10 @@ __attribute__((always_inline)) INLINE static int cell_is_drifted(
 #ifdef SWIFT_DEBUG_CHECKS
   if (c->ti_old > e->ti_current)
     error(
-        "Cell has been drifted too far forward in time! c->ti_old=%lld "
-        "e->ti_current=%lld",
-        c->ti_old, e->ti_current);
+        "Cell has been drifted too far forward in time! c->ti_old=%lld (t=%e) "
+        "and e->ti_current=%lld (t=%e)",
+        c->ti_old, c->ti_old * e->timeBase, e->ti_current,
+	e->ti_current * e->timeBase);
 #endif
 
   return (c->ti_old == e->ti_current);
@@ -60,11 +61,12 @@ __attribute__((always_inline)) INLINE static int cell_is_active(
     const struct cell *c, const struct engine *e) {
 
 #ifdef SWIFT_DEBUG_CHECKS
-  if (c->ti_end_min < e->ti_current)
+  if (c->ti_end_min < e->ti_current && c->nodeID != e->nodeID)
     error(
-        "cell in an impossible time-zone! c->ti_end_min=%lld "
-        "e->ti_current=%lld",
-        c->ti_end_min, e->ti_current);
+        "cell in an impossible time-zone! c->ti_end_min=%lld (t=%e) and "
+        "e->ti_current=%lld (t=%e)",
+        c->ti_end_min, c->ti_end_min * e->timeBase, e->ti_current,
+	e->ti_current * e->timeBase);
 #endif
 
   return (c->ti_end_min == e->ti_current);
diff --git a/src/cell.c b/src/cell.c
index b881ea3a78..4b7c59527e 100644
--- a/src/cell.c
+++ b/src/cell.c
@@ -1140,18 +1140,18 @@ void cell_drift(struct cell *c, const struct engine *e) {
 void cell_check_timesteps(struct cell *c) {
 #ifdef SWIFT_DEBUG_CHECKS
 
-  if(c->nodeID != engine_rank) return;
-
-  if(c->ti_end_min == 0) error("Cell without assigned time-step");
+  if(c->ti_end_min == 0 && c->nr_tasks > 0)
+    error("Cell without assigned time-step");
   
   if(c->split) {
     for(int k=0; k<8; ++k)
       if(c->progeny[k] != NULL) cell_check_timesteps(c->progeny[k]);
   } else {
 
-    for(int i=0; i<c->count; ++i)
-      if(c->parts[i].time_bin == 0) 
-	error("Particle without assigned time-bin");
+    if(c->nodeID == engine_rank)
+      for(int i=0; i<c->count; ++i)
+	if(c->parts[i].time_bin == 0) 
+	  error("Particle without assigned time-bin");
 
   }
 #endif
diff --git a/src/space.h b/src/space.h
index acfa0c4c2b..a28b76fe27 100644
--- a/src/space.h
+++ b/src/space.h
@@ -189,5 +189,4 @@ void space_check_drift_point(struct space *s, integertime_t ti_current);
 void space_check_timesteps(struct space *s);
 void space_clean(struct space *s);
 
-
 #endif /* SWIFT_SPACE_H */
-- 
GitLab