From df6c5e7c9c6ecf1a998c199a72e031175ae856ac Mon Sep 17 00:00:00 2001 From: Shijie Shu <92333861+sshu88@users.noreply.github.com> Date: Wed, 20 Nov 2024 11:03:59 -0800 Subject: [PATCH 1/3] Bug fix for issue #1289 Fix the issue of no wood product when forced by area-based harvest. https://github.com/NGEET/fates/issues/1289 --- biogeochem/EDLoggingMortalityMod.F90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/biogeochem/EDLoggingMortalityMod.F90 b/biogeochem/EDLoggingMortalityMod.F90 index 73ea7231e7..a091e4f3d6 100644 --- a/biogeochem/EDLoggingMortalityMod.F90 +++ b/biogeochem/EDLoggingMortalityMod.F90 @@ -291,7 +291,7 @@ subroutine LoggingMortality_frac( pft_i, dbh, canopy_layer, lmort_direct, & ! 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 == 0 .or. cur_harvest_tag == 2) 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 From 0eb912c11c467b63b9cce294521f36e6da47b0c2 Mon Sep 17 00:00:00 2001 From: Shijie Shu <92333861+sshu88@users.noreply.github.com> Date: Mon, 2 Dec 2024 13:46:00 -0800 Subject: [PATCH 2/3] Update EDLoggingMortalityMod.F90 Use named integer constants for "harvest_tag" --- biogeochem/EDLoggingMortalityMod.F90 | 33 ++++++++++++---------------- 1 file changed, 14 insertions(+), 19 deletions(-) diff --git a/biogeochem/EDLoggingMortalityMod.F90 b/biogeochem/EDLoggingMortalityMod.F90 index a091e4f3d6..c7d393f976 100644 --- a/biogeochem/EDLoggingMortalityMod.F90 +++ b/biogeochem/EDLoggingMortalityMod.F90 @@ -68,6 +68,7 @@ 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 implicit none private @@ -223,9 +224,6 @@ subroutine LoggingMortality_frac( pft_i, dbh, canopy_layer, lmort_direct, & 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 @@ -266,9 +264,9 @@ subroutine LoggingMortality_frac( pft_i, dbh, canopy_layer, lmort_direct, & call get_harvest_rate_area (patch_anthro_disturbance_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). - harvest_tag = 2 - cur_harvest_tag = 2 + ! 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 if (fates_global_verbose()) then write(fates_log(), *) 'Successfully Read Harvest Rate from HLM.', hlm_harvest_rates(:), harvest_rate @@ -291,7 +289,7 @@ subroutine LoggingMortality_frac( pft_i, dbh, canopy_layer, lmort_direct, & ! 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 .or. cur_harvest_tag == 2) 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 @@ -550,10 +548,7 @@ subroutine get_harvest_rate_carbon (patch_anthro_disturbance_label, hlm_harvest_ 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. @@ -573,7 +568,7 @@ subroutine get_harvest_rate_carbon (patch_anthro_disturbance_label, hlm_harvest_ 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 @@ -606,9 +601,9 @@ subroutine get_harvest_rate_carbon (patch_anthro_disturbance_label, hlm_harvest_ 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_anthro_disturbance_label .eq. secondaryforest .and. & @@ -616,9 +611,9 @@ subroutine get_harvest_rate_carbon (patch_anthro_disturbance_label, hlm_harvest_ 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_anthro_disturbance_label .eq. secondaryforest .and. & @@ -626,9 +621,9 @@ subroutine get_harvest_rate_carbon (patch_anthro_disturbance_label, hlm_harvest_ 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 @@ -1168,7 +1163,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 From 914393a4c69bf1f00e01750cecce69012d3b915d Mon Sep 17 00:00:00 2001 From: Shijie Shu <92333861+sshu88@users.noreply.github.com> Date: Mon, 2 Dec 2024 13:49:17 -0800 Subject: [PATCH 3/3] Update FatesConstantsMod.F90 Define named constants for "harvest_tag" --- main/FatesConstantsMod.F90 | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/main/FatesConstantsMod.F90 b/main/FatesConstantsMod.F90 index 66a9c56d8d..d38382a814 100644 --- a/main/FatesConstantsMod.F90 +++ b/main/FatesConstantsMod.F90 @@ -69,6 +69,10 @@ 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 ! Error Tolerances