Skip to content

Commit

Permalink
some more bugfixes and diagnostics on secondary forest tracking
Browse files Browse the repository at this point in the history
  • Loading branch information
ckoven committed Dec 19, 2018
1 parent 030b00f commit 32880fa
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 12 deletions.
2 changes: 1 addition & 1 deletion biogeochem/EDLoggingMortalityMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ subroutine IsItLoggingTime(is_master,currentSite)

else if(icode < 0 .and. icode > -366) then
! Logging event every year on specific day of year
if(hlm_day_of_year .eq. icode ) then
if(hlm_day_of_year .eq. abs(icode) ) then
logging_time = .true.
end if

Expand Down
19 changes: 12 additions & 7 deletions biogeochem/EDPatchDynamicsMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -358,9 +358,11 @@ subroutine spawn_patches( currentSite, bc_in)
call endrun(msg=errMsg(sourcefile, __LINE__))
end if

! figure out whether the receiver patch for disturbance from this patch will be primary or secondary land
! receiver patch is primary forest only if both the donor patch is primary forest and the dominant disturbance type is not logging
if (currentPatch%anthro_disturbance_label .eq. primaryforest .and. &
currentPatch%disturbance_rates(dtype_ilog) .lt. currentPatch%disturbance_rates(dtype_ifall) .and. &
currentPatch%disturbance_rates(dtype_ilog) .lt. currentPatch%disturbance_rates(dtype_ifire) ) then
(currentPatch%disturbance_rates(dtype_ilog) .lt. currentPatch%disturbance_rates(dtype_ifall) .or. &
currentPatch%disturbance_rates(dtype_ilog) .lt. currentPatch%disturbance_rates(dtype_ifire)) ) then

site_areadis_primary = site_areadis_primary + currentPatch%area * currentPatch%disturbance_rate
else
Expand All @@ -379,6 +381,7 @@ subroutine spawn_patches( currentSite, bc_in)
age = 0.0_r8

! create two empty patches, to absorb newly disturbed primary and secondary forest area
! first create patch to receive primary forest area
if ( site_areadis_primary .gt. 0.0_r8) then
allocate(new_patch_primary)
call create_patch(currentSite, new_patch_primary, age, site_areadis_primary, &
Expand All @@ -388,6 +391,7 @@ subroutine spawn_patches( currentSite, bc_in)
new_patch_primary%shortest => null()
endif

! next create patch to receive secondary forest area
if ( site_areadis_secondary .gt. 0.0_r8) then
allocate(new_patch_secondary)
call create_patch(currentSite, new_patch_secondary, age, site_areadis_secondary, &
Expand All @@ -402,9 +406,10 @@ subroutine spawn_patches( currentSite, bc_in)
do while(associated(currentPatch))

! figure out whether the receiver patch for disturbance from this patch will be primary or secondary land
! receiver patch is primary forest only if both the donor patch is primary forest and the dominant disturbance type is not logging
if (currentPatch%anthro_disturbance_label .eq. primaryforest .and. &
currentPatch%disturbance_rates(dtype_ilog) .lt. currentPatch%disturbance_rates(dtype_ifall) .and. &
currentPatch%disturbance_rates(dtype_ilog) .lt. currentPatch%disturbance_rates(dtype_ifire) ) then
(currentPatch%disturbance_rates(dtype_ilog) .lt. currentPatch%disturbance_rates(dtype_ifall) .or. &
currentPatch%disturbance_rates(dtype_ilog) .lt. currentPatch%disturbance_rates(dtype_ifire) ) ) then
new_patch => new_patch_primary
else
new_patch => new_patch_secondary
Expand All @@ -413,11 +418,11 @@ subroutine spawn_patches( currentSite, bc_in)
! This is the amount of patch area that is disturbed, and donated by the donor
patch_site_areadis = currentPatch%area * currentPatch%disturbance_rate

! for the secondary forest case, if the dominant disturbance from this patch is non-anthropogenic,
! for the case where the donating patch is secondary forest, if the dominant disturbance from this patch is non-anthropogenic,
! we need to average in the time-since-anthropogenic-disturbance from the donor patch into that of the receiver patch
if ( currentPatch%anthro_disturbance_label .eq. secondaryforest .and. &
currentPatch%disturbance_rates(dtype_ilog) .lt. currentPatch%disturbance_rates(dtype_ifall) .and. &
currentPatch%disturbance_rates(dtype_ilog) .lt. currentPatch%disturbance_rates(dtype_ifire) ) then
(currentPatch%disturbance_rates(dtype_ilog) .lt. currentPatch%disturbance_rates(dtype_ifall) .or. &
currentPatch%disturbance_rates(dtype_ilog) .lt. currentPatch%disturbance_rates(dtype_ifire) ) ) then

new_patch%age_since_anthro_disturbance = new_patch%age_since_anthro_disturbance + &
currentPatch%age_since_anthro_disturbance * (patch_site_areadis / site_areadis_secondary)
Expand Down
32 changes: 28 additions & 4 deletions main/FatesHistoryInterfaceMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,8 @@ module FatesHistoryInterfaceMod
integer, private :: ih_livestem_mr_si
integer, private :: ih_livecroot_mr_si
integer, private :: ih_fraction_secondary_forest_si
integer, private :: ih_biomass_secondary_forest_si
integer, private :: ih_woodproduct_si

! Indices to (site x scpf) variables
integer, private :: ih_nplant_si_scpf
Expand Down Expand Up @@ -1499,9 +1501,11 @@ subroutine update_history_dyn(this,nc,nsites,sites)
hio_npatches_si_age => this%hvars(ih_npatches_si_age)%r82d, &
hio_zstar_si_age => this%hvars(ih_zstar_si_age)%r82d, &
hio_biomass_si_age => this%hvars(ih_biomass_si_age)%r82d, &
hio_fraction_secondary_forest_si => this%hvars(ih_fraction_secondary_forest_si)%r81d, &
hio_agesince_anthrodist_si_age => this%hvars(ih_agesince_anthrodist_si_age)%r82d, &
hio_secondaryforest_area_si_age => this%hvars(ih_secondaryforest_area_si_age)%r82d, &
hio_fraction_secondary_forest_si => this%hvars(ih_fraction_secondary_forest_si)%r81d, &
hio_biomass_secondary_forest_si => this%hvars(ih_biomass_secondary_forest_si)%r81d, &
hio_woodproduct_si => this%hvars(ih_woodproduct_si)%r81d, &
hio_agesince_anthrodist_si_age => this%hvars(ih_agesince_anthrodist_si_age)%r82d, &
hio_secondaryforest_area_si_age => this%hvars(ih_secondaryforest_area_si_age)%r82d, &
hio_canopy_height_dist_si_height => this%hvars(ih_canopy_height_dist_si_height)%r82d, &
hio_leaf_height_dist_si_height => this%hvars(ih_leaf_height_dist_si_height)%r82d, &
hio_litter_moisture_si_fuel => this%hvars(ih_litter_moisture_si_fuel)%r82d, &
Expand Down Expand Up @@ -1549,6 +1553,9 @@ subroutine update_history_dyn(this,nc,nsites,sites)
hio_seed_bank_si(io_si) = sum(sites(s)%seed_bank) * g_per_kg

hio_canopy_spread_si(io_si) = sites(s)%spread

! track total wood product accumulation at the site level
hio_woodproduct_si(io_si) = sites(s)%resources_management%trunk_product_site * AREA_INV

ipa = 0
cpatch => sites(s)%oldest_patch
Expand Down Expand Up @@ -1714,6 +1721,12 @@ subroutine update_history_dyn(this,nc,nsites,sites)
hio_biomass_si_age(io_si,cpatch%age_class) = hio_biomass_si_age(io_si,cpatch%age_class) &
+ total_c * ccohort%n * AREA_INV

! track the total biomass on all secondary lands
if ( cpatch%anthro_disturbance_label .eq. secondaryforest ) then
hio_biomass_secondary_forest_si(io_si) = hio_biomass_secondary_forest_si(io_si) + &
total_c * ccohort%n * AREA_INV
endif

! Site by Size-Class x PFT (SCPF)
! ------------------------------------------------------------------------

Expand Down Expand Up @@ -3236,7 +3249,18 @@ subroutine define_history_vars(this, initialize_variables)
avgflag='A', vtype=site_r8, hlms='CLM:ALM', flushval=0.0_r8, upfreq=1, &
ivar=ivar, initialize=initialize_variables, index = ih_fraction_secondary_forest_si )

call this%set_history_var(vname='SECONDARY_AREA_BY_AGE_SINCE_ANTHRO_DIST', units='m2/m2', &
call this%set_history_var(vname='WOOD_PRODUCT', units='kgC/m2', &
long='Total wood product from logging', use_default='inactive', &
avgflag='A', vtype=site_r8, hlms='CLM:ALM', flushval=0.0_r8, upfreq=1, &
ivar=ivar, initialize=initialize_variables, index = ih_woodproduct_si )

call this%set_history_var(vname='SECONDARY_FOREST_BIOMASS', units='kgC/m2', &
long='Biomass on secondary lands (per total site area, mult by SECONDARY_FOREST_FRACTION to get per secondary forest area)',&
use_default='inactive', &
avgflag='A', vtype=site_r8, hlms='CLM:ALM', flushval=0.0_r8, upfreq=1, &
ivar=ivar, initialize=initialize_variables, index = ih_biomass_secondary_forest_si )

call this%set_history_var(vname='SECONDARY_AREA_AGE_ANTHRO_DIST', units='m2/m2', &
long='Secondary forest patch area age distribution since anthropgenic disturbance', use_default='inactive', &
avgflag='A', vtype=site_age_r8, hlms='CLM:ALM', flushval=0.0_r8, upfreq=1, &
ivar=ivar, initialize=initialize_variables, index = ih_agesince_anthrodist_si_age )
Expand Down

0 comments on commit 32880fa

Please sign in to comment.