Soil Water Balance (SWB2)
Loading...
Searching...
No Matches
interception__bucket.F90
Go to the documentation of this file.
2
3 use iso_c_binding
5 use datetime, only : mmdd2doy
6 use exceptions
7 use parameters, only : params
9 use fstring
11 implicit none
12
13 private
14
18! public :: IS_GROWING_SEASON
19
20! logical (c_bool) :: GROWING_SEASON = .true._c_bool
21
22 integer (c_int), allocatable :: ilandusecodes(:)
23 real (c_float), allocatable :: interception_a_value_growing_season(:)
24 real (c_float), allocatable :: interception_b_value_growing_season(:)
25 real (c_float), allocatable :: interception_n_value_growing_season(:)
26 real (c_float), allocatable :: interception_a_value_nongrowing_season(:)
27 real (c_float), allocatable :: interception_b_value_nongrowing_season(:)
28 real (c_float), allocatable :: interception_n_value_nongrowing_season(:)
29 real (c_float), allocatable :: bucket_interception_storage_max_growing_season(:)
30 real (c_float), allocatable :: bucket_interception_storage_max_nongrowing_season(:)
31
32 !> Form of the bucket interception: I = A + P*B^n
33
34! logical (c_bool), allocatable :: IS_GROWING_SEASON(:)
35
36 character( len=2 ), parameter :: date_delims = "/-"
37 real (c_float), parameter :: nodata_value = -9999._c_float
38
39contains
40
41 subroutine interception_bucket_initialize( active_cells )
42
43 logical (c_bool), intent(in) :: active_cells(:,:)
44
45 ! [ LOCALS ]
46 integer (c_int) :: inumberoflanduses
47 logical (c_bool) :: larelengthsequal
48 character (len=:), allocatable :: stemp
49 type (fstring_list_t) :: sl_temp_list
50 real (c_float), allocatable :: temp_values(:)
51 integer (c_int) :: status
52
53 !> Determine how many landuse codes are present
54 stemp = "LU_Code"
55 call params%get_parameters( skey=stemp, &
56 ivalues=ilandusecodes )
57
58 inumberoflanduses = count( ilandusecodes > 0 )
59
60 !> retrieve growing season interception amount: 'a' term
61 call sl_temp_list%clear()
62 call sl_temp_list%append("Growing_season_interception")
63 call sl_temp_list%append("Growing_season_interception_a")
64 call sl_temp_list%append("Interception_growing")
65 call sl_temp_list%append("Interception_a_term_growing_season")
66
67 call params%get_parameters( slkeys=sl_temp_list, &
68 fvalues=temp_values, &
69 lfatal=true )
70
71 if (all( temp_values > ftinyval) ) then
72
73 larelengthsequal = ( ubound(temp_values,1) == ubound(ilandusecodes,1) )
74
75 if ( .not. larelengthsequal ) &
76 call warn( smessage="The number of landuses does not match the number of interception values " &
77 //"specified for the 'a' term for use during the growing season.", &
78 smodule=__file__, iline=__line__, lfatal=true )
79
80 call move_alloc( temp_values, interception_a_value_growing_season )
81
82 endif
83
84 !> retrieve growing season interception amount: 'b' term
85 call sl_temp_list%clear()
86 call sl_temp_list%append("Growing_season_interception_b")
87 call sl_temp_list%append("Interception_growing_b_term")
88 call sl_temp_list%append("Interception_b_term_growing_season")
89
90 call params%get_parameters( slkeys=sl_temp_list, &
91 fvalues=temp_values, &
92 lfatal=false )
93
94 if (all( temp_values <= ftinyval) ) then
95
96 allocate(interception_b_value_growing_season( ubound( ilandusecodes, 1) ), stat=status )
98
99 else
100
101 larelengthsequal = ( ubound(temp_values,1) == ubound(ilandusecodes,1) )
102
103 if ( .not. larelengthsequal ) &
104 call warn( smessage="The number of landuses does not match the number of interception values " &
105 //"specified for the 'b' term for use during the growing season.", &
106 smodule=__file__, iline=__line__, lfatal=false )
107
108 call move_alloc( temp_values, interception_b_value_growing_season )
109
110 endif
111
112 !> retrieve growing season interception amount: 'n' term
113 call sl_temp_list%clear()
114 call sl_temp_list%append("Growing_season_interception_n")
115 call sl_temp_list%append("Interception_growing_n_term")
116 call sl_temp_list%append("Interception_n_term_growing_season")
117
118 call params%get_parameters( slkeys=sl_temp_list, &
119 fvalues=temp_values, &
120 lfatal=false )
121
122 if (all( temp_values <= ftinyval) ) then
123
124 allocate(interception_n_value_growing_season( ubound( ilandusecodes, 1) ), stat=status )
126
127 else
128
129 larelengthsequal = ( ubound(temp_values,1) == ubound(ilandusecodes,1) )
130
131 if ( .not. larelengthsequal ) &
132 call warn( smessage="The number of landuses does not match the number of interception values " &
133 //"specified for the 'n' term for use during the growing season.", &
134 smodule=__file__, iline=__line__, lfatal=true )
135
136 call move_alloc( temp_values, interception_n_value_growing_season )
137
138 endif
139
140 !> retrieve nongrowing season interception amount: 'a' term
141 call sl_temp_list%clear()
142 call sl_temp_list%append("Nongrowing_season_interception")
143 call sl_temp_list%append("Nongrowing_season_interception_a")
144 call sl_temp_list%append("Interception_nongrowing")
145 call sl_temp_list%append("Interception_a_term_nongrowing_season")
146
147 call params%get_parameters( slkeys=sl_temp_list, &
148 fvalues=temp_values, &
149 lfatal=true )
150
151 if (all( temp_values > ftinyval) ) then
152
153 larelengthsequal = ( ubound(temp_values,1) == ubound(ilandusecodes,1) )
154
155 if ( .not. larelengthsequal ) &
156 call warn( smessage="The number of landuses does not match the number of interception values " &
157 //"specified for the 'a' term for use during the nongrowing season.", &
158 smodule=__file__, iline=__line__, lfatal=false )
159
160 call move_alloc( temp_values, interception_a_value_nongrowing_season )
161
162 endif
163
164 !> retrieve nongrowing season interception amount: 'b' term
165 call sl_temp_list%clear()
166 call sl_temp_list%append("Nongrowing_season_interception_b")
167 call sl_temp_list%append("Interception_nongrowing_b_term")
168 call sl_temp_list%append("Interception_b_term_nongrowing_season")
169
170 call params%get_parameters( slkeys=sl_temp_list, &
171 fvalues=temp_values, &
172 lfatal=false )
173
174 if (all( temp_values <= ftinyval) ) then
175
176 allocate(interception_b_value_nongrowing_season( ubound( ilandusecodes, 1) ), stat=status )
178
179 else
180
181 larelengthsequal = ( ubound(temp_values,1) == ubound(ilandusecodes,1) )
182
183 if ( .not. larelengthsequal ) &
184 call warn( smessage="The number of landuses does not match the number of interception values " &
185 //"specified for the 'b' term for use during the nongrowing season.", &
186 smodule=__file__, iline=__line__, lfatal=false )
187
188 call move_alloc( temp_values, interception_b_value_nongrowing_season )
189
190 endif
191
192 !> retrieve nongrowing season interception amount: 'n' term
193 call sl_temp_list%clear()
194 call sl_temp_list%append("Nongrowing_season_interception_n")
195 call sl_temp_list%append("Interception_nongrowing_n_term")
196 call sl_temp_list%append("Interception_n_term_nongrowing_season")
197
198 call params%get_parameters( slkeys=sl_temp_list, &
199 fvalues=temp_values, &
200 lfatal=false )
201
202 if (all( temp_values <= ftinyval) ) then
203
204 allocate(interception_n_value_nongrowing_season( ubound( ilandusecodes, 1) ), stat=status )
206
207 else
208
209 larelengthsequal = ( ubound(temp_values,1) == ubound(ilandusecodes,1) )
210
211 if ( .not. larelengthsequal ) &
212 call warn( smessage="The number of landuses does not match the number of interception values " &
213 //"specified for the 'n' term for use during the nongrowing season.", &
214 smodule=__file__, iline=__line__, lfatal=false )
215
216 call move_alloc( temp_values, interception_n_value_nongrowing_season )
217
218 endif
219
220 !> retrieve interception storage max (NONGROWING)
221 call sl_temp_list%clear()
222 call sl_temp_list%append("Interception_storage_max_nongrowing")
223 call sl_temp_list%append("Interception_storage_max_nongrowing_season")
224 call sl_temp_list%append("Interception_Storage_Maximum_nongrowing")
225
226 call params%get_parameters( slkeys=sl_temp_list, &
228 lfatal=false )
229
230 larelengthsequal = ( ubound(bucket_interception_storage_max_nongrowing_season,1) == ubound(ilandusecodes,1) )
231
232 if ( .not. larelengthsequal ) then
233 call warn( smessage="The number of landuses does not match the number of interception storage " &
234 //"maximum values for the NONGROWING season " &
235 //"('interception_storage_max_nongrowing').", &
236 shints="A default value equal to the 'Growing_season_interception_a' was assigned for the" &
237 //" maximum interception storage", &
238 smodule=__file__, iline=__line__, lfatal=false )
239 allocate(temp_values(inumberoflanduses), stat=status)
241 call move_alloc(temp_values, bucket_interception_storage_max_nongrowing_season)
242 endif
243
244 !> retrieve interception storage max (GROWING)
245 call sl_temp_list%clear()
246 call sl_temp_list%append("Interception_storage_max_growing")
247 call sl_temp_list%append("Interception_storage_max_growing_season")
248 call sl_temp_list%append("Interception_Storage_Maximum_growing")
249
250 call params%get_parameters( slkeys=sl_temp_list, &
252 lfatal=false )
253
254 larelengthsequal = ( ubound(bucket_interception_storage_max_growing_season,1) == ubound(ilandusecodes,1) )
255
256 if ( .not. larelengthsequal ) then
257 call warn( smessage="The number of landuses does not match the number of interception storage " &
258 //"maximum values for the GROWING season " &
259 //"('interception_storage_max_growing').", &
260 shints="A default value equal to the 'Nongrowing_season_interception_a' was" &
261 //" assigned for the maximum interception storage", &
262 smodule=__file__, iline=__line__, lfatal=false )
263 allocate(temp_values(inumberoflanduses), stat=status)
265 call move_alloc(temp_values, bucket_interception_storage_max_growing_season)
266 endif
267
268 end subroutine interception_bucket_initialize
269
270!--------------------------------------------------------------------------------------------------
271
272 elemental subroutine interception_bucket_calculate( iLanduseIndex, &
273 fPrecip, &
274 fFog, &
275 fCanopy_Cover_Fraction, &
276 it_is_growing_season, &
277 fInterception )
278
279 integer (c_int), intent(in) :: ilanduseindex
280 real (c_float), intent(in) :: fprecip
281 real (c_float), intent(in) :: ffog
282 real (c_float), intent(in) :: fcanopy_cover_fraction
283 logical (c_bool), intent(in) :: it_is_growing_season
284 real (c_float), intent(out) :: finterception
285
286 ! [ LOCALS ]
287 real (c_float) :: fpotentialinterception
288 real (c_float) :: precip_plus_fog
289
290 precip_plus_fog = fprecip + ffog
291
292 if ( it_is_growing_season ) then
293
294 fpotentialinterception = interception_a_value_growing_season( ilanduseindex ) ! &
295! + INTERCEPTION_B_VALUE_GROWING_SEASON( iLanduseIndex ) &
296! * precip_plus_fog &
297! ** INTERCEPTION_N_VALUE_GROWING_SEASON( iLanduseIndex )
298
299 else
300
301 fpotentialinterception = interception_a_value_nongrowing_season( ilanduseindex ) ! &
302 ! + INTERCEPTION_B_VALUE_NONGROWING_SEASON( iLanduseIndex ) &
303 ! * precip_plus_fog &
304 ! ** INTERCEPTION_N_VALUE_NONGROWING_SEASON( iLanduseIndex )
305
306 endif
307
308 finterception = min( fpotentialinterception, fprecip + ffog ) * fcanopy_cover_fraction
309
310 end subroutine interception_bucket_calculate
311
312end module interception__bucket
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
This module contains the DATETIME_T class and associated time and date-related routines,...
Definition datetime.F90:9
integer(c_int) function, public mmdd2doy(smmdd, sinputitemname)
subroutine, public warn(smessage, smodule, iline, shints, lfatal, iloglevel, lecho)
real(c_float), dimension(:), allocatable, public bucket_interception_storage_max_growing_season
real(c_float), parameter nodata_value
real(c_float), dimension(:), allocatable interception_n_value_growing_season
character(len=2), parameter date_delims
Form of the bucket interception: I = A + P*B^n.
real(c_float), dimension(:), allocatable, public bucket_interception_storage_max_nongrowing_season
integer(c_int), dimension(:), allocatable ilandusecodes
elemental subroutine, public interception_bucket_calculate(ilanduseindex, fprecip, ffog, fcanopy_cover_fraction, it_is_growing_season, finterception)
real(c_float), dimension(:), allocatable interception_b_value_growing_season
real(c_float), dimension(:), allocatable interception_b_value_nongrowing_season
subroutine, public interception_bucket_initialize(active_cells)
real(c_float), dimension(:), allocatable interception_a_value_growing_season
real(c_float), dimension(:), allocatable interception_a_value_nongrowing_season
real(c_float), dimension(:), allocatable interception_n_value_nongrowing_season
type(parameters_t), public params
type(date_range_t), public sim_dt