87 integer (c_int) :: inumberoftew, inumberofrew
88 integer (c_int) :: inumberoflanduses
89 integer (c_int) :: iindex, iindex2
90 integer (c_int) :: istat
91 real (c_float) :: growing_cycle_length
93 character (len=10) :: smmddyyyy
94 character (len=:),
allocatable :: stext
98 character (len=:),
allocatable :: plantingdate_str
100 real (c_float),
allocatable :: l_ini_l(:)
101 real (c_float),
allocatable :: l_dev_l(:)
102 real (c_float),
allocatable :: l_mid_l(:)
103 real (c_float),
allocatable :: l_late_l(:)
104 real (c_float),
allocatable :: l_fallow_l(:)
106 real (c_float),
allocatable :: gdd_plant_l(:)
107 real (c_float),
allocatable :: gdd_ini_l(:)
108 real (c_float),
allocatable :: gdd_dev_l(:)
109 real (c_float),
allocatable :: gdd_mid_l(:)
110 real (c_float),
allocatable :: gdd_late_l(:)
112 real (c_float),
allocatable :: kcb_max(:)
114 real (c_float),
allocatable :: kcb_ini_l(:)
115 real (c_float),
allocatable :: kcb_mid_l(:)
116 real (c_float),
allocatable :: kcb_end_l(:)
117 real (c_float),
allocatable :: kcb_min_l(:)
119 real (c_float),
allocatable :: kcb_jan(:)
120 real (c_float),
allocatable :: kcb_feb(:)
121 real (c_float),
allocatable :: kcb_mar(:)
122 real (c_float),
allocatable :: kcb_apr(:)
123 real (c_float),
allocatable :: kcb_may(:)
124 real (c_float),
allocatable :: kcb_jun(:)
125 real (c_float),
allocatable :: kcb_jul(:)
126 real (c_float),
allocatable :: kcb_aug(:)
127 real (c_float),
allocatable :: kcb_sep(:)
128 real (c_float),
allocatable :: kcb_oct(:)
129 real (c_float),
allocatable :: kcb_nov(:)
130 real (c_float),
allocatable :: kcb_dec(:)
132 real (c_float) :: fkcb_initial
133 real (c_float) :: frz_initial
135 real (c_float),
parameter :: near_zero = 1.0e-9_c_float
140 sllist =
create_list(
"LU_Code, Landuse_Code, Landuse_Lookup_Code")
160 call params%get_parameters( skey=
"Planting_date", slvalues=slplantingdate )
162 call params%get_parameters( skey=
"L_ini", fvalues=l_ini_l)
163 call params%get_parameters( skey=
"L_dev", fvalues=l_dev_l)
164 call params%get_parameters( skey=
"L_mid", fvalues=l_mid_l)
165 call params%get_parameters( skey=
"L_late", fvalues=l_late_l)
166 call params%get_parameters( skey=
"L_fallow", fvalues=l_fallow_l)
168 call params%get_parameters( skey=
"GDD_plant", fvalues=gdd_plant_l)
169 call params%get_parameters( skey=
"GDD_ini", fvalues=gdd_ini_l)
170 call params%get_parameters( skey=
"GDD_dev", fvalues=gdd_dev_l)
171 call params%get_parameters( skey=
"GDD_mid", fvalues=gdd_mid_l)
172 call params%get_parameters( skey=
"GDD_late", fvalues=gdd_late_l)
174 call params%get_parameters( skey=
"Kcb_ini", fvalues=kcb_ini_l)
175 call params%get_parameters( skey=
"Kcb_mid", fvalues=kcb_mid_l)
176 call params%get_parameters( skey=
"Kcb_end", fvalues=kcb_end_l)
177 call params%get_parameters( skey=
"Kcb_min", fvalues=kcb_min_l)
179 call params%get_parameters( skey=
"Kcb_Jan", fvalues=kcb_jan )
180 call params%get_parameters( skey=
"Kcb_Feb", fvalues=kcb_feb )
181 call params%get_parameters( skey=
"Kcb_Mar", fvalues=kcb_mar )
182 call params%get_parameters( skey=
"Kcb_Apr", fvalues=kcb_apr )
183 call params%get_parameters( skey=
"Kcb_May", fvalues=kcb_may )
184 call params%get_parameters( skey=
"Kcb_Jun", fvalues=kcb_jun )
185 call params%get_parameters( skey=
"Kcb_Jul", fvalues=kcb_jul )
186 call params%get_parameters( skey=
"Kcb_Aug", fvalues=kcb_aug )
187 call params%get_parameters( skey=
"Kcb_Sep", fvalues=kcb_sep )
188 call params%get_parameters( skey=
"Kcb_Oct", fvalues=kcb_oct )
189 call params%get_parameters( skey=
"Kcb_Nov", fvalues=kcb_nov )
190 call params%get_parameters( skey=
"Kcb_Dec", fvalues=kcb_dec )
194 call assert( istat==0,
"Failed to allocate memory for GROWTH_STAGE_LENGTH_IN_DAYS array", &
198 call assert( istat==0,
"Failed to allocate memory for GROWTH_STAGE_GDD array", &
202 call assert( istat==0,
"Failed to allocate memory for GROWTH_STAGE_DATE array", &
205 allocate(
kcb_l( 16, inumberoflanduses ), stat=istat )
206 call assert( istat==0,
"Failed to allocate memory for KCB_l array", &
209 allocate(
kcb_method( inumberoflanduses ), stat=istat )
210 call assert( istat==0,
"Failed to allocate memory for KCB_METHOD vector", &
218 if ( ubound(l_ini_l,1) == inumberoflanduses ) &
221 if ( ubound(l_dev_l,1) == inumberoflanduses ) &
224 if ( ubound(l_mid_l,1) == inumberoflanduses ) &
227 if ( ubound(l_late_l,1) == inumberoflanduses ) &
230 if ( ubound(l_fallow_l,1) == inumberoflanduses ) &
233 call logs%write(
" ## Crop Kcb Curve Summary ##", ilinesafter=1)
234 call logs%write(
" _only meaningful for landuses where the Kcb curve is defined " &
235 //
"in terms of days _", ilinesafter=1)
236 call logs%write(
"Landuse Code | Planting Date | End of 'ini' | End of 'dev' " &
237 //
"| End of 'mid' | End of 'late' | End of 'fallow' ")
238 call logs%write(
"-------------|---------------|--------------|--------------" &
239 //
"|--------------|---------------|-----------------")
241 if ( slplantingdate%count == inumberoflanduses .and. slplantingdate%count > 0 )
then
243 do iindex=1, slplantingdate%count
245 plantingdate_str = slplantingdate%get( iindex )
249 if ( len_trim(plantingdate_str) == 0 ) cycle
251 if ( plantingdate_str .contains.
"/" )
then
262 call dtplantingdate%calcJulianDay()
308 if (ubound(kcb_ini_l,1) == inumberoflanduses)
kcb_l(
kcb_ini, :) = kcb_ini_l
309 if (ubound(kcb_mid_l,1) == inumberoflanduses)
kcb_l(
kcb_mid, :) = kcb_mid_l
310 if (ubound(kcb_end_l,1) == inumberoflanduses)
kcb_l(
kcb_end, :) = kcb_end_l
311 if (ubound(kcb_min_l,1) == inumberoflanduses)
kcb_l(
kcb_min, :) = kcb_min_l
313 if (ubound(kcb_jan,1) == inumberoflanduses)
kcb_l(
jan, :) = kcb_jan
314 if (ubound(kcb_feb,1) == inumberoflanduses)
kcb_l(
feb, :) = kcb_feb
315 if (ubound(kcb_mar,1) == inumberoflanduses)
kcb_l(
mar, :) = kcb_mar
316 if (ubound(kcb_apr,1) == inumberoflanduses)
kcb_l(
apr, :) = kcb_apr
317 if (ubound(kcb_may,1) == inumberoflanduses)
kcb_l(
may, :) = kcb_may
318 if (ubound(kcb_jun,1) == inumberoflanduses)
kcb_l(
jun, :) = kcb_jun
319 if (ubound(kcb_jul,1) == inumberoflanduses)
kcb_l(
jul, :) = kcb_jul
320 if (ubound(kcb_aug,1) == inumberoflanduses)
kcb_l(
aug, :) = kcb_aug
321 if (ubound(kcb_sep,1) == inumberoflanduses)
kcb_l(
sep, :) = kcb_sep
322 if (ubound(kcb_oct,1) == inumberoflanduses)
kcb_l(
oct, :) = kcb_oct
323 if (ubound(kcb_nov,1) == inumberoflanduses)
kcb_l(
nov, :) = kcb_nov
324 if (ubound(kcb_dec,1) == inumberoflanduses)
kcb_l(
dec, :) = kcb_dec
330 if ( all(
kcb_l(
jan:
dec, iindex ) > 0.0_c_float ) )
then
345 call warn(
"There are missing day-of-year (L_ini, L_dev, L_mid, L_late, L_fallow), " &
346 //
"growing degree-day ~(GDD_plant, GDD_ini, GDD_dev, GDD_mid, GDD_late)," &
347 //
" or monthly crop ~coefficients (Kcb_jan...Kcb_dec) for" &
453 relative_humidity_min_pct, &
455 plant_height_meters)
result(kcb_max)
457 real (c_float),
intent(in) :: wind_speed_meters_per_sec
458 real (c_float),
intent(in) :: relative_humidity_min_pct
459 real (c_float),
intent(in) :: kcb
460 real (c_float),
intent(in) :: plant_height_meters
462 real (c_float) :: kcb_max
463 real (c_double) :: u2
464 real (c_double) :: rhmin
465 real (c_double) :: plant_height
469 rhmin = clip( relative_humidity_min_pct, minval=20., maxval=80. )
470 u2 = clip(wind_speed_meters_per_sec, minval=1., maxval=6.)
471 plant_height = clip(plant_height_meters, minval=1., maxval=10.)
474 kcb_max = max( 1.2_c_double + ( (0.04_c_double * (u2 - 2._c_double) &
475 - 0.004_c_double * (rhmin - 45._c_double) ) ) &
476 * (plant_height_meters/3._c_double)**0.3_c_double, &
477 kcb + 0.05_c_double )