3 use iso_c_binding,
only : c_short, c_int, c_float, c_double
41 real (c_float),
allocatable ::
p_sat(:)
51 logical (c_bool),
intent(in) :: lactive(:,:)
52 real (c_float),
intent(in) :: fcanopy_cover_fraction(:)
53 integer (c_int),
intent(in) :: ilanduseindex(:)
56 integer (c_int) :: istat
58 integer (c_int) :: icount
59 integer (c_int) :: inumrecs
60 integer (c_int),
allocatable :: ilandusetablecodes(:)
61 integer (c_int) :: inumberoflanduses
62 logical (c_bool) :: larelengthsequal
63 real (c_float),
allocatable :: tempvals(:)
65 icount = count( lactive )
68 call assert( istat==0,
"Problem allocating memory.", __file__, __line__ )
73 call die(
"A EVAPORATION_TO_RAINFALL_RATIO grid must be supplied in order to" &
74 //
" make use of this option.", __file__, __line__)
87 call sllist%append(
"LU_Code" )
88 call sllist%append(
"Landuse_Lookup_Code" )
91 call params%get_parameters( slkeys=sllist, ivalues=ilandusetablecodes )
92 inumberoflanduses = count( ilandusetablecodes >= 0 )
95 call sllist%append(
"Canopy_Capacity")
96 call sllist%append(
"Canopy_Storage_Capacity")
100 call sllist%append(
"Trunk_Capacity")
101 call sllist%append(
"Trunk_Storage_Capacity")
105 call sllist%append(
"Stemflow_Fraction")
106 call sllist%append(
"Stemflow_Frac")
110 larelengthsequal = ( inumrecs == inumberoflanduses )
114 call sllist%append(
"interception_storage_max_growing")
115 call sllist%append(
"interception_storage_max_growing_season")
116 call sllist%append(
"interception_storage_maximum_growing")
118 call params%get_parameters( slkeys=sllist, &
123 larelengthsequal = ( inumrecs == inumberoflanduses )
125 if ( .not. larelengthsequal )
then
126 call warn( smessage=
"The number of landuses does not match the number of interception storage " &
127 //
"maximum values for the growing season" &
128 //
"('interception_storage_max_growing').", &
129 shints=
"A default value of 0.1 inches was assigned for the maximum interception storage", &
130 smodule=__file__, iline=__line__, lfatal=
false )
131 allocate(tempvals(inumberoflanduses), stat=istat)
139 call sllist%append(
"interception_storage_max_nongrowing")
140 call sllist%append(
"interception_storage_max_nongrowing_season")
141 call sllist%append(
"interception_storage_maximum_nongrowing")
143 call params%get_parameters( slkeys=sllist, &
148 larelengthsequal = ( inumrecs == inumberoflanduses )
150 if ( .not. larelengthsequal )
then
151 call warn( smessage=
"The number of landuses does not match the number of interception storage " &
152 //
"maximum values for the nongrowing season" &
153 //
"('interception_storage_max_nongrowing').", &
154 shints=
"A default value of 0.1 inches was assigned for the maximum interception storage", &
155 smodule=__file__, iline=__line__, lfatal=
false )
156 allocate(tempvals(inumberoflanduses), stat=istat)
171 larelengthsequal = ( inumrecs == inumberoflanduses )
173 if ( .not. larelengthsequal ) &
174 call warn( smessage=
"The number of trunk storage capacity values (" &
175 //
ascharacter( inumrecs )//
") does not match the number of landuse values (" &
177 smodule=__file__, iline=__line__, lfatal=.
true._c_bool )
181 larelengthsequal = ( inumrecs == inumberoflanduses )
183 if ( .not. larelengthsequal ) &
184 call warn( smessage=
"The number of stemflow fraction values (" &
185 //
ascharacter( inumrecs )//
") does not match the number of landuse values (" &
187 smodule=__file__, iline=__line__, lfatal=.
true._c_bool )
190 allocate(
p_sat( count( lactive ) ), stat=istat )
191 call assert( istat==0,
"Problem allocating memory for P_SAT.", __file__, __line__ )
195 fcanopy_cover_fraction )
204 real (c_float),
intent(in) :: e_div_p
205 real (c_float),
intent(in) :: canopy_storage_capacity
206 real (c_float),
intent(in) :: canopy_cover_fraction
207 real (c_float) :: psat
211 if ( canopy_cover_fraction > 0.0_c_float .and. canopy_storage_capacity > 0.0_c_float )
then
213 psat = - ( canopy_storage_capacity / ( canopy_cover_fraction * e_div_p ) ) &
214 * log( 1.0_c_float - e_div_p )
231 fTrunk_Storage_Capacity, fStemflow_Fraction, &
232 fEvaporation_to_Rainfall_Ratio, &
233 fPrecipitation_at_Saturation, fInterception )
235 real (c_float),
intent(in) :: frainfall
236 real (c_float),
intent(in) :: ffog
237 real (c_float),
intent(in) :: fcanopy_cover_fraction
238 real (c_float),
intent(in) :: ftrunk_storage_capacity
239 real (c_float),
intent(in) :: fstemflow_fraction
240 real (c_float),
intent(in) :: fevaporation_to_rainfall_ratio
241 real (c_float),
intent(in) :: fprecipitation_at_saturation
242 real (c_float),
intent(inout) :: finterception
245 real (c_float) :: frainfall_plus_fog
247 frainfall_plus_fog = frainfall + ffog
249 if ( fprecipitation_at_saturation .approxequal. 0.0_c_float )
then
251 finterception = 0.0_c_float
254 else if ( frainfall_plus_fog < fprecipitation_at_saturation )
then
257 finterception = fcanopy_cover_fraction * frainfall_plus_fog
260 else if ( frainfall_plus_fog > ftrunk_storage_capacity &
261 / (fstemflow_fraction + 1.0e-6) )
then
263 finterception = fcanopy_cover_fraction * fprecipitation_at_saturation &
264 + fcanopy_cover_fraction * fevaporation_to_rainfall_ratio &
265 * ( frainfall_plus_fog - fprecipitation_at_saturation ) &
266 + ftrunk_storage_capacity
275 finterception = fcanopy_cover_fraction * fprecipitation_at_saturation &
276 + fcanopy_cover_fraction * fevaporation_to_rainfall_ratio &
277 * ( frainfall_plus_fog - fprecipitation_at_saturation ) &
278 + fstemflow_fraction * frainfall_plus_fog
286 finterception = min( finterception, frainfall_plus_fog )
This module contains physical constants and convenience functions aimed at performing unit conversion...
logical(c_bool), parameter, public true
logical(c_bool), parameter, public false
Defines the DATA_CATALOG_T data type, which contains type-bound procedures to add,...
type(data_catalog_t), public dat
DAT is a global to hold data catalog entries.
subroutine, public warn(smessage, smodule, iline, shints, lfatal, iloglevel, lecho)
subroutine, public die(smessage, smodule, iline, shints, scalledby, icalledbyline)
Provides support for input and output of gridded ASCII data, as well as for creation and destruction ...
subroutine, public grid_writearcgrid(sfilename, pgrd)
elemental real(c_float) function, public precipitation_at_saturation(e_div_p, canopy_storage_capacity, canopy_cover_fraction)
real(c_float), dimension(:), allocatable, public stemflow_fraction_table_values
real(c_float), dimension(:), allocatable, public trunk_storage_capacity_table_values
real(c_float), dimension(:), allocatable, public evaporation_to_rainfall_ratio
subroutine, public interception_gash_initialize(lactive, fcanopy_cover_fraction, ilanduseindex)
Initialize the Gash interception algorithm.
real(c_float), dimension(:), allocatable, public gash_interception_storage_max_nongrowing_season
real(c_float), dimension(:), allocatable, public p_sat
real(c_float), dimension(:), allocatable, public canopy_storage_capacity_table_values
elemental subroutine, public interception_gash_calculate(frainfall, ffog, fcanopy_cover_fraction, ftrunk_storage_capacity, fstemflow_fraction, fevaporation_to_rainfall_ratio, fprecipitation_at_saturation, finterception)
real(c_float), dimension(:), allocatable, public gash_interception_storage_max_growing_season
type(data_catalog_entry_t), pointer pevaporation_to_rainfall_ratio
type(parameters_t), public params