3 use iso_c_binding,
only : c_short, c_int, c_float, c_double
42 real (c_float),
allocatable ::
p_sat(:)
54 logical (c_bool),
intent(in) :: lactive(:,:)
55 real (c_float),
intent(in) :: fcanopy_cover_fraction(:)
56 integer (c_int),
intent(in) :: ilanduseindex(:)
59 integer (c_int) :: istat
61 integer (c_int) :: iindex
62 integer (c_int) :: icount
63 integer (c_int) :: inumrecs
64 integer (c_int),
allocatable :: ilandusetablecodes(:)
65 integer (c_int) :: inumberoflanduses
66 logical (c_bool) :: larelengthsequal
67 real (c_float),
allocatable :: tempvals(:)
69 icount = count( lactive )
72 call assert( istat==0,
"Problem allocating memory.", __file__, __line__ )
77 call die(
"A EVAPORATION_TO_RAINFALL_RATIO grid must be supplied in order to" &
78 //
" make use of this option.", __file__, __line__)
91 call sllist%append(
"LU_Code" )
92 call sllist%append(
"Landuse_Lookup_Code" )
95 call params%get_parameters( slkeys=sllist, ivalues=ilandusetablecodes )
96 inumberoflanduses = count( ilandusetablecodes >= 0 )
99 call sllist%append(
"Canopy_Capacity")
100 call sllist%append(
"Canopy_Storage_Capacity")
104 call sllist%append(
"Trunk_Capacity")
105 call sllist%append(
"Trunk_Storage_Capacity")
109 call sllist%append(
"Stemflow_Fraction")
110 call sllist%append(
"Stemflow_Frac")
114 larelengthsequal = ( inumrecs == inumberoflanduses )
118 call sllist%append(
"interception_storage_max_growing")
119 call sllist%append(
"interception_storage_max_growing_season")
120 call sllist%append(
"interception_storage_maximum_growing")
122 call params%get_parameters( slkeys=sllist, &
127 larelengthsequal = ( inumrecs == inumberoflanduses )
129 if ( .not. larelengthsequal )
then
130 call warn( smessage=
"The number of landuses does not match the number of interception storage " &
131 //
"maximum values for the growing season" &
132 //
"('interception_storage_max_growing').", &
133 shints=
"A default value of 0.1 inches was assigned for the maximum interception storage", &
134 smodule=__file__, iline=__line__, lfatal=
false )
135 allocate(tempvals(inumberoflanduses), stat=istat)
143 call sllist%append(
"interception_storage_max_nongrowing")
144 call sllist%append(
"interception_storage_max_nongrowing_season")
145 call sllist%append(
"interception_storage_maximum_nongrowing")
147 call params%get_parameters( slkeys=sllist, &
152 larelengthsequal = ( inumrecs == inumberoflanduses )
154 if ( .not. larelengthsequal )
then
155 call warn( smessage=
"The number of landuses does not match the number of interception storage " &
156 //
"maximum values for the nongrowing season" &
157 //
"('interception_storage_max_nongrowing').", &
158 shints=
"A default value of 0.1 inches was assigned for the maximum interception storage", &
159 smodule=__file__, iline=__line__, lfatal=
false )
160 allocate(tempvals(inumberoflanduses), stat=istat)
167 if ( .not. larelengthsequal ) &
168 call warn( smessage=
"The number of canopy storage capacity values (" &
169 //
ascharacter( inumrecs )//
") does not match the number of landuse values (" &
171 smodule=__file__, iline=__line__, lfatal=.
true._c_bool )
175 larelengthsequal = ( inumrecs == inumberoflanduses )
177 if ( .not. larelengthsequal ) &
178 call warn( smessage=
"The number of trunk storage capacity values (" &
179 //
ascharacter( inumrecs )//
") does not match the number of landuse values (" &
181 smodule=__file__, iline=__line__, lfatal=.
true._c_bool )
185 larelengthsequal = ( inumrecs == inumberoflanduses )
187 if ( .not. larelengthsequal ) &
188 call warn( smessage=
"The number of stemflow fraction values (" &
189 //
ascharacter( inumrecs )//
") does not match the number of landuse values (" &
191 smodule=__file__, iline=__line__, lfatal=.
true._c_bool )
194 allocate(
p_sat( count( lactive ) ), stat=istat )
195 call assert( istat==0,
"Problem allocating memory for P_SAT.", __file__, __line__ )
199 fcanopy_cover_fraction )
208 real (c_float),
intent(in) :: e_div_p
209 real (c_float),
intent(in) :: canopy_storage_capacity
210 real (c_float),
intent(in) :: canopy_cover_fraction
211 real (c_float) :: psat
214 real (c_float) :: p_div_e
216 if ( canopy_cover_fraction > 0.0_c_float .and. canopy_storage_capacity > 0.0_c_float )
then
218 psat = - ( canopy_storage_capacity / ( canopy_cover_fraction * e_div_p ) ) &
219 * log( 1.0_c_float - e_div_p )
236 fTrunk_Storage_Capacity, fStemflow_Fraction, &
237 fEvaporation_to_Rainfall_Ratio, &
238 fPrecipitation_at_Saturation, fInterception )
240 real (c_float),
intent(in) :: frainfall
241 real (c_float),
intent(in) :: ffog
242 real (c_float),
intent(in) :: fcanopy_cover_fraction
243 real (c_float),
intent(in) :: ftrunk_storage_capacity
244 real (c_float),
intent(in) :: fstemflow_fraction
245 real (c_float),
intent(in) :: fevaporation_to_rainfall_ratio
246 real (c_float),
intent(in) :: fprecipitation_at_saturation
247 real (c_float),
intent(inout) :: finterception
250 real (c_float) :: frainfall_plus_fog
252 frainfall_plus_fog = frainfall + ffog
254 if ( fprecipitation_at_saturation .approxequal. 0.0_c_float )
then
256 finterception = 0.0_c_float
259 else if ( frainfall_plus_fog < fprecipitation_at_saturation )
then
262 finterception = fcanopy_cover_fraction * frainfall_plus_fog
265 else if ( frainfall_plus_fog > ftrunk_storage_capacity &
266 / (fstemflow_fraction + 1.0e-6) )
then
268 finterception = fcanopy_cover_fraction * fprecipitation_at_saturation &
269 + fcanopy_cover_fraction * fevaporation_to_rainfall_ratio &
270 * ( frainfall_plus_fog - fprecipitation_at_saturation ) &
271 + ftrunk_storage_capacity
280 finterception = fcanopy_cover_fraction * fprecipitation_at_saturation &
281 + fcanopy_cover_fraction * fevaporation_to_rainfall_ratio &
282 * ( frainfall_plus_fog - fprecipitation_at_saturation ) &
283 + fstemflow_fraction * frainfall_plus_fog
291 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
type(t_netcdf4_file), pointer pncfile
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
Provide support for use of netCDF files as input for time-varying, gridded meteorlogic data,...
type(parameters_t), public params