From db43eae967a8a4a62b372f28ddc7eca0917731d0 Mon Sep 17 00:00:00 2001
From: "Peter W. Draper" <p.w.draper@durham.ac.uk>
Date: Wed, 23 Aug 2017 18:19:55 +0100
Subject: [PATCH] Make sure we dump cells for any particles and avoid a
 possible issue with increment timing.

---
 src/debug.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/debug.c b/src/debug.c
index dca66ee45b..c9f12370f0 100644
--- a/src/debug.c
+++ b/src/debug.c
@@ -300,7 +300,7 @@ static void dumpCells_map(struct cell *c, void *data) {
 #endif
 
   /* Only locally active cells are dumped. */
-  if (c->count > 0)
+  if (c->count > 0 || c->gcount > 0 || c->scount > 0)
     fprintf(file,
             "  %6.3f %6.3f %6.3f %6.3f %6.3f %6.3f %6d %6d %6d %6d "
             "%6.1f %20lld %6d %6d %6d %6d\n",
@@ -324,8 +324,8 @@ void dumpCells(const char *prefix, struct space *s) {
   /* Name of output file. */
   static int nseq = 0;
   char fname[200];
-  sprintf(fname, "%s_%03d.dat", prefix, nseq);
-  atomic_inc(&nseq);
+  int uniq = atomic_inc(&nseq);
+  sprintf(fname, "%s_%03d.dat", prefix, uniq);
 
   file = fopen(fname, "w");
 
-- 
GitLab