@@ -6,6 +6,7 @@ module EDInitMod
66
77 use FatesConstantsMod , only : r8 = > fates_r8
88 use FatesConstantsMod , only : ifalse
9+ use FatesConstantsMod , only : itrue
910 use FatesGlobals , only : endrun = > fates_endrun
1011 use EDTypesMod , only : nclmax
1112 use FatesGlobals , only : fates_log
@@ -21,12 +22,20 @@ module EDInitMod
2122 use EDTypesMod , only : numpft_ed
2223 use FatesInterfaceMod , only : bc_in_type
2324 use EDTypesMod , only : use_fates_plant_hydro
24-
25+
26+ ! CIME GLOBALS
27+ use shr_log_mod , only : errMsg = > shr_log_errMsg
28+
2529 implicit none
2630 private
2731
2832 logical :: DEBUG = .false.
2933
34+ integer , parameter :: do_inv_init = ifalse
35+
36+ character (len=* ), parameter , private :: sourcefile = &
37+ __FILE__
38+
3039 public :: zero_site
3140 public :: init_patches
3241 public :: set_site_properties
@@ -184,65 +193,92 @@ end subroutine set_site_properties
184193
185194 ! ============================================================================
186195 subroutine init_patches ( nsites , sites , bc_in )
187- !
188- ! !DESCRIPTION:
189- ! initialize patches on new ground
190- !
191- ! !USES:
192- use EDParamsMod , only : ED_val_maxspread
193- use FatesPlantHydraulicsMod, only : updateSizeDepRhizHydProps
194- !
195- ! !ARGUMENTS
196- integer , intent (in ) :: nsites
197- type (ed_site_type) , intent (inout ), target :: sites(nsites)
198- type (bc_in_type), intent (in ) :: bc_in(nsites)
199- !
200- ! !LOCAL VARIABLES:
201- integer :: s
202- real (r8 ) :: cwd_ag_local(ncwd)
203- real (r8 ) :: cwd_bg_local(ncwd)
204- real (r8 ) :: spread_local(nclmax)
205- real (r8 ) :: leaf_litter_local(numpft_ed)
206- real (r8 ) :: root_litter_local(numpft_ed)
207- real (r8 ) :: age ! notional age of this patch
208- type (ed_patch_type), pointer :: newp
209- !- ---------------------------------------------------------------------
210-
211- cwd_ag_local(:) = 0.0_r8 ! ED_val_init_litter -- arbitrary value for litter pools. kgC m-2
212- cwd_bg_local(:) = 0.0_r8 ! ED_val_init_litter
213- leaf_litter_local(:) = 0.0_r8
214- root_litter_local(:) = 0.0_r8
215- spread_local(:) = ED_val_maxspread
216- age = 0.0_r8
217-
218- ! FIX(SPM,032414) clean this up...inits out of this loop
219- do s = 1 , nsites
220-
221- allocate (newp)
222-
223- newp% patchno = 1
224- newp% younger = > null ()
225- newp% older = > null ()
226-
227- sites(s)% youngest_patch = > newp
228- sites(s)% youngest_patch = > newp
229- sites(s)% oldest_patch = > newp
230-
231- ! make new patch...
232- call create_patch(sites(s), newp, age, AREA, &
233- spread_local, cwd_ag_local, cwd_bg_local, leaf_litter_local, &
234- root_litter_local)
235-
236- call init_cohorts(newp, bc_in(s))
237-
238- ! This sets the rhizosphere shells based on the plant initialization
239- ! The initialization of the plant-relevant hydraulics variables
240- ! were set from a call inside of the init_cohorts()->create_cohort() subroutine
241- if (use_fates_plant_hydro) then
242- call updateSizeDepRhizHydProps(sites(s), bc_in(s))
243- end if
244-
245- enddo
196+ !
197+ ! !DESCRIPTION:
198+ ! initialize patches
199+ ! This may be call a near bare ground initialization, or it may
200+ ! load patches from an inventory.
201+
202+ !
203+
204+
205+ use EDParamsMod , only : ED_val_maxspread
206+ use FatesPlantHydraulicsMod, only : updateSizeDepRhizHydProps
207+ use FatesInventoryInitMod, only : initialize_sites_by_inventory
208+
209+ !
210+ ! !ARGUMENTS
211+ integer , intent (in ) :: nsites
212+ type (ed_site_type) , intent (inout ), target :: sites(nsites)
213+ type (bc_in_type), intent (in ) :: bc_in(nsites)
214+ !
215+ ! !LOCAL VARIABLES:
216+ integer :: s
217+ real (r8 ) :: cwd_ag_local(ncwd)
218+ real (r8 ) :: cwd_bg_local(ncwd)
219+ real (r8 ) :: spread_local(nclmax)
220+ real (r8 ) :: leaf_litter_local(numpft_ed)
221+ real (r8 ) :: root_litter_local(numpft_ed)
222+ real (r8 ) :: age ! notional age of this patch
223+ type (ed_patch_type), pointer :: newp
224+
225+ ! List out some nominal patch values that are used for Near Bear Ground initializations
226+ ! as well as initializing inventory
227+ ! ---------------------------------------------------------------------------------------------
228+ cwd_ag_local(:) = 0.0_r8 ! ED_val_init_litter -- arbitrary value for litter pools. kgC m-2
229+ cwd_bg_local(:) = 0.0_r8 ! ED_val_init_litter
230+ leaf_litter_local(:) = 0.0_r8
231+ root_litter_local(:) = 0.0_r8
232+ spread_local(:) = ED_val_maxspread
233+ age = 0.0_r8
234+ ! ---------------------------------------------------------------------------------------------
235+
236+ ! ---------------------------------------------------------------------------------------------
237+ ! Two primary options, either a Near Bear Ground (NBG) or Inventory based cold-start
238+ ! ---------------------------------------------------------------------------------------------
239+
240+ if (do_inv_init .eq. itrue) then
241+
242+ call initialize_sites_by_inventory(nsites,sites,bc_in)
243+
244+ do s = 1 , nsites
245+ if (use_fates_plant_hydro) then
246+ call updateSizeDepRhizHydProps(sites(s), bc_in(s))
247+ end if
248+ enddo
249+
250+ else
251+
252+ ! FIX(SPM,032414) clean this up...inits out of this loop
253+ do s = 1 , nsites
254+
255+ allocate (newp)
256+
257+ newp% patchno = 1
258+ newp% younger = > null ()
259+ newp% older = > null ()
260+
261+ sites(s)% youngest_patch = > newp
262+ sites(s)% youngest_patch = > newp
263+ sites(s)% oldest_patch = > newp
264+
265+ ! make new patch...
266+ call create_patch(sites(s), newp, age, AREA, &
267+ spread_local, cwd_ag_local, cwd_bg_local, leaf_litter_local, &
268+ root_litter_local)
269+
270+ call init_cohorts(newp, bc_in(s))
271+
272+ ! This sets the rhizosphere shells based on the plant initialization
273+ ! The initialization of the plant-relevant hydraulics variables
274+ ! were set from a call inside of the init_cohorts()->create_cohort() subroutine
275+ if (use_fates_plant_hydro) then
276+ call updateSizeDepRhizHydProps(sites(s), bc_in(s))
277+ end if
278+
279+ enddo
280+
281+ end if
246282
247283 end subroutine init_patches
248284
0 commit comments