From f459bfa6e0e0153f47cbb7c09170b0bbe2f3923a Mon Sep 17 00:00:00 2001
From: Andreas Gattringer <gattringera@a772-cvl-ws23.biodiv.univie.ac.at>
Date: Wed, 28 Jun 2023 15:21:19 +0200
Subject: [PATCH] butterflies: debug generations update

---
 src/modules/butterflies/butterflies_generations.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/src/modules/butterflies/butterflies_generations.c b/src/modules/butterflies/butterflies_generations.c
index 54a6b5d..f234318 100644
--- a/src/modules/butterflies/butterflies_generations.c
+++ b/src/modules/butterflies/butterflies_generations.c
@@ -23,19 +23,26 @@ void bf_area_generation_update(struct cats_grid *grid, struct cats_thread_info *
 
         const cats_dt_rates ot = grid->param.OT;
 
+
+        int64_t cells_with_eggs = 0;
+        int64_t cells_with_eggs_removed = 0;
+
         for (cats_dt_coord row = start_row; row < end_row; row++) {
                 for (cats_dt_coord col = start_col; col < end_col; col++) {
 
 
                         if (get_suitability(grid, row, col) < ot)
                         {
+                                if (data->eggs[row][col] > 0) cells_with_eggs_removed += 1;
                                 data->eggs[row][col] = 0.0f;
                                 data->generations[row][col] = 0.0f;
                                 set_population_ignore_cc(grid, row, col, 0);
+
                                 continue;
                         }
 
                         if (cell_excluded_by_overlay(conf, row, col)) {
+                                if (data->eggs[row][col] > 0) cells_with_eggs_removed += 1;
                                 data->eggs[row][col] = 0.0f;
                                 data->generations[row][col] = 0.0f;
                                 set_population_ignore_cc(grid, row, col, 0);
@@ -43,6 +50,7 @@ void bf_area_generation_update(struct cats_grid *grid, struct cats_thread_info *
                         }
 
                         if ( ! (data->info_layer[row][col] & BF_CELL_VALID_DISPERSAL_TARGET)){
+                                if (data->eggs[row][col] > 0) cells_with_eggs_removed += 1;
                                 data->eggs[row][col] = 0.0f;
                                 data->generations[row][col] = 0.0f;
                                 set_population_ignore_cc(grid, row, col, 0);
@@ -51,7 +59,10 @@ void bf_area_generation_update(struct cats_grid *grid, struct cats_thread_info *
 
                         cats_dt_rates gen = calculate_rate(rate, 0, conf->param, grid, row, col, NULL);
                         data->generations[row][col] = (float) gen;
+                        if (data->eggs[row][col] > 0) cells_with_eggs += 1;
 
                 }
         }
+
+        log_message(LOG_INFO, "thread %d: %ld cells with eggs removed, %ld cells with eggs left", ts->id, cells_with_eggs_removed, cells_with_eggs);
 }
\ No newline at end of file
-- 
GitLab