Skip to content
This repository has been archived by the owner on Sep 14, 2018. It is now read-only.

Commit

Permalink
Merge pull request #4 from rgknox/yi-logging-v3
Browse files Browse the repository at this point in the history
Added disturbance index names and partial addition of logging NL entry
  • Loading branch information
xuyi02 authored Aug 28, 2017
2 parents 48b01dd + 113fd8f commit 65bd080
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 29 deletions.
12 changes: 9 additions & 3 deletions biogeochem/EDLoggingMortalityMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ module EDLoggingMortalityMod
use EDTypesMod , only : ncwd
use EDTypesMod , only : ed_site_type
use EDTypesMod , only : ed_resources_management_type
use EDTypesMod , only : dtype_ilog
use EDTypesMod , only : dtype_ifall
use EDTypesMod , only : dtype_ifire
use EDPftvarcon , only : EDPftvarcon_inst
use EDParamsMod , only : logging_event_code
use EDParamsMod , only : logging_dbhmin
Expand All @@ -31,7 +34,7 @@ module EDLoggingMortalityMod
use FatesInterfaceMod , only : hlm_current_day
use FatesInterfaceMod , only : hlm_model_day
use FatesInterfaceMod , only : hlm_day_of_year
use FatesConstantsMod , only : itrue
use FatesConstantsMod , only : itrue,ifalse
use FatesGlobals , only : endrun => fates_endrun
use FatesGlobals , only : fates_log
use shr_log_mod , only : errMsg => shr_log_errMsg
Expand Down Expand Up @@ -72,6 +75,9 @@ subroutine IsItLoggingTime(is_master)
logging_time = .false.
icode = int(logging_event_code)

! if(hlm_use_logging.eq.ifalse) return ! Don't turn on until fates-clm adds
! this to the interface (RGK 08-2017)

if(icode .eq. 1) then
! Logging is turned off
logging_time = .false.
Expand Down Expand Up @@ -239,8 +245,8 @@ subroutine logging_litter_fluxes(cp_Site, cp_target, new_patch_target, patch_sit
currentCohort => currentPatch%shortest
do while(associated(currentCohort))
p = currentCohort%pft
if(currentPatch%disturbance_rates(3) > currentPatch%disturbance_rates(2) .and. &
currentPatch%disturbance_rates(3) > currentPatch%disturbance_rates(1) )then
if(currentPatch%disturbance_rates(dtype_ilog) > currentPatch%disturbance_rates(dtype_ifire) .and. &
currentPatch%disturbance_rates(dtype_ilog) > currentPatch%disturbance_rates(dtype_ifall) )then
!mortality is dominant disturbance

if(EDPftvarcon_inst%woody(p) == 1)then
Expand Down
49 changes: 26 additions & 23 deletions biogeochem/EDPatchDynamicsMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ module EDPatchDynamicsMod
use EDTypesMod , only : min_patch_area
use EDTypesMod , only : nclmax
use EDTypesMod , only : maxpft
use EDTypesMod , only : dtype_ifall
use EDTypesMod , only : dtype_ilog
use EDTypesMod , only : dtype_ifire
use FatesInterfaceMod , only : hlm_use_planthydro
use FatesInterfaceMod , only : hlm_numlevgrnd
use FatesInterfaceMod , only : hlm_numlevsoil
Expand Down Expand Up @@ -128,7 +131,7 @@ subroutine disturbance_rates( site_in)

if(currentCohort%canopy_layer == 1)then

currentPatch%disturbance_rates(1) = currentPatch%disturbance_rates(1) + &
currentPatch%disturbance_rates(dtype_ifall) = currentPatch%disturbance_rates(dtype_ifall) + &
fates_mortality_disturbance_fraction * &
min(1.0_r8,currentCohort%dmort)*hlm_freq_day*currentCohort%c_area/currentPatch%area

Expand Down Expand Up @@ -156,7 +159,7 @@ subroutine disturbance_rates( site_in)

!May need to change currentCohort%c_area
!disturbance_rates will be reset to 0 at the end of spawn_patches
currentPatch%disturbance_rates(3) = currentPatch%disturbance_rates(3) + &
currentPatch%disturbance_rates(dtype_ilog) = currentPatch%disturbance_rates(dtype_ilog) + &
min(1.0_r8, currentCohort%lmort_logging + &
currentCohort%lmort_collateral + &
currentCohort%lmort_infra ) * &
Expand All @@ -175,18 +178,18 @@ subroutine disturbance_rates( site_in)
! if fires occur at site
! Fudge - fires can't burn the whole patch, as this causes /0 errors.
! This is accumulating the daily fires over the whole 30 day patch generation phase.
currentPatch%disturbance_rates(2) = min(0.99_r8,currentPatch%disturbance_rates(2) + currentPatch%frac_burnt)
currentPatch%disturbance_rates(dtype_ifire) = min(0.99_r8,currentPatch%disturbance_rates(dtype_ifire) + currentPatch%frac_burnt)

if (currentPatch%disturbance_rates(2) > 0.98_r8)then
write(fates_log(),*) 'very high fire areas',currentPatch%disturbance_rates(2),currentPatch%frac_burnt
if (currentPatch%disturbance_rates(dtype_ifire) > 0.98_r8)then
write(fates_log(),*) 'very high fire areas',currentPatch%disturbance_rates(dtype_ifire),currentPatch%frac_burnt
endif

if (currentPatch%disturbance_rates(3) > currentPatch%disturbance_rates(1) .and. &
currentPatch%disturbance_rates(3) > currentPatch%disturbance_rates(2) ) then
if (currentPatch%disturbance_rates(dtype_ilog) > currentPatch%disturbance_rates(dtype_ifall) .and. &
currentPatch%disturbance_rates(dtype_ilog) > currentPatch%disturbance_rates(dtype_ifire) ) then

! logging disturbance dominates
! Y.X. 3/2017
currentPatch%disturbance_rate = currentPatch%disturbance_rates(3)
currentPatch%disturbance_rate = currentPatch%disturbance_rates(dtype_ilog)

currentCohort => currentPatch%shortest
do while(associated(currentCohort))
Expand All @@ -200,10 +203,10 @@ subroutine disturbance_rates( site_in)
currentCohort => currentCohort%taller
enddo !currentCohort

elseif (currentPatch%disturbance_rates(2) > currentPatch%disturbance_rates(1) .and. &
currentPatch%disturbance_rates(2) > currentPatch%disturbance_rates(3) ) then ! DISTURBANCE IS FIRE
elseif (currentPatch%disturbance_rates(dtype_ifire) > currentPatch%disturbance_rates(dtype_ifall) .and. &
currentPatch%disturbance_rates(dtype_ifire) > currentPatch%disturbance_rates(dtype_ilog) ) then ! DISTURBANCE IS FIRE

currentPatch%disturbance_rate = currentPatch%disturbance_rates(2)
currentPatch%disturbance_rate = currentPatch%disturbance_rates(dtype_ifire)

! RGK 02-18-2014
! Since treefall mortality is not actually being applied
Expand All @@ -230,9 +233,9 @@ subroutine disturbance_rates( site_in)
currentCohort => currentCohort%taller
enddo !currentCohort

elseif (currentPatch%disturbance_rates(1) > currentPatch%disturbance_rates(2) .and. &
currentPatch%disturbance_rates(1) > currentPatch%disturbance_rates(3) ) then
currentPatch%disturbance_rate = currentPatch%disturbance_rates(1) ! DISTURBANCE IS MORTALITY
elseif (currentPatch%disturbance_rates(dtype_ifall) > currentPatch%disturbance_rates(dtype_ifire) .and. &
currentPatch%disturbance_rates(dtype_ifall) > currentPatch%disturbance_rates(dtype_ilog) ) then
currentPatch%disturbance_rate = currentPatch%disturbance_rates(dtype_ifall) ! DISTURBANCE IS MORTALITY

else
write(fates_log(),*) 'A dominant disturbance mode was not identified somehow'
Expand All @@ -241,11 +244,11 @@ subroutine disturbance_rates( site_in)
endif

site_in%disturbance_mortality = site_in%disturbance_mortality + &
currentPatch%disturbance_rates(1)*currentPatch%area/area
currentPatch%disturbance_rates(dtype_ifall)*currentPatch%area/area

!disturbance_logging
site_in%disturbance_logging = site_in%disturbance_logging + &
currentPatch%disturbance_rates(3)*currentPatch%area/area
currentPatch%disturbance_rates(dtype_ilog)*currentPatch%area/area

currentPatch => currentPatch%younger

Expand Down Expand Up @@ -413,8 +416,8 @@ subroutine spawn_patches( currentSite, bc_in)
nc%canopy_layer_yesterday = 1._r8

! treefall mortality is the dominant disturbance
if(currentPatch%disturbance_rates(1) > currentPatch%disturbance_rates(2) .and. &
currentPatch%disturbance_rates(1) > currentPatch%disturbance_rates(3))then
if(currentPatch%disturbance_rates(dtype_ifall) > currentPatch%disturbance_rates(dtype_ifire) .and. &
currentPatch%disturbance_rates(dtype_ifall) > currentPatch%disturbance_rates(dtype_ilog))then
if(currentCohort%canopy_layer == 1)then
! In the donor patch we are left with fewer trees because the area has decreased
! the plant density for large trees does not actually decrease in the donor patch
Expand Down Expand Up @@ -495,8 +498,8 @@ subroutine spawn_patches( currentSite, bc_in)
endif

! Fire is the dominant disturbance
elseif (currentPatch%disturbance_rates(2) > currentPatch%disturbance_rates(1) .and. &
currentPatch%disturbance_rates(2) > currentPatch%disturbance_rates(3)) then !fire
elseif (currentPatch%disturbance_rates(dtype_ifire) > currentPatch%disturbance_rates(dtype_ifall) .and. &
currentPatch%disturbance_rates(dtype_ifire) > currentPatch%disturbance_rates(dtype_ilog)) then !fire

! Number of members in the new patch, before we impose fire survivorship
nc%n = currentCohort%n * patch_site_areadis/currentPatch%area
Expand All @@ -518,8 +521,8 @@ subroutine spawn_patches( currentSite, bc_in)
nc%lmort_infra = 0.0_r8

! Logging is the dominant disturbance
elseif (currentPatch%disturbance_rates(3) > currentPatch%disturbance_rates(1) .and. &
currentPatch%disturbance_rates(3) > currentPatch%disturbance_rates(2)) then ! Logging
elseif (currentPatch%disturbance_rates(dtype_ilog) > currentPatch%disturbance_rates(dtype_ifall) .and. &
currentPatch%disturbance_rates(dtype_ilog) > currentPatch%disturbance_rates(dtype_ifire)) then ! Logging

if(EDPftvarcon_inst%woody(currentCohort%pft) == 1)then
! Move the survival trees into new patch
Expand Down Expand Up @@ -995,7 +998,7 @@ subroutine mortality_litter_fluxes(currentSite, cp_target, new_patch_target, pat
currentCohort => currentPatch%shortest
do while(associated(currentCohort))
p = currentCohort%pft
if(currentPatch%disturbance_rates(1) > currentPatch%disturbance_rates(2))then !mortality is dominant disturbance
if(currentPatch%disturbance_rates(dtype_ifall) > currentPatch%disturbance_rates(dtype_ifire))then !mortality is dominant disturbance
if(currentCohort%canopy_layer == 1)then
!currentCohort%dmort = mortality_rates(currentCohort)
!the disturbance calculations are done with the previous n, c_area and d_mort. So it's probably &
Expand Down
6 changes: 4 additions & 2 deletions main/EDTypesMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,10 @@ module EDTypesMod
integer , parameter :: external_recruitment = 0 ! external recruitment flag 1=yes
integer , parameter :: SENES = 10 ! Window of time over which we track temp for cold sensecence (days)
real(r8), parameter :: DINC_ED = 1.0_r8 ! size of LAI bins.
!integer , parameter :: N_DIST_TYPES = 2 ! number of disturbance types (mortality, fire)
integer , parameter :: N_DIST_TYPES = 3 ! add selective logging disturbance
integer , parameter :: N_DIST_TYPES = 3 ! Disturbance Modes 1) tree-fall, 2) fire, 3) logging
integer , parameter :: dtype_ifall = 1 ! index for naturally occuring tree-fall generated event
integer , parameter :: dtype_ifire = 2 ! index for fire generated disturbance event
integer , parameter :: dtype_ilog = 3 ! index for logging generated disturbance event

! SPITFIRE
integer, parameter :: NCWD = 4 ! number of coarse woody debris pools (twig,s branch,l branch, trunk)
Expand Down
24 changes: 23 additions & 1 deletion main/FatesInterfaceMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ module FatesInterfaceMod
use EDTypesMod , only : nlevleaf
use EDTypesMod , only : maxpft
use FatesConstantsMod , only : r8 => fates_r8
use FatesConstantsMod , only : itrue
use FatesConstantsMod , only : itrue,ifalse
use FatesGlobals , only : fates_global_verbose
use FatesGlobals , only : fates_log
use FatesGlobals , only : endrun => fates_endrun
Expand Down Expand Up @@ -121,6 +121,10 @@ module FatesInterfaceMod
integer, protected :: hlm_use_spitfire ! This flag signals whether or not to use SPITFIRE
! 1 = TRUE, 0 = FALSE


integer, protected :: hlm_use_logging ! This flag signals whether or not to use
! the logging module

integer, protected :: hlm_use_planthydro ! This flag signals whether or not to use
! plant hydraulics (bchristo/xu methods)
! 1 = TRUE, 0 = FALSE
Expand Down Expand Up @@ -1120,6 +1124,11 @@ subroutine set_fates_ctrlparms(tag,ival,rval,cval)
hlm_use_vertsoilc = unset_int
hlm_use_spitfire = unset_int
hlm_use_planthydro = unset_int
hlm_use_logging = ifalse ! (RGK: to allow backwards compatibility
! defaulting to FALSE, this will allow
! the call from the HLM to not necessarily
! be forced to exist. Will set this to unset
! along with other non backwards compatible changes
hlm_use_ed_st3 = unset_int
hlm_use_ed_prescribed_phys = unset_int
hlm_use_inventory_init = unset_int
Expand Down Expand Up @@ -1161,6 +1170,13 @@ subroutine set_fates_ctrlparms(tag,ival,rval,cval)
call endrun(msg=errMsg(sourcefile, __LINE__))
end if

if ( .not.((hlm_use_logging .eq.1).or.(hlm_use_logging.eq.0)) ) then
if (fates_global_verbose()) then
write(fates_log(), *) 'The FATES namelist planthydro flag must be 0 or 1, exiting'
end if
call endrun(msg=errMsg(sourcefile, __LINE__))
end if

if ( .not.((hlm_use_ed_st3.eq.1).or.(hlm_use_ed_st3.eq.0)) ) then
if (fates_global_verbose()) then
write(fates_log(), *) 'The FATES namelist stand structure flag must be 0 or 1, exiting'
Expand Down Expand Up @@ -1392,6 +1408,12 @@ subroutine set_fates_ctrlparms(tag,ival,rval,cval)
write(fates_log(),*) 'Transfering hlm_use_planthydro= ',ival,' to FATES'
end if

case('use_logging')
hlm_use_logging = ival
if (fates_global_verbose()) then
write(fates_log(),*) 'Transfering hlm_use_planthydro= ',ival,' to FATES'
end if

case('use_ed_st3')
hlm_use_ed_st3 = ival
if (fates_global_verbose()) then
Expand Down

0 comments on commit 65bd080

Please sign in to comment.