Skip to content

Commit

Permalink
adding patch area conservation error term to history output
Browse files Browse the repository at this point in the history
  • Loading branch information
ckoven committed Jun 9, 2020
1 parent 6b574f9 commit 3afe8ed
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 1 deletion.
5 changes: 4 additions & 1 deletion biogeochem/EDPatchDynamicsMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1161,7 +1161,7 @@ subroutine check_patch_area( currentSite )
! !USES:
!
! !ARGUMENTS:
type(ed_site_type), intent(in), target :: currentSite
type(ed_site_type), intent(inout), target :: currentSite
!
! !LOCAL VARIABLES:
real(r8) :: areatot
Expand Down Expand Up @@ -1216,6 +1216,9 @@ subroutine check_patch_area( currentSite )
currentSite%mass_balance(el)%patch_resize_err + mass_gain

end do

currentSite%patch_area_conservation_error = currentSite%patch_area_conservation_error + &
area_site-areatot

largestPatch%area = largestPatch%area + (area_site-areatot)

Expand Down
3 changes: 3 additions & 0 deletions main/EDMainMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,9 @@ subroutine ed_ecosystem_dynamics(currentSite, bc_in)
! Patch dynamics sub-routines: fusion, new patch creation (spwaning), termination.
!*********************************************************************************

! zero site-level patch area error tracking
currentSite%patch_area_conservation_error = 0._r8

! make new patches from disturbed land
if ( hlm_use_ed_st3.eq.ifalse ) then
call spawn_patches(currentSite, bc_in)
Expand Down
1 change: 1 addition & 0 deletions main/EDTypesMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -771,6 +771,7 @@ module EDTypesMod
real(r8) :: disturbance_rates_secondary_to_secondary(N_DIST_TYPES) ! actual disturbance rates from secondary patches to secondary patches [m2/m2/day]
real(r8) :: potential_disturbance_rates(N_DIST_TYPES) ! "potential" disturb rates (i.e. prior to the "which is most" logic) [m2/m2/day]
real(r8) :: primary_land_patchfusion_error ! error term in total area of primary patches associated with patch fusion [m2/m2/day]
real(r8) :: patch_area_conservation_error ! error term in total area of patches associated with patch area conservation [m2/m2/day]

end type ed_site_type

Expand Down
10 changes: 10 additions & 0 deletions main/FatesHistoryInterfaceMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ module FatesHistoryInterfaceMod
integer :: ih_canopy_biomass_si
integer :: ih_understory_biomass_si

integer :: ih_patch_area_conservation_error_si
integer :: ih_primaryland_fusion_error_si
integer :: ih_disturbance_rate_p2p_si
integer :: ih_disturbance_rate_p2s_si
Expand Down Expand Up @@ -1789,6 +1790,7 @@ subroutine update_history_dyn(this,nc,nsites,sites,bc_in)
hio_agb_si => this%hvars(ih_agb_si)%r81d, &
hio_canopy_biomass_si => this%hvars(ih_canopy_biomass_si)%r81d, &
hio_understory_biomass_si => this%hvars(ih_understory_biomass_si)%r81d, &
hio_patch_area_conservation_error_si => this%hvars(ih_patch_area_conservation_error_si)%r81d, &
hio_primaryland_fusion_error_si => this%hvars(ih_primaryland_fusion_error_si)%r81d, &
hio_disturbance_rate_p2p_si => this%hvars(ih_disturbance_rate_p2p_si)%r81d, &
hio_disturbance_rate_p2s_si => this%hvars(ih_disturbance_rate_p2s_si)%r81d, &
Expand Down Expand Up @@ -2064,6 +2066,9 @@ subroutine update_history_dyn(this,nc,nsites,sites,bc_in)
! error in primary lands from patch fusion
hio_primaryland_fusion_error_si = sites(s)%primary_land_patchfusion_error

! total error in patch area fixed during conservation check
hio_patch_area_conservation_error_si = sites(s)%patch_area_conservation_error

! output site-level disturbance rates
hio_disturbance_rate_p2p_si = sum(sites(s)%disturbance_rates_primary_to_primary(1:N_DIST_TYPES))
hio_disturbance_rate_p2s_si = sum(sites(s)%disturbance_rates_primary_to_secondary(1:N_DIST_TYPES))
Expand Down Expand Up @@ -4249,6 +4254,11 @@ subroutine define_history_vars(this, initialize_variables)
ivar=ivar, initialize=initialize_variables, index = ih_understory_biomass_si )

! disturbance rates
call this%set_history_var(vname='PATCH_AREA_CONSERVATION_ERROR', units='m2 m-2 d-1', &
long='Error in total patch area fixed to ensure conservation', use_default='active', &
avgflag='A', vtype=site_r8, hlms='CLM:ALM', flushval=0.0_r8, upfreq=1, &
ivar=ivar, initialize=initialize_variables, index = ih_patch_area_conservation_error_si )

call this%set_history_var(vname='PRIMARYLAND_PATCHFUSION_ERROR', units='m2 m-2 d-1', &
long='Error in total primary lands associated with patch fusion', use_default='active', &
avgflag='A', vtype=site_r8, hlms='CLM:ALM', flushval=0.0_r8, upfreq=1, &
Expand Down

0 comments on commit 3afe8ed

Please sign in to comment.