26 real(SRP) :: visrange, irradiance, step_rwalk, cost_step
27 integer :: food_item_selected, conspecif_selected
28 integer :: i, iii, ind
29 type(food_resource) :: joined_food_res_tmp
33 real(SRP),
dimension(100) :: way_passed
35 real(SRP) :: surlig_log_dt, surlig_log_st
38 character(len=*),
parameter :: PROCNAME =
"(life_cycles_DEBUG_TEST)"
42 call log_configure(
"writeonstdout" , .
true.)
43 call log_msg(
"*** START DEBUG BLOCK ***" )
52 reindex=.
true., label=
"TEMPORARY" )
54 call joined_food_res_tmp%save_csv(csv_file_name=
"foods_joined.csv")
55 call habitat_safe%food%save_csv(csv_file_name=
"foods_safe.csv")
60 do_inds:
do ind = 1, 20
64 call log_configure(
"writeonstdout" , .
true.)
65 call log_msg(
"Individual " // tostr(ind) )
79 call log_delimiter(log_level_chapter)
81 walks_beh:
do i=1, 500
84 call log_msg(
"*****************")
85 call log_msg(
"AGENT " // tostr(
proto_parents%individual(ind)%get_id()) //
" DEAD" )
92 call stopwatch_walk_wise%start(
"Walk # " // tostr(i))
94 if (
is_debug)
call log_delimiter(log_level_chapter)
95 call log_dbg(
"Agent walk no=" // tostr(i) //
" , agent ID " // &
97 " (# " // tostr(ind) //
"), name:" &
99 //
", is male: " // tostr(
proto_parents%individual(ind)%is_male()) //
".")
101 call log_dbg (
"Agent body length: " // &
111 call log_dbg (
" Light at surface deterministic: " // &
112 tostr(surlig_log_dt) // &
113 ", stochastic: " // &
114 tostr(surlig_log_st) // &
115 ", light at depth: " // &
125 tostr(agent_in) //
", with name " // &
126 global_habitats_available(agent_in)%get_label() )
138 call log_dbg(
"Environmental perceptions: light " // &
139 tostr(
proto_parents%individual(ind)%perceive_light%get_current()) // &
141 tostr(
proto_parents%individual(ind)%perceive_depth%get_current()) )
148 global_habitats_available( agent_in )%food )
160 call proto_parents%individual(ind)%motivations_percept_components()
161 call proto_parents%individual(ind)%motivations_primary_calc()
166 tostr(
proto_parents%individual(ind)%motivations%hunger%motivation_prim) // &
167 ", avoid_passive: "// &
168 tostr(
proto_parents%individual(ind)%motivations%avoid_passive%motivation_prim) // &
169 ", avoid_active: " // &
170 tostr(
proto_parents%individual(ind)%motivations%avoid_active%motivation_prim) // &
172 tostr(
proto_parents%individual(ind)%motivations%reproduction%motivation_prim), &
177 tostr(
proto_parents%individual(ind)%motivations%hunger%motivation_finl) // &
178 ", avoid_passive: "// &
179 tostr(
proto_parents%individual(ind)%motivations%avoid_passive%motivation_finl) // &
180 ", avoid_active: " // &
181 tostr(
proto_parents%individual(ind)%motivations%avoid_active%motivation_finl) // &
183 tostr(
proto_parents%individual(ind)%motivations%reproduction%motivation_finl), &
190 maxval(
proto_parents%individual%motivations%max_perception() )
194 ", whole population." )
197 tostr(
proto_parents%individual(ind)%perceive_food%get_count()))
199 call log_dbg(
" distance >" // &
200 tostr(
proto_parents%individual(ind)%perceive_food%foods_distances))
202 tostr(
proto_parents%individual(ind)%perceive_food%foods_seen%get_size() ))
203 call log_dbg(
" dist. (d/sl) >" // &
204 tostr(
proto_parents%individual(ind)%perceive_food%foods_distances &
208 real(SRP),
allocatable,
dimension(:) :: visibility, p_capture
209 allocate(visibility(
proto_parents%individual(ind)%perceive_food%get_count()))
210 allocate(p_capture(
proto_parents%individual(ind)%perceive_food%get_count()))
211 do i=1,
proto_parents%individual(ind)%perceive_food%get_count()
212 visibility(i)=
proto_parents%individual(ind)%perceive_food%foods_seen(i)%visibility()
214 proto_parents%individual(ind)%perceive_food%foods_seen(i)%capture_probability( &
215 distance=
proto_parents%individual(ind)%perceive_food%foods_distances(i) )
217 call log_dbg(
" vis range >" // tostr(visibility))
218 call log_dbg(
" dist. (d/vr) >" // &
219 tostr(
proto_parents%individual(ind)%perceive_food%foods_distances &
221 call log_dbg(
" P capture >" // tostr(p_capture))
224 call log_dbg(
" average distance: " // &
225 tostr(proto_parents%individual(ind)%perceive_food%get_meandist()))
226 call log_dbg(
" memory food N: " // &
227 tostr(proto_parents%individual(ind)%memory_stack%memory_food))
228 call log_dbg(
" memory food dist: " // &
229 tostr(proto_parents%individual(ind)%memory_stack%memory_foodist))
230 call log_dbg(
" memory food size: " // &
231 tostr(proto_parents%individual(ind)%memory_stack%memory_foodsiz))
232 call log_dbg(
" average distance in memory: " // &
233 tostr(proto_parents%individual(ind)%memory_stack%get_food_mean_dist()))
234 call log_dbg(
" probability of capture subjective: " // &
235 tostr(proto_parents%individual(ind)%food_probability_capture_subjective()))
237 call log_dbg(ltag_info //
"*** Agent can see conspecifics: " // &
238 tostr(proto_parents%individual(ind)%perceive_consp%get_count()))
240 if ( proto_parents%individual(ind)%has_consp() )
then
241 call log_dbg(
" iid >" // &
242 tostr(proto_parents%individual(ind)%perceive_consp%conspecifics_seen%get_cid()))
245 call log_dbg(
" sex (is male), objective >" // &
246 tostr(proto_parents%individual( &
247 proto_parents%individual(ind)%perceive_consp%conspecifics_seen%get_cid() )%is_male()))
250 call log_dbg(
" mass objective >" // &
251 tostr(proto_parents%individual( &
252 proto_parents%individual(ind)%perceive_consp%conspecifics_seen%get_cid() )%get_mass()))
253 call log_dbg(
"Probability of reproduction: " // &
254 tostr(proto_parents%individual(ind)%probability_reproduction()) )
257 call log_dbg(ltag_info //
"*** Agent can see predators: " // &
258 tostr(proto_parents%individual(ind)%perceive_predator%get_count()))
260 if (proto_parents%individual(ind)%starved_death())
then
261 call proto_parents%individual(ind)%dies()
262 if (is_debug)
call log_delimiter(log_level_section)
263 call log_dbg (
"INFO: Agent dies due to starvation, ID: " // &
264 tostr(proto_parents%individual(ind)%get_id()) // &
265 "at time step " // tostr(i) )
266 call log_dbg (
" Body length: " // &
267 tostr(proto_parents%individual(ind)%body_length) // &
269 tostr(proto_parents%individual(ind)%body_mass) // &
270 ", maximum mass: " // &
271 tostr(proto_parents%individual(ind)%body_mass_maximum) // &
272 ", birth mass : " // &
273 tostr(proto_parents%individual(ind)%body_mass_birth) )
274 call log_dbg(
" Energy :" // &
275 tostr(proto_parents%individual(ind)%energy_current) // &
276 ", energy maximum: " // &
277 tostr(proto_parents%individual(ind)%energy_maximum) )
278 if (is_debug)
call log_delimiter(log_level_section)
279 call log_dbg(stopwatch_walk_wise%log())
283 call log_dbg(
"GOS is :" // proto_parents%individual(ind)%gos_label() )
284 call log_dbg(
"GOS arousal :" // tostr(proto_parents%individual(ind)%arousal()) )
287 call log_dbg(
"Before walk:")
288 call log_dbg(
" +++ Current mass: " // tostr(proto_parents%individual(ind)%mass()) // &
289 ", length: " // tostr(proto_parents%individual(ind)%length()) // &
290 ", energy: " // tostr(proto_parents%individual(ind)%get_energy()) )
292 call log_dbg( ltag_info //
"Mean distance to food items: " // &
293 tostr(proto_parents%individual(ind)%memory_stack%get_food_mean_dist()) , &
296 real(SRP) :: dist_food_sl
297 dist_food_sl = proto_parents%individual(ind)%memory_stack%get_food_mean_dist() / &
298 proto_parents%individual(ind)%get_length()
299 call log_dbg( ltag_info //
"Mean distance to food items: " // &
300 tostr(dist_food_sl) //
" SL units of agent ", &
307 if (is_debug)
call log_delimiter(log_level_chapter)
308 call log_dbg(ltag_info //
"START BEHAVIOUR (do_behave)")
310 call proto_parents%individual(ind)%do_behave( &
311 rescale_max_motivation= &
312 global_rescale_maximum_motivation)
314 if (is_debug)
call log_delimiter(log_level_chapter)
315 call log_dbg(ltag_info //
"EXECUTED BEHAVIOUR: " // &
316 proto_parents%individual(ind)%behaviour_is() )
317 if (is_debug)
call log_delimiter(log_level_chapter)
320 call log_dbg(
"After walk:")
321 call log_dbg(
" +++ Current mass: " // tostr(proto_parents%individual(ind)%mass()) // &
322 ", length: " // tostr(proto_parents%individual(ind)%length()) // &
323 ", energy: " // tostr(proto_parents%individual(ind)%get_energy()) )
325 call log_dbg( ltag_info //
"Current testosterone: " // &
326 tostr(proto_parents%individual(ind)%testosterone_level) // &
327 ", current estrogen: " // &
328 tostr(proto_parents%individual(ind)%estrogen_level ) )
330 if ( proto_parents%individual(ind)%is_male() ) &
331 call log_dbg( ltag_info //
"Testosterone: " // tostr(proto_parents%individual(ind)%testosterone_history ) )
333 if ( proto_parents%individual(ind)%is_female() ) &
334 call log_dbg( ltag_info //
"Estrogen: " // tostr(proto_parents%individual(ind)%estrogen_history ) )
339 call proto_parents%individual(ind)%sex_steroids_update()
340 call proto_parents%individual(ind)%subtract_living_cost()
341 call proto_parents%individual(ind)%energy_update()
344 call proto_parents%individual(ind)%age_increment()
350 call generation_one%fitness_calc()
354 save_data_inds_debug_end: block
355 character(len=:),
allocatable :: output_data_file
357 output_data_file =
"agents_" // model_name //
"_" // mmdd // &
358 "_gen_" // tostr(global_generation_number_current, &
359 generations) //
"_end" // csv
360 call proto_parents%save_csv(output_data_file, is_logging=.true.)
361 end block save_data_inds_debug_end
365 call disassemble ( habitat_safe, habitat_dangerous )
367 call joined_food_res_tmp%save_csv(csv_file_name=
"foods_joined_after.csv")
368 call habitat_safe%food%save_csv(csv_file_name=
"foods_safe_after.csv")
369 call habitat_dangerous%food%save_csv(csv_file_name=
"foods_dangerous_after.csv")
373 call system_halt(message=
"NORMAL TERMINATION DEBUG TEST PROCEDURE")
379 if (proto_parents%individual(ind)%is_dead())
exit inds
390 if (is_debug)
call log_delimiter(log_level_volume)
391 call log_dbg(
"********** Agent " // tostr(ind) //
"*****************")
392 call log_dbg(
"Agent location one:" // &
393 tostr(proto_parents%individual(ind)%location(.true.)))
394 call log_dbg (
"Agent body length: " // &
395 tostr(proto_parents%individual(ind)%body_length) // &
397 tostr(proto_parents%individual(ind)%body_mass) // &
399 tostr(proto_parents%individual(ind)%get_energy()) //
"=" // &
400 tostr(energy_reserve(proto_parents%individual(ind)%body_mass, &
401 proto_parents%individual(ind)%body_length)) )
406 call stopwatch_walk_wise%start(
"Walk # " // tostr(i))
408 if (is_debug)
call log_delimiter(log_level_chapter)
409 call log_dbg(
"Agent walk no=" // tostr(i) //
" , agent ID " // &
410 tostr(proto_parents%individual(ind)%get_id()) // &
411 " (# " // tostr(ind) //
"), name:" &
412 // trim(proto_parents%individual(ind)%individ_label())&
413 //
", is male: " // tostr(proto_parents%individual(ind)%is_male()) //
".")
415 call log_dbg (
"Agent body length: " // &
416 tostr(proto_parents%individual(ind)%body_length) // &
418 tostr(proto_parents%individual(ind)%body_mass) // &
420 tostr(proto_parents%individual(ind)%get_energy()) )
423 call stopwatch_op_current%start()
425 step_rwalk = dist2step(400.0)
426 call log_dbg(
" Step size for random walk: " // tostr(step_rwalk) // &
427 ", " // tostr(step_rwalk / proto_parents%individual(ind)%get_length()) // &
428 " agent's body sizes." )
430 call proto_parents%individual(ind)%rwalk( step_rwalk, 0.50, &
433 call log_dbg(
" cycle ind:walk "// tostr(ind) //
":"// tostr(i) // &
434 ", Loc: " // tostr(proto_parents%individual(ind)%location(.true.)))
435 call log_dbg(
" way "// &
436 tostr(proto_parents%individual(ind)%way()))
439 way_passed(i) = proto_parents%individual(ind)%way()
441 cost_step = proto_parents%individual(ind)%cost_swim(distance=way_passed(i))
442 call log_dbg(
" Cost of random walk step: " // tostr(cost_step) // &
443 " is " // tostr(100.0_srp * cost_step / proto_parents%individual(ind)%body_mass ) // &
444 "% of agent's body mass." )
447 proto_parents%individual(ind)%body_mass=proto_parents%individual(ind)%body_mass - &
452 call proto_parents%individual(ind)%perceptions_inner()
456 call proto_parents%individual(ind)%perceptions_environ()
457 call log_dbg(
"Environmental perceptions: light " // &
458 tostr(proto_parents%individual(ind)%perceive_light%get_current()) // &
460 tostr(proto_parents%individual(ind)%perceive_depth%get_current()) )
462 call log_dbg(
"Agent's data: depth: " // tostr(proto_parents%individual(ind)%dpos()) )
468 call proto_parents%individual(ind)%see_food(joined_food_res_tmp)
470 call proto_parents%individual(ind)%see_consp( proto_parents%individual )
472 call proto_parents%individual(ind)%see_pred( habitat_safe%predators )
475 call proto_parents%individual(ind)%motivations_percept_components()
476 call proto_parents%individual(ind)%motivations_primary_calc()
477 call proto_parents%individual(ind)%modulation()
478 call proto_parents%individual(ind)%motivations_to_memory()
479 call proto_parents%individual(ind)%gos_find()
481 if (proto_parents%individual(ind)%starved_death())
then
482 call proto_parents%individual(ind)%dies()
483 if (is_debug)
call log_delimiter(log_level_section)
484 call log_dbg (
"INFO: Agent dies due to starvation, ID: " // &
485 tostr(proto_parents%individual(ind)%get_id()))
486 call log_dbg (
" Body length: " // &
487 tostr(proto_parents%individual(ind)%body_length) // &
489 tostr(proto_parents%individual(ind)%body_mass) // &
490 ", maximum mass: " // &
491 tostr(proto_parents%individual(ind)%body_mass_maximum) // &
492 ", birth mass : " // &
493 tostr(proto_parents%individual(ind)%body_mass_birth) )
494 call log_dbg(
" Energy :" // &
495 tostr(proto_parents%individual(ind)%energy_current) // &
496 ", energy maximum: " // &
497 tostr(proto_parents%individual(ind)%energy_maximum) )
498 if (is_debug)
call log_delimiter(log_level_section)
499 call log_dbg(stopwatch_walk_wise%log())
503 call log_dbg(
"GOS is :" // proto_parents%individual(ind)%gos_label() )
504 call log_dbg(
"GOS arousal :" // tostr(proto_parents%individual(ind)%arousal()) )
506 call log_dbg(
"**** can see food: " // tostr(proto_parents%individual(ind)%perceive_food%get_count()))
507 has_food_check:
if ( proto_parents%individual(ind)%has_food() )
then
508 call log_dbg(
" coord(1) >" // &
509 tostr(proto_parents%individual(ind)%perceive_food%foods_seen(1)%location(.true.)))
510 call log_dbg(
" distance >" // &
511 tostr(proto_parents%individual(ind)%perceive_food%foods_distances))
512 call log_dbg(
" dist. (d/l) >" // &
513 tostr(proto_parents%individual(ind)%perceive_food%foods_distances &
514 / proto_parents%individual(ind)%get_length()))
515 call log_dbg(
" available >" // &
516 tostr(proto_parents%individual(ind)%perceive_food%foods_seen%is_available()))
517 call log_dbg(
" iid >" // &
518 tostr(proto_parents%individual(ind)%perceive_food%foods_seen%get_iid()))
520 do iii=1, proto_parents%individual(ind)%perceive_food%get_count()
521 call log_dbg(
" Prob:" // tostr(iii) //
"=" // &
522 tostr(proto_parents%individual(ind)%perceive_food%foods_seen(iii)%capture_probability( &
523 distance=proto_parents%individual(ind)%perceive_food%foods_distances(iii) ) ) // &
524 " dist:" // tostr(proto_parents%individual(ind)%perceive_food%foods_distances(iii)) // &
525 " size:" // tostr(proto_parents%individual(ind)%perceive_food%foods_seen(iii)%get_size()) // &
526 " mass:" // tostr(proto_parents%individual(ind)%perceive_food%foods_seen(iii)%get_mass()) &
531 call log_dbg(
" Food items are above: " // &
532 tostr( proto_parents%individual(ind)%is_above(proto_parents%individual(ind)%perceive_food%foods_seen) ) )
534 call log_dbg(
" Food items are below: " // &
535 tostr( proto_parents%individual(ind)%is_below(proto_parents%individual(ind)%perceive_food%foods_seen) ) )
537 call log_dbg(
" **Food items are above (user operator test): " // &
538 tostr( proto_parents%individual(ind) .above. proto_parents%individual(ind)%perceive_food%foods_seen ) )
539 if (proto_parents%individual(ind) .above. proto_parents%individual(ind)%perceive_food%foods_seen(1)) &
540 call log_dbg(
" **Test operator .above. :: agent is above the first item TRUE; " // &
541 "agent dpos: " // tostr(proto_parents%individual(ind)%dpos()) // &
542 ", food item dpos: " // tostr( proto_parents%individual(ind)%perceive_food%foods_seen(1)%dpos() ) )
544 call log_dbg(
" ++Food items are below (user operator test): " // &
545 tostr( proto_parents%individual(ind) .below. proto_parents%individual(ind)%perceive_food%foods_seen ) )
546 if (proto_parents%individual(ind) .below. proto_parents%individual(ind)%perceive_food%foods_seen(1)) &
547 call log_dbg(
" ++Test operator .below. :: agent is below the first item TRUE; " // &
548 "agent dpos: " // tostr(proto_parents%individual(ind)%dpos()) // &
549 ", food item dpos: " // tostr( proto_parents%individual(ind)%perceive_food%foods_seen(1)%dpos() ) )
551 call log_dbg(
"Relative functions test:")
552 call log_dbg(
" Food items above: " // tostr(proto_parents%individual(ind)%food_items_above()))
553 call log_dbg(
" Food items mass above: " // tostr(proto_parents%individual(ind)%food_mass_above()))
554 call log_dbg(
" Food items below: " // tostr(proto_parents%individual(ind)%food_items_below()))
555 call log_dbg(
" Food items mass below: " // tostr(proto_parents%individual(ind)%food_mass_below()))
558 call log_dbg(
"Finding food took " // tostr(stopwatch_op_current%elapsed()) )
561 call log_dbg(
" +++ Current mass: " // tostr(proto_parents%individual(ind)%mass()) // &
562 ", length: " // tostr(proto_parents%individual(ind)%length()) // &
563 ", energy: " // tostr(proto_parents%individual(ind)%get_energy()) )
567 food_item_selected = proto_parents%individual(ind)%food_item_select(rescale_max_motivation=6.0_srp)
572 call proto_parents%individual(ind)%do_eat_food_item(food_item_selected, joined_food_res_tmp)
574 call log_dbg(
"**** Tried to eat food item: " // tostr(food_item_selected))
575 call log_dbg(
" +++ Updated mass: " // tostr(proto_parents%individual(ind)%mass()) // &
576 ", length: " // tostr(proto_parents%individual(ind)%length()) // &
577 ", energy: " // tostr(proto_parents%individual(ind)%get_energy()) )
579 call log_dbg(
"Selected food iid " // &
580 tostr(proto_parents%individual(ind)%perceive_food%foods_seen(food_item_selected)%food_iid) )
582 call log_dbg(
"Selected item status " // &
583 tostr(proto_parents%individual(ind)%perceive_food%foods_seen(food_item_selected)%eaten) )
585 iii = proto_parents%individual(ind)%perceive_food%foods_seen(food_item_selected)%food_iid
586 call log_dbg(
"Selected food iid " // tostr(iii) )
587 call log_dbg(
"Selected item status " // &
588 tostr(proto_parents%individual(ind)%perceive_food%foods_seen(food_item_selected)%eaten) )
591 call log_dbg(
"Selected food item iid in resource " // tostr(joined_food_res_tmp%food(iii)%food_iid) )
593 call log_dbg(
"Selected food item status in resource " // tostr(joined_food_res_tmp%food(iii)%eaten) )
597 call proto_parents%individual(ind)%mass_grow(0.0_srp)
598 call proto_parents%individual(ind)%len_grow(0.0_srp)
599 end if has_food_check
601 call log_dbg(
"Food items status " // tostr(proto_parents%individual(ind)%perceive_food%foods_seen%eaten) )
604 call log_dbg(
"**** can see consp: " // tostr(proto_parents%individual(ind)%perceive_consp%get_count() ) )
605 has_consp_chk:
if ( proto_parents%individual(ind)%has_consp() )
then
606 call log_dbg(
" coord(1) >" // &
607 tostr(proto_parents%individual(ind)%perceive_consp%conspecifics_seen(1)%location(.true.)))
608 call log_dbg(
" iid >" // &
609 tostr(proto_parents%individual(ind)%perceive_consp%conspecifics_seen%get_cid()))
610 call log_dbg(
" sex (male) >" // &
611 tostr(proto_parents%individual(ind)%perceive_consp%conspecifics_seen%is_male()))
612 call log_dbg(
" sex (male) ?>" // &
613 tostr(proto_parents%individual( &
614 proto_parents%individual(ind)%perceive_consp%conspecifics_seen%get_cid() )%is_male()))
616 call log_dbg(
" mass >" // &
617 tostr(proto_parents%individual(ind)%perceive_consp%conspecifics_seen%get_mass()))
618 call log_dbg(
" mass ?>" // &
619 tostr(proto_parents%individual( &
620 proto_parents%individual(ind)%perceive_consp%conspecifics_seen%get_cid() )%get_mass()))
621 call log_dbg(
"Probability of reproduction: " // &
622 tostr(proto_parents%individual(ind)%probability_reproduction()) )
624 call log_dbg(
"Absolute difference in mass (all sex agents): " // &
625 tostr( proto_parents%individual(ind)%get_mass() - &
626 average( proto_parents%individual(ind)%perceive_consp%conspecifics_seen%get_mass() ) ) &
628 call log_dbg(
"Delta mass relative (all sex agents): " // &
630 within( proto_parents%individual(ind)%get_mass() / &
631 average( proto_parents%individual(ind)%perceive_consp%conspecifics_seen%get_mass() ), &
632 minval(probability_reproduction_delta_mass_abscissa), &
633 maxval(probability_reproduction_delta_mass_abscissa) &
638 conspecif_selected = proto_parents%individual(ind)%consp_select(rescale_max_motivation=6.0_srp)
640 call log_dbg(
"Selected conspecific No: " // tostr(conspecif_selected) )
641 call log_dbg(
"Selected consp iid: " // &
642 tostr(proto_parents%individual(ind)%perceive_consp%conspecifics_seen(conspecif_selected)%cid) )
644 call log_dbg(
"Selected consp is male: " // &
645 tostr(proto_parents%individual(ind)%perceive_consp%conspecifics_seen(conspecif_selected)%sex_is_male ) )
647 call log_dbg(
"Selected consp mass: " // &
648 tostr(proto_parents%individual(ind)%perceive_consp%conspecifics_seen(conspecif_selected)%get_mass() ) )
650 call log_dbg(
"Selected conspecific coordinates: " // &
651 tostr(proto_parents%individual(ind)%perceive_consp%conspecifics_seen(conspecif_selected)%x) //
"," // &
652 tostr(proto_parents%individual(ind)%perceive_consp%conspecifics_seen(conspecif_selected)%y) //
"," // &
653 tostr(proto_parents%individual(ind)%perceive_consp%conspecifics_seen(conspecif_selected)%depth) )
659 call log_dbg(
"**** can see pred: " // tostr(proto_parents%individual(ind)%perceive_predator%get_count() ) )
660 if ( proto_parents%individual(ind)%has_pred() )
then
661 call log_dbg(
" coord(1) =" // &
662 tostr(proto_parents%individual(ind)%perceive_predator%predators_seen(1)%location(.true.)))
663 call log_dbg(
" iid =" // &
664 tostr(proto_parents%individual(ind)%perceive_predator%predators_seen%get_cid()))
665 call log_dbg(
" dist =" // &
666 tostr(proto_parents%individual(ind)%perceive_predator%predators_seen%get_dist()))
667 call log_dbg(
" attack rates=" // &
668 tostr(proto_parents%individual(ind)%perceive_predator%predators_attack_rates))
670 call log_dbg(
" Probability of capture by predator 1: " // &
671 tostr(proto_parents%individual(ind)%risk_pred( &
672 proto_parents%individual(ind)%perceive_predator%predators_seen(1), &
673 proto_parents%individual(ind)%perceive_predator%predators_attack_rates(1) )))
678 light_depth( depth=proto_parents%individual(ind)%dpos(), &
680 light_surface(tstep=global_time_step_model_current, &
681 is_stochastic=daylight_stochastic) )
682 visrange = m2cm( visual_range( &
683 irradiance = irradiance, &
685 carea( cm2m( proto_parents%individual(ind)% &
686 perceive_predator%predators_seen(1)%get_size() ) ), &
687 prey_contrast = preycontrast_default ) )
688 call log_dbg(
" visual range =" // tostr(visrange) )
697 call proto_parents%individual(ind)%perception_to_memory()
700 call log_dbg(
"INFO: Subtracting cost of living for agent # " // &
701 tostr(ind) //
" and add weight and length to the history.")
704 call proto_parents%individual(ind)%subtract_living_cost()
707 call proto_parents%individual(ind)%sex_steroids_update()
709 call add_to_history(proto_parents%individual(ind)%body_length_history, &
710 proto_parents%individual(ind)%body_length)
712 call add_to_history(proto_parents%individual(ind)%body_mass_history, &
713 proto_parents%individual(ind)%body_mass)
715 call log_dbg(stopwatch_walk_wise%log())
717 call proto_parents%individual(ind)%destroy_perception()
718 call log_dbg(
"Perceptions destroyed for ind " // tostr(ind) //
"("// tostr(i) //
")")
723 call log_dbg(
"Average walk step distance: " // tostr(average(way_passed)) )
724 call debug_histogram_save(x_data=way_passed, &
725 csv_out_file=
"debug_hist_way_" // mmdd //
"_g" // &
726 tostr(global_generation_number_current) //
"_ind_" // &
728 delete_csv=.false., enable_non_debug=.true. )
730 call log_dbg(
"INFO: Subtracting cost of living for agent # " // &
731 tostr(ind) //
" and add weight and length to the history.")
734 call proto_parents%individual(ind)%subtract_living_cost()
736 call proto_parents%individual(ind)%sex_steroids_update()
738 call add_to_history(proto_parents%individual(ind)%body_length_history, &
739 proto_parents%individual(ind)%body_length)
741 call add_to_history(proto_parents%individual(ind)%body_mass_history, &
742 proto_parents%individual(ind)%body_mass)
744 if (proto_parents%individual(ind)%starved_death())
then
745 call proto_parents%individual(ind)%dies_debug()
746 if (is_debug)
call log_delimiter(log_level_section)
747 call log_dbg (
"INFO: Agent dies due to starvation, ID: " // &
748 tostr(proto_parents%individual(ind)%get_id()))
749 call log_dbg (
" Body length: " // &
750 tostr(proto_parents%individual(ind)%body_length) // &
752 tostr(proto_parents%individual(ind)%body_mass) // &
753 ", maximum mass: " // &
754 tostr(proto_parents%individual(ind)%body_mass_maximum) // &
755 ", birth mass : " // &
756 tostr(proto_parents%individual(ind)%body_mass_birth) )
757 call log_dbg(
" Energy :" // &
758 tostr(proto_parents%individual(ind)%energy_current) // &
759 ", energy maximum: " // &
760 tostr(proto_parents%individual(ind)%energy_maximum) )
761 if (is_debug)
call log_delimiter(log_level_section)
767 call csv_matrix_write ( reshape( &
768 [proto_parents%individual(ind)%history%x, &
769 proto_parents%individual(ind)%history%y, &
770 proto_parents%individual(ind)%history%depth], &
771 [history_size_spatial, 3]), &
772 "zz_move_hist_" // mmdd // &
773 "_gen_" // tostr(global_generation_number_current, generations) // &
774 "_ind_" // tostr(ind) // csv, &
779 call csv_matrix_write ( reshape( &
780 [proto_parents%individual(ind)%body_length_history, &
781 proto_parents%individual(ind)%body_mass_history], &
782 [history_size_agent_prop, 2]), &
783 "zz_length_mass_hist_" // mmdd // &
784 "_gen_" // tostr(global_generation_number_current, generations) // &
785 "_ind_" // tostr(ind) // csv, &
790 call csv_matrix_write ( reshape( &
791 [real(proto_parents%individual(ind)%memory_stack%memory_food), &
792 proto_parents%individual(ind)%memory_stack%memory_foodsiz, &
793 proto_parents%individual(ind)%memory_stack%memory_reprfac ], &
794 [history_size_perception, 3]), &
795 "zz_percept_" // mmdd // &
796 "_gen_" // tostr(global_generation_number_current, generations) // &
797 "_ind_" // tostr(ind) //
"_name_" // &
798 trim(proto_parents%individual(ind)%individ_label()) // csv, &
799 [
"PRC_FOOD ",
"PRC_FOOD_SIZ",
"PRC_REPRFAC "] &
805 print *,
"************** INDS ended "
811 save_data_inds_init: block
812 character(len=:),
allocatable :: output_data_file
814 output_data_file =
"agents_" // model_name //
"_" // mmdd // &
815 "_gen_" // tostr(global_generation_number_current, &
816 generations) //
"_z_end" // csv
817 call proto_parents%save_csv(output_data_file, is_logging=.true.)
818 end block save_data_inds_init
820 call csv_matrix_write ( reshape( &
821 [ joined_food_res_tmp%food%x, &
822 joined_food_res_tmp%food%y, &
823 joined_food_res_tmp%food%depth, &
824 joined_food_res_tmp%food%size, &
825 conv_l2r(joined_food_res_tmp%food%eaten), &
826 real(joined_food_res_tmp%food%food_iid,SRP)], &
827 [joined_food_res_tmp%number_food_items, 6]), &
828 "zzz_zzz_food_ALL_after_" // MODEL_NAME //
"_" // MMDD // &
829 "_gen_" // TOSTR(Global_Generation_Number_Current, GENERATIONS) // csv, &
830 [
"X ",
"Y ",
"D ",
"SIZE",
"EATN",
"IID "] &
833 call joined_food_res_tmp%unjoin( habitat_safe%food, habitat_dangerous%food, reindex=.true. )
835 call joined_food_res_tmp%destroy()
837 call csv_matrix_write ( reshape( &
838 [ habitat_safe%food%food%x, &
839 habitat_safe%food%food%y, &
840 habitat_safe%food%food%depth, &
841 habitat_safe%food%food%size, &
842 conv_l2r(habitat_safe%food%food%eaten), &
843 real(habitat_safe%food%food%food_iid,SRP)], &
844 [habitat_safe%food%number_food_items, 6]), &
845 "zzz_food_safe_" // MODEL_NAME //
"_" // MMDD // &
846 "_gen_" // TOSTR(Global_Generation_Number_Current, GENERATIONS) // csv, &
847 [
"X ",
"Y ",
"D ",
"SIZE",
"EATN",
"IID "] &
850 call csv_matrix_write ( reshape( &
851 [ habitat_dangerous%food%food%x, &
852 habitat_dangerous%food%food%y, &
853 habitat_dangerous%food%food%depth, &
854 habitat_dangerous%food%food%size, &
855 conv_l2r(habitat_dangerous%food%food%eaten), &
856 real(habitat_dangerous%food%food%food_iid,SRP)],&
857 [habitat_dangerous%food%number_food_items, 6]), &
858 "zzz_food_dang_" // MODEL_NAME //
"_" // MMDD // &
859 "_gen_" // TOSTR(Global_Generation_Number_Current, GENERATIONS) // csv, &
860 [
"X ",
"Y ",
"D ",
"SIZE",
"EATN",
"IID "] &
863 call system_halt(message=
"NORMAL TERMINATION DEBUG TEST PROCEDURE")
COMMONDATA – definitions of global constants and procedures.
logical, public, protected is_debug
Sets the model in the debug mode if TRUE. The Debug mode generates huge additional outputs and logs....
character(len= *), parameter, private modname
MODNAME always refers to the name of the current module for use by the LOGGER function LOG_DBG....
logical, parameter, public daylight_stochastic
Flag for stochastic daylight pattern (if TRUE) or deterministic sinusoidal (when FALSE)....
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...
logical, parameter, public true
Safety parameter avoid errors in logical values, so we can now refer to standard Fortran ....
real(srp), public global_rescale_maximum_motivation
Global maximum sensory information that is updated for the whole population of agents.
logical, public, protected is_screen_output
Sets the model in screen output mode. If TRUE, the logger output goes to the screen (standard output ...
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, public ltag_info
Definition of high level file objects.
Implementation of the genetic algorithm.
type(population), pointer, public proto_parents
type(habitat), public habitat_dangerous
type(habitat), public habitat_safe
We have an environment composed of two habitats, safe and a dangerous.
subroutine life_cycles_debug_test
Debugging and testing lifecycle, random wakls etc. Has been initially implemented as DEBUG_03: block
CPU timer container object for debugging and speed/performance control. Arbitrary timers can be insta...