From 635f3fff21bef2db8f23e4697497f341098344c3 Mon Sep 17 00:00:00 2001 From: Ryan Knox Date: Mon, 5 Feb 2024 21:56:15 -0500 Subject: [PATCH 1/5] removed lamda requirement for phosphatase dyanamics in fates --- .../src/biogeochem/PhosphorusDynamicsMod.F90 | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/components/elm/src/biogeochem/PhosphorusDynamicsMod.F90 b/components/elm/src/biogeochem/PhosphorusDynamicsMod.F90 index 077474e2a86e..44ac8ea43579 100644 --- a/components/elm/src/biogeochem/PhosphorusDynamicsMod.F90 +++ b/components/elm/src/biogeochem/PhosphorusDynamicsMod.F90 @@ -605,8 +605,8 @@ subroutine PhosphorusBiochemMin_balance(bounds,num_soilc, filter_soilc, & km_ptase => veg_vp%km_ptase , & alpha_ptase => veg_vp%alpha_ptase , & decomp_ppools_vr_col => col_ps%decomp_ppools_vr, & + lamda_ptase => veg_vp%lamda_ptase, & ! critical value of nitrogen cost of phosphatase activity induced phosphorus uptake - lamda_ptase => veg_vp%lamda_ptase , & cn_scalar => cnstate_vars%cn_scalar , & cp_scalar => cnstate_vars%cp_scalar , & is_soil => decomp_cascade_con%is_soil) @@ -639,28 +639,29 @@ subroutine PhosphorusBiochemMin_balance(bounds,num_soilc, filter_soilc, & if(use_fates) then do j = 1,nlevdecomp - do p = 1, alm_fates%fates(ci)%bc_out(s)%num_plant_comps - lamda_up = alm_fates%fates(ci)%bc_out(s)%cp_scalar(p)/ & - max(alm_fates%fates(ci)%bc_out(s)%cn_scalar(p),1e-20_r8) - lamda_up = min(max(lamda_up,0.0_r8), 150.0_r8) + do p = 1, alm_fates%fates(ci)%bc_out(s)%num_plant_comps + pft = alm_fates%fates(ci)%bc_out(s)%ft_index(p) + fr_frac = alm_fates%fates(ci)%bc_out(s)%veg_rootc(p,j) / & - sum(alm_fates%fates(ci)%bc_out(s)%veg_rootc(p,:)) + sum(alm_fates%fates(ci)%bc_out(s)%veg_rootc(:,:)) + + ! lamda is not used currently with fates, fates also does not + ! scale by the cn_ and cp_scalars + ! lamda_ptase = alm_fates%fates(ci)%bc_pconst%eca_lambda_ptase(pft) - pft = alm_fates%fates(ci)%bc_out(s)%ft_index(p) ptase_tmp = alm_fates%fates(ci)%bc_pconst%eca_vmax_ptase(pft) * & - fr_frac * max(lamda_up - lamda_ptase, 0.0_r8) / & - ( alm_fates%fates(ci)%bc_pconst%eca_km_ptase(pft) + & - max(lamda_up - alm_fates%fates(ci)%bc_pconst%eca_lambda_ptase(pft), 0.0_r8)) + fr_frac/dzsoi_decomp(j) / ( alm_fates%fates(ci)%bc_pconst%eca_km_ptase(pft) + 1._r8) biochem_pmin_to_plant_vr_patch(p,j) = ptase_tmp * alm_fates%fates(ci)%bc_pconst%eca_alpha_ptase(pft) - biochem_pmin_vr(c,j) = biochem_pmin_vr(c,j) + ptase_tmp*(1._r8 - alm_fates%fates(ci)%bc_pconst%eca_alpha_ptase(pft)) + biochem_pmin_vr(c,j) = biochem_pmin_vr(c,j) + ptase_tmp * (1._r8 - alm_fates%fates(ci)%bc_pconst%eca_alpha_ptase(pft)) biochem_pmin_to_ecosysp_vr_col_pot(c,j) = biochem_pmin_to_ecosysp_vr_col_pot(c,j) + ptase_tmp end do end do else + do j = 1,nlevdecomp do p = col_pp%pfti(c), col_pp%pftf(c) if (veg_pp%active(p).and. (veg_pp%itype(p) .ne. noveg)) then From fb5d26001d9cf7764be8e93672052bd3f1ffe392 Mon Sep 17 00:00:00 2001 From: Ryan Knox Date: Thu, 8 Feb 2024 08:59:23 -0800 Subject: [PATCH 2/5] Fix to fates phosphatase, adding iteration counter diagnostic on land energy solver --- .../elm/src/biogeochem/PhosphorusDynamicsMod.F90 | 5 +++-- components/elm/src/biogeophys/BareGroundFluxesMod.F90 | 3 ++- components/elm/src/biogeophys/CanopyFluxesMod.F90 | 5 ++++- components/elm/src/biogeophys/FrictionVelocityType.F90 | 10 +++++++++- 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/components/elm/src/biogeochem/PhosphorusDynamicsMod.F90 b/components/elm/src/biogeochem/PhosphorusDynamicsMod.F90 index 44ac8ea43579..9e7e70576cfe 100644 --- a/components/elm/src/biogeochem/PhosphorusDynamicsMod.F90 +++ b/components/elm/src/biogeochem/PhosphorusDynamicsMod.F90 @@ -649,13 +649,14 @@ subroutine PhosphorusBiochemMin_balance(bounds,num_soilc, filter_soilc, & ! lamda is not used currently with fates, fates also does not ! scale by the cn_ and cp_scalars + ! Also, we do not currently allow phosphatase released P + ! to go directly to the plants in FATES. This implies as an alpha of 0. ! lamda_ptase = alm_fates%fates(ci)%bc_pconst%eca_lambda_ptase(pft) ptase_tmp = alm_fates%fates(ci)%bc_pconst%eca_vmax_ptase(pft) * & fr_frac/dzsoi_decomp(j) / ( alm_fates%fates(ci)%bc_pconst%eca_km_ptase(pft) + 1._r8) - biochem_pmin_to_plant_vr_patch(p,j) = ptase_tmp * alm_fates%fates(ci)%bc_pconst%eca_alpha_ptase(pft) - biochem_pmin_vr(c,j) = biochem_pmin_vr(c,j) + ptase_tmp * (1._r8 - alm_fates%fates(ci)%bc_pconst%eca_alpha_ptase(pft)) + biochem_pmin_vr(c,j) = biochem_pmin_vr(c,j) + ptase_tmp !*(1._r8 - alm_fates%fates(ci)%bc_pconst%eca_alpha_ptase(pft)) biochem_pmin_to_ecosysp_vr_col_pot(c,j) = biochem_pmin_to_ecosysp_vr_col_pot(c,j) + ptase_tmp end do diff --git a/components/elm/src/biogeophys/BareGroundFluxesMod.F90 b/components/elm/src/biogeophys/BareGroundFluxesMod.F90 index 7932887d5bc9..8723fd94bb12 100644 --- a/components/elm/src/biogeophys/BareGroundFluxesMod.F90 +++ b/components/elm/src/biogeophys/BareGroundFluxesMod.F90 @@ -252,7 +252,7 @@ subroutine BareGroundFluxes(bounds, num_nolakeurbanp, filter_nolakeurbanp, & ! Initialize Monin-Obukhov length and wind speed call MoninObukIni(ur(p), thv(c), dthv, zldis(p), z0mg_patch(p), um(p), obu(p)) - + num_iter(p) = 0 end do ! Perform stability iteration @@ -322,6 +322,7 @@ subroutine BareGroundFluxes(bounds, num_nolakeurbanp, filter_nolakeurbanp, & fn = 0 do f = 1, fnold p = filterp(f) + num_iter(p) = iter if (.not. (abs(tau_diff(p)) < dtaumin)) then fn = fn + 1 filterp(fn) = p diff --git a/components/elm/src/biogeophys/CanopyFluxesMod.F90 b/components/elm/src/biogeophys/CanopyFluxesMod.F90 index 0732f48d733a..7b8873064dc0 100755 --- a/components/elm/src/biogeophys/CanopyFluxesMod.F90 +++ b/components/elm/src/biogeophys/CanopyFluxesMod.F90 @@ -379,6 +379,7 @@ subroutine CanopyFluxes(bounds, num_nolakeurbanp, filter_nolakeurbanp, & z0hv => frictionvel_vars%z0hv_patch , & ! Output: [real(r8) (:) ] roughness length over vegetation, sensible heat [m] z0qv => frictionvel_vars%z0qv_patch , & ! Output: [real(r8) (:) ] roughness length over vegetation, latent heat [m] rb1 => frictionvel_vars%rb1_patch , & ! Output: [real(r8) (:) ] boundary layer resistance (s/m) + num_iter => frictionvel_vars%num_iter_patch , & ! Output: number of iterations required t_h2osfc => col_es%t_h2osfc , & ! Input: [real(r8) (:) ] surface water temperature t_soisno => col_es%t_soisno , & ! Input: [real(r8) (:,:) ] soil temperature (Kelvin) @@ -749,7 +750,8 @@ subroutine CanopyFluxes(bounds, num_nolakeurbanp, filter_nolakeurbanp, & ! Initialize Monin-Obukhov length and wind speed call MoninObukIni(ur(p), thv(c), dthv(p), zldis(p), z0mv(p), um(p), obu(p)) - + num_iter(p) = 0 + end do ! Set counter for leaf temperature iteration (itlef) @@ -1157,6 +1159,7 @@ subroutine CanopyFluxes(bounds, num_nolakeurbanp, filter_nolakeurbanp, & dele(p) = abs(efe(p)-efeb(p)) efeb(p) = efe(p) det(p) = max(del(p),del2(p)) + num_iter(p) = itlef end do fnold = fn fn = 0 diff --git a/components/elm/src/biogeophys/FrictionVelocityType.F90 b/components/elm/src/biogeophys/FrictionVelocityType.F90 index 9ee8d586cd94..0c6ef9a371a3 100644 --- a/components/elm/src/biogeophys/FrictionVelocityType.F90 +++ b/components/elm/src/biogeophys/FrictionVelocityType.F90 @@ -41,7 +41,9 @@ module FrictionVelocityType real(r8), pointer :: z0mg_col (:) ! col roughness length over ground, momentum [m] real(r8), pointer :: z0hg_col (:) ! col roughness length over ground, sensible heat [m] real(r8), pointer :: z0qg_col (:) ! col roughness length over ground, latent heat [m] - + integer, pointer :: num_iter_patch (:) ! number of iterations performed to find a solution + ! to the land-energy flux balance in CanopyFluxes() + contains procedure, public :: Init @@ -102,6 +104,7 @@ subroutine InitAllocate(this, bounds) allocate(this%z0mv_patch (begp:endp)) ; this%z0mv_patch (:) = spval allocate(this%z0hv_patch (begp:endp)) ; this%z0hv_patch (:) = spval allocate(this%z0qv_patch (begp:endp)) ; this%z0qv_patch (:) = spval + allocate(this%num_iter_patch (begp:endp)) ; this%num_iter_patch (:) = huge(1) allocate(this%z0mg_col (begc:endc)) ; this%z0mg_col (:) = spval allocate(this%z0qg_col (begc:endc)) ; this%z0qg_col (:) = spval allocate(this%z0hg_col (begc:endc)) ; this%z0hg_col (:) = spval @@ -209,6 +212,11 @@ subroutine InitHistory(this, bounds) ptr_patch=this%z0qv_patch, default='inactive') end if + this%num_iter_patch(begp:endp) = huge(1) + call hist_addfld1d(fname='ITER_LND_EBAL_AVG', units='count', & + avgflag='A', long_name='average number of iterations performed in land-energy balance', & + ptr_patch=this%num_iter_patch, default = 'inactive') + end subroutine InitHistory !----------------------------------------------------------------------- From 3b149fbcab1aaf18325c7bc150e67545cd411814 Mon Sep 17 00:00:00 2001 From: Ryan Knox Date: Fri, 9 Feb 2024 09:03:23 -0800 Subject: [PATCH 3/5] Updates to eca-fates-phosphatase fix and land-energy-balance iteration counts --- components/elm/src/biogeophys/BareGroundFluxesMod.F90 | 5 +++-- components/elm/src/biogeophys/CanopyFluxesMod.F90 | 4 ++-- components/elm/src/biogeophys/FrictionVelocityType.F90 | 6 +++--- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/components/elm/src/biogeophys/BareGroundFluxesMod.F90 b/components/elm/src/biogeophys/BareGroundFluxesMod.F90 index 8723fd94bb12..83662758eba8 100644 --- a/components/elm/src/biogeophys/BareGroundFluxesMod.F90 +++ b/components/elm/src/biogeophys/BareGroundFluxesMod.F90 @@ -191,6 +191,7 @@ subroutine BareGroundFluxes(bounds, num_nolakeurbanp, filter_nolakeurbanp, & qflx_ev_h2osfc => veg_wf%qflx_ev_h2osfc , & ! Output: [real(r8) (:) ] evaporation flux from h2osfc (W/m**2) [+ to atm] qflx_evap_soi => veg_wf%qflx_evap_soi , & ! Output: [real(r8) (:) ] soil evaporation (mm H2O/s) (+ = to atm) qflx_evap_tot => veg_wf%qflx_evap_tot , & ! Output: [real(r8) (:) ] qflx_evap_soi + qflx_evap_can + qflx_tran_veg + num_iter => frictionvel_vars%num_iter_patch , & ! Output: number of iterations required begp => bounds%begp , & endp => bounds%endp & ) @@ -252,7 +253,7 @@ subroutine BareGroundFluxes(bounds, num_nolakeurbanp, filter_nolakeurbanp, & ! Initialize Monin-Obukhov length and wind speed call MoninObukIni(ur(p), thv(c), dthv, zldis(p), z0mg_patch(p), um(p), obu(p)) - num_iter(p) = 0 + num_iter(p) = 0._r8 end do ! Perform stability iteration @@ -322,7 +323,7 @@ subroutine BareGroundFluxes(bounds, num_nolakeurbanp, filter_nolakeurbanp, & fn = 0 do f = 1, fnold p = filterp(f) - num_iter(p) = iter + num_iter(p) = real(iter,r8) if (.not. (abs(tau_diff(p)) < dtaumin)) then fn = fn + 1 filterp(fn) = p diff --git a/components/elm/src/biogeophys/CanopyFluxesMod.F90 b/components/elm/src/biogeophys/CanopyFluxesMod.F90 index 7b8873064dc0..6c96e70e172d 100755 --- a/components/elm/src/biogeophys/CanopyFluxesMod.F90 +++ b/components/elm/src/biogeophys/CanopyFluxesMod.F90 @@ -750,7 +750,7 @@ subroutine CanopyFluxes(bounds, num_nolakeurbanp, filter_nolakeurbanp, & ! Initialize Monin-Obukhov length and wind speed call MoninObukIni(ur(p), thv(c), dthv(p), zldis(p), z0mv(p), um(p), obu(p)) - num_iter(p) = 0 + num_iter(p) = 0._r8 end do @@ -1159,7 +1159,7 @@ subroutine CanopyFluxes(bounds, num_nolakeurbanp, filter_nolakeurbanp, & dele(p) = abs(efe(p)-efeb(p)) efeb(p) = efe(p) det(p) = max(del(p),del2(p)) - num_iter(p) = itlef + num_iter(p) = real(itlef,r8) end do fnold = fn fn = 0 diff --git a/components/elm/src/biogeophys/FrictionVelocityType.F90 b/components/elm/src/biogeophys/FrictionVelocityType.F90 index 0c6ef9a371a3..bd2f4458dd5a 100644 --- a/components/elm/src/biogeophys/FrictionVelocityType.F90 +++ b/components/elm/src/biogeophys/FrictionVelocityType.F90 @@ -41,7 +41,7 @@ module FrictionVelocityType real(r8), pointer :: z0mg_col (:) ! col roughness length over ground, momentum [m] real(r8), pointer :: z0hg_col (:) ! col roughness length over ground, sensible heat [m] real(r8), pointer :: z0qg_col (:) ! col roughness length over ground, latent heat [m] - integer, pointer :: num_iter_patch (:) ! number of iterations performed to find a solution + real(r8), pointer :: num_iter_patch (:) ! number of iterations performed to find a solution ! to the land-energy flux balance in CanopyFluxes() contains @@ -104,7 +104,7 @@ subroutine InitAllocate(this, bounds) allocate(this%z0mv_patch (begp:endp)) ; this%z0mv_patch (:) = spval allocate(this%z0hv_patch (begp:endp)) ; this%z0hv_patch (:) = spval allocate(this%z0qv_patch (begp:endp)) ; this%z0qv_patch (:) = spval - allocate(this%num_iter_patch (begp:endp)) ; this%num_iter_patch (:) = huge(1) + allocate(this%num_iter_patch (begp:endp)) ; this%num_iter_patch (:) = spval allocate(this%z0mg_col (begc:endc)) ; this%z0mg_col (:) = spval allocate(this%z0qg_col (begc:endc)) ; this%z0qg_col (:) = spval allocate(this%z0hg_col (begc:endc)) ; this%z0hg_col (:) = spval @@ -212,7 +212,7 @@ subroutine InitHistory(this, bounds) ptr_patch=this%z0qv_patch, default='inactive') end if - this%num_iter_patch(begp:endp) = huge(1) + this%num_iter_patch(begp:endp) = spval call hist_addfld1d(fname='ITER_LND_EBAL_AVG', units='count', & avgflag='A', long_name='average number of iterations performed in land-energy balance', & ptr_patch=this%num_iter_patch, default = 'inactive') From 40580c8f8ecd6a2ad4ff134cf89890f689f685ff Mon Sep 17 00:00:00 2001 From: Ryan Knox Date: Wed, 14 Feb 2024 13:39:07 -0800 Subject: [PATCH 4/5] Explicitly setting biochem pmin to plants to zero for fates ptase activity --- components/elm/src/biogeochem/PhosphorusDynamicsMod.F90 | 1 + 1 file changed, 1 insertion(+) diff --git a/components/elm/src/biogeochem/PhosphorusDynamicsMod.F90 b/components/elm/src/biogeochem/PhosphorusDynamicsMod.F90 index 9e7e70576cfe..5a8918236f4a 100644 --- a/components/elm/src/biogeochem/PhosphorusDynamicsMod.F90 +++ b/components/elm/src/biogeochem/PhosphorusDynamicsMod.F90 @@ -656,6 +656,7 @@ subroutine PhosphorusBiochemMin_balance(bounds,num_soilc, filter_soilc, & ptase_tmp = alm_fates%fates(ci)%bc_pconst%eca_vmax_ptase(pft) * & fr_frac/dzsoi_decomp(j) / ( alm_fates%fates(ci)%bc_pconst%eca_km_ptase(pft) + 1._r8) + biochem_pmin_to_plant_vr_patch(p,j) = 0._r8 biochem_pmin_vr(c,j) = biochem_pmin_vr(c,j) + ptase_tmp !*(1._r8 - alm_fates%fates(ci)%bc_pconst%eca_alpha_ptase(pft)) biochem_pmin_to_ecosysp_vr_col_pot(c,j) = biochem_pmin_to_ecosysp_vr_col_pot(c,j) + ptase_tmp From b211e59867727f6493d8a24510bd419f6b68241e Mon Sep 17 00:00:00 2001 From: Ryan Knox Date: Fri, 16 Feb 2024 09:55:41 -0800 Subject: [PATCH 5/5] for fates: updating default nutrient supplementation status to on, setting nutrient limiting testdefs to off --- components/elm/bld/namelist_files/namelist_defaults.xml | 9 ++++++++- .../testdefs/testmods_dirs/elm/fates_eca/user_nl_elm | 2 ++ .../testdefs/testmods_dirs/elm/fates_rd/user_nl_elm | 2 ++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/components/elm/bld/namelist_files/namelist_defaults.xml b/components/elm/bld/namelist_files/namelist_defaults.xml index 4f02fc9df8ac..9bcc9ad7d8e7 100644 --- a/components/elm/bld/namelist_files/namelist_defaults.xml +++ b/components/elm/bld/namelist_files/namelist_defaults.xml @@ -55,7 +55,14 @@ attributes from the config_cache.xml file (with keys converted to upper-case). NONE -NONE + + + + + +ALL +ALL + RD diff --git a/components/elm/cime_config/testdefs/testmods_dirs/elm/fates_eca/user_nl_elm b/components/elm/cime_config/testdefs/testmods_dirs/elm/fates_eca/user_nl_elm index 407d0dcecf2a..3371f4b63065 100644 --- a/components/elm/cime_config/testdefs/testmods_dirs/elm/fates_eca/user_nl_elm +++ b/components/elm/cime_config/testdefs/testmods_dirs/elm/fates_eca/user_nl_elm @@ -6,6 +6,8 @@ fates_parteh_mode = 2 use_lch4 = .true. fates_spitfire_mode = 1 hist_empty_htapes = .true. +suplphos = 'NONE' +suplnitro = 'NONE' hist_fincl1 = 'FATES_NCOHORTS', 'FATES_TRIMMING', 'FATES_AREA_PLANTS', 'FATES_AREA_TREES', 'FATES_COLD_STATUS', 'FATES_GDD', 'FATES_NCHILLDAYS', 'FATES_NCOLDDAYS', 'FATES_DAYSINCE_COLDLEAFOFF', diff --git a/components/elm/cime_config/testdefs/testmods_dirs/elm/fates_rd/user_nl_elm b/components/elm/cime_config/testdefs/testmods_dirs/elm/fates_rd/user_nl_elm index 30a0dbb88cb0..eeff7ea9c51b 100644 --- a/components/elm/cime_config/testdefs/testmods_dirs/elm/fates_rd/user_nl_elm +++ b/components/elm/cime_config/testdefs/testmods_dirs/elm/fates_rd/user_nl_elm @@ -6,6 +6,8 @@ fates_parteh_mode = 2 use_lch4 = .true. fates_spitfire_mode = 1 hist_empty_htapes = .true. +suplphos = 'NONE' +suplnitro = 'NONE' hist_fincl1 = 'FATES_NCOHORTS', 'FATES_TRIMMING', 'FATES_AREA_PLANTS', 'FATES_AREA_TREES', 'FATES_COLD_STATUS', 'FATES_GDD', 'FATES_NCHILLDAYS', 'FATES_NCOLDDAYS', 'FATES_DAYSINCE_COLDLEAFOFF',