25 character (len=*),
parameter,
private ::
modname =
"(THE_ENVIRONMENT)"
52 real(
srp) :: x, y, depth
80 procedure,
public :: distance_segment2d => &
86 procedure,
public :: distance_segment => &
130 generic,
public :: location => now_o, now_v
133 generic,
public :: now => now_o, now_v
178 type(
spatial),
dimension(HISTORY_SIZE_SPATIAL) :: history
191 procedure,
public :: repeat_position => &
228 generic,
public :: rwalk => rwalk3d, rwalk25d
246 generic,
public :: corwalk => corwalk3d, corwalk25d
263 generic,
public :: dirwalk => dirwalk3d, dirwalk25d
299 generic,
public :: build => build_vector, build_object, build_unlimited
329 procedure,
public :: nearest_target => &
355 generic,
public :: uniform => uniform_s,uniform2_s,uniform_v,uniform2_v
436 character (len=LABEL_LENGTH) :: food_label
439 integer :: number_food_items
508 character (len=LABEL_LENGTH) :: label
540 procedure,
public :: risk_fish_group => &
557 character (len=LABEL_LENGTH) :: habitat_name
559 real(
srp) :: risk_mortality
561 real(
srp) :: risk_egg_mortality
564 integer :: predators_number
575 type(
predator),
allocatable,
dimension(:) :: predators
821 interface operator (.cat.)
822 procedure spatial_stack2arrays
823 procedure spatial_moving_stack2arrays
824 end interface operator (.cat.)
837 interface operator (.catloc.)
838 procedure spatial_class_stack2arrays_locs
839 end interface operator (.catloc.)
848 procedure spatial_check_located_within_3d
849 end interface operator (.within.)
858 interface operator (.contains.)
859 procedure environment_check_located_within_3d
860 end interface operator (.contains.)
880 interface operator (.above.)
881 procedure spatial_check_located_below
882 end interface operator (.above.)
902 interface operator (.below.)
903 procedure spatial_check_located_above
904 end interface operator (.below.)
914 interface operator (-)
915 procedure environment_shrink_xy_fixed
916 end interface operator (-)
940 class(
spatial),
intent(inout) :: this
965 real(SRP),
dimension(3),
intent(in) :: min_coord, max_coord
970 call this%coord_min%position(
spatial( &
971 min_coord(1), min_coord(2), min_coord(3)) )
972 call this%coord_max%position(
spatial( &
973 max_coord(1), max_coord(2), max_coord(3)) )
993 type(
spatial),
intent(in) :: min_coord, max_coord
996 this%coord_min = min_coord
997 this%coord_max = max_coord
1011 real(SRP),
parameter :: MAX_COORD=huge(0.0)
1012 real(SRP),
parameter :: MIN_COORD=-1_srp*huge(0.0)
1014 call this%build(
spatial(min_coord, min_coord, min_coord), &
1015 spatial(max_coord, max_coord, max_coord) )
1049 real(
srp),
intent(in) :: shrink_value
1052 call shrunken%build( [ this%coord_min%x + shrink_value, &
1053 this%coord_min%y + shrink_value, &
1054 this%coord_min%depth ], &
1055 [ this%coord_max%x - shrink_value, &
1056 this%coord_max%y - shrink_value, &
1057 this%coord_max%depth ] )
1073 posout = this%coord_min%location()
1089 posout = this%coord_max%location()
1098 real(
srp) :: mindepth
1100 mindepth = min( this%coord_min%dpos(), this%coord_max%dpos() )
1109 real(
srp) :: maxdepth
1111 maxdepth = max( this%coord_min%dpos(), this%coord_max%dpos() )
1127 real(
srp),
optional,
intent(in) :: ref_depth
1145 real(
srp),
optional,
intent(in) :: offset
1150 type(
spatial),
dimension(DIM_ENVIRON_CORNERS) :: corners
1154 real(
srp),
parameter :: ref_depth_def = 0.0_srp
1157 real(
srp) :: ref_depth_loc, offset_loc
1160 if (
present(ref_depth))
then
1161 ref_depth_loc = ref_depth
1163 ref_depth_loc = ref_depth_def
1165 if (
present(offset))
then
1168 offset_loc = 0.0_srp
1184 corners(1) =
spatial( this%coord_min%x + offset_loc, &
1185 this%coord_min%y + offset_loc, ref_depth_loc)
1187 corners(2) =
spatial( this%coord_max%x - offset_loc, &
1188 this%coord_min%y + offset_loc, ref_depth_loc)
1190 corners(3) =
spatial( this%coord_max%x - offset_loc, &
1191 this%coord_max%y - offset_loc, ref_depth_loc)
1193 corners(4) =
spatial( this%coord_min%x + offset_loc, &
1194 this%coord_max%y - offset_loc, ref_depth_loc)
1216 class(
spatial),
intent(in) :: check_object
1221 if (check_object%x >= this%coord_min%x .and. &
1222 check_object%y >= this%coord_min%y .and. &
1223 check_object%depth >= this%coord_min%depth .and. &
1224 check_object%x <= this%coord_max%x .and. &
1225 check_object%y <= this%coord_max%y .and. &
1226 check_object%depth <= this%coord_max%depth )
then
1250 uniform =
spatial( rand(this%coord_min%x, this%coord_max%x), &
1251 rand(this%coord_min%y, this%coord_max%y), &
1252 rand(this%coord_min%depth, this%coord_max%depth) )
1264 real(
srp),
intent(in) :: fixdepth
1274 uniform =
spatial( rand(this%coord_min%x, this%coord_max%x), &
1275 rand(this%coord_min%y, this%coord_max%y), &
1294 integer,
intent(in) :: num
1298 type(
spatial),
dimension(num) :: uniform
1318 uniform(i) = this%uniform_s()
1336 real(
srp),
dimension(:),
intent(in) :: fixdep_array
1340 type(
spatial),
dimension(size(fixdep_array)) :: uniform
1348 do i=1,
size(fixdep_array)
1355 uniform(i) =
spatial( rand(this%coord_min%x, this%coord_max%x), &
1356 rand(this%coord_min%y, this%coord_max%y), &
1371 num, centroid, variance)
result (gaussian)
1375 integer,
intent(in) :: num
1379 class(
spatial),
optional,
intent(in) :: centroid
1382 real(
srp),
optional,
intent(in) :: variance
1385 type(
spatial),
dimension(num) :: gaussian
1388 type(
spatial) :: centroid_here
1391 real(
srp) :: x_coord, y_coord, d_coord, variance_here
1398 if (
present(centroid))
then
1399 if ( this%is_within(centroid) )
then
1402 call centroid_here%position( centroid%location() )
1406 call centroid_here%position( this%uniform() )
1409 call centroid_here%position( this%uniform() )
1413 if (
present(variance))
then
1414 variance_here = variance
1416 variance_here = 1.0_srp
1423 x_coord = rnorm( centroid_here%x, variance_here )
1424 y_coord = rnorm( centroid_here%y, variance_here )
1425 d_coord = rnorm( centroid_here%depth, variance_here )
1427 do while ( this%is_within(
spatial(x_coord, y_coord, d_coord) ) )
1428 x_coord = rnorm( centroid_here%x, variance_here )
1429 y_coord = rnorm( centroid_here%y, variance_here )
1430 d_coord = rnorm( centroid_here%depth, variance_here )
1433 gaussian(i) =
spatial(x_coord, y_coord, d_coord)
1451 num, centroid, fixdepth, variance, variance_depth) &
1456 integer,
intent(in) :: num
1460 class(
spatial),
optional,
intent(in) :: centroid
1463 real(
srp),
optional,
intent(in) :: fixdepth
1466 real(
srp),
optional,
intent(in) :: variance
1469 real(
srp),
optional,
intent(in) :: variance_depth
1472 type(
spatial),
dimension(num) :: gaussian
1475 type(
spatial) :: centroid_here
1478 real(
srp) :: x_coord, y_coord, d_coord, variance_here
1485 check_centroid:
if (
present(centroid))
then
1486 check_depth1:
if (
present(fixdepth))
then
1488 if ( fixdepth >= this%coord_min%dpos() .and. &
1489 fixdepth <= this%coord_max%dpos() )
then
1492 call centroid_here%position( &
1493 spatial( centroid%xpos(), centroid%ypos(), fixdepth ) )
1496 if (.not. this%is_within( centroid_here ) )
then
1502 call centroid_here%position( centroid%location() )
1506 if (.not. this%is_within( centroid_here ) )
then
1513 if ( this%is_within(centroid) )
then
1516 call centroid_here%position( centroid%location() )
1529 check_depth2:
if (
present(fixdepth))
then
1530 if ( fixdepth >= this%coord_min%dpos() .and. &
1531 fixdepth <= this%coord_max%dpos() )
then
1533 call centroid_here%position( this%uniform( fixdepth ) )
1536 call centroid_here%position( this%uniform( ) )
1541 call centroid_here%position( this%uniform( ) )
1543 end if check_centroid
1546 if (
present(variance))
then
1547 variance_here = variance
1549 variance_here = 1.0_srp
1554 depth_stochastic:
if (
present(variance_depth))
then
1560 x_coord = rnorm( centroid_here%x, variance_here )
1561 y_coord = rnorm( centroid_here%y, variance_here )
1562 d_coord = rnorm( centroid_here%depth, variance_depth )
1564 do while ( .not. this%is_within(
spatial(x_coord, y_coord, d_coord) ) )
1565 x_coord = rnorm( centroid_here%x, variance_here )
1566 y_coord = rnorm( centroid_here%y, variance_here )
1567 d_coord = rnorm( centroid_here%depth, variance_depth )
1570 gaussian(i) =
spatial(x_coord, y_coord, d_coord)
1572 else depth_stochastic
1576 d_coord = centroid_here%dpos()
1581 x_coord = rnorm( centroid_here%x, variance_here )
1582 y_coord = rnorm( centroid_here%y, variance_here )
1584 do while ( .not. this%is_within(
spatial(x_coord, y_coord, d_coord) ) )
1585 x_coord = rnorm( centroid_here%x, variance_here )
1586 y_coord = rnorm( centroid_here%y, variance_here )
1589 gaussian(i) =
spatial(x_coord, y_coord, d_coord)
1591 end if depth_stochastic
1598 real(
srp),
optional :: fixed_depth
1600 if (
present(fixed_depth))
then
1602 centroid_out = this%uniform( fixed_depth )
1604 do while ( .not. this%is_within(centroid_out) )
1605 centroid_out = this%uniform( fixed_depth )
1609 centroid_out = this%uniform( )
1611 do while ( .not. this%is_within(centroid_out) )
1612 centroid_out = this%uniform( )
1633 offset_into, point_spatial, point_dist)
1638 class(
spatial),
intent(in) :: outside_object
1661 real(SRP),
optional,
intent(in) :: offset_into
1665 type(
spatial),
optional,
intent(out) :: point_spatial
1667 real(SRP),
optional,
intent(out) :: point_dist
1673 type(
spatial),
dimension(DIM_ENVIRON_CORNERS) :: corners
1677 type(
spatial),
dimension(DIM_ENVIRON_CORNERS) :: segment_nearest_obj
1678 real(SRP),
dimension(DIM_ENVIRON_CORNERS) :: segment_distance
1688 if ( this%is_within(outside_object) )
then
1689 if (
present(point_spatial)) &
1690 call point_spatial%position( outside_object%location() )
1691 if (
present(point_dist)) point_dist = 0.0_srp
1699 if (
present(offset_into))
then
1703 corners = this%corners2d( ref_depth = outside_object%depth, &
1704 offset=offset_into )
1706 corners = this%corners2d( ref_depth = outside_object%depth )
1724 do i=1,
size(corners)-1
1725 call outside_object%distance_segment2d( &
1726 sectp1=corners( i ), &
1727 sectp2=corners( i+1 ), &
1728 min_dist=segment_distance( i ), &
1729 point_segment=segment_nearest_obj( i ))
1731 call outside_object%distance_segment2d( &
1732 sectp1=corners(
size(corners) ), &
1733 sectp2=corners( 1 ), &
1734 min_dist=segment_distance(
size(corners) ), &
1735 point_segment=segment_nearest_obj(
size(corners) ))
1741 if (
present(point_spatial)) &
1742 point_spatial = segment_nearest_obj( minloc(segment_distance,1) )
1744 if (
present(point_dist)) point_dist = minval(segment_distance)
1757 class(
spatial),
intent(inout) :: this
1760 real(SRP),
intent(in) :: x,y,depth
1777 class(
spatial),
intent(inout) :: this
1781 type(
spatial),
intent(in) :: location
1785 this%depth = location%depth
1793 class(
spatial),
intent(inout) :: this
1807 class(
spatial),
intent(in) :: this
1811 coordinates%x = this%x
1812 coordinates%y = this%y
1813 coordinates%depth = this%depth
1837 class(
spatial),
intent(in) :: this
1845 logical,
intent(in) :: vector
1847 real(
srp),
dimension(DIMENSIONALITY_DEFAULT) :: coordinates
1849 coordinates(1) = this%x
1850 coordinates(2) = this%y
1851 coordinates(3) = this%depth
1860 class(
spatial),
intent(in) :: this
1873 class(
spatial),
intent(in) :: this
1886 class(
spatial),
intent(in) :: this
1888 real(
srp) :: depth_pos
1890 depth_pos = this%depth
1902 result(irradiance_at_depth)
1903 class(
spatial),
intent(in) :: this
1904 integer,
optional,
intent(in) :: time_step_model
1905 real(
srp) :: irradiance_at_depth
1908 integer :: time_step_model_here
1913 if (
present(time_step_model))
then
1914 time_step_model_here = time_step_model
1921 irradiance_at_depth = &
1924 tstep=time_step_model_here, &
1939 time_step_model)
result (visrange)
1940 class(
spatial),
intent(in) :: this
1951 real(
srp),
optional,
intent(in) :: object_area
1955 real(
srp),
optional,
intent(in) :: contrast
1959 integer,
optional,
intent(in) :: time_step_model
1961 real(
srp) :: visrange
1964 integer :: time_step_model_here
1965 real(
srp) :: object_area_here, contrast_here
1968 real(
srp) :: irradiance_agent_depth
1971 character(len=*),
parameter ::
procname = &
1972 "(spatial_visibility_visual_range_m)"
1979 if (
present(object_area))
then
1980 object_area_here = object_area
1986 call log_msg(
ltag_error //
"Object area ('object_area') parameter is" //&
1987 " not provided for a base SPATIAL class object in" // &
1988 procname //
": MISSING value is used for area.")
1992 if (
present(contrast))
then
1993 contrast_here = contrast
2000 if (
present(time_step_model))
then
2001 time_step_model_here = time_step_model
2008 irradiance_agent_depth = this%illumination(time_step_model_here)
2012 prey_area = object_area_here, &
2013 prey_contrast = contrast_here ) )
2040 result(environ_list_number)
2041 class(
spatial),
intent(in) :: this
2049 class(
environment),
optional,
dimension(:),
intent(in) :: environments_array
2052 integer :: environ_list_number
2055 integer :: number_environments
2060 array_provided:
if (
present(environments_array))
then
2065 number_environments =
size(environments_array)
2068 environ_list_number = 0
2072 do concurrent(i=1:number_environments)
2073 if (this .
within. environments_array(i) )
then
2078 environ_list_number = i
2096 environ_list_number = 0
2100 do concurrent(i=1:number_environments)
2106 environ_list_number = i
2111 end if array_provided
2125 real(SRP),
intent(in) :: x,y,depth
2148 type(
spatial),
intent(in) :: location
2159 this%depth = location%depth
2191 result(distance_euclidean)
2192 class(
spatial),
intent(in) :: this
2194 real(
srp) :: distance_euclidean
2196 class(
spatial),
intent(in) :: other
2206 distance_euclidean =
dist( [this%x, this%y, this%depth], &
2207 [other%x, other%y, other%depth] )
2225 type(
spatial),
intent(in),
dimension(:) :: a
2227 type(
spatial),
intent(in),
dimension(:) :: b
2229 type(
spatial),
dimension(:),
allocatable :: c
2231 allocate(c(
size(a)+
size(b)))
2233 c(
size(a)+1:
size(a)+
size(b)) = b
2258 allocate(c(
size(a)+
size(b)))
2260 c(
size(a)+1:
size(a)+
size(b)) = b
2282 class(
spatial),
intent(in),
dimension(:) :: a
2284 class(
spatial),
intent(in),
dimension(:) :: b
2286 type(
spatial),
dimension(:),
allocatable :: c
2288 allocate(c(
size(a)+
size(b)))
2289 call c(1:
size(a))%position( a%location() )
2290 call c(
size(a)+1:
size(a)+
size(b))%position( b%location() )
2306 elemental function dist3d (this, other)
result (distance_euclidean)
2307 class(
spatial),
intent(in) :: this
2309 real(
srp) :: distance_euclidean
2311 class(
spatial),
intent(in) :: other
2321 distance_euclidean =
dist(this%x, other%x, &
2323 this%depth, other%depth)
2335 result(distance_euclidean)
2336 class(
spatial),
intent(in) :: this
2339 integer,
optional,
intent(in) :: from_history
2341 real(
srp) :: distance_euclidean
2346 distance_euclidean=0.0_srp
2368 result(distance_euclidean)
2372 integer,
optional,
intent(in) :: from_history
2374 real(
srp) :: distance_euclidean
2377 integer :: from_history_here
2380 integer :: history_size
2389 history_size =
size(this%history)
2397 if (
present(from_history))
then
2399 from_history_here = from_history
2404 from_history_here = 0
2409 distance_euclidean=
dist( this%x, this%history(history_size)%x, &
2410 this%y, this%history(history_size)%y, &
2411 this%depth, this%history(history_size)%depth )
2421 do i = history_size, history_size-from_history_here+1, -1
2422 distance_euclidean = distance_euclidean + &
2423 dist( this%history(i)%x, this%history(i-1)%x, &
2424 this%history(i)%y, this%history(i-1)%y, &
2425 this%history(i)%depth, this%history(i-1)%depth )
2446 call this%spatial_history_clean()
2472 real(
srp),
optional,
intent(in) :: step
2475 real(
srp) :: min_depth
2478 real(
srp) :: step_here
2489 this%find_environment( &
2503 if (this%dpos() - step_here <= min_depth ) &
2504 step_here = max( 0.0_srp, this%dpos() - min_depth -
zero )
2515 if (this%is_available()) &
2516 call this%position(
spatial( x = this%x, &
2518 depth = this%depth - step_here ) )
2520 call this%position(
spatial( x = this%x, &
2522 depth = this%depth - step_here ) )
2535 real(
srp),
optional,
intent(in) :: step
2538 real(
srp) :: max_depth
2541 real(
srp) :: step_here
2552 this%find_environment( &
2566 if (this%dpos() + step_here >= max_depth ) &
2567 step_here = max( 0.0_srp, max_depth - this%dpos() -
zero )
2577 if (this%is_available()) &
2578 call this%position(
spatial( x = this%x, &
2580 depth = this%depth + step_here ) )
2582 call this%position(
spatial( x = this%x, &
2584 depth = this%depth + step_here ) )
2605 cv_shift, environment_limits)
2609 real(SRP),
intent(in) :: meanshift
2612 real(SRP),
intent(in) :: cv_shift
2615 class(
environment),
intent(in),
optional :: environment_limits
2619 type(
spatial) :: current_pos, test_object
2625 current_pos = this%now()
2630 call test_object%position(
spatial( &
2631 x=current_pos%x .radd. &
2632 rnorm( meanshift,
cv2variance(cv_shift, meanshift) ), &
2633 y=current_pos%y .radd. &
2634 rnorm( meanshift,
cv2variance(cv_shift, meanshift) ), &
2635 depth=current_pos%depth .radd. &
2636 rnorm( meanshift,
cv2variance(cv_shift, meanshift) ) ))
2642 environ_restrict:
if (
present(environment_limits))
then
2646 do while (.NOT. test_object%is_within(environment_limits))
2649 call test_object%position(
spatial( &
2650 x=current_pos%x .radd. &
2651 rnorm( meanshift,
cv2variance(cv_shift, meanshift) ), &
2652 y=current_pos%y .radd. &
2653 rnorm( meanshift,
cv2variance(cv_shift, meanshift) ), &
2654 depth=current_pos%depth .radd. &
2655 rnorm( meanshift,
cv2variance(cv_shift, meanshift) ) ))
2657 end if environ_restrict
2662 call this%position(test_object)
2687 meanshift_xy, cv_shift_xy, &
2688 meanshift_depth, cv_shift_depth, &
2693 real(SRP),
intent(in) :: meanshift_xy, meanshift_depth
2696 real(SRP),
intent(in) :: cv_shift_xy, cv_shift_depth
2699 class(
environment),
intent(in),
optional :: environment_limits
2703 type(
spatial) :: current_pos, test_object
2709 current_pos = this%now()
2714 call test_object%position(
spatial( &
2715 x=current_pos%x .radd. &
2716 rnorm( meanshift_xy, &
2718 y=current_pos%y .radd. &
2719 rnorm( meanshift_xy, &
2721 depth=current_pos%depth .radd. &
2722 rnorm( meanshift_depth, &
2723 cv2variance(cv_shift_depth, meanshift_depth) ) ) )
2729 environ_restrict:
if (
present(environment_limits))
then
2733 do while (.NOT. test_object%is_within(environment_limits))
2736 call test_object%position(
spatial( &
2737 x=current_pos%x .radd. &
2738 rnorm( meanshift_xy, &
2740 y=current_pos%y .radd. &
2741 rnorm( meanshift_xy, &
2743 depth=current_pos%depth .radd. &
2744 rnorm( meanshift_depth, &
2745 cv2variance(cv_shift_depth, meanshift_depth) ) ) )
2747 end if environ_restrict
2752 call this%position(test_object)
2770 environment_limits,&
2775 class(
spatial),
intent(in) :: target
2777 real(SRP),
intent(in) :: meanshift
2780 real(SRP),
intent(in) :: cv_shift
2785 logical,
optional,
intent(in) :: is_away
2803 real(SRP),
optional,
intent(in) :: ci_lim
2807 class(
environment),
intent(in),
optional :: environment_limits
2812 logical,
optional,
intent(out) :: is_converged
2821 integer,
optional,
intent(out) :: debug_reps
2825 type(
spatial) :: current_pos, test_object
2832 real(SRP) :: perc_ci
2835 real(SRP),
parameter :: PERC_CI_DEF = 1.95996
2838 integer,
parameter :: CONVERG = 100
2846 if (
present(is_away))
then
2851 if(
present(ci_lim))
then
2854 perc_ci = perc_ci_def
2864 if ( .not. move_out .and. &
2865 this%distance(
target) < perc_ci * meanshift * cv_shift )
then
2866 if (
present(is_converged))
then
2867 is_converged = .
true.
2869 if(
present(debug_reps))
then
2879 current_pos = this%now()
2886 call test_object%position(
spatial( &
2887 x=current_pos%x .radd. &
2888 rnorm( meanshift,
cv2variance(cv_shift, meanshift) ), &
2889 y=current_pos%y .radd. &
2890 rnorm( meanshift,
cv2variance(cv_shift, meanshift) ), &
2891 depth=current_pos%depth .radd. &
2892 rnorm( meanshift,
cv2variance(cv_shift, meanshift) ) ) )
2908 away:
if (move_out)
then
2909 environ_restrict1:
if (
present(environment_limits))
then
2912 do while ( test_object%distance(
target) < this%distance(
target) .or. &
2913 .NOT. test_object%is_within(environment_limits) )
2915 if (erep > converg)
exit
2919 call test_object%position(
spatial( &
2920 x=current_pos%x .radd. &
2921 rnorm( meanshift,
cv2variance(cv_shift, meanshift) ), &
2922 y=current_pos%y .radd. &
2923 rnorm( meanshift,
cv2variance(cv_shift, meanshift) ), &
2924 depth=current_pos%depth .radd. &
2925 rnorm( meanshift,
cv2variance(cv_shift, meanshift) ) ) )
2927 else environ_restrict1
2928 do while ( test_object%distance(
target) < this%distance(
target) )
2930 if (erep > converg)
exit
2934 call test_object%position(
spatial( &
2935 x=current_pos%x .radd. &
2936 rnorm( meanshift,
cv2variance(cv_shift, meanshift) ), &
2937 y=current_pos%y .radd. &
2938 rnorm( meanshift,
cv2variance(cv_shift, meanshift) ), &
2939 depth=current_pos%depth .radd. &
2940 rnorm( meanshift,
cv2variance(cv_shift, meanshift) ) ) )
2942 end if environ_restrict1
2944 environ_restrict2:
if (
present(environment_limits))
then
2947 do while ( test_object%distance(
target) > this%distance(
target) .or. &
2948 .NOT. test_object%is_within(environment_limits) )
2950 if (erep > converg)
exit
2954 call test_object%position(
spatial( &
2955 x=current_pos%x .radd. &
2956 rnorm( meanshift,
cv2variance(cv_shift, meanshift) ), &
2957 y=current_pos%y .radd. &
2958 rnorm( meanshift,
cv2variance(cv_shift, meanshift) ), &
2959 depth=current_pos%depth .radd. &
2960 rnorm( meanshift,
cv2variance(cv_shift, meanshift) ) ) )
2962 else environ_restrict2
2963 do while ( test_object%distance(
target) > this%distance(
target) )
2965 if (erep > converg)
exit
2969 call test_object%position(
spatial( &
2970 x=current_pos%x .radd. &
2971 rnorm( meanshift,
cv2variance(cv_shift, meanshift) ), &
2972 y=current_pos%y .radd. &
2973 rnorm( meanshift,
cv2variance(cv_shift, meanshift) ), &
2974 depth=current_pos%depth .radd. &
2975 rnorm( meanshift,
cv2variance(cv_shift, meanshift) ) ) )
2977 end if environ_restrict2
2982 if (erep < converg)
call this%position(test_object)
2986 if ( .not. move_out .and. &
2987 this%distance(
target) < perc_ci * meanshift * cv_shift )
then
2988 if (
present(is_converged))
then
2989 is_converged = .
true.
2993 if(
present(debug_reps))
then
3014 environment_limits,&
3019 class(
spatial),
intent(in) :: target
3021 real(SRP),
intent(in) :: meanshift_xy
3024 real(SRP),
intent(in) :: cv_shift_xy
3026 real(SRP),
intent(in) :: meanshift_depth
3029 real(SRP),
intent(in) :: cv_shift_depth
3034 logical,
optional,
intent(in) :: is_away
3052 real(SRP),
optional,
intent(in) :: ci_lim
3056 class(
environment),
intent(in),
optional :: environment_limits
3061 logical,
optional,
intent(out) :: is_converged
3070 integer,
optional,
intent(out) :: debug_reps
3074 type(
spatial) :: current_pos, test_object
3081 real(SRP) :: perc_ci
3084 real(SRP),
parameter :: PERC_CI_DEF = 1.95996
3087 integer,
parameter :: CONVERG = 100
3095 if (
present(is_away))
then
3100 if(
present(ci_lim))
then
3103 perc_ci = perc_ci_def
3113 if ( .not. move_out .and. &
3114 this%distance(
target) < perc_ci * meanshift_xy * cv_shift_xy )
then
3115 if (
present(is_converged))
then
3116 is_converged = .
true.
3118 if(
present(debug_reps))
then
3128 current_pos = this%now()
3135 call test_object%position(
spatial( &
3136 x=current_pos%x .radd. &
3137 rnorm( meanshift_xy, &
3139 y=current_pos%y .radd. &
3140 rnorm( meanshift_xy, &
3142 depth=current_pos%depth .radd. &
3143 rnorm( meanshift_depth, &
3144 cv2variance(cv_shift_depth, meanshift_depth) ) ) )
3160 away:
if (move_out)
then
3161 environ_restrict1:
if (
present(environment_limits))
then
3164 do while ( test_object%distance(
target) < this%distance(
target) .or. &
3165 .NOT. test_object%is_within(environment_limits) )
3167 if (erep > converg)
exit
3171 call test_object%position(
spatial( &
3172 x=current_pos%x .radd. &
3173 rnorm( meanshift_xy, &
3175 y=current_pos%y .radd. &
3176 rnorm( meanshift_xy, &
3178 depth=current_pos%depth .radd. &
3179 rnorm( meanshift_depth, &
3182 else environ_restrict1
3183 do while ( test_object%distance(
target) < this%distance(
target) )
3185 if (erep > converg)
exit
3189 call test_object%position(
spatial( &
3190 x=current_pos%x .radd. &
3191 rnorm( meanshift_xy, &
3193 y=current_pos%y .radd. &
3194 rnorm( meanshift_xy, &
3196 depth=current_pos%depth .radd. &
3197 rnorm( meanshift_depth, &
3200 end if environ_restrict1
3202 environ_restrict2:
if (
present(environment_limits))
then
3205 do while ( test_object%distance(
target) > this%distance(
target) .or. &
3206 .NOT. test_object%is_within(environment_limits) )
3208 if (erep > converg)
exit
3212 call test_object%position(
spatial( &
3213 x=current_pos%x .radd. &
3214 rnorm( meanshift_xy, &
3216 y=current_pos%y .radd. &
3217 rnorm( meanshift_xy, &
3219 depth=current_pos%depth .radd. &
3220 rnorm( meanshift_depth, &
3223 else environ_restrict2
3224 do while ( test_object%distance(
target) > this%distance(
target) )
3226 if (erep > converg)
exit
3230 call test_object%position(
spatial( &
3231 x=current_pos%x .radd. &
3232 rnorm( meanshift_xy, &
3234 y=current_pos%y .radd. &
3235 rnorm( meanshift_xy, &
3237 depth=current_pos%depth .radd. &
3238 rnorm( meanshift_depth, &
3241 end if environ_restrict2
3246 if (erep < converg)
call this%position(test_object)
3250 if ( .not. move_out .and. &
3251 this%distance(
target) < perc_ci * meanshift_xy * cv_shift_xy )
then
3252 if (
present(is_converged))
then
3253 is_converged = .
true.
3257 if(
present(debug_reps))
then
3295 class(
spatial),
intent(in) :: target
3297 real(SRP),
intent(in) :: meanshift
3300 real(SRP),
intent(in) :: cv_shift
3303 class(
environment),
intent(in),
optional :: environment_limits
3307 type(
spatial) :: current_pos, test_object
3313 current_pos = this%now()
3318 call test_object%position(
spatial( &
3326 environ_restrict:
if (
present(environment_limits))
then
3329 do while (.NOT. test_object%is_within(environment_limits))
3332 call test_object%position(
spatial( &
3337 end if environ_restrict
3342 call this%position(test_object)
3351 real(srp) :: coord_new
3355 real(srp),
intent(in) :: coord_target, coord_object
3360 if ( abs(coord_target-coord_object) < meanshift )
then
3362 coord_new = coord_target
3366 delta = rnorm( meanshift,
cv2variance(cv_shift, meanshift) )
3370 if ( abs(coord_target-(coord_object-delta)) < &
3371 abs(coord_target-(coord_object+delta)) )
then
3372 coord_new = coord_object-delta
3374 coord_new = coord_object+delta
3419 class(
spatial),
intent(in) :: target
3421 real(SRP),
intent(in) :: meanshift_xy, meanshift_depth
3424 real(SRP),
intent(in) :: cv_shift_xy, cv_shift_depth
3427 class(
environment),
intent(in),
optional :: environment_limits
3431 type(
spatial) :: current_pos, test_object
3437 current_pos = this%now()
3442 call test_object%position(
spatial( &
3444 meanshift_xy, cv_shift_xy), &
3446 meanshift_xy, cv_shift_xy), &
3448 meanshift_depth, cv_shift_depth) ) )
3453 environ_restrict:
if (
present(environment_limits))
then
3456 do while (.NOT. test_object%is_within(environment_limits))
3459 call test_object%position(
spatial( &
3461 meanshift_xy, cv_shift_xy), &
3463 meanshift_xy, cv_shift_xy), &
3465 meanshift_depth, cv_shift_depth) ) )
3467 end if environ_restrict
3472 call this%position(test_object)
3482 real(srp) :: coord_new
3486 real(srp) :: coord_target, coord_object
3491 real(srp) :: meanshift, cv_shift
3497 if ( abs(coord_target-coord_object) < meanshift )
then
3499 coord_new = coord_target
3503 delta = rnorm( meanshift,
cv2variance(cv_shift, meanshift) )
3507 if ( abs(coord_target-(coord_object-delta)) < &
3508 abs(coord_target-(coord_object+delta)) )
then
3509 coord_new = coord_object-delta
3511 coord_new = coord_object+delta
3524 environment_limits, n_walks )
3528 real(SRP),
optional,
dimension(:),
intent(in) :: dist_array
3530 real(SRP),
optional,
dimension(:),
intent(in) :: cv_array
3533 real(SRP),
optional,
intent(in) :: dist_all
3536 real(SRP),
optional,
intent(in) :: cv_all
3542 class(
environment),
intent(in),
optional :: environment_limits
3545 integer,
optional,
intent(in) :: n_walks
3548 real(SRP),
dimension(size(this)) :: dist_array_here, cv_array_here
3549 integer :: n_walks_here
3552 real(SRP),
dimension(size(this)) :: step_size_walk
3553 integer :: j, i, ind, pop_n
3554 integer,
dimension(size(this)) :: pop_permutation
3557 real(SRP),
parameter :: STEP_DEFAULT = 1.0_srp
3560 real(SRP),
parameter :: CV_DEFAULT = 0.5_srp
3566 if (
present(dist_array))
then
3567 dist_array_here = dist_array
3569 dist_array_here = step_default
3572 if (
present(cv_array))
then
3573 cv_array_here = cv_array
3575 cv_array_here = cv_default
3578 if (
present(dist_all))
then
3579 dist_array_here = dist_all
3581 dist_array_here = step_default
3584 if (
present(cv_all))
then
3585 cv_array_here = cv_all
3587 cv_array_here = cv_default
3590 if (
present(n_walks))
then
3591 n_walks_here = n_walks
3597 step_size_walk =
dist2step(dist_array_here)
3602 pop_permutation = permute_random(pop_n)
3612 environ_restrict_food:
if (
present(environment_limits))
then
3613 do j=1, n_walks_here
3615 ind = pop_permutation(i)
3616 if (this(ind)%is_available()) &
3617 call this(ind)%rwalk( step_size_walk(ind), &
3618 cv_array_here(ind), &
3619 environment_limits )
3622 else environ_restrict_food
3623 do j=1, n_walks_here
3625 ind = pop_permutation(i)
3626 if (this(ind)%is_available()) &
3627 call this(ind)%rwalk( step_size_walk(ind), &
3628 cv_array_here(ind), &
3630 this(ind)%find_environment( &
3634 end if environ_restrict_food
3639 environ_restrict_def:
if (
present(environment_limits))
then
3640 do j=1, n_walks_here
3642 ind = pop_permutation(i)
3643 call this(ind)%rwalk( step_size_walk(ind), &
3644 cv_array_here(ind), &
3645 environment_limits )
3648 else environ_restrict_def
3649 do j=1, n_walks_here
3651 ind = pop_permutation(i)
3652 call this(ind)%rwalk( step_size_walk(ind), &
3653 cv_array_here(ind), &
3655 this(ind)%find_environment( &
3659 end if environ_restrict_def
3673 dist_array_depth, cv_array_depth, &
3674 dist_all_xy, cv_all_xy, &
3675 dist_all_depth, cv_all_depth, &
3676 environment_limits, n_walks )
3680 real(SRP),
optional,
dimension(:),
intent(in) :: dist_array_xy
3682 real(SRP),
optional,
dimension(:),
intent(in) :: cv_array_xy
3684 real(SRP),
optional,
dimension(:),
intent(in) :: dist_array_depth
3686 real(SRP),
optional,
dimension(:),
intent(in) :: cv_array_depth
3689 real(SRP),
optional,
intent(in) :: dist_all_xy
3693 real(SRP),
optional,
intent(in) :: cv_all_xy
3696 real(SRP),
optional,
intent(in) :: dist_all_depth
3700 real(SRP),
optional,
intent(in) :: cv_all_depth
3706 class(
environment),
intent(in),
optional :: environment_limits
3709 integer,
optional,
intent(in) :: n_walks
3712 real(SRP),
dimension(size(this)) :: dist_array_xy_here, cv_array_xy_here
3713 real(SRP),
dimension(size(this)) :: &
3714 dist_array_depth_here, cv_array_depth_here
3715 integer :: n_walks_here
3718 real(SRP),
dimension(size(this)) :: step_size_walk_xy, step_size_walk_depth
3719 integer :: j, i, ind, pop_n
3720 integer,
dimension(size(this)) :: pop_permutation
3723 real(SRP),
parameter :: STEP_DEFAULT = 1.0_srp
3726 real(SRP),
parameter :: CV_DEFAULT = 0.5_srp
3732 if (
present(dist_array_xy))
then
3733 dist_array_xy_here = dist_array_xy
3735 dist_array_xy_here = step_default
3738 if (
present(cv_array_xy))
then
3739 cv_array_xy_here = cv_array_xy
3741 cv_array_xy_here = cv_default
3748 if (
present(dist_array_depth))
then
3749 dist_array_depth_here = dist_array_depth
3751 dist_array_depth_here = step_default / 2.0_srp
3754 if (
present(cv_array_depth))
then
3755 cv_array_depth_here = cv_array_depth
3757 cv_array_depth_here = cv_default
3760 if (
present(dist_all_xy))
then
3761 dist_array_xy_here = dist_all_xy
3763 dist_array_xy_here = step_default
3766 if (
present(cv_all_xy))
then
3767 cv_array_xy_here = cv_all_xy
3769 cv_array_xy_here = cv_default
3772 if (
present(dist_all_depth))
then
3773 dist_array_depth_here = dist_all_depth
3775 dist_array_depth_here = step_default / 2.0_srp
3778 if (
present(cv_all_depth))
then
3779 cv_array_depth_here = cv_all_depth
3781 cv_array_depth_here = cv_default
3784 if (
present(n_walks))
then
3785 n_walks_here = n_walks
3791 step_size_walk_xy =
dist2step(dist_array_xy_here)
3792 step_size_walk_depth =
dist2step(dist_array_depth_here)
3797 pop_permutation = permute_random(pop_n)
3808 environ_restrict_food:
if (
present(environment_limits))
then
3809 do j=1, n_walks_here
3811 ind = pop_permutation(i)
3812 if(this(ind)%is_available()) &
3813 call this(ind)%rwalk25d &
3814 ( meanshift_xy = step_size_walk_xy(ind), &
3815 cv_shift_xy = cv_array_xy_here(ind), &
3816 meanshift_depth = step_size_walk_depth(ind), &
3817 cv_shift_depth = cv_array_depth_here(ind), &
3818 environment_limits = environment_limits )
3821 else environ_restrict_food
3822 do j=1, n_walks_here
3824 ind = pop_permutation(i)
3825 if(this(ind)%is_available()) &
3826 call this(ind)%rwalk25d &
3827 ( meanshift_xy = step_size_walk_xy(ind), &
3828 cv_shift_xy = cv_array_xy_here(ind), &
3829 meanshift_depth = step_size_walk_depth(ind), &
3830 cv_shift_depth = cv_array_depth_here(ind), &
3832 this(ind)%find_environment( &
3836 end if environ_restrict_food
3841 environ_restrict_def:
if (
present(environment_limits))
then
3842 do j=1, n_walks_here
3844 ind = pop_permutation(i)
3845 call this(ind)%rwalk25d &
3846 ( meanshift_xy = step_size_walk_xy(ind), &
3847 cv_shift_xy = cv_array_xy_here(ind), &
3848 meanshift_depth = step_size_walk_depth(ind), &
3849 cv_shift_depth = cv_array_depth_here(ind), &
3850 environment_limits = environment_limits )
3853 else environ_restrict_def
3854 do j=1, n_walks_here
3856 ind = pop_permutation(i)
3857 call this(ind)%rwalk25d &
3858 ( meanshift_xy = step_size_walk_xy(ind), &
3859 cv_shift_xy = cv_array_xy_here(ind), &
3860 meanshift_depth = step_size_walk_depth(ind), &
3861 cv_shift_depth = cv_array_depth_here(ind), &
3863 this(ind)%find_environment( &
3867 end if environ_restrict_def
3893 class(
spatial),
intent(in) :: this
3897 class(
environment),
intent(in) :: environment_limits
3902 is_within = environment_limits%is_within(this)
3926 class(
spatial),
intent(in) :: this
3927 class(
spatial),
intent(in) :: check_object
3928 logical :: are_below
3930 if ( check_object%dpos() > this%dpos() )
then
3958 class(
spatial),
intent(in) :: this
3959 class(
spatial),
intent(in) :: check_object
3960 logical :: are_above
3962 if ( check_object%dpos() < this%dpos() )
then
3993 class(
spatial),
intent(in) :: this
3997 class(
spatial),
dimension(:),
intent(in) :: neighbours
4001 integer,
optional,
intent(out) :: number
4008 integer :: i, number_here
4012 real(
srp),
dimension(size(neighbours)) :: distance
4024 do concurrent( i = 1:
size(neighbours) )
4025 distance(i) = this%distance(neighbours(i))
4029 number_here = minloc(distance,1)
4033 object = neighbours(number_here)%location()
4036 if(
present(number)) number = number_here
4064 class(
spatial),
intent(in) :: this
4068 class(
spatial),
dimension(:),
intent(in) :: neighbours
4072 type(
spatial),
optional,
intent(out) :: object
4083 real(
srp),
dimension(size(neighbours)) :: distance
4086 if (
present(object))
call object%missing()
4096 do concurrent( i = 1:
size(neighbours) )
4097 distance(i) = this%distance(neighbours(i))
4101 id = minloc(distance,1)
4104 if(
present(object))
call object%position( neighbours(id)%location() )
4117 otherrisks, eggmortality, &
4118 predators_number, loc_predators, &
4119 food_abundance, loc_food, sizes_food )
4120 class(
habitat),
intent(inout) :: this
4124 type(
spatial),
intent(in) :: coord_min,coord_max
4125 character (len=*),
optional,
intent(in) :: label
4126 real(SRP),
optional,
intent(in) :: otherrisks
4127 real(SRP),
optional,
intent(in) :: eggmortality
4130 integer :: predators_number
4135 type(
spatial),
dimension(:),
optional :: loc_predators
4139 integer :: food_abundance
4144 type(
spatial),
dimension(:),
optional :: loc_food
4148 real(SRP),
dimension(:),
optional :: sizes_food
4151 real(SRP) :: predation_here
4152 real(SRP) :: otherrisks_here
4153 real(SRP) :: eggmortality_here
4156 type(
spatial),
allocatable,
dimension(:) :: loc_pred_here
4159 type(
spatial),
allocatable,
dimension(:) :: loc_food_here
4162 real(SRP),
allocatable,
dimension(:) :: sizes_food_here
4173 call this%build(coord_min, coord_max)
4176 if (
present(label))
then
4177 this%habitat_name = label
4179 this%habitat_name =
"HAB_" // rand_string(
label_length - len(
"HAB_"), &
4184 if (
present(otherrisks))
then
4185 otherrisks_here = otherrisks
4189 this%risk_mortality = otherrisks_here
4192 if (
present(eggmortality))
then
4193 eggmortality_here = eggmortality
4197 this%risk_egg_mortality = eggmortality_here
4202 this%predators_number = predators_number
4205 if (.not.
allocated(loc_pred_here)) &
4206 allocate(loc_pred_here(this%predators_number))
4210 if (
present(loc_predators))
then
4211 loc_pred_here = loc_predators
4217 loc_pred_here = this%uniform(this%predators_number)
4225 if (.not.
allocated(this%predators)) &
4226 allocate(this%predators(this%predators_number))
4237 do concurrent( i = 1:this%predators_number )
4238 call this%predators(i)%make( &
4241 position=loc_pred_here(i), &
4242 label=
"PRED_" // tostr(i,this%predators_number) )
4248 do i = 1, this%predators_number
4249 call this%predators(i)%make( &
4254 position=loc_pred_here(i), &
4255 label=
"PRED_" // tostr(i,this%predators_number) )
4261 if (
allocated(loc_pred_here))
deallocate (loc_pred_here)
4266 this%food%number_food_items = food_abundance
4269 if (.not.
allocated(loc_food_here)) &
4270 allocate(loc_food_here(this%food%number_food_items))
4275 if (
present(loc_food))
then
4283 call loc_food_here%position(loc_food)
4298 loc_food_here = this%uniform(this%food%number_food_items)
4302 if (.not.
allocated(sizes_food_here)) &
4303 allocate(sizes_food_here(this%food%number_food_items))
4307 if (
present(sizes_food))
then
4308 sizes_food_here = sizes_food
4315 call rnorm_array( sizes_food_here, &
4329 call this%food%make(
"FOOD_" // this%habitat_name, &
4330 this%food%number_food_items, &
4335 if (
allocated(loc_food_here))
deallocate(loc_food_here)
4336 if (
allocated(sizes_food_here))
deallocate(sizes_food_here)
4343 class(
habitat),
intent(in) :: this
4345 character(len=LABEL_LENGTH) :: habitat_name
4347 habitat_name = this%habitat_name
4354 class(
habitat),
intent(in) :: this
4357 real(
srp) :: value_out
4359 value_out = this%risk_mortality
4366 class(
habitat),
intent(in) :: this
4369 real(
srp) :: value_out
4371 value_out = this%risk_egg_mortality
4378 class(
habitat),
intent(inout) :: this
4381 character(len=*),
optional,
intent(in) :: csv_file_name
4383 logical,
optional,
intent(out) :: is_success
4386 character(len=FILENAME_LENGTH) :: csv_file_name_here
4387 logical :: is_success_write
4394 character(len=LABEL_LENGTH),
dimension(size(this%predators%label)) :: &
4395 body_size_str, attack_rate_str
4400 if (
present(csv_file_name))
then
4401 csv_file_name_here = csv_file_name
4403 csv_file_name_here =
"predators_" // trim(this%habitat_name) //
"_" // &
4415 do concurrent(i=1:this%predators_number)
4416 body_size_str(i) = tostr(this%predators(i)%body_size)
4417 attack_rate_str(i) = tostr(this%predators(i)%attack_rate)
4419 is_success_write = .
false.
4420 call csv_matrix_write( reshape( &
4423 this%predators%label ], &
4424 [ this%predators_number, 3 ] ), &
4426 csv_file_name_here, &
4427 [
character(len=LABEL_LENGTH) :: &
4428 "BODY_SIZE",
"ATTACK_RATE",
"LABEL" ], &
4431 if (
present(is_success)) is_success = is_success_write
4438 suppress_output=.
true., &
4465 real(SRP),
optional,
intent(in) :: maxdepth
4468 character(len=*),
intent(in) :: csv_file_name
4471 logical,
optional,
intent(out) :: is_success
4478 character(len=:),
allocatable :: record_string
4481 real(SRP) :: maxdepth_loc
4486 real(SRP) :: visibility_food
4516 character(len=LABEL_LENGTH),
dimension(*),
parameter :: COLNAMES = &
4518 "TIMESTEP",
"SURFACE_LIGHT",
"LIGHT_DEP_10",
"LIGHT_DEP_HLF", &
4519 "LIGHT_DEP_MAX",
"MEAN_DEPTH",
"LIGHT_MDEPTH",
"FOOD_VIS_SURF", &
4520 "FOOD_VIS_10",
"FOOD_VIS_HLF",
"FOOD_VIS_DPMAX",
"FOOD_VIS_MDEPT",&
4521 "DEP_VR_UND_400",
"DEP_VR_UND_200",
"DEP_VR_UND_100", &
4525 real(SRP) :: surface_light
4526 real(SRP) :: target_depth
4527 real(SRP) :: target_depth_light
4528 real(SRP) :: depth_minimum_fall
4531 if (
present(maxdepth))
then
4532 maxdepth_loc = maxdepth
4539 call out_file%open_write( trim(csv_file_name),
format_csv )
4540 if ( .not. out_file%is_success() )
then
4541 if (
present(is_success)) is_success = .
false.
4542 call out_file%close()
4547 record_string = repeat(
" ",
label_length*
size(colnames)+
size(colnames)*4)
4548 call csv_record_append( record_string, colnames )
4549 call out_file%record_write(record_string)
4550 if ( .not. out_file%is_success() )
then
4551 if (
present(is_success)) is_success = .
false.
4552 call out_file%close()
4560 record_string = repeat(
" ",
label_length*
size(colnames)+
size(colnames)*4)
4563 call csv_record_append( record_string, i )
4566 call csv_record_append( record_string, surface_light )
4568 target_depth_light =
light_depth( depth = maxdepth_loc / 10.0_srp, &
4569 surface_light = surface_light, &
4570 is_stochastic=.
false. )
4571 call csv_record_append( record_string, target_depth_light )
4573 target_depth_light =
light_depth( depth = maxdepth_loc / 2.0_srp, &
4574 surface_light = surface_light, &
4575 is_stochastic=.
false. )
4576 call csv_record_append( record_string, target_depth_light )
4578 target_depth_light =
light_depth( depth = maxdepth_loc, &
4579 surface_light = surface_light, &
4580 is_stochastic=.
false. )
4581 call csv_record_append( record_string, target_depth_light )
4584 call csv_record_append( record_string, target_depth )
4586 target_depth_light =
light_depth( depth = target_depth, &
4587 surface_light = surface_light, &
4588 is_stochastic=.
false. )
4589 call csv_record_append( record_string, target_depth_light )
4591 call object_std%position_v( 1.0_srp, 2.0_srp, 0.0 )
4592 visibility_food = object_std%visibility( &
4596 time_step_model = i )
4597 call csv_record_append( record_string, visibility_food )
4599 call object_std%position_v( 1.0_srp, 2.0_srp, maxdepth_loc / 10.0_srp )
4600 visibility_food = object_std%visibility( &
4604 time_step_model = i )
4605 call csv_record_append( record_string, visibility_food )
4607 call object_std%position_v( 1.0_srp, 2.0_srp, maxdepth_loc / 2.0_srp )
4608 visibility_food = object_std%visibility( &
4612 time_step_model = i )
4613 call csv_record_append( record_string, visibility_food )
4615 call object_std%position_v( 1.0_srp, 2.0_srp, maxdepth_loc )
4616 visibility_food = object_std%visibility( &
4620 time_step_model = i )
4621 call csv_record_append( record_string, visibility_food )
4623 call object_std%position_v( 1.0_srp, 2.0_srp, target_depth )
4624 visibility_food = object_std%visibility( &
4628 time_step_model = i )
4629 call csv_record_append( record_string, visibility_food )
4634 time_step_model = i )
4635 call csv_record_append( record_string, depth_minimum_fall )
4640 time_step_model = i )
4641 call csv_record_append( record_string, depth_minimum_fall )
4646 time_step_model = i )
4647 call csv_record_append( record_string, depth_minimum_fall )
4652 time_step_model = i )
4653 call csv_record_append( record_string, depth_minimum_fall )
4655 call out_file%record_write(record_string)
4656 if ( .not. out_file%is_success() )
then
4657 if (
present(is_success)) is_success = .
false.
4658 call out_file%close()
4664 call out_file%close()
4665 if ( out_file%is_success() )
then
4666 if (
present(is_success)) is_success = .
true.
4668 if (
present(is_success)) is_success = .
false.
4678 result(habitat_centre)
4681 type(
spatial) :: habitat_centre
4684 logical,
optional,
intent(in) :: nodepth
4687 habitat_centre%x = (this%coord_max%x - this%coord_min%x)/2.0_srp
4688 habitat_centre%y = (this%coord_max%y - this%coord_min%y)/2.0_srp
4691 if (
present(nodepth))
then
4692 if (nodepth .eqv. .
false.)
then
4694 habitat_centre%depth = (this%coord_max%depth - &
4695 this%coord_min%depth)/2.0_srp
4699 habitat_centre%depth = (this%coord_max%depth - &
4700 this%coord_min%depth)/2.0_srp
4731 result(visual_range_calculate)
4734 character(len=*),
parameter ::
procname =
"(visual_range_scalar)"
4737 real(
srp),
intent(in) :: irradiance
4740 real(
srp),
optional,
intent(in) :: prey_area
4744 real(
srp),
optional,
intent(in) :: prey_contrast
4747 real(
srp) :: visual_range_calculate
4751 real(
hrp) :: visual_range_hrp_here
4764 real(
hrp),
parameter :: visual_range_max_overflow = 1300.0_hrp
4767 integer :: error_flag
4775 character(len=LABEL_LENGTH),
parameter,
dimension(3) :: &
4776 error_msg = [
"NO_CONVERGENCE",
"DIVISION_ZERO ",
"NEGATIVE_RANGE"]
4779 real(
srp) :: prey_area_here, prey_contrast_here
4800 if(irradiance <
zero)
then
4801 visual_range_calculate = 0.0_srp
4807 if (
present(prey_area))
then
4808 prey_area_here=prey_area
4818 if (
present(prey_contrast))
then
4819 prey_contrast_here=prey_contrast
4828 call srgetr( visual_range_hrp_here, &
4829 real(
beamatt,
hrp),
real(prey_contrast_here,HRP), &
4830 real(prey_area_here,HRP),
real(VISCAP,HRP), &
4831 real(EYESAT,HRP),
real(irradiance,HRP), error_flag )
4841 if (error_flag /= 0)
then
4842 call log_msg(
"ERROR: In " //
procname // &
4843 ": (srgetr) issued error code " // &
4844 tostr(error_flag) //
" :: " // error_msg(error_flag) // &
4845 ". Object area (prey_area)=" // tostr(prey_area) // &
4846 ", object contrast (prey_contrast)=" // &
4847 tostr(prey_contrast) // &
4848 ". Visual range calculated as " // &
4849 tostr(visual_range_hrp_here) //
" m" )
4855 if (visual_range_hrp_here <
zero )
then
4856 visual_range_hrp_here = visual_range_max_overflow
4857 call log_msg(
"ERROR: In " //
procname //
": Visual range " // &
4858 "recalculated using `VISUAL_RANGE_MAX_OVERFLOW` ceiling: " &
4859 // tostr(
cm2m(visual_range_hrp_here)) //
" m for HRP " // &
4860 "real kind=" // tostr(
hrp) //
" precision model." )
4866 visual_range_calculate = real(visual_range_hrp_here,
srp)
4899 prey_contrast)
result(visual_range_calculate)
4902 character(len=*),
parameter ::
procname =
"(visual_range_vector)"
4905 real(
srp),
intent(in) :: irradiance
4909 real(
srp),
dimension(:),
intent(in) :: prey_area
4915 real(
srp),
optional,
dimension(size(prey_area)),
intent(in) :: &
4922 real(
srp),
optional,
intent(in) :: prey_contrast
4925 real(
srp),
dimension(size(prey_area)) :: visual_range_calculate
4928 real(
srp),
dimension(size(prey_area)) :: prey_contrast_here
4951 if (
present(prey_contrast_vect))
then
4952 prey_contrast_here=prey_contrast_vect
4960 if (
present(prey_contrast))
then
4961 prey_contrast_here = prey_contrast
4974 do i=1,
size(visual_range_calculate)
4976 prey_area(i), prey_contrast_here(i))
5010 result(visual_range_calculate)
5013 real(
srp),
intent(in) :: irradiance
5016 real(
srp),
optional,
intent(in) :: prey_area
5020 real(
srp),
optional,
intent(in) :: prey_contrast
5030 real(
srp) :: visual_range_calculate
5034 real(
hrp) :: visual_range_hrp_here
5037 real(
srp) :: prey_area_here, prey_contrast_here
5040 integer :: error_flag
5055 if (
present(prey_area))
then
5056 prey_area_here=prey_area
5061 if (
present(prey_contrast))
then
5062 prey_contrast_here=prey_contrast
5077 call srgetr( visual_range_hrp_here, &
5078 real(
beamatt,
hrp),
real(prey_contrast_here,HRP), &
5079 real(prey_area_here,HRP),
real(VISCAP,HRP), &
5080 real(EYESAT,HRP),
real(irradiance,HRP), error_flag )
5092 visual_range_calculate = real(visual_range_hrp_here,
srp)
5148 elemental subroutine srgetr(r, c, C0, Ap, Vc, Ke, Eb, IER)
5166 real(
hrp),
intent(in) :: c, c0, ap, vc, ke, eb
5167 real(
hrp),
intent(out) :: r
5168 integer,
optional,
intent(out) :: ier
5170 real(
hrp) :: as, eps, rst, tol, tolf, f1, fder, dx
5176 call easyr(rst,c0,ap,vc,ke,eb)
5187 call deriv(r,f1,fder,c,c0,ap,vc,ke,eb)
5188 tolf = 100.0_hrp * eps
5194 if (f1 .feq. 0.0_hrp)
goto 7
5197 if (fder .feq. 0.0_hrp)
goto 8
5204 if (r .LT. 0.0_hrp)
goto 9
5208 call deriv(r,f1,fder,c,c0,ap,vc,ke,eb)
5213 if ((as-1.0_hrp) > 0.0_hrp) tol = tol*as
5215 if ((abs(dx)-tol) > 0.0_hrp)
goto 6
5216 if ((abs(f1)-tolf) .LE. 0.0_hrp)
goto 7
5220 if (
present(ier)) ier = 1
5223 8
if (
present(ier)) ier = 2
5226 9
if (
present(ier)) ier = 3
5237 elemental subroutine easyr(r, C0, Ap, Vc, Ke, Eb)
5238 real(
hrp),
intent(out) :: r
5239 real(
hrp),
intent(in) :: c0, ap, vc, ke, eb
5243 r2 = abs(c0)*ap*vc*eb/(ke+eb)
5246 end subroutine easyr
5270 elemental subroutine deriv(r, F1, FDER, c, C0, Ap, Vc, Ke, Eb)
5280 real(
hrp),
intent(inout) :: r
5281 real(
hrp),
intent(out) :: f1, fder
5282 real(
hrp),
intent(in) :: c, c0, ap, vc, ke, eb
5284 real(
hrp) :: fr1, fr2
5299 real(
hrp),
parameter :: huge_real = huge(0.0_hrp)
5300 real(
hrp),
parameter :: max_log = log(huge_real)
5303 character(len=*),
parameter ::
procname =
"(deriv)"
5305 fr2=log(abs(c0)*ap*vc)
5315 if (c*r < max_log)
then
5316 fr1=log(((ke+eb)/eb)*r*r*exp(c*r))
5333 fder = c + 2.0_hrp/r
5336 end subroutine deriv
5364 integer,
optional,
intent(in) :: tstep
5367 integer :: tstep_loc
5369 if (
present(tstep))
then
5376 surlig =
daylight * 0.5_srp * (1.01_srp + sin(
pi * 2.0_srp * &
5404 integer,
optional,
intent(in) :: tstep
5408 logical,
intent(in) :: is_stochastic
5411 real(
srp) :: surlig_deterministic
5414 integer :: tstep_loc
5416 if (
present(tstep))
then
5424 if (is_stochastic)
then
5428 surlig = rnorm(surlig_deterministic,(surlig_deterministic*
daylight_cv)**2)
5431 surlig = surlig_deterministic
5450 integer,
intent(in),
dimension(:) :: tstep
5452 real(
srp),
dimension(size(tstep)) :: surlig
5456 logical,
intent(in) :: is_stochastic
5459 real(
srp),
dimension(size(tstep)) :: surlig_deterministic
5467 if (is_stochastic)
then
5473 surlig(i) = rnorm( surlig_deterministic(i), &
5478 surlig = surlig_deterministic
5512 integer,
intent(in) :: depth
5516 real(
srp),
optional,
intent(in) :: surface_light
5521 logical,
optional,
intent(in) :: is_stochastic
5524 real(
srp) :: surface_light_loc
5525 logical :: is_stochastic_loc
5527 if (
present(is_stochastic))
then
5528 is_stochastic_loc = is_stochastic
5533 if (
present(surface_light))
then
5534 surface_light_loc = surface_light
5536 surface_light_loc =
light_surface(is_stochastic=is_stochastic_loc)
5587 real(
srp),
intent(in) :: depth
5591 real(
srp),
optional,
intent(in) :: surface_light
5596 logical,
optional,
intent(in) :: is_stochastic
5599 real(
srp) :: surface_light_loc
5600 logical :: is_stochastic_loc
5602 if (
present(is_stochastic))
then
5603 is_stochastic_loc = is_stochastic
5608 if (
present(surface_light))
then
5609 surface_light_loc = surface_light
5611 surface_light_loc =
light_surface(is_stochastic=is_stochastic_loc)
5619 eb = surface_light_loc * exp(-
lightdecay * depth)
5633 elemental function dist_scalar(x1, x2, y1, y2, z1, z2)
result (distance)
5634 real(
srp) :: distance
5635 real(
srp),
intent(in) :: x1, x2, y1, y2
5636 real(
srp),
intent(in),
optional :: z1, z2
5638 if (
present(z1))
then
5639 if (
present(z2))
then
5642 distance = sqrt( (x1-x2)**2 + (y1-y2)**2 + (z1-z2)**2 )
5644 distance = sqrt( (x1-x2)**2 + (y1-y2)**2 )
5647 distance = sqrt( (x1-x2)**2 + (y1-y2)**2 )
5668 real(
srp) :: distance
5672 real(
srp),
intent(in),
dimension(:) :: cvector1
5673 real(
srp),
intent(in),
dimension(:) :: cvector2
5675 distance = sqrt(sum( (cvector1-cvector2)**2 ))
5685 real(
srp) :: distance
5689 real(
srp),
intent(in),
dimension(:) :: cvector1
5690 real(
srp),
intent(in),
dimension(:) :: cvector2
5692 distance = abs( sum( (cvector1-cvector2)**2 ) )
5701 real(
srp),
intent(in),
dimension(:) :: vector
5703 real(
srp) :: vlength
5707 vlength = sqrt( sum(vector**2) )
5724 elemental function dist2step(average_distance, dimensionality) &
5727 real(
srp) :: unit_step
5731 real(
srp),
intent(in) :: average_distance
5734 integer,
optional,
intent(in) :: dimensionality
5739 if (
present(dimensionality))
then
5740 dim_here = dimensionality
5745 unit_step = sqrt( (average_distance**2) / dim_here )
5760 call this%spatial_history_clean()
5766 this%eaten = .
false.
5790 type(
spatial),
intent(in) :: location
5794 real(
srp),
optional,
intent(in) :: size
5799 integer,
intent(in) :: iid
5804 call this%position(location)
5808 call this%spatial_history_clean()
5814 if (
present(size))
then
5819 this%eaten = .
false.
5822 call this%set_iid(iid)
5843 real(
srp),
optional,
intent(in) :: prob
5848 real(
srp) :: prob_here
5851 character(len=*),
parameter ::
procname=
"(food_item_capture_success_stochast)"
5859 if (
present(prob))
then
5868 if ( this%is_available() )
then
5873 if ( rand_r4() < prob_here ) success = .
true.
5876 "as it is not available (has been already eaten?). Check code.")
5898 distance, time_step_model ) &
5902 real(
srp),
optional,
intent(in) :: distance
5906 integer,
optional,
intent(in) :: time_step_model
5908 real(
srp) :: capt_prob
5911 character(len=*),
parameter :: &
5912 procname=
"(food_item_capture_probability_calc)"
5915 real(
srp) :: distance_here
5916 integer :: time_step_model_here
5919 real(
srp) :: visrange_predator
5922 real(
srp),
dimension(3) :: interpol_abscissa, interpol_ordinate
5926 if (
present(time_step_model))
then
5927 time_step_model_here = time_step_model
5937 visrange_predator = this%visibility()
5947 interpol_abscissa = [ 0.0_srp, &
5948 visrange_predator/2.0_srp, &
5969 if (
present(distance))
then
5970 if (distance > visrange_predator)
then
5975 "the visual range:" // tostr(distance) //
">" // &
5983 if (distance .feq.
missing)
then
5987 distance_here = distance
5989 distance_here = visrange_predator/2.0_srp
6000 capt_prob =
within( ddpinterpol(interpol_abscissa, interpol_ordinate, &
6007 call log_dbg(
"INFO: Calculated food item capture probability: " // &
6008 tostr(capt_prob) //
", Distance: " // tostr(distance_here) // &
6015 grid_xx=interpol_abscissa, grid_yy=interpol_ordinate, &
6016 ipol_value=distance_here, &
6017 algstr=
"DDPINTERPOL", &
6018 output_file=
"plot_debug_capture_probability_s_" // &
6020 tostr(this%get_iid()) //
"_" // &
6037 time_step_model)
result (visrange)
6042 real(
srp),
optional,
intent(in) :: object_area
6046 real(
srp),
optional,
intent(in) :: contrast
6050 integer,
optional,
intent(in) :: time_step_model
6051 real(
srp) :: visrange
6054 real(
srp) :: object_area_here, contrast_here
6057 real(
srp) :: irradiance_agent_depth
6058 integer :: time_step_model_here
6062 if (
present(object_area))
then
6063 object_area_here = object_area
6065 object_area_here =
carea(
cm2m( this%size ) )
6070 if (
present(contrast))
then
6071 contrast_here = contrast
6078 if (
present(time_step_model))
then
6079 time_step_model_here = time_step_model
6087 irradiance_agent_depth = this%illumination(time_step_model_here)
6091 prey_area = object_area_here, &
6092 prey_contrast = contrast_here ) )
6101 depth_range_min, depth_range_max, &
6102 object_area, object_contrast, &
6103 time_step_model )
result (depth_out)
6107 real(
srp),
intent(in) :: target_range
6114 real(
srp),
optional,
intent(in) :: depth_range_min
6120 real(
srp),
optional,
intent(in) :: depth_range_max
6126 real(
srp),
optional,
intent(in) :: object_area
6130 real(
srp),
optional,
intent(in) :: object_contrast
6135 integer,
optional,
intent(in) :: time_step_model
6136 real(
srp) :: depth_out
6139 real(
srp) :: depth_range_min_loc, depth_range_max_loc
6140 real(
srp) :: object_area_here, contrast_here
6141 integer :: time_step_model_here
6147 if (
present(depth_range_min))
then
6148 depth_range_min_loc = depth_range_min
6153 if (
present(depth_range_max))
then
6154 depth_range_max_loc = depth_range_max
6162 if (
present(object_area))
then
6163 object_area_here = object_area
6170 if (
present(object_contrast))
then
6171 contrast_here = object_contrast
6178 if (
present(time_step_model))
then
6179 time_step_model_here = time_step_model
6195 depth_out =
zeroin( depth_range_min_loc, &
6196 depth_range_max_loc, &
6202 if ( depth_out .feq.
missing )
then
6204 depth_out = depth_range_max_loc
6205 else if (
visibility_loc(depth_range_min_loc) < target_range )
then
6206 depth_out = depth_range_min_loc
6217 real(
srp),
intent(in) :: depth
6218 real(
srp) :: vis_out
6220 real(
srp) :: irradiance_at_depth
6224 irradiance_at_depth = &
6227 tstep=time_step_model_here, &
6228 is_stochastic=.
false.) )
6232 prey_area = object_area_here, &
6233 prey_contrast = contrast_here ) )
6244 real(
srp),
intent(in) :: depth
6270 logical :: not_available
6272 if (this%eaten)
then
6273 not_available = .true.
6275 not_available = .false.
6291 logical :: available
6293 if (this%eaten)
then
6308 real(srp) :: item_size
6310 item_size = this%size
6323 real(srp),
intent(in) :: radius
6324 real(srp) :: this_mass
6326 this_mass = food_item_density * (4.0_srp/3.0_srp * pi * radius**3)
6338 real(srp),
intent(in) :: mass
6341 radius = ( mass / (food_item_density*4.0_srp/3.0_srp*pi) )**(1_srp/3_srp)
6353 real(srp) :: item_mass
6371 integer,
intent(in) :: iid
6388 class(
food_item),
intent(inout) :: the_other
6393 call the_other%make(this%location(), this%size, this%food_iid)
6394 the_other%eaten = this%eaten
6421 character(len=*),
intent(in) :: label
6424 integer,
intent(in) :: abundance
6427 type(
spatial),
dimension(:),
intent(in) :: locations
6430 real(srp),
dimension(:),
intent(in) :: sizes
6438 if (.not.
allocated(this%food))
allocate(this%food(abundance))
6441 this%food_label = label
6444 this%number_food_items = abundance
6449 call this%food%create()
6456 do concurrent( i=1:
size(this%food) )
6458 call this%food(i)%make( locations(i), sizes(i), i )
6468 integer :: abundance_out
6470 abundance_out = this%number_food_items
6479 character(len=LABEL_LENGTH) :: label_out
6481 label_out = this%food_label
6491 if (
allocated(this%food))
deallocate(this%food)
6494 this%food_label =
"undefined"
6497 this%number_food_items = unknown
6511 type(
spatial),
dimension(size(this%food)) :: locate_array
6518 do concurrent( i=1:
size(this%food) )
6519 locate_array(i) = this%food(i)%location()
6528 result(average_distance_food_items)
6530 integer,
optional,
intent(in) :: n_sample
6531 real(srp) :: average_distance_food_items
6534 integer :: n_sample_here
6537 integer,
parameter :: n_sample_default = 100
6539 if (
present(n_sample))
then
6540 n_sample_here = n_sample
6542 n_sample_here = n_sample_default
6567 integer,
optional,
intent(in) :: replace
6573 integer,
dimension(:),
allocatable :: idx_eaten_items
6584 partial_full:
if (
present(replace))
then
6586 n_eaten = count( this%food%eaten .eqv. .true. )
6589 if ( replace >= n_eaten )
then
6590 where ( this%food%eaten ) this%food%eaten = .false.
6597 allocate( idx_eaten_items(n_eaten) ); idx_eaten_items = unknown
6601 do concurrent(i=1:
size(this%food))
6602 if (this%food(i)%eaten .eqv. .true.)
then
6604 idx_eaten_items(j) = i
6608 idx_eaten_items = idx_eaten_items( permute_random(n_eaten) )
6610 do concurrent(i=1:replace)
6611 this%food(idx_eaten_items(i))%eaten = .false.
6625 this%food%eaten = .false.
6665 real(SRP),
optional,
intent(in) :: max_depth
6669 integer,
optional,
intent(in) :: time_step_model
6672 real(SRP) :: depth_loc
6673 integer :: tstep_loc
6676 integer :: habitat_res
6684 real(SRP) :: target_depth
6696 ifood = rand_i(1, this%number_food_items)
6699 habitat_res = this%food(ifood)%find_environment()
6700 if (
present(max_depth))
then
6701 depth_loc = max_depth
6708 if (
present(time_step_model))
then
6709 tstep_loc = time_step_model
6711 tstep_loc = global_time_step_model_current
6723 do concurrent(ifood=1:this%number_food_items)
6724 position_new =
spatial( this%food(ifood)%xpos(), &
6725 this%food(ifood)%ypos(), &
6727 call this%food(ifood)%position( position_new )
6750 do ifood=1, this%number_food_items
6751 call this%food(ifood)%rwalk( meanshift_xy = food_item_migrate_xy_mean, &
6752 cv_shift_xy = food_item_migrate_xy_cv, &
6753 meanshift_depth = food_item_migrate_depth_mean, &
6754 cv_shift_depth = food_item_migrate_depth_cv, &
6755 environment_limits = &
6774 integer :: ifood, habitat_res
6782 ifood = rand_i(1, this%number_food_items)
6783 habitat_res = this%food(ifood)%find_environment()
6796 do ifood=1, this%number_food_items
6797 call this%food(ifood)%rwalk( meanshift_xy = food_item_migrate_xy_mean, &
6798 cv_shift_xy = food_item_migrate_xy_cv, &
6799 meanshift_depth = food_item_migrate_depth_mean, &
6800 cv_shift_depth = food_item_migrate_depth_cv, &
6801 environment_limits = &
6836 class(
habitat),
dimension(:),
intent(inout) :: habitats
6840 integer,
optional,
intent(in) :: time_step_model
6843 integer :: tstep_loc
6850 if (
present(time_step_model))
then
6851 tstep_loc = time_step_model
6853 tstep_loc = global_time_step_model_current
6859 do i=1,
size(habitats)
6860 call habitats(i)%food%migrate_vertical(time_step_model = tstep_loc)
6876 class(
habitat),
dimension(:),
intent(inout) :: habitats
6884 do i=1,
size(habitats)
6885 call habitats(i)%food%rwalk()
6904 integer,
intent(in) :: tstep
6906 real(srp),
intent(in) :: depth
6909 real(srp) :: copcenterdepth
6912 real(srp) :: copsindepth
6921 copsindepth = sin( pi * real(tstep,srp) * 2.0_srp * &
6922 real(dielcycles, srp)/(
real(LIFESPAN, SRP) + 1.0_srp) )
6923 copcenterdepth = depth / 2.0_srp + 0.499_srp * depth*copsindepth
6931 character(len=*),
optional,
intent(in) :: csv_file_name
6932 logical,
optional,
intent(out) :: is_success
6935 character(len=FILENAME_LENGTH) :: csv_file_name_here
6936 logical :: is_success_write
6941 if (
present(csv_file_name))
then
6942 csv_file_name_here = csv_file_name
6944 csv_file_name_here =
"food_items_" // trim(this%food_label) //
"_" // &
6945 model_name //
"_" // mmdd //
"_gen_" // &
6946 tostr(global_generation_number_current, &
6953 is_success_write = .false.
6954 call csv_matrix_write ( reshape( &
6960 conv_l2r(this%food%eaten), &
6961 real(this%food%food_iid,SRP) ], &
6962 [this%number_food_items, 7]), &
6963 csv_file_name_here, &
6964 [
character(len=LABEL_LENGTH) :: &
6965 "X",
"Y",
"DPTH",
"SIZE", &
6966 "MASS",
"EATEN",
"IID"], &
6969 if (
present(is_success)) is_success = is_success_write
6974 if ( is_zip_outputs )
then
6975 call call_external(command=cmd_zip_output //
" " // csv_file_name_here, &
6976 suppress_output=.true., &
6977 is_background_task=zip_outputs_background )
6995 logical,
optional,
intent(in) :: reindex
6997 call qsort(this%food)
7001 if (
present(reindex))
then
7002 if (reindex)
call this%reindex()
7017 type(
food_item),
intent(in out),
dimension(:) :: a
7020 if(
size(a) > 1)
then
7022 call qsort(a(:iq-1))
7026 end subroutine qsort
7034 type(
food_item),
intent(inout),
dimension(:) :: a
7035 integer,
intent(out) :: marker
7051 if (a(j)%size <= x)
exit
7056 if (a(i)%size >= x)
exit
7064 elseif (i == j)
then
7089 integer,
optional,
intent(in) :: start_iid
7092 integer :: start_iid_loc
7097 if (
present(start_iid))
then
7098 start_iid_loc = start_iid
7103 do concurrent(i=1:this%number_food_items)
7104 this%food(i)%food_iid = i + start_iid_loc - 1
7156 class(
food_resource),
optional,
intent(inout) :: resource_1, &
7177 integer,
parameter :: n_resources = 4
7179 integer :: start_value_resource
7181 start_value_resource = 1
7183 r1:
if (
present(resource_1))
then
7185 call resource_1%reindex(start_value_resource)
7187 start_value_resource = resource_1%number_food_items + 1
7190 r2:
if (
present(resource_2))
then
7191 call resource_2%reindex(start_value_resource)
7192 start_value_resource = resource_2%number_food_items + 1
7195 r3:
if (
present(resource_3))
then
7196 call resource_3%reindex(start_value_resource)
7197 start_value_resource = resource_3%number_food_items + 1
7200 r4:
if (
present(resource_4))
then
7201 call resource_4%reindex(start_value_resource)
7202 start_value_resource = resource_4%number_food_items + 1
7205 r5:
if (
present(resource_5))
then
7206 call resource_5%reindex(start_value_resource)
7207 start_value_resource = resource_5%number_food_items + 1
7210 r6:
if (
present(resource_6))
then
7211 call resource_6%reindex(start_value_resource)
7212 start_value_resource = resource_6%number_food_items + 1
7215 r7:
if (
present(resource_7))
then
7216 call resource_7%reindex(start_value_resource)
7217 start_value_resource = resource_7%number_food_items + 1
7220 r8:
if (
present(resource_8))
then
7221 call resource_8%reindex(start_value_resource)
7222 start_value_resource = resource_8%number_food_items + 1
7225 r9:
if (
present(resource_9))
then
7226 call resource_9%reindex(start_value_resource)
7227 start_value_resource = resource_9%number_food_items + 1
7230 r10:
if (
present(resource_10))
then
7231 call resource_10%reindex(start_value_resource)
7232 start_value_resource = resource_10%number_food_items + 1
7235 r11:
if (
present(resource_11))
then
7236 call resource_11%reindex(start_value_resource)
7237 start_value_resource = resource_11%number_food_items + 1
7240 r12:
if (
present(resource_12))
then
7241 call resource_12%reindex(start_value_resource)
7242 start_value_resource = resource_12%number_food_items + 1
7245 r13:
if (
present(resource_13))
then
7246 call resource_13%reindex(start_value_resource)
7247 start_value_resource = resource_13%number_food_items + 1
7250 r14:
if (
present(resource_14))
then
7251 call resource_14%reindex(start_value_resource)
7252 start_value_resource = resource_14%number_food_items + 1
7255 r15:
if (
present(resource_15))
then
7256 call resource_15%reindex(start_value_resource)
7257 start_value_resource = resource_15%number_food_items + 1
7260 r16:
if (
present(resource_16))
then
7261 call resource_16%reindex(start_value_resource)
7262 start_value_resource = resource_16%number_food_items + 1
7265 r17:
if (
present(resource_17))
then
7266 call resource_17%reindex(start_value_resource)
7267 start_value_resource = resource_17%number_food_items + 1
7270 r18:
if (
present(resource_18))
then
7271 call resource_18%reindex(start_value_resource)
7272 start_value_resource = resource_18%number_food_items + 1
7275 r19:
if (
present(resource_19))
then
7276 call resource_19%reindex(start_value_resource)
7277 start_value_resource = resource_19%number_food_items + 1
7280 r20:
if (
present(resource_20))
then
7281 call resource_20%reindex(start_value_resource)
7282 start_value_resource = resource_20%number_food_items + 1
7381 class(
food_resource),
intent(out) :: food_resource_collapsed
7406 logical,
optional,
intent(in) :: reindex
7409 character(len=*),
optional,
intent(in) :: label
7412 integer :: abundance_total
7415 type(
spatial),
dimension(:),
allocatable :: &
7416 locations_res_1, locations_res_2, locations_res_3, &
7417 locations_res_4, locations_res_5, locations_res_6, &
7418 locations_res_7, locations_res_8, locations_res_9, &
7419 locations_res_10, locations_res_11, locations_res_12, &
7420 locations_res_13, locations_res_14, locations_res_15, &
7421 locations_res_16, locations_res_17, locations_res_18, &
7422 locations_res_19, locations_res_20
7424 real(SRP),
dimension(:),
allocatable :: &
7425 sizes_res_1, sizes_res_2, sizes_res_3, sizes_res_4, &
7426 sizes_res_5, sizes_res_6, sizes_res_7, sizes_res_8, &
7427 sizes_res_9, sizes_res_10, sizes_res_11, sizes_res_12, &
7428 sizes_res_13, sizes_res_14, sizes_res_15, sizes_res_16, &
7429 sizes_res_17, sizes_res_18, sizes_res_19, sizes_res_20
7431 logical,
dimension(:),
allocatable :: &
7432 eaten_res_1, eaten_res_2, eaten_res_3, eaten_res_4, &
7433 eaten_res_5, eaten_res_6, eaten_res_7, eaten_res_8, &
7434 eaten_res_9, eaten_res_10, eaten_res_11, eaten_res_12, &
7435 eaten_res_13, eaten_res_14, eaten_res_15, eaten_res_16, &
7436 eaten_res_17, eaten_res_18, eaten_res_19, eaten_res_20
7438 integer,
dimension(:),
allocatable :: &
7439 old_iid_res_1, old_iid_res_2, old_iid_res_3, old_iid_res_4, &
7440 old_iid_res_5, old_iid_res_6, old_iid_res_7, old_iid_res_8, &
7441 old_iid_res_9, old_iid_res_10, old_iid_res_11, old_iid_res_12, &
7442 old_iid_res_13, old_iid_res_14, old_iid_res_15, old_iid_res_16, &
7443 old_iid_res_17, old_iid_res_18, old_iid_res_19, old_iid_res_20
7446 character(len=LABEL_LENGTH) :: label_loc
7450 if (
present(label))
then
7453 label_loc =
"tmp_object"
7463 if (
present(resource_1))
then
7464 abundance_total = abundance_total + resource_1%number_food_items
7465 allocate(locations_res_1(resource_1%number_food_items))
7466 locations_res_1 = resource_1%location()
7467 allocate(sizes_res_1(resource_1%number_food_items))
7468 sizes_res_1 = resource_1%food%size
7469 allocate(eaten_res_1(resource_1%number_food_items))
7470 eaten_res_1 = resource_1%food%eaten
7471 allocate(old_iid_res_1(resource_1%number_food_items))
7472 old_iid_res_1 = resource_1%food%food_iid
7474 allocate(locations_res_1(0))
7475 allocate(sizes_res_1(0))
7476 allocate(eaten_res_1(0))
7477 allocate(old_iid_res_1(0))
7480 if (
present(resource_2))
then
7481 abundance_total = abundance_total + resource_2%number_food_items
7482 allocate(locations_res_2(resource_2%number_food_items))
7483 locations_res_2 = resource_2%location()
7484 allocate(sizes_res_2(resource_2%number_food_items))
7485 sizes_res_2 = resource_2%food%size
7486 allocate(eaten_res_2(resource_2%number_food_items))
7487 eaten_res_2 = resource_2%food%eaten
7488 allocate(old_iid_res_2(resource_2%number_food_items))
7489 old_iid_res_2 = resource_2%food%food_iid
7491 allocate(locations_res_2(0))
7492 allocate(sizes_res_2(0))
7493 allocate(eaten_res_2(0))
7494 allocate(old_iid_res_2(0))
7497 if (
present(resource_3))
then
7498 abundance_total = abundance_total + resource_3%number_food_items
7499 allocate(locations_res_3(resource_3%number_food_items))
7500 locations_res_3 = resource_3%location()
7501 allocate(sizes_res_3(resource_3%number_food_items))
7502 sizes_res_3 = resource_3%food%size
7503 allocate(eaten_res_3(resource_3%number_food_items))
7504 eaten_res_3 = resource_3%food%eaten
7505 allocate(old_iid_res_3(resource_3%number_food_items))
7506 old_iid_res_3 = resource_3%food%food_iid
7508 allocate(locations_res_3(0))
7509 allocate(sizes_res_3(0))
7510 allocate(eaten_res_3(0))
7511 allocate(old_iid_res_3(0))
7514 if (
present(resource_4))
then
7515 abundance_total = abundance_total + resource_4%number_food_items
7516 allocate(locations_res_4(resource_4%number_food_items))
7517 locations_res_4 = resource_4%location()
7518 allocate(sizes_res_4(resource_4%number_food_items))
7519 sizes_res_4 = resource_4%food%size
7520 allocate(eaten_res_4(resource_4%number_food_items))
7521 eaten_res_4 = resource_4%food%eaten
7522 allocate(old_iid_res_4(resource_4%number_food_items))
7523 old_iid_res_4 = resource_4%food%food_iid
7525 allocate(locations_res_4(0))
7526 allocate(sizes_res_4(0))
7527 allocate(eaten_res_4(0))
7528 allocate(old_iid_res_4(0))
7531 if (
present(resource_5))
then
7532 abundance_total = abundance_total + resource_5%number_food_items
7533 allocate(locations_res_5(resource_5%number_food_items))
7534 locations_res_5 = resource_5%location()
7535 allocate(sizes_res_5(resource_5%number_food_items))
7536 sizes_res_5 = resource_5%food%size
7537 allocate(eaten_res_5(resource_5%number_food_items))
7538 eaten_res_5 = resource_5%food%eaten
7539 allocate(old_iid_res_5(resource_5%number_food_items))
7540 old_iid_res_5 = resource_5%food%food_iid
7542 allocate(locations_res_5(0))
7543 allocate(sizes_res_5(0))
7544 allocate(eaten_res_5(0))
7545 allocate(old_iid_res_5(0))
7548 if (
present(resource_6))
then
7549 abundance_total = abundance_total + resource_6%number_food_items
7550 allocate(locations_res_6(resource_6%number_food_items))
7551 locations_res_6 = resource_6%location()
7552 allocate(sizes_res_6(resource_6%number_food_items))
7553 sizes_res_6 = resource_6%food%size
7554 allocate(eaten_res_6(resource_6%number_food_items))
7555 eaten_res_6 = resource_6%food%eaten
7556 allocate(old_iid_res_6(resource_6%number_food_items))
7557 old_iid_res_6 = resource_6%food%food_iid
7559 allocate(locations_res_6(0))
7560 allocate(sizes_res_6(0))
7561 allocate(eaten_res_6(0))
7562 allocate(old_iid_res_6(0))
7565 if (
present(resource_7))
then
7566 abundance_total = abundance_total + resource_7%number_food_items
7567 allocate(locations_res_7(resource_7%number_food_items))
7568 locations_res_7 = resource_7%location()
7569 allocate(sizes_res_7(resource_7%number_food_items))
7570 sizes_res_7 = resource_7%food%size
7571 allocate(eaten_res_7(resource_7%number_food_items))
7572 eaten_res_7 = resource_7%food%eaten
7573 allocate(old_iid_res_7(resource_7%number_food_items))
7574 old_iid_res_7 = resource_7%food%food_iid
7576 allocate(locations_res_7(0))
7577 allocate(sizes_res_7(0))
7578 allocate(eaten_res_7(0))
7579 allocate(old_iid_res_7(0))
7582 if (
present(resource_8))
then
7583 abundance_total = abundance_total + resource_8%number_food_items
7584 allocate(locations_res_8(resource_8%number_food_items))
7585 locations_res_8 = resource_8%location()
7586 allocate(sizes_res_8(resource_8%number_food_items))
7587 sizes_res_8 = resource_8%food%size
7588 allocate(eaten_res_8(resource_8%number_food_items))
7589 eaten_res_8 = resource_8%food%eaten
7590 allocate(old_iid_res_8(resource_8%number_food_items))
7591 old_iid_res_8 = resource_8%food%food_iid
7593 allocate(locations_res_8(0))
7594 allocate(sizes_res_8(0))
7595 allocate(eaten_res_8(0))
7596 allocate(old_iid_res_8(0))
7599 if (
present(resource_9))
then
7600 abundance_total = abundance_total + resource_9%number_food_items
7601 allocate(locations_res_9(resource_9%number_food_items))
7602 locations_res_9 = resource_9%location()
7603 allocate(sizes_res_9(resource_9%number_food_items))
7604 sizes_res_9 = resource_9%food%size
7605 allocate(eaten_res_9(resource_9%number_food_items))
7606 eaten_res_9 = resource_9%food%eaten
7607 allocate(old_iid_res_9(resource_9%number_food_items))
7608 old_iid_res_9 = resource_9%food%food_iid
7610 allocate(locations_res_9(0))
7611 allocate(sizes_res_9(0))
7612 allocate(eaten_res_9(0))
7613 allocate(old_iid_res_9(0))
7616 if (
present(resource_10))
then
7617 abundance_total = abundance_total + resource_10%number_food_items
7618 allocate(locations_res_10(resource_10%number_food_items))
7619 locations_res_10 = resource_10%location()
7620 allocate(sizes_res_10(resource_10%number_food_items))
7621 sizes_res_10 = resource_10%food%size
7622 allocate(eaten_res_10(resource_10%number_food_items))
7623 eaten_res_10 = resource_10%food%eaten
7624 allocate(old_iid_res_10(resource_10%number_food_items))
7625 old_iid_res_10 = resource_10%food%food_iid
7627 allocate(locations_res_10(0))
7628 allocate(sizes_res_10(0))
7629 allocate(eaten_res_10(0))
7630 allocate(old_iid_res_10(0))
7633 if (
present(resource_11))
then
7634 abundance_total = abundance_total + resource_11%number_food_items
7635 allocate(locations_res_11(resource_11%number_food_items))
7636 locations_res_11 = resource_11%location()
7637 allocate(sizes_res_11(resource_11%number_food_items))
7638 sizes_res_11 = resource_11%food%size
7639 allocate(eaten_res_11(resource_11%number_food_items))
7640 eaten_res_11 = resource_11%food%eaten
7641 allocate(old_iid_res_11(resource_11%number_food_items))
7642 old_iid_res_11 = resource_11%food%food_iid
7644 allocate(locations_res_11(0))
7645 allocate(sizes_res_11(0))
7646 allocate(eaten_res_11(0))
7647 allocate(old_iid_res_11(0))
7650 if (
present(resource_12))
then
7651 abundance_total = abundance_total + resource_12%number_food_items
7652 allocate(locations_res_12(resource_12%number_food_items))
7653 locations_res_12 = resource_12%location()
7654 allocate(sizes_res_12(resource_12%number_food_items))
7655 sizes_res_12 = resource_12%food%size
7656 allocate(eaten_res_12(resource_12%number_food_items))
7657 eaten_res_12 = resource_12%food%eaten
7658 allocate(old_iid_res_12(resource_12%number_food_items))
7659 old_iid_res_12 = resource_12%food%food_iid
7661 allocate(locations_res_12(0))
7662 allocate(sizes_res_12(0))
7663 allocate(eaten_res_12(0))
7664 allocate(old_iid_res_12(0))
7667 if (
present(resource_13))
then
7668 abundance_total = abundance_total + resource_13%number_food_items
7669 allocate(locations_res_13(resource_13%number_food_items))
7670 locations_res_13 = resource_13%location()
7671 allocate(sizes_res_13(resource_13%number_food_items))
7672 sizes_res_13 = resource_13%food%size
7673 allocate(eaten_res_13(resource_13%number_food_items))
7674 eaten_res_13 = resource_13%food%eaten
7675 allocate(old_iid_res_13(resource_13%number_food_items))
7676 old_iid_res_13 = resource_13%food%food_iid
7678 allocate(locations_res_13(0))
7679 allocate(sizes_res_13(0))
7680 allocate(eaten_res_13(0))
7681 allocate(old_iid_res_13(0))
7684 if (
present(resource_14))
then
7685 abundance_total = abundance_total + resource_14%number_food_items
7686 allocate(locations_res_14(resource_14%number_food_items))
7687 locations_res_14 = resource_14%location()
7688 allocate(sizes_res_14(resource_14%number_food_items))
7689 sizes_res_14 = resource_14%food%size
7690 allocate(eaten_res_14(resource_14%number_food_items))
7691 eaten_res_14 = resource_14%food%eaten
7692 allocate(old_iid_res_14(resource_14%number_food_items))
7693 old_iid_res_14 = resource_14%food%food_iid
7695 allocate(locations_res_14(0))
7696 allocate(sizes_res_14(0))
7697 allocate(eaten_res_14(0))
7698 allocate(old_iid_res_14(0))
7701 if (
present(resource_15))
then
7702 abundance_total = abundance_total + resource_15%number_food_items
7703 allocate(locations_res_15(resource_15%number_food_items))
7704 locations_res_15 = resource_15%location()
7705 allocate(sizes_res_15(resource_15%number_food_items))
7706 sizes_res_15 = resource_15%food%size
7707 allocate(eaten_res_15(resource_15%number_food_items))
7708 eaten_res_15 = resource_15%food%eaten
7709 allocate(old_iid_res_15(resource_15%number_food_items))
7710 old_iid_res_15 = resource_15%food%food_iid
7712 allocate(locations_res_15(0))
7713 allocate(sizes_res_15(0))
7714 allocate(eaten_res_15(0))
7715 allocate(old_iid_res_15(0))
7718 if (
present(resource_16))
then
7719 abundance_total = abundance_total + resource_16%number_food_items
7720 allocate(locations_res_16(resource_16%number_food_items))
7721 locations_res_16 = resource_16%location()
7722 allocate(sizes_res_16(resource_16%number_food_items))
7723 sizes_res_16 = resource_16%food%size
7724 allocate(eaten_res_16(resource_16%number_food_items))
7725 eaten_res_16 = resource_16%food%eaten
7726 allocate(old_iid_res_16(resource_16%number_food_items))
7727 old_iid_res_16 = resource_16%food%food_iid
7729 allocate(locations_res_16(0))
7730 allocate(sizes_res_16(0))
7731 allocate(eaten_res_16(0))
7732 allocate(old_iid_res_16(0))
7735 if (
present(resource_17))
then
7736 abundance_total = abundance_total + resource_17%number_food_items
7737 allocate(locations_res_17(resource_17%number_food_items))
7738 locations_res_17 = resource_17%location()
7739 allocate(sizes_res_17(resource_17%number_food_items))
7740 sizes_res_17 = resource_17%food%size
7741 allocate(eaten_res_17(resource_17%number_food_items))
7742 eaten_res_17 = resource_17%food%eaten
7743 allocate(old_iid_res_17(resource_17%number_food_items))
7744 old_iid_res_17 = resource_17%food%food_iid
7746 allocate(locations_res_17(0))
7747 allocate(sizes_res_17(0))
7748 allocate(eaten_res_17(0))
7749 allocate(old_iid_res_17(0))
7752 if (
present(resource_18))
then
7753 abundance_total = abundance_total + resource_18%number_food_items
7754 allocate(locations_res_18(resource_18%number_food_items))
7755 locations_res_18 = resource_18%location()
7756 allocate(sizes_res_18(resource_18%number_food_items))
7757 sizes_res_18 = resource_18%food%size
7758 allocate(eaten_res_18(resource_18%number_food_items))
7759 eaten_res_18 = resource_18%food%eaten
7760 allocate(old_iid_res_18(resource_18%number_food_items))
7761 old_iid_res_18 = resource_18%food%food_iid
7763 allocate(locations_res_18(0))
7764 allocate(sizes_res_18(0))
7765 allocate(eaten_res_18(0))
7766 allocate(old_iid_res_18(0))
7769 if (
present(resource_19))
then
7770 abundance_total = abundance_total + resource_19%number_food_items
7771 allocate(locations_res_19(resource_19%number_food_items))
7772 locations_res_19 = resource_19%location()
7773 allocate(sizes_res_19(resource_19%number_food_items))
7774 sizes_res_19 = resource_19%food%size
7775 allocate(eaten_res_19(resource_19%number_food_items))
7776 eaten_res_19 = resource_19%food%eaten
7777 allocate(old_iid_res_19(resource_19%number_food_items))
7778 old_iid_res_19 = resource_19%food%food_iid
7780 allocate(locations_res_19(0))
7781 allocate(sizes_res_19(0))
7782 allocate(eaten_res_19(0))
7783 allocate(old_iid_res_19(0))
7786 if (
present(resource_20))
then
7787 abundance_total = abundance_total + resource_20%number_food_items
7788 allocate(locations_res_20(resource_20%number_food_items))
7789 locations_res_20 = resource_20%location()
7790 allocate(sizes_res_20(resource_20%number_food_items))
7791 sizes_res_20 = resource_20%food%size
7792 allocate(eaten_res_20(resource_20%number_food_items))
7793 eaten_res_20 = resource_20%food%eaten
7794 allocate(old_iid_res_20(resource_20%number_food_items))
7795 old_iid_res_20 = resource_20%food%food_iid
7797 allocate(locations_res_20(0))
7798 allocate(sizes_res_20(0))
7799 allocate(eaten_res_20(0))
7800 allocate(old_iid_res_20(0))
7806 call food_resource_collapsed%make( &
7808 abundance=abundance_total, &
7809 locations=[ locations_res_1, &
7828 locations_res_20 ], &
7829 sizes=[ sizes_res_1, &
7852 food_resource_collapsed%food%eaten = [ eaten_res_1, &
7873 food_resource_collapsed%food%food_iid = [ old_iid_res_1, &
7896 if (
present(reindex))
then
7897 if (reindex)
call food_resource_collapsed%reindex()
7915 result(food_resource_collapsed)
7918 logical,
optional,
intent(in) :: reindex
7921 character(len=*),
optional,
intent(in) :: label
7926 integer :: abundance_total
7929 character(len=LABEL_LENGTH) :: label_loc
7932 integer :: i, j, k, size_arr_step
7947 if (
present(label))
then
7950 label_loc =
"tmp_object"
7952 food_resource_collapsed%food_label = label_loc
7955 if (.not.
allocated( food_resource_collapsed%food )) &
7956 allocate( food_resource_collapsed%food(abundance_total) )
7960 food_resource_collapsed%number_food_items = abundance_total
7964 call food_resource_collapsed%food%create()
7977 do j = size_arr_step + 1, size_arr_step + &
7980 food_resource_collapsed%food(j) = &
7983 size_arr_step = size_arr_step + &
7990 if (
present(reindex))
then
7991 if (reindex)
call food_resource_collapsed%reindex()
8055 class(
food_resource),
optional,
intent(inout) :: resource_1, &
8078 logical,
optional,
intent(in) :: reindex
8082 integer :: global_count_collapsed, i
8086 global_count_collapsed = 0
8088 if (
present(resource_1))
then
8089 associate( res => resource_1 )
8093 do i=1, res%number_food_items
8094 global_count_collapsed = global_count_collapsed + 1
8098 call res%food(i)%position( &
8099 food_resource_collapsed%food(global_count_collapsed)%location())
8100 res%food(i)%size = food_resource_collapsed%food( &
8101 global_count_collapsed)%size
8102 res%food(i)%eaten = food_resource_collapsed%food( &
8103 global_count_collapsed)%eaten
8104 res%food(i)%food_iid = food_resource_collapsed%food( &
8105 global_count_collapsed)%food_iid
8109 if (
present(reindex))
then
8110 if (reindex)
call res%reindex()
8115 if (
present(resource_2))
then
8116 associate( res => resource_2 )
8120 do i=1, res%number_food_items
8121 global_count_collapsed = global_count_collapsed + 1
8125 call res%food(i)%position( &
8126 food_resource_collapsed%food(global_count_collapsed)%location())
8127 res%food(i)%size = food_resource_collapsed%food( &
8128 global_count_collapsed)%size
8129 res%food(i)%eaten = food_resource_collapsed%food( &
8130 global_count_collapsed)%eaten
8131 res%food(i)%food_iid = food_resource_collapsed%food( &
8132 global_count_collapsed)%food_iid
8136 if (
present(reindex))
then
8137 if (reindex)
call res%reindex()
8142 if (
present(resource_3))
then
8143 associate( res => resource_3 )
8147 do i=1, res%number_food_items
8148 global_count_collapsed = global_count_collapsed + 1
8152 call res%food(i)%position( &
8153 food_resource_collapsed%food(global_count_collapsed)%location())
8154 res%food(i)%size = food_resource_collapsed%food( &
8155 global_count_collapsed)%size
8156 res%food(i)%eaten = food_resource_collapsed%food( &
8157 global_count_collapsed)%eaten
8158 res%food(i)%food_iid = food_resource_collapsed%food( &
8159 global_count_collapsed)%food_iid
8163 if (
present(reindex))
then
8164 if (reindex)
call res%reindex()
8169 if (
present(resource_4))
then
8170 associate( res => resource_4 )
8174 do i=1, res%number_food_items
8175 global_count_collapsed = global_count_collapsed + 1
8179 call res%food(i)%position( &
8180 food_resource_collapsed%food(global_count_collapsed)%location())
8181 res%food(i)%size = food_resource_collapsed%food( &
8182 global_count_collapsed)%size
8183 res%food(i)%eaten = food_resource_collapsed%food( &
8184 global_count_collapsed)%eaten
8185 res%food(i)%food_iid = food_resource_collapsed%food( &
8186 global_count_collapsed)%food_iid
8190 if (
present(reindex))
then
8191 if (reindex)
call res%reindex()
8196 if (
present(resource_5))
then
8197 associate( res => resource_5 )
8201 do i=1, res%number_food_items
8202 global_count_collapsed = global_count_collapsed + 1
8206 call res%food(i)%position( &
8207 food_resource_collapsed%food(global_count_collapsed)%location())
8208 res%food(i)%size = food_resource_collapsed%food( &
8209 global_count_collapsed)%size
8210 res%food(i)%eaten = food_resource_collapsed%food( &
8211 global_count_collapsed)%eaten
8212 res%food(i)%food_iid = food_resource_collapsed%food( &
8213 global_count_collapsed)%food_iid
8217 if (
present(reindex))
then
8218 if (reindex)
call res%reindex()
8223 if (
present(resource_6))
then
8224 associate( res => resource_6 )
8228 do i=1, res%number_food_items
8229 global_count_collapsed = global_count_collapsed + 1
8233 call res%food(i)%position( &
8234 food_resource_collapsed%food(global_count_collapsed)%location())
8235 res%food(i)%size = food_resource_collapsed%food( &
8236 global_count_collapsed)%size
8237 res%food(i)%eaten = food_resource_collapsed%food( &
8238 global_count_collapsed)%eaten
8239 res%food(i)%food_iid = food_resource_collapsed%food( &
8240 global_count_collapsed)%food_iid
8244 if (
present(reindex))
then
8245 if (reindex)
call res%reindex()
8250 if (
present(resource_7))
then
8251 associate( res => resource_7 )
8255 do i=1, res%number_food_items
8256 global_count_collapsed = global_count_collapsed + 1
8260 call res%food(i)%position( &
8261 food_resource_collapsed%food(global_count_collapsed)%location())
8262 res%food(i)%size = food_resource_collapsed%food( &
8263 global_count_collapsed)%size
8264 res%food(i)%eaten = food_resource_collapsed%food( &
8265 global_count_collapsed)%eaten
8266 res%food(i)%food_iid = food_resource_collapsed%food( &
8267 global_count_collapsed)%food_iid
8271 if (
present(reindex))
then
8272 if (reindex)
call res%reindex()
8277 if (
present(resource_8))
then
8278 associate( res => resource_8 )
8282 do i=1, res%number_food_items
8283 global_count_collapsed = global_count_collapsed + 1
8287 call res%food(i)%position( &
8288 food_resource_collapsed%food(global_count_collapsed)%location())
8289 res%food(i)%size = food_resource_collapsed%food( &
8290 global_count_collapsed)%size
8291 res%food(i)%eaten = food_resource_collapsed%food( &
8292 global_count_collapsed)%eaten
8293 res%food(i)%food_iid = food_resource_collapsed%food( &
8294 global_count_collapsed)%food_iid
8298 if (
present(reindex))
then
8299 if (reindex)
call res%reindex()
8304 if (
present(resource_9))
then
8305 associate( res => resource_9 )
8309 do i=1, res%number_food_items
8310 global_count_collapsed = global_count_collapsed + 1
8314 call res%food(i)%position( &
8315 food_resource_collapsed%food(global_count_collapsed)%location())
8316 res%food(i)%size = food_resource_collapsed%food( &
8317 global_count_collapsed)%size
8318 res%food(i)%eaten = food_resource_collapsed%food( &
8319 global_count_collapsed)%eaten
8320 res%food(i)%food_iid = food_resource_collapsed%food( &
8321 global_count_collapsed)%food_iid
8325 if (
present(reindex))
then
8326 if (reindex)
call res%reindex()
8331 if (
present(resource_10))
then
8332 associate( res => resource_10 )
8336 do i=1, res%number_food_items
8337 global_count_collapsed = global_count_collapsed + 1
8341 call res%food(i)%position( &
8342 food_resource_collapsed%food(global_count_collapsed)%location())
8343 res%food(i)%size = food_resource_collapsed%food( &
8344 global_count_collapsed)%size
8345 res%food(i)%eaten = food_resource_collapsed%food( &
8346 global_count_collapsed)%eaten
8347 res%food(i)%food_iid = food_resource_collapsed%food( &
8348 global_count_collapsed)%food_iid
8352 if (
present(reindex))
then
8353 if (reindex)
call res%reindex()
8358 if (
present(resource_11))
then
8359 associate( res => resource_11 )
8363 do i=1, res%number_food_items
8364 global_count_collapsed = global_count_collapsed + 1
8368 call res%food(i)%position( &
8369 food_resource_collapsed%food(global_count_collapsed)%location())
8370 res%food(i)%size = food_resource_collapsed%food( &
8371 global_count_collapsed)%size
8372 res%food(i)%eaten = food_resource_collapsed%food( &
8373 global_count_collapsed)%eaten
8374 res%food(i)%food_iid = food_resource_collapsed%food( &
8375 global_count_collapsed)%food_iid
8379 if (
present(reindex))
then
8380 if (reindex)
call res%reindex()
8385 if (
present(resource_12))
then
8386 associate( res => resource_12 )
8390 do i=1, res%number_food_items
8391 global_count_collapsed = global_count_collapsed + 1
8395 call res%food(i)%position( &
8396 food_resource_collapsed%food(global_count_collapsed)%location())
8397 res%food(i)%size = food_resource_collapsed%food( &
8398 global_count_collapsed)%size
8399 res%food(i)%eaten = food_resource_collapsed%food( &
8400 global_count_collapsed)%eaten
8401 res%food(i)%food_iid = food_resource_collapsed%food( &
8402 global_count_collapsed)%food_iid
8406 if (
present(reindex))
then
8407 if (reindex)
call res%reindex()
8412 if (
present(resource_13))
then
8413 associate( res => resource_13 )
8417 do i=1, res%number_food_items
8418 global_count_collapsed = global_count_collapsed + 1
8422 call res%food(i)%position( &
8423 food_resource_collapsed%food(global_count_collapsed)%location())
8424 res%food(i)%size = food_resource_collapsed%food( &
8425 global_count_collapsed)%size
8426 res%food(i)%eaten = food_resource_collapsed%food( &
8427 global_count_collapsed)%eaten
8428 res%food(i)%food_iid = food_resource_collapsed%food( &
8429 global_count_collapsed)%food_iid
8433 if (
present(reindex))
then
8434 if (reindex)
call res%reindex()
8439 if (
present(resource_14))
then
8440 associate( res => resource_14 )
8444 do i=1, res%number_food_items
8445 global_count_collapsed = global_count_collapsed + 1
8449 call res%food(i)%position( &
8450 food_resource_collapsed%food(global_count_collapsed)%location())
8451 res%food(i)%size = food_resource_collapsed%food( &
8452 global_count_collapsed)%size
8453 res%food(i)%eaten = food_resource_collapsed%food( &
8454 global_count_collapsed)%eaten
8455 res%food(i)%food_iid = food_resource_collapsed%food( &
8456 global_count_collapsed)%food_iid
8460 if (
present(reindex))
then
8461 if (reindex)
call res%reindex()
8466 if (
present(resource_15))
then
8467 associate( res => resource_15 )
8471 do i=1, res%number_food_items
8472 global_count_collapsed = global_count_collapsed + 1
8476 call res%food(i)%position( &
8477 food_resource_collapsed%food(global_count_collapsed)%location())
8478 res%food(i)%size = food_resource_collapsed%food( &
8479 global_count_collapsed)%size
8480 res%food(i)%eaten = food_resource_collapsed%food( &
8481 global_count_collapsed)%eaten
8482 res%food(i)%food_iid = food_resource_collapsed%food( &
8483 global_count_collapsed)%food_iid
8487 if (
present(reindex))
then
8488 if (reindex)
call res%reindex()
8493 if (
present(resource_16))
then
8494 associate( res => resource_16 )
8498 do i=1, res%number_food_items
8499 global_count_collapsed = global_count_collapsed + 1
8503 call res%food(i)%position( &
8504 food_resource_collapsed%food(global_count_collapsed)%location())
8505 res%food(i)%size = food_resource_collapsed%food( &
8506 global_count_collapsed)%size
8507 res%food(i)%eaten = food_resource_collapsed%food( &
8508 global_count_collapsed)%eaten
8509 res%food(i)%food_iid = food_resource_collapsed%food( &
8510 global_count_collapsed)%food_iid
8514 if (
present(reindex))
then
8515 if (reindex)
call res%reindex()
8520 if (
present(resource_17))
then
8521 associate( res => resource_17 )
8525 do i=1, res%number_food_items
8526 global_count_collapsed = global_count_collapsed + 1
8530 call res%food(i)%position( &
8531 food_resource_collapsed%food(global_count_collapsed)%location())
8532 res%food(i)%size = food_resource_collapsed%food( &
8533 global_count_collapsed)%size
8534 res%food(i)%eaten = food_resource_collapsed%food( &
8535 global_count_collapsed)%eaten
8536 res%food(i)%food_iid = food_resource_collapsed%food( &
8537 global_count_collapsed)%food_iid
8541 if (
present(reindex))
then
8542 if (reindex)
call res%reindex()
8547 if (
present(resource_18))
then
8548 associate( res => resource_18 )
8552 do i=1, res%number_food_items
8553 global_count_collapsed = global_count_collapsed + 1
8557 call res%food(i)%position( &
8558 food_resource_collapsed%food(global_count_collapsed)%location())
8559 res%food(i)%size = food_resource_collapsed%food( &
8560 global_count_collapsed)%size
8561 res%food(i)%eaten = food_resource_collapsed%food( &
8562 global_count_collapsed)%eaten
8563 res%food(i)%food_iid = food_resource_collapsed%food( &
8564 global_count_collapsed)%food_iid
8568 if (
present(reindex))
then
8569 if (reindex)
call res%reindex()
8574 if (
present(resource_19))
then
8575 associate( res => resource_19 )
8579 do i=1, res%number_food_items
8580 global_count_collapsed = global_count_collapsed + 1
8584 call res%food(i)%position( &
8585 food_resource_collapsed%food(global_count_collapsed)%location())
8586 res%food(i)%size = food_resource_collapsed%food( &
8587 global_count_collapsed)%size
8588 res%food(i)%eaten = food_resource_collapsed%food( &
8589 global_count_collapsed)%eaten
8590 res%food(i)%food_iid = food_resource_collapsed%food( &
8591 global_count_collapsed)%food_iid
8595 if (
present(reindex))
then
8596 if (reindex)
call res%reindex()
8601 if (
present(resource_20))
then
8602 associate( res => resource_20 )
8606 do i=1, res%number_food_items
8607 global_count_collapsed = global_count_collapsed + 1
8611 call res%food(i)%position( &
8612 food_resource_collapsed%food(global_count_collapsed)%location())
8613 res%food(i)%size = food_resource_collapsed%food( &
8614 global_count_collapsed)%size
8615 res%food(i)%eaten = food_resource_collapsed%food( &
8616 global_count_collapsed)%eaten
8617 res%food(i)%food_iid = food_resource_collapsed%food( &
8618 global_count_collapsed)%food_iid
8622 if (
present(reindex))
then
8623 if (reindex)
call res%reindex()
8642 logical,
optional,
intent(in) :: reindex
8646 integer :: global_count_collapsed, res_num, i, j
8653 global_count_collapsed = 0
8657 do concurrent(i=1:res%number_food_items)
8662 global_count_collapsed = sum( &
8664 j=1, res_num-1 )] ) + i
8668 call res%food(i)%position( &
8669 food_resource_collapsed%food(global_count_collapsed)%location())
8670 res%food(i)%size = food_resource_collapsed%food( &
8671 global_count_collapsed)%size
8672 res%food(i)%eaten = food_resource_collapsed%food( &
8673 global_count_collapsed)%eaten
8674 res%food(i)%food_iid = food_resource_collapsed%food( &
8675 global_count_collapsed)%food_iid
8679 if (
present(reindex))
then
8680 if (reindex)
call res%reindex()
8728 type(
habitat),
optional,
intent(in) :: habitat_1, &
8752 logical,
optional,
intent(in) :: reindex
8756 integer :: global_count_collapsed
8758 global_count_collapsed = 0
8763 if (
present(habitat_1))
then
8764 global_count_collapsed = global_count_collapsed + 1
8767 if (
present(habitat_2))
then
8768 global_count_collapsed = global_count_collapsed + 1
8771 if (
present(habitat_3))
then
8772 global_count_collapsed = global_count_collapsed + 1
8775 if (
present(habitat_4))
then
8776 global_count_collapsed = global_count_collapsed + 1
8779 if (
present(habitat_5))
then
8780 global_count_collapsed = global_count_collapsed + 1
8783 if (
present(habitat_6))
then
8784 global_count_collapsed = global_count_collapsed + 1
8787 if (
present(habitat_7))
then
8788 global_count_collapsed = global_count_collapsed + 1
8791 if (
present(habitat_8))
then
8792 global_count_collapsed = global_count_collapsed + 1
8795 if (
present(habitat_9))
then
8796 global_count_collapsed = global_count_collapsed + 1
8799 if (
present(habitat_10))
then
8800 global_count_collapsed = global_count_collapsed + 1
8803 if (
present(habitat_11))
then
8804 global_count_collapsed = global_count_collapsed + 1
8807 if (
present(habitat_10))
then
8808 global_count_collapsed = global_count_collapsed + 1
8811 if (
present(habitat_13))
then
8812 global_count_collapsed = global_count_collapsed + 1
8815 if (
present(habitat_14))
then
8816 global_count_collapsed = global_count_collapsed + 1
8819 if (
present(habitat_15))
then
8820 global_count_collapsed = global_count_collapsed + 1
8823 if (
present(habitat_16))
then
8824 global_count_collapsed = global_count_collapsed + 1
8827 if (
present(habitat_17))
then
8828 global_count_collapsed = global_count_collapsed + 1
8831 if (
present(habitat_18))
then
8832 global_count_collapsed = global_count_collapsed + 1
8835 if (
present(habitat_19))
then
8836 global_count_collapsed = global_count_collapsed + 1
8839 if (
present(habitat_20))
then
8840 global_count_collapsed = global_count_collapsed + 1
8854 global_count_collapsed = 0
8856 if (
present(habitat_1))
then
8857 global_count_collapsed = global_count_collapsed + 1
8861 if (
present(habitat_2))
then
8862 global_count_collapsed = global_count_collapsed + 1
8866 if (
present(habitat_3))
then
8867 global_count_collapsed = global_count_collapsed + 1
8871 if (
present(habitat_4))
then
8872 global_count_collapsed = global_count_collapsed + 1
8876 if (
present(habitat_5))
then
8877 global_count_collapsed = global_count_collapsed + 1
8881 if (
present(habitat_6))
then
8882 global_count_collapsed = global_count_collapsed + 1
8886 if (
present(habitat_7))
then
8887 global_count_collapsed = global_count_collapsed + 1
8891 if (
present(habitat_8))
then
8892 global_count_collapsed = global_count_collapsed + 1
8896 if (
present(habitat_9))
then
8897 global_count_collapsed = global_count_collapsed + 1
8901 if (
present(habitat_10))
then
8902 global_count_collapsed = global_count_collapsed + 1
8906 if (
present(habitat_11))
then
8907 global_count_collapsed = global_count_collapsed + 1
8911 if (
present(habitat_12))
then
8912 global_count_collapsed = global_count_collapsed + 1
8916 if (
present(habitat_13))
then
8917 global_count_collapsed = global_count_collapsed + 1
8921 if (
present(habitat_14))
then
8922 global_count_collapsed = global_count_collapsed + 1
8926 if (
present(habitat_15))
then
8927 global_count_collapsed = global_count_collapsed + 1
8931 if (
present(habitat_16))
then
8932 global_count_collapsed = global_count_collapsed + 1
8936 if (
present(habitat_17))
then
8937 global_count_collapsed = global_count_collapsed + 1
8941 if (
present(habitat_18))
then
8942 global_count_collapsed = global_count_collapsed + 1
8946 if (
present(habitat_19))
then
8947 global_count_collapsed = global_count_collapsed + 1
8951 if (
present(habitat_20))
then
8952 global_count_collapsed = global_count_collapsed + 1
8959 if (
present(reindex))
then
8999 type(
habitat),
intent(out) :: habitat_1
9001 type(
habitat),
optional,
intent(out) :: habitat_2, &
9025 logical,
optional,
intent(in) :: reindex
9029 integer :: global_count_collapsed
9031 global_count_collapsed = 0
9034 global_count_collapsed = global_count_collapsed + 1
9036 if (
present(reindex))
then
9037 if (reindex)
call habitat_1%food%reindex()
9041 if (
present(habitat_2))
then
9042 global_count_collapsed = global_count_collapsed + 1
9044 if (
present(reindex))
then
9045 if (reindex)
call habitat_2%food%reindex()
9049 if (
present(habitat_3))
then
9050 global_count_collapsed = global_count_collapsed + 1
9052 if (
present(reindex))
then
9053 if (reindex)
call habitat_3%food%reindex()
9057 if (
present(habitat_4))
then
9058 global_count_collapsed = global_count_collapsed + 1
9060 if (
present(reindex))
then
9061 if (reindex)
call habitat_4%food%reindex()
9065 if (
present(habitat_5))
then
9066 global_count_collapsed = global_count_collapsed + 1
9068 if (
present(reindex))
then
9069 if (reindex)
call habitat_5%food%reindex()
9073 if (
present(habitat_6))
then
9074 global_count_collapsed = global_count_collapsed + 1
9076 if (
present(reindex))
then
9077 if (reindex)
call habitat_6%food%reindex()
9081 if (
present(habitat_7))
then
9082 global_count_collapsed = global_count_collapsed + 1
9084 if (
present(reindex))
then
9085 if (reindex)
call habitat_7%food%reindex()
9089 if (
present(habitat_8))
then
9090 global_count_collapsed = global_count_collapsed + 1
9092 if (
present(reindex))
then
9093 if (reindex)
call habitat_8%food%reindex()
9097 if (
present(habitat_9))
then
9098 global_count_collapsed = global_count_collapsed + 1
9100 if (
present(reindex))
then
9101 if (reindex)
call habitat_9%food%reindex()
9105 if (
present(habitat_10))
then
9106 global_count_collapsed = global_count_collapsed + 1
9108 if (
present(reindex))
then
9109 if (reindex)
call habitat_10%food%reindex()
9113 if (
present(habitat_11))
then
9114 global_count_collapsed = global_count_collapsed + 1
9116 if (
present(reindex))
then
9117 if (reindex)
call habitat_11%food%reindex()
9121 if (
present(habitat_12))
then
9122 global_count_collapsed = global_count_collapsed + 1
9124 if (
present(reindex))
then
9125 if (reindex)
call habitat_12%food%reindex()
9129 if (
present(habitat_13))
then
9130 global_count_collapsed = global_count_collapsed + 1
9132 if (
present(reindex))
then
9133 if (reindex)
call habitat_13%food%reindex()
9137 if (
present(habitat_14))
then
9138 global_count_collapsed = global_count_collapsed + 1
9140 if (
present(reindex))
then
9141 if (reindex)
call habitat_14%food%reindex()
9145 if (
present(habitat_15))
then
9146 global_count_collapsed = global_count_collapsed + 1
9148 if (
present(reindex))
then
9149 if (reindex)
call habitat_15%food%reindex()
9153 if (
present(habitat_16))
then
9154 global_count_collapsed = global_count_collapsed + 1
9156 if (
present(reindex))
then
9157 if (reindex)
call habitat_16%food%reindex()
9161 if (
present(habitat_17))
then
9162 global_count_collapsed = global_count_collapsed + 1
9164 if (
present(reindex))
then
9165 if (reindex)
call habitat_17%food%reindex()
9169 if (
present(habitat_18))
then
9170 global_count_collapsed = global_count_collapsed + 1
9172 if (
present(reindex))
then
9173 if (reindex)
call habitat_18%food%reindex()
9177 if (
present(habitat_19))
then
9178 global_count_collapsed = global_count_collapsed + 1
9180 if (
present(reindex))
then
9181 if (reindex)
call habitat_19%food%reindex()
9185 if (
present(habitat_20))
then
9186 global_count_collapsed = global_count_collapsed + 1
9188 if (
present(reindex))
then
9189 if (reindex)
call habitat_20%food%reindex()
9217 index_vector, ranks, rank_max, &
9219 class(
spatial),
intent(in) :: this
9223 class(
spatial),
dimension(:),
intent(in) :: neighbours
9227 real(SRP),
dimension(:),
optional,
intent(out) :: dist
9232 integer,
dimension(:),
optional,
intent(out) :: index_vector
9236 integer,
dimension(:),
optional,
intent(out) :: ranks
9241 integer,
optional,
intent(in) :: rank_max
9244 logical,
optional,
intent(out) :: error_flag
9248 real(SRP),
dimension(size(neighbours)) :: dist_here
9249 integer,
dimension(size(neighbours)) :: index_vec_here
9252 character (len=*),
parameter :: PROCNAME =
"(spatial_neighbours_distances)"
9255 if (
present(error_flag)) error_flag=.false.
9264 dist_here = this%distance(neighbours)
9267 if (
present(
dist))
dist = dist_here
9273 if (
present(index_vector))
then
9275 if (
size(neighbours) /=
size(index_vector) )
then
9276 if (
present(error_flag)) error_flag=.true.
9277 call log_msg( ltag_warn // procname // &
9278 ": INDEX_VECTOR mismatch neighbours vector!" )
9280 if (
present(rank_max))
then
9284 call array_index(dist_here, index_vector, rank_max)
9287 call array_index(dist_here, index_vector)
9289 if (
present(ranks))
then
9291 if (
size(neighbours) /=
size(ranks) )
then
9292 if (
present(error_flag)) error_flag=.true.
9293 call log_msg( ltag_warn // procname // &
9294 ": RANKS mismatch neighbours vector!")
9296 call array_rank(index_vector, ranks)
9300 if (
present(ranks))
then
9301 if (
size(neighbours) /=
size(ranks) )
then
9302 call log_msg( ltag_warn // procname // &
9303 ": RANKS mismatch neighbours vector!")
9305 if (
present(rank_max))
then
9309 call array_index(dist_here, index_vec_here, rank_max)
9312 call array_index(dist_here, index_vec_here)
9314 call array_rank(index_vec_here, ranks)
9315 index_vector = index_vec_here
9330 class(
predator),
intent(inout) :: this
9333 real(srp),
intent(in) :: body_size
9335 real(srp),
intent(in) :: attack_rate
9338 type(
spatial),
intent(in),
optional :: position
9341 character(len=*),
optional,
intent(in) :: label
9348 this%body_size = max( zero, body_size )
9352 this%attack_rate = within(attack_rate, 0.0_srp, 1.0_srp)
9356 if (
present(position))
call this%position(position)
9359 if (
present(label))
then
9371 class(
predator),
intent(inout) :: this
9373 character(len=*),
optional :: label
9375 if (
present(label))
then
9378 this%label =
"PRED_" // rand_string( label_length-len(
"PRED_"), &
9379 label_cst, label_cen)
9387 class(
predator),
intent(in) :: this
9388 real(srp) :: body_size_get
9390 body_size_get = this%body_size
9397 class(
predator),
intent(in) :: this
9398 real(srp) :: capt_get
9400 capt_get = this%attack_rate
9429 prey_spatial, prey_length, &
9430 prey_distance, is_freezing, &
9431 time_step_model, debug_plot_file)
result (risk_out)
9432 class(
predator),
intent(in) :: this
9434 class(
spatial),
intent(in) :: prey_spatial
9436 real(srp),
intent(in) :: prey_length
9439 real(srp),
optional,
intent(in) :: prey_distance
9442 logical,
optional,
intent(in) :: is_freezing
9444 integer,
optional,
intent(in) :: time_step_model
9447 character(len=*),
optional,
intent(in) :: debug_plot_file
9451 real(srp) :: risk_out
9453 character(len=*),
parameter :: procname = &
9454 "(predator_capture_risk_calculate_fish)"
9457 real(srp) :: prey_distance_here
9458 logical :: is_freezing_loc
9459 integer :: time_step_here
9460 character(FILENAME_LENGTH) :: debug_plot_file_here
9464 real(srp) :: irradiance_agent_depth
9466 real(srp) :: prey_fish_area_m
9469 real(srp) :: prey_visibility
9472 if (
present(is_freezing))
then
9473 is_freezing_loc = is_freezing
9475 is_freezing_loc = .false.
9480 if (
present(time_step_model))
then
9481 time_step_here = time_step_model
9483 time_step_here = global_time_step_model_current
9488 if (
present(prey_distance))
then
9489 prey_distance_here = prey_distance
9494 prey_distance_here = this%distance( prey_spatial )
9502 if (
present(debug_plot_file))
then
9503 debug_plot_file_here = debug_plot_file
9505 debug_plot_file_here =
"plot_debug_predation_risk_" // &
9506 tostr(global_time_step_model_current) //
"_" // &
9507 rand_string(label_length, label_cst,label_cen) // ps
9514 irradiance_agent_depth = prey_spatial%illumination(time_step_here)
9518 prey_fish_area_m = length2sidearea_fish( cm2m( prey_length ) )
9534 irradiance = irradiance_agent_depth, &
9535 prey_area = prey_fish_area_m, &
9536 prey_contrast = individual_visual_contrast_default &
9543 if ( prey_visibility < prey_distance_here )
then
9544 call log_dbg(ltag_info //
"Prey agent is invisible to the predator:" // &
9545 " visibility=" // tostr(prey_visibility) //
" < " // &
9546 " distance=" // tostr(prey_distance_here), procname,
modname)
9557 moving_vs_freezing:
if (is_freezing_loc)
then
9567 integer,
parameter :: interpol_dim = 4
9569 real(srp),
dimension(INTERPOL_DIM) :: interpol_abscissa, &
9579 interpol_abscissa = [ 0.0_srp, &
9580 prey_visibility * 0.50_srp, &
9581 prey_visibility * 0.75_srp, &
9597 interpol_ordinate = [ this%attack_rate, &
9598 this%attack_rate * &
9599 predator_attack_capture_prob_frz_50, &
9600 this%attack_rate * &
9601 predator_attack_capture_prob_frz_75, &
9615 risk_out = within( ddpinterpol( interpol_abscissa, &
9616 interpol_ordinate, &
9617 prey_distance_here ), 0.0_srp, 1.0_srp )
9623 call debug_interpolate_plot_save( &
9624 grid_xx=interpol_abscissa, grid_yy=interpol_ordinate, &
9625 ipol_value=prey_distance_here, &
9626 algstr=
"DDPINTERPOL", &
9627 output_file=trim(debug_plot_file_here) )
9631 else moving_vs_freezing
9636 normal_moving: block
9641 integer,
parameter :: interpol_dim = 3
9643 real(srp),
dimension(INTERPOL_DIM) :: interpol_abscissa, &
9650 interpol_abscissa = [0.0_srp, prey_visibility/2.0_srp, prey_visibility]
9666 interpol_ordinate = [ this%attack_rate, &
9667 this%attack_rate * &
9668 predator_attack_capture_probability_half, &
9669 this%attack_rate * &
9670 predator_attack_capture_probability_min ]
9683 risk_out = within( ddpinterpol( interpol_abscissa, &
9684 interpol_ordinate, &
9685 prey_distance_here ), 0.0_srp, 1.0_srp )
9691 call debug_interpolate_plot_save( &
9692 grid_xx=interpol_abscissa, grid_yy=interpol_ordinate, &
9693 ipol_value=prey_distance_here, &
9694 algstr=
"DDPINTERPOL", &
9695 output_file=trim(debug_plot_file_here) )
9697 end block normal_moving
9699 end if moving_vs_freezing
9704 if ( is_freezing_loc )
call log_dbg(ltag_info //
"Agent is freezing.", &
9706 call log_dbg(ltag_info //
"Calculated predator's capture probability: " //&
9707 tostr(risk_out) //
", Distance: " // tostr(prey_distance_here) // &
9708 ", Visual range:" // tostr(prey_visibility), procname,
modname)
9727 prey_spatial, prey_length, is_freezing, &
9728 time_step_model, risk, risk_indexed, &
9730 class(
predator),
intent(in) :: this
9732 class(
spatial),
dimension(:),
intent(in) :: prey_spatial
9734 real(SRP),
dimension(:),
intent(in) :: prey_length
9737 logical,
optional,
dimension(:),
intent(in) :: is_freezing
9739 integer,
optional,
intent(in) :: time_step_model
9746 real(SRP),
optional,
dimension(:),
intent(out) :: risk
9762 real(SRP),
optional,
dimension(:),
intent(out) :: risk_indexed
9774 integer,
optional,
dimension(:),
intent(out) :: index_dist
9777 character(len=*),
parameter :: PROCNAME = &
9778 "(predator_capture_risk_calculate_fish_group)"
9781 integer :: time_step_model_here
9782 logical,
dimension(size(prey_spatial)) :: is_freezing_here
9846 integer,
dimension(size(prey_spatial)) :: dist_index
9852 real(SRP),
dimension(size(prey_spatial)) :: risk_adjusted
9860 real(SRP),
dimension(PREDATOR_RISK_GROUP_SELECT_INDEX_PARTIAL) :: &
9861 risk_adjusted_indexed
9867 real(SRP),
dimension(size(prey_spatial)) :: dist_neighbours
9873 logical,
dimension(PREDATOR_RISK_GROUP_SELECT_INDEX_PARTIAL) &
9874 :: risk_agent_is_visible
9879 real(SRP),
dimension(PREDATOR_RISK_GROUP_SELECT_INDEX_PARTIAL) &
9880 :: risk_agent_visibility
9890 integer,
dimension(PREDATOR_RISK_GROUP_SELECT_INDEX_PARTIAL) &
9895 integer :: rank_visible
9900 real(SRP),
dimension(PREDATOR_RISK_GROUP_SELECT_INDEX_PARTIAL) &
9901 :: risk_agent_baseline
9905 real(SRP) :: dilution_weight
9908 integer :: i, min_dim
9911 character(len=:),
allocatable :: tmp_debug_file
9919 dist_neighbours = missing ; dist_index = unknown
9920 risk_agent_rank = unknown ; risk_agent_is_visible = .false.
9921 risk_agent_visibility = missing ; risk_agent_baseline = 0.0_srp
9923 risk_adjusted = 0.0_srp; risk_adjusted_indexed = 0.0_srp
9927 if (
present(is_freezing))
then
9928 is_freezing_here = is_freezing
9930 is_freezing_here = .false.
9935 if (
present(time_step_model))
then
9936 time_step_model_here = time_step_model
9938 time_step_model_here = global_time_step_model_current
9943 if ( .not. (
size(prey_spatial) ==
size(prey_length) .and. &
9944 size(prey_length) ==
size(is_freezing_here) ) )
then
9947 call log_msg( ltag_warn //
"Unequal agent input arrays in " // procname &
9948 //
": " // tostr(
size(prey_spatial)) //
", " // &
9949 tostr(
size(prey_length)) //
", " // &
9950 tostr(
size(is_freezing)) )
9958 call this%neighbours( neighbours = prey_spatial, &
9959 dist = dist_neighbours, &
9960 index_vector = dist_index, &
9961 rank_max = predator_risk_group_select_index_partial,&
9962 error_flag = err_flag )
9964 if (err_flag)
call log_msg ( ltag_warn // procname //
": Got error flag" &
9965 //
" from conspecific objects (neighbours) procedure.")
9969 if (
present(index_dist))
then
9970 index_dist = unknown
9971 min_dim = min(
size(index_dist),
size(dist_index))
9972 index_dist(1:min_dim) = dist_index(1:min_dim)
9995 do i = 1, predator_risk_group_select_index_partial
9998 risk_agent_visibility(i) = &
9999 prey_spatial(dist_index(i))%visibility( &
10000 object_area = length2sidearea_fish(cm2m( &
10001 prey_length(dist_index(i)))), &
10002 time_step_model = time_step_model_here )
10008 if ( dist_neighbours(dist_index(i)) < risk_agent_visibility(i) )
then
10011 risk_agent_is_visible(i) = .true.
10031 rank_visible = rank_visible + 1
10032 risk_agent_rank(i) = rank_visible
10043 risk_agent_baseline(i) = &
10044 this%risk_fish( prey_spatial = prey_spatial(dist_index(i)), &
10045 prey_length = prey_length(dist_index(i)), &
10046 is_freezing = is_freezing_here(dist_index(i)), &
10047 time_step_model = time_step_model_here )
10057 if ( rank_visible==0 )
then
10058 call log_dbg(ltag_info //
"This predator does not see any potential" // &
10059 " prey agents.", procname,
modname)
10060 if (
present(risk)) risk=risk_adjusted
10061 if (
present(risk_indexed))
then
10062 risk_indexed = missing
10063 min_dim = min(
size(risk_adjusted_indexed),
size(risk_indexed) )
10064 risk_indexed(1:min_dim) = risk_adjusted_indexed(1:min_dim)
10095 do concurrent(i=1:predator_risk_group_select_index_partial)
10096 risk_adjusted_indexed(i) = risk_adjusted(dist_index(i))
10130 tmp_debug_file =
"debug_predator_dilution_" // &
10131 tostr(global_time_step_model_current) //
"_" // &
10132 rand_string(label_length, label_cst,label_cen) // csv
10134 call csv_matrix_write ( reshape( &
10135 [conv_l2r(risk_agent_is_visible), &
10136 real(risk_agent_rank, kind=srp), &
10137 risk_agent_visibility, &
10138 dist_neighbours(dist_index( &
10139 1:predator_risk_group_select_index_partial)), &
10140 risk_agent_baseline, &
10141 risk_adjusted(dist_index( &
10142 1:predator_risk_group_select_index_partial))], &
10143 [predator_risk_group_select_index_partial, 6]), &
10145 [
"IS_VISIBLE",
"RANK ",
"VISIBILITY", &
10146 "DIST ",
"RISK_BASE ",
"RISK_ADJ "] &
10148 call log_dbg( ltag_info //
"Saved debug predator dilution data" // &
10149 ", CSV file: " // tmp_debug_file, procname,
modname )
10154 if (
present(risk)) risk=risk_adjusted
10155 if (
present(risk_indexed))
then
10156 risk_indexed = 0.0_srp
10157 min_dim = min(
size(risk_adjusted_indexed),
size(risk_indexed))
10158 risk_indexed(1:min_dim) = risk_adjusted_indexed(1:min_dim)
10173 do concurrent(i = 1 : predator_risk_group_select_index_partial)
10174 if ( risk_agent_is_visible(i) )
then
10183 risk_adjusted(dist_index(i))=risk_agent_baseline(i)
10202 character(len=*),
parameter :: PROCNAME =
"(adjust_risk_nonpar_fixed)"
10212 real(SRP),
dimension(size(PREDATOR_RISK_GROUP_DILUTION_ORDINATE)) &
10213 :: predator_risk_group_dilution_abscissa
10223 predator_risk_group_dilution_abscissa = &
10225 1.0_srp + (real(rank_visible - 1, srp)/2.0_srp), &
10226 real(rank_visible, SRP) ]
10228 do concurrent(i = 1 : predator_risk_group_select_index_partial)
10229 if ( risk_agent_is_visible(i) )
then
10259 dilution_weight=ddpinterpol( predator_risk_group_dilution_abscissa,&
10260 predator_risk_group_dilution_ordinate, &
10261 real(risk_agent_rank(i), SRP) )
10287 risk_adjusted(dist_index(i))=risk_agent_baseline(i)*dilution_weight
10317 real(SRP),
allocatable,
dimension(:) :: predator_risk_dilution
10323 if (rank_visible == 1)
then
10326 risk_adjusted(dist_index(1)) = risk_agent_baseline(1)
10328 elseif (rank_visible == 2)
then
10332 risk_adjusted(dist_index(1)) = risk_agent_baseline(1)
10333 risk_adjusted(dist_index(2)) = risk_agent_baseline(2) / 2.0_srp
10339 allocate(predator_risk_dilution(rank_visible-1))
10340 predator_risk_dilution = linspace( 2.0_srp/(rank_visible-1), &
10343 call log_dbg( ltag_info //
"Predator dilution factor array: " // &
10344 tostr(predator_risk_dilution), procname,
modname )
10347 do concurrent(i = 1 : predator_risk_group_select_index_partial)
10348 if ( risk_agent_is_visible(i) )
then
10349 if ( risk_agent_rank(i) == 1 )
then
10353 risk_adjusted(dist_index(i)) = risk_agent_baseline(i)
10372 risk_adjusted(dist_index(i)) = risk_agent_baseline(i) * &
10373 predator_risk_dilution(risk_agent_rank(i)-1)
10403 real(SRP),
allocatable,
dimension(:) :: predator_risk_dilution
10409 if (rank_visible == 1)
then
10412 risk_adjusted(dist_index(1)) = risk_agent_baseline(1)
10414 elseif (rank_visible == 2)
then
10418 risk_adjusted(dist_index(1)) = risk_agent_baseline(1) / 2.0_srp
10419 risk_adjusted(dist_index(2)) = risk_agent_baseline(2) / 2.0_srp
10425 allocate(predator_risk_dilution(rank_visible))
10426 predator_risk_dilution = linspace( 2.0_srp/rank_visible, &
10429 call log_dbg( ltag_info //
"Predator dilution factor array: " // &
10430 tostr(predator_risk_dilution), procname,
modname )
10433 do concurrent(i = 1 : predator_risk_group_select_index_partial)
10434 if ( risk_agent_is_visible(i) )
then
10443 risk_adjusted(dist_index(i)) = risk_agent_baseline(i) * &
10444 predator_risk_dilution(risk_agent_rank(i))
10464 time_step_model)
result (visrange)
10465 class(
predator),
intent(in) :: this
10470 real(srp),
optional,
intent(in) :: object_area
10474 real(srp),
optional,
intent(in) :: contrast
10478 integer,
optional,
intent(in) :: time_step_model
10480 real(srp) :: visrange
10483 real(srp) :: object_area_here, contrast_here
10486 real(srp) :: irradiance_agent_depth
10487 integer :: time_step_model_here
10496 if (
present(object_area))
then
10497 object_area_here = object_area
10499 object_area_here = length2sidearea_fish( cm2m( this%body_size ) )
10504 if (
present(contrast))
then
10505 contrast_here = contrast
10507 contrast_here = preycontrast_default
10512 if (
present(time_step_model))
then
10513 time_step_model_here = time_step_model
10515 time_step_model_here = global_time_step_model_current
10521 irradiance_agent_depth = this%illumination(time_step_model_here)
10526 m2cm(
visual_range( irradiance = irradiance_agent_depth, &
10527 prey_area = object_area_here, &
10528 prey_contrast = contrast_here ) )
10542 result(mean_nndist)
10546 class(
spatial),
dimension(:),
intent(in) :: spatial_objects
10549 integer,
optional,
intent(in) :: sample_size
10553 real(srp) :: mean_nndist
10556 character(len=*),
parameter :: procname =
"(distance_average)"
10562 integer,
parameter :: sample_size_default=25, sample_size_warn=20
10578 integer,
parameter :: max_array_dimensionality = nint( &
10579 (sqrt(4.0_srp * sample_size_default + 1) + 1.0_srp) / 2.0_srp )
10583 integer :: i, j, k, perm
10586 integer(LONG) :: array_size
10587 integer(LONG) :: max_permutations
10590 type(
spatial) :: spatial_object_sampled
10594 type(
spatial),
dimension(size(spatial_objects)-1) :: spatial_all_other
10597 type(
spatial) :: spatial_object_nearest_neighbour
10599 if (
present(sample_size))
then
10602 n = sample_size_default
10606 array_size =
size(spatial_objects)
10612 max_permutations = ((array_size**2)-array_size)
10616 array_size_treat:
select case (array_size)
10623 call log_msg( ltag_warn // procname //
": too small array size " // &
10624 tostr(int(array_size)) //
", returned " // procname // &
10625 " value is ZERO." )
10626 mean_nndist = 0.0_srp
10632 case (2:max_array_dimensionality)
10634 call log_msg(ltag_info // procname //
": object array size is " // &
10635 "small enough for quick full object by object " // &
10636 "calculation; Random object sampling is NOT used." )
10639 mean_nndist = 0.0_srp
10645 base_obj:
do i = 1, array_size
10648 call spatial_object_sampled%position( spatial_objects(i)%location() )
10651 do j = 1, array_size
10654 call spatial_all_other(k)%position(spatial_objects(j)%location())
10660 spatial_object_nearest_neighbour = &
10661 spatial_object_sampled%nearest( spatial_all_other )
10666 mean_nndist = mean_nndist + spatial_object_sampled%distance( &
10667 spatial_object_nearest_neighbour )
10671 mean_nndist = mean_nndist / real(array_size, srp)
10687 if (n > max_permutations / 2)
then
10688 call log_msg( ltag_warn // procname // &
10689 ": requested sample size " // &
10690 tostr(n) //
" exceeds 1/2 maximum number of permutations " // &
10691 tostr(int(max_permutations)) //
", use 1/2 of the latter.")
10692 n = max_permutations / 2
10700 if (n < sample_size_warn) &
10701 call log_msg( ltag_warn // procname //
": requested sample size " // &
10702 tostr(n) //
" is quite small, average value may be imprecise.")
10706 mean_nndist = 0.0_srp
10709 permute:
do perm = 1, n
10716 i = rand_i(1,int(array_size))
10717 call spatial_object_sampled%position( spatial_objects(i)%location() )
10730 call spatial_all_other(k)%position(spatial_objects(j)%location())
10736 spatial_object_nearest_neighbour = &
10737 spatial_object_sampled%nearest( spatial_all_other )
10743 mean_nndist = mean_nndist + spatial_object_sampled%distance( &
10744 spatial_object_nearest_neighbour )
10748 mean_nndist = mean_nndist / real(n, srp)
10750 end select array_size_treat
10770 min_dist, point_segment )
10773 class(
spatial),
intent(in) :: point
10775 class(
spatial),
intent(in) :: sectp1
10777 class(
spatial),
intent(in) :: sectp2
10781 real(SRP),
intent(out) :: min_dist
10787 type(
spatial),
optional,
intent(out) :: point_segment
10790 real(SRP) :: refval, dist2_p1_p2
10800 dist2_p1_p2 =
dist2_vector( [sectp1%x, sectp1%y], [sectp2%x, sectp2%y] )
10807 if ( dist2_p1_p2 < zero )
then
10808 min_dist =
dist( [point%x, point%y], [sectp1%x, sectp1%y] )
10819 refval = dot_product( [point%x,point%y]-[sectp1%x, sectp1%y], &
10820 [sectp2%x,sectp2%y]-[sectp1%x, sectp1%y] )/dist2_p1_p2
10828 if ( refval < 0.0_srp )
then
10829 min_dist =
dist( [point%x, point%y], [sectp1%x, sectp1%y] )
10830 if (
present(point_segment))
then
10831 point_segment =
spatial( sectp1%x, sectp1%y, point%depth )
10838 else if ( refval > 1.0_srp )
then
10839 min_dist =
dist( [point%x, point%y], [sectp2%x, sectp2%y] )
10840 if (
present(point_segment))
then
10841 point_segment =
spatial( sectp2%x, sectp2%y, point%depth )
10855 abs( (sectp2%y-sectp1%y)*point%x - (sectp2%x-sectp1%x)*point%y + &
10856 sectp2%x*sectp1%y - sectp2%y*sectp1%x ) / sqrt( dist2_p1_p2 )
10857 if (
present(point_segment))
then
10858 point_segment =
spatial( sectp1%x + (sectp2%x-sectp1%x) * refval, &
10859 sectp1%y + (sectp2%y-sectp1%y) * refval, &
10873 min_dist, point_segment )
10876 class(
spatial),
intent(in) :: point
10878 class(
spatial),
intent(in) :: sectp1
10880 class(
spatial),
intent(in) :: sectp2
10884 real(SRP),
intent(out) :: min_dist
10888 type(
spatial),
optional,
intent(out) :: point_segment
10891 real(SRP) :: refval, dist2_p1_p2
10894 type(
spatial) :: point_segment_loc
10904 dist2_p1_p2 =
dist2_vector( [sectp1%x, sectp1%y, sectp1%depth], &
10905 [sectp2%x, sectp2%y, sectp2%depth] )
10912 if ( dist2_p1_p2 < zero )
then
10913 min_dist =
dist( [point%x, point%y, point%depth], &
10914 [sectp1%x, sectp1%y, sectp1%depth] )
10925 refval = dot_product( [point%x,point%y,point%depth]- &
10926 [sectp1%x,sectp1%y,sectp1%depth], &
10927 [sectp2%x,sectp2%y,sectp2%depth]- &
10928 [sectp1%x,sectp1%y,sectp1%depth] ) / &
10935 if ( refval < 0.0_srp )
then
10936 min_dist =
dist( [point%x, point%y, point%depth], &
10937 [sectp1%x, sectp1%y, sectp1%depth] )
10938 if (
present(point_segment))
then
10939 point_segment =
spatial( sectp1%x, sectp1%y, sectp1%depth )
10944 else if ( refval > 1.0_srp )
then
10945 min_dist =
dist( [point%x, point%y, point%depth], &
10946 [sectp2%x, sectp2%y, sectp2%depth] )
10947 if (
present(point_segment))
then
10948 point_segment =
spatial( sectp2%x, sectp2%y, sectp2%depth )
10965 point_segment_loc = &
10966 spatial( sectp1%x + (sectp2%x - sectp1%x) * refval, &
10967 sectp1%y + (sectp2%y - sectp1%y) * refval, &
10968 sectp1%depth + (sectp2%depth - sectp1%depth) * refval )
10969 min_dist =
dist( [point%x, point%y, point%depth], &
10970 [point_segment_loc%x, point_segment_loc%y, &
10971 point_segment_loc%depth] )
10972 if (
present(point_segment))
then
10973 point_segment = point_segment_loc
10991 class(
spatial),
intent(in) :: obj_a, obj_b
10993 real(srp),
intent(in) :: offset
11005 dist = obj_a%distance(obj_b)
11013 if (
dist - offset > zero)
then
11015 obj_a%x + (
dist - offset) * (obj_b%x - obj_a%x) /
dist
11017 obj_a%y + (
dist - offset) * (obj_b%y - obj_a%y) /
dist
11019 obj_a%depth + (
dist - offset) * (obj_b%depth - obj_a%depth) /
dist
11021 obj_c =
spatial( missing, missing, missing )
Simple history stack function, add to the end of the stack. We need only to add components on top (en...
Checks if a real number is near 0.0. Thus function can be used for comparing two real values like thi...
Logical function to check if a value is within a specific range, lower <= X <= upper.
Force a value within the range set by the vmin and vmax dummy parameter values.
Interface to the procedure to assemble the global array of habitat objects the_environment::global_ha...
Interface to the procedure to disassemble the global habitats objects array the_environment::global_h...
Internal distance calculation backend engine.
An alias for the the_environment::food_resources_collapse_global_object() method for joining food res...
Calculate underwater background irradiance at specific depth.
Calculate surface light intensity (that is subject to diel variation) for specific time step of the m...
An alias to the_environment::food_resources_update_back_global_object() method to transfer (having be...
Calculate visual range of predator using Dag Aksnes's procedures srgetr(), easyr() and deriv().
Calculate visual range of predator using Dag Aksnes's procedures srgetr(), easyr() and deriv().
subroutine adjust_risk_dilute_nofirst()
Adjust the predation risk of a group of N prey agents for predator dilution effect.
real(srp) function updated_position(coord_target, coord_object)
Calculate a Gaussian random updated coordinate for multidimensional Gaussian targeted random walk alo...
real(srp) function visibility_loc(depth)
This function calculates the visibility range of the spatial object at the depth given by the argumen...
subroutine adjust_risk_nonpar_fixed()
Adjust the predation risk for confusion and dilution effects.
recursive pure subroutine qsort(A)
qsort and qs_partition_ are the two parts of the recursive sort algorithm qsort is the recursive fron...
real(srp) function visibility_loc_diff(depth)
This is a wrapper function that calculates the visibility range minus target minimum distance....
subroutine adjust_risk_dilute_all()
Adjust the predation risk of a group of N prey agents for predator dilution effect.
subroutine adjust_risk_nonpar_noadjust()
Adjust the predation risk for confusion and dilution effects.
type(spatial) function centroid_urandom(fixed_depth)
Make a random centroid with fixed depth bound within this environment.
pure subroutine qs_partition_size(A, marker)
qsort and qs_partition_ are the two parts of the recursive sort algorithm qs_partition_size is a pivo...
COMMONDATA – definitions of global constants and procedures.
character(len= *), parameter, private modname
MODNAME always refers to the name of the current module for use by the LOGGER function LOG_DBG....
integer, public global_generation_number_current
The current global generation number. This is a global non fixed-parameter variable that is updated i...
character(len= *), parameter, public ltag_error
real(srp), parameter, public food_item_size_default_cv
Coefficient of variation for Gaussian food items.
integer, parameter, public history_size_spatial
The size of the history for spatial moving objects, i.e. how many time steps positions to remember in...
character(len= *), parameter, public model_name
Model name for tags, file names etc. Must be very short. See Model descriptors.
character(len= *), parameter, public ps
Standard file extension for debug and other PostScript plots.
real(srp) function zeroin(ax, bx, f, tol)
This function calculates a zero of a function f(x) in the interval (ax,bx).
real(srp), parameter, public daylight_cv
Coefficient of variation for stochastic DAYLIGHT,.
integer, parameter, public srp
Definition of the standard real type precision (SRP).
real(srp), parameter, public pi
The PI number.
elemental real(srp) function cv2variance(cv, mean)
Calculate the variance from the coefficient of variation.
integer, parameter, public unknown
Numerical code for invalid or missing integer counts.
integer, parameter, public generations
Maximum number of generations in GA.
subroutine call_external(command, suppress_output, suppress_error, is_background_task, cmd_is_success, exit_code)
Call an external program using a command line. Wrapper to two alternative system shell calling intrin...
real(srp), parameter, public daylight
Maximum above-surface light intensity at midday, DAYLIGHT=500.0.
real(srp), parameter, public predator_attack_rate_cv
Coefficient of variation for a single predator attack among the whole population of stochastic predat...
integer, parameter, public label_length
The length of standard character string labels. We use labels for various objects,...
real(srp), parameter, public eggmortality_def
Default level of egg mortality in the habitat.
logical, public, protected is_zip_outputs
This parameter enables or disables post-processing compression of the data: if TRUE,...
real(srp), parameter, public food_item_capture_probability_min
The minimum probability of capture a food item, when the item is at a distance equal to the visual ra...
real(srp), parameter, public missing
Numerical code for missing and invalid real type values.
logical, parameter, public daylight_stochastic
Flag for stochastic daylight pattern (if TRUE) or deterministic sinusoidal (when FALSE)....
integer, parameter, public hrp
Definition of the high real precision (HRP). This real type kind is used in pieces where a higher lev...
subroutine log_dbg(message_string, procname, modname)
LOG_DBG: debug message to the log. The message goes to the logger only when running in the DEBUG mode...
real(hrp), parameter, public tolerance_high_def_hrp
Default value of high tolerance (low precision). This is the high commondata::hrp precision real....
real(srp), parameter, public predator_body_size
The body size of the predator. In this version all predators have the same body size set by this para...
logical, parameter, public true
Safety parameter avoid errors in logical values, so we can now refer to standard Fortran ....
integer, parameter, public label_cen
character(len=:), allocatable, public, protected mmdd
MMDD tag, year, month and day, used in file names and outputs. The value of the tag should be obtaine...
real(srp), parameter, public predator_attack_rate_default
Mean rate of a single predator attack.
real(srp), parameter, public zero
Some parameters should never be zero or below. In such cases they could be set to some smallest disti...
integer, parameter, public dielcycles
Number of days and nights in a lifespan, DIELCYCLES=500.
logical, parameter, public zip_outputs_background
This parameter defines if the output files are compressed in the background in the parallel mode or t...
integer, parameter, public lifespan
Number of time steps in the agent's maximum life length.
real(srp), parameter, public preycontrast_default
Inherent contrast of prey, CONTRAST =1.0.
elemental real(srp) function carea(R)
Calculate a circle area.
character(len= *), parameter, public ltag_warn
subroutine debug_interpolate_plot_save(grid_xx, grid_yy, ipol_value, algstr, output_file, enable_non_debug)
Produce a debug plot of the interpolation data using an external program htinterp from the HEDTOOLS t...
real(srp), parameter, public food_item_size_default
Default size of a single food item.
real(srp), parameter, public food_item_mean_size
The above is also the average size of a stochastic Gaussian food items.
real(srp), parameter, public beamatt
Beam attenuation coefficient of water (m-1),BEAMATT = 1.0.
integer, parameter, public label_cst
This parameter defines the range of characters that is used for generating random labels,...
integer, public global_time_step_model_current
The current global time step of the model. This is a global non fixed-parameter variable that is upda...
character(len= *), parameter, private procname
PROCNAME is the procedure name for logging and debugging (with commondata::modname).
real(srp), parameter, public food_item_capture_probability
The baseline probability that the food item is captured. See the_neurobio::food_item_capture_probabil...
character(len= *), parameter, public csv
Standard data file extension for data output is now .csv.
real(srp), parameter, public preyarea_default
Area of prey (m2), PREYAREA = 3.E-6.
real(srp), parameter, public food_item_minimum_size
The minimum size of a food item. This is the "floor" in case the stochastically generated (e....
real(srp), parameter, public tolerance_high_def_srp
Default value of high tolerance (low precision). This is the standard commondata::srp precision real....
real(srp), parameter, public lightdecay
Vertical conservation of light, per depth (old code lightdecay=0.2).
character(len= *), parameter, public cmd_zip_output
This parameter defines the compression program that is executed to "zip" the data files if commondata...
real(srp), parameter, public other_risks_def
Default level of other mortality risks in the habitat.
logical, parameter, public false
Definition of high level file objects.
Definition of environmental objects.
subroutine global_habitats_assemble(habitat_1, habitat_2, habitat_3, habitat_4, habitat_5, habitat_6, habitat_7, habitat_8, habitat_9, habitat_10, habitat_11, habitat_12, habitat_13, habitat_14, habitat_15, habitat_16, habitat_17, habitat_18, habitat_19, habitat_20, reindex)
Assemble the global habitats objects array the_environment::global_habitats_available from a list of ...
subroutine food_resource_migrate_move_items(this, max_depth, time_step_model)
This subroutine implements the migration of all the food items in the resource according to the plank...
elemental real(srp) function visual_range_fast(irradiance, prey_area, prey_contrast)
Wrapper for calculating visual range of a fish predator using the Dag Aksnes's procedures srgetr(),...
subroutine spatial_moving_randomwalk_gaussian_step_3d(this, meanshift, cv_shift, environment_limits)
Implements an optionally environment-restricted Gaussian random walk in 3D.
elemental subroutine food_item_set_iid(this, iid)
Set unique id for the food item object.
subroutine habitat_save_predators_csv(this, csv_file_name, is_success)
Save the predators with their characteristics into a CSV file.
integer, parameter dim_environ_corners
The number of corners for an environment object in the 2D X*x*Y plane.
real(srp) function, private light_surface_stochastic_scalar(tstep, is_stochastic)
Calculate stochastic surface light at specific time step of the model. Light (surlig) is calculated f...
subroutine geo_poly3d_dist_point_to_section(point, sectp1, sectp2, min_dist, point_segment)
Calculates the minimum distance from a the_environment::spatial class object to a line segment delimi...
real(srp) function food_item_capture_probability_calc(this, distance, time_step_model)
Calculate the probability of capture of this food item by a predator agent depending on the distance ...
type(habitat), dimension(:), allocatable, public global_habitats_available
A list (array) of all the the_environment::habitat objects available to the agents....
type(spatial) function environment_centre_coordinates_3d(this, nodepth)
Determine the centroid of the environment.
elemental subroutine, private deriv(r, F1, FDER, c, C0, Ap, Vc, Ke, Eb)
Derivation of equation for visual range of a predator. See the_environment::srgetr() for more details...
elemental logical function food_item_is_eaten_unavailable(this)
Logical check-indicator function for the food item being eaten and not available.
real(srp) function, private visual_range_scalar(irradiance, prey_area, prey_contrast)
Wrapper for calculating visual range of a fish predator using the Dag Aksnes's procedures srgetr(),...
real(srp) function, private light_depth_integer(depth, surface_light, is_stochastic)
Calculate underwater light at specific depth given specific surface light.
elemental real(srp) function spatial_get_current_pos_d_3d(this)
Get the current DEPTH position of a SPATIAL object.
elemental real(srp) function spatial_moving_self_distance_3d(this, from_history)
Calculate the Euclidean distance between the current and previous position of a single spatial movabl...
pure real(srp) function dist2_vector(cvector1, cvector2)
Calculate the squared distance between two N-dimensional points.
type(spatial) function environment_random_uniform_spatial_3d(this)
Generate a random spatial object with the uniform distribution within (i.e. bound to) this environmen...
elemental real(srp) function size2mass_food(radius)
Calculate the mass of a food item, the non-OO backend.
subroutine environment_whole_build_vector(this, min_coord, max_coord)
Create the highest level container environment. Set the size of the 3D environment container as two c...
type(spatial) function, dimension(size(fixdep_array)) environment_random_uniform_spatial_vec_2d(this, fixdep_array)
Generate a vector of random spatial objects with the uniform distribution within (i....
type(spatial) function environment_random_uniform_spatial_2d(this, fixdepth)
Generate a random spatial object with the uniform distribution within (i.e. bound to) this environmen...
elemental integer function food_resource_get_abundance(this)
Get the number of food items in the food resource.
elemental type(spatial) function spatial_get_current_pos_3d_o(this)
Get the current spatial position of a SPATIAL object.
subroutine environment_get_nearest_point_in_outside_obj(this, outside_object, offset_into, point_spatial, point_dist)
Get the spatial point position within this environment that is nearest to an arbitrary spatial object...
pure type(spatial) function, dimension(:), allocatable spatial_stack2arrays(a, b)
Concatenate two arrays of the_environment::spatial objects a and b. This procedure uses array slices ...
real(srp) function, private light_depth_real(depth, surface_light, is_stochastic)
Calculate underwater light at specific depth given specific surface light.
subroutine food_resources_update_back_global_object(food_resource_collapsed, reindex)
Transfer the (having been modified) food resource objects from the single united object food_resource...
subroutine spatial_moving_randomwalk_gaussian_step_25d(this, meanshift_xy, cv_shift_xy, meanshift_depth, cv_shift_depth, environment_limits)
Implements an optionally environment-restricted Gaussian random walk in a "2.5 dimensions",...
type(spatial) function, dimension(num) environment_random_gaussian_spatial_2d(this, num, centroid, fixdepth, variance, variance_depth)
Generates a vector of random spatial object with Gaussian coordinates within (i.e....
elemental subroutine spatial_fix_position_3d_o(this, location)
Place spatial object into a 3D space, define the object's current coordinates.
elemental logical function spatial_check_located_within_3d(this, environment_limits)
Function to check if this spatial object is located within an area set by an environmental object (pa...
elemental real(srp) function mass2size_food(mass)
Calculate the size (radius) of a food item, a reverse function of the_environment::size2mass_food():
elemental real(srp) function environment_get_minimum_depth(this)
Get the minimum depth in this environment.
pure real(srp) function, dimension(dimensionality_default) spatial_get_current_pos_3d_v(this, vector)
Get the current spatial position of a SPATIAL object.
real(srp) function center_depth_sinusoidal(tstep, depth)
This function calculates the target depth for the sinusoidal vertical migration pattern of the food i...
elemental subroutine food_item_make(this, location, size, iid)
Make a single food item, i.e. place it into a specific position in the model environment space and se...
integer function spatial_get_nearest_id(this, neighbours, object)
Determine the nearest spatial object to this spatial object among an array of other spatial objects.
subroutine food_resource_replenish_food_items_all(this, replace)
Replenish and restore food resource. The food resource is replenished by substituting randomly select...
pure subroutine food_resource_make(this, label, abundance, locations, sizes)
Make food resource object. This class standard constructor.
elemental real(srp) function predator_get_body_size(this)
Accessor function for the predator body size (length).
elemental real(srp) function food_item_get_mass(this)
Calculate and get the mass of the food item.
subroutine spatial_neighbours_distances(this, neighbours, dist, index_vector, ranks, rank_max, error_flag)
Calculate the distances between this spatial object and an array of its neighbours....
real(srp) function, dimension(size(prey_area)), private visual_range_vector(irradiance, prey_area, prey_contrast_vect, prey_contrast)
Wrapper for calculating visual range of a fish predator using the Dag Aksnes's procedures srgetr(),...
subroutine predator_label_set(this, label)
Set label for the predator, if not provided, set it random.
subroutine food_resources_collapse(food_resource_collapsed, resource_1, resource_2, resource_3, resource_4, resource_5, resource_6, resource_7, resource_8, resource_9, resource_10, resource_11, resource_12, resource_13, resource_14, resource_15, resource_16, resource_17, resource_18, resource_19, resource_20, reindex, label)
Collapse several food resources into one. The collapsed resource can then go into the perception syst...
elemental subroutine, private srgetr(r, c, C0, Ap, Vc, Ke, Eb, IER)
Obtain visual range by solving the non-linear equation by means of Newton-Raphson iteration and deriv...
pure type(spatial) function, dimension(dim_environ_corners) environment_get_corners_2dxy(this, ref_depth, offset)
Get the corners of the environment in the 2D X Y plane. This is a very simplistic procedure that work...
elemental subroutine, private easyr(r, C0, Ap, Vc, Ke, Eb)
Obtain a first estimate of visual range by using a simplified expression of visual range....
elemental real(srp) function spatial_get_current_pos_y_3d(this)
Get the current Y position of a SPATIAL object.
pure real(srp) function dist_vector_nd(cvector1, cvector2)
Calculate distance between N-dimensional points. This is a function engine for use within other type ...
real(srp) function minimum_depth_visibility(target_range, depth_range_min, depth_range_max, object_area, object_contrast, time_step_model)
Find the depth at which the visibility of a spatial object becomes smaller than a specific distance v...
elemental real(srp) function dist_scalar(x1, x2, y1, y2, z1, z2)
Calculate distance between 3D or 2D points. This is a function engine for use within type bound proce...
elemental subroutine spatial_moving_clean_hstory_3d(this)
Create a new empty history of positions for spatial moving object. Assign all values to the MISSING v...
real(srp) function predator_capture_risk_calculate_fish(this, prey_spatial, prey_length, prey_distance, is_freezing, time_step_model, debug_plot_file)
Calculates the risk of capture of the fish with the spatial location defined by prey_spatial and the ...
type(spatial) function offset_dist(obj_a, obj_b, offset)
Calculate a the_environment::spatial target with an offset.
subroutine predator_capture_risk_calculate_fish_group(this, prey_spatial, prey_length, is_freezing, time_step_model, risk, risk_indexed, index_dist)
Calculates the risk of capture by a specific predator of an array of the fish agents with the spatial...
subroutine geo_poly2d_dist_point_to_section(point, sectp1, sectp2, min_dist, point_segment)
Calculates the minimum distance from a the_environment::spatial class object to a line segment delimi...
pure type(spatial) function, dimension(:), allocatable spatial_class_stack2arrays_locs(a, b)
Concatenate the location components of two arrays of the_environment::spatial class objects a and b....
elemental real(srp) function, private light_surface_deterministic(tstep)
Calculate deterministic surface light at specific time step of the model. Light (surlig) is calculate...
character(len=label_length) function habitat_name_get(this)
Return the name of the habitat.
subroutine global_habitats_disassemble(habitat_1, habitat_2, habitat_3, habitat_4, habitat_5, habitat_6, habitat_7, habitat_8, habitat_9, habitat_10, habitat_11, habitat_12, habitat_13, habitat_14, habitat_15, habitat_16, habitat_17, habitat_18, habitat_19, habitat_20, reindex)
Disassemble the global habitats objects array the_environment::global_habitats_available into separat...
type(spatial) function spatial_get_nearest_object(this, neighbours, number)
Determine the nearest spatial object to this spatial object among an array of other spatial objects.
elemental integer function food_item_get_iid(this)
Get the unique id of the food item object.
subroutine spatial_moving_corwalk_gaussian_step_25d(this, target, meanshift_xy, cv_shift_xy, meanshift_depth, cv_shift_depth, is_away, ci_lim, environment_limits, is_converged, debug_reps)
Implements an optionally environment-restricted correlated directional Gaussian random walk in 3D tow...
real(srp) function predator_visibility_visual_range(this, object_area, contrast, time_step_model)
Calculate the visibility range of this predator. Wrapper to the the_environment::visual_range() funct...
type(spatial) function environment_get_minimum_obj(this)
Function to get the minimum spatial limits (coordinates) of the environment.
subroutine migrate_food_vertical(habitats, time_step_model)
Migrate food items in a whole array of food resources. The array is normally the the_environment::glo...
type(spatial) function, dimension(num) environment_random_gaussian_spatial_3d(this, num, centroid, variance)
Generates a vector of random spatial object with Gaussian coordinates within (i.e....
elemental subroutine food_resource_sort_by_size(this, reindex)
Sort the food resource objects within the array by their sizes. The two subroutines below are a varia...
elemental real(srp) function spatial_self_distance_3d(this, from_history)
Calculate the Euclidean distance between the current and previous position of a single spatial object...
real(srp) function food_resource_calc_average_distance_items(this, n_sample)
Calculate the average distance between food items within a resource. e.g. to compare it with the agen...
subroutine reindex_food_resources(resource_1, resource_2, resource_3, resource_4, resource_5, resource_6, resource_7, resource_8, resource_9, resource_10, resource_11, resource_12, resource_13, resource_14, resource_15, resource_16, resource_17, resource_18, resource_19, resource_20)
Reset and reindex iids for an input list of several food resources. As the result of this subroutine ...
subroutine environment_build_unlimited(this)
Build an unlimited environment, with the spatial coordinates limited by the maximum machine supported...
pure real(srp) function vect_magnitude(vector)
Calculate the magnitude of an arbitrary N-dimensional vector. This is a raw vector backend.
type(environment) function environment_shrink_xy_fixed(this, shrink_value)
Return an environment object that is shrunk by a fixed value in the 2D XxY plane.
elemental logical function food_item_is_available(this)
Logical check-indicator function for the food item being available.
type(spatial) function environment_get_maximum_obj(this)
Function to get the maximum spatial limits (coordinates) of the environment.
pure integer function spatial_get_environment_in_pos(this, environments_array)
Identify in which environment from the input list this spatial agent is currently in....
elemental subroutine spatial_moving_repeat_position_history_3d(this)
Repeat (re-save) the current position into the positional history stack.
elemental subroutine spatial_moving_go_up(this, step)
The spatial moving object ascends, goes up the depth with specific fixed step size.
real(srp) function spatial_calc_irradiance_at_depth(this, time_step_model)
Calculate the illumination (background irradiance) at the depth of the spatial object at an arbitrary...
subroutine spatial_moving_corwalk_gaussian_step_3d(this, target, meanshift, cv_shift, is_away, ci_lim, environment_limits, is_converged, debug_reps)
Implements an optionally environment-restricted correlated directional Gaussian random walk in 3D tow...
integer, parameter, private dimensionality_default
Default dimensionality of the environment universe.
elemental real(srp) function food_item_get_size(this)
Get the size component of the food item object.
elemental subroutine food_item_clone_assign(this, the_other)
Clone the properties of this food item to another food item.
subroutine rwalk3d_array(this, dist_array, cv_array, dist_all, cv_all, environment_limits, n_walks)
Perform one or several steps of random walk by an array of the_environment::spatial_moving class obje...
elemental subroutine spatial_make_missing(this)
Assign all commondata::missing` coordinates to the_environment::spatial object.
elemental real(srp) function dist3d(this, other)
This is a non-type-bound version of the distance calculation function.
real(srp) function spatial_visibility_visual_range_cm(this, object_area, contrast, time_step_model)
Calculate the visibility range of a spatial object. Wrapper to the the_environment::visual_range() fu...
pure subroutine food_resource_reset_iid_all(this, start_iid)
Reset individual iid for the food resource. Individual iids must normally coincide with the array ord...
subroutine spatial_moving_fix_position_3d_v(this, x, y, depth)
Place spatial movable object into a 3D space, define the object's current coordinates,...
real(srp) function distance_average(spatial_objects, sample_size)
Calculates the average nearest neighbour distance amongst an array of spatial objects (class) by samp...
elemental real(srp) function spatial_get_current_pos_x_3d(this)
Get the current X position of a SPATIAL object.
type(food_resource) function food_resources_collapse_global_object(reindex, label)
Join food resources into a single global food resource out of the global array the_environment::globa...
real(srp) function habitat_get_risk_mortality_egg(this)
Get the egg mortality risk associated with this habitat.
subroutine spatial_fix_position_3d_s(this, x, y, depth)
Place spatial object into a 3D space, define the object's current coordinates.
elemental subroutine predator_make_init(this, body_size, attack_rate, position, label)
Initialise a predator object.
pure type(spatial) function, dimension(size(this%food)) food_resource_locate_3d(this)
Get the location object array (array of SPATIAL objects) of a food resource object.
elemental logical function environment_check_located_within_3d(this, check_object)
Check if a spatial object is actually within this environment.
subroutine food_resources_update_back(food_resource_collapsed, resource_1, resource_2, resource_3, resource_4, resource_5, resource_6, resource_7, resource_8, resource_9, resource_10, resource_11, resource_12, resource_13, resource_14, resource_15, resource_16, resource_17, resource_18, resource_19, resource_20, reindex)
Transfer back the resulting food resources into their original objects out from a collapsed object fr...
elemental real(srp) function environment_get_maximum_depth(this)
Get the maximum depth in this environment.
elemental subroutine spatial_create_empty(this)
These are public access functions, but probably we don't need to allow public access to functions ins...
elemental subroutine spatial_moving_create_3d(this)
Create a new spatial moving object. Initially it has no position, all coordinate values are MISSING o...
real(srp) function food_item_visibility_visual_range(this, object_area, contrast, time_step_model)
Calculate the visibility range of this food item. Wrapper to the the_environment::visual_range() func...
pure subroutine food_resource_destroy_deallocate(this)
Delete and deallocate food resource object. This class standard destructor.
elemental subroutine food_item_create(this)
Create a single food item at an undefined position with default size.
subroutine save_dynamics(maxdepth, csv_file_name, is_success)
Save diagnostics data that shows the dynamics of the light and the average depth of the food items,...
elemental character(len=label_length) function food_resource_get_label(this)
Get the label of the this food resource.
type(spatial) function, dimension(num) environment_random_uniform_spatial_vec_3d(this, num)
Generate a vector of random spatial objects with the uniform distribution within (i....
subroutine spatial_moving_dirwalk_gaussian_step_25d(this, target, meanshift_xy, cv_shift_xy, meanshift_depth, cv_shift_depth, environment_limits)
Implements an optionally environment-restricted directional Gaussian random walk in "2....
real(srp) function, dimension(size(tstep)), private light_surface_stochastic_vector(tstep, is_stochastic)
Calculate stochastic surface light at specific time step of the model.
subroutine habitat_make_init(this, coord_min, coord_max, label, otherrisks, eggmortality, predators_number, loc_predators, food_abundance, loc_food, sizes_food)
Make an instance of the habitat object (an environment superset).
elemental logical function spatial_check_located_below(this, check_object)
Logical function to check if the argument spatial object(s) (check_object) is (are) located below the...
pure type(spatial_moving) function, dimension(:), allocatable spatial_moving_stack2arrays(a, b)
Concatenate two arrays of the_environment::spatial_moving objects a and b. This procedure uses array ...
elemental real(srp) function spatial_distance_3d(this, other)
Calculate the Euclidean distance between two spatial objects. This is a type-bound function.
logical function food_item_capture_success_stochast(this, prob)
Stochastic outcome of this food item capture by an agent. Returns TRUE if the food item is captured.
subroutine rwalk_food_step(habitats)
Perform a random walk of food items in a whole array of food resources. The array is normally the the...
subroutine rwalk25d_array(this, dist_array_xy, cv_array_xy, dist_array_depth, cv_array_depth, dist_all_xy, cv_all_xy, dist_all_depth, cv_all_depth, environment_limits, n_walks)
Perform one or several steps of random walk by an array of the_environment::spatial_moving class obje...
elemental subroutine food_item_disappear(this)
Make the food item "disappear" and take the "eaten" state, i.e. impossible for consumption by the age...
subroutine food_resource_save_foods_csv(this, csv_file_name, is_success)
Save characteristics of food items in the resource into a CSV file.
elemental real(srp) function dist2step(average_distance, dimensionality)
Calculate the unit step along a single coordinate axis given the average distance between any two poi...
elemental logical function spatial_check_located_above(this, check_object)
Logical function to check if the argument spatial object(s) (check_object) is (are) located above the...
character(len= *), parameter, private modname
elemental subroutine spatial_moving_go_down(this, step)
The spatial moving object decends, goes down the depth with specific fixed step size.
real(srp) function habitat_get_risk_mortality(this)
Get the mortality risk associated with this habitat.
elemental real(srp) function predator_get_attack_rate(this)
Accessor function for the predator attack rate.
subroutine spatial_moving_dirwalk_gaussian_step_3d(this, target, meanshift, cv_shift, environment_limits)
Implements an optionally environment-restricted directional Gaussian random walk in 3D towards a targ...
elemental subroutine spatial_moving_fix_position_3d_o(this, location)
Place spatial movable object into a 3D space, define the object's current coordinates,...
subroutine food_resource_rwalk_items_default(this)
Perform a random walk step for all food items within the food resource. The walk is performed with th...
subroutine environment_whole_build_object(this, min_coord, max_coord)
Create the highest level container environment. Set the size of the 3D environment container as two c...
FILE_HANDLE is the basic file handle object. It provides an unitary object oriented interface for ope...
Definition of the overall environment. Environment is a general container for all habitats,...
Definition of a single food item. Food item is a spatial object that has specific location in space....
Definition of the super-type FOOD resource type. This is a superclass, several sub-classes can be def...
Definition of the environment habitat HABITAT object. There can potentially be of several types of ha...
Definition of the PREDATOR objects. Predator is a moving agent that hunts on the evolving AHA agents ...
Definition of a movable spatial object. It extends the the_environment::spatial object,...
Definition of a spatial object. Spatial object determines the position of the agent,...