From 713381ec327753e57b38ba4bb9f4f76e633602f0 Mon Sep 17 00:00:00 2001
From: Matthieu Schaller <matthieu.schaller@durham.ac.uk>
Date: Tue, 13 Jun 2017 08:09:42 +0100
Subject: [PATCH] Use the same sorted-cell check in DOPAIR_SUBSET as the other
 DOPAIR functions.

---
 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 f83132e41d..9d297477bf 100644
--- a/src/runner_doiact.h
+++ b/src/runner_doiact.h
@@ -634,8 +634,10 @@ void DOPAIR_SUBSET(struct runner *r, struct cell *restrict ci,
   const int flipped = runner_flip[sid];
   sid = sortlistID[sid];
 
-  /* Have the cells been sorted? */
-  if (!(cj->sorted & (1 << sid))) error("Interacting unsorted cells.");
+  /* Has the cell cj been sorted? */
+  if (!(cj->sorted & (1 << sid)) ||
+      cj->dx_max_sort_old > space_maxreldx * cj->dmin)
+    error("Interacting unsorted cells.");
 
   /* Pick-out the sorted lists. */
   const struct entry *restrict sort_j = &cj->sort[sid * (cj->count + 1)];
-- 
GitLab