Soil Water Balance (SWB2)
Loading...
Searching...
No Matches
rooting_depth__FAO56.F90
Go to the documentation of this file.
1!> @file
2!! Contains a single module, \ref rooting_depth__FAO56, which
3!! provides support for dynamic rooting depth calculation
4
5!! Calculate the effective root zone depth given the current stage
6!! of plant growth, the soil type, and the crop type.
8
9 use iso_c_binding, only : c_short, c_int, c_float, c_double, c_bool
11 use fstring_list
12 use fstring, only : operator(.containssimilar.), ascharacter
13 use parameters, only : params
14 use exceptions, only : assert, warn
18 implicit none
19
20 private
21
23
24 logical(c_bool), allocatable :: variable_rooting_depth(:)
25
26contains
27
29
30 use parameters, only : params, params_dict
31
32 integer (c_int) :: number_of_landuses
33 integer (c_int) :: number_of_records
34 integer (c_int) :: indx
35 logical (c_bool) :: list_lengths_are_equal
36 type (fstring_list_t) :: sllist
37 type (fstring_list_t) :: sl_variable_rooting_depth
38 integer (c_int), allocatable :: landuse_table_codes(:)
39 logical (c_bool), allocatable :: tempbool(:)
40 character (len=31) :: temp_str
41 integer (c_int) :: status
42
43 ! create list of possible table headings to look for...
44 call sllist%append( "LU_Code" )
45 call sllist%append( "Landuse_Lookup_Code" )
46
47 !> Determine how many landuse codes are present
48 call params%get_parameters( slkeys=sllist, ivalues=landuse_table_codes )
49 number_of_landuses = count( landuse_table_codes >= 0 )
50 call sllist%clear()
51
52 sllist = create_list("allow_variable_rooting_depth, variable_rooting_depth")
53 call params%get_parameters( slkeys=sllist, slvalues=sl_variable_rooting_depth, lfatal=false )
54 call sllist%clear()
55
56 number_of_records = sl_variable_rooting_depth%count
57 list_lengths_are_equal = ( number_of_records == number_of_landuses )
58
59 print *, "INITIALIZING ROOTING DEPTH data structures:", trim(__file__), " ", __line__
60
61 if ( .not. list_lengths_are_equal ) then
62
63 call warn( smessage="The number of landuses does not match the number of values supplied for the " &
64 //"'allow_variable_rooting_depth' parameter.", &
65 shints="By default, all rooting depths will be allowed to vary, using the FAO-56 methodology.", &
66 smodule=__file__, iline=__line__, lfatal=false )
67 allocate(tempbool(number_of_landuses), stat=status)
68 tempbool = true
69 call move_alloc(tempbool, variable_rooting_depth)
70
71 else
72
73 allocate( variable_rooting_depth( sl_variable_rooting_depth%count ), stat=status )
74 call assert( status==0, "Problem allocating memory.", __file__, __line__ )
75
76 do indx=1, sl_variable_rooting_depth%count
77 temp_str = sl_variable_rooting_depth%get( indx )
78 if ( (temp_str .containssimilar. "variable") .or. (temp_str .containssimilar. "varying")) then
80 else
82 endif
83
84 print *, "SETTING 'allow_variable_rooting_depth' for landuse index "//ascharacter(indx)//" to "//trim(temp_str)
85
86 enddo
87
88 endif
89
90end subroutine initialize_rooting_depth
91
92!------------------------------------------------------------------------------
93
94!> Calculate the effective root zone depth.
95!!
96!! Calculate the effective root zone depth given the current stage
97!! of plant growth, the soil type, and the crop type.
98!!
99!! @param[inout] Zr_i Daily rooting depth estimate.
100!! @param[in] Zr_max The maximum rooting depth for this crop.
101!! @param[in] landuse_index Index corresponding to the line number of the table
102!! that holds data for a particular landuse.
103!! @param[in] Kcb current crop coefficient value for a cell.
104!! @note Implemented as equation 8-1 (Annex 8), FAO-56, Allen and others.
105elemental subroutine update_rooting_depth( Zr_i, Zr_max, landuse_index, Kcb )
106
107 real (c_float), intent(inout) :: zr_i
108 real (c_float), intent(in) :: zr_max
109 integer (c_int), intent(in) :: landuse_index
110 real (c_float), intent(in) :: kcb
111
112 ! [ LOCALS ]
113 ! 0.328 feet equals 0.1 meters, which is seems to be the standard
114 ! initial rooting depth in the FAO-56 methodology
115 real (c_float), parameter :: zr_min = 0.328
116 real (c_float) :: maxkcb
117 real (c_float) :: minkcb
118
119 if (variable_rooting_depth(landuse_index)) then
120
121 if ( kcb_method( landuse_index ) == kcb_method_monthly_values ) then
122 maxkcb = maxval( kcb_l( jan:dec, landuse_index ) )
123 minkcb = minval( kcb_l( jan:dec, landuse_index ) )
124 else
125 maxkcb = maxval( kcb_l( kcb_ini:kcb_min, landuse_index ) )
126 minkcb = minval( kcb_l( kcb_ini:kcb_min, landuse_index ) )
127 endif
128
129
130! if ( MinKCB > 0.49_c_float ) then
131
132! Zr_i = Zr_max
133
134 if ( kcb > minkcb ) then
135
136 ! scale the rooting depth in proportion to the progress within the Kcb curve...
137 ! update: we are not going to reduce the rooting depth until the Kcb value has been
138 ! reset to Kcb_ini
139 zr_i = max(zr_i, zr_min + ( kcb - minkcb ) / ( maxkcb - minkcb ) * ( zr_max - zr_min ))
140
141 else
142
143 zr_i = zr_min
144
145 endif
146
147 else
148
149 ! user has specified a constant rooting depth. set value to Zr_max
150 zr_i = zr_max
151
152 endif
153
154end subroutine update_rooting_depth
155
156end module rooting_depth__fao56
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
Update crop coefficients for crop types in simulation.
real(c_float), dimension(:,:), allocatable, public kcb_l
integer(c_int), dimension(:), allocatable, public kcb_method
subroutine, public warn(smessage, smodule, iline, shints, lfatal, iloglevel, lecho)
type(parameters_t), public params
type(dict_t), public params_dict
logical(c_bool), dimension(:), allocatable variable_rooting_depth
elemental subroutine, public update_rooting_depth(zr_i, zr_max, landuse_index, kcb)
Calculate the effective root zone depth.
subroutine, public initialize_rooting_depth()