Skip to content

Commit

Permalink
Merge pull request #7 from rgknox/mpaiao-pr-quadratic
Browse files Browse the repository at this point in the history
merge resolution
  • Loading branch information
mpaiao authored Jan 19, 2024
2 parents 0979a67 + a882f41 commit 24d3ea8
Show file tree
Hide file tree
Showing 51 changed files with 10,920 additions and 3,648 deletions.
291 changes: 169 additions & 122 deletions biogeochem/EDCanopyStructureMod.F90

Large diffs are not rendered by default.

44 changes: 22 additions & 22 deletions biogeochem/EDLoggingMortalityMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ module EDLoggingMortalityMod
use PRTGenericMod , only : sapw_organ, struct_organ, leaf_organ
use PRTGenericMod , only : fnrt_organ, store_organ, repro_organ
use FatesAllometryMod , only : set_root_fraction
use FatesConstantsMod , only : primaryforest, secondaryforest, secondary_age_threshold
use FatesConstantsMod , only : primaryland, secondaryland, secondary_age_threshold
use FatesConstantsMod , only : fates_tiny
use FatesConstantsMod , only : months_per_year, days_per_sec, years_per_day, g_per_kg
use FatesConstantsMod , only : hlm_harvest_area_fraction
Expand Down Expand Up @@ -199,7 +199,7 @@ subroutine LoggingMortality_frac( pft_i, dbh, canopy_layer, lmort_direct, &
lmort_collateral,lmort_infra, l_degrad, &
hlm_harvest_rates, hlm_harvest_catnames, &
hlm_harvest_units, &
patch_anthro_disturbance_label, secondary_age, &
patch_land_use_label, secondary_age, &
frac_site_primary, harvestable_forest_c, &
harvest_tag)

Expand All @@ -210,7 +210,7 @@ subroutine LoggingMortality_frac( pft_i, dbh, canopy_layer, lmort_direct, &
real(r8), intent(in) :: hlm_harvest_rates(:) ! annual harvest rate per hlm category
character(len=64), intent(in) :: hlm_harvest_catnames(:) ! names of hlm harvest categories
integer, intent(in) :: hlm_harvest_units ! unit type of hlm harvest rates: [area vs. mass]
integer, intent(in) :: patch_anthro_disturbance_label ! patch level anthro_disturbance_label
integer, intent(in) :: patch_land_use_label ! patch level land_use_label
real(r8), intent(in) :: secondary_age ! patch level age_since_anthro_disturbance
real(r8), intent(in) :: harvestable_forest_c(:) ! total harvestable forest carbon
! of all hlm harvest categories
Expand Down Expand Up @@ -265,7 +265,7 @@ subroutine LoggingMortality_frac( pft_i, dbh, canopy_layer, lmort_direct, &
! HARVEST_SH3 = harvest from secondary non-forest (assume this is young for biomass)

! Get the area-based harvest rates based on info passed to FATES from the boundary condition
call get_harvest_rate_area (patch_anthro_disturbance_label, hlm_harvest_catnames, &
call get_harvest_rate_area (patch_land_use_label, hlm_harvest_catnames, &
hlm_harvest_rates, frac_site_primary, secondary_age, harvest_rate)

! For area-based harvest, harvest_tag shall always be 2 (not applicable).
Expand All @@ -280,7 +280,7 @@ subroutine LoggingMortality_frac( pft_i, dbh, canopy_layer, lmort_direct, &
! 2=use carbon from hlm
! shall call another subroutine, which transfers biomass/carbon into fraction

call get_harvest_rate_carbon (patch_anthro_disturbance_label, hlm_harvest_catnames, &
call get_harvest_rate_carbon (patch_land_use_label, hlm_harvest_catnames, &
hlm_harvest_rates, secondary_age, harvestable_forest_c, &
harvest_rate, harvest_tag, cur_harvest_tag)

Expand Down Expand Up @@ -348,7 +348,7 @@ end subroutine LoggingMortality_frac

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

subroutine get_harvest_rate_area (patch_anthro_disturbance_label, hlm_harvest_catnames, hlm_harvest_rates, &
subroutine get_harvest_rate_area (patch_land_use_label, hlm_harvest_catnames, hlm_harvest_rates, &
frac_site_primary, secondary_age, harvest_rate)


Expand All @@ -361,7 +361,7 @@ subroutine get_harvest_rate_area (patch_anthro_disturbance_label, hlm_harvest_ca
! Arguments
real(r8), intent(in) :: hlm_harvest_rates(:) ! annual harvest rate per hlm category
character(len=64), intent(in) :: hlm_harvest_catnames(:) ! names of hlm harvest categories
integer, intent(in) :: patch_anthro_disturbance_label ! patch level anthro_disturbance_label
integer, intent(in) :: patch_land_use_label ! patch level land_use_label
real(r8), intent(in) :: secondary_age ! patch level age_since_anthro_disturbance
real(r8), intent(in) :: frac_site_primary
real(r8), intent(out) :: harvest_rate
Expand All @@ -374,17 +374,17 @@ subroutine get_harvest_rate_area (patch_anthro_disturbance_label, hlm_harvest_ca
! We do account forest only since non-forest harvest has geographical mismatch to LUH2 dataset
harvest_rate = 0._r8
do h_index = 1,hlm_num_lu_harvest_cats
if (patch_anthro_disturbance_label .eq. primaryforest) then
if (patch_land_use_label .eq. primaryland) then
if(hlm_harvest_catnames(h_index) .eq. "HARVEST_VH1" .or. &
hlm_harvest_catnames(h_index) .eq. "HARVEST_VH2") then
harvest_rate = harvest_rate + hlm_harvest_rates(h_index)
endif
else if (patch_anthro_disturbance_label .eq. secondaryforest .and. &
else if (patch_land_use_label .eq. secondaryland .and. &
secondary_age >= secondary_age_threshold) then
if(hlm_harvest_catnames(h_index) .eq. "HARVEST_SH1") then
harvest_rate = harvest_rate + hlm_harvest_rates(h_index)
endif
else if (patch_anthro_disturbance_label .eq. secondaryforest .and. &
else if (patch_land_use_label .eq. secondaryland .and. &
secondary_age < secondary_age_threshold) then
if(hlm_harvest_catnames(h_index) .eq. "HARVEST_SH2" .or. &
hlm_harvest_catnames(h_index) .eq. "HARVEST_SH3") then
Expand All @@ -396,7 +396,7 @@ subroutine get_harvest_rate_area (patch_anthro_disturbance_label, hlm_harvest_ca
! Normalize by site-level primary or secondary forest fraction
! since harvest_rate is specified as a fraction of the gridcell
! also need to put a cap so as not to harvest more primary or secondary area than there is in a gridcell
if (patch_anthro_disturbance_label .eq. primaryforest) then
if (patch_land_use_label .eq. primaryland) then
if (frac_site_primary .gt. fates_tiny) then
harvest_rate = min((harvest_rate / frac_site_primary),frac_site_primary)
else
Expand Down Expand Up @@ -511,18 +511,18 @@ subroutine get_harvestable_carbon (csite, site_area, hlm_harvest_catnames, harve
! since we have not separated forest vs. non-forest
! all carbon belongs to the forest categories
do h_index = 1,hlm_num_lu_harvest_cats
if (currentPatch%anthro_disturbance_label .eq. primaryforest) then
if (currentPatch%land_use_label .eq. primaryland) then
! Primary
if(hlm_harvest_catnames(h_index) .eq. "HARVEST_VH1") then
harvestable_forest_c(h_index) = harvestable_forest_c(h_index) + harvestable_patch_c
end if
else if (currentPatch%anthro_disturbance_label .eq. secondaryforest .and. &
else if (currentPatch%land_use_label .eq. secondaryland .and. &
currentPatch%age_since_anthro_disturbance >= secondary_age_threshold) then
! Secondary mature
if(hlm_harvest_catnames(h_index) .eq. "HARVEST_SH1") then
harvestable_forest_c(h_index) = harvestable_forest_c(h_index) + harvestable_patch_c
end if
else if (currentPatch%anthro_disturbance_label .eq. secondaryforest .and. &
else if (currentPatch%land_use_label .eq. secondaryland .and. &
currentPatch%age_since_anthro_disturbance < secondary_age_threshold) then
! Secondary young
if(hlm_harvest_catnames(h_index) .eq. "HARVEST_SH2") then
Expand All @@ -537,7 +537,7 @@ end subroutine get_harvestable_carbon

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

subroutine get_harvest_rate_carbon (patch_anthro_disturbance_label, hlm_harvest_catnames, &
subroutine get_harvest_rate_carbon (patch_land_use_label, hlm_harvest_catnames, &
hlm_harvest_rates, secondary_age, harvestable_forest_c, &
harvest_rate, harvest_tag, cur_harvest_tag)

Expand All @@ -550,7 +550,7 @@ subroutine get_harvest_rate_carbon (patch_anthro_disturbance_label, hlm_harvest_
! Arguments
real(r8), intent(in) :: hlm_harvest_rates(:) ! annual harvest rate per hlm category
character(len=64), intent(in) :: hlm_harvest_catnames(:) ! names of hlm harvest categories
integer, intent(in) :: patch_anthro_disturbance_label ! patch level anthro_disturbance_label
integer, intent(in) :: patch_land_use_label ! patch level land_use_label
real(r8), intent(in) :: secondary_age ! patch level age_since_anthro_disturbance
real(r8), intent(in) :: harvestable_forest_c(:) ! site level forest c matching criteria available for harvest, kgC site-1
real(r8), intent(out) :: harvest_rate ! area fraction
Expand Down Expand Up @@ -584,17 +584,17 @@ subroutine get_harvest_rate_carbon (patch_anthro_disturbance_label, hlm_harvest_
! mature and secondary young).
! Get the harvest rate from HLM
do h_index = 1,hlm_num_lu_harvest_cats
if (patch_anthro_disturbance_label .eq. primaryforest) then
if (patch_land_use_label .eq. primaryland) then
if(hlm_harvest_catnames(h_index) .eq. "HARVEST_VH1" .or. &
hlm_harvest_catnames(h_index) .eq. "HARVEST_VH2") then
harvest_rate_c = harvest_rate_c + hlm_harvest_rates(h_index)
endif
else if (patch_anthro_disturbance_label .eq. secondaryforest .and. &
else if (patch_land_use_label .eq. secondaryland .and. &
secondary_age >= secondary_age_threshold) then
if(hlm_harvest_catnames(h_index) .eq. "HARVEST_SH1") then
harvest_rate_c = harvest_rate_c + hlm_harvest_rates(h_index)
endif
else if (patch_anthro_disturbance_label .eq. secondaryforest .and. &
else if (patch_land_use_label .eq. secondaryland .and. &
secondary_age < secondary_age_threshold) then
if(hlm_harvest_catnames(h_index) .eq. "HARVEST_SH2" .or. &
hlm_harvest_catnames(h_index) .eq. "HARVEST_SH3") then
Expand All @@ -606,7 +606,7 @@ subroutine get_harvest_rate_carbon (patch_anthro_disturbance_label, hlm_harvest_
! Determine harvest status (succesful or not)
! Here only three categories are used
do h_index = 1,hlm_num_lu_harvest_cats
if (patch_anthro_disturbance_label .eq. primaryforest) then
if (patch_land_use_label .eq. primaryland) then
if(hlm_harvest_catnames(h_index) .eq. "HARVEST_VH1" ) then
if(harvestable_forest_c(h_index) >= harvest_rate_c) then
harvest_rate_supply = harvest_rate_supply + harvestable_forest_c(h_index)
Expand All @@ -615,7 +615,7 @@ subroutine get_harvest_rate_carbon (patch_anthro_disturbance_label, hlm_harvest_
harvest_tag(h_index) = 1
end if
end if
else if (patch_anthro_disturbance_label .eq. secondaryforest .and. &
else if (patch_land_use_label .eq. secondaryland .and. &
secondary_age >= secondary_age_threshold) then
if(hlm_harvest_catnames(h_index) .eq. "HARVEST_SH1" ) then
if(harvestable_forest_c(h_index) >= harvest_rate_c) then
Expand All @@ -625,7 +625,7 @@ subroutine get_harvest_rate_carbon (patch_anthro_disturbance_label, hlm_harvest_
harvest_tag(h_index) = 1
end if
end if
else if (patch_anthro_disturbance_label .eq. secondaryforest .and. &
else if (patch_land_use_label .eq. secondaryland .and. &
secondary_age < secondary_age_threshold) then
if(hlm_harvest_catnames(h_index) .eq. "HARVEST_SH2" ) then
if(harvestable_forest_c(h_index) >= harvest_rate_c) then
Expand Down
18 changes: 10 additions & 8 deletions biogeochem/EDMortalityFunctionsMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,18 @@ module EDMortalityFunctionsMod

contains

subroutine mortality_rates( cohort_in,bc_in,btran_ft, mean_temp, &
subroutine mortality_rates( cohort_in,bc_in, btran_ft, mean_temp, &
cmort,hmort,bmort, frmort,smort,asmort,dgmort )

! ============================================================================
! Calculate mortality rates from carbon storage, hydraulic cavitation,
! background and freezing and size and age dependent senescence
! ============================================================================

use FatesConstantsMod, only : tfrz => t_water_freeze_k_1atm
use FatesConstantsMod, only : fates_check_param_set
use DamageMainMod, only : GetDamageMortality
use FatesConstantsMod, only : tfrz => t_water_freeze_k_1atm
use FatesConstantsMod, only : fates_check_param_set
use DamageMainMod, only : GetDamageMortality
use EDParamsmod, only : soil_tfrz_thresh

type (fates_cohort_type), intent(in) :: cohort_in
type (bc_in_type), intent(in) :: bc_in
Expand Down Expand Up @@ -156,7 +157,8 @@ subroutine mortality_rates( cohort_in,bc_in,btran_ft, mean_temp, &
hmort = 0.0_r8
endif
else
if(btran_ft(cohort_in%pft) <= hf_sm_threshold)then
if( ( btran_ft(cohort_in%pft) <= hf_sm_threshold ) .and. &
( ( minval(bc_in%t_soisno_sl) - tfrz ) > soil_tfrz_thresh ) ) then
hmort = EDPftvarcon_inst%mort_scalar_hydrfailure(cohort_in%pft)
else
hmort = 0.0_r8
Expand Down Expand Up @@ -232,7 +234,7 @@ end subroutine mortality_rates
! ============================================================================

subroutine Mortality_Derivative( currentSite, currentCohort, bc_in, btran_ft, &
mean_temp, anthro_disturbance_label, age_since_anthro_disturbance, &
mean_temp, land_use_label, age_since_anthro_disturbance, &
frac_site_primary, harvestable_forest_c, harvest_tag)

!
Expand All @@ -250,7 +252,7 @@ subroutine Mortality_Derivative( currentSite, currentCohort, bc_in, btran_ft, &
type(bc_in_type), intent(in) :: bc_in
real(r8), intent(in) :: btran_ft(maxpft)
real(r8), intent(in) :: mean_temp
integer, intent(in) :: anthro_disturbance_label
integer, intent(in) :: land_use_label
real(r8), intent(in) :: age_since_anthro_disturbance
real(r8), intent(in) :: frac_site_primary

Expand Down Expand Up @@ -289,7 +291,7 @@ subroutine Mortality_Derivative( currentSite, currentCohort, bc_in, btran_ft, &
bc_in%hlm_harvest_rates, &
bc_in%hlm_harvest_catnames, &
bc_in%hlm_harvest_units, &
anthro_disturbance_label, &
land_use_label, &
age_since_anthro_disturbance, &
frac_site_primary, harvestable_forest_c, harvest_tag)

Expand Down
Loading

0 comments on commit 24d3ea8

Please sign in to comment.