Skip to content

Commit

Permalink
Merge pull request #862 from rgknox/params-maxpatch-logfinal
Browse files Browse the repository at this point in the history
parameter file updates
  • Loading branch information
rgknox authored Jun 21, 2022
2 parents 63bfacd + f054c85 commit 32bbd14
Show file tree
Hide file tree
Showing 29 changed files with 2,550 additions and 1,361 deletions.
13 changes: 6 additions & 7 deletions biogeochem/EDCanopyStructureMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ module EDCanopyStructureMod
use FatesInterfaceTypesMod , only : numpft
use FatesInterfaceTypesMod, only : bc_in_type
use FatesPlantHydraulicsMod, only : UpdateH2OVeg,InitHydrCohort, RecruitWaterStorage
use EDTypesMod , only : maxCohortsPerPatch
use PRTGenericMod, only : leaf_organ
use PRTGenericMod, only : all_carbon_elements
use PRTGenericMod, only : leaf_organ
Expand Down Expand Up @@ -1566,19 +1565,19 @@ subroutine leaf_area_profile( currentSite )
currentCohort => currentPatch%shortest
do while(associated(currentCohort))
ft = currentCohort%pft
min_chite = currentCohort%hite - currentCohort%hite * prt_params%crown(ft)
min_chite = currentCohort%hite - currentCohort%hite * prt_params%crown_depth_frac(ft)
max_chite = currentCohort%hite
do iv = 1,N_HITE_BINS
frac_canopy(iv) = 0.0_r8
! this layer is in the middle of the canopy
if(max_chite > maxh(iv).and.min_chite < minh(iv))then
frac_canopy(iv)= min(1.0_r8,dh / (currentCohort%hite*prt_params%crown(ft)))
frac_canopy(iv)= min(1.0_r8,dh / (currentCohort%hite*prt_params%crown_depth_frac(ft) ))
! this is the layer with the bottom of the canopy in it.
elseif(min_chite < maxh(iv).and.min_chite > minh(iv).and.max_chite > maxh(iv))then
frac_canopy(iv) = (maxh(iv) -min_chite ) / (currentCohort%hite*prt_params%crown(ft))
frac_canopy(iv) = (maxh(iv) -min_chite ) / (currentCohort%hite*prt_params%crown_depth_frac(ft) )
! this is the layer with the top of the canopy in it.
elseif(max_chite > minh(iv).and.max_chite < maxh(iv).and.min_chite < minh(iv))then
frac_canopy(iv) = (max_chite - minh(iv)) / (currentCohort%hite*prt_params%crown(ft))
frac_canopy(iv) = (max_chite - minh(iv)) / (currentCohort%hite*prt_params%crown_depth_frac(ft))
elseif(max_chite < maxh(iv).and.min_chite > minh(iv))then !the whole cohort is within this layer.
frac_canopy(iv) = 1.0_r8
endif
Expand Down Expand Up @@ -1674,11 +1673,11 @@ subroutine leaf_area_profile( currentSite )

layer_top_hite = currentCohort%hite - &
( real(iv-1,r8)/currentCohort%NV * currentCohort%hite * &
prt_params%crown(currentCohort%pft) )
prt_params%crown_depth_frac(currentCohort%pft) )

layer_bottom_hite = currentCohort%hite - &
( real(iv,r8)/currentCohort%NV * currentCohort%hite * &
prt_params%crown(currentCohort%pft) )
prt_params%crown_depth_frac(currentCohort%pft) )

fraction_exposed = 1.0_r8
if(currentSite%snow_depth > layer_top_hite)then
Expand Down
7 changes: 3 additions & 4 deletions biogeochem/EDCohortDynamicsMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ module EDCohortDynamicsMod
use FatesLitterMod , only : ncwd
use FatesLitterMod , only : ndcmpy
use FatesLitterMod , only : litter_type
use EDTypesMod , only : maxCohortsPerPatch
use EDParamsMod , only : max_cohort_per_patch
use EDTypesMod , only : AREA
use EDTypesMod , only : min_npm2, min_nppatch
use EDTypesMod , only : min_n_safemath
Expand Down Expand Up @@ -1072,7 +1072,6 @@ subroutine fuse_cohorts(currentSite, currentPatch, bc_in)
use FatesInterfaceTypesMod , only : hlm_use_cohort_age_tracking
use FatesConstantsMod , only : itrue
use FatesConstantsMod, only : days_per_year
use EDTypesMod , only : maxCohortsPerPatch

!
! !ARGUMENTS
Expand Down Expand Up @@ -1565,7 +1564,7 @@ subroutine fuse_cohorts(currentSite, currentPatch, bc_in)


if ( hlm_use_cohort_age_tracking .eq.itrue) then
if ( nocohorts > maxCohortsPerPatch ) then
if ( nocohorts > max_cohort_per_patch ) then
iterate = 1
!---------------------------------------------------------------------!
! Making profile tolerance larger means that more fusion will happen !
Expand All @@ -1580,7 +1579,7 @@ subroutine fuse_cohorts(currentSite, currentPatch, bc_in)

else

if (nocohorts > maxCohortsPerPatch) then
if (nocohorts > max_cohort_per_patch) then
iterate = 1
!---------------------------------------------------------------------!
! Making profile tolerance larger means that more fusion will happen !
Expand Down
24 changes: 13 additions & 11 deletions biogeochem/EDPatchDynamicsMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ module EDPatchDynamicsMod
use EDTypesMod , only : homogenize_seed_pfts
use EDTypesMod , only : n_dbh_bins, area, patchfusion_dbhbin_loweredges
use EDtypesMod , only : force_patchfuse_min_biomass
use EDTypesMod , only : maxPatchesPerSite
use EDTypesMod , only : maxPatchesPerSite_by_disttype
use EDTypesMod , only : ed_site_type, ed_patch_type, ed_cohort_type
use EDTypesMod , only : site_massbal_type
use EDTypesMod , only : site_fluxdiags_type
Expand Down Expand Up @@ -90,6 +88,9 @@ module EDPatchDynamicsMod
use SFParamsMod, only : SF_VAL_CWD_FRAC
use EDParamsMod, only : logging_event_code
use EDParamsMod, only : logging_export_frac
use EDParamsMod, only : maxpatch_primary
use EDParamsMod, only : maxpatch_secondary
use EDParamsMod, only : maxpatch_total
use FatesRunningMeanMod, only : ema_24hr, fixed_24hr, ema_lpa

! CIME globals
Expand Down Expand Up @@ -2319,15 +2320,16 @@ subroutine fuse_patches( csite, bc_in )
! to let there be one for each type of nocomp PFT on the site. this is likely to lead to problems
! if anthropogenic disturance is enabled.
if (hlm_use_nocomp.eq.itrue) then
maxpatches(primaryforest) = max(maxPatchesPerSite_by_disttype(primaryforest), sum(csite%use_this_pft))
maxpatches(secondaryforest) = maxPatchesPerSite - maxpatches(primaryforest)
if (maxPatchesPerSite .lt. maxpatches(primaryforest)) then
maxpatches(primaryforest) = max(maxpatch_primary, sum(csite%use_this_pft))
maxpatches(secondaryforest) = maxpatch_total - maxpatches(primaryforest)
if (maxpatch_total .lt. maxpatches(primaryforest)) then
write(fates_log(),*) 'too many PFTs and not enough patches for nocomp w/o fixed biogeog'
write(fates_log(),*) 'maxPatchesPerSite,numpft',maxPatchesPerSite,numpft, sum(csite%use_this_pft)
write(fates_log(),*) 'maxpatch_total,numpft',maxpatch_total,numpft, sum(csite%use_this_pft)
call endrun(msg=errMsg(sourcefile, __LINE__))
endif
else
maxpatches(:) = maxPatchesPerSite_by_disttype(:)
maxpatches(primaryforest) = maxpatch_primary
maxpatches(secondaryforest) = maxpatch_secondary
endif

currentPatch => currentSite%youngest_patch
Expand Down Expand Up @@ -2363,7 +2365,7 @@ subroutine fuse_patches( csite, bc_in )
iterate = 1

!---------------------------------------------------------------------!
! Keep doing this until nopatches <= maxPatchesPerSite !
! Keep doing this until nopatches <= maxpatch_total !
!---------------------------------------------------------------------!

iterate_eq_1_loop: do while(iterate == 1)
Expand Down Expand Up @@ -2505,10 +2507,10 @@ subroutine fuse_patches( csite, bc_in )
! a patch x patch loop, reset the patch fusion tolerance to the starting !
! value so that any subsequent fusions in this loop are done with that !
! value. otherwise we can end up in a situation where we've loosened the !
! fusion tolerance to get nopatches <= maxPatchesPerSite, but then, !
! fusion tolerance to get nopatches <= maxpatch_total, but then, !
! having accomplished that, we continue through all the patch x patch !
! combinations and then all the patches get fused, ending up with !
! nopatches << maxPatchesPerSite and losing all heterogeneity. !
! nopatches << maxpatch_total and losing all heterogeneity. !
!------------------------------------------------------------------------!

profiletol = ED_val_patch_fusion_tol
Expand Down Expand Up @@ -2567,7 +2569,7 @@ subroutine fuse_patches( csite, bc_in )
iterate = 0
endif

enddo iterate_eq_1_loop ! iterate .eq. 1 ==> nopatches>maxPatchesPerSite
enddo iterate_eq_1_loop ! iterate .eq. 1 ==> nopatches>maxpatch_total

end do disttype_loop

Expand Down
49 changes: 24 additions & 25 deletions biogeochem/EDPhysiologyMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -692,7 +692,6 @@ subroutine phenology( currentSite, bc_in )
use EDParamsMod, only : ED_val_phen_a, ED_val_phen_b, ED_val_phen_c, ED_val_phen_chiltemp
use EDParamsMod, only : ED_val_phen_mindayson, ED_val_phen_ncolddayslim, ED_val_phen_coldtemp


!
! !ARGUMENTS:
type(ed_site_type), intent(inout), target :: currentSite
Expand Down Expand Up @@ -1942,28 +1941,28 @@ subroutine recruitment( currentSite, currentPatch, bc_in )
case(nitrogen_element)

mass_demand = &
c_struct*prt_params%nitr_stoich_p2(ft,prt_params%organ_param_id(struct_organ)) + &
c_leaf*prt_params%nitr_stoich_p2(ft,prt_params%organ_param_id(leaf_organ)) + &
c_fnrt*prt_params%nitr_stoich_p2(ft,prt_params%organ_param_id(fnrt_organ)) + &
c_sapw*prt_params%nitr_stoich_p2(ft,prt_params%organ_param_id(sapw_organ)) + &
c_struct*prt_params%nitr_stoich_p1(ft,prt_params%organ_param_id(struct_organ)) + &
c_leaf*prt_params%nitr_stoich_p1(ft,prt_params%organ_param_id(leaf_organ)) + &
c_fnrt*prt_params%nitr_stoich_p1(ft,prt_params%organ_param_id(fnrt_organ)) + &
c_sapw*prt_params%nitr_stoich_p1(ft,prt_params%organ_param_id(sapw_organ)) + &
StorageNutrientTarget(ft, element_id, &
c_leaf*prt_params%nitr_stoich_p2(ft,prt_params%organ_param_id(leaf_organ)), &
c_fnrt*prt_params%nitr_stoich_p2(ft,prt_params%organ_param_id(fnrt_organ)), &
c_sapw*prt_params%nitr_stoich_p2(ft,prt_params%organ_param_id(sapw_organ)), &
c_struct*prt_params%nitr_stoich_p2(ft,prt_params%organ_param_id(struct_organ)))
c_leaf*prt_params%nitr_stoich_p1(ft,prt_params%organ_param_id(leaf_organ)), &
c_fnrt*prt_params%nitr_stoich_p1(ft,prt_params%organ_param_id(fnrt_organ)), &
c_sapw*prt_params%nitr_stoich_p1(ft,prt_params%organ_param_id(sapw_organ)), &
c_struct*prt_params%nitr_stoich_p1(ft,prt_params%organ_param_id(struct_organ)))

case(phosphorus_element)

mass_demand = &
c_struct*prt_params%phos_stoich_p2(ft,prt_params%organ_param_id(struct_organ)) + &
c_leaf*prt_params%phos_stoich_p2(ft,prt_params%organ_param_id(leaf_organ)) + &
c_fnrt*prt_params%phos_stoich_p2(ft,prt_params%organ_param_id(fnrt_organ)) + &
c_sapw*prt_params%phos_stoich_p2(ft,prt_params%organ_param_id(sapw_organ)) + &
c_struct*prt_params%phos_stoich_p1(ft,prt_params%organ_param_id(struct_organ)) + &
c_leaf*prt_params%phos_stoich_p1(ft,prt_params%organ_param_id(leaf_organ)) + &
c_fnrt*prt_params%phos_stoich_p1(ft,prt_params%organ_param_id(fnrt_organ)) + &
c_sapw*prt_params%phos_stoich_p1(ft,prt_params%organ_param_id(sapw_organ)) + &
StorageNutrientTarget(ft, element_id, &
c_leaf*prt_params%phos_stoich_p2(ft,prt_params%organ_param_id(leaf_organ)), &
c_fnrt*prt_params%phos_stoich_p2(ft,prt_params%organ_param_id(fnrt_organ)), &
c_sapw*prt_params%phos_stoich_p2(ft,prt_params%organ_param_id(sapw_organ)), &
c_struct*prt_params%phos_stoich_p2(ft,prt_params%organ_param_id(struct_organ)))
c_leaf*prt_params%phos_stoich_p1(ft,prt_params%organ_param_id(leaf_organ)), &
c_fnrt*prt_params%phos_stoich_p1(ft,prt_params%organ_param_id(fnrt_organ)), &
c_sapw*prt_params%phos_stoich_p1(ft,prt_params%organ_param_id(sapw_organ)), &
c_struct*prt_params%phos_stoich_p1(ft,prt_params%organ_param_id(struct_organ)))

case default
write(fates_log(),*) 'Undefined element type in recruitment'
Expand Down Expand Up @@ -2017,19 +2016,19 @@ subroutine recruitment( currentSite, currentPatch, bc_in )

case(nitrogen_element)

m_struct = c_struct*prt_params%nitr_stoich_p2(ft,prt_params%organ_param_id(struct_organ))
m_leaf = c_leaf*prt_params%nitr_stoich_p2(ft,prt_params%organ_param_id(leaf_organ))
m_fnrt = c_fnrt*prt_params%nitr_stoich_p2(ft,prt_params%organ_param_id(fnrt_organ))
m_sapw = c_sapw*prt_params%nitr_stoich_p2(ft,prt_params%organ_param_id(sapw_organ))
m_struct = c_struct*prt_params%nitr_stoich_p1(ft,prt_params%organ_param_id(struct_organ))
m_leaf = c_leaf*prt_params%nitr_stoich_p1(ft,prt_params%organ_param_id(leaf_organ))
m_fnrt = c_fnrt*prt_params%nitr_stoich_p1(ft,prt_params%organ_param_id(fnrt_organ))
m_sapw = c_sapw*prt_params%nitr_stoich_p1(ft,prt_params%organ_param_id(sapw_organ))
m_store = StorageNutrientTarget(ft, element_id, m_leaf, m_fnrt, m_sapw, m_struct )
m_repro = 0._r8

case(phosphorus_element)

m_struct = c_struct*prt_params%phos_stoich_p2(ft,prt_params%organ_param_id(struct_organ))
m_leaf = c_leaf*prt_params%phos_stoich_p2(ft,prt_params%organ_param_id(leaf_organ))
m_fnrt = c_fnrt*prt_params%phos_stoich_p2(ft,prt_params%organ_param_id(fnrt_organ))
m_sapw = c_sapw*prt_params%phos_stoich_p2(ft,prt_params%organ_param_id(sapw_organ))
m_struct = c_struct*prt_params%phos_stoich_p1(ft,prt_params%organ_param_id(struct_organ))
m_leaf = c_leaf*prt_params%phos_stoich_p1(ft,prt_params%organ_param_id(leaf_organ))
m_fnrt = c_fnrt*prt_params%phos_stoich_p1(ft,prt_params%organ_param_id(fnrt_organ))
m_sapw = c_sapw*prt_params%phos_stoich_p1(ft,prt_params%organ_param_id(sapw_organ))
m_store = StorageNutrientTarget(ft, element_id, m_leaf, m_fnrt, m_sapw, m_struct )
m_repro = 0._r8

Expand Down
2 changes: 1 addition & 1 deletion biogeochem/FatesAllometryMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -2008,7 +2008,7 @@ subroutine CrownDepth(height,ft,crown_depth)
! Original FATES crown depth heigh used for hydraulics
! crown_depth = min(height,0.1_r8)

crown_depth = prt_params%crown(ft) * height
crown_depth = prt_params%crown_depth_frac(ft) * height


return
Expand Down
1 change: 0 additions & 1 deletion biogeophys/EDSurfaceAlbedoMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ module EDSurfaceRadiationMod
#include "shr_assert.h"

use EDTypesMod , only : ed_patch_type, ed_site_type
use EDTypesMod , only : maxPatchesPerSite
use EDTypesMod , only : maxpft
use FatesConstantsMod , only : r8 => fates_r8
use FatesConstantsMod , only : itrue
Expand Down
18 changes: 9 additions & 9 deletions biogeophys/FatesPlantHydraulicsMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ module FatesPlantHydraulicsMod
use EDParamsMod , only : hydr_psi0
use EDParamsMod , only : hydr_psicap
use EDParamsMod , only : hydr_htftype_node
use EDParamsMod , only : hydr_solver_type
use EDParamsMod , only : hydr_solver

use EDTypesMod , only : ed_site_type
use EDTypesMod , only : ed_patch_type
Expand Down Expand Up @@ -1468,7 +1468,7 @@ subroutine InitHydrSites(sites,bc_in)
case(rhizlayer_aggmeth_none)

csite_hydr%nlevrhiz = bc_in(s)%nlevsoil
call sites(s)%si_hydr%InitHydrSite(numpft,nlevsclass,hydr_solver_type,bc_in(s)%nlevsoil)
call sites(s)%si_hydr%InitHydrSite(numpft,nlevsclass,hydr_solver,bc_in(s)%nlevsoil)

do j=1,csite_hydr%nlevrhiz
csite_hydr%map_r2s(j,1) = j
Expand All @@ -1480,7 +1480,7 @@ subroutine InitHydrSites(sites,bc_in)
case(rhizlayer_aggmeth_combine12)

csite_hydr%nlevrhiz = max(1,bc_in(s)%nlevsoil-1)
call sites(s)%si_hydr%InitHydrSite(numpft,nlevsclass,hydr_solver_type,bc_in(s)%nlevsoil)
call sites(s)%si_hydr%InitHydrSite(numpft,nlevsclass,hydr_solver,bc_in(s)%nlevsoil)

csite_hydr%map_r2s(1,1) = 1
j_bc = min(2,bc_in(s)%nlevsoil) ! this protects 1 soil layer
Expand All @@ -1498,7 +1498,7 @@ subroutine InitHydrSites(sites,bc_in)
case(rhizlayer_aggmeth_balN)

csite_hydr%nlevrhiz = min(aggN,bc_in(s)%nlevsoil)
call sites(s)%si_hydr%InitHydrSite(numpft,nlevsclass,hydr_solver_type,bc_in(s)%nlevsoil)
call sites(s)%si_hydr%InitHydrSite(numpft,nlevsclass,hydr_solver,bc_in(s)%nlevsoil)

ntoagg = int(ceiling(real(bc_in(s)%nlevsoil)/real(csite_hydr%nlevrhiz)-nearzero))

Expand Down Expand Up @@ -2627,21 +2627,21 @@ subroutine hydraulics_bc ( nsites, sites, bc_in, bc_out, dtime)
! from leaf to the current soil layer. This does NOT
! update cohort%th_*

if(hydr_solver_type == hydr_solver_2DNewton) then
if(hydr_solver == hydr_solver_2DNewton) then

call MatSolve2D(csite_hydr,ccohort,ccohort_hydr, &
dtime,qflx_tran_veg_indiv, &
sapflow,rootuptake(1:nlevrhiz),wb_err_plant,dwat_plant, &
dth_layershell_col)

elseif(hydr_solver_type == hydr_solver_2DPicard) then
elseif(hydr_solver == hydr_solver_2DPicard) then

call PicardSolve2D(csite_hydr,ccohort,ccohort_hydr, &
dtime,qflx_tran_veg_indiv, &
sapflow,rootuptake(1:nlevrhiz),wb_err_plant,dwat_plant, &
dth_layershell_col,csite_hydr%num_nodes)

elseif(hydr_solver_type == hydr_solver_1DTaylor ) then
elseif(hydr_solver == hydr_solver_1DTaylor ) then

! ---------------------------------------------------------------------------------
! Approach: do nlevsoi_hyd sequential solutions to Richards' equation,
Expand Down Expand Up @@ -4942,7 +4942,7 @@ subroutine MatSolve2D(csite_hydr,cohort,cohort_hydr, &


! This NaN's the scratch arrays
call csite_hydr%FlushSiteScratch(hydr_solver_type)
call csite_hydr%FlushSiteScratch(hydr_solver)

! This is the maximum number of iterations needed for this cohort
! (each soil layer has a different number, this saves the max)
Expand Down Expand Up @@ -5725,7 +5725,7 @@ subroutine PicardSolve2D(csite_hydr,cohort,cohort_hydr, &


! This NaN's the scratch arrays
call csite_hydr%FlushSiteScratch(hydr_solver_type)
call csite_hydr%FlushSiteScratch(hydr_solver)

! This is the maximum number of iterations needed for this cohort
! (each soil layer has a different number, this saves the max)
Expand Down
Loading

0 comments on commit 32bbd14

Please sign in to comment.