3 use iso_c_binding,
only : c_int, c_float, c_double, c_bool
17 real (c_float),
allocatable ::
cn_arci(:,:)
42 use ieee_arithmetic,
only : ieee_is_nan, ieee_is_finite
44 logical (c_bool),
intent(in) :: cell_is_active(:,:)
47 integer (c_int) :: inumberoflanduses
48 integer (c_int) :: inumberofsoilgroups
49 integer (c_int),
allocatable :: icurvenumberseqnums(:)
52 integer (c_int) :: istat
53 integer (c_int) :: isoilsindex
54 character (len=:),
allocatable :: stext
55 real (c_float),
allocatable :: cn(:)
57 call sllist%append(
"LU_Code")
58 call sllist%append(
"Landuse_Lookup_Code")
63 slcurvenumber =
params%grep_name(
"CN", lfatal=
true )
66 icurvenumberseqnums = slcurvenumber%get_integer()
69 inumberofsoilgroups = count( icurvenumberseqnums > 0 )
75 allocate(
cn_arciii(inumberoflanduses, inumberofsoilgroups), stat=istat )
76 call assert( istat == 0,
"Failed to allocate memory for curve number table - AMC III", &
79 allocate(
cn_arcii(inumberoflanduses, inumberofsoilgroups), stat=istat )
80 call assert( istat == 0,
"Failed to allocate memory for curve number table - AMC II", &
83 allocate(
cn_arci(inumberoflanduses, inumberofsoilgroups), stat=istat )
84 call assert( istat == 0,
"Failed to allocate memory for curve number table - AMC I", &
88 do isoilsindex = 1, inumberofsoilgroups
90 call params%get_parameters( skey=stext, fvalues=cn )
95 call assert( istat == 0,
"Failed to allocate memory for curve number PREV_5_DAYS_RAIN table", &
116 integer (c_int),
intent(in) :: ilandusecode
117 integer (c_int) :: ilanduseindex
123 ilanduseindex = ilanduseindex + 1
135 real (c_float),
intent(in) :: fcfgi
136 real (c_float),
intent(in) :: fcfgi_ul
137 real (c_float),
intent(in) :: fcfgi_ll
139 real (c_float) :: fpf
141 if(fcfgi <= fcfgi_ll )
then
143 elseif(fcfgi >= fcfgi_ul)
then
146 fpf = ( fcfgi - fcfgi_ll ) / ( fcfgi_ul - fcfgi_ll )
155 real (c_float),
intent(in) :: infil
156 integer (c_int),
intent(in) :: indx
251 it_is_growing_season, fSoilStorage_Max, &
252 fCFGI, fCFGI_LL, fCFGI_UL )
result( CN_adj )
254 integer (c_int),
intent(in) :: ilanduseindex
255 integer (c_int),
intent(in) :: isoilsindex
256 integer (c_int),
intent(in) :: cell_index
257 logical (c_bool),
intent(in) :: it_is_growing_season
258 real (c_float),
intent(in) :: fsoilstorage_max
259 real (c_float),
intent(in) :: fcfgi
260 real (c_float),
intent(in) :: fcfgi_ll
261 real (c_float),
intent(in) :: fcfgi_ul
262 real (c_float) :: cn_adj
266 real (c_float) :: frac
267 real (c_float) :: finflow
271 associate( cn_i =>
cn_arci( ilanduseindex, isoilsindex ), &
272 cn_ii =>
cn_arcii( ilanduseindex, isoilsindex ), &
273 cn_iii =>
cn_arciii( ilanduseindex, isoilsindex ) )
277 if( ( fcfgi > fcfgi_ll ) .and. ( fsoilstorage_max > 0.0_c_float ) )
then
284 cn_adj = cn_ii * (1-pf) + cn_iii * pf
286 else if ( it_is_growing_season )
then
326 cn_adj = min(cn_adj,100.0_c_float)
327 cn_adj = max(cn_adj,30.0_c_float)
336 real (c_float),
intent(in) :: cn_ii
337 real (c_float) :: cn_iii
339 cn_iii = cn_ii / ( 0.427_c_float + 0.00573_c_float * cn_ii )
341 cn_iii = max( cn_iii, 30.0_c_float )
342 cn_iii = min( cn_iii, 100.0_c_float )
350 real (c_float),
intent(in) :: cn_ii
351 real (c_float) :: cn_i
354 cn_i = cn_ii / (2.281_c_float - 0.01281_c_float * cn_ii )
356 cn_i = max( cn_i, 30.0_c_float )
357 cn_i = min( cn_i, 100.0_c_float )
386 it_is_growing_season, &
389 continuous_frozen_ground_index, &
393 real (c_float),
intent(inout) :: runoff
394 real (c_float),
intent(inout) :: curve_num_adj
395 integer (c_int),
intent(in) :: cell_index
396 integer (c_int),
intent(in) :: landuse_index
397 integer (c_int),
intent(in) :: soil_group
398 logical (c_bool),
intent(in) :: it_is_growing_season
399 real (c_float),
intent(in) :: inflow
400 real (c_float),
intent(in) :: soil_storage_max
402 real (c_float),
intent(in) :: cfgi_lower_limit
403 real (c_float),
intent(in) :: cfgi_upper_limit
407 real (c_float) :: smax
408 real (c_float) :: cn_adj
412 it_is_growing_season, &
418 smax = ( 1000.0_c_float / curve_num_adj ) - 10.0_c_float
426 smax = 1.33_c_float * ( smax**1.15_c_float )
429 if ( inflow > 0.05_c_float * smax )
then
430 runoff = ( inflow - 0.05_c_float * smax )**2 / ( inflow + 0.95_c_float * smax )
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,...
type(parameters_t), public params
type(dict_t), public params_dict
integer(c_int), parameter, public five_day_sum
elemental real(c_float) function, public update_curve_number_fn(ilanduseindex, isoilsindex, cell_index, it_is_growing_season, fsoilstorage_max, fcfgi, fcfgi_ll, fcfgi_ul)
type(datetime_t) date_last_updated
elemental real(c_float) function cn_ii_to_cn_i(cn_ii)
real(c_float), parameter amc_dry_growing
elemental real(c_float) function cn_ii_to_cn_iii(cn_ii)
elemental subroutine, public runoff_curve_number_calculate(runoff, curve_num_adj, cell_index, landuse_index, soil_group, it_is_growing_season, inflow, soil_storage_max, continuous_frozen_ground_index, cfgi_lower_limit, cfgi_upper_limit)
Calculate the runoff by means of the curve number method.
real(c_float), dimension(:,:), allocatable, public prev_5_days_rain
subroutine, public update_previous_5_day_rainfall(infil, indx)
real(c_float), parameter amc_wet_growing
real(c_float), parameter amc_dry_dormant
real(c_float), dimension(:,:), allocatable, public cn_arciii
real(c_float), dimension(:,:), allocatable, public cn_arci
subroutine, public runoff_curve_number_initialize(cell_is_active)
real(c_float), parameter amc_wet_dormant
real(c_float), dimension(:,:), allocatable, public cn_arcii
integer(c_int), dimension(:), allocatable ilandusecodes
elemental integer(c_int) function return_landuse_index_fn(ilandusecode)
elemental real(c_float) function prob_runoff_enhancement(fcfgi, fcfgi_ul, fcfgi_ll)
type(date_range_t), public sim_dt