-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathm_env.f90
11021 lines (9854 loc) · 536 KB
/
m_env.f90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
!> @file m_env.f90
!! The environmental objects of the AHA Model.
!! @author Sergey Budaev <[email protected]>
!! @author Jarl Giske <[email protected]>
!! @date 2016-2017
!-------------------------------------------------------------------------------
! $Id$
!-------------------------------------------------------------------------------
!-------------------------------------------------------------------------------
!> @brief Definition of environmental objects.
!> @section the_environment_module THE_ENVIRONMENT module
!> This module defines various environment objects and primitives, starting
!! from the basic primitive a spatial object the_environment::spatial. This
!! object represents a point in a three-dimensional space. The agent class
!! hierarchy starts from this spatial primitive as the agent is a spatial
!! object.
module THE_ENVIRONMENT
use COMMONDATA
implicit none
character (len=*), parameter, private :: MODNAME = "(THE_ENVIRONMENT)"
!> Default dimensionality of the environment universe.
integer, parameter, private :: DIMENSIONALITY_DEFAULT = 3
!> The number of corners for an environment object in the 2D *X*x*Y* plane
!! @warning Valid only in the simplistic box-like implementation of
!! environment objects and should be reimplemented if the
!! environment is set as an arbitrary polyhedron.
integer, parameter :: DIM_ENVIRON_CORNERS = 4
!> Definition of a spatial object. Spatial object determines the position of
!! the agent, food items and other things in the simulated space. Here we
!! use continuous 3D environment (real type coordinates)
!! @note IMPORTANT: We will use **position** method to **set** location of
!! a spatial object and **location** method to **get** its location.
!! @note We use `position_v` method to **set** define spatial position using
!! raw 3D coordinates, x, y, z -- it lacks extensibility -- for
!! convenience only.
!! @warning Note that we **do not** set **ID** at the elementary `SPATIAL`
!! objects. This is done to make type constructor `SPATIAL(x, y, z)`
!! (that is used frequently in different places) shorter and easier
!! to use. We do not need to include an ID then. IDs are set at
!! higher levels in the object hierarchy, e.g. `FOOD_ITEM` has
!! `food_iid` integer data component.
type, public :: SPATIAL
!> We define three-dimensional environment: x, y and depth.
real(SRP) :: x, y, depth
contains
!> Create an empty spatial object.
!! @note `position` is the standard method for placing spatial object,
!! returns object type. `position_v` is non-extensible method
!! that returns raw 3D coordinates, for convenience only.
!! `position` and `position_v` are overriden in moving
!! objects below. Not sure if we really need `position_v`.
!! See `the_environment::spatial_create_empty()`
procedure, public :: create => spatial_create_empty
!> Place spatial object into a 3D space, define the object's current
!! coordinates. Object-based procedure.
!! See `the_environment::spatial_fix_position_3d_o()`
procedure, public :: position => spatial_fix_position_3d_o
!> Place spatial object into a 3D space, define the object's current
!! coordinates. Vector-based procedure.
!! See `the_environment::spatial_fix_position_3d_s()`
procedure, public :: position_v => spatial_fix_position_3d_s
!> Assign all `MISSING` coordinates to the `SPATIAL` object.
!! See `the_environment::spatial_make_missing()`
procedure, public :: missing => spatial_make_missing
!> Calculate the Euclidean distance between two spatial objects.
!! See `the_environment::spatial_distance_3d()`
procedure, public :: distance => spatial_distance_3d
!> Calculates the minimum distance from a the_environment::spatial class
!! object to a line segment delimited by two the_environment::spatial
!! endpoints in the 2D *XY* plane (the depth coordinate is ignored).
!! See `the_environment::geo_poly2d_dist_point_to_section()`.
procedure, public :: distance_segment2d => &
geo_poly2d_dist_point_to_section
!> Calculates the minimum distance from a the_environment::spatial class
!! object to a line segment delimited by two the_environment::spatial
!! class endpoints in the 3D *XY* space.
!! See `the_environment::geo_poly3d_dist_point_to_section()`.
procedure, public :: distance_segment => &
geo_poly3d_dist_point_to_section
!> Calculate the Euclidean distance between the current and previous
!! position of a single spatial object.
!! See `the_environment::spatial_self_distance_3d()`
procedure, public :: way => spatial_self_distance_3d
!> Function to check if this spatial object is located within an area
!! set by an environmental object
!! See `the_environment::spatial_check_located_within_3d()`
procedure, public :: is_within => spatial_check_located_within_3d
!> Identify in which environment from the input list this spatial
!! agent is currently in.
!! See `the_environment::spatial_get_environment_in_pos()`.
procedure, public :: find_environment => spatial_get_environment_in_pos
!> Logical function to check if the argument spatial object(s) is(are)
!! located **below** this spatial object.
!! See `the_environment::spatial_check_located_below()`
procedure, public :: is_below => spatial_check_located_below
!> Logical function to check if the argument spatial object(s) is(are)
!! located **above** this spatial object.
!! See `the_environment::spatial_check_located_above()`
procedure, public :: is_above => spatial_check_located_above
!> Determine the nearest spatial object to **this** spatial object among
!! an array of other spatial objects.
!! See `the_environment::spatial_get_nearest_object()`
procedure, public :: nearest => spatial_get_nearest_object
!> Determine the nearest spatial object to **this** spatial object among
!! an array of other spatial objects.
!! See `the_environment::spatial_get_nearest_id()`
procedure, public :: nearest_num => spatial_get_nearest_id
!> Calculate the distances between **this** spatial object and an array of
!! its neighbours. Optionally output the distances, sorting index vector
!! and rankings vector for each of these neighbours. Optionally do only
!! partial indexing, up to the order `rank_max` for computational speed.
!! See `the_environment::spatial_neighbours_distances()`
procedure, public :: neighbours => spatial_neighbours_distances
!> Get the current spatial position of a `SPATIAL` object. Object-based.
!! See `the_environment::spatial_get_current_pos_3d_o()`
procedure, public :: now_o => spatial_get_current_pos_3d_o
!> Get the current spatial position of a `SPATIAL` object. Vector-based.
!! See `the_environment::spatial_get_current_pos_3d_v()`
procedure, public :: now_v => spatial_get_current_pos_3d_v
!> Get the current spatial position of a `SPATIAL` object.
!! Generic interface/alias.
generic, public :: location => now_o, now_v
!> Get the current spatial position of a `SPATIAL` object.
!! Generic interface/alias.
generic, public :: now => now_o, now_v
!> Get the current `X` position of a `SPATIAL` object.
!! See `the_environment::spatial_get_current_pos_x_3d()`
procedure, public :: xpos => spatial_get_current_pos_x_3d
!> Get the current `Y` position of a `SPATIAL` object.
!! See `the_environment::spatial_get_current_pos_y_3d()`
procedure, public :: ypos => spatial_get_current_pos_y_3d
!> Get the current `Z` (depth) position of a `SPATIAL` object.
!! See `the_environment::spatial_get_current_pos_d_3d()`
procedure, public :: dpos => spatial_get_current_pos_d_3d
!> Calculate the illumination (background irradiance) at the depth of the
!! spatial object at an arbitrary time step of the model.
!! See `the_environment::spatial_calc_irradiance_at_depth()`
procedure, public :: illumination => spatial_calc_irradiance_at_depth
!> Calculate the visibility range of a spatial object. Wrapper to the
!! `visual_range` function. This function calculates the distance from
!! which this object can be seen by a visual object (e.g. predator or
!! prey).
!! See `the_environment::spatial_visibility_visual_range_cm()`.
!! @warning The function interface for the basic spatial type
!! the_environment::spatial is called `visibility_basic`
!! to distinguish it from similar `visibility` methods
!! defined for several extension classes, such as
!! the_environment::predator, the_environment::food_item and
!! the_body::condition because this function is unrelated to
!! them, otherwise it must have the same parameters as in
!! the class extensions.
procedure, public :: visibility => spatial_visibility_visual_range_cm
end type SPATIAL
!> Definition of a movable spatial object. It extends the
!! the_environment::spatial object, but also adds its previous position
!! history in stack-like arrays. The history is maintained with the
!! commondata::add_to_history() subroutine, adding a single
!! element on the top (end) of the history stack.
type, public, extends(SPATIAL) :: SPATIAL_MOVING
!> We define prior historical values of the `SPATIAL` positions.
!! @note Historical stack has the same the_environment::spatial type but
!! is an array of prior values (i.e. array of
!! the_environment::spatial objects). The
!! the_environment::spatial_moving::position() method overrides
!! the standard function defined for the_environment::spatial
!! (the_environment::spatial::position()), it not only sets the
!! current position, but also moves the previous position of the
!! object into the history stack.
type(SPATIAL), dimension(HISTORY_SIZE_SPATIAL) :: history
contains
!> Create a new spatial moving object. Initially it has no position, all
!! coordinate values are commondata::missing or commondata::invalid for
!! real type coordinates.
!! See `the_environment::spatial_moving_create_3d()`
procedure, public :: create => spatial_moving_create_3d
!> Place spatial movable object into a 3D space, define the object's current
!! coordinates, but first save previous coordinates. Object-based.
!! See `the_environment::spatial_moving_fix_position_3d_o()`
procedure, public :: position => spatial_moving_fix_position_3d_o
!> Repeat/re-save the current position into the positional history stack.
!! See `the_environment::spatial_moving_repeat_position_history_3d()`.
procedure, public :: repeat_position => &
spatial_moving_repeat_position_history_3d
!> Place spatial movable object into a 3D space, define the object's current
!! coordinates, but first save previous coordinates. Vector-based.
!! See `the_environment::spatial_moving_fix_position_3d_v()`
procedure, public :: position_v => spatial_moving_fix_position_3d_v
!> Create a new empty history of positions for spatial moving object.
!! Assign all values to the commondata::missing value code.
!! See `the_environment::spatial_moving_clean_hstory_3d()`
procedure, public :: spatial_history_clean => spatial_moving_clean_hstory_3d
!> Calculate the Euclidean distance between the current and previous
!! position of a single spatial movable object. Optionally, it also
!! calculates the total distance traversed during the `from_history` points
!! from the history stack along with the distance from the current position
!! and the last historical value.
!! See `the_environment::spatial_moving_self_distance_3d()`.
procedure, public :: way => spatial_moving_self_distance_3d
!> The spatial moving object **ascends**, goes up the depth with specific
!! fixed step size. See `the_environment::spatial_moving_go_up()`.
procedure, public :: go_up => spatial_moving_go_up
!> The spatial moving object **decends**, goes down the depth with
!! specific fixed step size.
!! See `the_environment::spatial_moving_go_down()`.
procedure, public :: go_down => spatial_moving_go_down
!> Implements an optionally environment-restricted Gaussian random
!! walk in 3D.
!! See `the_environment::spatial_moving_randomwalk_gaussian_step_3d()`.
procedure, public :: rwalk3d => spatial_moving_randomwalk_gaussian_step_3d
!> Implements an optionally environment-restricted Gaussian random
!! walk in a "2.5 dimensions", i.e. 2D x y with separate walk
!! parameters for the third depth dimension.
!! See `the_environment::spatial_moving_randomwalk_gaussian_step_25d()`.
procedure, public :: rwalk25d=>spatial_moving_randomwalk_gaussian_step_25d
!> Implements an optionally environment-restricted Gaussian random
!! walk. Generic interface for 3D and 3.5D moves.
!! See `the_environment::spatial_moving_randomwalk_gaussian_step_3d()`
!! and `the_environment::spatial_moving_randomwalk_gaussian_step_25d()`.
generic, public :: rwalk => rwalk3d, rwalk25d
!> Implements an optionally environment-restricted **correlated
!! directional** Gaussian random walk in 3D towards (or away of)
!! an the_environment::spatial class `target` object.
!! See `the_environment::spatial_moving_corwalk_gaussian_step_3d()`.
procedure, public :: corwalk3d => spatial_moving_corwalk_gaussian_step_3d
!> Implements an optionally environment-restricted **correlated
!! directional** Gaussian random walk in 3D towards (or away of)
!! an the_environment::spatial class `target` object.
!! See `the_environment::spatial_moving_corwalk_gaussian_step_25d()`.
procedure, public :: corwalk25d =>spatial_moving_corwalk_gaussian_step_25d
!> Implements an optionally environment-restricted **correlated
!! directional** Gaussian random walk. `corwalk` is a generic
!! interface for 3D and "2.5"D moves. For details see the 3d version
!! and a version with separate *X,Y* and *depth* random parameters.
!! - `the_environment::spatial_moving_corwalk_gaussian_step_3d()`;
!! - `the_environment::spatial_moving_corwalk_gaussian_step_25d()`;
!! .
generic, public :: corwalk => corwalk3d, corwalk25d
!> Implements an optionally environment-restricted **directional**
!! Gaussian random walk in 3D towards a `target` the_environment::spatial
!! object.
!! See `the_environment::spatial_moving_dirwalk_gaussian_step_3d()`
!! @warning obsolete, will be removed!
procedure, public :: dirwalk3d => spatial_moving_dirwalk_gaussian_step_3d
!> Implements an optionally environment-restricted **directional**
!! Gaussian random walk in "2.5"D towards a `target` object. i.e.
!! 2D x y with separate walk parameters for the third depth
!! dimension.
!! See `the_environment::spatial_moving_dirwalk_gaussian_step_25d()`
!! @warning obsolete, will be removed!
procedure, public :: dirwalk25d=>spatial_moving_dirwalk_gaussian_step_25d
!> Implements an optionally environment-restricted **directional**
!! Gaussian random walk. Generic interface for 3D and "2.5"D moves.
!! @warning obsolete, will be removed!
generic, public :: dirwalk => dirwalk3d, dirwalk25d
end type SPATIAL_MOVING
!> Definition of the overall **environment**. Environment is a general
!! container for all habitats, patches and other similar objects where the
!! whole life of the agents takes place. Environment just provides
!! the *limits* for all these objects.
!! @warning In this version, the environment objects are the most simplistic
!! form: 3D "boxes". An arbitrary convex *polyhedron*-based environment
!! can be implemented but this requires a more complex computational
!! geometry backend.
!! @note Coordinate system should **always** use the `SPATIAL` type objects,
!! we don't define `_v`-type procedures (it is also unclear are `_v`
!! procedures really necessary).
type, public :: ENVIRONMENT
!> Set shape and limits of the whole environment, by default a
!! rectangle with Cartesian coordinates based on ENVIRONMENT_WHOLE_SIZE.
!! The minimum and maximum coordinates are set through the `SPATIAL`
!! object.
type(SPATIAL) :: coord_min, coord_max
contains
!> Create the highest level container environment. Vector-based.
!! See `the_environment::environment_whole_build_vector()`
procedure, public :: build_vector => environment_whole_build_vector
!> Create the highest level container environment. Object-based.
!! See `the_environment::environment_whole_build_object()`
procedure, public :: build_object => environment_whole_build_object
!> Build an **unlimited environment**, with the spatial coordinates limited
!! by the maximum machine supported values based on the intrinsic `huge`
!! function.
!! See `the_environment::environment_build_unlimited()`
procedure, public :: build_unlimited => environment_build_unlimited
!> Create the highest level container environment. Generic interface.
!! See `the_environment::environment_whole_build_vector()`,
!! `the_environment::environment_whole_build_object()` and
!! `the_environment::environment_build_unlimited()`
generic, public :: build => build_vector, build_object, build_unlimited
!> Return an environment object that is shrunk by a fixed value in the 2D
!! XxY plane.
!! See `the_environment::environment_shrink_xy_fixed()`.
procedure, public :: shrink2d => environment_shrink_xy_fixed
!> Function to get the **minimum** spatial limits (coordinates) of
!! the environment.
!! See `the_environment::environment_get_minimum_obj()`
procedure, public :: lim_min => environment_get_minimum_obj
!> Function to get the **maximum** spatial limits (coordinates) of
!! the environment.
!! See `the_environment::environment_get_maximum_obj()`
procedure, public :: lim_max => environment_get_maximum_obj
!> Get the **minimum depth** in this environment.
!! See `the_environment::environment_get_minimum_depth()`.
procedure, public :: depth_min => environment_get_minimum_depth
!> Get the **maximum depth** in this environment.
!! See `the_environment::environment_get_maximum_depth()`.
procedure, public :: depth_max => environment_get_maximum_depth
!> Check if a spatial object is actually within this environment.
!! See `the_environment::environment_check_located_within_3d()`
procedure, public :: is_within => environment_check_located_within_3d
!> Get the corners of the environment in the 2D X Y plane.
!! See `the_environment::environment_get_corners_2dxy()`.
procedure, public :: corners2d => environment_get_corners_2dxy
!> Get the spatial point position within this environment that is
!! nearest to an arbitrary spatial object located outside of the this
!! environment. If the spatial object is actually located in this
!! environment,return its own spatial position.
!! See `the_environment::environment_get_nearest_point_in_outside_obj()`.
procedure, public :: nearest_target => &
environment_get_nearest_point_in_outside_obj
!> Determine the centroid of the environment.
!! See `the_environment::environment_centre_coordinates_3d()`
procedure, public :: centre => environment_centre_coordinates_3d
!> Generate a random spatial object with the uniform distribution within
!! (i.e. bound to) **this** environment.
!! See `the_environment::environment_random_uniform_spatial_3d()`
procedure, public :: uniform_s => environment_random_uniform_spatial_3d
!> Generate a random spatial object with the uniform distribution within
!! (i.e. bound to) **this** environment, the third depth coordinate is
!! fixed.
!! See `the_environment::environment_random_uniform_spatial_2d()`
procedure, public :: uniform2_s => environment_random_uniform_spatial_2d
!> Generate a vector of random spatial objects with the uniform distribution
!! within (i.e. bound to) **this** environment. Full 3D procedure.
!! See `the_environment::environment_random_uniform_spatial_vec_3d()`
procedure, public :: uniform_v =>environment_random_uniform_spatial_vec_3d
!> Generate a vector of random spatial objects with the uniform distribution
!! within (i.e. bound to) **this** environment. The third, depth coordinate
!! is non-stochastic, and provided as an array parameter.
!! See `the_environment::environment_random_uniform_spatial_vec_2d()`
procedure, public :: uniform2_v=>environment_random_uniform_spatial_vec_2d
!> Generate a vector of random spatial objects with the uniform
!! distribution within (i.e. bound to) **this** environment. Generic
!! interface.
generic, public :: uniform => uniform_s,uniform2_s,uniform_v,uniform2_v
!> Generates a vector of random spatial object with Gaussian coordinates
!! within (i.e. bound to) **this** environment. Full 3D procedure.
!! See `the_environment::environment_random_gaussian_spatial_3d()`
procedure, public :: gaussian3d => environment_random_gaussian_spatial_3d
!> Generates a vector of random spatial object with Gaussian coordinates
!! within (i.e. bound to) **this** environment. The depth coordinate is
!! set separately and can be non-random (fixed for the whole output array)
!! or Gaussian with separate variance.
!! See `the_environment::environment_random_gaussian_spatial_2d()`
procedure, public :: gaussian2d => environment_random_gaussian_spatial_2d
end type ENVIRONMENT
!> Definition of a single food item. Food item is a spatial object that has
!! specific location in space. It can be "created" and eaten ("disappear").
!! Food item is an immobile SPATIAL object that has a position in 3D space.
type, public, extends(SPATIAL_MOVING) :: FOOD_ITEM
!> Food item has a size (radius) that determines its visibility and
!! nutritional value for the predatory agent.
real(SRP) :: size
!> Food item can be present or absent (eaten by the agent, =.TRUE.).
logical :: eaten
!> Unique ID of this food item. Needed in the resource array.
integer :: food_iid
contains
!> Create a single food item at an undefined position with default size.
!! See `the_environment::food_item_create()`
procedure, public :: create => food_item_create
!> Make a single food item, i.e. place it into a specific position
!! in the model environment space and set the size.
!! See `the_environment::food_item_make()`
procedure, public :: make => food_item_make
!> Stochastic outcome of **this** food item capture by an agent.
!! Returns TRUE if the food item is captured.
!! See `the_environment::food_item_capture_success_stochast()`
procedure, public :: capture_success => food_item_capture_success_stochast
!> Calculate the probability of capture of **this** food item by a predator
!! agent depending on the distance between the agent and this food item.
!! See `the_environment::food_item_capture_probability_calc()`
procedure, public :: capture_probability => food_item_capture_probability_calc
!> Calculate the visibility range of this food item. Wrapper to the
!! `visual_range` function. This function calculates the distance from
!! which this food item can be seen by a predator (i.e. the default
!! predator's visual range).
!! See `the_environment::food_item_visibility_visual_range()`
procedure, public :: visibility => food_item_visibility_visual_range
!> Make the food item "disappear" and take the "eaten" state, i.e.
!! impossible for consumption by the agents.
!! See `the_environment::food_item_disappear()`
procedure, public :: disappear => food_item_disappear
!> Logical check-indicator function for the food item being eaten and not
!! available.
!! See `the_environment::food_item_is_eaten_unavailable()`
procedure, public :: is_unavailable => food_item_is_eaten_unavailable
!> Logical check-indicator function for the food item being available.
!! @returns Logical indicator TRUE if the food item is present
!! in the environment and therefore available.
!! See `the_environment::food_item_is_available()`
procedure, public :: is_available => food_item_is_available
!> Get the size component of the food item object.
!! See `the_environment::food_item_get_size()`
procedure, public :: get_size => food_item_get_size
!> Calculate and get the mass of the food item.
!! See `the_environment::food_item_get_mass()`
procedure, public :: get_mass => food_item_get_mass
!> Get the unique id of the food item object.
!! See `the_environment::food_item_get_iid()`
procedure, public :: get_iid => food_item_get_iid
!> Set unique id for the food item object.
!! See `the_environment::food_item_set_iid()`
procedure, public :: set_iid => food_item_set_iid
!> Clone the properties of this food item to another food item.
!! See `the_environment::food_item_clone_assign()`
procedure, public :: clone => food_item_clone_assign
end type FOOD_ITEM
!> Definition of the super-type FOOD resource type. This is a superclass,
!! several sub-classes can be defined for different kinds of food and prey
!! objects.
type, public :: FOOD_RESOURCE
!> Food resource type label
character (len=LABEL_LENGTH) :: food_label
!> Availability of this kind of food, number of food objects that are
!! provided into the environment.
integer :: number_food_items
!> Food resource consists of an array of `FOOD_ITEM`'s
type(FOOD_ITEM), allocatable, dimension(:) :: food
contains
!> Make food resource object. This class standard constructor.
!! See `the_environment::food_resource_make()`
procedure, public :: make => food_resource_make
!> Replenish and restore food resource: the food resource is restored to
!! its initial state as set by the_environment::food_resource::make() or
!! to a **smaller** abundance.
!! See `the_environment::food_resource_replenish_food_items_all()`
procedure, public :: replenish => food_resource_replenish_food_items_all
!> Delete and deallocate food resource object. This class destructor.
!! See `the_environment::food_resource_destroy_deallocate()`
procedure, public :: destroy => food_resource_destroy_deallocate
!> Sort the food resource objects within the array by their sizes.
!! The two subroutines below are a variant of the recursive quick-sort
!! algorithm adapted for sorting real components of the the `FOOD_RESOURCE`
!! object.
!! See `the_environment::food_resource_sort_by_size()`
procedure, public :: sort => food_resource_sort_by_size
!> Reset individual iid for the food resource. Individual iids must normally
!! coincide with the array order index. If it is changed after sorting,
!! iids no longer reflect the correct index. So this subroutine resets iids
!! to be coinciding with each food item index.
!! See `the_environment::food_resource_reset_iid_all()`
procedure, public :: reindex => food_resource_reset_iid_all
!> Get the label of the this food resource.
!! See `the_environment::food_resource_get_label()`.
procedure, public :: get_label => food_resource_get_label
!> Get the number of food items in the food resource.
!! See `the_environment::food_resource_get_abundance()`.
procedure, public :: abundance => food_resource_get_abundance
!> Get the location object array (array of the_environment::spatial
!! objects) of a food resource object.
!! See `the_environment::food_resource_locate_3d()`
procedure, public :: location => food_resource_locate_3d
!> Calculate the average distance between food items within a resource.
!! See `the_environment::food_resource_calc_average_distance_items()`
procedure, public :: distance_average => &
food_resource_calc_average_distance_items
!> Collapse several food resources into one. The collapsed resource can then
!! go into the perception system. The properties of the component resources
!! are retained in the collapsed resource.
!! See `the_environment::food_resources_collapse()`
procedure, public :: join => food_resources_collapse
!> Transfer back the resulting food resources into their original objects
!! out from a collapsed object from `food_resources_collapse`.
!! See `the_environment::food_resources_update_back()`
procedure, public :: unjoin => food_resources_update_back
!> Implement vertical migration of all the food items in the resource in
!! a sinusoidal pattern.
!! See `the_environment::food_resource_migrate_move_items()`.
procedure, public :: migrate_vertical => food_resource_migrate_move_items
!> Perform a random walk step for all food items within the food
!! resource with default parameters.
!! See `the_environment::food_resource_rwalk_items_default()`.
procedure, public :: rwalk => food_resource_rwalk_items_default
!> Save characteristics of food items in the resource into a CSV file.
!! See `the_environment::food_resource_save_foods_csv()`.
procedure, public :: save_csv => food_resource_save_foods_csv
end type FOOD_RESOURCE
!> Definition of the `PREDATOR` objects. **Predator** is a moving agent that
!! hunts on the evolving AHA agents but its internal structure is very
!! simplistic (although we can in principle doit as a full AHA complexity
!! with genome, GOS etc...).
type, public, extends(SPATIAL_MOVING) :: PREDATOR
!> The label of the predator.
character (len=LABEL_LENGTH) :: label
!> Individual body size of the predator, can be stochastic or not. Can
!! affect attack rate (e.g. larger predators more dangerous).
real(SRP) :: body_size
!> The attack rate of the predator, i.e. the baseline probability of
!! attacking catching the prey agent if the latter is found in proximity
!! (within the visual range).
real(SRP) :: attack_rate
contains
!> Initialise a predator object.
!! See `the_environment::predator_make_init()`
procedure, public :: make => predator_make_init
!> Set label for the predator, if not provided, set it random.
!! See `the_environment::predator_label_set()`
procedure, public :: label_set => predator_label_set
!> Accessor function for the predator body size (length).
!! See `the_environment::predator_get_body_size()`
procedure, public :: get_size => predator_get_body_size
!> Accessor function for the predator attack rate .
!! See `the_environment::predator_get_capture_efficiency()`
procedure, public :: get_attack_rate => predator_get_attack_rate
!> Calculates the risk of capture of the `prey_spatial` idealised spatial
!! object with the body length `prey_length`. This is a backend function.
!! See `the_environment::predator_capture_risk_calculate_fish()`.
procedure, public :: risk_fish => predator_capture_risk_calculate_fish
!> Calculates the risk of capture by a specific predator of an
!! array of the fish agents with the spatial locations array
!! defined by `prey_spatial` and the body length array
!! `prey_length`. This subroutine takes account of both the predator
!! dilution and confusion effects and risk adjusted by the distance
!! towards the predator.
!! See `the_environment::predator_capture_risk_calculate_fish_group() `.
procedure, public :: risk_fish_group => &
predator_capture_risk_calculate_fish_group
!> Calculate the visibility range of this predator. Wrapper to the
!! `visual_range` function. This function calculates the distance from
!! which this predator can be seen by a visual object (e.g. prey).
!! See `the_environment::predator_visibility_visual_range()`.
procedure, public :: visibility => predator_visibility_visual_range
end type PREDATOR
!> Definition of the **environment habitat** `HABITAT` object.
!! There can potentially be of several types of habitats (patches etc.), so
!! the superclass HABITAT defines the most general properties and procedures.
!! More specific procedures are defined in sub-objects. Such procedures can
!! be overriden from super-object to sub-objects providing for procedure
!! polymorphism.
type, public, extends(ENVIRONMENT) :: HABITAT
!> The name of the habitat
character (len=LABEL_LENGTH) :: habitat_name
!> Other agent mortality risks
real(SRP) :: risk_mortality
!> Egg mortality risk
real(SRP) :: risk_egg_mortality
!> Number of predators that dwell in the habitat.
!... Habitat-specific predation ............................................
integer :: predators_number
!> Habitat has an array of predators (i.e. `PREDATOR` objects).
!! @note The implementation of predators is very simplistic here, just
!! a single type of predators integrated into the `HABITAT` object,
!! without a separate predator container. This is, for example,
!! different from the food resources made as a FOOD_RESOURCE
!! container (below) that allows several types of food.
!! A more advanced version should implement a specific container
!! like `FOOD_RESOURCE` and, ultimately, a full implementation
!! of an AHA predator (with the genome, neurobiology etc.). Do we
!! need several types of predators or predation bound functions?
type(PREDATOR), allocatable, dimension(:) :: predators
!... Habitat-specific food resources .......................................
!> Habitat has a food resource (i.e. FOOD_RESOURCE` object) which is
!! an array of `FOOD_ITEM`s.
!! @note A container object `FOOD_RESOURCE`is used for the food resource
!! rather than just raw number of food items and array of food items
!! (as done with predation) to allow implementation of several
!! different food resources more easily.
type(FOOD_RESOURCE) :: food
contains
!> Make an instance of the habitat object.
!! See `the_environment::habitat_make_init()`
procedure, public :: make => habitat_make_init
!> Return the name (label) of the habitat.
!! See `the_environment::habitat_name_get()`.
procedure, public :: get_label => habitat_name_get
!> Get the mortality risk associated with this habitat.
!! See `the_environment::habitat_get_risk_mortality()`.
procedure, public :: get_mortality => habitat_get_risk_mortality
!> Get the egg mortality risk associated with this habitat.
!! See `the_environment::habitat_get_risk_mortality_egg()`.
procedure, public :: get_egg_mort => habitat_get_risk_mortality_egg
!> Save the predators with their characteristics into a CSV file.
!! See `the_environment::habitat_save_predators_csv()`.
procedure, public :: save_predators_csv => habitat_save_predators_csv
end type HABITAT
!> A list (array) of all the the_environment::habitat objects available
!! to the agents. This single array should encompass all the locations that
!! the agent can potentially be in (e.g. migrate from one to another).
!!
!! It is then very important that the separate habitat objects that are
!! defined in the model are actually different data entities than the global
!! array. If any change is made to the habitat objects after the global
!! array was assembled, these must be synchronised with the array and vice
!! versa.
!!
!! To determine where the agent (or any other spatial object) is currently
!! located within use the the_environment::spatial::find_environment() method.
!! The simplest form of assembling the global array is
!! @code
!! allocate(Global_Habitats_Available(2))
!! Global_Habitats_Available = [habitat_safe, habitat_dangerous]
!! @endcode
!! A more powerful alternative is using the the_environment::assemble()
!! procedure:
!! @code
!! call assemble(habitat_safe, habitat_dangerous, reindex=.TRUE.)
!! @endcode
!! See the_environment::assemble() and the_environment::disassemble()
!! procedures for more information on creating the global array of habitat
!! objects and disassembling individual habitat objects back (updating the
!! internal data components and arrays for each of the individual habitats.
!!
!! Here is an example of the steps necessary to use joined food resource
!! from several assembled habitats:
!! @code
!! ! 1. Assemble the global array of habitat objects
!! ! Global_Habitats_Available.
!! call assemble( habitat_test1, habitat_test2, &
!! habitat_test3, habitat_test4 )
!!
!! ! 2. Join returns a single food resource object out of those in the
!! ! global array Global_Habitats_Available
!! joined_food_res2 = join( reindex=.TRUE. )
!!
!! ! 3. Modify the joined single food resource object in some way.
!! ! Here it just resets the sizes of the food items for a part
!! ! of the data.
!! joined_food_res2%food( 1:size(habitat_test1%food%food) )%size = 100.0
!!
!! ! 4. Unjoin updates the food resources from the single global object
!! ! back to the global array Global_Habitats_Available.
!! call unjoin( joined_food_res2, reindex=.TRUE. )
!!
!! ! 5. To complete unjoin, the updated food habitat and resource data
!! ! should be transferred back to the original separate habitat objects
!! ! usint `disassemble`
!! call disassemble( habitat_test1, habitat_test2, &
!! habitat_test3, habitat_test4 )
!! @endcode
!! @note Determining the environment object the agent is currently in
!! can be done by the_environment::spatial::find_environment()
!! method in this way:
!! @verbatim
!! ...
!! environment_limits = Global_Habitats_Available( &
!! this_agent%find_environment( &
!! Global_Habitats_Available) )
!! ...
!! @endverbatim
!! @note Using a list of the_environment::habitat's rather than
!! the_environment::environment's because the agent dwells in a
!! habitat object and extended properties (e.g. habitat name) are
!! easily available in such a case.
!! @warning It is not possible to define this global variable in the
!! commondata module because all environmental objects are defined
!! in a higher level hierarchy module the_environment.
!! @warning This array must be initialised immediately after creating the
!! environmental objects / habitats:
!! the_evolution::init_environment_objects().
!! @warning This global array definition cannot be moved to the start of
!! the module (for convenience), this results in the "object used
!! before it is defined" compiler error.
type(HABITAT), dimension(:), allocatable, public :: Global_Habitats_Available
!> Calculate *surface light* intensity (that is subject to diel variation)
!! for specific time step of the model. Irradiance can be *stochastic* if
!! an optionallogical `stochastic` flag is set to `TRUE`.
!! @details Light (`surlig`) is calculated from a sine function. Light
!! intensity just beneath the surface is modelled by assuming a
!! 50 % loss by scattering at the surface:
!! @f[ L_{t} = L_{max} 0.5 sin(\pi dt / \Omega ) . @f]
!! **Usage:**
!! - deterministic:
!! @code
!! surface_light(1)
!! @endcode
!! - stochastic:
!! @code
!! surface_light(1,YES)
!! @endcode
!>
!! @note Note that it is impossible to do a simple single whole-elemental
!! implementation for this function as `random_number` is *never
!! pure* but elemental can only work with all pure functions.
interface light_surface
module procedure light_surface_deterministic
module procedure light_surface_stochastic_scalar
module procedure light_surface_stochastic_vector
end interface light_surface
!> Calculate *underwater background irradiance* at specific depth
!! @details Underwater light is attenuated following Beer’s law,
!! @f[ E_{b}(z,t) = L_{t} e^{-K z} , @f] where @f$ E_{b}(z,t) @f@
!! is background irradiance at depth z at time t and K is the
!! attenuation coefficient for downwelling irradiance.
!! @note The generic interface includes two elemental functions for integer
!! and real depth.
interface light_depth
module procedure light_depth_integer
module procedure light_depth_real
end interface light_depth
!> Calculate visual range of predator using Dag Aksnes's procedures
!! `srgetr()`, `easyr()` and `deriv()`.
!! @note This is a non-pure/elemental version with **debugging log output**.
!! @warning The main interface name is `visual_range()`, it is this name
!! which is used throughout the code.
!! @note It is possible to use either the "debug" (this) or "fast" (next)
!! generic interface for `visual_range()` by tweaking the interface
!! name, e.g. to switch to the debug version rename
!! `visual_range_debug()` to `visual_range()` and the next version to
!! `visual_range_disable()`.
!!
!! ### Specific implementations ###
!! See specific implementations:
!! - the_environment::visual_range_scalar() for scalar argument
!! - the_environment::visual_range_vector() for vector argument
!! - the_environment::visual_range_fast() elemental (parallel-safe) version
!! lacking sanity checks and extended debugging.
!! .
interface visual_range
module procedure visual_range_scalar
module procedure visual_range_vector
end interface visual_range
!> Calculate visual range of predator using Dag Aksnes's procedures
!! `srgetr()`, `easyr()` and `deriv()`.
!! @note This is a pure/elemental version with **no** debugging log output.
!! @warning The main interface name is `visual_range`, it is this name
!! which is used throughout the code.
!! @warning The parameter `prey_contrast` to the **vector**-based function
!! call must be an **scalar**. Otherwise a segmentation fault
!! runtime error results. Vector-based call is analogous to calling
!! `visual_range_vector()` with `prey_contrast_vect` parameter.
interface visual_range_new
module procedure visual_range_fast
end interface visual_range_new
!> Internal distance calculation backend engine.
interface dist
module procedure dist_scalar
module procedure dist_vector_nd
end interface dist
!> An alias for the the_environment::food_resources_collapse_global_object()
!! method for joining food resources into a single global food resource out
!! of the global array the_environment::global_habitats_available.
!! See the_environment::unjoin() for how to unjoin an array of food resources
!! back into an array.
interface join
module procedure food_resources_collapse_global_object
end interface join
!> An alias to the_environment::food_resources_update_back_global_object()
!! method to transfer (having been modified) food resource objects out from
!! the single united object back to the global array
!! the_environment::global_habitats_available.
!! See the_environment::join() for how to join an array of food resources
!! into a single global object.
!! @warning Note that complete restoring the food resources back to each of
!! the individual habitat objects out of the global array must be
!! done using the the_environment::disassemble() procedure.
interface unjoin
module procedure food_resources_update_back_global_object
end interface
!> Interface to the procedure to **assemble** the global array of habitat
!! objects the_environment::global_habitats_available from a list of separate
!! habitat object components.
!! This call
!! @code
!! assemble(hab_a, hab_b, hab_c)
!! @endcode
!! is equivalent to
!! @code
!! Global_Habitats_Available = [ hab_a, hab_b, hab_c ]
!! @endcode
!! See the_environment::global_habitats_assemble() for the backend
!! implementation.
interface assemble
module procedure global_habitats_assemble
end interface
!> Interface to the procedure to **disassemble** the global habitats objects
!! array the_environment::global_habitats_available back into separate
!! habitat object components.
!! See the_environment::global_habitats_disassemble() for the backend
!! implementation.
interface disassemble
module procedure global_habitats_disassemble
end interface disassemble
!> Interface operator to concatenate two arrays of the spatial
!! the_environment::spatial or spatial moving the_environment::spatial_moving
!! objects.
!! @code
!! object1%location() .cat. object2%location()
!! @endcode
!! See the_environment::spatial_stack2arrays() and
!! the_environment::spatial_moving_stack2arrays() for backend implementation.
!> @warning This operator works with fixed **types** rather than class. All
!! input and output parameters are defined as **type**, so this
!! is not class-safe.
interface operator (.cat.)
procedure spatial_stack2arrays
procedure spatial_moving_stack2arrays
end interface operator (.cat.)
!> Interface operator to concatenate the **location** components of two
!! arrays ofthe_environment::spatial **class** objects.
!! @code
!! all_objects%position%( object1 .catloc. object2 )
!! @endcode
!> @note Unlike the .cat. operator implemented using the
!! the_environment::spatial_stack2arrays() and
!! the_environment::spatial_moving_stack2arrays() methods, this
!! procedure is class-safe and can be used with any class upwards,
!! but it concatenates **only** the location data (returns **type**
!! the_environment::spatial).
interface operator (.catloc.)
procedure spatial_class_stack2arrays_locs
end interface operator (.catloc.)
!> Interface operators `.within.` for testing whether a spatial object (first
!! argument lies within an environment (second argument). Usage:
!! @code
!! if ( object .within. environment ) then
!! @endcode
!! See `the_environment::spatial_check_located_within_3d()`.
interface operator (.within.)
procedure spatial_check_located_within_3d
end interface operator (.within.)
!> Interface operators `.contains.` for testing whether an environment
!! object (first argument) contains a `SPATIAL` object (second argument).
!! Usage:
!! @code
!! if ( environment .contains. object ) then
!! @endcode
!! See `the_environment::environment_check_located_within_3d()`.
interface operator (.contains.)
procedure environment_check_located_within_3d
end interface operator (.contains.)
!> Interface operators .above. for spatial objects. Usage:
!! @code
!! object1 .above. object2
!! @endcode
!! Tests the condition of `object1` is above `object2`
!! The operator can be used in two ways:
!! - as an expression, with both scalar and array values:
!! @code
!! parents%ind(i) .above. parents%ind(i)%perceive_food%foods_seen
!! @endcode
!! - in if blocks, only **scalars**:
!! @code
!! if ( parents%ind(i) .above. parents%ind(i)%perceive_food%foods_seen(1) )
!! @endcode
!! .
!! @note Note that the operator `.above.` refers to the "below" procedure
!! `the_environment::spatial_check_located_below` as the dummy
!! parameters have reverse order in this implementation procedure.
interface operator (.above.)
procedure spatial_check_located_below
end interface operator (.above.)
!> Interface operators .below. for spatial objects. Usage:
!! @code
!! object1 .below. object2
!! @endcode
!! Tests the condition of `object1` is below `object2`
!! The operator can be used in two ways:
!! - as an expression, with both scalar and array values:
!! @code
!! parents%ind(i) .below. parents%ind(i)%perceive_food%foods_seen
!! @endcode
!! - in if blocks, only **scalars**:
!! @code
!! if ( parents%ind(i) .below. parents%ind(i)%perceive_food%foods_seen(1) )
!! @endcode
!! .
!! @note Note that the operator `.below.` refers to the "above" procedure
!! `the_environment::spatial_check_located_above` as the dummy
!! parameters have reverse order in this implementation procedure.
interface operator (.below.)
procedure spatial_check_located_above
end interface operator (.below.)
!> Interface operator "-" for the the_environment::environment spatial
!! container objects. Return an environment object that is shrunk by a
!! fixed value in the 2D XxY plane.
!! See `the_environment::environment_shrink_xy_fixed()`.
!! The operator can be used as follows:
!! @code
!! temp_hab = habitat_safe - 0.5_SRP
!! @endcode
interface operator (-)
procedure environment_shrink_xy_fixed
end interface operator (-)
!-----------------------------------------------------------------------------
!> These are public access functions, but probably we don't need to allow
!! public access to functions inside generic interfaces
public :: light_surface, light_depth, visual_range
!> We do not need specific functions outside of this module, always use
!! generic functions.
private :: light_surface_deterministic, &
light_surface_stochastic_scalar, &
light_surface_stochastic_vector, &
light_depth_integer, &
light_depth_real, &
visual_range_scalar, &
visual_range_vector, &
srgetr, easyr, deriv
contains ! ........ implementation of procedures for this level ................
!-----------------------------------------------------------------------------
!> Create an empty spatial object. The object's starting coordinates get
!! all `MISSING` values.
elemental subroutine spatial_create_empty(this)
class(SPATIAL), intent(inout) :: this
call this%missing()
end subroutine spatial_create_empty
!-----------------------------------------------------------------------------
!> Create the highest level container environment.
!! Set the size of the 3D environment container as two coordinate vectors
!! setting the minimum and maximum coordinate limits:
!! `min_coord(1)` for *x*, `min_coord(2)` for *y*, `min_coord(3)` for *z*
!! The size of the environment should be set from parameter vectors
!! in `COMMONDATA`.
!! @param min_coord Minimum coordinate bound for the environment.
!! @param max_coord Maximum coordinate bound for the environment.
!! @note This version accepts simple *arrays* as the environment coordinates.
!! @warning Not-extensible version. TODO: Do we need it? Deprecate?
!! There is a generic function `build` that should normally be used.
subroutine environment_whole_build_vector(this, min_coord, max_coord)
class(ENVIRONMENT), intent(inout) :: this
! Set the size of the 3D environment container as two coordinate vectors
! setting the minimum and maximum coordinate limits:
! `min_coord(1)` for *x*, `min_coord(2)` for *y*, `min_coord(3)` for *z*
! The size of the environment should be set from parameter vectors
! in `COMMONDATA`.
real(SRP), dimension(3), intent(in) :: min_coord, max_coord
! Set the environment limits from the parameter vectors.
! @note We use standard type-bound function `position` with
! type constructor for `SPATIAL` here.
call this%coord_min%position( SPATIAL( &
min_coord(1), min_coord(2), min_coord(3)) )
call this%coord_max%position( SPATIAL( &
max_coord(1), max_coord(2), max_coord(3)) )
end subroutine environment_whole_build_vector
!-----------------------------------------------------------------------------
!> Create the highest level container environment.
!! Set the size of the 3D environment container as two coordinate vectors
!! setting the minimum and maximum coordinate limits. The parameters
!! `min_coord` and `max_coord` are SPATIAL objects.
!! @param min_coord Minimum coordinate bound for the environment,
!! `SPATIAL` object.
!! @param max_coord Maximum coordinate bound for the environment,
!! `SPATIAL` object.
!! @note This version accepts `SPATIAL` *objects* as the environment
!! coordinates.
subroutine environment_whole_build_object(this, min_coord, max_coord)
class(ENVIRONMENT), intent(inout) :: this
! Set the size of the 3D environment container as two coordinate vectors
! setting the minimum and maximum coordinate limits. The parameters
! `min_coord` and `max_coord` are SPATIAL objects.
type(SPATIAL), intent(in) :: min_coord, max_coord
! Set the environment limits from the parameter SPATIAL container objects.
this%coord_min = min_coord
this%coord_max = max_coord
end subroutine environment_whole_build_object