FishMet: Fish feeding and appetite model, OPEN EDITION  0.1
FishMet: Fish feeding and appetite model, OPEN EDITION
simulate Module Reference

Module that defines the runtime behaviour of the model. More...

Data Types

type  output_arrays_step_def
 This data structure keeps the output values for each time step. It should normally be instantiated as an allocatable array of the size equal to the total number of time steps in the model run. More...
 
type  output_stats_total_def
 Overall output statistics that are output from the model. More...
 

Functions/Subroutines

pure integer(long) function total_timesteps (hours)
 Calculate the total number of time steps in the model from the number of hours. This in fact converts hours to seconds. More...
 
impure subroutine output_arrays_init (time_steps)
 Allocate model output arrays output_arrays. More...
 
impure subroutine output_arrays_update_step (this_fish, time_step, temperature)
 Update model output arrays output_arrays. More...
 
impure subroutine output_arrays_add_ingested (is_given, is_eaten, time_step, add_eaten)
 Update the cumulative count of food items ingested. This cannot normally be done in output_arrays_update_step() and requires an input argument. More...
 
impure subroutine output_arrays_save_csv (file_name, is_gui_dialog, is_write_error)
 Save the model output arrays to a CSV data file. More...
 
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. More...
 
impure subroutine csv_file_error_report (csv_handle, is_gui_dialog)
 Report CSV file write error. More...
 
impure subroutine stomach_transport_save_csv (csv_file)
 Save the stomach transport data pattern for a single food item. More...
 
impure subroutine appetite_function_save_csv (csv_file)
 Save the appetite function the_fish::appetite_func() pattern for plotting, testing or analysis. More...
 
pure character(len=:) function, allocatable model_output_stats_txt ()
 Produce a text string containing general model output statistics. More...
 
character(len=:) function, allocatable model_output_stats_row_csv (show_header)
 Produce a text string containing general model output statistics. More...
 
impure subroutine test_run ()
 The procedure below is TEMPORARY, for testing and debugging. More...
 
impure subroutine init_provisioning (time_steps)
 Initialise the food provisioning schedule / pattern. More...
 
impure integer function, dimension(:), allocatable get_food_schedule_display ()
 Determine the food schedule array for separate display and analysis The primary role of this function is to plan (produce and display) the food provisioning pattern before simulation in GUI. More...
 
real(srp) function, dimension(:), allocatable get_ingestion_ratio_waste (rate_unit)
 calculate the array of the consumption ratio, i.e. eaten/provided, so it is also easy to calculate the waste rate More...
 

Variables

logical, parameter is_extended_logging_debug_test = .FALSE.
 Flag for extended/detailed debug logging. More...
 
logical, parameter, private is_urinal_branchial_kj_day = .TRUE.
 Flag that defines how urinal and branchial energy loss (UE+ZE) is calculated for model output arrays. If TRUE, UE+ZE is computed in kJ per kg per day (default), otherwise, in O2 equivalent unit: mg O2 / kg/hour. More...
 
integer, public gui_idx_progress
 Progress bar widget ID for the GUI mode, needed to update at runtime. More...
 
type(output_arrays_step_def), dimension(:), allocatable, public output_arrays
 output_arrays instantiates the global data structure that keeps the model output arrays. More...
 
type(output_stats_total_defoutput_stats
 output_stats instantiates non-array global data structure that keeps total model output statistics, that are not arrays by time step. More...
 

Detailed Description

Module that defines the runtime behaviour of the model.

Function/Subroutine Documentation

◆ total_timesteps()

pure integer(long) function simulate::total_timesteps ( integer, intent(in), optional  hours)

Calculate the total number of time steps in the model from the number of hours. This in fact converts hours to seconds.

Parameters
[in]hoursOptional hours to be converted to seconds. If absent, the default value is obtained from the global parameter commondata::global_run_model_hours.

Definition at line 115 of file m_simulate.f90.

Here is the caller graph for this function:

◆ output_arrays_init()

impure subroutine simulate::output_arrays_init ( integer(long), intent(in), optional  time_steps)

Allocate model output arrays output_arrays.

Parameters
[in]time_stepsOptional overall number of time steps of the model
Note
Note that this argument has the integer type of the kind commondata::long. This might taint default integer values.
This procedure cannot be pure because it allocates a global module-scope array.

Definition at line 131 of file m_simulate.f90.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ output_arrays_update_step()

impure subroutine simulate::output_arrays_update_step ( class(fish), intent(in)  this_fish,
integer(long), intent(in), optional  time_step,
real(srp), intent(in), optional  temperature 
)

Update model output arrays output_arrays.

Parameters
[in]this_fishThe fish that is participating in the simulation run.
[in]time_stepOptional time step, which coincides with the index of the model output arrays. The default value used if the argument is not given is defined by the global time step commondata::global_time_step.
[in]temperatureOptional temperature

Update oxygen uptake, convert to mg O2 per kg of body mass per hour

Update baseline meabolic rate, mg O2 per kg per hour

Update Active metabolic rate, mg O2 per kg per hour

Update SDA, mg O2 per hour per kg

Update urinal and branchial energy in kJ/kg per day

Alternatively, urinal and branchial energy is output as equivalent mg O2 per kg per hour

Warning
This makes sense only if UE+ZE is defined as factor of SMR rather than fixed rate (see commondata::global_is_ue_ze_fixed_rate)

Definition at line 181 of file m_simulate.f90.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ output_arrays_add_ingested()

impure subroutine simulate::output_arrays_add_ingested ( logical, intent(in)  is_given,
logical, intent(in)  is_eaten,
integer(long), intent(in), optional  time_step,
integer, intent(in), optional  add_eaten 
)

Update the cumulative count of food items ingested. This cannot normally be done in output_arrays_update_step() and requires an input argument.

Parameters
[in]is_givenLogical indicator whether a fod item is ingested at the current time step (TRUE) or not (FALSE). The cumulative number of food items consumed is updated (added) only if this parameter is TRUE.
[in]is_eatenLogical indicator whether a fod item is ingested at the current time step (TRUE) or not (FALSE). The cumulative number of food items consumed is updated (added) only if this parameter is TRUE.
[in]time_stepOptional time step, which coincides with the index of the model output arrays. The default value used if the argument is not given is defined by the global time step commondata::global_time_step.
[in]add_eatenOptional number of food items ingested, default value is 1.

Implementation notes

To update the cumulative count of food items ingested, the number of items ingested at this time step is added to the value at the previous time step. At the first step the counter is set to zero.

To update the cumulative count of food items not ingested, the number of items not ingested at this time step is added to the value at the previous time step. At the first step the counter is set to zero.

Definition at line 293 of file m_simulate.f90.

Here is the caller graph for this function:

◆ output_arrays_save_csv()

impure subroutine simulate::output_arrays_save_csv ( character(len=*), intent(in)  file_name,
logical, intent(in), optional  is_gui_dialog,
logical, intent(out), optional  is_write_error 
)

Save the model output arrays to a CSV data file.

Parameters
[in]file_nameThe name of the CSV file to save the data into.
[in]is_gui_dialogOptional indicator that error should report to GUI.
[out]is_write_errorOptional file error indicator flag, if TRUE, reports error
  • handle_csv is the CSV file handle object defining the file name, Fortran unit and error descriptor, see HEDTOOLS manual for details.
  • csv_record is the temporary character string that keeps the whole record of the file, i.e. the whole row of the spreadsheet table.
  • COLUMNS is a parameter array that keeps all column headers; its size is equal to the total number of variables (columns) in the data spreadsheet file.

Definition at line 374 of file m_simulate.f90.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ output_arrays_save_rate_data_csv()

impure subroutine simulate::output_arrays_save_rate_data_csv ( character(len=*), intent(in)  file_name,
logical, intent(in), optional  is_gui_dialog,
logical, intent(out), optional  is_write_error 
)

Save the rate data arrays to a CSV data file.

Parameters
[in]file_nameThe name of the CSV file to save the data into.
[in]is_gui_dialogOptional indicator that error should report to GUI.
[out]is_write_errorOptional file error indicator flag, if TRUE, reports error
  • handle_csv is the CSV file handle object defining the file name, Fortran unit and error descriptor, see HEDTOOLS manual for details.
  • csv_record is the temporary character string that keeps the whole record of the file, i.e. the whole row of the spreadsheet table.

Definition at line 506 of file m_simulate.f90.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ csv_file_error_report()

impure subroutine simulate::csv_file_error_report ( type(csv_file), intent(inout)  csv_handle,
logical, intent(in), optional  is_gui_dialog 
)

Report CSV file write error.

Parameters
[in]is_gui_dialogOptional indicator that error should report to GUI.

Definition at line 626 of file m_simulate.f90.

Here is the caller graph for this function:

◆ stomach_transport_save_csv()

impure subroutine simulate::stomach_transport_save_csv ( character(len=*), intent(in)  csv_file)

Save the stomach transport data pattern for a single food item.

Parameters
[in]csv_fileThe name of the CSV file is given as the argument.

Definition at line 638 of file m_simulate.f90.

◆ appetite_function_save_csv()

impure subroutine simulate::appetite_function_save_csv ( character(len=*), intent(in)  csv_file)

Save the appetite function the_fish::appetite_func() pattern for plotting, testing or analysis.

Parameters
[in]csv_fileThe name of the CSV file is given as the argument.

Definition at line 661 of file m_simulate.f90.

◆ model_output_stats_txt()

pure character(len=:) function, allocatable simulate::model_output_stats_txt

Produce a text string containing general model output statistics.

Note
Note that this procedure outputs table formatted data string for terminal output and visual inspection.

Definition at line 690 of file m_simulate.f90.

Here is the caller graph for this function:

◆ model_output_stats_row_csv()

character(len=:) function, allocatable simulate::model_output_stats_row_csv ( logical, intent(in), optional  show_header)

Produce a text string containing general model output statistics.

Note
Note that this procedure outputs CSV-formatted data string for saving in CSV output file. It does not write the csv output file.
Parameters
[in]show_headerOptional flag indicating that variable names header is included as the first line of the string

Definition at line 768 of file m_simulate.f90.

Here is the caller graph for this function:

◆ test_run()

impure subroutine simulate::test_run

The procedure below is TEMPORARY, for testing and debugging.

Maximum number of food items to show, this should never be greater than commondata::max_food_items_index.

  • Provide and schedule a food item
    • The fish decides to eat the food item scheduled
  • Update one time step of the fish stomach and mid-gut
  • Update the output arrays, use output_arrays_update_step().
  • Update the total count of food items eaten and not eaten

Definition at line 934 of file m_simulate.f90.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ init_provisioning()

impure subroutine simulate::init_provisioning ( integer(long), intent(in), optional  time_steps)

Initialise the food provisioning schedule / pattern.

Parameters
[in]time_stepsOptional overall number of time steps of the model
Note
Note that this argument has the integer type of the kind commondata::long. This might taint default integer values.
This procedure cannot be pure because it allocates a global module-scope array.

Definition at line 1251 of file m_simulate.f90.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_food_schedule_display()

impure integer function, dimension(:), allocatable simulate::get_food_schedule_display

Determine the food schedule array for separate display and analysis The primary role of this function is to plan (produce and display) the food provisioning pattern before simulation in GUI.

Definition at line 1299 of file m_simulate.f90.

◆ get_ingestion_ratio_waste()

real(srp) function, dimension(:), allocatable simulate::get_ingestion_ratio_waste ( integer, intent(in), optional  rate_unit)

calculate the array of the consumption ratio, i.e. eaten/provided, so it is also easy to calculate the waste rate

Parameters
[in]rate_unitOptional rate parameter, the rate is calculated per this number of seconds, the default is per minute

Definition at line 1324 of file m_simulate.f90.

Variable Documentation

◆ is_extended_logging_debug_test

logical, parameter simulate::is_extended_logging_debug_test = .FALSE.

Flag for extended/detailed debug logging.

Definition at line 26 of file m_simulate.f90.

◆ is_urinal_branchial_kj_day

logical, parameter, private simulate::is_urinal_branchial_kj_day = .TRUE.
private

Flag that defines how urinal and branchial energy loss (UE+ZE) is calculated for model output arrays. If TRUE, UE+ZE is computed in kJ per kg per day (default), otherwise, in O2 equivalent unit: mg O2 / kg/hour.

Definition at line 32 of file m_simulate.f90.

◆ gui_idx_progress

integer, public simulate::gui_idx_progress

Progress bar widget ID for the GUI mode, needed to update at runtime.

Definition at line 35 of file m_simulate.f90.

◆ output_arrays

type(output_arrays_step_def), dimension(:), allocatable, public simulate::output_arrays

output_arrays instantiates the global data structure that keeps the model output arrays.

Definition at line 96 of file m_simulate.f90.

◆ output_stats

type(output_stats_total_def) simulate::output_stats

output_stats instantiates non-array global data structure that keeps total model output statistics, that are not arrays by time step.

Definition at line 109 of file m_simulate.f90.