From 72095038012d2a236ec95e329d8ce63b6927f359 Mon Sep 17 00:00:00 2001 From: Andreas Gattringer <andreas.gattringer@univie.ac.at> Date: Mon, 3 Jul 2023 14:23:16 +0200 Subject: [PATCH] butterflies: renamed debug variables and improved rw debug output --- src/modules/butterflies/butterflies_actions.c | 13 ++++++++----- src/modules/butterflies/butterflies_dispersal.c | 6 +++--- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/modules/butterflies/butterflies_actions.c b/src/modules/butterflies/butterflies_actions.c index 9231a67..40e05cd 100644 --- a/src/modules/butterflies/butterflies_actions.c +++ b/src/modules/butterflies/butterflies_actions.c @@ -98,7 +98,7 @@ void grid_butterflies_maturation(struct cats_grid *grid, struct cats_thread_info const cats_dt_coord start_col = ts->area.start_col; const cats_dt_coord end_col = ts->area.end_col; - ts->temp_adults_present = 0; + ts->rw_debug_cells_with_adults = 0; for (cats_dt_coord row = start_row; row < end_row; row++) { for (cats_dt_coord col = start_col; col < end_col; col++) { @@ -122,9 +122,9 @@ void butterflies_area_dispersal(struct cats_grid *grid, struct cats_thread_info const cats_dt_coord start_col = ts->area.start_col; const cats_dt_coord end_col = ts->area.end_col; - ts->temp_adults_present = 0; - ts->temp1 = 0; - ts->temp2 = 0; + ts->rw_debug_cells_with_adults = 0; + ts->rw_debug_random_walks = 0; + ts->rw_debug_deposits = 0; for (cats_dt_coord row = start_row; row < end_row; row++) { @@ -138,7 +138,10 @@ void butterflies_area_dispersal(struct cats_grid *grid, struct cats_thread_info butterflies_cell_dispersal(grid, ts, row, col, false); } } - if (ts->temp_adults_present) printf("thread %d: %ld random walks (%ld cells) avg %f\n", ts->id, ts->temp_adults_present, ts->temp1, (float) ts->temp_adults_present / (float) ts->temp1); + if (ts->rw_debug_cells_with_adults) { + printf("thread %d: %ld cells with adults, %ld random walks, %ld deposits\n", + ts->id, ts->rw_debug_cells_with_adults, ts->rw_debug_random_walks, ts->rw_debug_deposits); + } } diff --git a/src/modules/butterflies/butterflies_dispersal.c b/src/modules/butterflies/butterflies_dispersal.c index ec65d61..1582d7f 100644 --- a/src/modules/butterflies/butterflies_dispersal.c +++ b/src/modules/butterflies/butterflies_dispersal.c @@ -91,7 +91,7 @@ static void inline single_random_walk(struct cats_thread_info *ts, struct cats_g eggs_left -= eggs_to_deposit; data->eggs[row][col] += (float) eggs_to_deposit; - ts->temp2++; + ts->rw_debug_deposits++; if (debug_rw) { fprintf(module_conf->debug_rw_file, "%d,%d,%d,%d,%d,%d,%d\n", rw_num, row, col, step + 1, module_conf->animal_dispersal_max_radius - step - 1, eggs_to_deposit, eggs_left); @@ -119,7 +119,7 @@ butterflies_cell_dispersal(struct cats_grid *grid, struct cats_thread_info *ts, // total adults: the number of adults that became adult in this cell, possibly exceeding the carrying capacity (thanks to poisson processes) const cats_dt_population total_adults = get_adult_population(grid, row, col); if (total_adults == 0) return; - ts->temp_adults_present++; + ts->rw_debug_cells_with_adults++; struct conf_data_butterflies *module_conf = CATS_MODULE_DATA; // total females: how many of the total adults are female, as drawn from a binomial distribution with p = 0.5 // can be safely cast, because gsl_ran_binomial will return a number <= total_adults @@ -230,7 +230,7 @@ butterflies_cell_dispersal(struct cats_grid *grid, struct cats_thread_info *ts, single_random_walk(ts, grid, row, col, eggs_to_disperse_per_female, egg_fraction_step, rw_number); - ts->temp1++; + ts->rw_debug_random_walks++; } if (debug_rw) { fflush(module_conf->debug_rw_file); -- GitLab