Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parteh scaling fixes #716

Merged
merged 35 commits into from
May 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
9a9505f
Fixes to parteh scaling algorithm, particularly trivial boundary cond…
rgknox Nov 10, 2020
8fdb1d9
cnp boundary scaling fixes
rgknox Nov 10, 2020
54fc2d6
Condensing the N/P need diagnostics
rgknox Nov 11, 2020
60fb19c
Updated need algorithm to use storage deficit
rgknox Nov 11, 2020
8c3a99a
Updates to parteh and nutrient coupling. Mostly related to defining m…
rgknox Nov 16, 2020
3b0d8b1
Initial code prep for logistic function to affect the cn_scalar in FA…
rgknox Dec 3, 2020
e1bf0a3
Updated cn_scalar calculations and nutrient storage target
rgknox Dec 3, 2020
c8778be
Updates to CNP storage and cn_scalar
rgknox Dec 8, 2020
74c320b
Updated regulating function for N storage recovering
rgknox Jan 24, 2021
941bd8f
Refactored parameter file to remove reproductive and storage organs f…
rgknox Jan 27, 2021
e19ed47
scaling fixes fixes
rgknox Jan 28, 2021
e50d027
Tweaked some order of operations in CNP allocation module
rgknox Jan 29, 2021
d6ab00c
Placed cap on N/P storage fraction when calculating CN_scalar
rgknox Jan 29, 2021
8e10af7
Removed N+P efflux from CNP model, as uptake downregulation will now …
rgknox Jan 30, 2021
66f3d4c
parteh updates: 1) new downregulation (linear and CN) functions for E…
rgknox Feb 15, 2021
bd8632a
Updates to history variables, adding NH4 and NO3 uptake diagnostics. …
rgknox Feb 18, 2021
cf623b0
bug fix on calculation of cn_scalar and cp_scalar for eca
rgknox Feb 21, 2021
2bbe5f9
Updated some default parameters for parteh=2
rgknox Apr 2, 2021
26470bb
Merge branch 'master' into parteh-scaling-fixes
rgknox Apr 2, 2021
7b20839
Merged in updates to the cnscalar formulation, storage nutrient calcu…
rgknox Apr 6, 2021
ff0fee8
removing unused code for demand calculations in new plants
rgknox Apr 6, 2021
1d5a73c
Reverted to nclmax=2, as that would be a different feature to use >2
rgknox Apr 7, 2021
094a752
minor comment and cleanings to FatesSoilBGCFluxMod.F90
rgknox Apr 7, 2021
aeaca30
Moved storage nutrient calculation to PRTGeneric and call it from mor…
rgknox Apr 9, 2021
b9d43e3
Adding thaw-depth to root depth calculations
rgknox Apr 10, 2021
11d71eb
debugging issues with nutrient coupling
rgknox Apr 23, 2021
3e675e9
Cleaning of debugging during cnp coupling developments
rgknox Apr 30, 2021
e3a783a
Remove print statement
rgknox Apr 30, 2021
3bf95e1
Added output boundary conditions for communication with CH4 model. Ad…
rgknox May 3, 2021
554165b
Added woody fraction bc for ch4 coupling
rgknox May 4, 2021
593ee03
Updated CH4 coupling with ELM/CLM to utilize use_ch4 coupling flag, w…
rgknox May 4, 2021
936ebee
Merge branch 'master' into parteh-scaling-fixes-may05
rgknox May 5, 2021
cce7113
Fixes to litter generation and what organs are filtered
rgknox May 10, 2021
b77a0d5
Revereted canopy layer and max cohort counts to maintain consistency …
rgknox May 10, 2021
0f7b617
Reverting bc_in_ptr and bc_out_ptr, because nag.
rgknox May 25, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions biogeochem/EDCanopyStructureMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -197,25 +197,25 @@ subroutine canopy_structure( currentSite , bc_in )

! Its possible that before we even enter this scheme
! some cohort numbers are very low. Terminate them.
call terminate_cohorts(currentSite, currentPatch, 1, 12)
call terminate_cohorts(currentSite, currentPatch, 1, 12, bc_in)

! Calculate how many layers we have in this canopy
! This also checks the understory to see if its crown
! area is large enough to warrant a temporary sub-understory layer
z = NumPotentialCanopyLayers(currentPatch,currentSite%spread,include_substory=.false.)

do i_lyr = 1,z ! Loop around the currently occupied canopy layers.
call DemoteFromLayer(currentSite, currentPatch, i_lyr)
call DemoteFromLayer(currentSite, currentPatch, i_lyr, bc_in)
end do

! After demotions, we may then again have cohorts that are very very
! very sparse, remove them
call terminate_cohorts(currentSite, currentPatch, 1,13)
call terminate_cohorts(currentSite, currentPatch, 1,13,bc_in)

call fuse_cohorts(currentSite, currentPatch, bc_in)

! Remove cohorts for various other reasons
call terminate_cohorts(currentSite, currentPatch, 2,13)
call terminate_cohorts(currentSite, currentPatch, 2,13,bc_in)


! ---------------------------------------------------------------------------------------
Expand All @@ -234,12 +234,12 @@ subroutine canopy_structure( currentSite , bc_in )
end do

! Remove cohorts that are incredibly sparse
call terminate_cohorts(currentSite, currentPatch, 1,14)
call terminate_cohorts(currentSite, currentPatch, 1,14,bc_in)

call fuse_cohorts(currentSite, currentPatch, bc_in)

! Remove cohorts for various other reasons
call terminate_cohorts(currentSite, currentPatch, 2,14)
call terminate_cohorts(currentSite, currentPatch, 2,14,bc_in)

end if

Expand Down Expand Up @@ -332,7 +332,7 @@ end subroutine canopy_structure
! ==============================================================================================


subroutine DemoteFromLayer(currentSite,currentPatch,i_lyr)
subroutine DemoteFromLayer(currentSite,currentPatch,i_lyr,bc_in)

use EDParamsMod, only : ED_val_comp_excln
use SFParamsMod, only : SF_val_CWD_frac
Expand All @@ -341,7 +341,8 @@ subroutine DemoteFromLayer(currentSite,currentPatch,i_lyr)
type(ed_site_type), intent(inout), target :: currentSite
type(ed_patch_type), intent(inout), target :: currentPatch
integer, intent(in) :: i_lyr ! Current canopy layer of interest

type(bc_in_type), intent(in) :: bc_in

! !LOCAL VARIABLES:
type(ed_cohort_type), pointer :: currentCohort
type(ed_cohort_type), pointer :: copyc
Expand Down Expand Up @@ -720,7 +721,7 @@ subroutine DemoteFromLayer(currentSite,currentPatch,i_lyr)
! put the litter from the terminated cohorts
! straight into the fragmenting pools
call SendCohortToLitter(currentSite,currentPatch, &
currentCohort,currentCohort%n)
currentCohort,currentCohort%n,bc_in)

currentCohort%n = 0.0_r8
currentCohort%c_area = 0.0_r8
Expand Down
77 changes: 36 additions & 41 deletions biogeochem/EDCohortDynamicsMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,11 @@ module EDCohortDynamicsMod
use PRTAllometricCNPMod, only : acnp_bc_in_id_pft, acnp_bc_in_id_ctrim
use PRTAllometricCNPMod, only : acnp_bc_in_id_lstat, acnp_bc_inout_id_dbh
use PRTAllometricCNPMod, only : acnp_bc_inout_id_rmaint_def, acnp_bc_in_id_netdc
use PRTAllometricCNPMod, only : acnp_bc_in_id_netdn, acnp_bc_in_id_netdp
use PRTAllometricCNPMod, only : acnp_bc_in_id_netdnh4, acnp_bc_in_id_netdno3, acnp_bc_in_id_netdp
use PRTAllometricCNPMod, only : acnp_bc_out_id_cefflux, acnp_bc_out_id_nefflux
use PRTAllometricCNPMod, only : acnp_bc_out_id_pefflux
use PRTAllometricCNPMod, only : acnp_bc_out_id_ngrow,acnp_bc_out_id_nmax
use PRTAllometricCNPMod, only : acnp_bc_out_id_pgrow,acnp_bc_out_id_pmax
use PRTAllometricCNPMod, only : acnp_bc_out_id_nneed
use PRTAllometricCNPMod, only : acnp_bc_out_id_pneed


use shr_infnan_mod, only : nan => shr_infnan_nan, assignment(=)
Expand Down Expand Up @@ -400,7 +400,8 @@ subroutine InitPRTBoundaryConditions(new_cohort)
call new_cohort%prt%RegisterBCIn(acnp_bc_in_id_ctrim,bc_rval = new_cohort%canopy_trim)
call new_cohort%prt%RegisterBCIn(acnp_bc_in_id_lstat,bc_ival = new_cohort%status_coh)
call new_cohort%prt%RegisterBCIn(acnp_bc_in_id_netdc, bc_rval = new_cohort%npp_acc)
call new_cohort%prt%RegisterBCIn(acnp_bc_in_id_netdn, bc_rval = new_cohort%daily_n_uptake)
call new_cohort%prt%RegisterBCIn(acnp_bc_in_id_netdnh4, bc_rval = new_cohort%daily_nh4_uptake)
call new_cohort%prt%RegisterBCIn(acnp_bc_in_id_netdno3, bc_rval = new_cohort%daily_no3_uptake)
call new_cohort%prt%RegisterBCIn(acnp_bc_in_id_netdp, bc_rval = new_cohort%daily_p_uptake)

call new_cohort%prt%RegisterBCInOut(acnp_bc_inout_id_dbh,bc_rval = new_cohort%dbh)
Expand All @@ -409,10 +410,8 @@ subroutine InitPRTBoundaryConditions(new_cohort)
call new_cohort%prt%RegisterBCOut(acnp_bc_out_id_cefflux, bc_rval = new_cohort%daily_c_efflux)
call new_cohort%prt%RegisterBCOut(acnp_bc_out_id_nefflux, bc_rval = new_cohort%daily_n_efflux)
call new_cohort%prt%RegisterBCOut(acnp_bc_out_id_pefflux, bc_rval = new_cohort%daily_p_efflux)
call new_cohort%prt%RegisterBCOut(acnp_bc_out_id_ngrow, bc_rval = new_cohort%daily_n_need1)
call new_cohort%prt%RegisterBCOut(acnp_bc_out_id_nmax, bc_rval = new_cohort%daily_n_need2)
call new_cohort%prt%RegisterBCOut(acnp_bc_out_id_pgrow, bc_rval = new_cohort%daily_p_need1)
call new_cohort%prt%RegisterBCOut(acnp_bc_out_id_pmax, bc_rval = new_cohort%daily_p_need2)
call new_cohort%prt%RegisterBCOut(acnp_bc_out_id_nneed, bc_rval = new_cohort%daily_n_need)
call new_cohort%prt%RegisterBCOut(acnp_bc_out_id_pneed, bc_rval = new_cohort%daily_p_need)


case DEFAULT
Expand Down Expand Up @@ -559,15 +558,14 @@ subroutine nan_cohort(cc_p)
currentCohort%resp_acc = nan ! RESP: kGC/cohort/day

! Fluxes from nutrient allocation
currentCohort%daily_n_uptake = nan
currentCohort%daily_nh4_uptake = nan
currentCohort%daily_no3_uptake = nan
currentCohort%daily_p_uptake = nan
currentCohort%daily_c_efflux = nan
currentCohort%daily_n_efflux = nan
currentCohort%daily_p_efflux = nan
currentCohort%daily_n_need1 = nan
currentCohort%daily_n_need2 = nan
currentCohort%daily_p_need1 = nan
currentCohort%daily_p_need2 = nan
currentCohort%daily_n_need = nan
currentCohort%daily_p_need = nan
currentCohort%daily_n_demand = nan
currentCohort%daily_p_demand = nan

Expand Down Expand Up @@ -678,17 +676,16 @@ subroutine zero_cohort(cc_p)
! after allocation. These variables exist in
! carbon-only mode but are not used.

currentCohort%daily_n_uptake = 0._r8
currentCohort%daily_nh4_uptake = 0._r8
currentCohort%daily_no3_uptake = 0._r8
currentCohort%daily_p_uptake = 0._r8

currentCohort%daily_c_efflux = 0._r8
currentCohort%daily_n_efflux = 0._r8
currentCohort%daily_p_efflux = 0._r8

currentCohort%daily_n_need1 = 0._r8
currentCohort%daily_n_need2 = 0._r8
currentCohort%daily_p_need1 = 0._r8
currentCohort%daily_p_need2 = 0._r8
currentCohort%daily_n_need = 0._r8
currentCohort%daily_p_need = 0._r8

! Initialize these as negative
currentCohort%daily_p_demand = -9._r8
Expand All @@ -698,7 +695,7 @@ subroutine zero_cohort(cc_p)
end subroutine zero_cohort

!-------------------------------------------------------------------------------------!
subroutine terminate_cohorts( currentSite, currentPatch, level , call_index)
subroutine terminate_cohorts( currentSite, currentPatch, level , call_index, bc_in)
!
! !DESCRIPTION:
! terminates cohorts when they get too small
Expand All @@ -711,7 +708,8 @@ subroutine terminate_cohorts( currentSite, currentPatch, level , call_index)
type (ed_patch_type), intent(inout), target :: currentPatch
integer , intent(in) :: level
integer :: call_index

type(bc_in_type), intent(in) :: bc_in

! Important point regarding termination levels. Termination is typically
! called after fusion. We do this so that we can re-capture the biomass that would
! otherwise be lost from termination. The biomass of a fused plant remains in the
Expand Down Expand Up @@ -827,7 +825,7 @@ subroutine terminate_cohorts( currentSite, currentPatch, level , call_index)

if (currentCohort%n.gt.0.0_r8) then
call SendCohortToLitter(currentSite,currentPatch, &
currentCohort,currentCohort%n)
currentCohort,currentCohort%n,bc_in)
end if

! Set pointers and remove the current cohort from the list
Expand Down Expand Up @@ -861,7 +859,7 @@ end subroutine terminate_cohorts

! =====================================================================================

subroutine SendCohortToLitter(csite,cpatch,ccohort,nplant)
subroutine SendCohortToLitter(csite,cpatch,ccohort,nplant,bc_in)

! -----------------------------------------------------------------------------------
! This routine transfers the existing mass in all pools and all elements
Expand All @@ -884,9 +882,9 @@ subroutine SendCohortToLitter(csite,cpatch,ccohort,nplant)
type (ed_patch_type) , target :: cpatch
type (ed_cohort_type) , target :: ccohort
real(r8) :: nplant ! Number (absolute)
! of plants to transfer
! of plants to transfer
type(bc_in_type), intent(in) :: bc_in

!
type(litter_type), pointer :: litt ! Litter object for each element
type(site_fluxdiags_type),pointer :: flux_diags

Expand All @@ -910,7 +908,8 @@ subroutine SendCohortToLitter(csite,cpatch,ccohort,nplant)

plant_dens = nplant/cpatch%area

call set_root_fraction(csite%rootfrac_scr, pft, csite%zi_soil)
call set_root_fraction(csite%rootfrac_scr, pft, csite%zi_soil, &
bc_in%max_rooting_depth_index_col)

do el=1,num_elements

Expand Down Expand Up @@ -1396,8 +1395,10 @@ subroutine fuse_cohorts(currentSite, currentPatch, bc_in)
currentCohort%frmort = (currentCohort%n*currentCohort%frmort + nextc%n*nextc%frmort)/newn

! Nutrient fluxes
currentCohort%daily_n_uptake = (currentCohort%n*currentCohort%daily_n_uptake + &
nextc%n*nextc%daily_n_uptake)/newn
currentCohort%daily_nh4_uptake = (currentCohort%n*currentCohort%daily_nh4_uptake + &
nextc%n*nextc%daily_nh4_uptake)/newn
currentCohort%daily_no3_uptake = (currentCohort%n*currentCohort%daily_no3_uptake + &
nextc%n*nextc%daily_no3_uptake)/newn
currentCohort%daily_p_uptake = (currentCohort%n*currentCohort%daily_p_uptake + &
nextc%n*nextc%daily_p_uptake)/newn

Expand All @@ -1413,15 +1414,10 @@ subroutine fuse_cohorts(currentSite, currentPatch, bc_in)
currentCohort%daily_p_efflux = (currentCohort%n*currentCohort%daily_p_efflux + &
nextc%n*nextc%daily_p_efflux)/newn

currentCohort%daily_n_need1 = (currentCohort%n*currentCohort%daily_n_need1 + &
nextc%n*nextc%daily_n_need1)/newn
currentCohort%daily_n_need2 = (currentCohort%n*currentCohort%daily_n_need2 + &
nextc%n*nextc%daily_n_need2)/newn
currentCohort%daily_p_need1 = (currentCohort%n*currentCohort%daily_p_need1 + &
nextc%n*nextc%daily_p_need1)/newn
currentCohort%daily_p_need2 = (currentCohort%n*currentCohort%daily_p_need2 + &
nextc%n*nextc%daily_p_need2)/newn

currentCohort%daily_n_need = (currentCohort%n*currentCohort%daily_n_need + &
nextc%n*nextc%daily_n_need)/newn
currentCohort%daily_p_need = (currentCohort%n*currentCohort%daily_p_need + &
nextc%n*nextc%daily_p_need)/newn


! logging mortality, Yi Xu
Expand Down Expand Up @@ -1817,15 +1813,14 @@ subroutine copy_cohort( currentCohort,copyc )
n%year_net_uptake = o%year_net_uptake
n%ts_net_uptake = o%ts_net_uptake

n%daily_n_uptake = o%daily_n_uptake
n%daily_nh4_uptake = o%daily_nh4_uptake
n%daily_no3_uptake = o%daily_no3_uptake
n%daily_p_uptake = o%daily_p_uptake
n%daily_c_efflux = o%daily_c_efflux
n%daily_n_efflux = o%daily_n_efflux
n%daily_p_efflux = o%daily_p_efflux
n%daily_n_need1 = o%daily_n_need1
n%daily_n_need2 = o%daily_n_need2
n%daily_p_need1 = o%daily_p_need1
n%daily_p_need2 = o%daily_p_need2
n%daily_n_need = o%daily_n_need
n%daily_p_need = o%daily_p_need
n%daily_n_demand = o%daily_n_demand
n%daily_p_demand = o%daily_p_demand

Expand Down
9 changes: 7 additions & 2 deletions biogeochem/EDLoggingMortalityMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ module EDLoggingMortalityMod
use EDParamsMod , only : logging_mechanical_frac
use EDParamsMod , only : logging_coll_under_frac
use EDParamsMod , only : logging_dbhmax_infra
use FatesInterfaceTypesMod , only : bc_in_type
use FatesInterfaceTypesMod , only : hlm_current_year
use FatesInterfaceTypesMod , only : hlm_current_month
use FatesInterfaceTypesMod , only : hlm_current_day
Expand Down Expand Up @@ -394,7 +395,7 @@ end subroutine get_harvest_rate_area

! ============================================================================

subroutine logging_litter_fluxes(currentSite, currentPatch, newPatch, patch_site_areadis)
subroutine logging_litter_fluxes(currentSite, currentPatch, newPatch, patch_site_areadis, bc_in)

! -------------------------------------------------------------------------------------------
!
Expand Down Expand Up @@ -440,6 +441,8 @@ subroutine logging_litter_fluxes(currentSite, currentPatch, newPatch, patch_site
type(ed_patch_type) , intent(inout), target :: currentPatch
type(ed_patch_type) , intent(inout), target :: newPatch
real(r8) , intent(in) :: patch_site_areadis
type(bc_in_type) , intent(in) :: bc_in


!LOCAL VARIABLES:
type(ed_cohort_type), pointer :: currentCohort
Expand Down Expand Up @@ -567,7 +570,9 @@ subroutine logging_litter_fluxes(currentSite, currentPatch, newPatch, patch_site
! derived from the current patch, so we need to multiply by patch_areadis/np%area
! ----------------------------------------------------------------------------------------

call set_root_fraction(currentSite%rootfrac_scr, pft, currentSite%zi_soil)
call set_root_fraction(currentSite%rootfrac_scr, pft, &
currentSite%zi_soil, &
bc_in%max_rooting_depth_index_col)

ag_wood = (direct_dead+indirect_dead) * (struct_m + sapw_m ) * &
prt_params%allom_agb_frac(currentCohort%pft)
Expand Down
1 change: 0 additions & 1 deletion biogeochem/EDMortalityFunctionsMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ module EDMortalityFunctionsMod
use FatesInterfaceTypesMod , only : hlm_use_planthydro
use EDLoggingMortalityMod , only : LoggingMortality_frac
use EDParamsMod , only : fates_mortality_disturbance_fraction
use FatesInterfaceTypesMod , only : bc_in_type

use PRTGenericMod, only : all_carbon_elements
use PRTGenericMod, only : store_organ
Expand Down
Loading