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 #5 from rgknox/yi-logging-v3
Browse files Browse the repository at this point in the history
removed unused patch logging variables, initialized site logging variables
  • Loading branch information
xuyi02 authored Aug 31, 2017
2 parents 65bd080 + 90d1ebe commit baa6eb6
Show file tree
Hide file tree
Showing 6 changed files with 210 additions and 220 deletions.
371 changes: 189 additions & 182 deletions biogeochem/EDLoggingMortalityMod.F90

Large diffs are not rendered by default.

18 changes: 2 additions & 16 deletions biogeochem/EDPatchDynamicsMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module EDPatchDynamicsMod
use EDCohortDynamicsMod , only : fuse_cohorts, sort_cohorts, insert_cohort
use EDtypesMod , only : ncwd, n_dbh_bins, ntol, area, dbhmax
use EDTypesMod , only : maxPatchesPerSite
use EDTypesMod , only : ed_site_type, ed_patch_type, ed_cohort_type, ed_resources_management_type
use EDTypesMod , only : ed_site_type, ed_patch_type, ed_cohort_type
use EDTypesMod , only : min_patch_area
use EDTypesMod , only : nclmax
use EDTypesMod , only : maxpft
Expand Down Expand Up @@ -86,8 +86,6 @@ subroutine disturbance_rates( site_in)
type (ed_patch_type) , pointer :: currentPatch
type (ed_cohort_type), pointer :: currentCohort

type (ed_resources_management_type) :: resources_management

real(r8) :: cmort
real(r8) :: bmort
real(r8) :: hmort
Expand Down Expand Up @@ -142,7 +140,7 @@ subroutine disturbance_rates( site_in)
! Yi Xu 2017
! ---------------------------------------------------------------

if (currentPatch%logging==1 .and. logging_time) then
if (logging_time) then

! always call this function if turn on logging at the beginning
call LoggingMortality_rates(site_in, currentCohort%pft, currentCohort%dbh, &
Expand Down Expand Up @@ -630,11 +628,6 @@ subroutine spawn_patches( currentSite, bc_in)
call terminate_cohorts(currentSite, currentPatch, 2)
call sort_cohorts(currentPatch)

if (currentPatch%logging==1 .and. logging_time) then
currentPatch%after_spawn_patch= 1
else
currentPatch%after_spawn_patch= 0
endif
currentPatch => currentPatch%younger

enddo ! currentPatch patch loop.
Expand Down Expand Up @@ -1294,13 +1287,6 @@ subroutine zero_patch(cp_p)
currentPatch%sabs_dif(:) = 0.0_r8
currentPatch%zstar = 0.0_r8

!LOGGING
!kGC/m2
currentPatch%trunk_product = 0.0_r8
currentPatch%logging = 1 ! Currently, assume all patch=1, need to change in future
currentPatch%after_spawn_patch = 0


end subroutine zero_patch

! ============================================================================
Expand Down
3 changes: 3 additions & 0 deletions main/EDInitMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ subroutine zero_site( site_in )
site_in%CWD_BG_diagnostic_input_carbonflux(:) = 0._r8
site_in%leaf_litter_diagnostic_input_carbonflux(:) = 0._r8
site_in%root_litter_diagnostic_input_carbonflux(:) = 0._r8

! Resources management (logging/harvesting, etc)
site_in%resources_management%trunk_product_site = 0.0_r8

end subroutine zero_site

Expand Down
15 changes: 1 addition & 14 deletions main/EDMainMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ subroutine ed_ecosystem_dynamics(currentSite, bc_in)

! Call a routine that simply identifies if logging should occur
! This is limited to a global event until more structured event handling is enabled
call IsItLoggingTime(hlm_masterproc)
call IsItLoggingTime(hlm_masterproc,currentSite)

!**************************************************************************
! Fire, growth, biogeochemistry.
Expand Down Expand Up @@ -500,19 +500,6 @@ subroutine ed_total_balance_check (currentSite, call_index )

enddo !end cohort loop

! Modify biomass for logging
! Yi Xu
! 03/2017

if (currentPatch%logging==1 .and. currentPatch%after_spawn_patch==1) then

! turn off this flag after spawn patch , since flux_in and flux_out are cleaned in every balance check
currentPatch%after_spawn_patch = 0

end if



currentPatch => currentPatch%younger

enddo !end patch loop
Expand Down
6 changes: 0 additions & 6 deletions main/EDTypesMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -443,12 +443,6 @@ module EDTypesMod
! PLANT HYDRAULICS
type(ed_patch_hydr_type) , pointer :: pa_hydr ! All patch hydraulics data, see FatesHydraulicsMemMod.F90

! LOGGING EFFECTS

integer :: logging ! 1=logging; 0=no logging
integer :: after_spawn_patch ! 1=after spawn patch; 0=before spawn patch
real(r8) :: trunk_product ! kGC/m2

contains

end type ed_patch_type
Expand Down
17 changes: 15 additions & 2 deletions main/FatesRestartInterfaceMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ module FatesRestartInterfaceMod
integer, private :: ir_fates_to_bgc_this_ts_si
integer, private :: ir_fates_to_bgc_last_ts_si
integer, private :: ir_seedrainflux_si
integer, private :: ir_trunk_product_si
integer, private :: ir_ncohort_pa
integer, private :: ir_balive_co
integer, private :: ir_bdead_co
Expand Down Expand Up @@ -591,6 +592,12 @@ subroutine define_restart_vars(this, initialize_variables)
units='kgC/m2/year', flushval = flushzero, &
hlms='CLM:ALM', initialize=initialize_variables, ivar=ivar, index = ir_seedrainflux_si )

call this%set_restart_var(vname='fates_trunk_product_site', vtype=site_r8, &
long_name='Accumulate trunk product flux at site', &
units='kgC/m2', flushval = flushzero, &
hlms='CLM:ALM', initialize=initialize_variables, ivar=ivar, index = ir_trunk_product_si )


! -----------------------------------------------------------------------------------
! Variables stored within cohort vectors
! Note: Some of these are multi-dimensional variables in the patch/site dimension
Expand Down Expand Up @@ -1025,6 +1032,7 @@ subroutine set_restart_vectors(this,nc,nsites,sites)
rio_fates_to_bgc_this_ts_si => this%rvars(ir_fates_to_bgc_this_ts_si)%r81d, &
rio_fates_to_bgc_last_ts_si => this%rvars(ir_fates_to_bgc_last_ts_si)%r81d, &
rio_seedrainflux_si => this%rvars(ir_seedrainflux_si)%r81d, &
rio_trunk_product_si => this%rvars(ir_trunk_product_si)%r81d, &
rio_ncohort_pa => this%rvars(ir_ncohort_pa)%int1d, &
rio_balive_co => this%rvars(ir_balive_co)%r81d, &
rio_bdead_co => this%rvars(ir_bdead_co)%r81d, &
Expand Down Expand Up @@ -1310,8 +1318,11 @@ subroutine set_restart_vectors(this,nc,nsites,sites)
rio_fates_to_bgc_this_ts_si(io_idx_si) = sites(s)%fates_to_bgc_this_ts
rio_fates_to_bgc_last_ts_si(io_idx_si) = sites(s)%fates_to_bgc_last_ts
rio_seedrainflux_si(io_idx_si) = sites(s)%tot_seed_rain_flux


! Accumulated trunk product
rio_trunk_product_si(io_idx_si) = sites(s)%resources_management%trunk_product_site
! set numpatches for this column

rio_npatch_si(io_idx_si) = patchespersite

do i = 1,numWaterMem ! numWaterMem currently 10
Expand Down Expand Up @@ -1611,6 +1622,7 @@ subroutine get_restart_vectors(this, nc, nsites, sites)
rio_fates_to_bgc_this_ts_si => this%rvars(ir_fates_to_bgc_this_ts_si)%r81d, &
rio_fates_to_bgc_last_ts_si => this%rvars(ir_fates_to_bgc_last_ts_si)%r81d, &
rio_seedrainflux_si => this%rvars(ir_seedrainflux_si)%r81d, &
rio_trunk_product_si => this%rvars(ir_trunk_product_si)%r81d, &
rio_ncohort_pa => this%rvars(ir_ncohort_pa)%int1d, &
rio_balive_co => this%rvars(ir_balive_co)%r81d, &
rio_bdead_co => this%rvars(ir_bdead_co)%r81d, &
Expand Down Expand Up @@ -1893,7 +1905,8 @@ subroutine get_restart_vectors(this, nc, nsites, sites)
sites(s)%fates_to_bgc_this_ts = rio_fates_to_bgc_this_ts_si(io_idx_si)
sites(s)%fates_to_bgc_last_ts = rio_fates_to_bgc_last_ts_si(io_idx_si)
sites(s)%tot_seed_rain_flux = rio_seedrainflux_si(io_idx_si)

sites(s)%resources_management%trunk_product_site = rio_trunk_product_si(io_idx_si)

end do

if ( DEBUG ) then
Expand Down

0 comments on commit baa6eb6

Please sign in to comment.