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