Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cats
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
BDC
cats
Commits
2b49b5af
Commit
2b49b5af
authored
2 years ago
by
Andreas Gattringer
Browse files
Options
Downloads
Patches
Plain Diff
butterflies: random walk debug: add id
parent
cb0aac87
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/modules/butterflies/butterflies_dispersal.c
+17
-7
17 additions, 7 deletions
src/modules/butterflies/butterflies_dispersal.c
with
17 additions
and
7 deletions
src/modules/butterflies/butterflies_dispersal.c
+
17
−
7
View file @
2b49b5af
...
@@ -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
++
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment