From d36d3dce2b04b60fb5993c9b0a8695e043881c9a Mon Sep 17 00:00:00 2001
From: Pedro Gonnet <gonnet@google.com>
Date: Wed, 12 Apr 2017 22:34:53 +0200
Subject: [PATCH] use a more sensible tolerance for the sorted indices checks.

---
 src/runner_doiact.h | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/runner_doiact.h b/src/runner_doiact.h
index 9bce0de7a0..f938fc54d4 100644
--- a/src/runner_doiact.h
+++ b/src/runner_doiact.h
@@ -915,7 +915,8 @@ void DOPAIR1(struct runner *r, struct cell *ci, struct cell *cj) {
     const float d = p->x[0] * runner_shift[sid][0] +
                     p->x[1] * runner_shift[sid][1] +
                     p->x[2] * runner_shift[sid][2];
-    if (fabsf(d - sort_i[pid].d) - ci->dx_max_sort > 1.0e-6)
+    if (fabsf(d - sort_i[pid].d) - ci->dx_max_sort >
+        1.0e-6 * max(fabsf(d), ci->dx_max_sort))
       error("particle shift diff exceeds dx_max_sort.");
   }
   for (int pjd = 0; pjd < cj->count; pjd++) {
@@ -923,7 +924,8 @@ void DOPAIR1(struct runner *r, struct cell *ci, struct cell *cj) {
     const float d = p->x[0] * runner_shift[sid][0] +
                     p->x[1] * runner_shift[sid][1] +
                     p->x[2] * runner_shift[sid][2];
-    if (fabsf(d - sort_j[pjd].d) - cj->dx_max_sort > 1.0e-6)
+    if (fabsf(d - sort_j[pjd].d) - cj->dx_max_sort >
+        1.0e-6 * max(fabsf(d), ci->dx_max_sort))
       error("particle shift diff exceeds dx_max_sort.");
   }
 #endif /* SWIFT_DEBUG_CHECKS */
-- 
GitLab