Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
313 changes: 153 additions & 160 deletions biogeochem/EDPhysiologyMod.F90

Large diffs are not rendered by default.

28 changes: 24 additions & 4 deletions biogeochem/FatesSoilBGCFluxMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ module FatesSoilBGCFluxMod
use FatesInterfaceTypesMod, only : hlm_parteh_mode
use FatesInterfaceTypesMod, only : hlm_use_ch4
use FatesInterfaceTypesMod, only : hlm_decomp
use FatesInterfaceTypesMod, only : hlm_phosphorus_suppl
use FatesInterfaceTypesMod, only : hlm_nitrogen_suppl
use FatesConstantsMod , only : prescribed_p_uptake
use FatesConstantsMod , only : prescribed_n_uptake
use FatesConstantsMod , only : coupled_p_uptake
Expand All @@ -68,7 +70,7 @@ module FatesSoilBGCFluxMod
use FatesConstantsMod, only : days_per_year
use FatesConstantsMod, only : sec_per_day
use FatesConstantsMod, only : years_per_day
use FatesConstantsMod, only : itrue
use FatesConstantsMod, only : itrue,ifalse
use FatesConstantsMod, only : nocomp_bareground
use FatesLitterMod, only : litter_type
use FatesLitterMod , only : ncwd
Expand Down Expand Up @@ -100,7 +102,7 @@ module FatesSoilBGCFluxMod
! =====================================================================================


subroutine UnPackNutrientAquisitionBCs(sites, bc_in)
subroutine UnPackNutrientAquisitionBCs(sites, bc_in, nitr_suppl, phos_suppl)

! -----------------------------------------------------------------------------------
! The purpose of this routine is to recieve the nutrient uptake flux
Expand All @@ -118,8 +120,10 @@ subroutine UnPackNutrientAquisitionBCs(sites, bc_in)

! !ARGUMENTS
type(ed_site_type), intent(inout) :: sites(:)
type(bc_in_type), intent(in) :: bc_in(:)

type(bc_in_type), intent(in) :: bc_in(:)
logical, intent(in) :: nitr_suppl ! Is the HLM supplementing nitrogen?
logical, intent(in) :: phos_suppl ! Is the HLM supplementing phosphorus?

! Locals
integer :: nsites ! number of sites
integer :: s ! site loop index
Expand All @@ -129,6 +133,22 @@ subroutine UnPackNutrientAquisitionBCs(sites, bc_in)
type(fates_cohort_type), pointer :: ccohort ! current cohort pointer
real(r8) :: fnrt_c ! fine-root carbon [kg]

! FATES needs to know the supplementation status of N and P in the soils
! If both are supplemented, then FATES doesn't activate dynamic roots
! even if we are in CNP mode.

if(nitr_suppl) then
hlm_nitrogen_suppl = itrue
else
hlm_nitrogen_suppl = ifalse
end if

if(phos_suppl) then
hlm_phosphorus_suppl = itrue
else
hlm_phosphorus_suppl = ifalse
end if

nsites = size(sites,dim=1)

! We can exit if this is a c-only simulation
Expand Down
36 changes: 14 additions & 22 deletions main/EDPftvarcon.F90
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ module EDPftvarcon
use PRTGenericMod, only : leaf_organ, fnrt_organ, store_organ
use PRTGenericMod, only : sapw_organ, struct_organ, repro_organ
use PRTGenericMod, only : prt_cnp_flex_allom_hyp,prt_carbon_allom_hyp
use FatesInterfaceTypesMod, only : hlm_nitrogen_spec, hlm_phosphorus_spec
use FatesInterfaceTypesMod, only : hlm_parteh_mode
use FatesInterfaceTypesMod, only : hlm_nu_com
use FatesConstantsMod , only : ievergreen
Expand Down Expand Up @@ -1725,28 +1724,21 @@ subroutine FatesCheckParams(is_master)
write(fates_log(),*) 'Aborting'
call endrun(msg=errMsg(sourcefile, __LINE__))
end if


! If nitrogen is turned on, check to make sure there are valid ammonium
! parameters
if(hlm_nitrogen_spec>0)then
if (trim(hlm_nu_com).eq.'ECA') then

if(any(EDpftvarcon_inst%eca_km_nh4(:)<0._r8) ) then
write(fates_log(),*) 'ECA with nitrogen is turned on'
write(fates_log(),*) 'bad ECA km value(s) for nh4: ',EDpftvarcon_inst%eca_km_nh4(:)
write(fates_log(),*) 'Aborting'
call endrun(msg=errMsg(sourcefile, __LINE__))
end if

if(hlm_nitrogen_spec==2)then
if(any(EDpftvarcon_inst%eca_km_no3(:)<0._r8)) then
write(fates_log(),*) 'ECA with nit/denitr is turned on'
write(fates_log(),*) 'bad ECA km value(s) for no3: ',EDpftvarcon_inst%eca_km_no3(:)
write(fates_log(),*) 'Aborting'
call endrun(msg=errMsg(sourcefile, __LINE__))
end if
end if
if (trim(hlm_nu_com).eq.'ECA') then
if(any(EDpftvarcon_inst%eca_km_nh4(:)<0._r8) ) then
write(fates_log(),*) 'ECA with nitrogen is turned on'
write(fates_log(),*) 'bad ECA km value(s) for nh4: ',EDpftvarcon_inst%eca_km_nh4(:)
write(fates_log(),*) 'Aborting'
call endrun(msg=errMsg(sourcefile, __LINE__))
end if
if(any(EDpftvarcon_inst%eca_km_no3(:)<0._r8)) then
write(fates_log(),*) 'ECA with nit/denitr is turned on'
write(fates_log(),*) 'bad ECA km value(s) for no3: ',EDpftvarcon_inst%eca_km_no3(:)
write(fates_log(),*) 'Aborting'
call endrun(msg=errMsg(sourcefile, __LINE__))
end if
end if

Expand Down Expand Up @@ -1776,8 +1768,8 @@ subroutine FatesCheckParams(is_master)
! We are using a simple phosphatase model right now. There is
! no critical value (lambda) , and there is no preferential uptake (alpha).
! Make sure these parameters are both set to 0.

if ((hlm_phosphorus_spec>0) .and. (trim(hlm_nu_com).eq.'ECA')) then
if (trim(hlm_nu_com).eq.'ECA') then
if (any(abs(EDPftvarcon_inst%eca_lambda_ptase(:)) > nearzero ) ) then
write(fates_log(),*) 'Critical Values for phosphatase in ECA are not'
write(fates_log(),*) 'enabled right now. Please set fates_eca_lambda_ptase = 0'
Expand Down
30 changes: 2 additions & 28 deletions main/FatesInterfaceMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1489,9 +1489,7 @@ subroutine set_fates_ctrlparms(tag,ival,rval,cval)
hlm_ipedof = unset_int
hlm_nu_com = 'unset'
hlm_decomp = 'unset'
hlm_nitrogen_spec = unset_int
hlm_use_tree_damage = unset_int
hlm_phosphorus_spec = unset_int
hlm_use_ch4 = unset_int
hlm_use_vertsoilc = unset_int
hlm_parteh_mode = unset_int
Expand Down Expand Up @@ -1694,21 +1692,9 @@ subroutine set_fates_ctrlparms(tag,ival,rval,cval)
write(fates_log(),*) 'FATES tree damage (use_fates_tree_damage = .true.) is not'
write(fates_log(),*) '(yet) compatible with CNP allocation (fates_parteh_mode = 2)'
call endrun(msg=errMsg(sourcefile, __LINE__))
end if
end if


end if

if(hlm_nitrogen_spec .eq. unset_int) then
write(fates_log(),*) 'FATES parameters unset: hlm_nitrogen_spec, exiting'
call endrun(msg=errMsg(sourcefile, __LINE__))
end if

if(hlm_phosphorus_spec .eq. unset_int) then
write(fates_log(),*) 'FATES parameters unset: hlm_phosphorus_spec, exiting'
call endrun(msg=errMsg(sourcefile, __LINE__))
end if


if( abs(hlm_hio_ignore_val-unset_double)<1e-10 ) then
write(fates_log(),*) 'FATES dimension/parameter unset: hio_ignore'
call endrun(msg=errMsg(sourcefile, __LINE__))
Expand Down Expand Up @@ -1924,18 +1910,6 @@ subroutine set_fates_ctrlparms(tag,ival,rval,cval)
write(fates_log(),*) 'Transfering hlm_use_tree_damage = ',ival,' to FATES'
end if

case('nitrogen_spec')
hlm_nitrogen_spec = ival
if (fates_global_verbose()) then
write(fates_log(),*) 'Transfering hlm_nitrogen_spec = ',ival,' to FATES'
end if

case('phosphorus_spec')
hlm_phosphorus_spec = ival
if (fates_global_verbose()) then
write(fates_log(),*) 'Transfering hlm_phosphorus_spec = ',ival,' to FATES'
end if

case('use_ch4')
hlm_use_ch4 = ival
if (fates_global_verbose()) then
Expand Down
23 changes: 7 additions & 16 deletions main/FatesInterfaceTypesMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -52,23 +52,14 @@ module FatesInterfaceTypesMod


character(len=16), public :: hlm_nu_com ! This string defines which soil
! nutrient competition scheme is in use.
! current options with
! E3SM: RD, ECA
! CESM: NONE
! ATS: ?
! NORESM: ?
! nutrient competition scheme is in use.
! current options with
! ELM: RD, ECA
! CLM: NONE
! ATS: ?


integer, public :: hlm_nitrogen_spec ! This flag signals which nitrogen
! species are active if any:
! 0: none
! 1: nh4 only
! 2: nh4 and no3

integer, public :: hlm_phosphorus_spec ! Signals if phosphorous is turned on in the HLM
! 0: none
! 1: p is on
integer, public :: hlm_nitrogen_suppl ! HLM nitrogen supplementation status (True=Supplementing)
integer, public :: hlm_phosphorus_suppl ! HLM phosphorus supplementation status (True=Supplementing)

real(r8), public :: hlm_stepsize ! The step-size of the host land model (s)
! moreover, this is the shortest main-model timestep
Expand Down
20 changes: 17 additions & 3 deletions parteh/PRTAllometricCNPMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,18 @@ module PRTAllometricCNPMod
use FatesIntegratorsMod , only : Euler
use FatesConstantsMod , only : calloc_abs_error
use FatesConstantsMod , only : nearzero
use FatesConstantsMod , only : ievergreen
use FatesConstantsMod , only : itrue
use FatesConstantsMod , only : ifalse
use FatesConstantsMod , only : coupled_p_uptake
use FatesConstantsMod , only : coupled_n_uptake
use FatesConstantsMod , only : fates_unset_r8
use FatesConstantsMod , only : fates_unset_int
use FatesConstantsMod , only : sec_per_day
use FatesConstantsMod , only : TRS_regeneration
use FatesConstantsMod , only : default_regeneration
use FatesConstantsMod , only : TRS_no_seedling_dyn
use FatesConstantsMod , only : min_max_dbh_for_trees
use FatesConstantsMod , only : ievergreen
use PRTParametersMod , only : prt_params
use FatesConstantsMod , only : leaves_on,leaves_off
use FatesConstantsMod , only : leaves_shedding
Expand All @@ -69,7 +73,8 @@ module PRTAllometricCNPMod
use FatesConstantsMod , only : prescribed_n_uptake
use EDPftvarcon, only : EDPftvarcon_inst
use FatesInterfaceTypesMod, only : hlm_regeneration_model

use FatesInterfaceTypesMod, only : hlm_nitrogen_suppl
use FatesInterfaceTypesMod, only : hlm_phosphorus_suppl


implicit none
Expand Down Expand Up @@ -1845,6 +1850,8 @@ subroutine CNPAllocateRemainder(this, c_gain,n_gain,p_gain, &
real(r8), dimension(num_organs) :: deficit_p
real(r8) :: target_n
real(r8) :: target_p
logical :: limiting_p
logical :: limiting_n
real(r8) :: store_c_target ! Target amount of C in storage including "overflow" [kgC]
real(r8) :: total_c_flux ! Total C flux from gains into storage and growth R [kgC]
real(r8), pointer :: dbh
Expand Down Expand Up @@ -1898,7 +1905,14 @@ subroutine CNPAllocateRemainder(this, c_gain,n_gain,p_gain, &

! This routine updates the l2fr (leaf 2 fine-root multiplier) variable
! It will also update the target
call this%CNPAdjustFRootTargets(target_c,target_dcdd)

! turn on the dynamic L2FR if either nutrient in not being supplemented
limiting_p = ((p_uptake_mode .eq. coupled_p_uptake) .and. (hlm_phosphorus_suppl .eq. ifalse))
limiting_n = ((n_uptake_mode .eq. coupled_p_uptake) .and. (hlm_nitrogen_suppl .eq. ifalse))

if (limiting_p .or. limiting_n) then
call this%CNPAdjustFRootTargets(target_c,target_dcdd)
end if

! -----------------------------------------------------------------------------------
! If carbon is still available, lets cram some into storage overflow
Expand Down