34 real (c_float),
intent(inout) :: frooting_depth(:,:)
38 integer (c_int),
allocatable :: ilanduse_code(:)
39 integer (c_int),
allocatable :: isoils_table_code(:)
40 integer (c_int),
allocatable :: isoils_components(:)
41 integer (c_int),
allocatable :: isoils_horizons(:)
42 real (c_float),
allocatable :: fsoils_awc(:)
43 real (c_float),
allocatable :: fsoils_top_depth(:)
44 real (c_float),
allocatable :: fsoils_bottom_depth(:)
45 real (c_float),
allocatable :: fsoils_component_fraction(:)
46 real (c_float),
allocatable :: fsoils_horizon_thickness(:)
48 integer (c_int) :: inumberoflanduses
49 integer (c_int) :: inumberofsoils
50 integer (c_int) :: inumberofsoilscomponents
51 integer (c_int) :: inumberofsoilshorizons
52 integer (c_int) :: inumberofsoilsawc
53 integer (c_int) :: inumberofsoilstopdepths
54 integer (c_int) :: inumberofsoilsbottomdepths
55 integer (c_int) :: inumberofsoilscomponentfractions
57 real (c_float) :: ftemp_awc
58 real (c_float) :: fdepthofdeepesthorizon
59 real (c_float) :: ffinal_awc
60 integer (c_int) :: ideepestsoilhorizon
61 logical (c_bool) :: lfirst
64 integer (c_int) :: istat
65 integer (c_int) :: iindex, iindex2
66 integer (c_int) :: iindex_x, iindex_y
67 real (c_float) :: frooting_depth_inches
68 real (c_float) :: fsoil_thickness_total
70 call sllist%append(
"LU_Code")
71 call sllist%append(
"Landuse_Code")
72 call sllist%append(
"Landuse_Lookup_Code")
74 call params%get_parameters( slkeys=sllist, ivalues=ilanduse_code )
75 inumberoflanduses = count( ilanduse_code >= 0 )
79 call sllist%append(
"Soils_Code")
80 call sllist%append(
"Soils_Lookup_Code")
81 call sllist%append(
"Soil_Code")
82 call sllist%append(
"Soil_Lookup_Code")
84 call params%get_parameters( slkeys=sllist, ivalues=isoils_table_code )
85 inumberofsoils = count( isoils_table_code >= 0 )
88 call sllist%append(
"Soils_Component")
89 call sllist%append(
"Soils_Component_Number")
90 call sllist%append(
"Soil_Component")
91 call sllist%append(
"Soil_Component_Number")
93 call params%get_parameters( slkeys=sllist, ivalues=isoils_components )
94 inumberofsoilscomponents = count( isoils_components >= 0 )
97 call sllist%append(
"Soils_Top_Depth")
98 call sllist%append(
"Soil_Top_Depth")
99 call sllist%append(
"Soils_Z_Top")
100 call sllist%append(
"Soils_Top_of_Horizon")
102 call params%get_parameters( slkeys=sllist, fvalues=fsoils_top_depth )
103 inumberofsoilstopdepths = count( fsoils_top_depth >= 0 )
106 call sllist%append(
"Soils_Bottom_Depth")
107 call sllist%append(
"Soil_Bottom_Depth")
108 call sllist%append(
"Soils_Z_Bottom")
109 call sllist%append(
"Soils_Bottom_of_Horizon")
111 call params%get_parameters( slkeys=sllist, fvalues=fsoils_bottom_depth )
112 inumberofsoilsbottomdepths = count( fsoils_bottom_depth >= 0 )
115 call sllist%append(
"Soils_Horizon")
116 call sllist%append(
"Soils_Horizon_Number")
117 call sllist%append(
"Soil_Horizon")
118 call sllist%append(
"Soil_Horizon_Number")
120 call params%get_parameters( slkeys=sllist, ivalues=isoils_horizons )
121 inumberofsoilshorizons = count( isoils_horizons >= 0 )
124 call sllist%append(
"Soils_Component_Fraction")
125 call sllist%append(
"Soil_Component_Fraction")
127 call params%get_parameters( slkeys=sllist, fvalues=fsoils_component_fraction )
128 inumberofsoilscomponentfractions = count( fsoils_component_fraction >= 0 )
132 call sllist%append(
"Soils_Available_Water_Content")
133 call sllist%append(
"Soils_AWC")
134 call sllist%append(
"Soil_Available_Water_Content")
135 call sllist%append(
"Soil_AWC")
136 call sllist%append(
"Available_Water_Content")
137 call sllist%append(
"AWC")
139 call params%get_parameters( slkeys=sllist, fvalues=fsoils_awc )
140 inumberofsoilsawc = count( fsoils_awc >= 0 )
149 "A SOILS_CODE grid must be supplied in order to make use of this option.", __file__, __line__)
153 allocate (fsoils_horizon_thickness( ubound( fsoils_bottom_depth, 1) ), stat=istat )
158 fsoils_horizon_thickness = fsoils_bottom_depth - fsoils_top_depth
160 do iindex_x=lbound( frooting_depth, 1 ), ubound( frooting_depth, 1 )
162 do iindex_y=lbound( frooting_depth, 2 ), ubound( frooting_depth, 2 )
165 frooting_depth_inches = frooting_depth( iindex_x, iindex_y ) * 12.0_c_float
167 ftemp_awc = 0.0_c_float
169 ideepestsoilhorizon = 0_c_int
170 fdepthofdeepesthorizon = 0.0_c_float
171 ffinal_awc = 0.0_c_float
173 do iindex=1, inumberofsoils
174 if (
psoils_code_grid%pGrdBase%iData( iindex_x, iindex_y ) == isoils_table_code( iindex ) )
then
182 do iindex2=iindex, inumberofsoils
183 if (
psoils_code_grid%pGrdBase%iData( iindex_x, iindex_y ) == isoils_table_code( iindex2 ) ) &
184 ideepestsoilhorizon = max( ideepestsoilhorizon, isoils_horizons( iindex2 ) )
188 do iindex2=iindex, inumberofsoils
189 if ( (
psoils_code_grid%pGrdBase%iData( iindex_x, iindex_y ) == isoils_table_code( iindex2 ) ) &
190 .and. ( ideepestsoilhorizon == isoils_horizons( iindex2) ) ) &
191 ffinal_awc = ffinal_awc + fsoils_awc( iindex2 ) * fsoils_component_fraction( iindex2 )
192 fdepthofdeepesthorizon = fsoils_bottom_depth( iindex2 )
198 if ( frooting_depth_inches < fsoils_top_depth( iindex ) ) cycle
202 if ( frooting_depth_inches > fsoils_bottom_depth( iindex ) )
then
204 ftemp_awc = ftemp_awc + fsoils_awc( iindex ) * fsoils_component_fraction( iindex ) &
205 * fsoils_horizon_thickness( iindex )
208 elseif ( frooting_depth_inches >= fsoils_top_depth( iindex ) &
209 .and. frooting_depth_inches <= fsoils_bottom_depth( iindex ) )
then
211 ftemp_awc = ftemp_awc + fsoils_awc( iindex ) * fsoils_component_fraction( iindex ) &
212 * ( frooting_depth_inches - fsoils_top_depth( iindex ) )
221 if (frooting_depth_inches > fdepthofdeepesthorizon ) &
223 ftemp_awc = ftemp_awc + ffinal_awc * ( frooting_depth_inches - fdepthofdeepesthorizon )
226 if ( frooting_depth_inches > 0.0_c_float )
then
227 ftemp_awc = ftemp_awc / frooting_depth_inches
229 ftemp_awc = 0.0_c_float