diff --git a/biogeochem/EDPatchDynamicsMod.F90 b/biogeochem/EDPatchDynamicsMod.F90 index 33c949327d..3ccd344242 100644 --- a/biogeochem/EDPatchDynamicsMod.F90 +++ b/biogeochem/EDPatchDynamicsMod.F90 @@ -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 @@ -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) diff --git a/main/EDMainMod.F90 b/main/EDMainMod.F90 index adb803e639..4c5286bb0a 100644 --- a/main/EDMainMod.F90 +++ b/main/EDMainMod.F90 @@ -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) diff --git a/main/EDTypesMod.F90 b/main/EDTypesMod.F90 index 2b2e9fd11a..a2b5df5892 100644 --- a/main/EDTypesMod.F90 +++ b/main/EDTypesMod.F90 @@ -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 diff --git a/main/FatesHistoryInterfaceMod.F90 b/main/FatesHistoryInterfaceMod.F90 index 478d4a18de..c6a916a4a1 100644 --- a/main/FatesHistoryInterfaceMod.F90 +++ b/main/FatesHistoryInterfaceMod.F90 @@ -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 @@ -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, & @@ -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)) @@ -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, &