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
275 changes: 120 additions & 155 deletions biogeochem/FatesAllometryMod.F90

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions biogeophys/LeafBiophysicsMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -950,7 +950,6 @@ subroutine CiFunc(ci, &
real(r8), intent(out) :: fval ! ci_input - ci_updated (Pa)

!real(r8) :: veg_esat ! Saturation vapor pressure at leaf-surface [Pa]
real(r8) :: veg_qs ! DUMMY, specific humidity at leaf-surface [kg/kg]
real(r8) :: a_gs ! The assimilation (a) for calculating conductance (gs)
! is either = to anet or agross
real(r8) :: ac ! Rubisco-limited gross photosynthesis (umol CO2/m**2/s)
Expand Down Expand Up @@ -1478,7 +1477,7 @@ function LeafHumidityStomaResis(leaf_psi, k_lwp, veg_tempk, can_vpress, can_pres
lwp_star = 1._r8
end if

! call QSat(veg_tempk, can_press, qsat_alt, veg_esat)
call QSat(veg_tempk, can_press, qsat_alt, veg_esat)

qsat_alt = qsat_alt * g_per_kg

Expand Down
11 changes: 8 additions & 3 deletions main/FatesInterfaceMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -821,11 +821,15 @@ subroutine SetFatesGlobalElements1(use_fates,surf_numpft,surf_numcft,paramfile)
end do
write(fates_log(),*) '============ End FATES Parameter Info ========='
end if

! This assigns named constants to the indices of each
! parameter datastructure, allowing data to be accessed
! directly from the structure
call SetParameterIndices()

! This call transfers parameters from the pstruct data-structure
! into the specific datastructures where parameters have there
! own primitive arrays

call FatesTransferParameters()

fates_numpft = size(prt_params%wood_density,dim=1)
Expand Down Expand Up @@ -2338,8 +2342,9 @@ subroutine UpdateFatesRMeansTStep(sites,bc_in, bc_out)
do while (associated(ccohort))
! call ccohort%tveg_lpa%UpdateRMean(bc_in(s)%t_veg_pa(ifp))
if(.not.ccohort%isnew)then
! [kgC/plant/yr] -> [gC/m2/yr]
site_npp = site_npp + ccohort%npp_acc_hold * ccohort%n*area_inv * g_per_kg
! [kgC/plant/yr] -> [gC/m2/s]
site_npp = site_npp + ccohort%npp_acc_hold * ccohort%n*area_inv * &
g_per_kg * hlm_days_per_year / sec_per_day
end if
ccohort => ccohort%shorter
end do
Expand Down
32 changes: 15 additions & 17 deletions main/FatesParameterDerivedMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ module FatesParameterDerivedMod
use FatesInterfaceTypesMod, only : nleafage
use FatesInterfaceTypesMod, only : nlevdamage
use FatesGlobals , only : fates_log
use EDParamsMod , only : ED_val_history_damage_bin_edges

use FatesParametersInterface


implicit none
private

Expand Down Expand Up @@ -81,21 +82,21 @@ end subroutine InitAllocateDamageTransitions

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

subroutine Init(this,numpft)
subroutine Init(this)

use EDPftvarcon, only: EDPftvarcon_inst
use SFParamsMod, only: SF_val_CWD_frac
use FatesLitterMod, only : ncwd

class(param_derived_type), intent(inout) :: this
integer, intent(in) :: numpft

! local variables
integer :: ft ! pft index
integer :: iage ! leaf age class index
integer :: numpft

associate( vcmax25top => EDPftvarcon_inst%vcmax25top )

associate( vcmax25top => pstruct%parameters(pid_vcmax25top)%r_data_2d )

numpft = size(vcmax25top,dim=2)

call this%InitAllocate(numpft)
call this%InitDamageTransitions(numpft)

Expand All @@ -114,14 +115,14 @@ subroutine Init(this,numpft)
! jmax25top(ft) = &
! (2.59_r8 - 0.035_r8*min(max((t10(p)-tfrzc),11._r8),35._r8)) * vcmax25top(ft)

this%jmax25top(ft,iage) = 1.67_r8 * vcmax25top(ft,iage)
this%tpu25top(ft,iage) = 0.167_r8 * vcmax25top(ft,iage)
this%kp25top(ft,iage) = 20000._r8 * vcmax25top(ft,iage)
this%jmax25top(ft,iage) = 1.67_r8 * vcmax25top(iage,ft)
this%tpu25top(ft,iage) = 0.167_r8 * vcmax25top(iage,ft)
this%kp25top(ft,iage) = 20000._r8 * vcmax25top(iage,ft)

end do

! Allocate fraction of aboveground woody biomass in branches
this%branch_frac(ft) = sum(SF_val_CWD_frac(1:3))
this%branch_frac(ft) = sum(pstruct%parameters(pid_cwd_frac)%r_data_1d(1:3),dim=1)

end do !ft

Expand All @@ -133,9 +134,6 @@ end subroutine Init

subroutine InitDamageTransitions(this, numpft)

use EDPftvarcon, only: EDPftvarcon_inst


class(param_derived_type), intent(inout) :: this
integer, intent(in) :: numpft

Expand All @@ -155,7 +153,7 @@ subroutine InitDamageTransitions(this, numpft)
! class widths
! append 100 to ED_val_history_damage_bin_edges
do j = 1,nlevdamage
damage_bin_edges_ex(j) = ED_val_history_damage_bin_edges(j)
damage_bin_edges_ex(j) = pstruct%parameters(pid_damage_bins)%r_data_1d(j) !ED_val_history_damage_bin_edges(j)
end do
damage_bin_edges_ex(j) = 100.0_r8

Expand All @@ -165,7 +163,7 @@ subroutine InitDamageTransitions(this, numpft)

do ft = 1, numpft

damage_frac = EDPftvarcon_inst%damage_frac(ft)
damage_frac = pstruct%parameters(pid_damage_frac)%r_data_1d(ft)

do i = 1, nlevdamage

Expand Down
195 changes: 195 additions & 0 deletions main/FatesParametersInterface.F90
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,215 @@ module FatesParametersInterface
! only uses shr libraries

use JSONParameterUtilsMod, only: params_type
use JSONParameterUtilsMod, only: param_type
use FatesConstantsMod, only : r8 => fates_r8

implicit none
private

type(params_type) :: pstruct

! Parameter indexes

integer, public :: pid_vcmax25top
integer, public :: pid_cwd_frac
integer, public :: pid_damage_frac
integer, public :: pid_damage_bins
integer, public :: pid_alloc_organ_id
integer, public :: pid_phen_leaf_habit
integer, public :: pid_phen_stem_drop_frac
integer, public :: pid_phen_fnrt_drop_frac
integer, public :: pid_phen_mindaysoff
integer, public :: pid_phen_drought_thresh
integer, public :: pid_phen_moist_thresh
integer, public :: pid_leaf_slamax
integer, public :: pid_leaf_slatop
integer, public :: pid_allom_sai_scaler
integer, public :: pid_allom_fnrt_prof_a
integer, public :: pid_allom_fnrt_prof_b
integer, public :: pid_allom_fnrt_prof_mode
integer, public :: pid_woody
integer, public :: pid_wood_density
integer, public :: pid_recruit_seed_dbh_thresh
integer, public :: pid_storage_cushion
integer, public :: pid_store_priority_frac
integer, public :: pid_turnover_senleaf_fdrought
integer, public :: pid_turnover_fnrt
integer, public :: pid_leafn_vert_scaler1
integer, public :: pid_leafn_vert_scaler2
integer, public :: pid_recruit_seed_alloc_mature
integer, public :: pid_recruit_seed_alloc
integer, public :: pid_trs_repro_alloc_a
integer, public :: pid_trs_repro_alloc_b
integer, public :: pid_c2b
integer, public :: pid_grperc
integer, public :: pid_allom_dbh_maxh
integer, public :: pid_allom_hmode
integer, public :: pid_allom_lmode
integer, public :: pid_allom_fmode
integer, public :: pid_allom_amode
integer, public :: pid_allom_stmode
integer, public :: pid_allom_cmode
integer, public :: pid_allom_smode
integer, public :: pid_allom_dmode
integer, public :: pid_allom_lapersa_int
integer, public :: pid_allom_lapersa_slp
integer, public :: pid_allom_l2fr
integer, public :: pid_cnp_kp
integer, public :: pid_cnp_ki
integer, public :: pid_cnp_kd
integer, public :: pid_cnp_store_ovrflw_frac
integer, public :: pid_cnp_nfix1
integer, public :: pid_allom_d2h1
integer, public :: pid_allom_d2h2
integer, public :: pid_allom_d2h3
integer, public :: pid_allom_agbfrac
integer, public :: pid_allom_d2l1
integer, public :: pid_allom_d2l2
integer, public :: pid_allom_d2l3
integer, public :: pid_allom_blca_ediff
integer, public :: pid_allom_d2ca_max
integer, public :: pid_allom_d2ca_min
integer, public :: pid_allom_agb1
integer, public :: pid_allom_agb2
integer, public :: pid_allom_agb3
integer, public :: pid_allom_agb4
integer, public :: pid_allom_h2cd1
integer, public :: pid_allom_h2cd2
integer, public :: pid_allom_zroot_maxd
integer, public :: pid_allom_zroot_maxz
integer, public :: pid_allom_zroot_mind
integer, public :: pid_allom_zroot_minz
integer, public :: pid_allom_zroot_k
integer, public :: pid_turnover_branch
integer, public :: pid_cnp_nitr_store_ratio
integer, public :: pid_cnp_phos_store_ratio
integer, public :: pid_turnover_leaf_canopy
integer, public :: pid_turnover_leaf_ustory
integer, public :: pid_stoich_nitr
integer, public :: pid_stoich_phos
integer, public :: pid_alloc_organ_priority
integer, public :: pid_cnp_nitr_retrans
integer, public :: pid_cnp_phos_retrans

public :: pstruct
public :: GetParameterIndices
public :: Transp2dInt
public :: Transp2dReal

contains

subroutine GetParameterIndices()

! Query the parameter data structure for the names
! of known parameters, and identify the data-structure
! index of each, into a named integer constant. These
! integer constants will be used for retrieval.
! This assignment happens once, here.

! Scalar Parameters
pid_damage_bins = pstruct%GetIndexFromName('fates_history_damage_bin_edges')

pid_vcmax25top = pstruct%GetIndexFromName('fates_leaf_vcmax25top')
pid_cwd_frac = pstruct%GetIndexFromName('fates_frag_cwd_frac')
pid_damage_frac = pstruct%GetIndexFromName('fates_damage_frac')

pid_alloc_organ_id = pstruct%GetIndexFromName('fates_alloc_organ_id')
pid_phen_leaf_habit = pstruct%GetIndexFromName('fates_phen_leaf_habit')
pid_phen_stem_drop_frac = pstruct%GetIndexFromName('fates_phen_stem_drop_fraction')
pid_phen_fnrt_drop_frac = pstruct%GetIndexFromName('fates_phen_fnrt_drop_fraction')
pid_phen_mindaysoff = pstruct%GetIndexFromName('fates_phen_mindaysoff')
pid_phen_drought_thresh = pstruct%GetIndexFromName('fates_phen_drought_threshold')
pid_phen_moist_thresh = pstruct%GetIndexFromName('fates_phen_moist_threshold')
pid_leaf_slamax = pstruct%GetIndexFromName('fates_leaf_slamax')
pid_leaf_slatop = pstruct%GetIndexFromName('fates_leaf_slatop')
pid_allom_sai_scaler = pstruct%GetIndexFromName('fates_allom_sai_scaler')
pid_allom_fnrt_prof_a = pstruct%GetIndexFromName('fates_allom_fnrt_prof_a')
pid_allom_fnrt_prof_b = pstruct%GetIndexFromName('fates_allom_fnrt_prof_b')
pid_allom_fnrt_prof_mode = pstruct%GetIndexFromName('fates_allom_fnrt_prof_mode')
pid_woody = pstruct%GetIndexFromName('fates_woody')
pid_wood_density = pstruct%GetIndexFromName('fates_wood_density')
pid_recruit_seed_dbh_thresh = pstruct%GetIndexFromName('fates_recruit_seed_dbh_repro_threshold')
pid_storage_cushion = pstruct%GetIndexFromName('fates_alloc_storage_cushion')
pid_store_priority_frac = pstruct%GetIndexFromName('fates_alloc_store_priority_frac')
pid_turnover_senleaf_fdrought = pstruct%GetIndexFromName('fates_turnover_senleaf_fdrought')
pid_turnover_fnrt = pstruct%GetIndexFromName('fates_turnover_fnrt')
pid_leafn_vert_scaler1 = pstruct%GetIndexFromName('fates_leafn_vert_scaler_coeff1')
pid_leafn_vert_scaler2 = pstruct%GetIndexFromName('fates_leafn_vert_scaler_coeff2')
pid_recruit_seed_alloc_mature = pstruct%GetIndexFromName('fates_recruit_seed_alloc_mature')
pid_recruit_seed_alloc = pstruct%GetIndexFromName('fates_recruit_seed_alloc')
pid_trs_repro_alloc_a = pstruct%GetIndexFromName('fates_trs_repro_alloc_a')
pid_trs_repro_alloc_b = pstruct%GetIndexFromName('fates_trs_repro_alloc_b')
pid_c2b = pstruct%GetIndexFromName('fates_c2b')
pid_grperc = pstruct%GetIndexFromName('fates_grperc')
pid_allom_dbh_maxh = pstruct%GetIndexFromName('fates_allom_dbh_maxheight')
pid_allom_hmode = pstruct%GetIndexFromName('fates_allom_hmode')
pid_allom_lmode = pstruct%GetIndexFromName('fates_allom_lmode')
pid_allom_fmode = pstruct%GetIndexFromName('fates_allom_fmode')
pid_allom_amode = pstruct%GetIndexFromName('fates_allom_amode')
pid_allom_stmode = pstruct%GetIndexFromName('fates_allom_stmode')
pid_allom_cmode = pstruct%GetIndexFromName('fates_allom_cmode')
pid_allom_smode = pstruct%GetIndexFromName('fates_allom_smode')
pid_allom_dmode = pstruct%GetIndexFromName('fates_allom_dmode')
pid_allom_lapersa_int = pstruct%GetIndexFromName('fates_allom_la_per_sa_int')
pid_allom_lapersa_slp = pstruct%GetIndexFromName('fates_allom_la_per_sa_slp')
pid_allom_l2fr = pstruct%GetIndexFromName('fates_allom_l2fr')
pid_cnp_kp = pstruct%GetIndexFromName('fates_cnp_pid_kp')
pid_cnp_ki = pstruct%GetIndexFromName('fates_cnp_pid_ki')
pid_cnp_kd = pstruct%GetIndexFromName('fates_cnp_pid_kd')
pid_cnp_store_ovrflw_frac = pstruct%GetIndexFromName('fates_cnp_store_ovrflw_frac')
pid_cnp_nfix1 = pstruct%GetIndexFromName('fates_cnp_nfix1')
pid_allom_agbfrac = pstruct%GetIndexFromName('fates_allom_agb_frac')
pid_allom_d2h1 = pstruct%GetIndexFromName('fates_allom_d2h1')
pid_allom_d2h2 = pstruct%GetIndexFromName('fates_allom_d2h2')
pid_allom_d2h3 = pstruct%GetIndexFromName('fates_allom_d2h3')
pid_allom_d2l1 = pstruct%GetIndexFromName('fates_allom_d2bl1')
pid_allom_d2l2 = pstruct%GetIndexFromName('fates_allom_d2bl2')
pid_allom_d2l3 = pstruct%GetIndexFromName('fates_allom_d2bl3')
pid_allom_blca_ediff = pstruct%GetIndexFromName('fates_allom_blca_expnt_diff')
pid_allom_d2ca_max = pstruct%GetIndexFromName('fates_allom_d2ca_coefficient_max')
pid_allom_d2ca_min = pstruct%GetIndexFromName('fates_allom_d2ca_coefficient_min')
pid_allom_agb1 = pstruct%GetIndexFromName('fates_allom_agb1')
pid_allom_agb2 = pstruct%GetIndexFromName('fates_allom_agb2')
pid_allom_agb3 = pstruct%GetIndexFromName('fates_allom_agb3')
pid_allom_agb4 = pstruct%GetIndexFromName('fates_allom_agb4')
pid_allom_h2cd1 = pstruct%GetIndexFromName('fates_allom_h2cd1')
pid_allom_h2cd2 = pstruct%GetIndexFromName('fates_allom_h2cd2')
pid_allom_zroot_maxd = pstruct%GetIndexFromName('fates_allom_zroot_max_dbh')
pid_allom_zroot_maxz = pstruct%GetIndexFromName('fates_allom_zroot_max_z')
pid_allom_zroot_mind = pstruct%GetIndexFromName('fates_allom_zroot_min_dbh')
pid_allom_zroot_minz = pstruct%GetIndexFromName('fates_allom_zroot_min_z')
pid_allom_zroot_k = pstruct%GetIndexFromName('fates_allom_zroot_k')
pid_turnover_branch = pstruct%GetIndexFromName('fates_turnover_branch')
pid_cnp_nitr_store_ratio = pstruct%GetIndexFromName('fates_cnp_nitr_store_ratio')
pid_cnp_phos_store_ratio = pstruct%GetIndexFromName('fates_cnp_phos_store_ratio')
pid_turnover_leaf_canopy = pstruct%GetIndexFromName('fates_turnover_leaf_canopy')
pid_turnover_leaf_ustory = pstruct%GetIndexFromName('fates_turnover_leaf_ustory')
pid_stoich_nitr = pstruct%GetIndexFromName('fates_stoich_nitr')
pid_stoich_phos = pstruct%GetIndexFromName('fates_stoich_phos')
pid_alloc_organ_priority = pstruct%GetIndexFromName('fates_alloc_organ_priority')
pid_cnp_nitr_retrans = pstruct%GetIndexFromName('fates_cnp_turnover_nitr_retrans')
pid_cnp_phos_retrans = pstruct%GetIndexFromName('fates_cnp_turnover_phos_retrans')

end subroutine GetParameterIndices

subroutine CheckParameters

type(param_type), pointer :: param(:)
integer :: corr_id
real(r8) :: correction

param => pstruct%parameters

! Apply correction to cwd fractions
correction = 1._r8 - sum(param(pid_cwd_frac)%r_data_1d(:),dim=1)
corr_id = maxloc(param(pid_cwd_frac)%r_data_1d(:),dim=1)
param(pid_cwd_frac)%r_data_1d(corr_id) = param(pid_cwd_frac)%r_data_1d(corr_id) + correction


end subroutine CheckParameters


subroutine Transp2dInt(i_2d_in,i_2d_out)

! The FATES JSON parameter files have a legacy from the netcdf
Expand Down
Loading