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

nutrient dynamics v2 of allocation and acquisition #880

Merged
merged 61 commits into from
Dec 2, 2022
Merged
Show file tree
Hide file tree
Changes from 48 commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
751490c
Setting target_m to dummy value to overcome IBM issues with base func…
rgknox Oct 18, 2021
9563af1
NCLMax = 3
rgknox Oct 28, 2021
7191021
Added nutrient storage limit and derivative to test effects on statur…
rgknox Oct 30, 2021
949e9ca
fixed logic limiting growth
rgknox Nov 3, 2021
5084a1d
Adjusted growth restrictions and uptake downregulation so that downre…
rgknox Nov 4, 2021
760e870
First complete pass-through on having a dynamic root response to nutr…
rgknox Nov 6, 2021
6f1b1ca
Work on dynamic root responses to nutrient availability
rgknox Nov 18, 2021
e1d88b1
version 2 of fates nutrient aquisition, bug fixes and enabling dynami…
rgknox Nov 24, 2021
561750f
Updates to fates nutrient coupling and feedback algorithm. Modified p…
rgknox Dec 3, 2021
f2a9b05
Adding l2fr to the restarts, updating soil root biomass diagnostic
rgknox Jan 1, 2022
9b50744
Updates to fates history variables for NP cycling
rgknox Jan 20, 2022
04c454f
Incremental work on l2fr searching
rgknox Feb 2, 2022
9f49427
Resolved conflicts between long-lived CNP update 2 branch and API 20
rgknox Feb 3, 2022
6bd5eb1
Updated l2fr diagnostics to be canopy and understory
rgknox Feb 3, 2022
b570617
Fixed l2fr and storage fraction history fields, updated some name con…
rgknox Feb 8, 2022
7a4a95a
Incremental work towards getting dynamic root response c/n balance to…
rgknox Feb 20, 2022
12f824d
Incremental changes towards fine-root biomass adaptation to N:C and P…
rgknox Feb 24, 2022
d017a31
merging in Charlies sym fix code
ckoven Oct 29, 2021
c4422f1
various updates to the cnp acquisition algorithm, including symbiotic…
rgknox Mar 15, 2022
1e34c39
Various updates to l2fr search algorithm
rgknox Apr 1, 2022
2326459
Added some parameters that were hard coded constants to the parameter…
rgknox Apr 15, 2022
5f44bfa
Added carbon storage fraction by sizexpft ustory/canopy
rgknox Apr 15, 2022
7b1a8b7
Started work on root reabsorption for cnp optimization
rgknox Apr 15, 2022
8fc9706
Merge branch 'cnp-dynamic-root-allom-dfdd-api21-symfix' of github.com…
rgknox Apr 15, 2022
7a1178f
CNP updates, small modifications to things like root trimming and lim…
rgknox May 6, 2022
8762093
cleaning up the cnp version 2 allocation code, adding in a diagnostic…
rgknox May 24, 2022
36491b9
Adding recruit l2fr and smoothing to the f_cn function
rgknox Jul 29, 2022
a75b6d6
Adding canopy layer x size x pft history diagnostics
rgknox Aug 3, 2022
434c0e0
Added in CNP limiter logic
rgknox Aug 8, 2022
893e227
Alternative PID error terms in CNP
rgknox Aug 9, 2022
681e4f5
Testing different PID controller methods and data prep methods.
rgknox Aug 14, 2022
43ee9b9
yet more reorganization and PID algorithm testing
rgknox Aug 19, 2022
8df96ae
various code modifications while exploring PID functions
rgknox Sep 21, 2022
75a7710
Updating parameter names to include PID. Cleaning up parteh CNP code
rgknox Sep 22, 2022
18bde56
Merge CNP branch up to API 24, resolve conflicts
rgknox Sep 22, 2022
13303d1
Updated parameter format to add PID terms, remove adaptive timescale …
rgknox Sep 22, 2022
2ae674c
Updating parameters for CNP, and various code cleaning for CNP
rgknox Sep 23, 2022
5d17995
Merge resolution fixes between CNP v2 and api24
rgknox Sep 23, 2022
26ee582
merge resolutions and parameter stuff
rgknox Sep 24, 2022
6e019d2
Updates to parameter file
rgknox Sep 24, 2022
06757ed
updating patch files
rgknox Sep 24, 2022
4465d7c
More merge resolutions between cnp v2 and api24
rgknox Sep 25, 2022
d490584
Cleanup in PRTAllometricCNP
rgknox Oct 11, 2022
68d71c2
More cleanup CNP growth code, removal of unused variables, labels, un…
rgknox Oct 11, 2022
cf89717
cnp v2, syntax cleanup
rgknox Oct 14, 2022
91bd865
cnp cleanup: change p uptake to p gain for consistency, remove tempor…
rgknox Oct 17, 2022
4ee19d2
Reverting nclmax
rgknox Oct 17, 2022
b194c1f
Clean up of fates cnp restart code and testing
rgknox Oct 19, 2022
9e69a0f
Added NPP boundary condition with ELM/CLM to enable npp hypothesis on…
rgknox Nov 8, 2022
f360032
first pass at resolving conflicts between nutrient cycling v2 and cro…
rgknox Nov 9, 2022
20e1c76
fixes to symbiotic fixation
rgknox Nov 9, 2022
fa8841e
update to bci xml parameter patch
rgknox Nov 15, 2022
c1f49d2
Merge branch 'master' into cnp-dynamic-root-allom-dfdd-api21-symfix
rgknox Nov 17, 2022
fb5a9de
Updated the fates default parameter file API update xmls
rgknox Nov 28, 2022
dd6f067
fix typo on carbon12_element
rgknox Nov 29, 2022
ab7af56
bug fix in fineroot allometry
rgknox Nov 29, 2022
9f6b8e9
Removed unused variable
rgknox Nov 29, 2022
b746edd
Reverting nclmax to 2
rgknox Nov 30, 2022
89cf208
fixed integration array indices for CNP
rgknox Nov 30, 2022
d3279d3
Removed the CLSZPF dimension temporarily to pass clm tests
rgknox Dec 1, 2022
3027e30
Merge resolution between v2 nutrients and the hydro pointer bug fix
rgknox Dec 1, 2022
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
86 changes: 48 additions & 38 deletions biogeochem/EDCanopyStructureMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,14 @@ module EDCanopyStructureMod
use FatesInterfaceTypesMod, only : bc_in_type
use FatesPlantHydraulicsMod, only : UpdateH2OVeg,InitHydrCohort, RecruitWaterStorage
use PRTGenericMod, only : leaf_organ
use PRTGenericMod, only : all_carbon_elements
use PRTGenericMod, only : leaf_organ
use PRTGenericMod, only : fnrt_organ
use PRTGenericMod, only : sapw_organ
use PRTGenericMod, only : store_organ
use PRTGenericMod, only : repro_organ
use PRTGenericMod, only : struct_organ
use PRTGenericMod, only : SetState
use FatesRunningMeanMod, only : ema_lpa
use PRTGenericMod, only : carbon12_element

! CIME Globals
use shr_log_mod , only : errMsg => shr_log_errMsg
Expand Down Expand Up @@ -143,7 +142,6 @@ subroutine canopy_structure( currentSite , bc_in )
logical :: area_not_balanced ! logical controlling if the patch layer areas
! have successfully been redistributed
integer :: return_code ! math checks on variables will return>0 if problems exist

! We only iterate because of possible imprecisions generated by the cohort
! termination process. These should be super small, so at the most
! try to re-balance 3 times. If that doesn't give layer areas
Expand Down Expand Up @@ -321,7 +319,7 @@ subroutine canopy_structure( currentSite , bc_in )
currentCohort => currentCohort%shorter
enddo
endif

currentPatch => currentPatch%younger
enddo !patch

Expand Down Expand Up @@ -628,11 +626,11 @@ subroutine DemoteFromLayer(currentSite,currentPatch,i_lyr,bc_in)
if(currentCohort%canopy_layer == i_lyr )then

cc_loss = currentCohort%excl_weight
leaf_c = currentCohort%prt%GetState(leaf_organ,all_carbon_elements)
store_c = currentCohort%prt%GetState(store_organ,all_carbon_elements)
fnrt_c = currentCohort%prt%GetState(fnrt_organ,all_carbon_elements)
sapw_c = currentCohort%prt%GetState(sapw_organ,all_carbon_elements)
struct_c = currentCohort%prt%GetState(struct_organ,all_carbon_elements)
leaf_c = currentCohort%prt%GetState(leaf_organ,carbon12_element)
store_c = currentCohort%prt%GetState(store_organ,carbon12_element)
fnrt_c = currentCohort%prt%GetState(fnrt_organ,carbon12_element)
sapw_c = currentCohort%prt%GetState(sapw_organ,carbon12_element)
struct_c = currentCohort%prt%GetState(struct_organ,carbon12_element)

if ( (cc_loss-currentCohort%c_area) > -nearzero .and. &
(cc_loss-currentCohort%c_area) < area_target_precision ) then
Expand Down Expand Up @@ -662,24 +660,26 @@ subroutine DemoteFromLayer(currentSite,currentPatch,i_lyr,bc_in)

allocate(copyc)

! (keep as an example)
! Initialize running means
!allocate(copyc%tveg_lpa)
!!allocate(copyc%l2fr_ema)
! Note, no need to give a starter value here,
! that will be taken care of in copy_cohort()
!!call copyc%l2fr_ema%InitRMean(ema_60day)

! Initialize the PARTEH object and point to the
! correct boundary condition fields
copyc%prt => null()
call InitPRTObject(copyc%prt)
call InitPRTBoundaryConditions(copyc)

if( hlm_use_planthydro.eq.itrue ) then
call InitHydrCohort(currentSite,copyc)
endif

! (keep as an example)
! Initialize running means
!allocate(copyc%tveg_lpa)
!call copyc%tveg_lpa%InitRMean(ema_lpa, &
! init_value=currentPatch%tveg_lpa%GetMean())

call copy_cohort(currentCohort, copyc)

call InitPRTBoundaryConditions(copyc)

newarea = currentCohort%c_area - cc_loss
copyc%n = currentCohort%n*newarea/currentCohort%c_area
currentCohort%n = currentCohort%n - copyc%n
Expand Down Expand Up @@ -721,6 +721,12 @@ subroutine DemoteFromLayer(currentSite,currentPatch,i_lyr,bc_in)
end if

! kill the ones which go into canopy layers that are not allowed
! USE THIS OVERRIDE IF YOU ARE FORCING A ONE COHORT SIMULATION
! (also make sure to turn off germination, external seed rain,
! (use only one PFT, and make sure disturb_frac is 0)
! (RGK-0822)
!if(currentCohort%canopy_layer>1) then

if(currentCohort%canopy_layer>nclmax )then
! put the litter from the terminated cohorts
! straight into the fragmenting pools
Expand Down Expand Up @@ -831,11 +837,11 @@ subroutine PromoteIntoLayer(currentSite,currentPatch,i_lyr)
!look at the cohorts in the canopy layer below...
if(currentCohort%canopy_layer == i_lyr+1)then

leaf_c = currentCohort%prt%GetState(leaf_organ,all_carbon_elements)
store_c = currentCohort%prt%GetState(store_organ,all_carbon_elements)
fnrt_c = currentCohort%prt%GetState(fnrt_organ,all_carbon_elements)
sapw_c = currentCohort%prt%GetState(sapw_organ,all_carbon_elements)
struct_c = currentCohort%prt%GetState(struct_organ,all_carbon_elements)
leaf_c = currentCohort%prt%GetState(leaf_organ,carbon12_element)
store_c = currentCohort%prt%GetState(store_organ,carbon12_element)
fnrt_c = currentCohort%prt%GetState(fnrt_organ,carbon12_element)
sapw_c = currentCohort%prt%GetState(sapw_organ,carbon12_element)
struct_c = currentCohort%prt%GetState(struct_organ,carbon12_element)

currentCohort%canopy_layer = i_lyr
call carea_allom(currentCohort%dbh,currentCohort%n,currentSite%spread, &
Expand Down Expand Up @@ -1095,11 +1101,11 @@ subroutine PromoteIntoLayer(currentSite,currentPatch,i_lyr)
if( (currentCohort%canopy_layer == i_lyr+1) ) then

cc_gain = currentCohort%prom_weight
leaf_c = currentCohort%prt%GetState(leaf_organ,all_carbon_elements)
store_c = currentCohort%prt%GetState(store_organ,all_carbon_elements)
fnrt_c = currentCohort%prt%GetState(fnrt_organ,all_carbon_elements)
sapw_c = currentCohort%prt%GetState(sapw_organ,all_carbon_elements)
struct_c = currentCohort%prt%GetState(struct_organ,all_carbon_elements)
leaf_c = currentCohort%prt%GetState(leaf_organ,carbon12_element)
store_c = currentCohort%prt%GetState(store_organ,carbon12_element)
fnrt_c = currentCohort%prt%GetState(fnrt_organ,carbon12_element)
sapw_c = currentCohort%prt%GetState(sapw_organ,carbon12_element)
struct_c = currentCohort%prt%GetState(struct_organ,carbon12_element)

if ( (cc_gain-currentCohort%c_area) > -nearzero .and. &
(cc_gain-currentCohort%c_area) < area_target_precision ) then
Expand All @@ -1118,11 +1124,17 @@ subroutine PromoteIntoLayer(currentSite,currentPatch,i_lyr)

allocate(copyc)


!!allocate(copyc%l2fr_ema)
! Note, no need to give a starter value here,
! that will be taken care of in copy_cohort()
!!call copyc%l2fr_ema%InitRMean(ema_60day)

! Initialize the PARTEH object and point to the
! correct boundary condition fields
copyc%prt => null()
call InitPRTObject(copyc%prt)
call InitPRTBoundaryConditions(copyc)


if( hlm_use_planthydro.eq.itrue ) then
call InitHydrCohort(CurrentSite,copyc)
Expand All @@ -1135,7 +1147,8 @@ subroutine PromoteIntoLayer(currentSite,currentPatch,i_lyr)
! init_value=currentPatch%tveg_lpa%GetMean())

call copy_cohort(currentCohort, copyc) !makes an identical copy...

call InitPRTBoundaryConditions(copyc)

newarea = currentCohort%c_area - cc_gain !new area of existing cohort

call carea_allom(currentCohort%dbh,currentCohort%n,currentSite%spread, &
Expand Down Expand Up @@ -1323,13 +1336,11 @@ subroutine canopy_summarization( nsites, sites, bc_in )
do while(associated(currentCohort))

ft = currentCohort%pft


leaf_c = currentCohort%prt%GetState(leaf_organ, all_carbon_elements)
sapw_c = currentCohort%prt%GetState(sapw_organ, all_carbon_elements)
struct_c = currentCohort%prt%GetState(struct_organ, all_carbon_elements)
fnrt_c = currentCohort%prt%GetState(fnrt_organ, all_carbon_elements)
store_c = currentCohort%prt%GetState(store_organ, all_carbon_elements)
leaf_c = currentCohort%prt%GetState(leaf_organ, carbon12_element)
sapw_c = currentCohort%prt%GetState(sapw_organ, carbon12_element)
struct_c = currentCohort%prt%GetState(struct_organ, carbon12_element)
fnrt_c = currentCohort%prt%GetState(fnrt_organ, carbon12_element)
store_c = currentCohort%prt%GetState(store_organ, carbon12_element)

! Update the cohort's index within the size bin classes
! Update the cohort's index within the SCPF classification system
Expand Down Expand Up @@ -1855,7 +1866,6 @@ subroutine update_hlm_dynamics(nsites,sites,fcolumn,bc_out)
total_patch_leaf_stem_area = 0._r8
currentCohort => currentPatch%shortest
do while(associated(currentCohort))

total_patch_leaf_stem_area = total_patch_leaf_stem_area + &
(currentCohort%treelai + currentCohort%treesai) * currentCohort%c_area
currentCohort => currentCohort%taller
Expand Down Expand Up @@ -2162,7 +2172,7 @@ subroutine UpdateCohortLAI(currentCohort, canopy_layer_tlai, patcharea)
real(r8) :: leaf_c ! leaf carbon [kg]

! Obtain the leaf carbon
leaf_c = currentCohort%prt%GetState(leaf_organ,all_carbon_elements)
leaf_c = currentCohort%prt%GetState(leaf_organ,carbon12_element)

! Note that tree_lai has an internal check on the canopy locatoin
currentCohort%treelai = tree_lai(leaf_c, currentCohort%pft, currentCohort%c_area, &
Expand Down
Loading