Skip to content

Commit

Permalink
Merge pull request #1291 from sshu88/fatesluc_cbasedhrv_v2
Browse files Browse the repository at this point in the history
Bug fix for issue #1289
  • Loading branch information
glemieux authored Dec 9, 2024
2 parents 02ee145 + 77e8948 commit 296e1d6
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 24 deletions.
45 changes: 21 additions & 24 deletions biogeochem/EDLoggingMortalityMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ module EDLoggingMortalityMod
use FatesConstantsMod , only : hlm_harvest_area_fraction
use FatesConstantsMod , only : hlm_harvest_carbon
use FatesConstantsMod, only : fates_check_param_set
use FatesConstantsMod, only : fates_no_harvest_debt, fates_with_harvest_debt, fates_bypass_harvest_debt

use FatesInterfaceTypesMod , only : numpft
use FatesLandUseChangeMod, only : GetInitLanduseHarvestRate
use FatesLandUseChangeMod, only : GetLUHStatedata
Expand Down Expand Up @@ -235,9 +237,6 @@ subroutine LoggingMortality_frac( currentSite, bc_in, pft_i, dbh, canopy_layer,
integer, intent(out) :: harvest_tag(:) ! tag to record the harvest status
! for the calculation of harvest debt in C-based
! harvest mode
! 0 - successful;
! 1 - unsuccessful since not enough carbon
! 2 - not applicable

! Local variables
integer :: cur_harvest_tag ! the harvest tag of the cohort today
Expand Down Expand Up @@ -278,10 +277,11 @@ subroutine LoggingMortality_frac( currentSite, bc_in, pft_i, dbh, canopy_layer,
harvest_rate = 0._r8
endif

! For area-based harvest, harvest_tag shall always be 2 (not applicable).
harvest_tag = 2
cur_harvest_tag = 2
elseif (logging_time) then
! For area-based harvest, harvest_tag shall always be fates_bypass_harvest_debt (not applicable).
harvest_tag = fates_bypass_harvest_debt
cur_harvest_tag = fates_bypass_harvest_debt

elseif (logging_time) then

! Pass logging rates to cohort level

Expand Down Expand Up @@ -312,8 +312,8 @@ subroutine LoggingMortality_frac( currentSite, bc_in, pft_i, dbh, canopy_layer,
hlm_harvest_rates, frac_site_primary, frac_site_secondary, secondary_young_fraction, secondary_age, harvest_rate)

! For area-based harvest, harvest_tag shall always be 2 (not applicable).
harvest_tag = 2
cur_harvest_tag = 2
harvest_tag = fates_bypass_harvest_debt
cur_harvest_tag = fates_bypass_harvest_debt

if (fates_global_verbose()) then
write(fates_log(), *) 'Successfully Read Harvest Rate from HLM.', hlm_harvest_rates(:), harvest_rate
Expand All @@ -336,14 +336,14 @@ subroutine LoggingMortality_frac( currentSite, bc_in, pft_i, dbh, canopy_layer,
else
harvest_rate = 0._r8
! For area-based harvest, harvest_tag shall always be 2 (not applicable).
harvest_tag = 2
cur_harvest_tag = 2
harvest_tag = fates_bypass_harvest_debt
cur_harvest_tag = fates_bypass_harvest_debt
endif

! transfer of area to secondary land is based on overall area affected, not just logged crown area
! l_degrad accounts for the affected area between logged crowns
if(prt_params%woody(pft_i) == itrue)then ! only set logging rates for trees
if (cur_harvest_tag == 0) then
if (cur_harvest_tag == fates_no_harvest_debt .or. cur_harvest_tag == fates_bypass_harvest_debt) then
! direct logging rates, based on dbh min and max criteria
if (dbh >= logging_dbhmin .and. .not. &
((logging_dbhmax < fates_check_param_set) .and. (dbh >= logging_dbhmax )) ) then
Expand Down Expand Up @@ -618,10 +618,7 @@ subroutine get_harvest_rate_carbon (patch_land_use_label, hlm_harvest_catnames,
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
integer, intent(inout) :: harvest_tag(:) ! 0. normal harvest; 1. current site does not have enough C but
! can perform harvest by ignoring criteria; 2. current site does
! not have enough carbon
! This harvest tag shall be a patch level variable but since all
integer, intent(inout) :: harvest_tag(:) ! This harvest tag can be raused to patch level but since all
! logging functions happen within cohort loop we can only put the
! calculation here. Can think about optimizing the logging calculation
! in the future.
Expand All @@ -641,7 +638,7 @@ subroutine get_harvest_rate_carbon (patch_land_use_label, hlm_harvest_catnames,
harvest_rate = 0._r8
harvest_rate_c = 0._r8
harvest_rate_supply = 0._r8
harvest_tag(:) = 2
harvest_tag(:) = fates_bypass_harvest_debt

! Since we have five harvest categories from forcing data but in FATES non-forest harvest
! is merged with forest harvest, we only have three logging type in FATES (primary, secondary
Expand Down Expand Up @@ -674,29 +671,29 @@ subroutine get_harvest_rate_carbon (patch_land_use_label, hlm_harvest_catnames,
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)
harvest_tag(h_index) = 0
harvest_tag(h_index) = fates_no_harvest_debt
else
harvest_tag(h_index) = 1
harvest_tag(h_index) = fates_with_harvest_debt
end if
end if
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
harvest_rate_supply = harvest_rate_supply + harvestable_forest_c(h_index)
harvest_tag(h_index) = 0
harvest_tag(h_index) = fates_no_harvest_debt
else
harvest_tag(h_index) = 1
harvest_tag(h_index) = fates_with_harvest_debt
end if
end if
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
harvest_rate_supply = harvest_rate_supply + harvestable_forest_c(h_index)
harvest_tag(h_index) = 0
harvest_tag(h_index) = fates_no_harvest_debt
else
harvest_tag(h_index) = 1
harvest_tag(h_index) = fates_with_harvest_debt
end if
end if
end if
Expand Down Expand Up @@ -1262,7 +1259,7 @@ subroutine get_harvest_debt(site_in, bc_in, harvest_tag)
end do
! Next we get the harvest debt through the harvest tag
do h_index = 1, hlm_num_lu_harvest_cats
if (harvest_tag(h_index) .eq. 1) then
if (harvest_tag(h_index) .eq. fates_with_harvest_debt) then
if(bc_in%hlm_harvest_catnames(h_index) .eq. "HARVEST_VH1") then
site_in%resources_management%harvest_debt = site_in%resources_management%harvest_debt + &
harvest_debt_pri
Expand Down
5 changes: 5 additions & 0 deletions main/FatesConstantsMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,11 @@ module FatesConstantsMod
integer, parameter, public :: hlm_harvest_area_fraction = 1 ! Code for harvesting by area
integer, parameter, public :: hlm_harvest_carbon = 2 ! Code for harvesting based on carbon extracted.

! integer labels for specifying harvest debt status
integer, parameter, public :: fates_no_harvest_debt = 0
integer, parameter, public :: fates_with_harvest_debt = 1
integer, parameter, public :: fates_bypass_harvest_debt = 2 ! Do not calculate harvest debt for area based harvest

! integer labels for specifying leaf maintenance respiration models
integer, parameter, public :: lmrmodel_ryan_1991 = 1
integer, parameter, public :: lmrmodel_atkin_etal_2017 = 2
Expand Down

0 comments on commit 296e1d6

Please sign in to comment.