16 use,
intrinsic :: iso_fortran_env, only : error_unit
35 "FishMet: the fish appetite and feeding model"
40 logical,
parameter,
public ::
is_debug = .true.
83 character,
parameter,
public ::
crlf = char(10)
90 =
"model_output_arrays"
362 real(srp),
allocatable,
dimension(:),
public :: &
403 integer(LONG),
allocatable,
dimension(:),
public :: &
445 real(srp),
dimension(:),
allocatable :: grid_mass
446 real(srp),
dimension(:),
allocatable :: grid_temperature
447 integer,
dimension(:,:),
allocatable :: emptying_time
725 real(srp),
parameter,
public ::
base_e = 2.7182818284590451_srp
744 [ 0.0_srp, 0.5_srp, 5.0_srp, 15.2_srp, 20.1_srp, 25.2_srp, 26.2_srp]
761 [38.0_srp, 38.0_srp, 40.6_srp, 67.8_srp, 94.6_srp, 136.7_srp, 145.9_srp]
812 module procedure sgr_r
813 module procedure sgr_i
835 use base_utils,
only: tostr
837 character(len=:),
allocatable :: message_show
839 character(len=500) :: msg_line
840 character(len=LABEL_LEN) :: yes_no_descr, f_min_s_descr, f_exist_descr
843 character(len=*),
parameter :: fmt_real=
"f9.3",fmt_rsrt=
"f8.2",fmt_int=
"I9"
844 character(len=*),
parameter :: fmt_real_lon=
"f14.3"
845 character(len=:),
allocatable :: fmtstr, label_stats
847 message_show =
crlf //
" GLOBAL PARAMETERS" //
crlf
849 fmtstr =
"(a,t56," // fmt_int //
")"
850 write(msg_line,fmtstr)
" Run duration, hours ('run_model_hours'): ", &
852 message_show = message_show //
crlf // trim(msg_line)
854 fmtstr =
"(a,t56," // fmt_int //
")"
855 write(msg_line,fmtstr)
" Day start offset, hours ('day_starts_hour'): ", &
857 message_show = message_show //
crlf // trim(msg_line)
859 fmtstr =
"(a,t56," // fmt_int //
")"
860 write(msg_line,fmtstr)
" Daytime duration, hours ('daytime_hours'): ", &
862 message_show = message_show //
crlf // trim(msg_line)
864 fmtstr =
"(a,t56," // fmt_real //
")"
865 write(msg_line,fmtstr)
" Temperature ('temperature'): ", &
867 message_show = message_show //
crlf // trim(msg_line)
869 fmtstr =
"(a,t56," // fmt_real //
")"
871 message_show = message_show //
crlf // trim(msg_line)
873 fmtstr =
"(a,t56," // fmt_real //
")"
874 write(msg_line,fmtstr)
" Stomach mass ('stomach_capacity'): ", &
876 message_show = message_show //
crlf // trim(msg_line)
878 fmtstr =
"(a,t56," // fmt_real //
")"
879 write(msg_line,fmtstr)
" Mid-gut mass ('midgut_capacity'): ", &
881 message_show = message_show //
crlf // trim(msg_line)
888 message_show = message_show //
crlf // &
889 " Stomach/midgut capacity auto (`stomach_midgut_automatic`): " // &
892 fmtstr =
"(a,t56," // fmt_real //
")"
893 write(msg_line,fmtstr)
" Absorption ratio ('absorption_ratio'): ", &
895 message_show = message_show //
crlf // trim(msg_line)
897 fmtstr =
"(a,t56," // fmt_int //
")"
898 write(msg_line,fmtstr)
" Delay after ingestion, min (ingestion_delay): ", &
900 message_show = message_show //
crlf // trim(msg_line)
902 fmtstr =
"(a,t56," // fmt_real //
")"
903 write(msg_line,fmtstr)
" Water Uptake ('water_uptake'): ", &
905 message_show = message_show //
crlf // trim(msg_line)
907 fmtstr =
"(a,t56," // fmt_real //
")"
908 write(msg_line,fmtstr)
" Water Uptake logistic a ('water_uptake_a'): ", &
910 message_show = message_show //
crlf // trim(msg_line)
912 fmtstr =
"(a,t56," // fmt_real //
")"
913 write(msg_line,fmtstr)
" Water Uptake logistic r ('water_uptake_r'): ", &
915 message_show = message_show //
crlf // trim(msg_line)
917 write(msg_line,
"(a)")
" Transport pattern in stomach " // &
918 "('transport_pattern_t','transport_pattern_r'):"
919 message_show = message_show //
crlf // trim(msg_line)
923 message_show = message_show //
crlf // trim(msg_line)
927 message_show = message_show //
crlf // trim(msg_line)
929 fmtstr =
"(a,t51," // fmt_real_lon //
")"
930 write(msg_line,fmtstr)
" Appetite logistic a ('appetite_factor_a'): ", &
932 message_show = message_show //
crlf // trim(msg_line)
934 fmtstr =
"(a,t56," // fmt_real //
")"
935 write(msg_line,fmtstr)
" Appetite logistic r ('appetite_factor_r'): ", &
937 message_show = message_show //
crlf // trim(msg_line)
939 fmtstr =
"(a,t56," // fmt_real //
")"
940 write(msg_line,fmtstr) &
941 " Appetite at night ('appetite_night'): ", &
943 message_show = message_show //
crlf // trim(msg_line)
945 fmtstr =
"(a,t56," // fmt_real //
")"
946 write(msg_line,fmtstr) &
947 " Appetite threshold ('appetite_threshold_stomach'): ", &
949 message_show = message_show //
crlf // trim(msg_line)
951 fmtstr =
"(a,t56," // fmt_real //
")"
952 write(msg_line,fmtstr) &
953 " Activity appetite factor ('activity_appetite_factor'): ",&
955 message_show = message_show //
crlf // trim(msg_line)
957 fmtstr =
"(a,t56," // fmt_int //
")"
958 write(msg_line,fmtstr)
" Digestion Delay, min ('digestion_delay'): ", &
960 message_show = message_show //
crlf // trim(msg_line)
962 fmtstr =
"(a,t56," // fmt_int //
")"
963 write(msg_line,fmtstr)
" Max. duration in mid-gut, h ('midgut_maxdur'): ",&
965 message_show = message_show //
crlf // trim(msg_line)
967 fmtstr =
"(a,t56," // fmt_real //
")"
968 write(msg_line,fmtstr) &
969 " Energy appetite steepness ('appetite_energy_rate'): ", &
971 message_show = message_show //
crlf // trim(msg_line)
973 fmtstr =
"(a,t56," // fmt_real //
")"
974 write(msg_line,fmtstr) &
975 " Energy appetite steepness ('appetite_energy_shift'): ", &
977 message_show = message_show //
crlf // trim(msg_line)
979 write(msg_line,
"(a)")
" Mid-gut Michaelis-Meneten absorption constants:"
980 message_show = message_show //
crlf // trim(msg_line)
982 fmtstr =
"(a,t56," //
"f9.7" //
")"
983 write(msg_line,fmtstr)
" r_max ('midgut_michaelis_r_max'): ", &
985 message_show = message_show //
crlf // trim(msg_line)
987 fmtstr =
"(a,t56," // fmt_real //
")"
988 write(msg_line,fmtstr)
" K_M ('midgut_michaelis_k'): ", &
990 message_show = message_show //
crlf // trim(msg_line)
992 write(msg_line,
"(a)")
" Michaelis-Meneten temperature adjustment grid:"
993 message_show = message_show //
crlf // trim(msg_line)
997 write(msg_line,fmtstr)
" 'midgut_temp_fact_t': ",
"[", &
999 message_show = message_show //
crlf // trim(msg_line)
1003 write(msg_line,fmtstr)
" 'midgut_temp_fact_m': ",
"[", &
1005 message_show = message_show //
crlf // trim(msg_line)
1007 write(msg_line,
"(a)")
" SMR function ('smr_oxygen_temp', 'smr_oxygen_o2'):"
1008 message_show = message_show //
crlf // trim(msg_line)
1013 message_show = message_show //
crlf // trim(msg_line)
1018 message_show = message_show //
crlf // trim(msg_line)
1021 fmtstr =
"(a,t56," // fmt_real //
")"
1022 write(msg_line,fmtstr) &
1023 " Branchial/urine ('branchial_ammonia_rate'): ", &
1025 message_show = message_show //
crlf // trim(msg_line)
1027 fmtstr =
"(a,t56," // fmt_real //
")"
1028 write(msg_line,fmtstr) &
1029 " Branchial/urine ('branchial_energy_factor'): ", &
1031 message_show = message_show //
crlf // trim(msg_line)
1034 fmtstr =
"(a,t57," //
"f8.6" //
")"
1035 write(msg_line,fmtstr) &
1036 " SDA absorp. ('sda_absorption_rate_max'): ", &
1038 message_show = message_show //
crlf // trim(msg_line)
1040 fmtstr =
"(a,t56," // fmt_real //
")"
1041 write(msg_line,fmtstr) &
1042 " SDA max level ('sda_energy_factor_max'): ", &
1044 message_show = message_show //
crlf // trim(msg_line)
1046 fmtstr =
"(a,t56," // fmt_real //
")"
1047 write(msg_line,fmtstr) &
1048 " Baseline day activity ('baseline_activity_day'): ", &
1050 message_show = message_show //
crlf // trim(msg_line)
1052 fmtstr =
"(a,t56," // fmt_real //
")"
1053 write(msg_line,fmtstr) &
1054 " Baseline night activity ('baseline_activity_night'): ",&
1056 message_show = message_show //
crlf // trim(msg_line)
1058 fmtstr =
"(a,t56," //
"f9.4" //
")"
1059 write(msg_line,fmtstr)
" Food item mass ('food_item_mass'): ", &
1061 message_show = message_show //
crlf // trim(msg_line)
1063 fmtstr =
"(a,t40," // fmt_real //
",a," //
"I3" //
",a)"
1064 write(msg_line,fmtstr)
" Food input rate ('food_input_rate'): ", &
1067 message_show = message_show //
crlf // trim(msg_line)
1074 write(msg_line,fmtstr)
" Food scheduling ('food_provision_pattern'): ", &
1076 message_show = message_show //
crlf // trim(msg_line)
1078 fmtstr =
"(a,t56," // fmt_int //
")"
1079 write(msg_line,fmtstr)
" Offset to start feeding, min " // &
1081 message_show = message_show //
crlf // trim(msg_line)
1086 yes_no_descr =
" all 24h periods)"
1088 yes_no_descr =
" apply once)"
1092 f_min_s_descr =
" (by s"
1094 f_min_s_descr =
" (by min"
1102 f_exist_descr =
" NO FILE"
1105 write(msg_line,
"(5a)")
" Food provision scheduling from file: ", &
1107 trim(yes_no_descr), trim(f_exist_descr)
1108 message_show = message_show //
crlf // trim(msg_line)
1110 if ( .not. is_okay )
then
1113 write(msg_line,fmtstr)
" Food provisioning schedule: ",
"[", &
1115 message_show = message_show //
crlf // trim(msg_line)
1117 fmtstr =
"(a,t30," // fmt_int //
")"
1118 write(msg_line,fmtstr)
" Offset to start feeding, min:", &
1120 message_show = message_show //
crlf // trim(msg_line)
1126 write(msg_line,
"(a)")
" Stress parameters:"
1127 message_show = message_show //
crlf // trim(msg_line)
1129 fmtstr =
"(a,t56," // fmt_real //
")"
1130 write(msg_line,fmtstr)
" 'stress_metabolic_cost': ", &
1132 message_show = message_show //
crlf // trim(msg_line)
1134 fmtstr =
"(a,t56," // fmt_real //
")"
1135 write(msg_line,fmtstr)
" 'stress_inactivity': ", &
1137 message_show = message_show //
crlf // trim(msg_line)
1142 write(msg_line,fmtstr)
" 'stress' (min): ",
"[", &
1145 write(msg_line,fmtstr)
" 'stress' (s): ",
"[", &
1148 message_show = message_show //
crlf // trim(msg_line)
1152 write(msg_line,fmtstr)
" 'stress_grid_hour: ",
"[", &
1154 message_show = message_show //
crlf // trim(msg_line)
1158 write(msg_line,fmtstr)
" 'stress_grid_fact: ",
"[", &
1160 message_show = message_show //
crlf // trim(msg_line)
1163 message_show = message_show //
crlf
1165 message_show = message_show //
crlf //
" Config file: '" // &
1168 message_show = message_show //
crlf // &
1169 " Output destination ('output_dest'): '" // &
1173 label_stats =
" [long]"
1175 label_stats =
" [short]"
1178 message_show = message_show //
crlf //
" Global output stats file: '" // &
1181 if (
is_debug)
write(msg_line,
"(a)")
" Running in the DEBUG mode;"
1182 message_show = message_show //
crlf //
crlf // trim(msg_line)
1186 message_show = message_show // trim(msg_line)
1188 message_show = message_show //
crlf
1196 logical :: is_enabled
1204 is_enabled = .false.
1214 real(srp),
intent(in) :: x
1215 real(srp),
intent(in) :: a
1216 real(srp),
intent(in) :: c
1217 real(srp),
intent(in) :: r
1220 y = c / ( 1.0_srp + a *
base_e **(-r*x) )
1237 real(srp),
intent(in) :: x
1239 real(srp),
intent(in) :: r_max
1241 real(srp),
intent(in) :: x50
1245 r = r_max * x / (x50 + x)
1255 use base_utils,
only : cspline_scalar
1256 real(srp),
optional,
intent(in) :: temperature
1259 real(srp) :: temp_loc
1261 if (
present(temperature))
then
1262 temp_loc = temperature
1276 is_adjust_water_uptake, water_uptake)
result (energy)
1278 real(srp),
intent(in) :: feed_mass
1280 real(srp),
intent(in),
optional :: gross_energy
1286 logical,
intent(in),
optional :: is_adjust_water_uptake
1289 real(srp),
intent(in),
optional :: water_uptake
1293 logical:: is_adjust_loc
1294 real(srp) :: water_uptake_loc
1296 if (
present(is_adjust_water_uptake))
then
1297 is_adjust_loc = is_adjust_water_uptake
1299 is_adjust_loc = .true.
1302 if (
present(water_uptake))
then
1303 water_uptake_loc = water_uptake
1309 if (
present(gross_energy))
then
1310 energy = feed_mass * gross_energy
1317 if (is_adjust_loc)
then
1318 energy = energy - energy * water_uptake_loc
1327 real(srp),
intent(in) :: l_o2
1329 real(srp) :: energy_kj
1331 energy_kj = 19.4_srp * l_o2
1338 elemental function o2mass(vol_l)
result (mass_g)
1340 real(srp),
intent(in) :: vol_l
1343 real(srp),
parameter :: ratio = 32.0_srp / 22.4_srp
1345 mass_g = ratio * vol_l
1350 elemental function o2vol(mass_g)
result (vol_l)
1352 real(srp),
intent(in) :: mass_g
1355 real(srp),
parameter :: ratio = 22.4_srp / 32.0_srp
1357 vol_l = mass_g * ratio
1365 real(srp),
optional,
intent(in) :: rate_min
1367 integer(LONG) :: n_sec
1369 real(srp) :: rate_min_loc
1371 if (
present(rate_min))
then
1372 rate_min_loc = rate_min
1385 n_sec = nint(
minute/rate_min_loc, long )
1397 integer,
dimension(:),
intent(in) :: inarray
1400 integer,
intent(in),
optional :: rate_unit
1402 real(srp),
dimension(:),
allocatable :: rate_out
1404 integer :: rate_unit_loc, oarray_max, sum_rate, i, j
1406 if (
present(rate_unit))
then
1407 rate_unit_loc = rate_unit
1412 oarray_max =
size(inarray)
1413 allocate( rate_out(oarray_max/rate_unit_loc) )
1416 sum_rate = inarray(1)
1419 if( inarray(i) > inarray(i-1) )
then
1420 sum_rate = sum_rate + inarray(i) - inarray(i-1)
1422 if (mod(i,rate_unit_loc)==0)
then
1424 rate_out(j) = real(sum_rate,srp) / real(rate_unit_loc,srp)
1438 real(srp),
dimension(:),
intent(in) :: inarray
1441 integer,
intent(in),
optional :: rate_unit
1443 real(srp),
dimension(:),
allocatable :: rate_out
1445 integer :: rate_unit_loc, oarray_max, i, j
1447 real(srp) :: sum_rate
1449 if (
present(rate_unit))
then
1450 rate_unit_loc = rate_unit
1455 oarray_max =
size(inarray)
1456 allocate( rate_out(oarray_max/rate_unit_loc) )
1459 sum_rate = inarray(1)
1462 if( inarray(i) > inarray(i-1) )
then
1463 sum_rate = sum_rate + inarray(i) - inarray(i-1)
1465 if (mod(i,rate_unit_loc)==0)
then
1467 rate_out(j) = sum_rate / real(rate_unit_loc,srp)
1478 pure function blockrate ( inarray, rate_unit )
result (rate_out)
1480 real(srp),
dimension(:),
intent(in) :: inarray
1483 integer,
intent(in),
optional :: rate_unit
1485 real(srp),
dimension(:),
allocatable :: rate_out
1487 integer :: rate_unit_loc, iarray_max, i, j
1488 real(srp) :: iarray_block_start, iarray_block_end
1490 if (
present(rate_unit))
then
1491 rate_unit_loc = rate_unit
1496 iarray_max =
size(inarray)
1497 allocate( rate_out(iarray_max/rate_unit_loc) )
1500 iarray_block_start = inarray(1)
1501 do i = 2, iarray_max
1502 if ( mod(i,rate_unit_loc)==0 )
then
1503 iarray_block_end = inarray(i)
1504 rate_out(j) = (iarray_block_end - iarray_block_start) / &
1505 real(rate_unit_loc,srp)
1506 iarray_block_start = inarray(i)
1520 real(srp),
dimension(:),
intent(in) :: inarray
1523 integer,
intent(in),
optional :: rate_unit
1525 integer,
optional,
intent(in) :: time_unit
1526 real(srp),
dimension(:),
allocatable :: rate_out
1528 integer :: rate_unit_loc, iarray_max, i, j
1529 integer :: time_unit_loc
1530 real(srp) :: iarray_block_start, iarray_block_end
1532 if (
present(rate_unit))
then
1533 rate_unit_loc = rate_unit
1538 if (
present(time_unit))
then
1539 time_unit_loc = time_unit
1544 iarray_max =
size(inarray)
1545 allocate( rate_out(iarray_max/rate_unit_loc) )
1548 iarray_block_start = inarray(1)
1549 do i = 2, iarray_max
1550 if ( mod(i,rate_unit_loc)==0 )
then
1551 iarray_block_end = inarray(i)
1552 rate_out(j) =
sgr_i( iarray_block_end, iarray_block_start, &
1553 rate_unit_loc, 0, time_unit_loc)
1554 iarray_block_start = inarray(i)
1576 integer,
dimension(:),
intent(inout) :: history_array
1578 integer,
intent(in) :: add_this
1581 integer :: history_size
1583 history_size =
size(history_array)
1585 history_array = cshift(history_array,1)
1586 history_array(history_size) = add_this
1601 real(srp),
dimension(:),
intent(inout) :: history_array
1603 real(srp),
intent(in) :: add_this
1606 integer :: history_size
1608 history_size =
size(history_array)
1610 history_array = cshift(history_array,1)
1611 history_array(history_size) = add_this
1625 character(*),
dimension(:),
intent(inout) :: history_array
1627 character(*),
intent(in) :: add_this
1630 integer :: history_size
1632 history_size =
size(history_array)
1634 history_array = cshift(history_array,1)
1635 history_array(history_size) = add_this
1642 real(srp),
dimension(:),
intent(in) :: history_array
1643 integer,
optional,
intent(in) :: offset
1644 real(srp) :: last_value
1646 integer :: offset_loc
1648 if (
present(offset))
then
1651 if (offset_loc >
size(history_array)-1)
then
1652 offset_loc =
size(history_array)-1
1653 else if (offset_loc < 0)
then
1660 last_value = history_array(
size(history_array)-offset_loc )
1667 integer,
dimension(:),
intent(in) :: history_array
1668 integer,
optional,
intent(in) :: offset
1669 integer :: last_value
1671 integer :: offset_loc
1673 if (
present(offset))
then
1676 if (offset_loc >
size(history_array)-1)
then
1677 offset_loc =
size(history_array)-1
1678 else if (offset_loc < 0)
then
1685 last_value = history_array(
size(history_array)-offset_loc )
1692 character(*),
dimension(:),
intent(in) :: history_array
1693 integer,
optional,
intent(in) :: offset
1694 character(len=:),
allocatable :: last_value
1696 integer :: offset_loc
1698 if (
present(offset))
then
1701 if (offset_loc >
size(history_array)-1)
then
1702 offset_loc =
size(history_array)-1
1703 else if (offset_loc < 0)
then
1710 last_value = history_array(
size(history_array)-offset_loc )
1726 elemental function within_r(value_in, vmin, vmax)
result (value_out)
1727 real(srp),
intent(in) :: value_in
1728 real(srp),
optional,
intent(in) :: vmin
1729 real(srp),
intent(in) :: vmax
1730 real(srp) :: value_out
1733 real(srp) :: vmin_here
1736 if (
present(vmin))
then
1742 value_out = min( max( value_in, vmin_here ), vmax )
1758 elemental function within_i(value_in, vmin, vmax)
result (value_out)
1759 integer,
intent(in) :: value_in
1760 integer,
optional,
intent(in) :: vmin
1761 integer,
intent(in) :: vmax
1762 integer :: value_out
1765 integer :: vmin_here
1768 if (
present(vmin))
then
1775 value_out = min( max( value_in, vmin_here ), vmax )
1806 use base_utils,
only : cspline
1808 real(srp),
dimension(:),
intent(in) :: temperature
1811 real(srp),
allocatable,
dimension(:) :: o2rate
1813 real(srp),
dimension( size(temperature) ) :: outval
1816 temperature, outval )
1849 use base_utils,
only : cspline_scalar
1851 real(srp),
intent(in) :: temperature
1862 elemental function fcr(input_f, output_m)
result (fcr_out)
1864 real(srp),
intent(in) :: input_f
1866 real(srp),
intent(in) :: output_m
1868 real(srp) :: fcr_out
1870 fcr_out = input_f / output_m
1875 elemental function kg2g(kg)
result (g)
1876 real(srp),
intent(in) :: kg
1884 elemental function g2kg(g)
result (kg)
1885 real(srp),
intent(in) :: g
1893 elemental function kg2mg(kg)
result (mg)
1894 real(srp),
intent(in) :: kg
1897 mg = 1000000.0_srp * kg
1902 elemental function mg2kg(mg)
result (kg)
1903 real(srp),
intent(in) :: mg
1906 kg = mg / 1000000.0_srp
1911 elemental function mg2g(mg)
result (g)
1912 real(srp),
intent(in) :: mg
1920 elemental function g2mg(g)
result (mg)
1921 real(srp),
intent(in) :: g
1931 real(srp),
intent(in) :: mu_unit
1934 unit = mu_unit * 0.000001_srp
1942 elemental function sgr_r( weight1, weight2, time1, time2 )
result (sgr_out)
1944 real(srp),
intent(in) :: weight1
1946 real(srp),
intent(in) :: weight2
1948 real(srp),
intent(in) :: time1
1950 real(srp),
intent(in) :: time2
1951 real(srp) :: sgr_out
1953 sgr_out = ( exp( ( log(weight2) - log(weight1) ) / &
1954 ( time2 - time1) ) - 1 ) * 100.0_srp
1963 elemental function sgr_i(weight1, weight2, time1, time2, time_unit) &
1966 real(srp),
intent(in) :: weight1
1968 real(srp),
intent(in) :: weight2
1970 integer,
intent(in) :: time1
1972 integer,
intent(in) :: time2
1981 integer,
optional,
intent(in) :: time_unit
1982 real(srp) :: sgr_out
1984 integer :: time_unit_loc
1986 if (
present(time_unit))
then
1987 time_unit_loc = time_unit
1992 if ( time_unit_loc > 1 )
then
1993 sgr_out=
sgr_r(weight1, weight2, real(time1,srp)/real(time_unit_loc,srp),&
1994 real(time2,srp)/
real(time_unit_loc,SRP) )
1996 sgr_out=
sgr_r(weight1, weight2, real(time1,srp), real(time2,srp) )
2007 real(srp),
parameter,
dimension(*) :: &
2008 mass_grid = [ 50.0_srp, 100.0_srp, 300.0_srp, 500.0_srp ]
2010 real(srp),
parameter,
dimension(*) :: &
2011 temp_grid = [ 5.0_srp, 10.0_srp, 15.0_srp, 20.0_srp, 22.0_srp ]
2013 integer,
parameter :: levels_mass = size(mass_grid), &
2014 levels_temp =
size(temp_grid)
2016 integer,
parameter,
dimension(LEVELS_MASS, LEVELS_TEMP) :: &
2017 emptying_grid_hour = reshape ( &
2028 [levels_mass, levels_temp], [0], [1,2] )
2033 pattern_def%grid_mass = mass_grid
2034 pattern_def%grid_temperature = temp_grid
2035 pattern_def%emptying_time = emptying_grid_hour *
hour
2041 character(len=:),
allocatable :: message_show
2042 logical,
optional,
intent(in) :: is_raw_s
2046 character(len=50) :: msg
2047 character(len=*),
parameter :: fmt_real=
"f9.2", colsep=
" |", &
2049 integer :: fmt_len = 9
2050 character(len=:),
allocatable :: fmtstr, fmtint
2052 if (
present(is_raw_s))
then
2053 is_raw_loc = is_raw_s
2055 is_raw_loc = .false.
2058 fmtstr =
"(" // fmt_real //
")"
2059 fmtint =
"(" // fmt_int //
")"
2062 message_show =
"Stomach emptying time (h) parameter matrix:" //
crlf
2065 message_show = message_show //
" " // colsep // &
2066 " BODY MASS:" //
crlf
2069 message_show = message_show //
" TEMP" // colsep
2072 message_show = message_show // trim(msg)
2075 message_show = message_show //
crlf // repeat(
"-",fmt_len) //
"--+" // &
2082 message_show = message_show // trim(msg) // colsep
2085 if (is_raw_loc)
then
2091 message_show = message_show // trim(msg)
2093 message_show = message_show //
crlf
2103 use base_utils,
only: tostr
2104 use base_strings,
only: uppercase
2105 character(len=:),
allocatable :: txt_out
2108 real(srp),
optional,
intent(in) :: adjust
2111 character(len=*),
optional,
intent(in) :: format
2114 character(len=*),
optional,
intent(in) :: show
2116 character(len=*),
optional,
intent(in) :: prefix
2122 real(srp),
dimension( size(Global_Transport_Pattern_R) ) :: stpr
2123 integer,
dimension( size(Global_Transport_Pattern_T) ) :: stpt
2124 real(srp) :: adjust_loc
2125 character(len=*),
parameter :: fmtstr =
"(f6.2)"
2127 character(len=:),
allocatable :: sep_l, sep_r, &
2130 if (
present(adjust))
then
2133 adjust_loc = 1.0_srp
2136 if (
present(format))
then
2137 if (uppercase(format)==
"R")
then
2140 elseif (uppercase(format)==
"PYTHON")
then
2149 if (
present(show))
then
2151 if (uppercase(show)==
"TRANSPORT_PATTERN_T")
then
2154 elseif (uppercase(show)==
"TRANSPORT_PATTERN_R")
then
2157 elseif (uppercase(show)==
"BOTH")
then
2165 if (
present(prefix))
then
2176 txt_out = prefl //
"transport_pattern_t = " // sep_l
2178 do i=1,
size(stpt)-1
2179 txt_out = txt_out // tostr(stpt(i)) //
", "
2181 txt_out = txt_out // tostr(stpt(
size(stpt)))
2183 txt_out = txt_out // sep_r
2193 txt_out = txt_out // prefl //
"transport_pattern_r = " // sep_l
2195 do i=1,
size(stpr)-1
2196 txt_out = txt_out // tostr(stpr(i),fmtstr) //
", "
2198 txt_out = txt_out // tostr(stpr(
size(stpr)),fmtstr)
2200 txt_out = txt_out // sep_r
Simple history stack function, add to the end of the stack. We need only to add components on top (en...
Public interface for the cum2rate function that calculates rate from raw cumulative array....
Return the last element of a history array with optional offset.
Function calculating standard oxygen consumption in rainbow trout based on the curve from Fig....
Function for calculating specific growth rate.
Force a value within the range set by the vmin and vmax dummy parameter values.
This module defines global parameters and general-level computational utilities.
elemental real(srp) function mg2kg(mg)
Convert mg to kg.
character(len=1), parameter, public prog_bar_char
The symbol used for writing the progress bar in text mode.
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...
pure logical function is_stress()
Calculate if stress factor grid is enabled. Stress is disabled if any of the stress parameters are no...
logical, public global_stress_intervention_is_minutes
Global logical flag setting the time unit for the stress intervention parameter array defined by glob...
character(len= *), parameter, public output_dest_dir
Default output directory: all plot and data file will be saved into this directory by default (local ...
integer, dimension(:), allocatable, public global_transport_pattern_t
Food transport in stomach: Time grid array for interpolation. Configuration file example:
real(srp), public global_food_input_rate
Standard rate of food item input, per minute. Configuration file example:
pure real(srp) function, dimension(:), allocatable blockrate(inarray, rate_unit)
Calculate rate based on simple block data, only the block start and end values are considered.
elemental real(srp) function g2kg(g)
Convert g to kg.
elemental real(srp) function midgut_temp_factor(temperature)
Calculate temperature adjustment factor for the Michaelis-Menten absorption process in the midgut....
character(len= *), parameter, public svn_version_global
real(srp), public global_food_item_mass
Standard mass of one food item. Configuration file example:
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...
real(srp), public global_feeding_activity_factor
Locomotor activity multiplier factor for the activity during the feeding time, i.e....
real(srp), public global_water_uptake_a
Parameters of the logistic water uptake function that defines the temporary pattern of water uptake c...
impure character(len=:) function, allocatable stomach_transport_txt(adjust, format, show, prefix)
Produce a formatted text string containing the adjusted stomach transport arrays commondata::global_t...
real(srp), public global_baseline_activity_day
Global baseline locomotor activity pattern (swimming speed) for each time step consists of two compon...
integer, dimension(2), public global_interval_food_param
Parameters of the food provisioning pattern:
elemental real(srp) function o2vol(mass_g)
Calculate the volume of 1 dm3 (l) of oxygen.
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...
elemental real(srp) function, private sgr_i(weight1, weight2, time1, time2, time_unit)
Calculates specific growth rate following Houde & Schekter (1981):
character(len= *), parameter, public def_stats_output_file
Default value of the general simulation statistics file defined in commondata::global_stats_output_fi...
real(srp), public global_midgut_mass
Fish mid-gut mass capacity, max. filling capacity. Configuration file example:
integer, public global_day_starts_hour
Default hour at which the "daytime" is normally started. This means, in particular,...
elemental integer function, private within_i(value_in, vmin, vmax)
Force a value within the range set by the vmin and vmax dummy parameter values. If the value is withi...
real(srp), public global_appetite_fish_night
Fish appetite at night. This value is normally low because the fish do not feed at night....
real(srp), public global_sda_absorp_rate_max
Defines the specific dynamic action (SDA) that depends on the absorption rate. There are two paramete...
character(len= *), parameter, public output_arrays_csv_file
Default file base-name for saving model output arrays.
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() ...
logical, public global_stomach_midgut_mass_is_automatic
Logical flag that specifies that the stomach and midgut mass (capacity) are automatically recalculate...
integer, public global_transport_dim
Food transport in stomach: Dimensionality of the transport pattern in the stomach.
integer, public global_run_model_hours
Default duration of the model run in hours. Note that parameter file uses hours as unit....
pure real(srp) function, private oxygen_rate_std_ddpi(temperature)
Function calculating standard oxygen consumption in rainbow trout based on the empirical curve define...
real(srp), public global_body_mass
Fish body mass, g, at the start of the simulation Configuration file example:
type(stomach_emptying_pattern), public global_stomach_emptying_pattern
Default stomach emptying pattern.
elemental real(srp) function michaelis_menten(x, r_max, x50)
Michaelis-Meneten function:
logical, parameter, public is_debug
Logical flag that sets the DEBUG mode. When the program is running in the DEBUG mode,...
real(srp), public global_mid_gut_mm_k_m
Michaelis-Meneten food absorption parameter in mid-gut, (see the_fish::michaelis_menten()) relative ...
character(len= *), parameter, public output_rate_data_csv_file
Default file base-name for saving model rate data.
pure real(srp) function, dimension(:), allocatable cum2rate_int(inarray, rate_unit)
Given an in put array of cumulative sum, this function calculates the rate per unit time defined by t...
elemental real(srp) function, private within_r(value_in, vmin, vmax)
Force a value within the range set by the vmin and vmax dummy parameter values. If the value is withi...
real(srp), public global_ue_ze_ammonia_excretion
A parameter defining branchial and urine (ZE+UE) energy consumption as a fixed ammonia excretion rate...
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...
integer, parameter, public file_name_len
The default length of the file name.
real(srp), public global_stress_activity_decr
Maximum value of the suppressive effect of stress on baseline activity. The actual suppression of the...
elemental real(srp) function energy_o2(l_o2)
Calculate the enegretic equivalent (kJ) of Oxygen uptake (l O2) Source: Rønnestad B291.
elemental real(srp) function kg2g(kg)
Convert kg to g.
integer, public global_run_model_feed_offset
The offset (delay) to start feeding at the beginning of the simulation, Note that the parameter file ...
real(srp), public global_stomach_mass
Fish stomach mass, max. filling capacity. Configuration file example:
real(srp), public global_baseline_activity_night
impure character(len=:) function, allocatable model_parameters_txt()
Produce a text string containing all global parameters of the model.
logical, parameter, public is_progress_bar_gui
Global parameter defining if progress bar is printed in the GUI mode.
integer, parameter, public minute
pure subroutine, private add_to_history_char(history_array, add_this)
Simple history stack function, add to the end of the stack. We need only to add components on top of ...
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...
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 ...
real(srp), public global_stress_cost_smr
Maximum value of the metabolic cost of stress in units of resting metabolic rate (SMR)....
real(srp), public global_absorption_ratio
Maximum absorption ratio relative to the original dry food item mass. Configuration file example:
elemental real(srp) function from_micro(mu_unit)
Convert micro (\mu) unit to unit, e.g. from micro mol to mol Metric prefix micro = 10^-6: unit x 0....
real(srp), dimension(*), parameter trout_oxygen_grid_x_temp
Interpolation grid defining the function calculating standard oxygen consumption in rainbow trout bas...
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...
logical, parameter, public is_stress_enable
Compile-time logical flag that defines if stress effects described by global_stress_factor_hour,...
integer, public global_ingestion_delay_min
Delay of ingestion, min.
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...
pure real(srp) function, dimension(:), allocatable, private sgr_blockrate(inarray, rate_unit, time_unit)
Calculate an array of specific growth rate rate values based on simple block data,...
integer, parameter, public hour
Global time constants, number of sec in hour and min.
pure real(srp) function, private last_in_history_r(history_array, offset)
Return the last value in the array. Note that this function is especially useful for long nested obje...
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...
pure subroutine, private add_to_history_r(history_array, add_this)
Simple history stack function, add to the end of the stack. We need only to add components on top of ...
real(srp), public global_appetite_stomach_threshold
Protective appetite threshold for stomach: this is the maximum value of the the_fish::stomach::appeti...
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...
character(len= *), parameter, public txt_sec
Time scale abbreviation strings for Y axes of output plots.
elemental real(srp) function mg2g(mg)
Convert mg to g.
real(srp), public global_transport_baseline_fish_mass
The baseline fish mass that applies to the stomach transport pattern defined by global_transport_patt...
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...
elemental real(srp) function feed_energy(feed_mass, gross_energy, is_adjust_water_uptake, water_uptake)
Calculate the energy content of a feed mass.
real(srp), public global_food_gross_energy
Gross energy content of the feed, MJ/kg (=kJ7g) Configuration file example:
real(srp), parameter, public base_e
Natural logarithm base, e
logical, public global_output_stats_is_long
Define if the output stats are saved using the long or short format. In the first case,...
character(len= *), parameter, public program_title
Program title that appears on the main interface/window.
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...
integer, parameter, public gui_progress_bar_steps
Number of steps in the progress bar at the GUI mode.
elemental real(srp) function kg2mg(kg)
Convert kg to mg.
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...
integer, parameter, public label_len
The default length of labels and similar text strings.
logical, public global_is_ue_ze_fixed_rate
Logical flag to choose how branchial and urinal (ZE+UE) energy loss is calculated.
real(srp), parameter, public debug_warn_level
Warning level in the debugging mode.
integer, parameter, public minimum_filename_chars
The minimum length of a data file. Note that cancelled file name dialog returns a six-char random seq...
real(srp), public global_temperature
Ambient temperature Configuration file example:
real(srp), parameter, public min_mass_toler
Minimum mass of food item that counts as non-zero, a tolerance limit.
real(srp), public global_sda_factor_max
Defines the specific dynamic action (SDA) that depends on the absorption rate. There are two paramete...
integer, parameter, public prog_bar_len
The length of the progress bar in text mode.
elemental real(srp) function fcr(input_f, output_m)
Function to calculate the FCR, feed conversion rate .
integer, public global_rate_interval
Default rate discretization interval in minutes, this interval is used to plot the ingestion rate.
elemental real(srp) function g2mg(g)
Convert g to mg.
real(srp), public global_mid_gut_mm_r_max
Michaelis-Meneten food absorption parameter in mid-gut, (see the_fish::michaelis_menten()) relative ...
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)...
pure real(srp) function, dimension(:), allocatable, private oxygen_rate_std_spline(temperature)
Function calculating standard oxygen consumption in rainbow trout based on the empirical curve define...
real(srp), public global_appetite_activity_factor
Activity appetite factor determining how fish locomotor activity increases with increasing appetite....
pure subroutine, private add_to_history_i4(history_array, add_this)
Simple history stack function, add to the end of the stack. We need only to add components on top of ...
real(srp), public global_energy_appetite_rate
The steepness parameter of the Logistic energy component of appetite.
integer(long), public global_time_step
Global variable that defines the current time step.
integer, parameter, public gui_progress_bar_max
Maximum value (steps) in the progress bar (minimum is 0)
character(len= *), parameter, public txt_hour
pure real(srp) function, dimension(:), allocatable cum2rate_r(inarray, rate_unit)
Given an in put array of cumulative sum, this function calculates the rate per unit time defined by t...
real(srp), public global_appetite_logist_r
Logistic function parameter R for the appetite factor. See the_fish::appetite_func().
logical, dimension(:), allocatable, public global_interval_food_pattern
Global food provisioning pattern, logical TRUE/FALSE for each time step.
character, parameter, public crlf
real(srp), public global_energy_appetite_shift
The shift parameter of the Logistic energy component of appetite.
real(srp), public global_appetite_logist_a
Logistic function parameter A for the appetite factor. See the_fish::appetite_func().
pure integer function, private last_in_history_i4(history_array, offset)
Return the last value in the array. Note that this function is especially useful for long nested obje...
elemental integer(long) function rate2int(rate_min)
The function converts rate per min to interval in seconds.
pure character(len=:) function, allocatable, private last_in_history_char(history_array, offset)
Return the last value in the array. Note that this function is especially useful for long nested obje...
elemental real(srp) function, private sgr_r(weight1, weight2, time1, time2)
Calculates specific growth rate following Houde & Schekter (1981):
logical, public verbose
Global logical flag to suppress extra text diagnostics and messages, the "quiet mode" or the "verbose...
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 ...
real(srp), dimension(:), allocatable, public global_transport_pattern_r
Food transport in stomach: Proportion of food mass left in stomach. Configuration file example:
integer, public global_hours_daytime_feeding
Default duration of the day time in hours, night duration is defined as 24 - ::global_hours_day_feedi...
real(srp), public global_water_uptake_r
Parameters of the logistic water uptake function that defines the temporary pattern of water uptake c...
real(srp), public global_ue_ze_factor
A parameter defining branchial and urine (ZE+UE) energy consumption as a factor to SMR,...
impure character(len=:) function, allocatable stomach_emptying_txt(is_raw_s)
Show the stomach emptying data structure.
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...
character(len= *), parameter, public txt_min
elemental real(srp) function o2mass(vol_l)
Calculate the mass of 1 dm3 (l) of Oxygen.
integer, parameter, public max_food_items_index
Maximum number of food items in the fish stomach, this is the maximum index for the food items array ...
real(srp), public global_transport_baseline_temperature
The baseline temperature that applies to the stomach transport pattern defined by global_transport_pa...
elemental real(srp) function logistic(X, A, C, R)
Logistic function is defined by the equation.
integer, parameter, public max_points_plot
The maximum number of data points that are plotted for the model output arrays (squeezed arrays).
real(srp), dimension(*), parameter trout_oxygen_grid_y_o2std
Interpolation grid defining the function calculating standard oxygen consumption in rainbow trout bas...
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...
real(srp), public global_water_uptake
Proportion of water uptake, relative of dry mass of the food item. Configuration file example:
A data structure that defines the stomach emptying pattern as dependent on the temperature and the fi...