From 8b838c62e4cb6f3f25aed8342e3fc8a498c9c369 Mon Sep 17 00:00:00 2001
From: Jacob Kegerreis <jacob.kegerreis@durham.ac.uk>
Date: Wed, 3 Jul 2019 12:54:30 +0100
Subject: [PATCH] TEMPORARY debug printing

---
 src/engine.c    |  6 ++++++
 src/single_io.c | 14 ++++++++++++++
 src/space.c     | 16 ++++++++--------
 3 files changed, 28 insertions(+), 8 deletions(-)

diff --git a/src/engine.c b/src/engine.c
index 9e8ae1104c..a61d16c640 100644
--- a/src/engine.c
+++ b/src/engine.c
@@ -3404,6 +3404,12 @@ void engine_launch(struct engine *e) {
 
   /* Sit back and wait for the runners to come home. */
   swift_barrier_wait(&e->wait_barrier);
+  
+  ///###
+  const size_t N_tot = e->s->nr_gparts - e->s->nr_inhibited_gparts;
+  const size_t N_gas = e->s->nr_gparts - e->s->nr_inhibited_gparts;
+  if(N_tot != N_gas)
+    error("Incompatible counts of particles!");
 
   if (e->verbose)
     message("took %.3f %s.", clocks_from_ticks(getticks() - tic),
diff --git a/src/single_io.c b/src/single_io.c
index 7a7856d29c..54bca31f58 100644
--- a/src/single_io.c
+++ b/src/single_io.c
@@ -728,6 +728,20 @@ void write_output_single(struct engine* e, const char* baseName,
   const size_t Ndm_written =
       Ntot_written > 0 ? Ntot_written - Nbaryons_written : 0;
 
+  ///###
+  message("Ntot_written = %zd", Ntot_written);
+  message("Ngas_written = %zd", Ngas_written);
+  message("Nstars_written = %zd", Nstars_written);
+  message("Nblackholes_written = %zd", Nblackholes_written);
+  message("Nbaryons_written = %zd", Nbaryons_written);
+  message("Ndm_written = %zd", Ndm_written);
+  message("e->s->nr_gparts = %lu", e->s->nr_gparts);
+  message("e->s->nr_inhibited_gparts = %lu", e->s->nr_inhibited_gparts);
+  message("e->s->nr_extra_gparts = %lu", e->s->nr_extra_gparts);
+  message("e->s->nr_parts = %lu", e->s->nr_parts);
+  message("e->s->nr_inhibited_parts = %lu", e->s->nr_inhibited_parts);
+  message("e->s->nr_extra_parts = %lu", e->s->nr_extra_parts);
+
   /* Format things in a Gadget-friendly array */
   long long N_total[swift_type_count] = {
       (long long)Ngas_written,   (long long)Ndm_written,        0, 0,
diff --git a/src/space.c b/src/space.c
index f7c3b7f779..a19524ed09 100644
--- a/src/space.c
+++ b/src/space.c
@@ -1307,7 +1307,7 @@ void space_rebuild(struct space *s, int repartitioned, int verbose) {
     }
   }
 
-#ifdef SWIFT_DEBUG_CHECKS
+///### #ifdef SWIFT_DEBUG_CHECKS
   /* Check that all parts are in the correct places. */
   size_t check_count_inhibited_part = 0;
   for (size_t k = 0; k < nr_parts; k++) {
@@ -1323,7 +1323,7 @@ void space_rebuild(struct space *s, int repartitioned, int verbose) {
   }
   if (check_count_inhibited_part != count_inhibited_parts)
     error("Counts of inhibited particles do not match!");
-#endif /* SWIFT_DEBUG_CHECKS */
+///### #endif /* SWIFT_DEBUG_CHECKS */
 
   /* Move non-local sparts and inhibited sparts to the end of the list. */
   if (!repartitioned && (s->e->nr_nodes > 1 || count_inhibited_sparts > 0)) {
@@ -1465,7 +1465,7 @@ void space_rebuild(struct space *s, int repartitioned, int verbose) {
     }
   }
 
-#ifdef SWIFT_DEBUG_CHECKS
+///### #ifdef SWIFT_DEBUG_CHECKS
   /* Check that all gparts are in the correct place. */
   size_t check_count_inhibited_gpart = 0;
   for (size_t k = 0; k < nr_gparts; k++) {
@@ -1481,7 +1481,7 @@ void space_rebuild(struct space *s, int repartitioned, int verbose) {
   }
   if (check_count_inhibited_gpart != count_inhibited_gparts)
     error("Counts of inhibited g-particles do not match!");
-#endif /* SWIFT_DEBUG_CHECKS */
+///### #endif /* SWIFT_DEBUG_CHECKS */
 
 #ifdef WITH_MPI
 
@@ -1619,7 +1619,7 @@ void space_rebuild(struct space *s, int repartitioned, int verbose) {
     space_parts_sort(s->parts, s->xparts, h_index, cell_part_counts,
                      s->nr_cells, 0);
 
-#ifdef SWIFT_DEBUG_CHECKS
+///### #ifdef SWIFT_DEBUG_CHECKS
   /* Verify that the part have been sorted correctly. */
   for (size_t k = 0; k < nr_parts; k++) {
     const struct part *p = &s->parts[k];
@@ -1643,7 +1643,7 @@ void space_rebuild(struct space *s, int repartitioned, int verbose) {
         p->x[2] < c->loc[2] || p->x[2] > c->loc[2] + c->width[2])
       error("part not sorted into the right top-level cell!");
   }
-#endif /* SWIFT_DEBUG_CHECKS */
+///### #endif /* SWIFT_DEBUG_CHECKS */
 
   /* Sort the sparts according to their cells. */
   if (nr_sparts > 0)
@@ -1794,7 +1794,7 @@ void space_rebuild(struct space *s, int repartitioned, int verbose) {
     space_gparts_sort(s->gparts, s->parts, s->sparts, s->bparts, g_index,
                       cell_gpart_counts, s->nr_cells);
 
-#ifdef SWIFT_DEBUG_CHECKS
+///### #ifdef SWIFT_DEBUG_CHECKS
   /* Verify that the gpart have been sorted correctly. */
   for (size_t k = 0; k < nr_gparts; k++) {
     const struct gpart *gp = &s->gparts[k];
@@ -1818,7 +1818,7 @@ void space_rebuild(struct space *s, int repartitioned, int verbose) {
         gp->x[2] < c->loc[2] || gp->x[2] > c->loc[2] + c->width[2])
       error("gpart not sorted into the right top-level cell!");
   }
-#endif /* SWIFT_DEBUG_CHECKS */
+///### #endif /* SWIFT_DEBUG_CHECKS */
 
   /* Extract the cell counts from the sorted indices. Deduct the extra
    * particles. */
-- 
GitLab