FishMet: Fish feeding and appetite model, OPEN EDITION  0.1
FishMet: Fish feeding and appetite model, OPEN EDITION
m_runtime.f90 (16564)
Go to the documentation of this file.
1 !> @file m_runtime.f90
2 !! The FishMet Model: Parameter input and output, model scheduling.
3 
4 ! ------------------------------------------------------------------------------
5 ! Copyright notice:
6 ! Copyright (c) 2015-2024 Sergey Budaev & Ivar Rønnestad
7 ! FishMet model code is distributed according to GNU AGPL v3, see LICENSE.md
8 ! ------------------------------------------------------------------------------
9 
10 ! Notes:
11 ! This module is for general scheduling of the model, parameters
12 ! inpuit and output
13 
14 !> Module that defines the runtime behaviour of the model
15 module runtime
16 
17  use realcalc
18  use commondata
19  use parsetext
20  use base_strings, only : lowercase, parse
21  use simulate
22  use the_fish
23  use, intrinsic :: iso_fortran_env, only : error_unit
24 
25  implicit none
26 
27  contains
28 
29  !> This procedure performs basic initialisation of the system:
30  !! - read environment variables determining global behaviour of the model
31  !! - call ::read_parameters_file() to get global model parameters from the
32  !! configuration file
33  !! .
34  impure subroutine system_init
35  use stubs, only : print_help_switches
36 
37  character(len=LABEL_LEN) :: t_string
38 
39  integer :: i, n_args
40  character(LABEL_LEN), dimension(:), allocatable :: cmd_args
41 
42  !> ### Command line parameters and environment variables ###
43  !> The behaviour of the model program can be controlled using command line
44  !! parameters and environment variables.
45  ! Get the number of command line arguments, they will be placed
46  ! into the `cmd_args array`.
47  n_args = command_argument_count()
48  allocate(cmd_args(n_args))
49 
50  ! Parse command line arguments.
51  do i=1, n_args
52  call get_command_argument(number = i, value = cmd_args(i))
53  cmd_args(i) = lowercase(cmd_args(i))
54  end do
55 
56  !> #### Help screen ####
57  !> Help screen: if the program is executed with one of these command line
58  !! parameters `-h --help -help /h /help`, a short screen help is
59  !! printed on the terminal and the program halts.
60  if ( any(cmd_args=="-h") .or. &
61  any(cmd_args=="--help") .or. &
62  any(cmd_args=="-help") .or. &
63  any(cmd_args=="/h") .or. &
64  any(cmd_args=="/help") ) then
65  call print_help_switches()
66  stop
67  end if
68 
69  !> #### Set the output mode ####
70  !> There are two output modes: normal and "quiet," in the later case
71  !! only requested information is written to the screen, no accessory
72  !! information is written.
73  if ( any(cmd_args=="-q") .or. any(cmd_args=="--quiet") .or. &
74  any(cmd_args=="/q") .or. any(cmd_args=="/quiet") ) then
75  verbose = .false.
76  else
77  verbose = .true.
78  end if
79 
80  !> #### Parameters file ####
81  !! The main parameter file is kept in commondata::global_param_file_name
82  !! and is defined by the environment variable `FFA_MODEL_PARAMETER_FILE`.
83  call get_environment_variable( name="FFA_MODEL_PARAMETER_FILE", &
84  value=t_string)
85  if ( len_trim(t_string)==0 ) then
87  else
88  global_param_file_name = t_string
89  end if
90 
91 
92  !> The environment variable `FFA_MODEL_OUTPUT_DEST` can set the output
93  !! destination directory in addition to the `output_dest` parameter in the
94  !! model configuration file. The value set by the environment variable
95  !! takes priority over the configuration file.
96  call get_environment_variable( name="FFA_MODEL_OUTPUT_DEST", &
97  value=t_string)
98  if ( len_trim(t_string)==0 ) then
100  else
101  global_output_dest = t_string
102  end if
103 
104  !> - Read global parameters from the configuration file defined in
105  !! commondata::param_file_name_def.
106  !! .
107  call read_parameters()
108 
109  end subroutine system_init
110 
111  !> This subroutine starts and schedules the model
112  impure subroutine system_run_main()
113  use stubs, only : cmd_iface_process_commands
114  use csv_io, only : get_free_funit
115 
116  logical :: is_exit_program
117 
118  integer :: stats_file_unit, file_error_status
119  logical :: is_model_stats_save_header_done, file_exists
120 
121  !> - Print param,eters
122  write(*,"(a)") model_parameters_txt()
123 
124  !> - Run the model
125  call test_run()
126 
127  !> - Print basic output stats
128  write(*,"(a)") model_output_stats_txt()
129 
132 
133  !> - Save model stats row
134  is_model_stats_save_header_done = .false.
135 
136  inquire( file=global_stats_output_file, exist=file_exists )
137  if (file_exists) then
138  is_model_stats_save_header_done = .true.
139  end if
140 
141  if (is_model_stats_save_header_done) then
142  if (verbose) write(*,*) "NOTE: File ", trim(global_stats_output_file), &
143  " exists, data will be appended."
144  ! not saved header yet, equivalent to `append stats` command
145  stats_file_unit = get_free_funit()
146  open(stats_file_unit, file=global_stats_output_file, &
147  status="old", position="append", action="write", &
148  iostat=file_error_status)
149  if (file_error_status /= 0) then
150  write(error_unit,*) &
151  ">>> ERROR: file write error! Use `output statistics` " // &
152  "command first, check free space or permissions."
153  else
154  write(stats_file_unit,"(a)") model_output_stats_row_csv()
155  end if
156  close(stats_file_unit)
157  else
158  ! new file started, equivalent `output stats` command
159  stats_file_unit = get_free_funit()
160  open(stats_file_unit, file=global_stats_output_file, &
161  status="replace", action="write", iostat=file_error_status)
162  if (file_error_status /= 0) then
163  write(error_unit,*) &
164  ">>> ERROR: file write error! Use `output statistics` " // &
165  "command first, check free space or permissions."
166  else
167  write(stats_file_unit,"(a)") &
168  model_output_stats_row_csv(show_header=.true.)
169  end if
170  close(stats_file_unit)
171  end if
172 
173  end subroutine system_run_main
174 
175  !> The subroutine **read_parameters** reads global parameters
176  !! defined in the commondata module from configuration file
177  !! commondata::param_file_name_def.
178  impure subroutine read_parameters()
179  use csv_io, only : get_free_funit, fs_unlink
180 
181  integer, parameter :: param_funit = 254 ! File unit for config file
182  type(pto) :: cf ! PARSETEXT file handle object
183  logical :: config_file_exist, config_param_is_missing
184  logical :: iface_is_gui, is_scale_relative
185  integer :: iin, f_unit_tmp, iostat_f_tmp
186  character(len=:), allocatable :: tmp_parse
187  character(len=*), parameter :: f_name_tmp = ".tmpfile"
188 
189  ! a temporary copy of Global_Transport_Pattern_T for analysis
190  real(srp), allocatable, dimension(:):: get_transport_pattern_t
191 
192  ! .......................................................................
193  ! Check if the configuration file exists, if not, exit with error.
194  inquire( file=trim(global_param_file_name), exist=config_file_exist )
195  if (.not. config_file_exist ) then
196  call exit_with_error( "Configuration file '" // &
197  trim(global_param_file_name) // "' cannot be found." )
198  end if
199 
200  ! .......................................................................
201  ! Open and parse the input configuration file
202  call ptparse(cf, trim(global_param_file_name), param_funit)
203 
204  ! Read the parameters
205  ! ### All following are model parameters
206 
207  global_run_model_hours = ptread_i(cf, 'run_model_hours', unknown)
208 
209  global_day_starts_hour = ptread_i(cf, 'day_starts_hour', 0)
210 
211  global_run_model_feed_offset = ptread_i(cf, 'feed_start_offset', 0)
212 
213  global_hours_daytime_feeding = ptread_i(cf, 'daytime_hours', unknown)
214 
216  ptread_r(cf, 'baseline_activity_day', missing)
217 
219  ptread_r(cf, 'baseline_activity_night', missing)
220 
221  global_body_mass = ptread_r(cf, 'body_mass', missing)
222 
223  global_stomach_mass = ptread_r(cf,'stomach_capacity', missing)
224 
225  global_midgut_mass = ptread_r(cf,'midgut_capacity', missing)
226 
227  global_absorption_ratio = ptread_r(cf,'absorption_ratio', missing)
228 
229  global_ingestion_delay_min = ptread_i(cf, 'ingestion_delay', unknown)
230 
231  global_water_uptake = ptread_r(cf,'water_uptake', missing)
232 
233  global_water_uptake_a = ptread_r(cf,'water_uptake_a', missing)
234 
235  global_water_uptake_r = ptread_r(cf,'water_uptake_r', missing)
236 
237  global_digestion_delay_min = ptread_i(cf, 'digestion_delay', unknown)
238 
239  global_maximum_duration_midgut_min=ptread_i(cf, 'midgut_maxdur', unknown)
240 
241  global_appetite_fish_night = ptread_r(cf, "appetite_night", missing)
242 
244  ptread_r(cf,'appetite_threshold_stomach', missing)
245 
246  global_appetite_logist_a = ptread_r(cf,'appetite_factor_a', missing)
247 
248  global_appetite_logist_r = ptread_r(cf,'appetite_factor_r', missing)
249 
251  ptread_r(cf,'activity_appetite_factor', 0.3_srp)
252 
253  global_ue_ze_factor = ptread_r(cf, 'branchial_energy_factor', missing)
254 
256  ptread_r(cf, 'branchial_ammonia_rate', missing)
257 
258  if ( global_ue_ze_factor == missing .and. &
259  global_ue_ze_ammonia_excretion > 0.0_srp ) then
261  if (is_debug .and. verbose) write(*,"(a,f6.4,a)") &
262  "NOTE: branchial and urinal energy loss is fixed rate: ", &
263  global_ue_ze_ammonia_excretion, " mu mol/g/h"
264  else if ( global_ue_ze_factor == missing .and. &
265  global_ue_ze_ammonia_excretion == missing ) then
266  global_ue_ze_factor = 0.0_srp
268  if (is_debug .and. verbose) &
269  write(*,*) "NOTE: branchial and urinal energy loss zero"
270  else
271  if (global_ue_ze_factor < 0.0_srp) global_ue_ze_factor = 0.0_srp
273  end if
274 
276  ptread_r(cf, 'sda_absorption_rate_max', 0.0_srp )
277 
278  global_sda_factor_max = ptread_r(cf, 'sda_energy_factor_max', 0.0_srp)
279 
280  ! Get Global_Transport_Pattern_T and autodetect time scale, s or h
281  get_transport_pattern_t = ptread_rvec( cf, 'transport_pattern_t' )
282 
283  ! Check if the time scale of the stomach transfer pattern vector is
284  ! provided in hours or in raw data sec. The main parameter
285  ! commondata::global_transport_pattern_t is in sec.
286  check_scale: if ( get_transport_pattern_t(2) > 120.0_srp ) then
287  ! - large number is provided, means the parameter vector is given
288  ! in raw seconds.
289  global_transport_pattern_t = nint(get_transport_pattern_t)
290  if (is_debug .and. verbose) &
291  write(*,*) "NOTE: transport_pattern_t in raw sec"
292  else check_scale
293  ! - small numbers (<120 = 2 min) means the parameter array is
294  ! given in hours
295  global_transport_pattern_t = nint(get_transport_pattern_t*hour)
296  if (is_debug .and. verbose) &
297  write(error_unit,"(a)") "NOTE: transport_pattern_t in hours"
298  end if check_scale
299 
300  global_transport_pattern_r = ptread_rvec( cf, 'transport_pattern_r' )
301 
303  call exit_with_error( "transport_pattern_t, transport_pattern_r" // &
304  " must have same dimensions", no_exit=.false. )
305 
307 
309  ptread_r(cf,'transport_pattern_base_temp', missing)
310 
312  ptread_r(cf,'transport_pattern_base_mass', missing)
313 
314  global_mid_gut_mm_r_max = ptread_r(cf,'midgut_michaelis_r_max', missing)
315 
316  global_mid_gut_mm_k_m = ptread_r(cf,'midgut_michaelis_k', missing)
317 
318  global_energy_appetite_rate = ptread_r(cf,"appetite_energy_rate",40.0_srp)
319 
320  global_energy_appetite_shift = ptread_r(cf,"appetite_energy_shift",0.2_srp)
321 
322  global_oxygen_grid_x_temp = ptread_rvec( cf, 'smr_oxygen_temp', &
324 
325  global_oxygen_grid_y_o2std = ptread_rvec( cf, 'smr_oxygen_o2', &
327 
329  call exit_with_error( "smr_oxygen_temp, smr_oxygen_o2" // &
330  " must have same dimensions", no_exit=.false. )
331 
332  global_food_item_mass = ptread_r(cf,'food_item_mass', missing)
333 
334  global_food_gross_energy = ptread_r(cf,'feed_gross_energy', missing)
335 
336  global_temperature = ptread_r(cf, 'temperature', missing)
337 
338  global_temp_factor_midgut_t = ptread_rvec(cf,'midgut_temp_fact_t', &
339  [1.0_srp, 10.0_srp, 25.0_srp])
340 
341  global_temp_factor_midgut_m = ptread_rvec(cf,'midgut_temp_fact_m', &
342  [1.0_srp, 1.0_srp, 1.0_srp])
343 
344  global_food_input_rate = ptread_r(cf,'food_input_rate', missing)
345 
347  'stomach_midgut_automatic', .false. )
348 
349  global_interval_food_param = ptread_ivec( cf, 'food_provision_pattern' )
350 
351  global_food_pattern_file = ptread_s( cf, "food_provision_file_name", "")
352 
353  global_food_pattern_file_is_propagate = ptread_l( cf, &
354  'food_provision_file_repeat', .true. )
355 
356  global_food_pattern_file_is_steps = ptread_l( cf, &
357  'food_provisioning_file_by_s', .false. )
358 
359  global_rate_interval = ptread_i(cf, 'rate_interval', 10)
360 
361  global_stats_output_file = ptread_s( cf, "stats_output_file", &
363 
364  global_output_stats_is_long = ptread_l(cf, "stats_output_long", .true.)
365 
367  ptread_s(cf, "stomach_emptying_matrix", "")
368  if ( trim(global_stomach_emptying_matrix_file) == "") then
370  if (is_debug .and. verbose) write(error_unit,"(a)") &
371  "WARNING: stomach emptying grid matrix is not set, use default:" // &
373  else
374  inquire( file=trim(global_stomach_emptying_matrix_file), &
375  exist=config_file_exist )
376  if (.not. config_file_exist ) then
377  write(error_unit,"(a)") "WARNING: stomach emptying grid file " // &
378  trim(global_stomach_emptying_matrix_file) // " not found"
379  write(error_unit,"(a)") " use default matrix"
382  else
385  if (size(global_stomach_emptying_pattern%emptying_time)<=9) then
386  write(error_unit,"(a)") "WARNING: stomach emptying grid file: " // &
388  write(error_unit,"(a)") &
389  " does not seem to contain correct data, "// &
390  "use default matrix"
393  end if
394 
395  end if
396  end if
397 
398  global_stress_factor_hour = ptread_rvec(cf, &
399  "stress_grid_hour", [missing, missing])
400  global_stress_fact_suppress = ptread_rvec(cf, &
401  "stress_grid_fact", [missing, missing])
402 
403  global_stress_intervention_is_minutes = ptread_l(cf,"stress_is_min",.true.)
404 
405  global_stress_cost_smr = ptread_r(cf, "stress_metabolic_cost", missing)
406 
407  global_stress_activity_decr = ptread_r(cf, "stress_inactivity", missing)
408 
409  if ( size(global_stress_factor_hour) /= &
410  size(global_stress_fact_suppress) ) then
411  global_stress_factor_hour = [missing, missing]
412  global_stress_fact_suppress = [missing, missing]
413  write(error_unit,"(a)") &
414  "WARNING: Stress grid arrays 'stress_grid_hour' and"
415  write(error_unit,"(a)") &
416  " 'stress_grid_fact' non-conformant, " // &
417  "stress disabled"
418  end if
419 
420  ! Get Global_Stress_Intervention_Time from the parameter file in correct
421  ! units. Note that Global_Stress_Intervention_Is_Minutes (stress_is_min)
422  ! can appear in the parameter file before or after stress because the file
423  ! is parsed after it is fully read
424  get_stress_array: block
425  integer(LONG), allocatable, dimension(:) :: stress_timing_in
426  stress_timing_in = ptread_ivec(cf, "stress", [unknown])
427  if ( any(stress_timing_in==unknown .or. any(stress_timing_in<0)) ) then
429  else
431  global_stress_intervention_time = stress_timing_in * minute
432  else
433  global_stress_intervention_time = stress_timing_in
434  end if
435  end if
436  end block get_stress_array
437 
438  ! Destination output directory commondata::global_output_dest is set from
439  ! the configuration file only if it is not already set to some non-default
440  ! value from the environment variable `FFA_MODEL_OUTPUT_DEST`
441  ! (see system_init()).
442  if ( global_output_dest == output_dest_dir ) then
443  global_output_dest = ptread_s( cf, "output_dest", output_dest_dir )
444  end if
445 
446  ! Check the above set output directory is writeable
447  check_write_dir: if (global_output_dest /= output_dest_dir) then
448  f_unit_tmp = get_free_funit()
449  open( unit=f_unit_tmp, file=trim(global_output_dest) // f_name_tmp, &
450  status='replace', iostat=iostat_f_tmp )
451  if (iostat_f_tmp /= 0) then
452  if (is_debug .and. verbose) write(error_unit,"(a)") &
453  "WARNING: destination directory " // trim(global_output_dest) //&
454  " is NOT writeable, reset to default."
456  end if
457  close(f_unit_tmp)
458  call fs_unlink(trim(global_output_dest) // f_name_tmp)
459  end if check_write_dir
460 
461  call ptkill(cf)
462 
463  ! .......................................................................
464  ! Check the configuration data, the file must always provide all
465  ! data, missing values are not allowed
466 
467  config_param_is_missing = .false.
468 
469  if (global_baseline_activity_day == missing) then
470  call exit_with_error("baseline_activity_day is MISSING", no_exit=.true.)
471  config_param_is_missing = .true.
472  end if
473 
474  if (global_baseline_activity_night == missing) then
475  call exit_with_error("baseline_activity_night is MISSING", no_exit=.true.)
476  config_param_is_missing = .true.
477  end if
478 
479  if (global_body_mass == missing) then
480  call exit_with_error("body_mass is MISSING", no_exit=.true.)
481  config_param_is_missing = .true.
482  end if
483 
484  if ( global_stomach_mass == missing .OR. &
486  global_stomach_mass = salmon_stomach_capacity(global_body_mass)
487  if (is_debug .and. verbose) write(error_unit, "(a,f9.3)") &
488  "WARNING: FILE_PARAMETERS: stomach_capacity from body_mass:", &
490  end if
491 
492  if ( global_midgut_mass == missing .or. &
494  global_midgut_mass = salmon_midgut_capacity(global_body_mass)
495  if (is_debug .and. verbose) write(error_unit, "(a,f9.3)") &
496  "WARNING: FILE_PARAMETERS: midgut_capacity from body_mass:", &
498  end if
499 
500  if (global_ingestion_delay_min == unknown) then
501  call exit_with_error("ingestion_delay is MISSING", no_exit=.true.)
502  config_param_is_missing = .true.
503  end if
504 
505  if (global_water_uptake == missing) then
506  call exit_with_error("water_uptake is MISSING", no_exit=.true.)
507  config_param_is_missing = .true.
508  end if
509 
510  if ( all(global_transport_pattern_t == unknown) ) then
511  call exit_with_error("transport_pattern_t is MISSING", no_exit=.true.)
512  config_param_is_missing = .true.
513  end if
514 
515  if ( all(global_transport_pattern_r == missing) ) then
516  call exit_with_error("transport_pattern_r is MISSING", no_exit=.true.)
517  config_param_is_missing = .true.
518  end if
519 
520  if ( all(global_oxygen_grid_x_temp == unknown) ) then
522  call exit_with_error("smr_oxygen_temp is MISSING", no_exit=.true.)
523  end if
524 
525  if ( all(global_oxygen_grid_y_o2std == unknown) ) then
527  call exit_with_error("smr_oxygen_o2 is MISSING", no_exit=.true.)
528  end if
529 
530  if (global_food_item_mass == missing) then
531  call exit_with_error("food_item_mass is MISSING", no_exit=.true.)
532  config_param_is_missing = .true.
533  end if
534 
535  if (global_temperature == missing) then
536  call exit_with_error("temperature is MISSING", no_exit=.true.)
537  config_param_is_missing = .true.
538  end if
539 
540  if (global_food_input_rate == missing) then
541  call exit_with_error("food_input_rate is MISSING", no_exit=.true.)
542  config_param_is_missing = .true.
543  end if
544 
545  ! Final check if any of the above configuration parameters was not set
546  ! correctly, if so, halt with error
547  if (config_param_is_missing) &
548  call exit_with_error( "Bad configuration file: " // &
549  trim(global_param_file_name) )
550 
551  end subroutine read_parameters
552 
553  !> A wrapper subroutine that will produce error message and halt
554  impure subroutine exit_with_error(message, no_exit)
555  use stubs, only : exit_with_error_cmd
556 
557  !> The error message that is printed to the standard error device or
558  !! appear as a warning window depending on the interface type.
559  character(len=*), intent(in) :: message
560  !> Optional parameter that dictates NOT to stop the program and just
561  !! print the error message. This may be useful if the program must
562  !! check a series of conditions and then exit at the last one.
563  logical, optional, intent(in) :: no_exit
564 
565  ! Local copy of optional parameter
566  logical :: no_exit_loc
567 
568  if (present(no_exit)) then
569  no_exit_loc = no_exit
570  else
571  no_exit_loc = .false.
572  end if
573 
574  call exit_with_error_cmd(message, no_exit_loc)
575 
576  end subroutine exit_with_error
577 
578  !-----------------------------------------------------------------------------
579  !> Parse and cut revision **number** in form of string from the whole SVN
580  !! revision string. SVN revision number can therefore be included into the
581  !! model outputs and output file names. This is convenient because the model
582  !! version is identified by a single SVN revision number.
583  !! @returns revision number from Subversion.
584  !! @warning `STRINGS` module uses unsafe coding prone to bugs, e.g.
585  !! does not clearly state dummy parameters intent and doesn't
586  !! work correctly with `parameter`s.
587  function parse_svn_version ( svn_version_string ) result (sversion)
588  !> The standard revision string as defined by the `$Revision: XXX $`
589  !! keyword from Subversion.
590  character(*), intent(in) :: svn_version_string
591  character(len=:), allocatable :: sversion ! @returns revision number.
592 
593  ! @note Have to copy `svn_version_string` to this local variable as
594  ! `PARSE` is broken when used with fixed parameters (no `intent`).
595  character(len=len(svn_version_string)) :: svn_string_copy
596  ! Delimiters for substrings.
597  character(len=3) :: delims = " :$"
598  ! String parts after parsing and cutting. Are 3 parts enough?
599  character(len=len(svn_version_string)), dimension(3) :: sargs
600  integer :: n_args
601 
602  !> ### Implementation notes ###
603  !> Subversion has a useful feature: various keywords can be inserted and
604  !! automatically updated in the source code under revision control, e.g.
605  !! revision number, date, user etc. The character string parameter constant
606  !! `commondata::svn_version_string` keeps the Subversion revision tag.
607  !! This subroutine parses the tag striping all other characters out.
608  svn_string_copy = svn_version_string
609  call parse(svn_string_copy, delims, sargs, n_args)
610  sversion = trim(sargs(n_args)) ! Version number is the last part.
611 
612  end function parse_svn_version
613 
614  !> Check if the stomach pattern matrix agrees with the stomach emptying
615  !! partameter matrix, i.e. the difference is less than one hour.
616  elemental function check_stomach_transport_emptying_agree() result (is_agree)
617  logical :: is_agree
618 
619  real(srp) :: check_calc, check_last_param
620  ! Absolute difference must be within this value
621  real(srp), parameter :: hour_diff_max = 1.0_srp
622 
623  check_calc = &
624  real( stomach_emptying_time(global_body_mass, global_temperature), srp)
625  check_last_param = &
626  real(global_transport_pattern_t(size(global_transport_pattern_t)),srp)
627 
628  if (abs(check_calc / hour - check_last_param / hour) < hour_diff_max) then
629  is_agree = .true.
630  else
631  is_agree = .false.
632  end if
633 
635 
636 
637 end module runtime
638 
639 
640 
This module defines global parameters and general-level computational utilities.
Definition: m_common.f90:13
character(len=file_name_len), public global_food_pattern_file
Global variable that keeps the file name for the food provisioning pattern see environ::food_provisio...
Definition: m_common.f90:641
logical, public global_stress_intervention_is_minutes
Global logical flag setting the time unit for the stress intervention parameter array defined by glob...
Definition: m_common.f90:392
character(len= *), parameter, public output_dest_dir
Default output directory: all plot and data file will be saved into this directory by default (local ...
Definition: m_common.f90:99
integer, dimension(:), allocatable, public global_transport_pattern_t
Food transport in stomach: Time grid array for interpolation. Configuration file example:
Definition: m_common.f90:325
real(srp), public global_food_input_rate
Standard rate of food item input, per minute. Configuration file example:
Definition: m_common.f90:618
real(srp), public global_food_item_mass
Standard mass of one food item. Configuration file example:
Definition: m_common.f90:593
integer, public global_digestion_delay_min
Delay of digestion, min. It is the delay of absorption after a food item was transmitted to the mid-g...
Definition: m_common.f90:275
real(srp), public global_water_uptake_a
Parameters of the logistic water uptake function that defines the temporary pattern of water uptake c...
Definition: m_common.f90:303
real(srp), public global_baseline_activity_day
Global baseline locomotor activity pattern (swimming speed) for each time step consists of two compon...
Definition: m_common.f90:685
integer, dimension(2), public global_interval_food_param
Parameters of the food provisioning pattern:
Definition: m_common.f90:629
logical, public global_food_pattern_file_is_propagate
Global logical flag that defines if the feed scheduling pattern defined by the global_interval_food_p...
Definition: m_common.f90:649
character(len= *), parameter, public def_stats_output_file
Default value of the general simulation statistics file defined in commondata::global_stats_output_fi...
Definition: m_common.f90:722
real(srp), public global_midgut_mass
Fish mid-gut mass capacity, max. filling capacity. Configuration file example:
Definition: m_common.f90:240
integer, public global_day_starts_hour
Default hour at which the "daytime" is normally started. This means, in particular,...
Definition: m_common.f90:204
real(srp), public global_appetite_fish_night
Fish appetite at night. This value is normally low because the fish do not feed at night....
Definition: m_common.f90:459
real(srp), public global_sda_absorp_rate_max
Defines the specific dynamic action (SDA) that depends on the absorption rate. There are two paramete...
Definition: m_common.f90:554
character(len= *), parameter, public output_arrays_csv_file
Default file base-name for saving model output arrays.
Definition: m_common.f90:89
real(srp), dimension(:), allocatable, public global_oxygen_grid_y_o2std
This parameter defines the Y axis of the grid: oxygen consumption. See commondata::oxygen_rate_std() ...
Definition: m_common.f90:586
logical, public global_stomach_midgut_mass_is_automatic
Logical flag that specifies that the stomach and midgut mass (capacity) are automatically recalculate...
Definition: m_common.f90:249
integer, public global_transport_dim
Food transport in stomach: Dimensionality of the transport pattern in the stomach.
Definition: m_common.f90:319
integer, public global_run_model_hours
Default duration of the model run in hours. Note that parameter file uses hours as unit....
Definition: m_common.f90:196
real(srp), public global_body_mass
Fish body mass, g, at the start of the simulation Configuration file example:
Definition: m_common.f90:226
type(stomach_emptying_pattern), public global_stomach_emptying_pattern
Default stomach emptying pattern.
Definition: m_common.f90:451
logical, parameter, public is_debug
Logical flag that sets the DEBUG mode. When the program is running in the DEBUG mode,...
Definition: m_common.f90:40
real(srp), public global_mid_gut_mm_k_m
Michaelis-Meneten food absorption parameter in mid-gut, (see the_fish::michaelis_menten()) relative ...
Definition: m_common.f90:499
character(len= *), parameter, public output_rate_data_csv_file
Default file base-name for saving model rate data.
Definition: m_common.f90:93
real(srp), public global_ue_ze_ammonia_excretion
A parameter defining branchial and urine (ZE+UE) energy consumption as a fixed ammonia excretion rate...
Definition: m_common.f90:535
character(len=file_name_len), public global_param_file_name
Defines the name of the file that keeps global parameters. This name is normally defined by the envir...
Definition: m_common.f90:153
real(srp), public global_stress_activity_decr
Maximum value of the suppressive effect of stress on baseline activity. The actual suppression of the...
Definition: m_common.f90:383
integer, public global_run_model_feed_offset
The offset (delay) to start feeding at the beginning of the simulation, Note that the parameter file ...
Definition: m_common.f90:211
real(srp), public global_stomach_mass
Fish stomach mass, max. filling capacity. Configuration file example:
Definition: m_common.f90:233
real(srp), public global_baseline_activity_night
Definition: m_common.f90:685
impure character(len=:) function, allocatable model_parameters_txt()
Produce a text string containing all global parameters of the model.
Definition: m_common.f90:835
integer, parameter, public minute
Definition: m_common.f90:61
integer, public global_maximum_duration_midgut_min
The maximum duration a food item can be processed in the fish mid-gut, min. If it stays in the mid-gu...
Definition: m_common.f90:284
character(len=file_name_len), public global_stats_output_file
Global variable keeping the file name for saving general simulation statistics. Data (rows) for each ...
Definition: m_common.f90:699
real(srp), public global_stress_cost_smr
Maximum value of the metabolic cost of stress in units of resting metabolic rate (SMR)....
Definition: m_common.f90:374
real(srp), public global_absorption_ratio
Maximum absorption ratio relative to the original dry food item mass. Configuration file example:
Definition: m_common.f90:257
real(srp), dimension(*), parameter trout_oxygen_grid_x_temp
Interpolation grid defining the function calculating standard oxygen consumption in rainbow trout bas...
Definition: m_common.f90:743
character(len=file_name_len), public global_output_dest
Output directory: all plot and output files will be saved into this directory, default value is set b...
Definition: m_common.f90:134
integer, public global_ingestion_delay_min
Delay of ingestion, min.
Definition: m_common.f90:266
real(srp), dimension(:), allocatable, public global_temp_factor_midgut_m
Temperature adjustment for absorption is controlled by the two parameters below that define the tempe...
Definition: m_common.f90:415
integer, parameter, public hour
Global time constants, number of sec in hour and min.
Definition: m_common.f90:61
character(len= *), parameter, public param_file_name_def
Defines the name of the file that keeps global parameters. The parameter file contains the coupled pa...
Definition: m_common.f90:146
real(srp), public global_appetite_stomach_threshold
Protective appetite threshold for stomach: this is the maximum value of the the_fish::stomach::appeti...
Definition: m_common.f90:469
real(srp), dimension(:), allocatable, public global_stress_fact_suppress
The pattern of stress effect on the appetite is described by two grid arrays global_stress_factor_hou...
Definition: m_common.f90:362
real(srp), public global_transport_baseline_fish_mass
The baseline fish mass that applies to the stomach transport pattern defined by global_transport_patt...
Definition: m_common.f90:429
character(len=file_name_len), public global_stomach_emptying_matrix_file
Global variable keeping the file name for the baseline stomach emptying matrix file that keeps the st...
Definition: m_common.f90:710
real(srp), public global_food_gross_energy
Gross energy content of the feed, MJ/kg (=kJ7g) Configuration file example:
Definition: m_common.f90:600
logical, public global_output_stats_is_long
Define if the output stats are saved using the long or short format. In the first case,...
Definition: m_common.f90:718
real(srp), dimension(:), allocatable, public global_stress_factor_hour
The pattern of stress effect on the appetite is described by two grid arrays global_stress_factor_hou...
Definition: m_common.f90:352
real(srp), dimension(:), allocatable, public global_temp_factor_midgut_t
Temperature adjustment for absorption is controlled by the two parameters below that define the tempe...
Definition: m_common.f90:342
logical, public global_is_ue_ze_fixed_rate
Logical flag to choose how branchial and urinal (ZE+UE) energy loss is calculated.
Definition: m_common.f90:544
real(srp), public global_temperature
Ambient temperature Configuration file example:
Definition: m_common.f90:611
real(srp), public global_sda_factor_max
Defines the specific dynamic action (SDA) that depends on the absorption rate. There are two paramete...
Definition: m_common.f90:566
integer, public global_rate_interval
Default rate discretization interval in minutes, this interval is used to plot the ingestion rate.
Definition: m_common.f90:188
real(srp), public global_mid_gut_mm_r_max
Michaelis-Meneten food absorption parameter in mid-gut, (see the_fish::michaelis_menten()) relative ...
Definition: m_common.f90:491
integer(long), dimension(:), allocatable, public global_stress_intervention_time
The time of stress intervention is set by this array. It is the start points of stressful effects (s)...
Definition: m_common.f90:403
real(srp), public global_appetite_activity_factor
Activity appetite factor determining how fish locomotor activity increases with increasing appetite....
Definition: m_common.f90:519
real(srp), public global_energy_appetite_rate
The steepness parameter of the Logistic energy component of appetite.
Definition: m_common.f90:505
real(srp), public global_appetite_logist_r
Logistic function parameter R for the appetite factor. See the_fish::appetite_func().
Definition: m_common.f90:483
character, parameter, public crlf
Definition: m_common.f90:83
real(srp), public global_energy_appetite_shift
The shift parameter of the Logistic energy component of appetite.
Definition: m_common.f90:511
real(srp), public global_appetite_logist_a
Logistic function parameter A for the appetite factor. See the_fish::appetite_func().
Definition: m_common.f90:476
logical, public verbose
Global logical flag to suppress extra text diagnostics and messages, the "quiet mode" or the "verbose...
Definition: m_common.f90:173
pure type(stomach_emptying_pattern) function stomach_emptying_def_default()
Define the default stomach emptying data structure ::stomach_emptying_pattern in case the input data ...
Definition: m_common.f90:2005
real(srp), dimension(:), allocatable, public global_transport_pattern_r
Food transport in stomach: Proportion of food mass left in stomach. Configuration file example:
Definition: m_common.f90:331
integer, public global_hours_daytime_feeding
Default duration of the day time in hours, night duration is defined as 24 - ::global_hours_day_feedi...
Definition: m_common.f90:219
real(srp), public global_water_uptake_r
Parameters of the logistic water uptake function that defines the temporary pattern of water uptake c...
Definition: m_common.f90:315
real(srp), public global_ue_ze_factor
A parameter defining branchial and urine (ZE+UE) energy consumption as a factor to SMR,...
Definition: m_common.f90:527
impure character(len=:) function, allocatable stomach_emptying_txt(is_raw_s)
Show the stomach emptying data structure.
Definition: m_common.f90:2041
real(srp), dimension(:), allocatable, public global_oxygen_grid_x_temp
This parameter defines the X axis of the grid: temperature. See commondata::oxygen_rate_std() for det...
Definition: m_common.f90:576
real(srp), public global_transport_baseline_temperature
The baseline temperature that applies to the stomach transport pattern defined by global_transport_pa...
Definition: m_common.f90:422
real(srp), dimension(*), parameter trout_oxygen_grid_y_o2std
Interpolation grid defining the function calculating standard oxygen consumption in rainbow trout bas...
Definition: m_common.f90:760
logical, public global_food_pattern_file_is_steps
Global logical flag that defines if the feed scheduling pattern defined by the global_food_pattern_fi...
Definition: m_common.f90:658
real(srp), public global_water_uptake
Proportion of water uptake, relative of dry mass of the food item. Configuration file example:
Definition: m_common.f90:291
Module that defines the runtime behaviour of the model.
Definition: m_runtime.f90:15
elemental logical function check_stomach_transport_emptying_agree()
Check if the stomach pattern matrix agrees with the stomach emptying partameter matrix,...
Definition: m_runtime.f90:617
impure subroutine exit_with_error(message, no_exit)
A wrapper subroutine that will produce error message and halt.
Definition: m_runtime.f90:555
impure subroutine system_run_main()
This subroutine starts and schedules the model.
Definition: m_runtime.f90:113
impure subroutine read_parameters()
The subroutine read_parameters reads global parameters defined in the commondata module from configur...
Definition: m_runtime.f90:179
impure subroutine system_init
This procedure performs basic initialisation of the system:
Definition: m_runtime.f90:35
character(len=:) function, allocatable parse_svn_version(svn_version_string)
Parse and cut revision number in form of string from the whole SVN revision string....
Definition: m_runtime.f90:588
Module that defines the runtime behaviour of the model.
Definition: m_simulate.f90:15
impure subroutine test_run()
The procedure below is TEMPORARY, for testing and debugging.
Definition: m_simulate.f90:935
impure subroutine output_arrays_save_csv(file_name, is_gui_dialog, is_write_error)
Save the model output arrays to a CSV data file.
Definition: m_simulate.f90:376
character(len=:) function, allocatable model_output_stats_row_csv(show_header)
Produce a text string containing general model output statistics.
Definition: m_simulate.f90:769
pure character(len=:) function, allocatable model_output_stats_txt()
Produce a text string containing general model output statistics.
Definition: m_simulate.f90:691
impure subroutine output_arrays_save_rate_data_csv(file_name, is_gui_dialog, is_write_error)
Save the rate data arrays to a CSV data file.
Definition: m_simulate.f90:509
This module defines the fish and its components. The model is discrete, time is based on time steps,...
Definition: m_fish.f90:12
impure type(stomach_emptying_pattern) function get_stomach_emptying_matrix_csv(csv_file)
Get the stomach emptying time base matrix from a CSV input data file.
Definition: m_fish.f90:2641