From fa75892eea5778c52c67ac825a2ed890a09160c6 Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Thu, 17 Feb 2022 23:25:29 -0700 Subject: [PATCH 01/32] New subr. time_evolv_params to calc. time-evolving leafcn_patch --- src/biogeophys/CanopyStateType.F90 | 51 ++++++++++++++++++++++++++++++ src/main/clm_driver.F90 | 5 +++ 2 files changed, 56 insertions(+) diff --git a/src/biogeophys/CanopyStateType.F90 b/src/biogeophys/CanopyStateType.F90 index 78f15b71c2..1b62cc7bef 100644 --- a/src/biogeophys/CanopyStateType.F90 +++ b/src/biogeophys/CanopyStateType.F90 @@ -7,6 +7,7 @@ module CanopyStateType use shr_log_mod , only : errMsg => shr_log_errMsg use abortutils , only : endrun use decompMod , only : bounds_type + use atm2lndType , only : atm2lnd_type use landunit_varcon , only : istsoil, istcrop use clm_varpar , only : nlevcan, nvegwcs use clm_varcon , only : spval @@ -24,6 +25,8 @@ module CanopyStateType integer , pointer :: frac_veg_nosno_patch (:) ! patch fraction of vegetation not covered by snow (0 OR 1) [-] integer , pointer :: frac_veg_nosno_alb_patch (:) ! patch fraction of vegetation not covered by snow (0 OR 1) [-] + real(r8) , pointer :: leafcn_patch (:) ! patch leafcn + real(r8) , pointer :: tlai_patch (:) ! patch canopy one-sided leaf area index, no burying by snow real(r8) , pointer :: tsai_patch (:) ! patch canopy one-sided stem area index, no burying by snow real(r8) , pointer :: elai_patch (:) ! patch canopy one-sided leaf area index with burying by snow @@ -70,6 +73,7 @@ module CanopyStateType procedure, public :: InitAccBuffer procedure, public :: InitAccVars procedure, public :: UpdateAccVars + procedure, public :: time_evolv_params ! updates time-evolving params procedure, public :: Restart end type CanopyState_type @@ -120,6 +124,7 @@ subroutine InitAllocate(this, bounds) allocate(this%tlai_hist_patch (begp:endp)) ; this%tlai_hist_patch (:) = nan allocate(this%tsai_hist_patch (begp:endp)) ; this%tsai_hist_patch (:) = nan allocate(this%htop_hist_patch (begp:endp)) ; this%htop_hist_patch (:) = nan + allocate(this%leafcn_patch (begp:endp)) ; this%leafcn_patch (:) = nan allocate(this%tlai_patch (begp:endp)) ; this%tlai_patch (:) = nan allocate(this%tsai_patch (begp:endp)) ; this%tsai_patch (:) = nan allocate(this%elai_patch (begp:endp)) ; this%elai_patch (:) = nan @@ -229,6 +234,11 @@ subroutine InitHistory(this, bounds) endif !fates or CN + this%leafcn_patch(begp:endp) = spval + call hist_addfld1d (fname='leafcn', units='gC/gN', & + avgflag='A', long_name='Leaf C:N', & + ptr_patch=this%leafcn_patch) + if(use_fates_sp)then this%tlai_hist_patch(begp:endp) = spval call hist_addfld1d (fname='TLAI', units='m', & @@ -511,6 +521,7 @@ subroutine InitCold(this, bounds) do p = bounds%begp, bounds%endp l = patch%landunit(p) + this%leafcn_patch(p) = 0._r8 this%tlai_patch(p) = 0._r8 this%tsai_patch(p) = 0._r8 this%elai_patch(p) = 0._r8 @@ -537,6 +548,42 @@ subroutine InitCold(this, bounds) end subroutine InitCold + !----------------------------------------------------------------------- + subroutine time_evolv_params(this, bounds, atm2lnd_inst) + ! + ! !DESCRIPTION: + ! Update time-evolving parameters + ! + ! !USES: + use pftconMod, only : pftcon + ! + ! !ARGUMENTS: + class(canopystate_type) :: this + type(bounds_type) , intent(in) :: bounds + type(atm2lnd_type), intent(in) :: atm2lnd_inst + ! + ! !LOCAL VARIABLES: + integer :: g, c, p ! indices + real(r8) :: co2_ppmv ! atm co2 concentration + ! Could use 355 value from clm_varctl.F90 to avoid this hardwiring? + real(r8), parameter :: co2_base = 350._r8 ! units ppmv + real(r8), parameter :: cn_slope = 10._r8 + + character(len=*), parameter :: subname = 'time_evolv_params' + !----------------------------------------------------------------------- + + ! Loop to get leafcn_col + do p = bounds%begp, bounds%endp + c = patch%column(p) + g = patch%gridcell(p) + co2_ppmv = 1.e6_r8 * atm2lnd_inst%forc_pco2_grc(g) / & + atm2lnd_inst%forc_pbot_downscaled_col(c) + this%leafcn_patch(p) = pftcon%leafcn(patch%itype(p)) + & + max(cn_slope * log(co2_ppmv / co2_base), 0._r8) + end do + + end subroutine time_evolv_params + !------------------------------------------------------------------------ subroutine Restart(this, bounds, ncid, flag) ! @@ -562,6 +609,10 @@ subroutine Restart(this, bounds, ncid, flag) dim1name='pft', long_name='fraction of vegetation not covered by snow (0 or 1)', units='', & interpinic_flag='interp', readvar=readvar, data=this%frac_veg_nosno_alb_patch) +! call restartvar(ncid=ncid, flag=flag, varname='LEAFCN', xtype=ncd_double, & +! dim1name='pft', long_name='leaf C:N', units='gC/gN', & +! interpinic_flag='interp', readvar=readvar, data=this%leafcn_patch) + call restartvar(ncid=ncid, flag=flag, varname='tlai', xtype=ncd_double, & dim1name='pft', long_name='one-sided leaf area index, no burying by snow', units='', & interpinic_flag='interp', readvar=readvar, data=this%tlai_patch) diff --git a/src/main/clm_driver.F90 b/src/main/clm_driver.F90 index 132e58b02f..49e3ee4b32 100644 --- a/src/main/clm_driver.F90 +++ b/src/main/clm_driver.F90 @@ -165,6 +165,11 @@ subroutine clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate, ro call get_proc_bounds(bounds_proc) nclumps = get_proc_clumps() + ! ------------------------------------------------- + ! Obtain updated values of time-evolving parameters + ! ------------------------------------------------- + call canopystate_inst%time_evolv_params(bounds_proc, atm2lnd_inst) + ! ======================================================================== ! In the first time step of a startup or hybrid run, we want to update CLM's glacier ! areas to match those given by GLC. This is because, in initialization, we do not yet From 26ad2e52ed62fb482572e7bed80faa336dd86266 Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Thu, 17 Feb 2022 23:35:47 -0700 Subject: [PATCH 02/32] Rename new history variable to LEAFCN_TARGET --- src/biogeophys/CanopyStateType.F90 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/biogeophys/CanopyStateType.F90 b/src/biogeophys/CanopyStateType.F90 index 1b62cc7bef..fc03a8a1c1 100644 --- a/src/biogeophys/CanopyStateType.F90 +++ b/src/biogeophys/CanopyStateType.F90 @@ -235,8 +235,8 @@ subroutine InitHistory(this, bounds) endif !fates or CN this%leafcn_patch(begp:endp) = spval - call hist_addfld1d (fname='leafcn', units='gC/gN', & - avgflag='A', long_name='Leaf C:N', & + call hist_addfld1d (fname='LEAFCN_TARGET', units='gC/gN', & + avgflag='A', long_name='Target leaf C:N; compare against leafC/leafN', & ptr_patch=this%leafcn_patch) if(use_fates_sp)then From 48c29127cc34de63cc20dd36d1a7337cb6b7ebc6 Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Fri, 18 Feb 2022 11:26:04 -0700 Subject: [PATCH 03/32] Correction for new history field LEAFCN_TARGET to appear in hist --- src/biogeophys/CanopyStateType.F90 | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/biogeophys/CanopyStateType.F90 b/src/biogeophys/CanopyStateType.F90 index fc03a8a1c1..2106936ba9 100644 --- a/src/biogeophys/CanopyStateType.F90 +++ b/src/biogeophys/CanopyStateType.F90 @@ -173,6 +173,11 @@ subroutine InitHistory(this, bounds) begp = bounds%begp; endp= bounds%endp begc = bounds%begc; endc= bounds%endc + this%leafcn_patch(begp:endp) = spval + call hist_addfld1d (fname='LEAFCN_TARGET', units='gC/gN', & + avgflag='A', long_name='Target leaf C:N; compare against leafC/leafN', & + ptr_patch=this%leafcn_patch) + this%elai_patch(begp:endp) = spval call hist_addfld1d (fname='ELAI', units='m^2/m^2', & avgflag='A', long_name='exposed one-sided leaf area index', & @@ -234,11 +239,6 @@ subroutine InitHistory(this, bounds) endif !fates or CN - this%leafcn_patch(begp:endp) = spval - call hist_addfld1d (fname='LEAFCN_TARGET', units='gC/gN', & - avgflag='A', long_name='Target leaf C:N; compare against leafC/leafN', & - ptr_patch=this%leafcn_patch) - if(use_fates_sp)then this%tlai_hist_patch(begp:endp) = spval call hist_addfld1d (fname='TLAI', units='m', & @@ -609,8 +609,8 @@ subroutine Restart(this, bounds, ncid, flag) dim1name='pft', long_name='fraction of vegetation not covered by snow (0 or 1)', units='', & interpinic_flag='interp', readvar=readvar, data=this%frac_veg_nosno_alb_patch) -! call restartvar(ncid=ncid, flag=flag, varname='LEAFCN', xtype=ncd_double, & -! dim1name='pft', long_name='leaf C:N', units='gC/gN', & +! call restartvar(ncid=ncid, flag=flag, varname='LEAFCN_TARGET', xtype=ncd_double, & +! dim1name='pft', long_name='Target leaf C:N; compare against leafC/leafN', units='gC/gN', & ! interpinic_flag='interp', readvar=readvar, data=this%leafcn_patch) call restartvar(ncid=ncid, flag=flag, varname='tlai', xtype=ncd_double, & From 878728a92aa7b21e393933ad9276d03859b7d4c7 Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Mon, 21 Feb 2022 11:17:58 -0700 Subject: [PATCH 04/32] Add time-evolving leafcn_patch (LEAFCN_TARGET) to restart --- src/biogeophys/CanopyStateType.F90 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/biogeophys/CanopyStateType.F90 b/src/biogeophys/CanopyStateType.F90 index 2106936ba9..257c758a6c 100644 --- a/src/biogeophys/CanopyStateType.F90 +++ b/src/biogeophys/CanopyStateType.F90 @@ -609,9 +609,9 @@ subroutine Restart(this, bounds, ncid, flag) dim1name='pft', long_name='fraction of vegetation not covered by snow (0 or 1)', units='', & interpinic_flag='interp', readvar=readvar, data=this%frac_veg_nosno_alb_patch) -! call restartvar(ncid=ncid, flag=flag, varname='LEAFCN_TARGET', xtype=ncd_double, & -! dim1name='pft', long_name='Target leaf C:N; compare against leafC/leafN', units='gC/gN', & -! interpinic_flag='interp', readvar=readvar, data=this%leafcn_patch) + call restartvar(ncid=ncid, flag=flag, varname='LEAFCN_TARGET', xtype=ncd_double, & + dim1name='pft', long_name='Target leaf C:N; compare against leafC/leafN', units='gC/gN', & + interpinic_flag='interp', readvar=readvar, data=this%leafcn_patch) call restartvar(ncid=ncid, flag=flag, varname='tlai', xtype=ncd_double, & dim1name='pft', long_name='one-sided leaf area index, no burying by snow', units='', & From 6c230efec7f3aa197b441ebb4fbec8342c6bb81f Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Mon, 21 Feb 2022 15:57:38 -0700 Subject: [PATCH 05/32] Move leafcn_patch declaration to CNVegNitrogenStateType from CanopyState Removed three leafcn associate statements that were unused --- src/biogeochem/CNGRespMod.F90 | 1 - src/biogeochem/CNGapMortalityMod.F90 | 1 - src/biogeochem/CNVegNitrogenStateType.F90 | 68 +++++++++++++++++++++-- src/biogeophys/CanopyStateType.F90 | 51 ----------------- src/biogeophys/LunaMod.F90 | 1 - src/main/clm_driver.F90 | 3 +- 6 files changed, 66 insertions(+), 59 deletions(-) diff --git a/src/biogeochem/CNGRespMod.F90 b/src/biogeochem/CNGRespMod.F90 index 44a2225548..d944925f5f 100644 --- a/src/biogeochem/CNGRespMod.F90 +++ b/src/biogeochem/CNGRespMod.F90 @@ -59,7 +59,6 @@ subroutine CNGResp(num_soilp, filter_soilp, cnveg_carbonflux_inst, canopystate_i woody => pftcon%woody , & ! Input: binary flag for woody lifeform (1=woody, 0=not woody) grperc => pftcon%grperc , & ! Input: growth respiration parameter grpnow => pftcon%grpnow , & ! Input: growth respiration parameter - leafcn => pftcon%leafcn , & ! Input: leaf C:N (gC/gN) livewdcn => pftcon%livewdcn , & ! Input: live wood (phloem and ray parenchyma) C:N (gC/gN) laisun => canopystate_inst%laisun_patch , & ! Input: [real(r8) (:)] sunlit projected leaf area index diff --git a/src/biogeochem/CNGapMortalityMod.F90 b/src/biogeochem/CNGapMortalityMod.F90 index bd6867b999..843bce9321 100644 --- a/src/biogeochem/CNGapMortalityMod.F90 +++ b/src/biogeochem/CNGapMortalityMod.F90 @@ -133,7 +133,6 @@ subroutine CNGapMortality (bounds, num_soilc, filter_soilc, num_soilp, filter_so greffic => dgvs_inst%greffic_patch , & ! Input: [real(r8) (:) ] heatstress => dgvs_inst%heatstress_patch , & ! Input: [real(r8) (:) ] - leafcn => pftcon%leafcn , & ! Input: [real(r8) (:)] leaf C:N (gC/gN) livewdcn => pftcon%livewdcn , & ! Input: [real(r8) (:)] live wood (phloem and ray parenchyma) C:N (gC/gN) laisun => canopystate_inst%laisun_patch , & ! Input: [real(r8) (:) ] sunlit projected leaf area index laisha => canopystate_inst%laisha_patch , & ! Input: [real(r8) (:) ] shaded projected leaf area index diff --git a/src/biogeochem/CNVegNitrogenStateType.F90 b/src/biogeochem/CNVegNitrogenStateType.F90 index f8d491faf4..f550aaf5e6 100644 --- a/src/biogeochem/CNVegNitrogenStateType.F90 +++ b/src/biogeochem/CNVegNitrogenStateType.F90 @@ -17,6 +17,7 @@ module CNVegNitrogenStateType use ColumnType , only : col use PatchType , only : patch use dynPatchStateUpdaterMod, only : patch_state_updater_type + use atm2lndType , only : atm2lnd_type use CNSpeciesMod , only : CN_SPECIES_N use CNVegComputeSeedMod, only : ComputeSeedAmounts ! @@ -29,6 +30,7 @@ module CNVegNitrogenStateType ! type, public :: cnveg_nitrogenstate_type + real(r8), pointer :: leafcn_patch (:) ! patch leafcn real(r8), pointer :: grainn_patch (:) ! (gN/m2) grain N (crop) real(r8), pointer :: grainn_storage_patch (:) ! (gN/m2) grain N storage (crop) real(r8), pointer :: grainn_xfer_patch (:) ! (gN/m2) grain N transfer (crop) @@ -80,6 +82,7 @@ module CNVegNitrogenStateType procedure , private :: InitAllocate procedure , private :: InitHistory procedure , private :: InitCold + procedure , public :: time_evolv_params ! updates time-evolving params end type cnveg_nitrogenstate_type !------------------------------------------------------------------------ @@ -126,6 +129,7 @@ subroutine InitAllocate(this, bounds) begc = bounds%begc; endc = bounds%endc begg = bounds%begg; endg = bounds%endg + allocate(this%leafcn_patch (begp:endp)) ; this%leafcn_patch (:) = nan allocate(this%grainn_patch (begp:endp)) ; this%grainn_patch (:) = nan allocate(this%grainn_storage_patch (begp:endp)) ; this%grainn_storage_patch (:) = nan allocate(this%grainn_xfer_patch (begp:endp)) ; this%grainn_xfer_patch (:) = nan @@ -197,6 +201,11 @@ subroutine InitHistory(this, bounds) !------------------------------- ! patch state variables !------------------------------- + + this%leafcn_patch(begp:endp) = spval + call hist_addfld1d (fname='LEAFCN_TARGET', units='gC/gN', & + avgflag='A', long_name='Target leaf C:N; compare against leafC/leafN', & + ptr_patch=this%leafcn_patch) if (use_crop) then this%grainn_patch(begp:endp) = spval @@ -436,8 +445,9 @@ subroutine InitCold(this, bounds, & this%frootn_storage_patch(p) = 0._r8 end if else - this%leafn_patch(p) = leafc_patch(p) / pftcon%leafcn(patch%itype(p)) - this%leafn_storage_patch(p) = leafc_storage_patch(p) / pftcon%leafcn(patch%itype(p)) + this%leafcn_patch(p) = pftcon%leafcn(patch%itype(p)) + this%leafn_patch(p) = leafc_patch(p) / this%leafcn_patch(p) + this%leafn_storage_patch(p) = leafc_storage_patch(p) / this%leafcn_patch(p) if (MM_Nuptake_opt .eqv. .true.) then this%frootn_patch(p) = frootc_patch(p) / pftcon%frootcn(patch%itype(p)) this%frootn_storage_patch(p) = frootc_storage_patch(p) / pftcon%frootcn(patch%itype(p)) @@ -666,6 +676,10 @@ subroutine Restart ( this, bounds, ncid, flag, leafc_patch, & dim1name='pft', long_name='', units='', & interpinic_flag='interp', readvar=readvar, data=this%ntrunc_patch) + call restartvar(ncid=ncid, flag=flag, varname='LEAFCN_TARGET', xtype=ncd_double, & + dim1name='pft', long_name='Target leaf C:N; compare against leafC/leafN', units='gC/gN', & + interpinic_flag='interp', readvar=readvar, data=this%leafcn_patch) + if (use_crop) then call restartvar(ncid=ncid, flag=flag, varname='grainn', xtype=ncd_double, & dim1name='pft', long_name='grain N', units='gN/m2', & @@ -749,8 +763,17 @@ subroutine Restart ( this, bounds, ncid, flag, leafc_patch, & this%frootn_storage_patch(p) = 0._r8 end if else - this%leafn_patch(p) = leafc_patch(p) / pftcon%leafcn(patch%itype(p)) - this%leafn_storage_patch(p) = leafc_storage_patch(p) / pftcon%leafcn(patch%itype(p)) + ! max in next line ensures leafcn_patch equals at least the + ! leafcn for bare ground (noveg) to avoid div by 0 when the + ! initial file doesn't include leafcn_patch. In that situation + ! it seems, however, like a better initial condition to set + ! this%leafcn_patch(p) = pftcon%leafcn(patch%itype(p)) + ! ...but leafcn_patch does get updated before anything else + ! in clm_driver, so either option may give the same answer. + this%leafcn_patch(p) = max(pftcon%leafcn(noveg), & + this%leafcn_patch(p)) + this%leafn_patch(p) = leafc_patch(p) / this%leafcn_patch(p) + this%leafn_storage_patch(p) = leafc_storage_patch(p) / this%leafcn_patch(p) if (MM_Nuptake_opt .eqv. .true.) then this%frootn_patch(p) = frootc_patch(p) / pftcon%frootcn(patch%itype(p)) this%frootn_storage_patch(p) = frootc_storage_patch(p) / pftcon%frootcn(patch%itype(p)) @@ -863,6 +886,7 @@ subroutine SetValues ( this, & do fi = 1,num_patch i = filter_patch(fi) + this%leafcn_patch(i) = value_patch this%leafn_patch(i) = value_patch this%leafn_storage_patch(i) = value_patch this%leafn_xfer_patch(i) = value_patch @@ -1057,6 +1081,42 @@ subroutine Summary_nitrogenstate(this, bounds, num_allc, filter_allc, & end subroutine Summary_nitrogenstate + !----------------------------------------------------------------------- + subroutine time_evolv_params(this, bounds, atm2lnd_inst) + ! + ! !DESCRIPTION: + ! Update time-evolving parameters + ! + ! !USES: + use pftconMod, only : pftcon + ! + ! !ARGUMENTS: + class(cnveg_nitrogenstate_type) :: this + type(bounds_type) , intent(in) :: bounds + type(atm2lnd_type), intent(in) :: atm2lnd_inst + ! + ! !LOCAL VARIABLES: + integer :: g, c, p ! indices + real(r8) :: co2_ppmv ! atm co2 concentration + ! Could use 355 value from clm_varctl.F90 to avoid this hardwiring? + real(r8), parameter :: co2_base = 350._r8 ! units ppmv + real(r8), parameter :: cn_slope = 10._r8 + + character(len=*), parameter :: subname = 'time_evolv_params' + !----------------------------------------------------------------------- + + ! Loop to get leafcn_col + do p = bounds%begp, bounds%endp + c = patch%column(p) + g = patch%gridcell(p) + co2_ppmv = 1.e6_r8 * atm2lnd_inst%forc_pco2_grc(g) / & + atm2lnd_inst%forc_pbot_downscaled_col(c) + this%leafcn_patch(p) = pftcon%leafcn(patch%itype(p)) + & + max(cn_slope * log(co2_ppmv / co2_base), 0._r8) + end do + + end subroutine time_evolv_params + !----------------------------------------------------------------------- subroutine DynamicPatchAdjustments(this, bounds, & num_soilp_with_inactive, filter_soilp_with_inactive, & diff --git a/src/biogeophys/CanopyStateType.F90 b/src/biogeophys/CanopyStateType.F90 index 257c758a6c..78f15b71c2 100644 --- a/src/biogeophys/CanopyStateType.F90 +++ b/src/biogeophys/CanopyStateType.F90 @@ -7,7 +7,6 @@ module CanopyStateType use shr_log_mod , only : errMsg => shr_log_errMsg use abortutils , only : endrun use decompMod , only : bounds_type - use atm2lndType , only : atm2lnd_type use landunit_varcon , only : istsoil, istcrop use clm_varpar , only : nlevcan, nvegwcs use clm_varcon , only : spval @@ -25,8 +24,6 @@ module CanopyStateType integer , pointer :: frac_veg_nosno_patch (:) ! patch fraction of vegetation not covered by snow (0 OR 1) [-] integer , pointer :: frac_veg_nosno_alb_patch (:) ! patch fraction of vegetation not covered by snow (0 OR 1) [-] - real(r8) , pointer :: leafcn_patch (:) ! patch leafcn - real(r8) , pointer :: tlai_patch (:) ! patch canopy one-sided leaf area index, no burying by snow real(r8) , pointer :: tsai_patch (:) ! patch canopy one-sided stem area index, no burying by snow real(r8) , pointer :: elai_patch (:) ! patch canopy one-sided leaf area index with burying by snow @@ -73,7 +70,6 @@ module CanopyStateType procedure, public :: InitAccBuffer procedure, public :: InitAccVars procedure, public :: UpdateAccVars - procedure, public :: time_evolv_params ! updates time-evolving params procedure, public :: Restart end type CanopyState_type @@ -124,7 +120,6 @@ subroutine InitAllocate(this, bounds) allocate(this%tlai_hist_patch (begp:endp)) ; this%tlai_hist_patch (:) = nan allocate(this%tsai_hist_patch (begp:endp)) ; this%tsai_hist_patch (:) = nan allocate(this%htop_hist_patch (begp:endp)) ; this%htop_hist_patch (:) = nan - allocate(this%leafcn_patch (begp:endp)) ; this%leafcn_patch (:) = nan allocate(this%tlai_patch (begp:endp)) ; this%tlai_patch (:) = nan allocate(this%tsai_patch (begp:endp)) ; this%tsai_patch (:) = nan allocate(this%elai_patch (begp:endp)) ; this%elai_patch (:) = nan @@ -173,11 +168,6 @@ subroutine InitHistory(this, bounds) begp = bounds%begp; endp= bounds%endp begc = bounds%begc; endc= bounds%endc - this%leafcn_patch(begp:endp) = spval - call hist_addfld1d (fname='LEAFCN_TARGET', units='gC/gN', & - avgflag='A', long_name='Target leaf C:N; compare against leafC/leafN', & - ptr_patch=this%leafcn_patch) - this%elai_patch(begp:endp) = spval call hist_addfld1d (fname='ELAI', units='m^2/m^2', & avgflag='A', long_name='exposed one-sided leaf area index', & @@ -521,7 +511,6 @@ subroutine InitCold(this, bounds) do p = bounds%begp, bounds%endp l = patch%landunit(p) - this%leafcn_patch(p) = 0._r8 this%tlai_patch(p) = 0._r8 this%tsai_patch(p) = 0._r8 this%elai_patch(p) = 0._r8 @@ -548,42 +537,6 @@ subroutine InitCold(this, bounds) end subroutine InitCold - !----------------------------------------------------------------------- - subroutine time_evolv_params(this, bounds, atm2lnd_inst) - ! - ! !DESCRIPTION: - ! Update time-evolving parameters - ! - ! !USES: - use pftconMod, only : pftcon - ! - ! !ARGUMENTS: - class(canopystate_type) :: this - type(bounds_type) , intent(in) :: bounds - type(atm2lnd_type), intent(in) :: atm2lnd_inst - ! - ! !LOCAL VARIABLES: - integer :: g, c, p ! indices - real(r8) :: co2_ppmv ! atm co2 concentration - ! Could use 355 value from clm_varctl.F90 to avoid this hardwiring? - real(r8), parameter :: co2_base = 350._r8 ! units ppmv - real(r8), parameter :: cn_slope = 10._r8 - - character(len=*), parameter :: subname = 'time_evolv_params' - !----------------------------------------------------------------------- - - ! Loop to get leafcn_col - do p = bounds%begp, bounds%endp - c = patch%column(p) - g = patch%gridcell(p) - co2_ppmv = 1.e6_r8 * atm2lnd_inst%forc_pco2_grc(g) / & - atm2lnd_inst%forc_pbot_downscaled_col(c) - this%leafcn_patch(p) = pftcon%leafcn(patch%itype(p)) + & - max(cn_slope * log(co2_ppmv / co2_base), 0._r8) - end do - - end subroutine time_evolv_params - !------------------------------------------------------------------------ subroutine Restart(this, bounds, ncid, flag) ! @@ -609,10 +562,6 @@ subroutine Restart(this, bounds, ncid, flag) dim1name='pft', long_name='fraction of vegetation not covered by snow (0 or 1)', units='', & interpinic_flag='interp', readvar=readvar, data=this%frac_veg_nosno_alb_patch) - call restartvar(ncid=ncid, flag=flag, varname='LEAFCN_TARGET', xtype=ncd_double, & - dim1name='pft', long_name='Target leaf C:N; compare against leafC/leafN', units='gC/gN', & - interpinic_flag='interp', readvar=readvar, data=this%leafcn_patch) - call restartvar(ncid=ncid, flag=flag, varname='tlai', xtype=ncd_double, & dim1name='pft', long_name='one-sided leaf area index, no burying by snow', units='', & interpinic_flag='interp', readvar=readvar, data=this%tlai_patch) diff --git a/src/biogeophys/LunaMod.F90 b/src/biogeophys/LunaMod.F90 index dbd39daedf..71b9698f0a 100644 --- a/src/biogeophys/LunaMod.F90 +++ b/src/biogeophys/LunaMod.F90 @@ -313,7 +313,6 @@ subroutine Update_Photosynthesis_Capacity(bounds, fn, filterp, & associate( & c3psn => pftcon%c3psn , & ! photosynthetic pathway: 0. = c4, 1. = c3 slatop => pftcon%slatop , & ! specific leaf area at top of canopy, projected area basis [m^2/gC] - leafcn => pftcon%leafcn , & ! leaf C:N (gC/gN) forc_pbot10 => atm2lnd_inst%forc_pbot240_downscaled_patch , & ! Input: [real(r8) (:) ] 10 day mean atmospheric pressure(Pa) CO2_p240 => atm2lnd_inst%forc_pco2_240_patch , & ! Input: [real(r8) (:) ] 10-day mean CO2 partial pressure (Pa) O2_p240 => atm2lnd_inst%forc_po2_240_patch , & ! Input: [real(r8) (:) ] 10-day mean O2 partial pressure (Pa) diff --git a/src/main/clm_driver.F90 b/src/main/clm_driver.F90 index 49e3ee4b32..b81ae16a01 100644 --- a/src/main/clm_driver.F90 +++ b/src/main/clm_driver.F90 @@ -168,7 +168,8 @@ subroutine clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate, ro ! ------------------------------------------------- ! Obtain updated values of time-evolving parameters ! ------------------------------------------------- - call canopystate_inst%time_evolv_params(bounds_proc, atm2lnd_inst) + call bgc_vegetation_inst%cnveg_nitrogenstate_inst%time_evolv_params( & + bounds_proc, atm2lnd_inst) ! ======================================================================== ! In the first time step of a startup or hybrid run, we want to update CLM's glacier From 86b805b082b98817c87e40337b64bdee2fc1e391 Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Mon, 21 Feb 2022 17:35:34 -0700 Subject: [PATCH 06/32] Replace pftcon%leafcn w cnveg_nitrogenstate_inst%leafcn_patch ...where pftcon%leafcn is used. I didn't replace it in function SpeciesTypeMultiplier in CNVegComputeSeedMod.F90 and the corresponding unit tests. This far I still get bfb identical answers when I run SMS_Ly3_Mmpi-serial.1x1_numaIA.IHistClm50BgcCropQianRs.cheyenne_intel.clm-default --- src/biogeochem/CNFUNMod.F90 | 10 ++++---- src/biogeochem/CNPhenologyMod.F90 | 24 +++++++++---------- .../NutrientCompetitionCLM45defaultMod.F90 | 19 +++++++-------- .../NutrientCompetitionFlexibleCNMod.F90 | 14 +++++------ src/biogeophys/CanopyFluxesMod.F90 | 7 +++++- src/biogeophys/PhotosynthesisMod.F90 | 15 ++++++++---- src/main/clm_driver.F90 | 1 + 7 files changed, 50 insertions(+), 40 deletions(-) diff --git a/src/biogeochem/CNFUNMod.F90 b/src/biogeochem/CNFUNMod.F90 index 37593a2b57..2069ca6732 100644 --- a/src/biogeochem/CNFUNMod.F90 +++ b/src/biogeochem/CNFUNMod.F90 @@ -147,7 +147,7 @@ subroutine CNFUNInit (bounds,cnveg_state_inst,cnveg_carbonstate_inst,cnveg_nitro ! Set local pointers associate(ivt => patch%itype , & ! Input: [integer (:) ] p - leafcn => pftcon%leafcn , & ! Input: leaf C:N (gC/gN) + leafcn => cnveg_nitrogenstate_inst%leafcn_patch , & ! Input: leaf C:N (gC/gN) leafcn_offset => cnveg_state_inst%leafcn_offset_patch , & ! Output: ! [real(r8) (:) ] Leaf C:N used by FUN leafc_storage_xfer_acc => cnveg_carbonstate_inst%leafc_storage_xfer_acc_patch , & ! Output: [real(r8) (:) @@ -181,7 +181,7 @@ subroutine CNFUNInit (bounds,cnveg_state_inst,cnveg_carbonstate_inst,cnveg_nitro !--- numofyear = nstep/nstep_fun if (mod(nstep,nstep_fun) == 0) then - leafcn_offset(bounds%begp:bounds%endp) = leafcn(ivt(bounds%begp:bounds%endp)) + leafcn_offset(bounds%begp:bounds%endp) = leafcn(bounds%begp:bounds%endp) storage_cdemand(bounds%begp:bounds%endp) = 0._r8 storage_ndemand(bounds%begp:bounds%endp) = 0._r8 leafn_storage_xfer_acc(bounds%begp:bounds%endp) = 0._r8 @@ -504,7 +504,7 @@ subroutine CNFUN(bounds,num_soilc, filter_soilc,num_soilp& !-------------------------------------------------------------------- !--------------------------------- associate(ivt => patch%itype , & ! Input: [integer (:) ] p - leafcn => pftcon%leafcn , & ! Input: leaf C:N (gC/gN) + leafcn => cnveg_nitrogenstate_inst%leafcn_patch , & ! Input: leaf C:N (gC/gN) season_decid => pftcon%season_decid , & ! Input: binary flag for seasonal ! -deciduous leaf habit (0 or 1) stress_decid => pftcon%stress_decid , & ! Input: binary flag for stress @@ -1196,7 +1196,7 @@ subroutine CNFUN(bounds,num_soilc, filter_soilc,num_soilp& litterfall_c_step(p,istp)* fixerfrac,& litterfall_n_step(p,istp)* fixerfrac,& total_n_resistance, total_c_spent_retrans,total_c_accounted_retrans, & - free_n_retrans,paid_for_n_retrans, leafcn(ivt(p)), & + free_n_retrans,paid_for_n_retrans, leafcn(p), & grperc(ivt(p)), plantCN(p)) else @@ -1227,7 +1227,7 @@ subroutine CNFUN(bounds,num_soilc, filter_soilc,num_soilp& if (leafn(p) == 0.0_r8) then ! to avoid division by zero delta_CN = fun_cn_flex_c(ivt(p)) ! Max CN ratio over standard else - delta_CN = (leafc(p)+leafc_storage(p))/(leafn(p)+leafn_storage(p)) - leafcn(ivt(p)) ! leaf CN ratio + delta_CN = (leafc(p)+leafc_storage(p))/(leafn(p)+leafn_storage(p)) - leafcn(p) ! leaf CN ratio end if ! C used for uptake is reduced if the cost of N is very high frac_ideal_C_use = max(0.0_r8,1.0_r8 - (total_N_resistance-fun_cn_flex_a(ivt(p)))/fun_cn_flex_b(ivt(p)) ) diff --git a/src/biogeochem/CNPhenologyMod.F90 b/src/biogeochem/CNPhenologyMod.F90 index 1c12747d72..de04b4c3cb 100644 --- a/src/biogeochem/CNPhenologyMod.F90 +++ b/src/biogeochem/CNPhenologyMod.F90 @@ -1695,7 +1695,7 @@ subroutine CropPhenology(num_pcropp, filter_pcropp , & ivt => patch%itype , & ! Input: [integer (:) ] patch vegetation type leaf_long => pftcon%leaf_long , & ! Input: leaf longevity (yrs) - leafcn => pftcon%leafcn , & ! Input: leaf C:N (gC/gN) + leafcn => cnveg_nitrogenstate_inst%leafcn_patch , & ! Input: leaf C:N (gC/gN) manunitro => pftcon%manunitro , & ! Input: max manure to be applied in total (kgN/m2) mxmat => pftcon%mxmat , & ! Input: minplanttemp => pftcon%minplanttemp , & ! Input: @@ -1860,7 +1860,7 @@ subroutine CropPhenology(num_pcropp, filter_pcropp , & hdidx(p) = 0._r8 vf(p) = 0._r8 - call PlantCrop(p, leafcn(ivt(p)), jday, crop_inst, cnveg_state_inst, & + call PlantCrop(p, leafcn(p), jday, crop_inst, cnveg_state_inst, & cnveg_carbonstate_inst, cnveg_nitrogenstate_inst, & cnveg_carbonflux_inst, cnveg_nitrogenflux_inst, & c13_cnveg_carbonstate_inst, c14_cnveg_carbonstate_inst) @@ -1891,7 +1891,7 @@ subroutine CropPhenology(num_pcropp, filter_pcropp , & if (do_plant_normal .or. do_plant_lastchance) then - call PlantCrop(p, leafcn(ivt(p)), jday, crop_inst, cnveg_state_inst, & + call PlantCrop(p, leafcn(p), jday, crop_inst, cnveg_state_inst, & cnveg_carbonstate_inst, cnveg_nitrogenstate_inst, & cnveg_carbonflux_inst, cnveg_nitrogenflux_inst, & c13_cnveg_carbonstate_inst, c14_cnveg_carbonstate_inst) @@ -2087,7 +2087,7 @@ subroutine CropPhenology(num_pcropp, filter_pcropp , & crop_seedc_to_leaf(p) = crop_seedc_to_leaf(p) - leafc_xfer(p)/dt crop_seedn_to_leaf(p) = crop_seedn_to_leaf(p) - leafn_xfer(p)/dt leafc_xfer(p) = 0._r8 - leafn_xfer(p) = leafc_xfer(p) / leafcn(ivt(p)) + leafn_xfer(p) = leafc_xfer(p) / leafcn(p) if (use_c13) then c13_cnveg_carbonstate_inst%leafc_xfer_patch(p) = 0._r8 endif @@ -2127,7 +2127,7 @@ subroutine CropPhenology(num_pcropp, filter_pcropp , & crop_seedn_to_leaf(p) = crop_seedn_to_leaf(p) - leafn_xfer(p)/dt onset_counter(p) = 0._r8 leafc_xfer(p) = 0._r8 - leafn_xfer(p) = leafc_xfer(p) / leafcn(ivt(p)) + leafn_xfer(p) = leafc_xfer(p) / leafcn(p) if (use_c13) then c13_cnveg_carbonstate_inst%leafc_xfer_patch(p) = 0._r8 endif @@ -2227,7 +2227,7 @@ subroutine PlantCrop(p, leafcn_in, jday, & ! ! !ARGUMENTS: integer , intent(in) :: p ! PATCH index running over - real(r8) , intent(in) :: leafcn_in ! leaf C:N (gC/gN) of this patch's vegetation type (pftcon%leafcn(ivt(p))) + real(r8) , intent(in) :: leafcn_in ! leaf C:N (gC/gN) of this patch integer , intent(in) :: jday ! julian day of the year type(crop_type) , intent(inout) :: crop_inst type(cnveg_state_type) , intent(inout) :: cnveg_state_inst @@ -2585,7 +2585,7 @@ subroutine CNOffsetLitterfall (num_soilp, filter_soilp, & associate( & ivt => patch%itype , & ! Input: [integer (:) ] patch vegetation type - leafcn => pftcon%leafcn , & ! Input: leaf C:N (gC/gN) + leafcn => cnveg_nitrogenstate_inst%leafcn_patch , & ! Input: leaf C:N (gC/gN) biofuel_harvfrac => pftcon%biofuel_harvfrac , & ! Input: cut a fraction of leaf & stem for biofuel (-) @@ -2703,7 +2703,7 @@ subroutine CNOffsetLitterfall (num_soilp, filter_soilp, & leafcn_offset(p) = leafc(p)/leafn(p) end if else - leafcn_offset(p) = leafcn(ivt(p)) + leafcn_offset(p) = leafcn(p) end if leafn_to_litter(p) = leafc_to_litter(p)/leafcn_offset(p) - leafn_to_retransn(p) leafn_to_litter(p) = max(leafn_to_litter(p),0._r8) @@ -2723,7 +2723,7 @@ subroutine CNOffsetLitterfall (num_soilp, filter_soilp, & end if ! calculate the leaf N litterfall and retranslocation leafn_to_litter(p) = leafc_to_litter(p) / lflitcn(ivt(p)) - leafn_to_retransn(p) = (leafc_to_litter(p) / leafcn(ivt(p))) - leafn_to_litter(p) + leafn_to_retransn(p) = (leafc_to_litter(p) / leafcn(p)) - leafn_to_litter(p) end if @@ -2803,7 +2803,7 @@ subroutine CNBackgroundLitterfall (num_soilp, filter_soilp, & associate( & ivt => patch%itype , & ! Input: [integer (:) ] patch vegetation type - leafcn => pftcon%leafcn , & ! Input: leaf C:N (gC/gN) + leafcn => cnveg_nitrogenstate_inst%leafcn_patch , & ! Input: leaf C:N (gC/gN) lflitcn => pftcon%lflitcn , & ! Input: leaf litter C:N (gC/gN) frootcn => pftcon%frootcn , & ! Input: fine root C:N (gC/gN) @@ -2845,7 +2845,7 @@ subroutine CNBackgroundLitterfall (num_soilp, filter_soilp, & leafcn_offset(p) = leafc(p)/leafn(p) end if else - leafcn_offset(p) = leafcn(ivt(p)) + leafcn_offset(p) = leafcn(p) end if leafn_to_litter(p) = leafc_to_litter(p)/leafcn_offset(p) - leafn_to_retransn(p) leafn_to_litter(p) = max(leafn_to_litter(p),0._r8) @@ -2866,7 +2866,7 @@ subroutine CNBackgroundLitterfall (num_soilp, filter_soilp, & end if ! calculate the leaf N litterfall and retranslocation leafn_to_litter(p) = leafc_to_litter(p) / lflitcn(ivt(p)) - leafn_to_retransn(p) = (leafc_to_litter(p) / leafcn(ivt(p))) - leafn_to_litter(p) + leafn_to_retransn(p) = (leafc_to_litter(p) / leafcn(p)) - leafn_to_litter(p) end if diff --git a/src/biogeochem/NutrientCompetitionCLM45defaultMod.F90 b/src/biogeochem/NutrientCompetitionCLM45defaultMod.F90 index d93f0a168e..72ef03594c 100644 --- a/src/biogeochem/NutrientCompetitionCLM45defaultMod.F90 +++ b/src/biogeochem/NutrientCompetitionCLM45defaultMod.F90 @@ -15,6 +15,7 @@ module NutrientCompetitionCLM45defaultMod use LandunitType , only : lun use ColumnType , only : col use PatchType , only : patch + use CNVegNitrogenStateType, only : cnveg_nitrogenstate_type use NutrientCompetitionMethodMod, only : nutrient_competition_method_type use NutrientCompetitionMethodMod, only : params_inst !use clm_varctl , only : iulog @@ -86,7 +87,6 @@ subroutine calc_plant_nutrient_competition (this, & use CanopyStateType , only : canopystate_type use CNVegCarbonStateType , only : cnveg_carbonstate_type use CNVegCarbonFluxType , only : cnveg_carbonflux_type - use CNVegNitrogenStateType, only : cnveg_nitrogenstate_type use CNVegNitrogenFluxType , only : cnveg_nitrogenflux_type use SoilBiogeochemNitrogenStateType, only : soilbiogeochem_nitrogenstate_type use CNSharedParamsMod , only : use_fun @@ -113,7 +113,7 @@ subroutine calc_plant_nutrient_competition (this, & call this%calc_plant_cn_alloc (bounds, num_soilp, filter_soilp, & cnveg_state_inst, crop_inst, canopystate_inst, & cnveg_carbonstate_inst, cnveg_carbonflux_inst, c13_cnveg_carbonflux_inst, & - c14_cnveg_carbonflux_inst, cnveg_nitrogenflux_inst, & + c14_cnveg_carbonflux_inst, cnveg_nitrogenflux_inst, cnveg_nitrogenstate_inst, & aroot=aroot(bounds%begp:bounds%endp), & arepr=arepr(bounds%begp:bounds%endp), & fpg_col=fpg_col(bounds%begc:bounds%endc)) @@ -124,7 +124,7 @@ end subroutine calc_plant_nutrient_competition subroutine calc_plant_cn_alloc (this, bounds, num_soilp, filter_soilp, & cnveg_state_inst, crop_inst, canopystate_inst, & cnveg_carbonstate_inst, cnveg_carbonflux_inst, c13_cnveg_carbonflux_inst, & - c14_cnveg_carbonflux_inst, cnveg_nitrogenflux_inst, & + c14_cnveg_carbonflux_inst, cnveg_nitrogenflux_inst, cnveg_nitrogenstate_inst, & aroot, arepr, fpg_col) ! ! !USES: @@ -153,6 +153,7 @@ subroutine calc_plant_cn_alloc (this, bounds, num_soilp, filter_soilp, & type(cnveg_carbonflux_type) , intent(inout) :: c13_cnveg_carbonflux_inst type(cnveg_carbonflux_type) , intent(inout) :: c14_cnveg_carbonflux_inst type(cnveg_nitrogenflux_type) , intent(inout) :: cnveg_nitrogenflux_inst + type(cnveg_nitrogenstate_type) , intent(in) :: cnveg_nitrogenstate_inst real(r8) , intent(in) :: aroot(bounds%begp:) real(r8) , intent(in) :: arepr(bounds%begp:) real(r8) , intent(in) :: fpg_col(bounds%begc:) @@ -184,7 +185,7 @@ subroutine calc_plant_cn_alloc (this, bounds, num_soilp, filter_soilp, & croot_stem => pftcon%croot_stem , & ! Input: allocation parameter: new coarse root C per new stem C (gC/gC) stem_leaf => pftcon%stem_leaf , & ! Input: allocation parameter: new stem c per new leaf C (gC/gC) flivewd => pftcon%flivewd , & ! Input: allocation parameter: fraction of new wood that is live (phloem and ray parenchyma) (no units) - leafcn => pftcon%leafcn , & ! Input: leaf C:N (gC/gN) + leafcn => cnveg_nitrogenstate_inst%leafcn_patch , & ! Input: leaf C:N (gC/gN) frootcn => pftcon%frootcn , & ! Input: fine root C:N (gC/gN) livewdcn => pftcon%livewdcn , & ! Input: live wood (phloem and ray parenchyma) C:N (gC/gN) deadwdcn => pftcon%deadwdcn , & ! Input: dead wood (xylem and heartwood) C:N (gC/gN) @@ -280,7 +281,7 @@ subroutine calc_plant_cn_alloc (this, bounds, num_soilp, filter_soilp, & f4 = flivewd(ivt(p)) g1 = grperc(ivt(p)) g2 = grpnow(ivt(p)) - cnl = leafcn(ivt(p)) + cnl = leafcn(p) cnfr = frootcn(ivt(p)) cnlw = livewdcn(ivt(p)) cndw = deadwdcn(ivt(p)) @@ -446,7 +447,6 @@ subroutine calc_plant_nutrient_demand(this, bounds, num_soilp, filter_soilp,& use CropType , only : crop_type use CNVegStateType , only : cnveg_state_type use CNVegCarbonStateType , only : cnveg_carbonstate_type - use CNVegNitrogenStateType , only : cnveg_nitrogenstate_type use CNVegCarbonFluxType , only : cnveg_carbonflux_type use CNVegNitrogenFluxType , only : cnveg_nitrogenflux_type use SoilBiogeochemCarbonFluxType, only : soilbiogeochem_carbonflux_type @@ -506,7 +506,6 @@ subroutine calc_plant_nitrogen_demand(this, bounds, num_soilp, filter_soilp, & use CropType , only : crop_type use CNVegStateType , only : cnveg_state_type use CNVegCarbonStateType , only : cnveg_carbonstate_type - use CNVegNitrogenStateType , only : cnveg_nitrogenstate_type use CNVegCarbonFluxType , only : cnveg_carbonflux_type use CNVegNitrogenFluxType , only : cnveg_nitrogenflux_type use CNSharedParamsMod , only : use_fun @@ -556,7 +555,7 @@ subroutine calc_plant_nitrogen_demand(this, bounds, num_soilp, filter_soilp, & croot_stem => pftcon%croot_stem , & ! Input: allocation parameter: new coarse root C per new stem C (gC/gC) stem_leaf => pftcon%stem_leaf , & ! Input: allocation parameter: new stem c per new leaf C (gC/gC) flivewd => pftcon%flivewd , & ! Input: allocation parameter: fraction of new wood that is live (phloem and ray parenchyma) (no units) - leafcn => pftcon%leafcn , & ! Input: leaf C:N (gC/gN) + leafcn => cnveg_nitrogenstate_inst%leafcn_patch , & ! Input: leaf C:N (gC/gN) frootcn => pftcon%frootcn , & ! Input: fine root C:N (gC/gN) livewdcn => pftcon%livewdcn , & ! Input: live wood (phloem and ray parenchyma) C:N (gC/gN) deadwdcn => pftcon%deadwdcn , & ! Input: dead wood (xylem and heartwood) C:N (gC/gN) @@ -761,7 +760,7 @@ subroutine calc_plant_nitrogen_demand(this, bounds, num_soilp, filter_soilp, & f4 = flivewd(ivt(p)) g1 = grperc(ivt(p)) g2 = grpnow(ivt(p)) - cnl = leafcn(ivt(p)) + cnl = leafcn(p) cnfr = frootcn(ivt(p)) cnlw = livewdcn(ivt(p)) cndw = deadwdcn(ivt(p)) @@ -859,7 +858,7 @@ subroutine calc_plant_nitrogen_demand(this, bounds, num_soilp, filter_soilp, & if (grain_flag(p) == 0._r8)then if(.not.use_fun) then t1 = 1 / dt - leafn_to_retransn(p) = t1 * ((leafc(p) / leafcn(ivt(p))) - (leafc(p) / & + leafn_to_retransn(p) = t1 * ((leafc(p) / leafcn(p)) - (leafc(p) / & fleafcn(ivt(p)))) livestemn_to_retransn(p) = t1 * ((livestemc(p) / livewdcn(ivt(p))) - (livestemc(p) / & fstemcn(ivt(p)))) diff --git a/src/biogeochem/NutrientCompetitionFlexibleCNMod.F90 b/src/biogeochem/NutrientCompetitionFlexibleCNMod.F90 index a642a5dd2d..8a27c78472 100644 --- a/src/biogeochem/NutrientCompetitionFlexibleCNMod.F90 +++ b/src/biogeochem/NutrientCompetitionFlexibleCNMod.F90 @@ -313,7 +313,7 @@ subroutine calc_plant_cn_alloc(this, bounds, num_soilp, filter_soilp, & croot_stem => pftcon%croot_stem , & ! Input: allocation parameter: new coarse root C per new stem C (gC/gC) stem_leaf => pftcon%stem_leaf , & ! Input: allocation parameter: new stem c per new leaf C (gC/gC) flivewd => pftcon%flivewd , & ! Input: allocation parameter: fraction of new wood that is live (phloem and ray parenchyma) (no units) - leafcn => pftcon%leafcn , & ! Input: leaf C:N (gC/gN) + leafcn => cnveg_nitrogenstate_inst%leafcn_patch , & ! Input: leaf C:N (gC/gN) frootcn => pftcon%frootcn , & ! Input: fine root C:N (gC/gN) livewdcn => pftcon%livewdcn , & ! Input: live wood (phloem and ray parenchyma) C:N (gC/gN) deadwdcn => pftcon%deadwdcn , & ! Input: dead wood (xylem and heartwood) C:N (gC/gN) @@ -429,7 +429,7 @@ subroutine calc_plant_cn_alloc(this, bounds, num_soilp, filter_soilp, & f4 = flivewd(ivt(p)) g1 = grperc(ivt(p)) g2 = grpnow(ivt(p)) - cnl = leafcn(ivt(p)) + cnl = leafcn(p) cnfr = frootcn(ivt(p)) cnlw = livewdcn(ivt(p)) cndw = deadwdcn(ivt(p)) @@ -998,7 +998,7 @@ subroutine calc_plant_cn_alloc(this, bounds, num_soilp, filter_soilp, & end if end if - leafcn_max = leafcn(ivt(p)) + 15.0_r8 + leafcn_max = leafcn(p) + 15.0_r8 frootcn_max = frootcn(ivt(p)) + 15.0_r8 ! Note that for high CN ratio stress the plant part does not retranslocate nitrogen as the plant part will need the N @@ -1269,7 +1269,7 @@ subroutine calc_plant_nitrogen_demand(this, bounds, num_soilp, filter_soilp, & croot_stem => pftcon%croot_stem , & ! Input: allocation parameter: new coarse root C per new stem C (gC/gC) stem_leaf => pftcon%stem_leaf , & ! Input: allocation parameter: new stem c per new leaf C (gC/gC) flivewd => pftcon%flivewd , & ! Input: allocation parameter: fraction of new wood that is live (phloem and ray parenchyma) (no units) - leafcn => pftcon%leafcn , & ! Input: leaf C:N (gC/gN) + leafcn => cnveg_nitrogenstate_inst%leafcn_patch , & ! Input: leaf C:N (gC/gN) frootcn => pftcon%frootcn , & ! Input: fine root C:N (gC/gN) livewdcn => pftcon%livewdcn , & ! Input: live wood (phloem and ray parenchyma) C:N (gC/gN) deadwdcn => pftcon%deadwdcn , & ! Input: dead wood (xylem and heartwood) C:N (gC/gN) @@ -1476,7 +1476,7 @@ subroutine calc_plant_nitrogen_demand(this, bounds, num_soilp, filter_soilp, & f4 = flivewd(ivt(p)) g1 = grperc(ivt(p)) g2 = grpnow(ivt(p)) - cnl = leafcn(ivt(p)) + cnl = leafcn(p) cnfr = frootcn(ivt(p)) cnlw = livewdcn(ivt(p)) cndw = deadwdcn(ivt(p)) @@ -1656,8 +1656,8 @@ subroutine calc_plant_nitrogen_demand(this, bounds, num_soilp, filter_soilp, & if (nscalar_opt) then - leafcn_min = leafcn(ivt(p)) - 10.0_r8 - leafcn_max = leafcn(ivt(p)) + 10.0_r8 + leafcn_min = leafcn(p) - 10.0_r8 + leafcn_max = leafcn(p) + 10.0_r8 this%actual_leafcn(p) = max( this%actual_leafcn(p), leafcn_min-0.0001_r8 ) this%actual_leafcn(p) = min( this%actual_leafcn(p), leafcn_max ) diff --git a/src/biogeophys/CanopyFluxesMod.F90 b/src/biogeophys/CanopyFluxesMod.F90 index 1d5298bac2..8646de1d90 100644 --- a/src/biogeophys/CanopyFluxesMod.F90 +++ b/src/biogeophys/CanopyFluxesMod.F90 @@ -41,6 +41,7 @@ module CanopyFluxesMod use HumanIndexMod , only : humanindex_type use ch4Mod , only : ch4_type use PhotosynthesisMod , only : photosyns_type + use CNVegnitrogenstateType, only : cnveg_nitrogenstate_type use GridcellType , only : grc use ColumnType , only : col use PatchType , only : patch @@ -190,7 +191,7 @@ subroutine CanopyFluxes(bounds, num_exposedvegp, filter_exposedvegp, energyflux_inst, frictionvel_inst, soilstate_inst, solarabs_inst, surfalb_inst, & temperature_inst, waterfluxbulk_inst, waterstatebulk_inst, & waterdiagnosticbulk_inst, wateratm2lndbulk_inst, ch4_inst, ozone_inst, & - photosyns_inst, & + photosyns_inst, cnveg_nitrogenstate_inst, & humanindex_inst, soil_water_retention_curve, & downreg_patch, leafn_patch, froot_carbon, croot_carbon) ! @@ -260,6 +261,7 @@ subroutine CanopyFluxes(bounds, num_exposedvegp, filter_exposedvegp, type(ch4_type) , intent(inout) :: ch4_inst class(ozone_base_type) , intent(inout) :: ozone_inst type(photosyns_type) , intent(inout) :: photosyns_inst + type(cnveg_nitrogenstate_type) , intent(in) :: cnveg_nitrogenstate_inst type(humanindex_type) , intent(inout) :: humanindex_inst class(soil_water_retention_curve_type) , intent(in) :: soil_water_retention_curve real(r8), intent(in) :: downreg_patch(bounds%begp:) ! fractional reduction in GPP due to N limitation (dimensionless) @@ -1066,6 +1068,7 @@ subroutine CanopyFluxes(bounds, num_exposedvegp, filter_exposedvegp, svpts(begp:endp), eah(begp:endp), o2(begp:endp), co2(begp:endp), rb(begp:endp), bsun(begp:endp), & bsha(begp:endp), btran(begp:endp), dayl_factor(begp:endp), leafn_patch(begp:endp), & qsatl(begp:endp), qaf(begp:endp), & + cnveg_nitrogenstate_inst, & atm2lnd_inst, temperature_inst, soilstate_inst, waterdiagnosticbulk_inst, surfalb_inst, solarabs_inst, & canopystate_inst, ozone_inst, photosyns_inst, waterfluxbulk_inst, & froot_carbon(begp:endp), croot_carbon(begp:endp)) @@ -1073,6 +1076,7 @@ subroutine CanopyFluxes(bounds, num_exposedvegp, filter_exposedvegp, call Photosynthesis (bounds, fn, filterp, & svpts(begp:endp), eah(begp:endp), o2(begp:endp), co2(begp:endp), rb(begp:endp), btran(begp:endp), & dayl_factor(begp:endp), leafn_patch(begp:endp), & + cnveg_nitrogenstate_inst, & atm2lnd_inst, temperature_inst, surfalb_inst, solarabs_inst, & canopystate_inst, ozone_inst, photosyns_inst, phase='sun') endif @@ -1087,6 +1091,7 @@ subroutine CanopyFluxes(bounds, num_exposedvegp, filter_exposedvegp, call Photosynthesis (bounds, fn, filterp, & svpts(begp:endp), eah(begp:endp), o2(begp:endp), co2(begp:endp), rb(begp:endp), btran(begp:endp), & dayl_factor(begp:endp), leafn_patch(begp:endp), & + cnveg_nitrogenstate_inst, & atm2lnd_inst, temperature_inst, surfalb_inst, solarabs_inst, & canopystate_inst, ozone_inst, photosyns_inst, phase='sha') end if diff --git a/src/biogeophys/PhotosynthesisMod.F90 b/src/biogeophys/PhotosynthesisMod.F90 index 5b2c68a0fb..6e5921ce1e 100644 --- a/src/biogeophys/PhotosynthesisMod.F90 +++ b/src/biogeophys/PhotosynthesisMod.F90 @@ -24,6 +24,7 @@ module PhotosynthesisMod use CIsoAtmTimeseriesMod, only : C14BombSpike, use_c14_bombspike, C13TimeSeries, use_c13_timeseries, nsectors_c14 use atm2lndType , only : atm2lnd_type use CanopyStateType , only : canopystate_type + use CNVegnitrogenstateType, only : cnveg_nitrogenstate_type use WaterDiagnosticBulkType , only : waterdiagnosticbulk_type use WaterFluxBulkType , only : waterfluxbulk_type use SoilStateType , only : soilstate_type @@ -1220,6 +1221,7 @@ end subroutine NewPatchInit subroutine Photosynthesis ( bounds, fn, filterp, & esat_tv, eair, oair, cair, rb, btran, & dayl_factor, leafn, & + cnveg_nitrogenstate_inst, & atm2lnd_inst, temperature_inst, surfalb_inst, solarabs_inst, & canopystate_inst, ozone_inst, photosyns_inst, phase) ! @@ -1249,6 +1251,7 @@ subroutine Photosynthesis ( bounds, fn, filterp, & real(r8) , intent(in) :: btran( bounds%begp: ) ! transpiration wetness factor (0 to 1) [pft] real(r8) , intent(in) :: dayl_factor( bounds%begp: ) ! scalar (0-1) for daylength real(r8) , intent(in) :: leafn( bounds%begp: ) ! leaf N (gN/m2) + type(cnveg_nitrogenstate_type), intent(in) :: cnveg_nitrogenstate_inst type(atm2lnd_type) , intent(in) :: atm2lnd_inst type(temperature_type) , intent(in) :: temperature_inst type(surfalb_type) , intent(in) :: surfalb_inst @@ -1378,7 +1381,7 @@ subroutine Photosynthesis ( bounds, fn, filterp, & associate( & c3psn => pftcon%c3psn , & ! Input: photosynthetic pathway: 0. = c4, 1. = c3 crop => pftcon%crop , & ! Input: crop or not (0 =not crop and 1 = crop) - leafcn => pftcon%leafcn , & ! Input: leaf C:N (gC/gN) + leafcn => cnveg_nitrogenstate_inst%leafcn_patch , & ! Input: leaf C:N (gC/gN) flnr => pftcon%flnr , & ! Input: fraction of leaf N in the Rubisco enzyme (gN Rubisco / gN leaf) fnitr => pftcon%fnitr , & ! Input: foliage nitrogen limitation factor (-) slatop => pftcon%slatop , & ! Input: specific leaf area at top of canopy, projected area basis [m^2/gC] @@ -1547,10 +1550,10 @@ subroutine Photosynthesis ( bounds, fn, filterp, & if (lnc_opt .eqv. .false.) then ! Leaf nitrogen concentration at the top of the canopy (g N leaf / m**2 leaf) - if ( (slatop(patch%itype(p)) *leafcn(patch%itype(p))) .le. 0.0_r8)then + if ( (slatop(patch%itype(p)) * leafcn(p)) .le. 0.0_r8)then call endrun(subgrid_index=p, subgrid_level=subgrid_level_patch, msg="ERROR: slatop or leafcn is zero") end if - lnc(p) = 1._r8 / (slatop(patch%itype(p)) * leafcn(patch%itype(p))) + lnc(p) = 1._r8 / (slatop(patch%itype(p)) * leafcn(p)) end if ! Using the actual nitrogen allocated to the leaf after @@ -2685,6 +2688,7 @@ end subroutine ci_func subroutine PhotosynthesisHydraulicStress ( bounds, fn, filterp, & esat_tv, eair, oair, cair, rb, bsun, bsha, btran, dayl_factor, leafn, & qsatl, qaf, & + cnveg_nitrogenstate_inst, & atm2lnd_inst, temperature_inst, soilstate_inst, waterdiagnosticbulk_inst, & surfalb_inst, solarabs_inst, canopystate_inst, ozone_inst, & photosyns_inst, waterfluxbulk_inst, froot_carbon, croot_carbon) @@ -2728,6 +2732,7 @@ subroutine PhotosynthesisHydraulicStress ( bounds, fn, filterp, & real(r8) , intent(in) :: froot_carbon( bounds%begp: ) ! fine root carbon (gC/m2) [pft] real(r8) , intent(in) :: croot_carbon( bounds%begp: ) ! live coarse root carbon (gC/m2) [pft] + type(cnveg_nitrogenstate_type), intent(in) :: cnveg_nitrogenstate_inst type(atm2lnd_type) , intent(in) :: atm2lnd_inst type(temperature_type) , intent(in) :: temperature_inst type(surfalb_type) , intent(in) :: surfalb_inst @@ -2929,7 +2934,7 @@ subroutine PhotosynthesisHydraulicStress ( bounds, fn, filterp, & tsai => canopystate_inst%tsai_patch , & ! Input: [real(r8) (:) ] patch canopy one-sided stem area index, no burying by snow c3psn => pftcon%c3psn , & ! Input: photosynthetic pathway: 0. = c4, 1. = c3 crop => pftcon%crop , & ! Input: crop or not (0 =not crop and 1 = crop) - leafcn => pftcon%leafcn , & ! Input: leaf C:N (gC/gN) + leafcn => cnveg_nitrogenstate_inst%leafcn_patch , & ! Input: leaf C:N (gC/gN) flnr => pftcon%flnr , & ! Input: fraction of leaf N in the Rubisco enzyme (gN Rubisco / gN leaf) fnitr => pftcon%fnitr , & ! Input: foliage nitrogen limitation factor (-) slatop => pftcon%slatop , & ! Input: specific leaf area at top of canopy, projected area basis [m^2/gC] @@ -3151,7 +3156,7 @@ subroutine PhotosynthesisHydraulicStress ( bounds, fn, filterp, & if (lnc_opt .eqv. .false.) then ! Leaf nitrogen concentration at the top of the canopy (g N leaf / m**2 leaf) - lnc(p) = 1._r8 / (slatop(patch%itype(p)) * leafcn(patch%itype(p))) + lnc(p) = 1._r8 / (slatop(patch%itype(p)) * leafcn(p)) end if ! Using the actual nitrogen allocated to the leaf after diff --git a/src/main/clm_driver.F90 b/src/main/clm_driver.F90 index b81ae16a01..36dd258c70 100644 --- a/src/main/clm_driver.F90 +++ b/src/main/clm_driver.F90 @@ -696,6 +696,7 @@ subroutine clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate, ro temperature_inst, water_inst%waterfluxbulk_inst, water_inst%waterstatebulk_inst, & water_inst%waterdiagnosticbulk_inst, water_inst%wateratm2lndbulk_inst, & ch4_inst, ozone_inst, photosyns_inst, & + bgc_vegetation_inst%cnveg_nitrogenstate_inst, & humanindex_inst, soil_water_retention_curve, & downreg_patch = downreg_patch(bounds_clump%begp:bounds_clump%endp), & leafn_patch = leafn_patch(bounds_clump%begp:bounds_clump%endp), & From 13a9af8d41d00ef4322bb7774e5a374605444b04 Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Tue, 22 Feb 2022 18:44:48 -0700 Subject: [PATCH 07/32] Repl. pftcon%leafcn also in function SpeciesTypeMultiplier I.e. in CNVegComputeSeedMod.F90 BUT not in the corresponding unit tests --- src/biogeochem/CNVegCarbonStateType.F90 | 3 +++ src/biogeochem/CNVegComputeSeedMod.F90 | 13 +++++++++---- src/biogeochem/CNVegNitrogenStateType.F90 | 1 + src/biogeochem/dynConsBiogeochemMod.F90 | 3 +++ 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/biogeochem/CNVegCarbonStateType.F90 b/src/biogeochem/CNVegCarbonStateType.F90 index 318f00eac2..29532f5885 100644 --- a/src/biogeochem/CNVegCarbonStateType.F90 +++ b/src/biogeochem/CNVegCarbonStateType.F90 @@ -2538,6 +2538,7 @@ subroutine DynamicPatchAdjustments(this, bounds, & num_soilp_with_inactive, filter_soilp_with_inactive, & patch_state_updater, & leafc_seed, deadstemc_seed, & + leafcn_patch, & conv_cflux, wood_product_cflux, crop_product_cflux, & dwt_frootc_to_litter, & dwt_livecrootc_to_litter, & @@ -2559,6 +2560,7 @@ subroutine DynamicPatchAdjustments(this, bounds, & type(patch_state_updater_type) , intent(in) :: patch_state_updater real(r8) , intent(in) :: leafc_seed ! seed amount for leaf C real(r8) , intent(in) :: deadstemc_seed ! seed amount for deadstem C + real(r8) , intent(in) :: leafcn_patch( bounds%begp: ) ! current leaf C:N (gC/gN) real(r8) , intent(inout) :: conv_cflux( bounds%begp: ) ! patch-level conversion C flux to atm (expressed per unit GRIDCELL area) real(r8) , intent(inout) :: wood_product_cflux( bounds%begp: ) ! patch-level product C flux (expressed per unit GRIDCELL area) real(r8) , intent(inout) :: crop_product_cflux( bounds%begp: ) ! patch-level crop product C flux (expressed per unit GRIDCELL area) @@ -2600,6 +2602,7 @@ subroutine DynamicPatchAdjustments(this, bounds, & call ComputeSeedAmounts(bounds, & num_soilp_with_inactive, filter_soilp_with_inactive, & + leafcn_patch = leafcn_patch(begp:endp), & species = this%species, & leafc_seed = leafc_seed, & deadstemc_seed = deadstemc_seed, & diff --git a/src/biogeochem/CNVegComputeSeedMod.F90 b/src/biogeochem/CNVegComputeSeedMod.F90 index 2581d5ba1e..6735b01bef 100644 --- a/src/biogeochem/CNVegComputeSeedMod.F90 +++ b/src/biogeochem/CNVegComputeSeedMod.F90 @@ -39,6 +39,7 @@ module CNVegComputeSeedMod !----------------------------------------------------------------------- subroutine ComputeSeedAmounts(bounds, & num_soilp_with_inactive, filter_soilp_with_inactive, & + leafcn_patch, & species, & leafc_seed, deadstemc_seed, & leaf_patch, leaf_storage_patch, leaf_xfer_patch, & @@ -66,6 +67,7 @@ subroutine ComputeSeedAmounts(bounds, & integer , intent(in) :: species ! which C/N species we're operating on; should be one of the values in CNSpeciesMod real(r8) , intent(in) :: leafc_seed ! seed amount for leaf C real(r8) , intent(in) :: deadstemc_seed ! seed amount for deadstem C + real(r8) , intent(in) :: leafcn_patch( bounds%begp: ) ! current leaf C:N (gC/gN) real(r8) , intent(in) :: leaf_patch( bounds%begp: ) ! current leaf C or N content (g/m2) real(r8) , intent(in) :: leaf_storage_patch( bounds%begp: ) ! current leaf C or N storage content (g/m2) real(r8) , intent(in) :: leaf_xfer_patch( bounds%begp: ) ! current leaf C or N xfer content (g/m2) @@ -88,6 +90,7 @@ subroutine ComputeSeedAmounts(bounds, & real(r8) :: my_leaf_seed real(r8) :: my_deadstem_seed integer :: pft_type + real(r8) :: leafcn real(r8) :: pleaf real(r8) :: pstor real(r8) :: pxfer @@ -118,6 +121,7 @@ subroutine ComputeSeedAmounts(bounds, & my_deadstem_seed = 0._r8 pft_type = patch%itype(p) + leafcn = leafcn_patch(p) call LeafProportions( & ignore_current_state = ignore_current_state_patch(p), & @@ -131,10 +135,10 @@ subroutine ComputeSeedAmounts(bounds, & if (pft_type /= noveg) then my_leaf_seed = leafc_seed * & - SpeciesTypeMultiplier(species, pft_type, COMPONENT_LEAF) + SpeciesTypeMultiplier(species, pft_type, leafcn, COMPONENT_LEAF) if (pftcon%woody(pft_type) == 1._r8) then my_deadstem_seed = deadstemc_seed * & - SpeciesTypeMultiplier(species, pft_type, COMPONENT_DEADWOOD) + SpeciesTypeMultiplier(species, pft_type, leafcn, COMPONENT_DEADWOOD) end if end if @@ -150,7 +154,7 @@ end subroutine ComputeSeedAmounts !----------------------------------------------------------------------- - function SpeciesTypeMultiplier(species, pft_type, component) result(multiplier) + function SpeciesTypeMultiplier(species, pft_type, leafcn, component) result(multiplier) ! ! !DESCRIPTION: ! Returns a multiplier based on the species type. This multiplier is @@ -163,6 +167,7 @@ function SpeciesTypeMultiplier(species, pft_type, component) result(multiplier) real(r8) :: multiplier ! function result integer, intent(in) :: species ! which C/N species we're operating on; should be one of the values in CNSpeciesMod integer, intent(in) :: pft_type + real(r8), intent(in) :: leafcn integer, intent(in) :: component ! which plant component; should be one of the COMPONENT_* parameters defined in this module ! ! !LOCAL VARIABLES: @@ -188,7 +193,7 @@ function SpeciesTypeMultiplier(species, pft_type, component) result(multiplier) case (CN_SPECIES_N) select case (component) case (COMPONENT_LEAF) - multiplier = 1._r8 / pftcon%leafcn(pft_type) + multiplier = 1._r8 / leafcn case (COMPONENT_DEADWOOD) multiplier = 1._r8 / pftcon%deadwdcn(pft_type) case default diff --git a/src/biogeochem/CNVegNitrogenStateType.F90 b/src/biogeochem/CNVegNitrogenStateType.F90 index f550aaf5e6..b60be2ff64 100644 --- a/src/biogeochem/CNVegNitrogenStateType.F90 +++ b/src/biogeochem/CNVegNitrogenStateType.F90 @@ -1184,6 +1184,7 @@ subroutine DynamicPatchAdjustments(this, bounds, & call ComputeSeedAmounts(bounds, & num_soilp_with_inactive, filter_soilp_with_inactive, & + leafcn_patch = this%leafcn_patch(begp:endp), & species = CN_SPECIES_N, & leafc_seed = leafc_seed, & deadstemc_seed = deadstemc_seed, & diff --git a/src/biogeochem/dynConsBiogeochemMod.F90 b/src/biogeochem/dynConsBiogeochemMod.F90 index f8cff29911..ca46f4f79a 100644 --- a/src/biogeochem/dynConsBiogeochemMod.F90 +++ b/src/biogeochem/dynConsBiogeochemMod.F90 @@ -445,6 +445,7 @@ subroutine dyn_cnbal_patch(bounds, & patch_state_updater, & leafc_seed = leafc_seed, & deadstemc_seed = deadstemc_seed, & + leafcn_patch = cnveg_nitrogenstate_inst%leafcn_patch(begp:endp), & conv_cflux = conv_cflux(begp:endp), & wood_product_cflux = wood_product_cflux(begp:endp), & crop_product_cflux = crop_product_cflux(begp:endp), & @@ -468,6 +469,7 @@ subroutine dyn_cnbal_patch(bounds, & patch_state_updater, & leafc_seed = leafc_seed, & deadstemc_seed = deadstemc_seed, & + leafcn_patch = cnveg_nitrogenstate_inst%leafcn_patch(begp:endp), & conv_cflux = conv_c13flux(begp:endp), & wood_product_cflux = wood_product_c13flux(begp:endp), & crop_product_cflux = crop_product_c13flux(begp:endp), & @@ -493,6 +495,7 @@ subroutine dyn_cnbal_patch(bounds, & patch_state_updater, & leafc_seed = leafc_seed, & deadstemc_seed = deadstemc_seed, & + leafcn_patch = cnveg_nitrogenstate_inst%leafcn_patch(begp:endp), & conv_cflux = conv_c14flux(begp:endp), & wood_product_cflux = wood_product_c14flux(begp:endp), & crop_product_cflux = crop_product_c14flux(begp:endp), & From a5f485674b6a562b93ab21583b3348cac5fe5dd3 Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Fri, 25 Feb 2022 19:10:21 -0700 Subject: [PATCH 08/32] Renamed subr. time_evolv_params to time_evolv_leafcn to be specific We may rename to something more generic if future development warrants --- src/biogeochem/CNVegNitrogenStateType.F90 | 8 ++++---- src/main/clm_driver.F90 | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/biogeochem/CNVegNitrogenStateType.F90 b/src/biogeochem/CNVegNitrogenStateType.F90 index b60be2ff64..528c12ed42 100644 --- a/src/biogeochem/CNVegNitrogenStateType.F90 +++ b/src/biogeochem/CNVegNitrogenStateType.F90 @@ -82,7 +82,7 @@ module CNVegNitrogenStateType procedure , private :: InitAllocate procedure , private :: InitHistory procedure , private :: InitCold - procedure , public :: time_evolv_params ! updates time-evolving params + procedure , public :: time_evolv_leafcn ! updates time-evolving leafcn end type cnveg_nitrogenstate_type !------------------------------------------------------------------------ @@ -1082,7 +1082,7 @@ subroutine Summary_nitrogenstate(this, bounds, num_allc, filter_allc, & end subroutine Summary_nitrogenstate !----------------------------------------------------------------------- - subroutine time_evolv_params(this, bounds, atm2lnd_inst) + subroutine time_evolv_leafcn(this, bounds, atm2lnd_inst) ! ! !DESCRIPTION: ! Update time-evolving parameters @@ -1102,7 +1102,7 @@ subroutine time_evolv_params(this, bounds, atm2lnd_inst) real(r8), parameter :: co2_base = 350._r8 ! units ppmv real(r8), parameter :: cn_slope = 10._r8 - character(len=*), parameter :: subname = 'time_evolv_params' + character(len=*), parameter :: subname = 'time_evolv_leafcn' !----------------------------------------------------------------------- ! Loop to get leafcn_col @@ -1115,7 +1115,7 @@ subroutine time_evolv_params(this, bounds, atm2lnd_inst) max(cn_slope * log(co2_ppmv / co2_base), 0._r8) end do - end subroutine time_evolv_params + end subroutine time_evolv_leafcn !----------------------------------------------------------------------- subroutine DynamicPatchAdjustments(this, bounds, & diff --git a/src/main/clm_driver.F90 b/src/main/clm_driver.F90 index 36dd258c70..33f25d9cd5 100644 --- a/src/main/clm_driver.F90 +++ b/src/main/clm_driver.F90 @@ -168,7 +168,7 @@ subroutine clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate, ro ! ------------------------------------------------- ! Obtain updated values of time-evolving parameters ! ------------------------------------------------- - call bgc_vegetation_inst%cnveg_nitrogenstate_inst%time_evolv_params( & + call bgc_vegetation_inst%cnveg_nitrogenstate_inst%time_evolv_leafcn( & bounds_proc, atm2lnd_inst) ! ======================================================================== From 0fe849e20701371ca0152ea2aedac5a6e395f4c6 Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Tue, 1 Mar 2022 19:00:13 -0700 Subject: [PATCH 09/32] Changed hardwired settings for cn_slope and co2_base --- src/biogeochem/CNVegNitrogenStateType.F90 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/biogeochem/CNVegNitrogenStateType.F90 b/src/biogeochem/CNVegNitrogenStateType.F90 index 528c12ed42..115dc9894f 100644 --- a/src/biogeochem/CNVegNitrogenStateType.F90 +++ b/src/biogeochem/CNVegNitrogenStateType.F90 @@ -1099,8 +1099,8 @@ subroutine time_evolv_leafcn(this, bounds, atm2lnd_inst) integer :: g, c, p ! indices real(r8) :: co2_ppmv ! atm co2 concentration ! Could use 355 value from clm_varctl.F90 to avoid this hardwiring? - real(r8), parameter :: co2_base = 350._r8 ! units ppmv - real(r8), parameter :: cn_slope = 10._r8 + real(r8), parameter :: co2_base = 310._r8 ! units ppmv + real(r8), parameter :: cn_slope = 0._r8 character(len=*), parameter :: subname = 'time_evolv_leafcn' !----------------------------------------------------------------------- From 830abfa46f1bf4388a1974fc3e2f4fd6ef21b9db Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Tue, 18 Mar 2025 13:20:12 -0600 Subject: [PATCH 10/32] Additional conflict resolutions from side-by-side comparison of mods --- src/biogeochem/CNPhenologyMod.F90 | 2 +- src/biogeochem/NutrientCompetitionCLM45defaultMod.F90 | 3 +-- src/biogeochem/NutrientCompetitionFlexibleCNMod.F90 | 4 ++-- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/biogeochem/CNPhenologyMod.F90 b/src/biogeochem/CNPhenologyMod.F90 index ee0d0c2326..21b3e78645 100644 --- a/src/biogeochem/CNPhenologyMod.F90 +++ b/src/biogeochem/CNPhenologyMod.F90 @@ -2074,7 +2074,7 @@ subroutine CropPhenology(num_pcropp, filter_pcropp , & associate( & ivt => patch%itype , & ! Input: [integer (:) ] patch vegetation type - leaf_long => pftcon%leaf_long , & ! Input: leaf longevity (yrs) + leaf_long => pftcon%leaf_long , & ! Input: leaf longevity (yrs) leafcn => cnveg_nitrogenstate_inst%leafcn_patch , & ! Input: leaf C:N (gC/gN) manunitro => pftcon%manunitro , & ! Input: max manure to be applied in total (kgN/m2) minplanttemp => pftcon%minplanttemp , & ! Input: diff --git a/src/biogeochem/NutrientCompetitionCLM45defaultMod.F90 b/src/biogeochem/NutrientCompetitionCLM45defaultMod.F90 index 537c04bcb3..332a746bdd 100644 --- a/src/biogeochem/NutrientCompetitionCLM45defaultMod.F90 +++ b/src/biogeochem/NutrientCompetitionCLM45defaultMod.F90 @@ -113,7 +113,6 @@ subroutine calc_plant_nutrient_competition (this, & call this%calc_plant_cn_alloc (bounds, num_soilp, filter_soilp, & cnveg_state_inst, crop_inst, canopystate_inst, & cnveg_carbonstate_inst, cnveg_carbonflux_inst, c13_cnveg_carbonflux_inst, & - c14_cnveg_carbonflux_inst, cnveg_nitrogenflux_inst, & c14_cnveg_carbonflux_inst, cnveg_nitrogenflux_inst, cnveg_nitrogenstate_inst, & fpg_col=fpg_col(bounds%begc:bounds%endc)) @@ -123,7 +122,7 @@ end subroutine calc_plant_nutrient_competition subroutine calc_plant_cn_alloc (this, bounds, num_soilp, filter_soilp, & cnveg_state_inst, crop_inst, canopystate_inst, & cnveg_carbonstate_inst, cnveg_carbonflux_inst, c13_cnveg_carbonflux_inst, & - c14_cnveg_carbonflux_inst, cnveg_nitrogenflux_inst, cnveg_nitrogenstate_inst, & + c14_cnveg_carbonflux_inst, cnveg_nitrogenflux_inst, cnveg_nitrogenstate_inst, fpg_col) ! ! !USES: use pftconMod , only : pftcon, npcropmin diff --git a/src/biogeochem/NutrientCompetitionFlexibleCNMod.F90 b/src/biogeochem/NutrientCompetitionFlexibleCNMod.F90 index cf7afcc3ad..aec7d0c480 100644 --- a/src/biogeochem/NutrientCompetitionFlexibleCNMod.F90 +++ b/src/biogeochem/NutrientCompetitionFlexibleCNMod.F90 @@ -1520,8 +1520,8 @@ subroutine calc_plant_nitrogen_demand(this, bounds, & this%actual_leafcn(p) = leafc(p) / leafn(p) end if - leafcn_min = leafcn(ivt(p)) - 10.0_r8 - leafcn_max = leafcn(ivt(p)) + 10.0_r8 + leafcn_min = leafcn(p) - 10.0_r8 + leafcn_max = leafcn(p) + 10.0_r8 this%actual_leafcn(p) = max( this%actual_leafcn(p), leafcn_min-0.0001_r8 ) this%actual_leafcn(p) = min( this%actual_leafcn(p), leafcn_max ) From 1d64552daf87fc0bdfe11963aaa7246feacdffac Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Wed, 19 Mar 2025 09:34:26 -0600 Subject: [PATCH 11/32] Corrections for aux_clm tests to build successfully --- src/biogeochem/NutrientCompetitionCLM45defaultMod.F90 | 1 + src/biogeochem/NutrientCompetitionFlexibleCNMod.F90 | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/biogeochem/NutrientCompetitionCLM45defaultMod.F90 b/src/biogeochem/NutrientCompetitionCLM45defaultMod.F90 index 332a746bdd..3df5b25edb 100644 --- a/src/biogeochem/NutrientCompetitionCLM45defaultMod.F90 +++ b/src/biogeochem/NutrientCompetitionCLM45defaultMod.F90 @@ -179,6 +179,7 @@ subroutine calc_plant_cn_alloc (this, bounds, num_soilp, filter_soilp, & stem_leaf => pftcon%stem_leaf , & ! Input: allocation parameter: new stem c per new leaf C (gC/gC) flivewd => pftcon%flivewd , & ! Input: allocation parameter: fraction of new wood that is live (phloem and ray parenchyma) (no units) leafcn => cnveg_nitrogenstate_inst%leafcn_patch , & ! Input: leaf C:N (gC/gN) + frootcn => pftcon%frootcn , & ! Input: fine root C:N (gC/gN) livewdcn => pftcon%livewdcn , & ! Input: live wood (phloem and ray parenchyma) C:N (gC/gN) deadwdcn => pftcon%deadwdcn , & ! Input: dead wood (xylem and heartwood) C:N (gC/gN) fcur2 => pftcon%fcur , & ! Input: allocation parameter: fraction of allocation that goes to currently displayed growth, remainder to storage diff --git a/src/biogeochem/NutrientCompetitionFlexibleCNMod.F90 b/src/biogeochem/NutrientCompetitionFlexibleCNMod.F90 index aec7d0c480..421b3100a0 100644 --- a/src/biogeochem/NutrientCompetitionFlexibleCNMod.F90 +++ b/src/biogeochem/NutrientCompetitionFlexibleCNMod.F90 @@ -635,6 +635,7 @@ subroutine calc_plant_cn_alloc(this, bounds, num_soilp, filter_soilp, & f3 = f3, & f4 = f4, & f5 = f5, & + leafcn = leafcn(p), & ! Outputs npool_to_leafn = npool_to_leafn(p), & @@ -930,7 +931,7 @@ end subroutine calc_plant_cn_alloc !----------------------------------------------------------------------- subroutine calc_npool_to_components_flexiblecn( & - npool, ivt, nlc, fcur, f1, f2, f3, f4, f5, & + npool, ivt, nlc, fcur, f1, f2, f3, f4, f5, leafcn, & npool_to_leafn, npool_to_leafn_storage, & npool_to_frootn, npool_to_frootn_storage, & npool_to_livestemn, npool_to_livestemn_storage, & @@ -952,6 +953,7 @@ subroutine calc_npool_to_components_flexiblecn( & real(r8), intent(in) :: f3 ! C allocation parameter - stem:leaf ratio real(r8), intent(in) :: f4 ! C allocation parameter - fraction of new wood that is live real(r8), intent(in) :: f5(:) ! C allocation parameter - repr:leaf ratio for each crop reproductive pool + real(r8), intent(in) :: leafcn ! leaf C:N (gC/gN) ! Each of the following output variables is in units of gN/m2/s; they are ! intent(inout) because some may remain unchanged in some circumstances. @@ -1018,7 +1020,6 @@ subroutine calc_npool_to_components_flexiblecn( & associate( & woody => pftcon%woody , & ! Input: binary flag for woody lifeform (1=woody, 0=not woody) - leafcn => cnveg_nitrogenstate_inst%leafcn_patch, & ! Input: leaf C:N (gC/gN) frootcn => pftcon%frootcn , & ! Input: fine root C:N (gC/gN) livewdcn => pftcon%livewdcn , & ! Input: live wood (phloem and ray parenchyma) C:N (gC/gN) deadwdcn => pftcon%deadwdcn , & ! Input: dead wood (xylem and heartwood) C:N (gC/gN) @@ -1027,7 +1028,7 @@ subroutine calc_npool_to_components_flexiblecn( & dt = get_step_size_real() - cnl = leafcn(p) + cnl = leafcn cnfr = frootcn(ivt) cnlw = livewdcn(ivt) cndw = deadwdcn(ivt) From 625ded8084d8b2cde41240c289a756ea26db2bbc Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Wed, 19 Mar 2025 16:00:42 -0600 Subject: [PATCH 12/32] Updates to get specific failing test to pass SMS_D_Mmpi-serial_Ld5.5x5_amazon.I2000Clm60Bgc.derecho_gnu.clm-HillslopeC I will retry aux_clm now --- src/biogeochem/CNVegNitrogenStateType.F90 | 25 ++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/src/biogeochem/CNVegNitrogenStateType.F90 b/src/biogeochem/CNVegNitrogenStateType.F90 index 20d5c1fe29..292b74bdac 100644 --- a/src/biogeochem/CNVegNitrogenStateType.F90 +++ b/src/biogeochem/CNVegNitrogenStateType.F90 @@ -342,7 +342,6 @@ subroutine InitAllocate(this, bounds, alloc_full_veg) allocate(this%totn_p2c_col (begc:endc)) ; this%totn_p2c_col (:) = nan - allocate(this%leafcn_patch (begp:endp)) ; this%leafcn_patch (:) = nan if(use_matrixcn)then allocate(this%leafn0_patch (begp:endp)) ; this%leafn0_patch (:) = nan allocate(this%leafn0_storage_patch (begp:endp)) ; this%leafn0_storage_patch (:) = nan @@ -840,6 +839,8 @@ subroutine InitCold(this, bounds, & l = patch%landunit(p) if (lun%itype(l) == istsoil .or. lun%itype(l) == istcrop) then + this%leafcn_patch(p) = pftcon%leafcn(patch%itype(p)) + if (patch%itype(p) == noveg) then this%leafn_patch(p) = 0._r8 this%leafn_storage_patch(p) = 0._r8 @@ -856,7 +857,6 @@ subroutine InitCold(this, bounds, & end if end if else - this%leafcn_patch(p) = pftcon%leafcn(patch%itype(p)) this%leafn_patch(p) = leafc_patch(p) / this%leafcn_patch(p) this%leafn_storage_patch(p) = leafc_storage_patch(p) / this%leafcn_patch(p) if(use_matrixcn)then @@ -2305,9 +2305,14 @@ subroutine time_evolv_leafcn(this, bounds, atm2lnd_inst) ! ! !DESCRIPTION: ! Update time-evolving parameters + ! In the current implementation, we call this subroutine from clm_drv + ! first thing, before anything else. Hence we allocate leafcn_patch + ! to memory if_first_step here instead of waiting for the call to + ! InitAllocate. ! ! !USES: use pftconMod, only : pftcon + use clm_time_manager, only : is_first_step ! ! !ARGUMENTS: class(cnveg_nitrogenstate_type) :: this @@ -2315,7 +2320,7 @@ subroutine time_evolv_leafcn(this, bounds, atm2lnd_inst) type(atm2lnd_type), intent(in) :: atm2lnd_inst ! ! !LOCAL VARIABLES: - integer :: g, c, p ! indices + integer :: g, l, c, p ! indices real(r8) :: co2_ppmv ! atm co2 concentration ! Could use 355 value from clm_varctl.F90 to avoid this hardwiring? real(r8), parameter :: co2_base = 310._r8 ! units ppmv @@ -2324,14 +2329,20 @@ subroutine time_evolv_leafcn(this, bounds, atm2lnd_inst) character(len=*), parameter :: subname = 'time_evolv_leafcn' !----------------------------------------------------------------------- + if (is_first_step()) then + allocate(this%leafcn_patch(bounds%begp:bounds%endp)); this%leafcn_patch(:) = nan + end if ! Loop to get leafcn_col do p = bounds%begp, bounds%endp c = patch%column(p) + l = patch%landunit(p) g = patch%gridcell(p) - co2_ppmv = 1.e6_r8 * atm2lnd_inst%forc_pco2_grc(g) / & - atm2lnd_inst%forc_pbot_downscaled_col(c) - this%leafcn_patch(p) = pftcon%leafcn(patch%itype(p)) + & - max(cn_slope * log(co2_ppmv / co2_base), 0._r8) + if (lun%itype(l) == istsoil .or. lun%itype(l) == istcrop) then + co2_ppmv = 1.e6_r8 * atm2lnd_inst%forc_pco2_grc(g) / & + atm2lnd_inst%forc_pbot_downscaled_col(c) + this%leafcn_patch(p) = pftcon%leafcn(patch%itype(p)) + & + max(cn_slope * log(co2_ppmv / co2_base), 0._r8) + end if end do end subroutine time_evolv_leafcn From f7be84e913af39822222fa907852a683e35f9ad7 Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Wed, 19 Mar 2025 16:52:24 -0600 Subject: [PATCH 13/32] Try allocating leafcn_patch twice to prevent test failures --- src/biogeochem/CNVegNitrogenStateType.F90 | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/biogeochem/CNVegNitrogenStateType.F90 b/src/biogeochem/CNVegNitrogenStateType.F90 index 292b74bdac..39b87225ff 100644 --- a/src/biogeochem/CNVegNitrogenStateType.F90 +++ b/src/biogeochem/CNVegNitrogenStateType.F90 @@ -340,8 +340,8 @@ subroutine InitAllocate(this, bounds, alloc_full_veg) allocate(this%seedn_grc (begg:endg)) ; this%seedn_grc (:) = nan allocate(this%totvegn_col (begc:endc)) ; this%totvegn_col (:) = nan allocate(this%totn_p2c_col (begc:endc)) ; this%totn_p2c_col (:) = nan - + allocate(this%leafcn_patch (begp:endp)) ; this%leafcn_patch (:) = nan if(use_matrixcn)then allocate(this%leafn0_patch (begp:endp)) ; this%leafn0_patch (:) = nan allocate(this%leafn0_storage_patch (begp:endp)) ; this%leafn0_storage_patch (:) = nan @@ -2302,13 +2302,16 @@ end subroutine Summary_nitrogenstate !----------------------------------------------------------------------- subroutine time_evolv_leafcn(this, bounds, atm2lnd_inst) + ! + ! AUTHOR: slevis ! ! !DESCRIPTION: ! Update time-evolving parameters - ! In the current implementation, we call this subroutine from clm_drv - ! first thing, before anything else. Hence we allocate leafcn_patch - ! to memory if_first_step here instead of waiting for the call to - ! InitAllocate. + ! In the current implementation, I call this subroutine from clm_drv + ! first thing, before anything else. Hence I allocate leafcn_patch + ! to memory if_first_step here to prevent an error in some tests. + ! I allocate again in InitAllocate to prevent a similar error in + ! InitHistory in other tests. ! ! !USES: use pftconMod, only : pftcon From a6194763f13814dd9e69d566395758b97333642a Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Fri, 21 Mar 2025 15:06:39 -0600 Subject: [PATCH 14/32] Missed this change in the original implementation --- src/biogeochem/CNAllocationMod.F90 | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/biogeochem/CNAllocationMod.F90 b/src/biogeochem/CNAllocationMod.F90 index 6376279a61..bb4e7c7519 100644 --- a/src/biogeochem/CNAllocationMod.F90 +++ b/src/biogeochem/CNAllocationMod.F90 @@ -23,6 +23,7 @@ module CNAllocationMod use CNVegCarbonStateType , only : cnveg_carbonstate_type use CNVegCarbonFluxType , only : cnveg_carbonflux_type use CNVegStateType , only : cnveg_state_type + use CNVegNitrogenStateType, only: cnveg_nitrogenstate_type use CropReprPoolsMod , only : nrepr use CNPhenologyMod , only : CropPhase use CNSharedParamsMod , only : use_fun @@ -433,7 +434,7 @@ end subroutine calc_crop_allocation_fractions !----------------------------------------------------------------------- subroutine calc_allometry(num_soilp, filter_soilp, & - cnveg_carbonflux_inst, cnveg_state_inst) + cnveg_carbonflux_inst, cnveg_state_inst, cnveg_nitrogenstate_inst) ! ! !DESCRIPTION: ! Calculate c_allometry and n_allometry terms based on allocation fractions @@ -442,6 +443,7 @@ subroutine calc_allometry(num_soilp, filter_soilp, & integer , intent(in) :: num_soilp ! number of soil patches in filter integer , intent(in) :: filter_soilp(:) ! filter for soil patches type(cnveg_carbonflux_type) , intent(in) :: cnveg_carbonflux_inst + type(cnveg_nitrogenstate_type) , intent(in) :: cnveg_nitrogenstate_inst type(cnveg_state_type) , intent(inout) :: cnveg_state_inst ! ! !LOCAL VARIABLES: @@ -464,7 +466,7 @@ subroutine calc_allometry(num_soilp, filter_soilp, & croot_stem => pftcon%croot_stem , & ! Input: allocation parameter: new coarse root C per new stem C (gC/gC) stem_leaf => pftcon%stem_leaf , & ! Input: allocation parameter: new stem c per new leaf C (gC/gC) flivewd => pftcon%flivewd , & ! Input: allocation parameter: fraction of new wood that is live (phloem and ray parenchyma) (no units) - leafcn => pftcon%leafcn , & ! Input: leaf C:N (gC/gN) + leafcn_t_evolving => cnveg_nitrogenstate_inst%leafcn_patch, & ! Input: leaf C:N (gC/gN) frootcn => pftcon%frootcn , & ! Input: fine root C:N (gC/gN) livewdcn => pftcon%livewdcn , & ! Input: live wood (phloem and ray parenchyma) C:N (gC/gN) deadwdcn => pftcon%deadwdcn , & ! Input: dead wood (xylem and heartwood) C:N (gC/gN) @@ -503,7 +505,7 @@ subroutine calc_allometry(num_soilp, filter_soilp, & else g1 = grperc(ivt(p)) end if - cnl = leafcn(ivt(p)) + cnl = leafcn_t_evolving(p) cnfr = frootcn(ivt(p)) cnlw = livewdcn(ivt(p)) cndw = deadwdcn(ivt(p)) From a24446f639e5032e3c47e74816759f3b0da69329 Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Fri, 21 Mar 2025 15:13:57 -0600 Subject: [PATCH 15/32] This should have gone together with the last commit --- src/biogeochem/CNDriverMod.F90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/biogeochem/CNDriverMod.F90 b/src/biogeochem/CNDriverMod.F90 index 0274fcc87f..b407e07ad5 100644 --- a/src/biogeochem/CNDriverMod.F90 +++ b/src/biogeochem/CNDriverMod.F90 @@ -429,7 +429,7 @@ subroutine CNDriverNoLeaching(bounds, end if call calc_allometry(num_bgc_vegp, filter_bgc_vegp, & - cnveg_carbonflux_inst, cnveg_state_inst) + cnveg_carbonflux_inst, cnveg_state_inst, cnveg_nitrogenstate_inst) call t_stopf('cnalloc') end if From 8e1e2c64b8b9c03372e6cac6320453f2d4dec8b7 Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Fri, 21 Mar 2025 15:18:56 -0600 Subject: [PATCH 16/32] Clarify the variable name to leafcn_t_evolving in CNFUNMod --- src/biogeochem/CNFUNMod.F90 | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/biogeochem/CNFUNMod.F90 b/src/biogeochem/CNFUNMod.F90 index 7dfe1cc941..3608a92f16 100644 --- a/src/biogeochem/CNFUNMod.F90 +++ b/src/biogeochem/CNFUNMod.F90 @@ -216,7 +216,7 @@ subroutine CNFUNInit (bounds,cnveg_state_inst,cnveg_carbonstate_inst,cnveg_nitro ! Set local pointers associate(ivt => patch%itype , & ! Input: [integer (:) ] p - leafcn => cnveg_nitrogenstate_inst%leafcn_patch , & ! Input: leaf C:N (gC/gN) + leafcn_t_evolving => cnveg_nitrogenstate_inst%leafcn_patch , & ! Input: leaf C:N (gC/gN) leafcn_offset => cnveg_state_inst%leafcn_offset_patch , & ! Output: ! [real(r8) (:) ] Leaf C:N used by FUN leafc_storage_xfer_acc => cnveg_carbonstate_inst%leafc_storage_xfer_acc_patch , & ! Output: [real(r8) (:) @@ -249,7 +249,7 @@ subroutine CNFUNInit (bounds,cnveg_state_inst,cnveg_carbonstate_inst,cnveg_nitro !--- numofyear = nstep/nstep_fun if (mod(nstep,nstep_fun) == 0) then - leafcn_offset(bounds%begp:bounds%endp) = leafcn(bounds%begp:bounds%endp) + leafcn_offset(bounds%begp:bounds%endp) = leafcn_t_evolving(bounds%begp:bounds%endp) storage_cdemand(bounds%begp:bounds%endp) = 0._r8 storage_ndemand(bounds%begp:bounds%endp) = 0._r8 leafn_storage_xfer_acc(bounds%begp:bounds%endp) = 0._r8 @@ -573,7 +573,7 @@ subroutine CNFUN(bounds,num_soilc, filter_soilc,num_soilp& !-------------------------------------------------------------------- !--------------------------------- associate(ivt => patch%itype , & ! Input: [integer (:) ] p - leafcn => cnveg_nitrogenstate_inst%leafcn_patch , & ! Input: leaf C:N (gC/gN) + leafcn_t_evolving => cnveg_nitrogenstate_inst%leafcn_patch , & ! Input: leaf C:N (gC/gN) season_decid => pftcon%season_decid , & ! Input: binary flag for seasonal ! -deciduous leaf habit (0 or 1) stress_decid => pftcon%stress_decid , & ! Input: binary flag for stress @@ -1276,7 +1276,7 @@ subroutine CNFUN(bounds,num_soilc, filter_soilc,num_soilp& litterfall_c_step(p,istp)* fixerfrac,& litterfall_n_step(p,istp)* fixerfrac,& total_n_resistance, total_c_spent_retrans,total_c_accounted_retrans, & - free_n_retrans,paid_for_n_retrans, leafcn(p), & + free_n_retrans,paid_for_n_retrans, leafcn_t_evolving(p), & grperc(ivt(p)), plantCN(p)) else @@ -1307,7 +1307,7 @@ subroutine CNFUN(bounds,num_soilc, filter_soilc,num_soilp& if (leafn(p) == 0.0_r8) then ! to avoid division by zero delta_CN = fun_cn_flex_c(ivt(p)) ! Max CN ratio over standard else - delta_CN = (leafc(p)+leafc_storage(p))/(leafn(p)+leafn_storage(p)) - leafcn(p) ! leaf CN ratio + delta_CN = (leafc(p)+leafc_storage(p))/(leafn(p)+leafn_storage(p)) - leafcn_t_evolving(p) ! leaf CN ratio end if ! C used for uptake is reduced if the cost of N is very high frac_ideal_C_use = max(0.0_r8,1.0_r8 - (total_N_resistance-fun_cn_flex_a(ivt(p)))/fun_cn_flex_b(ivt(p)) ) From 237d949696eadb399edc24b1cd5336f5eed08ee7 Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Fri, 21 Mar 2025 15:25:18 -0600 Subject: [PATCH 17/32] Apply use_cn to the new code in Photosynthesis and clm_driver --- src/biogeophys/PhotosynthesisMod.F90 | 29 ++++++++++++++++++++-------- src/main/clm_driver.F90 | 6 ++++-- 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/src/biogeophys/PhotosynthesisMod.F90 b/src/biogeophys/PhotosynthesisMod.F90 index 0467cff8a8..7ac94fa168 100644 --- a/src/biogeophys/PhotosynthesisMod.F90 +++ b/src/biogeophys/PhotosynthesisMod.F90 @@ -1355,6 +1355,7 @@ subroutine Photosynthesis ( bounds, fn, filterp, & real(r8) :: sum_nscaler real(r8) :: total_lai + real(r8) :: leafcn_local integer :: nptreemax real(r8) :: dtime ! land model time step (sec) @@ -1381,7 +1382,8 @@ subroutine Photosynthesis ( bounds, fn, filterp, & associate( & c3psn => pftcon%c3psn , & ! Input: photosynthetic pathway: 0. = c4, 1. = c3 crop => pftcon%crop , & ! Input: crop or not (0 =not crop and 1 = crop) - leafcn => cnveg_nitrogenstate_inst%leafcn_patch , & ! Input: leaf C:N (gC/gN) + leafcn_t_evolving => cnveg_nitrogenstate_inst%leafcn_patch, & ! Input: leaf C:N (gC/gN) + leafcn => pftcon%leafcn , & ! Input: leaf C:N (gC/gN) flnr => pftcon%flnr , & ! Input: fraction of leaf N in the Rubisco enzyme (gN Rubisco / gN leaf) fnitr => pftcon%fnitr , & ! Input: foliage nitrogen limitation factor (-) slatop => pftcon%slatop , & ! Input: specific leaf area at top of canopy, projected area basis [m^2/gC] @@ -1547,13 +1549,17 @@ subroutine Photosynthesis ( bounds, fn, filterp, & do f = 1, fn p = filterp(f) - if (lnc_opt .eqv. .false.) then + if (.not. lnc_opt) then ! Leaf nitrogen concentration at the top of the canopy (g N leaf / m**2 leaf) - - if ( (slatop(patch%itype(p)) * leafcn(p)) .le. 0.0_r8)then + if (use_cn) then + leafcn_local = leafcn_t_evolving(p) + else + leafcn_local = leafcn(ivt(p)) + end if + if ( (slatop(ivt(p)) * leafcn_local) <= 0.0_r8)then call endrun(subgrid_index=p, subgrid_level=subgrid_level_patch, msg="ERROR: slatop or leafcn is zero") end if - lnc(p) = 1._r8 / (slatop(patch%itype(p)) * leafcn(p)) + lnc(p) = 1._r8 / (slatop(ivt(p)) * leafcn_local) end if ! Using the actual nitrogen allocated to the leaf after @@ -2881,6 +2887,7 @@ subroutine PhotosynthesisHydraulicStress ( bounds, fn, filterp, & real(r8) , pointer :: o3coefg_sha (:) ! o3 coefficient used in rs calculation, shaded real(r8) :: sum_nscaler real(r8) :: total_lai + real(r8) :: leafcn_local integer :: nptreemax real(r8) :: dtime ! land model time step (sec) integer :: j,g ! index @@ -2942,7 +2949,8 @@ subroutine PhotosynthesisHydraulicStress ( bounds, fn, filterp, & tsai => canopystate_inst%tsai_patch , & ! Input: [real(r8) (:) ] patch canopy one-sided stem area index, no burying by snow c3psn => pftcon%c3psn , & ! Input: photosynthetic pathway: 0. = c4, 1. = c3 crop => pftcon%crop , & ! Input: crop or not (0 =not crop and 1 = crop) - leafcn => cnveg_nitrogenstate_inst%leafcn_patch , & ! Input: leaf C:N (gC/gN) + leafcn_t_evolving => cnveg_nitrogenstate_inst%leafcn_patch, & ! Input: leaf C:N (gC/gN) + leafcn => pftcon%leafcn , & ! Input: leaf C:N (gC/gN) flnr => pftcon%flnr , & ! Input: fraction of leaf N in the Rubisco enzyme (gN Rubisco / gN leaf) fnitr => pftcon%fnitr , & ! Input: foliage nitrogen limitation factor (-) slatop => pftcon%slatop , & ! Input: specific leaf area at top of canopy, projected area basis [m^2/gC] @@ -3162,9 +3170,14 @@ subroutine PhotosynthesisHydraulicStress ( bounds, fn, filterp, & do f = 1, fn p = filterp(f) - if (lnc_opt .eqv. .false.) then + if (.not. lnc_opt) then + if (use_cn) then + leafcn_local = leafcn_t_evolving(p) + else + leafcn_local = leafcn(ivt(p)) + end if ! Leaf nitrogen concentration at the top of the canopy (g N leaf / m**2 leaf) - lnc(p) = 1._r8 / (slatop(patch%itype(p)) * leafcn(p)) + lnc(p) = 1._r8 / (slatop(ivt(p)) * leafcn_local) end if ! Using the actual nitrogen allocated to the leaf after diff --git a/src/main/clm_driver.F90 b/src/main/clm_driver.F90 index b15abd0e6a..2e7cd24945 100644 --- a/src/main/clm_driver.F90 +++ b/src/main/clm_driver.F90 @@ -172,8 +172,10 @@ subroutine clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate, ro ! ------------------------------------------------- ! Obtain updated values of time-evolving parameters ! ------------------------------------------------- - call bgc_vegetation_inst%cnveg_nitrogenstate_inst%time_evolv_leafcn( & - bounds_proc, atm2lnd_inst) + if (use_cn) then + call bgc_vegetation_inst%cnveg_nitrogenstate_inst%time_evolv_leafcn( & + bounds_proc, atm2lnd_inst) + end if ! ======================================================================== ! In the first time step of a startup or hybrid run, we want to update CLM's glacier From 6da19db7d2817271d622d0a72ddf423bac815eca Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Fri, 21 Mar 2025 15:28:17 -0600 Subject: [PATCH 18/32] Remove the new variable from restart and update its initialization --- src/biogeochem/CNVegCarbonStateType.F90 | 1 - src/biogeochem/CNVegNitrogenStateType.F90 | 10 +++------- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/src/biogeochem/CNVegCarbonStateType.F90 b/src/biogeochem/CNVegCarbonStateType.F90 index 77c4a1015e..784983f54b 100644 --- a/src/biogeochem/CNVegCarbonStateType.F90 +++ b/src/biogeochem/CNVegCarbonStateType.F90 @@ -1794,7 +1794,6 @@ subroutine Restart ( this, bounds, ncid, flag, carbon_type, reseed_dead_plants, use shr_infnan_mod , only : isnan => shr_infnan_isnan, nan => shr_infnan_nan, assignment(=) use clm_varcon , only : c13ratio, c14ratio use clm_varctl , only : spinup_state, use_cndv, MM_Nuptake_opt - use clm_varctl , only : spinup_state, use_cndv, MM_Nuptake_opt use clm_time_manager , only : is_restart use landunit_varcon , only : istsoil, istcrop use spmdMod , only : mpicom diff --git a/src/biogeochem/CNVegNitrogenStateType.F90 b/src/biogeochem/CNVegNitrogenStateType.F90 index 39b87225ff..8ed51d63ad 100644 --- a/src/biogeochem/CNVegNitrogenStateType.F90 +++ b/src/biogeochem/CNVegNitrogenStateType.F90 @@ -836,11 +836,11 @@ subroutine InitCold(this, bounds, & do p = bounds%begp,bounds%endp + this%leafcn_patch(p) = pftcon%leafcn(patch%itype(p)) + l = patch%landunit(p) if (lun%itype(l) == istsoil .or. lun%itype(l) == istcrop) then - this%leafcn_patch(p) = pftcon%leafcn(patch%itype(p)) - if (patch%itype(p) == noveg) then this%leafn_patch(p) = 0._r8 this%leafn_storage_patch(p) = 0._r8 @@ -1649,10 +1649,6 @@ subroutine Restart ( this, bounds, ncid, flag, leafc_patch, & dim1name='pft', long_name='', units='', & interpinic_flag='interp', readvar=readvar, data=this%ntrunc_patch) - call restartvar(ncid=ncid, flag=flag, varname='LEAFCN_TARGET', xtype=ncd_double, & - dim1name='pft', long_name='Target leaf C:N; compare against leafC/leafN', units='gC/gN', & - interpinic_flag='interp', readvar=readvar, data=this%leafcn_patch) - if (use_crop) then do k = 1, nrepr data1dptr => this%reproductiven_patch(:,k) @@ -2333,7 +2329,7 @@ subroutine time_evolv_leafcn(this, bounds, atm2lnd_inst) !----------------------------------------------------------------------- if (is_first_step()) then - allocate(this%leafcn_patch(bounds%begp:bounds%endp)); this%leafcn_patch(:) = nan + allocate(this%leafcn_patch(bounds%begp:bounds%endp)); this%leafcn_patch(:) = pftcon%leafcn(patch%itype(:)) end if ! Loop to get leafcn_col do p = bounds%begp, bounds%endp From cb1880a4ba6c1290a8a274ad5b8d70d6cb5a91d6 Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Mon, 24 Mar 2025 10:43:10 -0600 Subject: [PATCH 19/32] Code change to address izumi failures --- src/biogeophys/PhotosynthesisMod.F90 | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/biogeophys/PhotosynthesisMod.F90 b/src/biogeophys/PhotosynthesisMod.F90 index 7ac94fa168..d46c7dadd5 100644 --- a/src/biogeophys/PhotosynthesisMod.F90 +++ b/src/biogeophys/PhotosynthesisMod.F90 @@ -1382,7 +1382,6 @@ subroutine Photosynthesis ( bounds, fn, filterp, & associate( & c3psn => pftcon%c3psn , & ! Input: photosynthetic pathway: 0. = c4, 1. = c3 crop => pftcon%crop , & ! Input: crop or not (0 =not crop and 1 = crop) - leafcn_t_evolving => cnveg_nitrogenstate_inst%leafcn_patch, & ! Input: leaf C:N (gC/gN) leafcn => pftcon%leafcn , & ! Input: leaf C:N (gC/gN) flnr => pftcon%flnr , & ! Input: fraction of leaf N in the Rubisco enzyme (gN Rubisco / gN leaf) fnitr => pftcon%fnitr , & ! Input: foliage nitrogen limitation factor (-) @@ -1552,7 +1551,7 @@ subroutine Photosynthesis ( bounds, fn, filterp, & if (.not. lnc_opt) then ! Leaf nitrogen concentration at the top of the canopy (g N leaf / m**2 leaf) if (use_cn) then - leafcn_local = leafcn_t_evolving(p) + leafcn_local = cnveg_nitrogenstate_inst%leafcn_patch(p) else leafcn_local = leafcn(ivt(p)) end if @@ -2949,7 +2948,6 @@ subroutine PhotosynthesisHydraulicStress ( bounds, fn, filterp, & tsai => canopystate_inst%tsai_patch , & ! Input: [real(r8) (:) ] patch canopy one-sided stem area index, no burying by snow c3psn => pftcon%c3psn , & ! Input: photosynthetic pathway: 0. = c4, 1. = c3 crop => pftcon%crop , & ! Input: crop or not (0 =not crop and 1 = crop) - leafcn_t_evolving => cnveg_nitrogenstate_inst%leafcn_patch, & ! Input: leaf C:N (gC/gN) leafcn => pftcon%leafcn , & ! Input: leaf C:N (gC/gN) flnr => pftcon%flnr , & ! Input: fraction of leaf N in the Rubisco enzyme (gN Rubisco / gN leaf) fnitr => pftcon%fnitr , & ! Input: foliage nitrogen limitation factor (-) @@ -3172,7 +3170,7 @@ subroutine PhotosynthesisHydraulicStress ( bounds, fn, filterp, & if (.not. lnc_opt) then if (use_cn) then - leafcn_local = leafcn_t_evolving(p) + leafcn_local = cnveg_nitrogenstate_inst%leafcn_patch(p) else leafcn_local = leafcn(ivt(p)) end if From 430b5b13c31a03ffd2c763e859e72d7d09f042d6 Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Mon, 24 Mar 2025 11:19:00 -0600 Subject: [PATCH 20/32] Code change to address FUNIT failure on derecho --- .../test/CNVegComputeSeed_test/test_ComputeSeedAmounts.pf | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/biogeochem/test/CNVegComputeSeed_test/test_ComputeSeedAmounts.pf b/src/biogeochem/test/CNVegComputeSeed_test/test_ComputeSeedAmounts.pf index be87b4c989..076b358bd5 100644 --- a/src/biogeochem/test/CNVegComputeSeed_test/test_ComputeSeedAmounts.pf +++ b/src/biogeochem/test/CNVegComputeSeed_test/test_ComputeSeedAmounts.pf @@ -92,6 +92,7 @@ contains real(r8), intent(out), optional :: seed_leaf_xfer real(r8), intent(out), optional :: seed_deadstem + real(r8) :: leafcn_patch(bounds%begp:bounds%endp) real(r8) :: leaf_patch(bounds%begp:bounds%endp) real(r8) :: leaf_storage_patch(bounds%begp:bounds%endp) real(r8) :: leaf_xfer_patch(bounds%begp:bounds%endp) @@ -102,6 +103,7 @@ contains real(r8) :: seed_leaf_xfer_patch(bounds%begp:bounds%endp) real(r8) :: seed_deadstem_patch(bounds%begp:bounds%endp) + leafcn_patch(:) = 10._r8 leaf_patch(:) = 0._r8 leaf_patch(POI) = LEAF_POI leaf_storage_patch(:) = 0._r8 @@ -117,6 +119,7 @@ contains call ComputeSeedAmounts(bounds, & this%numf, this%filter, & + leafcn_patch = leafcn_patch, & species = species, & leafc_seed = LEAFC_SEED, & deadstemc_seed = DEADSTEMC_SEED, & From 1503e17d4254efa6aa7e458cd5d670bc07a0465b Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Mon, 24 Mar 2025 16:51:25 -0600 Subject: [PATCH 21/32] Read params leafcn_co2_base and leafcn_co2_slope from the paramfile --- src/biogeochem/CNVegNitrogenStateType.F90 | 49 ++++++++++++++++++----- src/biogeochem/CNVegetationFacade.F90 | 2 +- 2 files changed, 39 insertions(+), 12 deletions(-) diff --git a/src/biogeochem/CNVegNitrogenStateType.F90 b/src/biogeochem/CNVegNitrogenStateType.F90 index 8ed51d63ad..ffa4784075 100644 --- a/src/biogeochem/CNVegNitrogenStateType.F90 +++ b/src/biogeochem/CNVegNitrogenStateType.F90 @@ -21,14 +21,20 @@ module CNVegNitrogenStateType use CNSpeciesMod , only : CN_SPECIES_N use CNVegComputeSeedMod, only : ComputeSeedAmounts use CropReprPoolsMod , only : nrepr, get_repr_hist_fname, get_repr_rest_fname, get_repr_longname + use ncdio_pio ! ! !PUBLIC TYPES: implicit none private - + type :: cnveg_nstate_params_type + real(r8) :: leafcn_co2_base ! ppm CO2 for target leaf CN scaling + real(r8) :: leafcn_co2_slope ! CO2 effects on target leaf CN scaling (unitless) + end type cnveg_nstate_params_type ! + type(cnveg_nstate_params_type), public, protected :: params_inst ! params_inst is populated in readParams + type, public :: cnveg_nitrogenstate_type real(r8), pointer :: leafcn_patch (:) ! patch leafcn @@ -220,6 +226,7 @@ module CNVegNitrogenStateType procedure , private :: InitAllocate procedure , private :: InitHistory procedure , private :: InitCold + procedure , private :: ReadParams procedure , public :: time_evolv_leafcn ! updates time-evolving leafcn end type cnveg_nitrogenstate_type @@ -234,10 +241,11 @@ module CNVegNitrogenStateType !------------------------------------------------------------------------ subroutine Init(this, bounds, & leafc_patch, leafc_storage_patch, frootc_patch, frootc_storage_patch, & - deadstemc_patch, alloc_full_veg) + deadstemc_patch, alloc_full_veg, params_ncid) class(cnveg_nitrogenstate_type) :: this type(bounds_type) , intent(in) :: bounds + type(file_desc_t) , intent(inout) :: params_ncid ! pio netCDF file id real(r8) , intent(in) :: leafc_patch (:) !(begp:) real(r8) , intent(in) :: leafc_storage_patch (:) !(begp:) real(r8) , intent(in) :: frootc_patch (:) !(begp:) @@ -251,6 +259,7 @@ subroutine Init(this, bounds, & call this%InitCold ( bounds, & leafc_patch, leafc_storage_patch, frootc_patch, frootc_storage_patch, deadstemc_patch) end if + call this%ReadParams( params_ncid ) end subroutine Init !------------------------------------------------------------------------ @@ -1118,7 +1127,6 @@ subroutine Restart ( this, bounds, ncid, flag, leafc_patch, & ! ! !USES: use restUtilMod - use ncdio_pio use clm_varctl , only : spinup_state, use_cndv use clm_time_manager , only : get_nstep, is_restart use clm_varctl , only : MM_Nuptake_opt @@ -2296,6 +2304,32 @@ subroutine Summary_nitrogenstate(this, bounds, num_soilc, filter_soilc, num_soil end subroutine Summary_nitrogenstate + !----------------------------------------------------------------------- + subroutine ReadParams ( this, ncid ) + ! + ! !USES: + use paramUtilMod, only: readNcdioScalar + + implicit none + + ! !ARGUMENTS: + class(cnveg_nitrogenstate_type) :: this + type(file_desc_t), intent(inout) :: ncid ! pio netCDF file id + ! + ! !LOCAL VARIABLES: + !----------------------------------------------------------------------- + + ! read in parameters + + ! read in the scalar parameters + + ! ppm CO2 for target leaf CN scaling (ppmv) + call readNcdioScalar(ncid, 'leafcn_co2_base', sourcefile, params_inst%leafcn_co2_base) + ! CO2 effects on target leaf CN scaling (unitless) + call readNcdioScalar(ncid, 'leafcn_co2_slope', sourcefile, params_inst%leafcn_co2_slope) + + end subroutine ReadParams + !----------------------------------------------------------------------- subroutine time_evolv_leafcn(this, bounds, atm2lnd_inst) ! @@ -2321,11 +2355,6 @@ subroutine time_evolv_leafcn(this, bounds, atm2lnd_inst) ! !LOCAL VARIABLES: integer :: g, l, c, p ! indices real(r8) :: co2_ppmv ! atm co2 concentration - ! Could use 355 value from clm_varctl.F90 to avoid this hardwiring? - real(r8), parameter :: co2_base = 310._r8 ! units ppmv - real(r8), parameter :: cn_slope = 0._r8 - - character(len=*), parameter :: subname = 'time_evolv_leafcn' !----------------------------------------------------------------------- if (is_first_step()) then @@ -2340,7 +2369,7 @@ subroutine time_evolv_leafcn(this, bounds, atm2lnd_inst) co2_ppmv = 1.e6_r8 * atm2lnd_inst%forc_pco2_grc(g) / & atm2lnd_inst%forc_pbot_downscaled_col(c) this%leafcn_patch(p) = pftcon%leafcn(patch%itype(p)) + & - max(cn_slope * log(co2_ppmv / co2_base), 0._r8) + max(params_inst%leafcn_co2_slope * log(co2_ppmv / params_inst%leafcn_co2_base), 0._r8) end if end do @@ -2393,8 +2422,6 @@ subroutine DynamicPatchAdjustments(this, bounds, & real(r8) :: seed_leafn_storage_patch(bounds%begp:bounds%endp) real(r8) :: seed_leafn_xfer_patch(bounds%begp:bounds%endp) real(r8) :: seed_deadstemn_patch(bounds%begp:bounds%endp) - - character(len=*), parameter :: subname = 'DynamicPatchAdjustments' !----------------------------------------------------------------------- begp = bounds%begp diff --git a/src/biogeochem/CNVegetationFacade.F90 b/src/biogeochem/CNVegetationFacade.F90 index dd20ce50a2..47099708f4 100644 --- a/src/biogeochem/CNVegetationFacade.F90 +++ b/src/biogeochem/CNVegetationFacade.F90 @@ -282,7 +282,7 @@ subroutine Init(this, bounds, NLFilename, nskip_steps, params_ncid) this%cnveg_carbonstate_inst%frootc_patch(begp:endp), & this%cnveg_carbonstate_inst%frootc_storage_patch(begp:endp), & this%cnveg_carbonstate_inst%deadstemc_patch(begp:endp), & - alloc_full_veg=alloc_full_veg) + alloc_full_veg=alloc_full_veg, params_ncid=params_ncid) call this%cnveg_nitrogenflux_inst%Init(bounds,alloc_full_veg=alloc_full_veg) call this%c_products_inst%Init(bounds, species_non_isotope_type('C')) From 287fea89abafe83b35dc30be54b98fb2f2bc383b Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Wed, 26 Mar 2025 11:31:37 -0600 Subject: [PATCH 22/32] Rename leafcn to leafcn_t_evolving where appropriate and add comments --- src/biogeochem/CNPhenologyMod.F90 | 20 +++++++++---------- src/biogeochem/CNVegCarbonStateType.F90 | 6 +++--- src/biogeochem/CNVegComputeSeedMod.F90 | 6 +++--- src/biogeochem/CNVegNitrogenStateType.F90 | 4 ++-- .../NutrientCompetitionCLM45defaultMod.F90 | 8 ++++---- .../NutrientCompetitionFlexibleCNMod.F90 | 18 ++++++++--------- src/biogeochem/dynConsBiogeochemMod.F90 | 6 +++--- .../test_ComputeSeedAmounts.pf | 2 +- src/biogeophys/PhotosynthesisMod.F90 | 8 ++++---- src/main/clm_driver.F90 | 3 +++ 10 files changed, 42 insertions(+), 39 deletions(-) diff --git a/src/biogeochem/CNPhenologyMod.F90 b/src/biogeochem/CNPhenologyMod.F90 index 21b3e78645..a06ce11d57 100644 --- a/src/biogeochem/CNPhenologyMod.F90 +++ b/src/biogeochem/CNPhenologyMod.F90 @@ -2075,7 +2075,7 @@ subroutine CropPhenology(num_pcropp, filter_pcropp , & ivt => patch%itype , & ! Input: [integer (:) ] patch vegetation type leaf_long => pftcon%leaf_long , & ! Input: leaf longevity (yrs) - leafcn => cnveg_nitrogenstate_inst%leafcn_patch , & ! Input: leaf C:N (gC/gN) + leafcn_t_evolving => cnveg_nitrogenstate_inst%leafcn_patch , & ! Input: leaf C:N (gC/gN) manunitro => pftcon%manunitro , & ! Input: max manure to be applied in total (kgN/m2) minplanttemp => pftcon%minplanttemp , & ! Input: planttemp => pftcon%planttemp , & ! Input: @@ -2301,7 +2301,7 @@ subroutine CropPhenology(num_pcropp, filter_pcropp , & vf(p) = 0._r8 end if - call PlantCrop(p, leafcn(p), jday, kyr, do_plant_normal, & + call PlantCrop(p, leafcn_t_evolving(p), jday, kyr, do_plant_normal, & do_plant_lastchance, do_plant_prescribed, & temperature_inst, crop_inst, cnveg_state_inst, & cnveg_carbonstate_inst, cnveg_nitrogenstate_inst, & @@ -2562,7 +2562,7 @@ subroutine CropPhenology(num_pcropp, filter_pcropp , & crop_seedc_to_leaf(p) = crop_seedc_to_leaf(p) - leafc_xfer(p)/dt crop_seedn_to_leaf(p) = crop_seedn_to_leaf(p) - leafn_xfer(p)/dt leafc_xfer(p) = 0._r8 - leafn_xfer(p) = leafc_xfer(p) / leafcn(p) + leafn_xfer(p) = leafc_xfer(p) / leafcn_t_evolving(p) if (use_c13) then c13_cnveg_carbonstate_inst%leafc_xfer_patch(p) = 0._r8 endif @@ -2602,7 +2602,7 @@ subroutine CropPhenology(num_pcropp, filter_pcropp , & crop_seedn_to_leaf(p) = crop_seedn_to_leaf(p) - leafn_xfer(p)/dt onset_counter(p) = 0._r8 leafc_xfer(p) = 0._r8 - leafn_xfer(p) = leafc_xfer(p) / leafcn(p) + leafn_xfer(p) = leafc_xfer(p) / leafcn_t_evolving(p) if (use_c13) then c13_cnveg_carbonstate_inst%leafc_xfer_patch(p) = 0._r8 endif @@ -3388,7 +3388,7 @@ subroutine CNOffsetLitterfall (num_soilp, filter_soilp, & associate( & ivt => patch%itype , & ! Input: [integer (:) ] patch vegetation type - leafcn => cnveg_nitrogenstate_inst%leafcn_patch , & ! Input: leaf C:N (gC/gN) + leafcn_t_evolving => cnveg_nitrogenstate_inst%leafcn_patch , & ! Input: leaf C:N (gC/gN) biofuel_harvfrac => pftcon%biofuel_harvfrac , & ! Input: cut a fraction of leaf & stem for biofuel (-) repr_structure_harvfrac => pftcon%repr_structure_harvfrac , & ! Input: fraction of each reproductive structure component that is harvested and sent to the crop products pool @@ -3740,7 +3740,7 @@ subroutine CNOffsetLitterfall (num_soilp, filter_soilp, & leafcn_offset(p) = leafc(p)/leafn(p) end if else - leafcn_offset(p) = leafcn(p) + leafcn_offset(p) = leafcn_t_evolving(p) end if leafn_to_litter(p) = leafc_to_litter(p)/leafcn_offset(p) - leafn_to_retransn(p) leafn_to_litter(p) = max(leafn_to_litter(p),0._r8) @@ -3772,7 +3772,7 @@ subroutine CNOffsetLitterfall (num_soilp, filter_soilp, & end if ! calculate the leaf N litterfall and retranslocation leafn_to_litter(p) = leafc_to_litter(p) / lflitcn(ivt(p)) - leafn_to_retransn(p) = (leafc_to_litter(p) / leafcn(p)) - leafn_to_litter(p) + leafn_to_retransn(p) = (leafc_to_litter(p) / leafcn_t_evolving(p)) - leafn_to_litter(p) if (use_matrixcn) then if(leafn(p) .gt. 0)then @@ -3888,7 +3888,7 @@ subroutine CNBackgroundLitterfall (num_soilp, filter_soilp, & associate( & ivt => patch%itype , & ! Input: [integer (:) ] patch vegetation type - leafcn => cnveg_nitrogenstate_inst%leafcn_patch , & ! Input: leaf C:N (gC/gN) + leafcn_t_evolving => cnveg_nitrogenstate_inst%leafcn_patch , & ! Input: leaf C:N (gC/gN) lflitcn => pftcon%lflitcn , & ! Input: leaf litter C:N (gC/gN) frootcn => pftcon%frootcn , & ! Input: fine root C:N (gC/gN) @@ -3974,7 +3974,7 @@ subroutine CNBackgroundLitterfall (num_soilp, filter_soilp, & leafcn_offset(p) = leafc(p)/leafn(p) end if else - leafcn_offset(p) = leafcn(p) + leafcn_offset(p) = leafcn_t_evolving(p) end if leafn_to_litter(p) = leafc_to_litter(p)/leafcn_offset(p) - leafn_to_retransn(p) leafn_to_litter(p) = max(leafn_to_litter(p),0._r8) @@ -4003,7 +4003,7 @@ subroutine CNBackgroundLitterfall (num_soilp, filter_soilp, & end if ! calculate the leaf N litterfall and retranslocation leafn_to_litter(p) = leafc_to_litter(p) / lflitcn(ivt(p)) - leafn_to_retransn(p) = (leafc_to_litter(p) / leafcn(p)) - leafn_to_litter(p) + leafn_to_retransn(p) = (leafc_to_litter(p) / leafcn_t_evolving(p)) - leafn_to_litter(p) if (use_matrixcn) then if(leafn(p) .ne. 0)then diff --git a/src/biogeochem/CNVegCarbonStateType.F90 b/src/biogeochem/CNVegCarbonStateType.F90 index 784983f54b..142578e656 100644 --- a/src/biogeochem/CNVegCarbonStateType.F90 +++ b/src/biogeochem/CNVegCarbonStateType.F90 @@ -4636,7 +4636,7 @@ subroutine DynamicPatchAdjustments(this, bounds, & num_soilp_with_inactive, filter_soilp_with_inactive, & patch_state_updater, & leafc_seed, deadstemc_seed, & - leafcn_patch, & + leafcn_t_evolving, & conv_cflux, wood_product_cflux, crop_product_cflux, & dwt_frootc_to_litter, & dwt_livecrootc_to_litter, & @@ -4658,7 +4658,7 @@ subroutine DynamicPatchAdjustments(this, bounds, & type(patch_state_updater_type) , intent(in) :: patch_state_updater real(r8) , intent(in) :: leafc_seed ! seed amount for leaf C real(r8) , intent(in) :: deadstemc_seed ! seed amount for deadstem C - real(r8) , intent(in) :: leafcn_patch( bounds%begp: ) ! current leaf C:N (gC/gN) + real(r8) , intent(in) :: leafcn_t_evolving( bounds%begp: ) ! current leaf C:N (gC/gN) real(r8) , intent(inout) :: conv_cflux( bounds%begp: ) ! patch-level conversion C flux to atm (expressed per unit GRIDCELL area) real(r8) , intent(inout) :: wood_product_cflux( bounds%begp: ) ! patch-level product C flux (expressed per unit GRIDCELL area) real(r8) , intent(inout) :: crop_product_cflux( bounds%begp: ) ! patch-level crop product C flux (expressed per unit GRIDCELL area) @@ -4701,7 +4701,7 @@ subroutine DynamicPatchAdjustments(this, bounds, & call ComputeSeedAmounts(bounds, & num_soilp_with_inactive, filter_soilp_with_inactive, & - leafcn_patch = leafcn_patch(begp:endp), & + leafcn_t_evolving = leafcn_t_evolving(begp:endp), & species = this%species, & leafc_seed = leafc_seed, & deadstemc_seed = deadstemc_seed, & diff --git a/src/biogeochem/CNVegComputeSeedMod.F90 b/src/biogeochem/CNVegComputeSeedMod.F90 index 6735b01bef..760c2fc767 100644 --- a/src/biogeochem/CNVegComputeSeedMod.F90 +++ b/src/biogeochem/CNVegComputeSeedMod.F90 @@ -39,7 +39,7 @@ module CNVegComputeSeedMod !----------------------------------------------------------------------- subroutine ComputeSeedAmounts(bounds, & num_soilp_with_inactive, filter_soilp_with_inactive, & - leafcn_patch, & + leafcn_t_evolving, & species, & leafc_seed, deadstemc_seed, & leaf_patch, leaf_storage_patch, leaf_xfer_patch, & @@ -67,7 +67,7 @@ subroutine ComputeSeedAmounts(bounds, & integer , intent(in) :: species ! which C/N species we're operating on; should be one of the values in CNSpeciesMod real(r8) , intent(in) :: leafc_seed ! seed amount for leaf C real(r8) , intent(in) :: deadstemc_seed ! seed amount for deadstem C - real(r8) , intent(in) :: leafcn_patch( bounds%begp: ) ! current leaf C:N (gC/gN) + real(r8) , intent(in) :: leafcn_t_evolving( bounds%begp: ) ! current leaf C:N (gC/gN) real(r8) , intent(in) :: leaf_patch( bounds%begp: ) ! current leaf C or N content (g/m2) real(r8) , intent(in) :: leaf_storage_patch( bounds%begp: ) ! current leaf C or N storage content (g/m2) real(r8) , intent(in) :: leaf_xfer_patch( bounds%begp: ) ! current leaf C or N xfer content (g/m2) @@ -121,7 +121,7 @@ subroutine ComputeSeedAmounts(bounds, & my_deadstem_seed = 0._r8 pft_type = patch%itype(p) - leafcn = leafcn_patch(p) + leafcn = leafcn_t_evolving(p) call LeafProportions( & ignore_current_state = ignore_current_state_patch(p), & diff --git a/src/biogeochem/CNVegNitrogenStateType.F90 b/src/biogeochem/CNVegNitrogenStateType.F90 index ffa4784075..42759c09e6 100644 --- a/src/biogeochem/CNVegNitrogenStateType.F90 +++ b/src/biogeochem/CNVegNitrogenStateType.F90 @@ -37,7 +37,7 @@ module CNVegNitrogenStateType type, public :: cnveg_nitrogenstate_type - real(r8), pointer :: leafcn_patch (:) ! patch leafcn + real(r8), pointer :: leafcn_patch(:) ! time evolving leafcn calculated in subroutine time_evolv_leafcn from co2_ppmv and three paramfile parameters; of the three parameters, leafcn_co2_slope is set to 0 (as of ctsm5.4) so leafcn_patch defaults to the values of paramfile parameter leafcn real(r8), pointer :: reproductiven_patch (:,:) ! (gN/m2) reproductive (e.g., grain) N (crop) real(r8), pointer :: reproductiven_storage_patch (:,:) ! (gN/m2) reproductive (e.g., grain) N storage (crop) real(r8), pointer :: reproductiven_xfer_patch (:,:) ! (gN/m2) reproductive (e.g., grain) N transfer (crop) @@ -2441,7 +2441,7 @@ subroutine DynamicPatchAdjustments(this, bounds, & call ComputeSeedAmounts(bounds, & num_soilp_with_inactive, filter_soilp_with_inactive, & - leafcn_patch = this%leafcn_patch(begp:endp), & + leafcn_t_evolving = this%leafcn_patch(begp:endp), & species = CN_SPECIES_N, & leafc_seed = leafc_seed, & deadstemc_seed = deadstemc_seed, & diff --git a/src/biogeochem/NutrientCompetitionCLM45defaultMod.F90 b/src/biogeochem/NutrientCompetitionCLM45defaultMod.F90 index 3df5b25edb..2fb618356c 100644 --- a/src/biogeochem/NutrientCompetitionCLM45defaultMod.F90 +++ b/src/biogeochem/NutrientCompetitionCLM45defaultMod.F90 @@ -178,7 +178,7 @@ subroutine calc_plant_cn_alloc (this, bounds, num_soilp, filter_soilp, & croot_stem => pftcon%croot_stem , & ! Input: allocation parameter: new coarse root C per new stem C (gC/gC) stem_leaf => pftcon%stem_leaf , & ! Input: allocation parameter: new stem c per new leaf C (gC/gC) flivewd => pftcon%flivewd , & ! Input: allocation parameter: fraction of new wood that is live (phloem and ray parenchyma) (no units) - leafcn => cnveg_nitrogenstate_inst%leafcn_patch , & ! Input: leaf C:N (gC/gN) + leafcn_t_evolving => cnveg_nitrogenstate_inst%leafcn_patch , & ! Input: leaf C:N (gC/gN) frootcn => pftcon%frootcn , & ! Input: fine root C:N (gC/gN) livewdcn => pftcon%livewdcn , & ! Input: live wood (phloem and ray parenchyma) C:N (gC/gN) deadwdcn => pftcon%deadwdcn , & ! Input: dead wood (xylem and heartwood) C:N (gC/gN) @@ -275,7 +275,7 @@ subroutine calc_plant_cn_alloc (this, bounds, num_soilp, filter_soilp, & f4 = flivewd(ivt(p)) g1 = grperc(ivt(p)) g2 = grpnow(ivt(p)) - cnl = leafcn(p) + cnl = leafcn_t_evolving(p) cnfr = frootcn(ivt(p)) cnlw = livewdcn(ivt(p)) cndw = deadwdcn(ivt(p)) @@ -551,7 +551,7 @@ subroutine calc_plant_nitrogen_demand(this, bounds, & associate( & ivt => patch%itype , & ! Input: [integer (:) ] patch vegetation type - leafcn => cnveg_nitrogenstate_inst%leafcn_patch , & ! Input: leaf C:N (gC/gN) + leafcn_t_evolving => cnveg_nitrogenstate_inst%leafcn_patch , & ! Input: leaf C:N (gC/gN) frootcn => pftcon%frootcn , & ! Input: fine root C:N (gC/gN) livewdcn => pftcon%livewdcn , & ! Input: live wood (phloem and ray parenchyma) C:N (gC/gN) graincn => pftcon%graincn , & ! Input: grain C:N (gC/gN) @@ -644,7 +644,7 @@ subroutine calc_plant_nitrogen_demand(this, bounds, & if (grain_flag(p) == 0._r8)then if(.not.use_fun) then t1 = 1 / dt - leafn_to_retransn(p) = t1 * ((leafc(p) / leafcn(p)) - (leafc(p) / & + leafn_to_retransn(p) = t1 * ((leafc(p) / leafcn_t_evolving(p)) - (leafc(p) / & fleafcn(ivt(p)))) livestemn_to_retransn(p) = t1 * ((livestemc(p) / livewdcn(ivt(p))) - (livestemc(p) / & fstemcn(ivt(p)))) diff --git a/src/biogeochem/NutrientCompetitionFlexibleCNMod.F90 b/src/biogeochem/NutrientCompetitionFlexibleCNMod.F90 index 421b3100a0..491813b600 100644 --- a/src/biogeochem/NutrientCompetitionFlexibleCNMod.F90 +++ b/src/biogeochem/NutrientCompetitionFlexibleCNMod.F90 @@ -275,7 +275,7 @@ subroutine calc_plant_cn_alloc(this, bounds, num_soilp, filter_soilp, & croot_stem => pftcon%croot_stem , & ! Input: allocation parameter: new coarse root C per new stem C (gC/gC) stem_leaf => pftcon%stem_leaf , & ! Input: allocation parameter: new stem c per new leaf C (gC/gC) flivewd => pftcon%flivewd , & ! Input: allocation parameter: fraction of new wood that is live (phloem and ray parenchyma) (no units) - leafcn => cnveg_nitrogenstate_inst%leafcn_patch , & ! Input: leaf C:N (gC/gN) + leafcn_t_evolving => cnveg_nitrogenstate_inst%leafcn_patch , & ! Input: leaf C:N (gC/gN) frootcn => pftcon%frootcn , & ! Input: fine root C:N (gC/gN) livewdcn => pftcon%livewdcn , & ! Input: live wood (phloem and ray parenchyma) C:N (gC/gN) fcur2 => pftcon%fcur , & ! Input: allocation parameter: fraction of allocation that goes to currently displayed growth, remainder to storage @@ -635,7 +635,7 @@ subroutine calc_plant_cn_alloc(this, bounds, num_soilp, filter_soilp, & f3 = f3, & f4 = f4, & f5 = f5, & - leafcn = leafcn(p), & + leafcn_t_evolving = leafcn_t_evolving(p), & ! Outputs npool_to_leafn = npool_to_leafn(p), & @@ -729,7 +729,7 @@ subroutine calc_plant_cn_alloc(this, bounds, num_soilp, filter_soilp, & end if end if - leafcn_max = leafcn(p) + 15.0_r8 + leafcn_max = leafcn_t_evolving(p) + 15.0_r8 frootcn_max = frootcn(ivt(p)) + 15.0_r8 ! Note that for high CN ratio stress the plant part does not retranslocate nitrogen as the plant part will need the N @@ -931,7 +931,7 @@ end subroutine calc_plant_cn_alloc !----------------------------------------------------------------------- subroutine calc_npool_to_components_flexiblecn( & - npool, ivt, nlc, fcur, f1, f2, f3, f4, f5, leafcn, & + npool, ivt, nlc, fcur, f1, f2, f3, f4, f5, leafcn_t_evolving, & npool_to_leafn, npool_to_leafn_storage, & npool_to_frootn, npool_to_frootn_storage, & npool_to_livestemn, npool_to_livestemn_storage, & @@ -953,7 +953,7 @@ subroutine calc_npool_to_components_flexiblecn( & real(r8), intent(in) :: f3 ! C allocation parameter - stem:leaf ratio real(r8), intent(in) :: f4 ! C allocation parameter - fraction of new wood that is live real(r8), intent(in) :: f5(:) ! C allocation parameter - repr:leaf ratio for each crop reproductive pool - real(r8), intent(in) :: leafcn ! leaf C:N (gC/gN) + real(r8), intent(in) :: leafcn_t_evolving ! leaf C:N (gC/gN) ! Each of the following output variables is in units of gN/m2/s; they are ! intent(inout) because some may remain unchanged in some circumstances. @@ -1028,7 +1028,7 @@ subroutine calc_npool_to_components_flexiblecn( & dt = get_step_size_real() - cnl = leafcn + cnl = leafcn_t_evolving cnfr = frootcn(ivt) cnlw = livewdcn(ivt) cndw = deadwdcn(ivt) @@ -1456,7 +1456,7 @@ subroutine calc_plant_nitrogen_demand(this, bounds, & associate( & ivt => patch%itype , & ! Input: [integer (:) ] patch vegetation type - leafcn => cnveg_nitrogenstate_inst%leafcn_patch , & ! Input: leaf C:N (gC/gN) + leafcn_t_evolving => cnveg_nitrogenstate_inst%leafcn_patch , & ! Input: leaf C:N (gC/gN) fleafcn => pftcon%fleafcn , & ! Input: leaf c:n during organ fill ffrootcn => pftcon%ffrootcn , & ! Input: froot c:n during organ fill fstemcn => pftcon%fstemcn , & ! Input: stem c:n during organ fill @@ -1521,8 +1521,8 @@ subroutine calc_plant_nitrogen_demand(this, bounds, & this%actual_leafcn(p) = leafc(p) / leafn(p) end if - leafcn_min = leafcn(p) - 10.0_r8 - leafcn_max = leafcn(p) + 10.0_r8 + leafcn_min = leafcn_t_evolving(p) - 10.0_r8 + leafcn_max = leafcn_t_evolving(p) + 10.0_r8 this%actual_leafcn(p) = max( this%actual_leafcn(p), leafcn_min-0.0001_r8 ) this%actual_leafcn(p) = min( this%actual_leafcn(p), leafcn_max ) diff --git a/src/biogeochem/dynConsBiogeochemMod.F90 b/src/biogeochem/dynConsBiogeochemMod.F90 index ca46f4f79a..a96807d702 100644 --- a/src/biogeochem/dynConsBiogeochemMod.F90 +++ b/src/biogeochem/dynConsBiogeochemMod.F90 @@ -445,7 +445,7 @@ subroutine dyn_cnbal_patch(bounds, & patch_state_updater, & leafc_seed = leafc_seed, & deadstemc_seed = deadstemc_seed, & - leafcn_patch = cnveg_nitrogenstate_inst%leafcn_patch(begp:endp), & + leafcn_t_evolving = cnveg_nitrogenstate_inst%leafcn_patch(begp:endp), & conv_cflux = conv_cflux(begp:endp), & wood_product_cflux = wood_product_cflux(begp:endp), & crop_product_cflux = crop_product_cflux(begp:endp), & @@ -469,7 +469,7 @@ subroutine dyn_cnbal_patch(bounds, & patch_state_updater, & leafc_seed = leafc_seed, & deadstemc_seed = deadstemc_seed, & - leafcn_patch = cnveg_nitrogenstate_inst%leafcn_patch(begp:endp), & + leafcn_t_evolving = cnveg_nitrogenstate_inst%leafcn_patch(begp:endp), & conv_cflux = conv_c13flux(begp:endp), & wood_product_cflux = wood_product_c13flux(begp:endp), & crop_product_cflux = crop_product_c13flux(begp:endp), & @@ -495,7 +495,7 @@ subroutine dyn_cnbal_patch(bounds, & patch_state_updater, & leafc_seed = leafc_seed, & deadstemc_seed = deadstemc_seed, & - leafcn_patch = cnveg_nitrogenstate_inst%leafcn_patch(begp:endp), & + leafcn_t_evolving = cnveg_nitrogenstate_inst%leafcn_patch(begp:endp), & conv_cflux = conv_c14flux(begp:endp), & wood_product_cflux = wood_product_c14flux(begp:endp), & crop_product_cflux = crop_product_c14flux(begp:endp), & diff --git a/src/biogeochem/test/CNVegComputeSeed_test/test_ComputeSeedAmounts.pf b/src/biogeochem/test/CNVegComputeSeed_test/test_ComputeSeedAmounts.pf index 076b358bd5..49593a197e 100644 --- a/src/biogeochem/test/CNVegComputeSeed_test/test_ComputeSeedAmounts.pf +++ b/src/biogeochem/test/CNVegComputeSeed_test/test_ComputeSeedAmounts.pf @@ -119,7 +119,7 @@ contains call ComputeSeedAmounts(bounds, & this%numf, this%filter, & - leafcn_patch = leafcn_patch, & + leafcn_t_evolving = leafcn_patch, & species = species, & leafc_seed = LEAFC_SEED, & deadstemc_seed = DEADSTEMC_SEED, & diff --git a/src/biogeophys/PhotosynthesisMod.F90 b/src/biogeophys/PhotosynthesisMod.F90 index d46c7dadd5..80e4c62e97 100644 --- a/src/biogeophys/PhotosynthesisMod.F90 +++ b/src/biogeophys/PhotosynthesisMod.F90 @@ -1550,9 +1550,9 @@ subroutine Photosynthesis ( bounds, fn, filterp, & if (.not. lnc_opt) then ! Leaf nitrogen concentration at the top of the canopy (g N leaf / m**2 leaf) - if (use_cn) then + if (use_cn) then ! use the leafcn calculated in subroutine time_evolv_leafcn leafcn_local = cnveg_nitrogenstate_inst%leafcn_patch(p) - else + else ! use the leafcn prescribed in the paramfile leafcn_local = leafcn(ivt(p)) end if if ( (slatop(ivt(p)) * leafcn_local) <= 0.0_r8)then @@ -3169,9 +3169,9 @@ subroutine PhotosynthesisHydraulicStress ( bounds, fn, filterp, & p = filterp(f) if (.not. lnc_opt) then - if (use_cn) then + if (use_cn) then ! use the leafcn calculated in subroutine time_evolv_leafcn leafcn_local = cnveg_nitrogenstate_inst%leafcn_patch(p) - else + else ! use the leafcn prescribed in the paramfile leafcn_local = leafcn(ivt(p)) end if ! Leaf nitrogen concentration at the top of the canopy (g N leaf / m**2 leaf) diff --git a/src/main/clm_driver.F90 b/src/main/clm_driver.F90 index 2e7cd24945..6a35ee73df 100644 --- a/src/main/clm_driver.F90 +++ b/src/main/clm_driver.F90 @@ -171,6 +171,9 @@ subroutine clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate, ro ! ------------------------------------------------- ! Obtain updated values of time-evolving parameters + ! As of ctsm5.4 + ! - We have this capability for leafcn by calculating this parameter in subroutine time_evolv_leafcn + ! - We default the time evolving leafcn calculation to leafcn's paramfile values ! ------------------------------------------------- if (use_cn) then call bgc_vegetation_inst%cnveg_nitrogenstate_inst%time_evolv_leafcn( & From 56a3d6cb0b0980c8e714920afc57e5c55039c6ce Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Wed, 26 Mar 2025 14:51:10 -0600 Subject: [PATCH 23/32] Rename leafcn_patch to leafcn_t_evolving_patch update some comments --- src/biogeochem/CNAllocationMod.F90 | 2 +- src/biogeochem/CNFUNMod.F90 | 4 +- src/biogeochem/CNPhenologyMod.F90 | 6 +-- src/biogeochem/CNVegNitrogenStateType.F90 | 52 ++++++++++--------- .../NutrientCompetitionCLM45defaultMod.F90 | 4 +- .../NutrientCompetitionFlexibleCNMod.F90 | 4 +- src/biogeochem/dynConsBiogeochemMod.F90 | 6 +-- .../test_ComputeSeedAmounts.pf | 6 +-- src/biogeophys/PhotosynthesisMod.F90 | 4 +- 9 files changed, 46 insertions(+), 42 deletions(-) diff --git a/src/biogeochem/CNAllocationMod.F90 b/src/biogeochem/CNAllocationMod.F90 index bb4e7c7519..254e951cfe 100644 --- a/src/biogeochem/CNAllocationMod.F90 +++ b/src/biogeochem/CNAllocationMod.F90 @@ -466,7 +466,7 @@ subroutine calc_allometry(num_soilp, filter_soilp, & croot_stem => pftcon%croot_stem , & ! Input: allocation parameter: new coarse root C per new stem C (gC/gC) stem_leaf => pftcon%stem_leaf , & ! Input: allocation parameter: new stem c per new leaf C (gC/gC) flivewd => pftcon%flivewd , & ! Input: allocation parameter: fraction of new wood that is live (phloem and ray parenchyma) (no units) - leafcn_t_evolving => cnveg_nitrogenstate_inst%leafcn_patch, & ! Input: leaf C:N (gC/gN) + leafcn_t_evolving => cnveg_nitrogenstate_inst%leafcn_t_evolving_patch, & ! Input: leaf C:N (gC/gN) frootcn => pftcon%frootcn , & ! Input: fine root C:N (gC/gN) livewdcn => pftcon%livewdcn , & ! Input: live wood (phloem and ray parenchyma) C:N (gC/gN) deadwdcn => pftcon%deadwdcn , & ! Input: dead wood (xylem and heartwood) C:N (gC/gN) diff --git a/src/biogeochem/CNFUNMod.F90 b/src/biogeochem/CNFUNMod.F90 index 3608a92f16..cdbe7ba71b 100644 --- a/src/biogeochem/CNFUNMod.F90 +++ b/src/biogeochem/CNFUNMod.F90 @@ -216,7 +216,7 @@ subroutine CNFUNInit (bounds,cnveg_state_inst,cnveg_carbonstate_inst,cnveg_nitro ! Set local pointers associate(ivt => patch%itype , & ! Input: [integer (:) ] p - leafcn_t_evolving => cnveg_nitrogenstate_inst%leafcn_patch , & ! Input: leaf C:N (gC/gN) + leafcn_t_evolving => cnveg_nitrogenstate_inst%leafcn_t_evolving_patch , & ! Input: leaf C:N (gC/gN) leafcn_offset => cnveg_state_inst%leafcn_offset_patch , & ! Output: ! [real(r8) (:) ] Leaf C:N used by FUN leafc_storage_xfer_acc => cnveg_carbonstate_inst%leafc_storage_xfer_acc_patch , & ! Output: [real(r8) (:) @@ -573,7 +573,7 @@ subroutine CNFUN(bounds,num_soilc, filter_soilc,num_soilp& !-------------------------------------------------------------------- !--------------------------------- associate(ivt => patch%itype , & ! Input: [integer (:) ] p - leafcn_t_evolving => cnveg_nitrogenstate_inst%leafcn_patch , & ! Input: leaf C:N (gC/gN) + leafcn_t_evolving => cnveg_nitrogenstate_inst%leafcn_t_evolving_patch , & ! Input: leaf C:N (gC/gN) season_decid => pftcon%season_decid , & ! Input: binary flag for seasonal ! -deciduous leaf habit (0 or 1) stress_decid => pftcon%stress_decid , & ! Input: binary flag for stress diff --git a/src/biogeochem/CNPhenologyMod.F90 b/src/biogeochem/CNPhenologyMod.F90 index a06ce11d57..ff1e5b1b74 100644 --- a/src/biogeochem/CNPhenologyMod.F90 +++ b/src/biogeochem/CNPhenologyMod.F90 @@ -2075,7 +2075,7 @@ subroutine CropPhenology(num_pcropp, filter_pcropp , & ivt => patch%itype , & ! Input: [integer (:) ] patch vegetation type leaf_long => pftcon%leaf_long , & ! Input: leaf longevity (yrs) - leafcn_t_evolving => cnveg_nitrogenstate_inst%leafcn_patch , & ! Input: leaf C:N (gC/gN) + leafcn_t_evolving => cnveg_nitrogenstate_inst%leafcn_t_evolving_patch, & ! Input: leaf C:N (gC/gN) manunitro => pftcon%manunitro , & ! Input: max manure to be applied in total (kgN/m2) minplanttemp => pftcon%minplanttemp , & ! Input: planttemp => pftcon%planttemp , & ! Input: @@ -3388,7 +3388,7 @@ subroutine CNOffsetLitterfall (num_soilp, filter_soilp, & associate( & ivt => patch%itype , & ! Input: [integer (:) ] patch vegetation type - leafcn_t_evolving => cnveg_nitrogenstate_inst%leafcn_patch , & ! Input: leaf C:N (gC/gN) + leafcn_t_evolving => cnveg_nitrogenstate_inst%leafcn_t_evolving_patch , & ! Input: leaf C:N (gC/gN) biofuel_harvfrac => pftcon%biofuel_harvfrac , & ! Input: cut a fraction of leaf & stem for biofuel (-) repr_structure_harvfrac => pftcon%repr_structure_harvfrac , & ! Input: fraction of each reproductive structure component that is harvested and sent to the crop products pool @@ -3888,7 +3888,7 @@ subroutine CNBackgroundLitterfall (num_soilp, filter_soilp, & associate( & ivt => patch%itype , & ! Input: [integer (:) ] patch vegetation type - leafcn_t_evolving => cnveg_nitrogenstate_inst%leafcn_patch , & ! Input: leaf C:N (gC/gN) + leafcn_t_evolving => cnveg_nitrogenstate_inst%leafcn_t_evolving_patch, & ! Input: leaf C:N (gC/gN) lflitcn => pftcon%lflitcn , & ! Input: leaf litter C:N (gC/gN) frootcn => pftcon%frootcn , & ! Input: fine root C:N (gC/gN) diff --git a/src/biogeochem/CNVegNitrogenStateType.F90 b/src/biogeochem/CNVegNitrogenStateType.F90 index 42759c09e6..c50c50b704 100644 --- a/src/biogeochem/CNVegNitrogenStateType.F90 +++ b/src/biogeochem/CNVegNitrogenStateType.F90 @@ -37,7 +37,7 @@ module CNVegNitrogenStateType type, public :: cnveg_nitrogenstate_type - real(r8), pointer :: leafcn_patch(:) ! time evolving leafcn calculated in subroutine time_evolv_leafcn from co2_ppmv and three paramfile parameters; of the three parameters, leafcn_co2_slope is set to 0 (as of ctsm5.4) so leafcn_patch defaults to the values of paramfile parameter leafcn + real(r8), pointer :: leafcn_t_evolving_patch (:) ! (gC/gN) time evolving leafcn real(r8), pointer :: reproductiven_patch (:,:) ! (gN/m2) reproductive (e.g., grain) N (crop) real(r8), pointer :: reproductiven_storage_patch (:,:) ! (gN/m2) reproductive (e.g., grain) N storage (crop) real(r8), pointer :: reproductiven_xfer_patch (:,:) ! (gN/m2) reproductive (e.g., grain) N transfer (crop) @@ -350,7 +350,7 @@ subroutine InitAllocate(this, bounds, alloc_full_veg) allocate(this%totvegn_col (begc:endc)) ; this%totvegn_col (:) = nan allocate(this%totn_p2c_col (begc:endc)) ; this%totn_p2c_col (:) = nan - allocate(this%leafcn_patch (begp:endp)) ; this%leafcn_patch (:) = nan + allocate(this%leafcn_t_evolving_patch (begp:endp)) ; this%leafcn_t_evolving_patch (:) = nan if(use_matrixcn)then allocate(this%leafn0_patch (begp:endp)) ; this%leafn0_patch (:) = nan allocate(this%leafn0_storage_patch (begp:endp)) ; this%leafn0_storage_patch (:) = nan @@ -505,10 +505,10 @@ subroutine InitHistory(this, bounds) ! patch state variables !------------------------------- - this%leafcn_patch(begp:endp) = spval + this%leafcn_t_evolving_patch(begp:endp) = spval call hist_addfld1d (fname='LEAFCN_TARGET', units='gC/gN', & avgflag='A', long_name='Target leaf C:N; compare against leafC/leafN', & - ptr_patch=this%leafcn_patch) + ptr_patch=this%leafcn_t_evolving_patch) if (use_crop) then this%reproductiven_patch(begp:endp,:) = spval @@ -845,7 +845,7 @@ subroutine InitCold(this, bounds, & do p = bounds%begp,bounds%endp - this%leafcn_patch(p) = pftcon%leafcn(patch%itype(p)) + this%leafcn_t_evolving_patch(p) = pftcon%leafcn(patch%itype(p)) l = patch%landunit(p) if (lun%itype(l) == istsoil .or. lun%itype(l) == istcrop) then @@ -866,11 +866,11 @@ subroutine InitCold(this, bounds, & end if end if else - this%leafn_patch(p) = leafc_patch(p) / this%leafcn_patch(p) - this%leafn_storage_patch(p) = leafc_storage_patch(p) / this%leafcn_patch(p) + this%leafn_patch(p) = leafc_patch(p) / this%leafcn_t_evolving_patch(p) + this%leafn_storage_patch(p) = leafc_storage_patch(p) / this%leafcn_t_evolving_patch(p) if(use_matrixcn)then - this%matrix_cap_leafn_patch(p) = leafc_patch(p) / this%leafcn_patch(p) - this%matrix_cap_leafn_storage_patch(p) = leafc_storage_patch(p) / this%leafcn_patch(p) + this%matrix_cap_leafn_patch(p) = leafc_patch(p) / this%leafcn_t_evolving_patch(p) + this%matrix_cap_leafn_storage_patch(p) = leafc_storage_patch(p) / this%leafcn_t_evolving_patch(p) end if if (MM_Nuptake_opt .eqv. .true.) then this%frootn_patch(p) = frootc_patch(p) / pftcon%frootcn(patch%itype(p)) @@ -1833,20 +1833,20 @@ subroutine Restart ( this, bounds, ncid, flag, leafc_patch, & end if end if else - ! max in next line ensures leafcn_patch equals at least the + ! max in next line ensures leafcn_t_evolving_patch equals at least the ! leafcn for bare ground (noveg) to avoid div by 0 when the - ! initial file doesn't include leafcn_patch. In that situation + ! initial file doesn't include leafcn_t_evolving_patch. In that situation ! it seems, however, like a better initial condition to set - ! this%leafcn_patch(p) = pftcon%leafcn(patch%itype(p)) - ! ...but leafcn_patch does get updated before anything else + ! this%leafcn_t_evolving_patch(p) = pftcon%leafcn(patch%itype(p)) + ! ...but leafcn_t_evolving_patch does get updated before anything else ! in clm_driver, so either option may give the same answer. - this%leafcn_patch(p) = max(pftcon%leafcn(noveg), & - this%leafcn_patch(p)) - this%leafn_patch(p) = leafc_patch(p) / this%leafcn_patch(p) - this%leafn_storage_patch(p) = leafc_storage_patch(p) / this%leafcn_patch(p) + this%leafcn_t_evolving_patch(p) = max(pftcon%leafcn(noveg), & + this%leafcn_t_evolving_patch(p)) + this%leafn_patch(p) = leafc_patch(p) / this%leafcn_t_evolving_patch(p) + this%leafn_storage_patch(p) = leafc_storage_patch(p) / this%leafcn_t_evolving_patch(p) if(use_matrixcn)then - this%matrix_cap_leafn_patch(p) = leafc_patch(p) / this%leafcn_patch(p) - this%matrix_cap_leafn_storage_patch(p) = leafc_storage_patch(p) / this%leafcn_patch(p) + this%matrix_cap_leafn_patch(p) = leafc_patch(p) / this%leafcn_t_evolving_patch(p) + this%matrix_cap_leafn_storage_patch(p) = leafc_storage_patch(p) / this%leafcn_t_evolving_patch(p) end if if (MM_Nuptake_opt .eqv. .true.) then this%frootn_patch(p) = frootc_patch(p) / pftcon%frootcn(patch%itype(p)) @@ -2003,7 +2003,7 @@ subroutine SetValues ( this, & do fi = 1,num_patch i = filter_patch(fi) - this%leafcn_patch(i) = value_patch + this%leafcn_t_evolving_patch(i) = value_patch this%leafn_patch(i) = value_patch this%leafn_storage_patch(i) = value_patch this%leafn_xfer_patch(i) = value_patch @@ -2338,11 +2338,15 @@ subroutine time_evolv_leafcn(this, bounds, atm2lnd_inst) ! !DESCRIPTION: ! Update time-evolving parameters ! In the current implementation, I call this subroutine from clm_drv - ! first thing, before anything else. Hence I allocate leafcn_patch + ! first thing, before anything else. Hence I allocate leafcn_t_evolving_patch ! to memory if_first_step here to prevent an error in some tests. ! I allocate again in InitAllocate to prevent a similar error in ! InitHistory in other tests. ! + ! Calculate time evolving leafcn from co2_ppmv and three paramfile + ! parameters. Of the three parameters, leafcn_co2_slope is set to 0 + ! (as of ctsm5.4) so leafcn_t_evolving_patch defaults to the values of + ! paramfile parameter leafcn ! !USES: use pftconMod, only : pftcon use clm_time_manager, only : is_first_step @@ -2358,7 +2362,7 @@ subroutine time_evolv_leafcn(this, bounds, atm2lnd_inst) !----------------------------------------------------------------------- if (is_first_step()) then - allocate(this%leafcn_patch(bounds%begp:bounds%endp)); this%leafcn_patch(:) = pftcon%leafcn(patch%itype(:)) + allocate(this%leafcn_t_evolving_patch(bounds%begp:bounds%endp)); this%leafcn_t_evolving_patch(:) = pftcon%leafcn(patch%itype(:)) end if ! Loop to get leafcn_col do p = bounds%begp, bounds%endp @@ -2368,7 +2372,7 @@ subroutine time_evolv_leafcn(this, bounds, atm2lnd_inst) if (lun%itype(l) == istsoil .or. lun%itype(l) == istcrop) then co2_ppmv = 1.e6_r8 * atm2lnd_inst%forc_pco2_grc(g) / & atm2lnd_inst%forc_pbot_downscaled_col(c) - this%leafcn_patch(p) = pftcon%leafcn(patch%itype(p)) + & + this%leafcn_t_evolving_patch(p) = pftcon%leafcn(patch%itype(p)) + & max(params_inst%leafcn_co2_slope * log(co2_ppmv / params_inst%leafcn_co2_base), 0._r8) end if end do @@ -2441,7 +2445,7 @@ subroutine DynamicPatchAdjustments(this, bounds, & call ComputeSeedAmounts(bounds, & num_soilp_with_inactive, filter_soilp_with_inactive, & - leafcn_t_evolving = this%leafcn_patch(begp:endp), & + leafcn_t_evolving = this%leafcn_t_evolving_patch(begp:endp), & species = CN_SPECIES_N, & leafc_seed = leafc_seed, & deadstemc_seed = deadstemc_seed, & diff --git a/src/biogeochem/NutrientCompetitionCLM45defaultMod.F90 b/src/biogeochem/NutrientCompetitionCLM45defaultMod.F90 index 2fb618356c..82dceef664 100644 --- a/src/biogeochem/NutrientCompetitionCLM45defaultMod.F90 +++ b/src/biogeochem/NutrientCompetitionCLM45defaultMod.F90 @@ -178,7 +178,7 @@ subroutine calc_plant_cn_alloc (this, bounds, num_soilp, filter_soilp, & croot_stem => pftcon%croot_stem , & ! Input: allocation parameter: new coarse root C per new stem C (gC/gC) stem_leaf => pftcon%stem_leaf , & ! Input: allocation parameter: new stem c per new leaf C (gC/gC) flivewd => pftcon%flivewd , & ! Input: allocation parameter: fraction of new wood that is live (phloem and ray parenchyma) (no units) - leafcn_t_evolving => cnveg_nitrogenstate_inst%leafcn_patch , & ! Input: leaf C:N (gC/gN) + leafcn_t_evolving => cnveg_nitrogenstate_inst%leafcn_t_evolving_patch , & ! Input: leaf C:N (gC/gN) frootcn => pftcon%frootcn , & ! Input: fine root C:N (gC/gN) livewdcn => pftcon%livewdcn , & ! Input: live wood (phloem and ray parenchyma) C:N (gC/gN) deadwdcn => pftcon%deadwdcn , & ! Input: dead wood (xylem and heartwood) C:N (gC/gN) @@ -551,7 +551,7 @@ subroutine calc_plant_nitrogen_demand(this, bounds, & associate( & ivt => patch%itype , & ! Input: [integer (:) ] patch vegetation type - leafcn_t_evolving => cnveg_nitrogenstate_inst%leafcn_patch , & ! Input: leaf C:N (gC/gN) + leafcn_t_evolving => cnveg_nitrogenstate_inst%leafcn_t_evolving_patch , & ! Input: leaf C:N (gC/gN) frootcn => pftcon%frootcn , & ! Input: fine root C:N (gC/gN) livewdcn => pftcon%livewdcn , & ! Input: live wood (phloem and ray parenchyma) C:N (gC/gN) graincn => pftcon%graincn , & ! Input: grain C:N (gC/gN) diff --git a/src/biogeochem/NutrientCompetitionFlexibleCNMod.F90 b/src/biogeochem/NutrientCompetitionFlexibleCNMod.F90 index 491813b600..00e8a00b77 100644 --- a/src/biogeochem/NutrientCompetitionFlexibleCNMod.F90 +++ b/src/biogeochem/NutrientCompetitionFlexibleCNMod.F90 @@ -275,7 +275,7 @@ subroutine calc_plant_cn_alloc(this, bounds, num_soilp, filter_soilp, & croot_stem => pftcon%croot_stem , & ! Input: allocation parameter: new coarse root C per new stem C (gC/gC) stem_leaf => pftcon%stem_leaf , & ! Input: allocation parameter: new stem c per new leaf C (gC/gC) flivewd => pftcon%flivewd , & ! Input: allocation parameter: fraction of new wood that is live (phloem and ray parenchyma) (no units) - leafcn_t_evolving => cnveg_nitrogenstate_inst%leafcn_patch , & ! Input: leaf C:N (gC/gN) + leafcn_t_evolving => cnveg_nitrogenstate_inst%leafcn_t_evolving_patch , & ! Input: leaf C:N (gC/gN) frootcn => pftcon%frootcn , & ! Input: fine root C:N (gC/gN) livewdcn => pftcon%livewdcn , & ! Input: live wood (phloem and ray parenchyma) C:N (gC/gN) fcur2 => pftcon%fcur , & ! Input: allocation parameter: fraction of allocation that goes to currently displayed growth, remainder to storage @@ -1456,7 +1456,7 @@ subroutine calc_plant_nitrogen_demand(this, bounds, & associate( & ivt => patch%itype , & ! Input: [integer (:) ] patch vegetation type - leafcn_t_evolving => cnveg_nitrogenstate_inst%leafcn_patch , & ! Input: leaf C:N (gC/gN) + leafcn_t_evolving => cnveg_nitrogenstate_inst%leafcn_t_evolving_patch , & ! Input: leaf C:N (gC/gN) fleafcn => pftcon%fleafcn , & ! Input: leaf c:n during organ fill ffrootcn => pftcon%ffrootcn , & ! Input: froot c:n during organ fill fstemcn => pftcon%fstemcn , & ! Input: stem c:n during organ fill diff --git a/src/biogeochem/dynConsBiogeochemMod.F90 b/src/biogeochem/dynConsBiogeochemMod.F90 index a96807d702..445d1a7bda 100644 --- a/src/biogeochem/dynConsBiogeochemMod.F90 +++ b/src/biogeochem/dynConsBiogeochemMod.F90 @@ -445,7 +445,7 @@ subroutine dyn_cnbal_patch(bounds, & patch_state_updater, & leafc_seed = leafc_seed, & deadstemc_seed = deadstemc_seed, & - leafcn_t_evolving = cnveg_nitrogenstate_inst%leafcn_patch(begp:endp), & + leafcn_t_evolving = cnveg_nitrogenstate_inst%leafcn_t_evolving_patch(begp:endp), & conv_cflux = conv_cflux(begp:endp), & wood_product_cflux = wood_product_cflux(begp:endp), & crop_product_cflux = crop_product_cflux(begp:endp), & @@ -469,7 +469,7 @@ subroutine dyn_cnbal_patch(bounds, & patch_state_updater, & leafc_seed = leafc_seed, & deadstemc_seed = deadstemc_seed, & - leafcn_t_evolving = cnveg_nitrogenstate_inst%leafcn_patch(begp:endp), & + leafcn_t_evolving = cnveg_nitrogenstate_inst%leafcn_t_evolving_patch(begp:endp), & conv_cflux = conv_c13flux(begp:endp), & wood_product_cflux = wood_product_c13flux(begp:endp), & crop_product_cflux = crop_product_c13flux(begp:endp), & @@ -495,7 +495,7 @@ subroutine dyn_cnbal_patch(bounds, & patch_state_updater, & leafc_seed = leafc_seed, & deadstemc_seed = deadstemc_seed, & - leafcn_t_evolving = cnveg_nitrogenstate_inst%leafcn_patch(begp:endp), & + leafcn_t_evolving = cnveg_nitrogenstate_inst%leafcn_t_evolving_patch(begp:endp), & conv_cflux = conv_c14flux(begp:endp), & wood_product_cflux = wood_product_c14flux(begp:endp), & crop_product_cflux = crop_product_c14flux(begp:endp), & diff --git a/src/biogeochem/test/CNVegComputeSeed_test/test_ComputeSeedAmounts.pf b/src/biogeochem/test/CNVegComputeSeed_test/test_ComputeSeedAmounts.pf index 49593a197e..c0911fb9ee 100644 --- a/src/biogeochem/test/CNVegComputeSeed_test/test_ComputeSeedAmounts.pf +++ b/src/biogeochem/test/CNVegComputeSeed_test/test_ComputeSeedAmounts.pf @@ -92,7 +92,7 @@ contains real(r8), intent(out), optional :: seed_leaf_xfer real(r8), intent(out), optional :: seed_deadstem - real(r8) :: leafcn_patch(bounds%begp:bounds%endp) + real(r8) :: leafcn_t_evolving_patch(bounds%begp:bounds%endp) real(r8) :: leaf_patch(bounds%begp:bounds%endp) real(r8) :: leaf_storage_patch(bounds%begp:bounds%endp) real(r8) :: leaf_xfer_patch(bounds%begp:bounds%endp) @@ -103,7 +103,7 @@ contains real(r8) :: seed_leaf_xfer_patch(bounds%begp:bounds%endp) real(r8) :: seed_deadstem_patch(bounds%begp:bounds%endp) - leafcn_patch(:) = 10._r8 + leafcn_t_evolving_patch(:) = 10._r8 leaf_patch(:) = 0._r8 leaf_patch(POI) = LEAF_POI leaf_storage_patch(:) = 0._r8 @@ -119,7 +119,7 @@ contains call ComputeSeedAmounts(bounds, & this%numf, this%filter, & - leafcn_t_evolving = leafcn_patch, & + leafcn_t_evolving = leafcn_t_evolving_patch, & species = species, & leafc_seed = LEAFC_SEED, & deadstemc_seed = DEADSTEMC_SEED, & diff --git a/src/biogeophys/PhotosynthesisMod.F90 b/src/biogeophys/PhotosynthesisMod.F90 index 80e4c62e97..4a93a0f7d9 100644 --- a/src/biogeophys/PhotosynthesisMod.F90 +++ b/src/biogeophys/PhotosynthesisMod.F90 @@ -1551,7 +1551,7 @@ subroutine Photosynthesis ( bounds, fn, filterp, & if (.not. lnc_opt) then ! Leaf nitrogen concentration at the top of the canopy (g N leaf / m**2 leaf) if (use_cn) then ! use the leafcn calculated in subroutine time_evolv_leafcn - leafcn_local = cnveg_nitrogenstate_inst%leafcn_patch(p) + leafcn_local = cnveg_nitrogenstate_inst%leafcn_t_evolving_patch(p) else ! use the leafcn prescribed in the paramfile leafcn_local = leafcn(ivt(p)) end if @@ -3170,7 +3170,7 @@ subroutine PhotosynthesisHydraulicStress ( bounds, fn, filterp, & if (.not. lnc_opt) then if (use_cn) then ! use the leafcn calculated in subroutine time_evolv_leafcn - leafcn_local = cnveg_nitrogenstate_inst%leafcn_patch(p) + leafcn_local = cnveg_nitrogenstate_inst%leafcn_t_evolving_patch(p) else ! use the leafcn prescribed in the paramfile leafcn_local = leafcn(ivt(p)) end if From 9bbc2167f568a23e8a3cb520e1f017346a5b5e24 Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Wed, 26 Mar 2025 15:05:34 -0600 Subject: [PATCH 24/32] Remove redundant leafcn_t_evolving_patch update from subr. restart --- src/biogeochem/CNVegNitrogenStateType.F90 | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/biogeochem/CNVegNitrogenStateType.F90 b/src/biogeochem/CNVegNitrogenStateType.F90 index c50c50b704..b748502444 100644 --- a/src/biogeochem/CNVegNitrogenStateType.F90 +++ b/src/biogeochem/CNVegNitrogenStateType.F90 @@ -1833,15 +1833,6 @@ subroutine Restart ( this, bounds, ncid, flag, leafc_patch, & end if end if else - ! max in next line ensures leafcn_t_evolving_patch equals at least the - ! leafcn for bare ground (noveg) to avoid div by 0 when the - ! initial file doesn't include leafcn_t_evolving_patch. In that situation - ! it seems, however, like a better initial condition to set - ! this%leafcn_t_evolving_patch(p) = pftcon%leafcn(patch%itype(p)) - ! ...but leafcn_t_evolving_patch does get updated before anything else - ! in clm_driver, so either option may give the same answer. - this%leafcn_t_evolving_patch(p) = max(pftcon%leafcn(noveg), & - this%leafcn_t_evolving_patch(p)) this%leafn_patch(p) = leafc_patch(p) / this%leafcn_t_evolving_patch(p) this%leafn_storage_patch(p) = leafc_storage_patch(p) / this%leafcn_t_evolving_patch(p) if(use_matrixcn)then From 50785f645bb44863f387e8425d4372276ff49756 Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Wed, 26 Mar 2025 15:13:19 -0600 Subject: [PATCH 25/32] Update comments --- src/main/clm_driver.F90 | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/clm_driver.F90 b/src/main/clm_driver.F90 index 6a35ee73df..fc2c4ac26a 100644 --- a/src/main/clm_driver.F90 +++ b/src/main/clm_driver.F90 @@ -171,9 +171,11 @@ subroutine clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate, ro ! ------------------------------------------------- ! Obtain updated values of time-evolving parameters + ! ! As of ctsm5.4 - ! - We have this capability for leafcn by calculating this parameter in subroutine time_evolv_leafcn - ! - We default the time evolving leafcn calculation to leafcn's paramfile values + ! - We have this capability for leafcn by calculating leafcn_t_evolving_patch in subr. time_evolv_leafcn + ! - leafcn_t_evolving_patch's calculation defaults to leafcn's paramfile values + ! - This needs to be called before calling dynSubgrid_driver ! ------------------------------------------------- if (use_cn) then call bgc_vegetation_inst%cnveg_nitrogenstate_inst%time_evolv_leafcn( & From f298fc80a71d7f211f56612bd9c2ea1ac10c6c6b Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Wed, 26 Mar 2025 15:29:26 -0600 Subject: [PATCH 26/32] Rm allocate(this%leafcn_t_evolving_patch from subr. time_evolv_leafcn --- src/biogeochem/CNVegNitrogenStateType.F90 | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/biogeochem/CNVegNitrogenStateType.F90 b/src/biogeochem/CNVegNitrogenStateType.F90 index b748502444..8bacf51883 100644 --- a/src/biogeochem/CNVegNitrogenStateType.F90 +++ b/src/biogeochem/CNVegNitrogenStateType.F90 @@ -2328,11 +2328,6 @@ subroutine time_evolv_leafcn(this, bounds, atm2lnd_inst) ! ! !DESCRIPTION: ! Update time-evolving parameters - ! In the current implementation, I call this subroutine from clm_drv - ! first thing, before anything else. Hence I allocate leafcn_t_evolving_patch - ! to memory if_first_step here to prevent an error in some tests. - ! I allocate again in InitAllocate to prevent a similar error in - ! InitHistory in other tests. ! ! Calculate time evolving leafcn from co2_ppmv and three paramfile ! parameters. Of the three parameters, leafcn_co2_slope is set to 0 @@ -2352,9 +2347,6 @@ subroutine time_evolv_leafcn(this, bounds, atm2lnd_inst) real(r8) :: co2_ppmv ! atm co2 concentration !----------------------------------------------------------------------- - if (is_first_step()) then - allocate(this%leafcn_t_evolving_patch(bounds%begp:bounds%endp)); this%leafcn_t_evolving_patch(:) = pftcon%leafcn(patch%itype(:)) - end if ! Loop to get leafcn_col do p = bounds%begp, bounds%endp c = patch%column(p) From e511893311e151f5bbfd8ef11f9518482515df00 Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Wed, 26 Mar 2025 17:07:23 -0600 Subject: [PATCH 27/32] Add testmods_dirs/clm/leafcn_t_evolving for aux_clm test to be added While preparing the README for this test, I discovered incorrect info in the README for ciso_cwd_hr, so I also updated that README --- .../testdefs/testmods_dirs/clm/ciso_cwd_hr/README | 10 +++++++--- .../testmods_dirs/clm/leafcn_t_evolving/README | 6 ++++++ .../clm/leafcn_t_evolving/include_user_mods | 1 + .../testmods_dirs/clm/leafcn_t_evolving/user_nl_clm | 1 + 4 files changed, 15 insertions(+), 3 deletions(-) create mode 100644 cime_config/testdefs/testmods_dirs/clm/leafcn_t_evolving/README create mode 100644 cime_config/testdefs/testmods_dirs/clm/leafcn_t_evolving/include_user_mods create mode 100644 cime_config/testdefs/testmods_dirs/clm/leafcn_t_evolving/user_nl_clm diff --git a/cime_config/testdefs/testmods_dirs/clm/ciso_cwd_hr/README b/cime_config/testdefs/testmods_dirs/clm/ciso_cwd_hr/README index 39ac318b86..d0dab73f44 100644 --- a/cime_config/testdefs/testmods_dirs/clm/ciso_cwd_hr/README +++ b/cime_config/testdefs/testmods_dirs/clm/ciso_cwd_hr/README @@ -1,8 +1,12 @@ This points to an alternate params file with -rf_cwdl2 = 0.5 -rf_cwdl3_bgc = 0.5 -while by default these parameters equal zero. +ceta = 450 (default = 358) +The README used to say that the alternate paramfile contained +rf_cwdl2 = 0.5 (default 0) +rf_cwdl3_bgc = 0.5 (default 0) +but now 0.5 is the default. + +The README also used to say: The test outputs inactive history fields that would contain zeros when running with the default params file and should be greater than zero when running with the alternate params file. diff --git a/cime_config/testdefs/testmods_dirs/clm/leafcn_t_evolving/README b/cime_config/testdefs/testmods_dirs/clm/leafcn_t_evolving/README new file mode 100644 index 0000000000..3a21ac1a4e --- /dev/null +++ b/cime_config/testdefs/testmods_dirs/clm/leafcn_t_evolving/README @@ -0,0 +1,6 @@ +This points to an alternate params file with +leafcn_co2_slope = 30 (default = 0) +to confirm that the leafcn_t_evolving calculation doesn't fail. + +When we added this test, slevis and ekluzek agreed to consolidate our custom paramfiles into one. +The first of the consolidated paramfiles is named ctsm60_ceta450_cn30_co2_slope30.c250326.nc. diff --git a/cime_config/testdefs/testmods_dirs/clm/leafcn_t_evolving/include_user_mods b/cime_config/testdefs/testmods_dirs/clm/leafcn_t_evolving/include_user_mods new file mode 100644 index 0000000000..fe0e18cf88 --- /dev/null +++ b/cime_config/testdefs/testmods_dirs/clm/leafcn_t_evolving/include_user_mods @@ -0,0 +1 @@ +../default diff --git a/cime_config/testdefs/testmods_dirs/clm/leafcn_t_evolving/user_nl_clm b/cime_config/testdefs/testmods_dirs/clm/leafcn_t_evolving/user_nl_clm new file mode 100644 index 0000000000..443e9ac1e5 --- /dev/null +++ b/cime_config/testdefs/testmods_dirs/clm/leafcn_t_evolving/user_nl_clm @@ -0,0 +1 @@ +paramfile = '$DIN_LOC_ROOT/lnd/clm2/paramdata/ctsm60_ceta450_cn30_co2_slope30.c250326.nc' From 14ef2488ca2bd337f83c8bed6a7e6b38c8a33ccb Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Wed, 26 Mar 2025 17:23:14 -0600 Subject: [PATCH 28/32] Add the new test to testlist_clm.xml --- cime_config/testdefs/testlist_clm.xml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/cime_config/testdefs/testlist_clm.xml b/cime_config/testdefs/testlist_clm.xml index 36bdedbf8a..4e85a2fd26 100644 --- a/cime_config/testdefs/testlist_clm.xml +++ b/cime_config/testdefs/testlist_clm.xml @@ -1202,6 +1202,15 @@ + + + + + + + + + From c7f008b4d26cf967a32ebaba1b12a4f32b3dcfd7 Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Wed, 26 Mar 2025 17:55:46 -0600 Subject: [PATCH 29/32] Move "call time_evolv_leafcn" into a loop over clumps (Bill's review) --- src/main/clm_driver.F90 | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main/clm_driver.F90 b/src/main/clm_driver.F90 index fc2c4ac26a..8be8295e99 100644 --- a/src/main/clm_driver.F90 +++ b/src/main/clm_driver.F90 @@ -178,8 +178,14 @@ subroutine clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate, ro ! - This needs to be called before calling dynSubgrid_driver ! ------------------------------------------------- if (use_cn) then - call bgc_vegetation_inst%cnveg_nitrogenstate_inst%time_evolv_leafcn( & - bounds_proc, atm2lnd_inst) + !$OMP PARALLEL DO PRIVATE (nc, bounds_clump) + do nc = 1, nclumps + call get_clump_bounds(nc, bounds_clump) + + call bgc_vegetation_inst%cnveg_nitrogenstate_inst%time_evolv_leafcn( & + bounds_clump, atm2lnd_inst) + end do + !$OMP END PARALLEL DO end if ! ======================================================================== From e85903333b27234978939554bb484c24d8c1499f Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Fri, 28 Mar 2025 12:48:10 -0600 Subject: [PATCH 30/32] Use the bgc_vegp filter instead of an if-statement for efficiency --- src/biogeochem/CNVegNitrogenStateType.F90 | 24 +++++++++++------------ src/main/clm_driver.F90 | 7 +++++-- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/src/biogeochem/CNVegNitrogenStateType.F90 b/src/biogeochem/CNVegNitrogenStateType.F90 index 8bacf51883..4d3cf7f3cf 100644 --- a/src/biogeochem/CNVegNitrogenStateType.F90 +++ b/src/biogeochem/CNVegNitrogenStateType.F90 @@ -2322,7 +2322,7 @@ subroutine ReadParams ( this, ncid ) end subroutine ReadParams !----------------------------------------------------------------------- - subroutine time_evolv_leafcn(this, bounds, atm2lnd_inst) + subroutine time_evolv_leafcn(this, bounds, num_bgc_vegp, filter_bgc_vegp, atm2lnd_inst) ! ! AUTHOR: slevis ! @@ -2339,25 +2339,25 @@ subroutine time_evolv_leafcn(this, bounds, atm2lnd_inst) ! ! !ARGUMENTS: class(cnveg_nitrogenstate_type) :: this - type(bounds_type) , intent(in) :: bounds - type(atm2lnd_type), intent(in) :: atm2lnd_inst + type(bounds_type), intent(in) :: bounds + integer, intent(in) :: num_bgc_vegp ! number of veg patches in filter + integer, intent(in) :: filter_bgc_vegp(:) ! filter for veg patches + type(atm2lnd_type), intent(in) :: atm2lnd_inst ! ! !LOCAL VARIABLES: - integer :: g, l, c, p ! indices + integer :: g, c, p, fp ! indices real(r8) :: co2_ppmv ! atm co2 concentration !----------------------------------------------------------------------- ! Loop to get leafcn_col - do p = bounds%begp, bounds%endp + do fp = 1, num_bgc_vegp + p = filter_bgc_vegp(fp) c = patch%column(p) - l = patch%landunit(p) g = patch%gridcell(p) - if (lun%itype(l) == istsoil .or. lun%itype(l) == istcrop) then - co2_ppmv = 1.e6_r8 * atm2lnd_inst%forc_pco2_grc(g) / & - atm2lnd_inst%forc_pbot_downscaled_col(c) - this%leafcn_t_evolving_patch(p) = pftcon%leafcn(patch%itype(p)) + & - max(params_inst%leafcn_co2_slope * log(co2_ppmv / params_inst%leafcn_co2_base), 0._r8) - end if + co2_ppmv = 1.e6_r8 * atm2lnd_inst%forc_pco2_grc(g) / & + atm2lnd_inst%forc_pbot_downscaled_col(c) + this%leafcn_t_evolving_patch(p) = pftcon%leafcn(patch%itype(p)) + & + max(params_inst%leafcn_co2_slope * log(co2_ppmv / params_inst%leafcn_co2_base), 0._r8) end do end subroutine time_evolv_leafcn diff --git a/src/main/clm_driver.F90 b/src/main/clm_driver.F90 index 8be8295e99..b2302c1cdd 100644 --- a/src/main/clm_driver.F90 +++ b/src/main/clm_driver.F90 @@ -182,8 +182,11 @@ subroutine clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate, ro do nc = 1, nclumps call get_clump_bounds(nc, bounds_clump) - call bgc_vegetation_inst%cnveg_nitrogenstate_inst%time_evolv_leafcn( & - bounds_clump, atm2lnd_inst) + call bgc_vegetation_inst%cnveg_nitrogenstate_inst%time_evolv_leafcn( & + bounds_clump, & + filter_inactive_and_active(nc)%num_bgc_vegp, & + filter_inactive_and_active(nc)%bgc_vegp, & + atm2lnd_inst) end do !$OMP END PARALLEL DO end if From 4ad5256fd851e4336b7fef32e8cc6b20c637a004 Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Wed, 14 May 2025 11:30:48 -0600 Subject: [PATCH 31/32] Calculate co2_ppmv with both pco2 & pbot not_downscaled (Bill's review) --- src/biogeochem/CNVegNitrogenStateType.F90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/biogeochem/CNVegNitrogenStateType.F90 b/src/biogeochem/CNVegNitrogenStateType.F90 index 4d3cf7f3cf..7ff8e77df9 100644 --- a/src/biogeochem/CNVegNitrogenStateType.F90 +++ b/src/biogeochem/CNVegNitrogenStateType.F90 @@ -2355,7 +2355,7 @@ subroutine time_evolv_leafcn(this, bounds, num_bgc_vegp, filter_bgc_vegp, atm2ln c = patch%column(p) g = patch%gridcell(p) co2_ppmv = 1.e6_r8 * atm2lnd_inst%forc_pco2_grc(g) / & - atm2lnd_inst%forc_pbot_downscaled_col(c) + atm2lnd_inst%forc_pbot_not_downscaled_grc(g) this%leafcn_t_evolving_patch(p) = pftcon%leafcn(patch%itype(p)) + & max(params_inst%leafcn_co2_slope * log(co2_ppmv / params_inst%leafcn_co2_base), 0._r8) end do From 737159083dd8062c89908060633b4ef62f86ca0d Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Wed, 14 May 2025 12:07:10 -0600 Subject: [PATCH 32/32] Updated ChangeLog/Sum --- doc/ChangeLog | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++ doc/ChangeSum | 1 + 2 files changed, 61 insertions(+) diff --git a/doc/ChangeLog b/doc/ChangeLog index e594c688a0..ab165f8136 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,4 +1,64 @@ =============================================================== +Tag name: ctsm5.3.044 +Originator(s): slevis (Samuel Levis,UCAR/TSS,303-665-1310) +Date: Wed 14 May 2025 11:42:41 AM MDT +One-line Summary: Introduce time-evolving LEAFCN_TARGET as function of leafcn param + +Purpose and description of changes +---------------------------------- + + Motivated by a phd student's project (Emma Hauser, now Professor at UW-Madison) we have introduced time-evolving leafcn as a possible template for other time-evolving parameters. + +Significant changes to scientifically-supported configurations +-------------------------------------------------------------- + +Does this tag change answers significantly for any of the following physics configurations? +(Details of any changes will be given in the "Answer changes" section below.) + + [Put an [X] in the box for any configuration with significant answer changes.] + +[ ] clm6_0 + +[ ] clm5_0 + +[ ] ctsm5_0-nwp + +[ ] clm4_5 + + +Bugs fixed +---------- +List of CTSM issues fixed (include CTSM Issue # and description) [one per line]: + Resolves #1646 Time evolving parameterization for leaf properties + +Notes of particular relevance for developers: +--------------------------------------------- +Changes to tests or testing: + New test in aux_clm that points to an alternate params file with leafcn_co2_slope = 30 (default = 0) to confirm that the leafcn_t_evolving calculation doesn't fail + +Testing summary: +---------------- + + [PASS means all tests PASS; OK means tests PASS other than expected fails.] + + regular tests (aux_clm: https://github.com/ESCOMP/CTSM/wiki/System-Testing-Guide#pre-merge-system-testing): + + derecho ----- OK + izumi ------- OK + +Answer changes +-------------- + +Changes answers relative to baseline: No + but field lists differ due to new history field LEAFCN_TARGET + +Other details +------------- +Pull Requests that document the changes (include PR ids): + https://github.com/ESCOMP/ctsm/pull/1654 + +=============================================================== +=============================================================== Tag name: ctsm5.3.043 Originator(s): slevis (Samuel Levis,UCAR/TSS,303-665-1310) Date: Fri 09 May 2025 12:28:17 PM MDT diff --git a/doc/ChangeSum b/doc/ChangeSum index e805a39512..85192e7d5a 100644 --- a/doc/ChangeSum +++ b/doc/ChangeSum @@ -1,5 +1,6 @@ Tag Who Date Summary ============================================================================================================================ + ctsm5.3.044 slevis 05/14/2025 Introduce time-evolving LEAFCN_TARGET as function of leafcn param ctsm5.3.043 slevis 05/09/2025 Merge b4b-dev ctsm5.3.042 glemieux 05/08/2025 Update FATES tag, tests and address namelist option bug ctsm5.3.041 samrabin 04/25/2025 Merge b4b-dev to master