Skip to content
Snippets Groups Projects
Commit 2b49b5af authored by Andreas Gattringer's avatar Andreas Gattringer
Browse files

butterflies: random walk debug: add id

parent cb0aac87
No related branches found
No related tags found
No related merge requests found
...@@ -60,7 +60,6 @@ static void inline single_random_walk(struct cats_thread_info *ts, struct cats_g ...@@ -60,7 +60,6 @@ static void inline single_random_walk(struct cats_thread_info *ts, struct cats_g
const unsigned long int direction = gsl_rng_uniform_int(ts->rng, N_DIRECTIONS); const unsigned long int direction = gsl_rng_uniform_int(ts->rng, N_DIRECTIONS);
const cats_dt_coord *offsets = DIRECTION_OFFSETS[direction]; const cats_dt_coord *offsets = DIRECTION_OFFSETS[direction];
const cats_dt_coord row_offset = offsets[0]; const cats_dt_coord row_offset = offsets[0];
const cats_dt_coord col_offset = offsets[1]; const cats_dt_coord col_offset = offsets[1];
...@@ -72,14 +71,15 @@ static void inline single_random_walk(struct cats_thread_info *ts, struct cats_g ...@@ -72,14 +71,15 @@ static void inline single_random_walk(struct cats_thread_info *ts, struct cats_g
col += col_offset; col += col_offset;
if (row >= rows || row < 0 || col >= cols || col < 0) { if (row >= rows || row < 0 || col >= cols || col < 0) {
if (debug_rw) {fclose(f);} if (debug_rw) { fclose(f); }
return; // we escaped the simulation extent and got lost return; // we escaped the simulation extent and got lost
} }
// is the cell a valid dispersal target location? // is the cell a valid dispersal target location?
if (!(data->info_layer[row][col] & BF_CELL_VALID_DISPERSAL_TARGET)) { if (!(data->info_layer[row][col] & BF_CELL_VALID_DISPERSAL_TARGET)) {
if (debug_rw) { if (debug_rw) {
fprintf(f, "%d,%d,%d,%d,%d,%d\n",row, col, steps + 1, module_conf->animal_dispersal_max_radius - steps -1,0, eggs_left); fprintf(f, "%d,%d,%d,%d,%d,%d\n", row, col, steps + 1,
module_conf->animal_dispersal_max_radius - steps - 1, 0, eggs_left);
} }
continue; continue;
...@@ -97,7 +97,8 @@ static void inline single_random_walk(struct cats_thread_info *ts, struct cats_g ...@@ -97,7 +97,8 @@ static void inline single_random_walk(struct cats_thread_info *ts, struct cats_g
data->eggs[row][col] += (float) eggs_to_deposit; data->eggs[row][col] += (float) eggs_to_deposit;
ts->temp2++; ts->temp2++;
if (debug_rw) { if (debug_rw) {
fprintf(f, "%d,%d,%d,%d,%d,%d\n",row, col, steps + 1, module_conf->animal_dispersal_max_radius - steps - 1, eggs_to_deposit, eggs_left); fprintf(f, "%d,%d,%d,%d,%d,%d,%d\n", rw_num, row, col, steps + 1,
module_conf->animal_dispersal_max_radius - steps - 1, eggs_to_deposit, eggs_left);
} }
...@@ -210,12 +211,21 @@ butterflies_cell_dispersal(struct cats_grid *grid, struct cats_thread_info *ts, ...@@ -210,12 +211,21 @@ butterflies_cell_dispersal(struct cats_grid *grid, struct cats_thread_info *ts,
if (debug_rw) { if (debug_rw) {
FILE *f = fopen(conf->run_name, "w"); FILE *f = fopen(conf->run_name, "w");
fprintf(f, "row,col,step,steps left,eggs deposited,eggs left\n"); fprintf(f, "id,row,col,step,steps left,eggs deposited,eggs left\n");
fprintf(f, "%d,%d,0,%d,%d,%d\n",row, col, module_conf->animal_dispersal_max_radius,(int) ceill(eggs_per_female * module_conf->egg_fraction_source), (int) ceill(eggs_to_disperse_per_female));
fclose(f); fclose(f);
} }
for (int32_t rw_number = 0; rw_number < wandering_females; rw_number++) { for (int32_t rw_number = 0; rw_number < wandering_females; rw_number++) {
if (debug_rw) {
FILE *f = fopen(conf->run_name, "a");
fprintf(f, "%d,%d,%d,%d,0,%d,%d\n", rw_number, row, col,
module_conf->animal_dispersal_max_radius,
(int) ceill(eggs_per_female * module_conf->egg_fraction_source),
(int) ceill(eggs_to_disperse_per_female));
fclose(f);
}
single_random_walk(ts, grid, row, col, eggs_to_disperse_per_female, egg_fraction_step, rw_number); single_random_walk(ts, grid, row, col, eggs_to_disperse_per_female, egg_fraction_step, rw_number);
ts->temp1++; ts->temp1++;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment