From 195b35558854e952d23343c35e3dc7019e94eaff Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Wed, 6 Aug 2025 17:03:28 -0700 Subject: [PATCH 1/8] add subroutine to replace repeated calls to update gpp_site and ar_site --- main/FatesInterfaceTypesMod.F90 | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/main/FatesInterfaceTypesMod.F90 b/main/FatesInterfaceTypesMod.F90 index 06cdb7c606..2c11bbc38e 100644 --- a/main/FatesInterfaceTypesMod.F90 +++ b/main/FatesInterfaceTypesMod.F90 @@ -804,6 +804,10 @@ module FatesInterfaceTypesMod real(r8) :: litter_cwd_c_si ! Total litter plus CWD carbon [Site-Level, gC m-2] real(r8) :: seed_c_si ! Total seed carbon [Site-Level, gC m-2] + contains + + procedure :: UpdateGPPAR + end type bc_out_type @@ -859,6 +863,26 @@ subroutine ZeroBCOutCarbonFluxes(bc_out) end subroutine ZeroBCOutCarbonFluxes + ! ====================================================================================== + subroutine UpdateGPPAR(this, ncohorts, gpp_acc_hold, resp_g_acc_hold, resp_m_acc_hold, & + resp_excess_hold, sec_per_day, AREA_INV) + + class(bc_out_type), intent(inout) :: this + real(r8), intent(in) :: ncohorts + real(r8), intent(in) :: gpp_acc_hold + real(r8), intent(in) :: resp_g_acc_hold + real(r8), intent(in) :: resp_m_acc_hold + real(r8), intent(in) :: resp_excess_hold + real(r8), intent(in) :: sec_per_day + real(r8), intent(in) :: AREA_INV + + this%gpp_site = this%gpp_site + gpp_acc_hold * & + AREA_INV * ncohorts / sec_per_day + this%ar_site = this%ar_site + (resp_m_acc_hold + resp_g_acc_hold + & + resp_excess_hold*real( hlm_days_per_year,r8)) * & + AREA_INV * ncohorts / sec_per_day + + end subroutine UpdateGPPAR end module FatesInterfaceTypesMod From a517c971d1175068f5b2df0a9765160f5490c707 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Wed, 6 Aug 2025 17:03:57 -0700 Subject: [PATCH 2/8] create restart update subroutine to call update for gpp_site and ar_site --- main/FatesInterfaceMod.F90 | 41 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/main/FatesInterfaceMod.F90 b/main/FatesInterfaceMod.F90 index 6f8bd6879d..c70d5eb4b4 100644 --- a/main/FatesInterfaceMod.F90 +++ b/main/FatesInterfaceMod.F90 @@ -159,6 +159,10 @@ module FatesInterfaceMod ! instance is fine. type(bc_pconst_type) :: bc_pconst + + contains + + procedure :: RestartUpdateBCOut end type fates_interface_type @@ -2694,4 +2698,41 @@ subroutine FatesReadParameters(param_reader) end subroutine FatesReadParameters +! ====================================================================================== + +subroutine RestartUpdateBCOut(this, s) + + ! Arguments + class(fates_interface_type), intent(inout) :: this + integer, intent(in) :: s + + ! Locals + type(fates_patch_type), pointer :: currentPatch + type(fates_cohort_type), pointer :: currentCohort + + ! Zero gpp and ar as the update call does not zero + this%bc_out(s)%gpp_site = 0._r8 + this%bc_out(s)%ar_site = 0._r8 + + currentPatch => this%sites(s)%youngest_patch + do while(associated(currentPatch)) + currentCohort => currentPatch%shortest + do while(associated(currentCohort)) + + + call this%bc_out(s)%UpdateGPPAR(currentCohort%n, currentCohort%gpp_acc_hold, & + 0.0_r8, 0.0_r8, & + 0.0_r8, sec_per_day, area_inv) + + !call this%bc_out(s)%UpdateGPPAR(currentCohort%n, currentCohort%gpp_acc_hold, & + ! currentCohort%resp_g_acc_hold, currentCohort%resp_m_acc_hold, & + ! currentCohort%resp_excess_hold, sec_per_day, area_inv) + + currentCohort => currentCohort%taller + end do + currentPatch => currentPatch%older + end do + +end subroutine RestartUpdateBCOut + end module FatesInterfaceMod From 21a709f2751adde6eb31d12659660b5a4274131b Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Tue, 12 Aug 2025 12:22:57 -0700 Subject: [PATCH 3/8] add check to avoid new cohorts during restart --- main/FatesInterfaceMod.F90 | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/main/FatesInterfaceMod.F90 b/main/FatesInterfaceMod.F90 index c70d5eb4b4..09d420fa75 100644 --- a/main/FatesInterfaceMod.F90 +++ b/main/FatesInterfaceMod.F90 @@ -2719,14 +2719,13 @@ subroutine RestartUpdateBCOut(this, s) currentCohort => currentPatch%shortest do while(associated(currentCohort)) + if (.not. currentCohort%isnew) then - call this%bc_out(s)%UpdateGPPAR(currentCohort%n, currentCohort%gpp_acc_hold, & - 0.0_r8, 0.0_r8, & - 0.0_r8, sec_per_day, area_inv) - - !call this%bc_out(s)%UpdateGPPAR(currentCohort%n, currentCohort%gpp_acc_hold, & - ! currentCohort%resp_g_acc_hold, currentCohort%resp_m_acc_hold, & - ! currentCohort%resp_excess_hold, sec_per_day, area_inv) + call this%bc_out(s)%UpdateGPPAR(currentCohort%n, currentCohort%gpp_acc_hold, & + currentCohort%resp_g_acc_hold, currentCohort%resp_m_acc_hold, & + currentCohort%resp_excess_hold, sec_per_day, area_inv) + + end if currentCohort => currentCohort%taller end do From aaae441ee9c276526d8031355fb8c7efa75ef7ac Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Wed, 13 Aug 2025 13:50:02 -0700 Subject: [PATCH 4/8] simplify UpdateGPPAR for legibility --- main/FatesInterfaceTypesMod.F90 | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/main/FatesInterfaceTypesMod.F90 b/main/FatesInterfaceTypesMod.F90 index 2c11bbc38e..af8f208de0 100644 --- a/main/FatesInterfaceTypesMod.F90 +++ b/main/FatesInterfaceTypesMod.F90 @@ -877,11 +877,14 @@ subroutine UpdateGPPAR(this, ncohorts, gpp_acc_hold, resp_g_acc_hold, resp_m_acc real(r8), intent(in) :: sec_per_day real(r8), intent(in) :: AREA_INV - this%gpp_site = this%gpp_site + gpp_acc_hold * & - AREA_INV * ncohorts / sec_per_day + real(r8) :: conversion_factor + + conversion_factor = AREA_INV * ncohorts / real(hlm_days_per_year,r8) / sec_per_day + + this%gpp_site = this%gpp_site + gpp_acc_hold * conversion_factor + this%ar_site = this%ar_site + (resp_m_acc_hold + resp_g_acc_hold + & - resp_excess_hold*real( hlm_days_per_year,r8)) * & - AREA_INV * ncohorts / sec_per_day + resp_excess_hold*real( hlm_days_per_year,r8)) * conversion_factor end subroutine UpdateGPPAR From 0d7c6076f1e8947d8fd66f3937ac62a41a43fc95 Mon Sep 17 00:00:00 2001 From: Ryan Knox Date: Wed, 10 Sep 2025 15:42:54 -0400 Subject: [PATCH 5/8] changing gpp and ar output boundary flux to use the massbalance data already available --- main/EDMainMod.F90 | 33 +++++++++------------------- main/FatesInterfaceMod.F90 | 36 ------------------------------- main/FatesInterfaceTypesMod.F90 | 29 ------------------------- main/FatesRestartInterfaceMod.F90 | 27 +++++++++++++++++++++-- 4 files changed, 35 insertions(+), 90 deletions(-) diff --git a/main/EDMainMod.F90 b/main/EDMainMod.F90 index 4a746c1168..81b8ea3bb7 100644 --- a/main/EDMainMod.F90 +++ b/main/EDMainMod.F90 @@ -426,9 +426,7 @@ subroutine ed_integrate_state_variables(currentSite, bc_in, bc_out ) current_fates_landuse_state_vector = currentSite%get_current_landuse_statevector() - ! Clear site GPP and AR passing to HLM - bc_out%gpp_site = 0._r8 - bc_out%ar_site = 0._r8 + ! Patch level biomass are required for C-based harvest call get_harvestable_carbon(currentSite, bc_in%site_area, bc_in%hlm_harvest_catnames, harvestable_forest_c) @@ -645,20 +643,10 @@ subroutine ed_integrate_state_variables(currentSite, bc_in, bc_out ) currentCohort%npp_acc_hold = currentCohort%npp_acc_hold - & currentCohort%resp_excess_hold*real( hlm_days_per_year,r8) - - ! Passing gpp_acc_hold to HLM - bc_out%gpp_site = bc_out%gpp_site + currentCohort%gpp_acc_hold * & - AREA_INV * currentCohort%n / real( hlm_days_per_year,r8) / sec_per_day - bc_out%ar_site = bc_out%ar_site + (currentCohort%resp_m_acc_hold + & - currentCohort%resp_g_acc_hold + currentCohort%resp_excess_hold*real(hlm_days_per_year,r8) ) * & - AREA_INV * currentCohort%n / real( hlm_days_per_year,r8) / sec_per_day ! Update the mass balance tracking for the daily nutrient uptake flux ! Then zero out the daily uptakes, they have been used - ! ----------------------------------------------------------------------------- - - call EffluxIntoLitterPools(currentSite, currentPatch, currentCohort, bc_in ) @@ -693,7 +681,9 @@ subroutine ed_integrate_state_variables(currentSite, bc_in, bc_out ) currentCohort%resp_m_acc*currentCohort%n + & currentCohort%resp_excess_hold*currentCohort%n + & currentCohort%resp_g_acc_hold*currentCohort%n/real( hlm_days_per_year,r8) - + + + call currentCohort%prt%CheckMassConservation(ft,5) ! Update the leaf biophysical rates based on proportion of leaf @@ -925,11 +915,16 @@ subroutine ed_update_site( currentSite, bc_in, bc_out, is_restarting ) bc_out%seed_c_si = bc_out%seed_c_si * g_per_kg * AREA_INV ! Set boundary condition to HLM for carbon loss to atm from fires and grazing - ! [kgC/ha/day]*[m2/ha]*[day/s] = [kg/m2/s] + ! [kgC/ha/day]*[ha/m2]*[day/s] = [kg/m2/s] site_cmass => currentSite%mass_balance(element_pos(carbon12_element)) bc_out%fire_closs_to_atm_si = site_cmass%burn_flux_to_atm * ha_per_m2 * days_per_sec bc_out%grazing_closs_to_atm_si = site_cmass%herbivory_flux_out * ha_per_m2 * days_per_sec + ! Pass site-level mass fluxes to output boundary conditions + ! [kg/site/day] * [site/m2 day/sec] = [kgC/m2/s] + bc_out%gpp_site = site_cmass%gpp_acc * area_inv / sec_per_day + bc_out%ar_site = site_cmass%aresp_acc * area_inv / sec_per_day + end subroutine ed_update_site !-------------------------------------------------------------------------------! @@ -1178,14 +1173,6 @@ subroutine bypass_dynamics(currentSite, bc_out) ! Shouldn't need to zero any nutrient fluxes ! as they should just be zero, no uptake ! in ST3 mode. - - ! Passing - bc_out%gpp_site = bc_out%gpp_site + currentCohort%gpp_acc_hold * & - AREA_INV * currentCohort%n / real( hlm_days_per_year,r8) / sec_per_day - bc_out%ar_site = bc_out%ar_site + (currentCohort%resp_m_acc_hold + & - currentCohort%resp_g_acc_hold + & - currentCohort%resp_excess_hold*real( hlm_days_per_year,r8)) * & - AREA_INV * currentCohort%n / real( hlm_days_per_year,r8) / sec_per_day currentCohort => currentCohort%taller enddo diff --git a/main/FatesInterfaceMod.F90 b/main/FatesInterfaceMod.F90 index 09d420fa75..178f0f4475 100644 --- a/main/FatesInterfaceMod.F90 +++ b/main/FatesInterfaceMod.F90 @@ -2698,40 +2698,4 @@ subroutine FatesReadParameters(param_reader) end subroutine FatesReadParameters -! ====================================================================================== - -subroutine RestartUpdateBCOut(this, s) - - ! Arguments - class(fates_interface_type), intent(inout) :: this - integer, intent(in) :: s - - ! Locals - type(fates_patch_type), pointer :: currentPatch - type(fates_cohort_type), pointer :: currentCohort - - ! Zero gpp and ar as the update call does not zero - this%bc_out(s)%gpp_site = 0._r8 - this%bc_out(s)%ar_site = 0._r8 - - currentPatch => this%sites(s)%youngest_patch - do while(associated(currentPatch)) - currentCohort => currentPatch%shortest - do while(associated(currentCohort)) - - if (.not. currentCohort%isnew) then - - call this%bc_out(s)%UpdateGPPAR(currentCohort%n, currentCohort%gpp_acc_hold, & - currentCohort%resp_g_acc_hold, currentCohort%resp_m_acc_hold, & - currentCohort%resp_excess_hold, sec_per_day, area_inv) - - end if - - currentCohort => currentCohort%taller - end do - currentPatch => currentPatch%older - end do - -end subroutine RestartUpdateBCOut - end module FatesInterfaceMod diff --git a/main/FatesInterfaceTypesMod.F90 b/main/FatesInterfaceTypesMod.F90 index af8f208de0..4f27f90805 100644 --- a/main/FatesInterfaceTypesMod.F90 +++ b/main/FatesInterfaceTypesMod.F90 @@ -804,10 +804,6 @@ module FatesInterfaceTypesMod real(r8) :: litter_cwd_c_si ! Total litter plus CWD carbon [Site-Level, gC m-2] real(r8) :: seed_c_si ! Total seed carbon [Site-Level, gC m-2] - contains - - procedure :: UpdateGPPAR - end type bc_out_type @@ -863,29 +859,4 @@ subroutine ZeroBCOutCarbonFluxes(bc_out) end subroutine ZeroBCOutCarbonFluxes - ! ====================================================================================== - - subroutine UpdateGPPAR(this, ncohorts, gpp_acc_hold, resp_g_acc_hold, resp_m_acc_hold, & - resp_excess_hold, sec_per_day, AREA_INV) - - class(bc_out_type), intent(inout) :: this - real(r8), intent(in) :: ncohorts - real(r8), intent(in) :: gpp_acc_hold - real(r8), intent(in) :: resp_g_acc_hold - real(r8), intent(in) :: resp_m_acc_hold - real(r8), intent(in) :: resp_excess_hold - real(r8), intent(in) :: sec_per_day - real(r8), intent(in) :: AREA_INV - - real(r8) :: conversion_factor - - conversion_factor = AREA_INV * ncohorts / real(hlm_days_per_year,r8) / sec_per_day - - this%gpp_site = this%gpp_site + gpp_acc_hold * conversion_factor - - this%ar_site = this%ar_site + (resp_m_acc_hold + resp_g_acc_hold + & - resp_excess_hold*real( hlm_days_per_year,r8)) * conversion_factor - - end subroutine UpdateGPPAR - end module FatesInterfaceTypesMod diff --git a/main/FatesRestartInterfaceMod.F90 b/main/FatesRestartInterfaceMod.F90 index f2c78051a1..6b89fa4d84 100644 --- a/main/FatesRestartInterfaceMod.F90 +++ b/main/FatesRestartInterfaceMod.F90 @@ -112,6 +112,9 @@ module FatesRestartInterfaceMod integer :: ir_snow_depth_si integer :: ir_trunk_product_si integer :: ir_landuse_config_si + integer :: ir_gpp_acc_si + integer :: ir_ar_acc_si + integer :: ir_ncohort_pa integer :: ir_canopy_layer_co integer :: ir_canopy_layer_yesterday_co @@ -316,7 +319,8 @@ module FatesRestartInterfaceMod ! The number of variable dim/kind types we have defined (static) integer, parameter, public :: fates_restart_num_dimensions = 2 !(cohort,column) - integer, parameter, public :: fates_restart_num_dim_kinds = 4 !(cohort-int,cohort-r8,site-int,site-r8) + integer, parameter, public :: fates_restart_num_dim_kinds = 4 !(cohort-int,cohort-r8, + ! site-int,site-r8) ! integer constants for storing logical data integer, parameter, public :: old_cohort = 0 @@ -749,6 +753,16 @@ subroutine define_restart_vars(this, initialize_variables) units='kgC/m2', flushval = flushzero, & hlms='CLM:ALM', initialize=initialize_variables, ivar=ivar, index = ir_landuse_config_si ) + call this%set_restart_var(vname='fates_massbal_gpp', vtype=site_r8, & + long_name='accumulated gpp over previous day cycle', & + units='kgC/m2/s', flushval = flushzero, & + hlms='CLM:ALM', initialize=initialize_variables, ivar=ivar, index = ir_gpp_acc_si ) + + call this%set_restart_var(vname='fates_massbal_ar', vtype=site_r8, & + long_name='accumulated autotrophic respiration over previous day cycle', & + units='kgC/m2/s', flushval = flushzero, & + hlms='CLM:ALM', initialize=initialize_variables, ivar=ivar, index = ir_ar_acc_si ) + ! ----------------------------------------------------------------------------------- ! Variables stored within cohort vectors ! Note: Some of these are multi-dimensional variables in the patch/site dimension @@ -2080,6 +2094,7 @@ subroutine set_restart_vectors(this,nc,nsites,sites) integer :: ft ! functional type index integer :: el ! element loop index + integer :: c_el ! element loop index for carbon12 integer :: ilyr ! soil layer index integer :: nlevsoil ! total soil layers in patch of interest integer :: k,j,i ! indices to the radiation matrix @@ -2378,7 +2393,9 @@ subroutine set_restart_vectors(this,nc,nsites,sites) end do end if - + c_el = element_pos(carbon12_element) + this%rvars(ir_gpp_acc_si)%r81d(io_idx_si) = sites(s)%mass_balance(c_el)%gpp_acc + this%rvars(ir_aresp_acc_si)%r81d(io_idx_si) = sites(s)%mass_balance(c_el)%aresp_acc ! canopy spread term rio_spread_si(io_idx_si) = sites(s)%spread @@ -3084,6 +3101,7 @@ subroutine get_restart_vectors(this, nc, nsites, sites) integer :: patchespersite ! number of patches per site integer :: cohortsperpatch ! number of cohorts per patch integer :: el ! loop counter for elements + integer :: c_el ! loop counter for carbon12 integer :: nlevsoil ! number of soil layers integer :: ilyr ! soil layer loop counter integer :: iscpf ! multiplex loop counter for size x pft @@ -3363,6 +3381,11 @@ subroutine get_restart_vectors(this, nc, nsites, sites) end do end if + + c_el = element_pos(carbon12_element) + sites(s)%mass_balance(c_el)%gpp_acc = this%rvars(ir_gpp_acc_si)%r81d(io_idx_si) + sites(s)%mass_balance(c_el)%aresp_acc = this%rvars(ir_aresp_acc_si)%r81d(io_idx_si) + sites(s)%spread = rio_spread_si(io_idx_si) From 58e0d670a261f881e763dd46ec2413e5b3ac356c Mon Sep 17 00:00:00 2001 From: Ryan Knox Date: Thu, 11 Sep 2025 10:22:53 -0700 Subject: [PATCH 6/8] bug fixes for changes to nbp bc_out variables --- main/FatesInterfaceMod.F90 | 4 ---- main/FatesRestartInterfaceMod.F90 | 7 ++++--- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/main/FatesInterfaceMod.F90 b/main/FatesInterfaceMod.F90 index 178f0f4475..06bbf3d0b7 100644 --- a/main/FatesInterfaceMod.F90 +++ b/main/FatesInterfaceMod.F90 @@ -160,10 +160,6 @@ module FatesInterfaceMod type(bc_pconst_type) :: bc_pconst - contains - - procedure :: RestartUpdateBCOut - end type fates_interface_type diff --git a/main/FatesRestartInterfaceMod.F90 b/main/FatesRestartInterfaceMod.F90 index 6b89fa4d84..2c0f9e7b1c 100644 --- a/main/FatesRestartInterfaceMod.F90 +++ b/main/FatesRestartInterfaceMod.F90 @@ -49,8 +49,9 @@ module FatesRestartInterfaceMod use EDTypesMod, only : area use EDTypesMod, only : set_patchno use EDParamsMod, only : nlevleaf - use PRTGenericMod, only : prt_global + use PRTGenericMod, only : carbon12_element use PRTGenericMod, only : num_elements + use PRTGenericMod, only : element_pos use FatesRunningMeanMod, only : rmean_type use FatesRunningMeanMod, only : ema_lpa use FatesRadiationMemMod, only : num_swb,norman_solver,twostr_solver @@ -113,7 +114,7 @@ module FatesRestartInterfaceMod integer :: ir_trunk_product_si integer :: ir_landuse_config_si integer :: ir_gpp_acc_si - integer :: ir_ar_acc_si + integer :: ir_aresp_acc_si integer :: ir_ncohort_pa integer :: ir_canopy_layer_co @@ -761,7 +762,7 @@ subroutine define_restart_vars(this, initialize_variables) call this%set_restart_var(vname='fates_massbal_ar', vtype=site_r8, & long_name='accumulated autotrophic respiration over previous day cycle', & units='kgC/m2/s', flushval = flushzero, & - hlms='CLM:ALM', initialize=initialize_variables, ivar=ivar, index = ir_ar_acc_si ) + hlms='CLM:ALM', initialize=initialize_variables, ivar=ivar, index = ir_aresp_acc_si ) ! ----------------------------------------------------------------------------------- ! Variables stored within cohort vectors From f8d9e2bc93d49d431282b99e76e376ad466f28af Mon Sep 17 00:00:00 2001 From: Ryan Knox Date: Fri, 12 Sep 2025 11:30:56 -0700 Subject: [PATCH 7/8] Updated some descriptive text --- biogeochem/EDPatchDynamicsMod.F90 | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/biogeochem/EDPatchDynamicsMod.F90 b/biogeochem/EDPatchDynamicsMod.F90 index e6ba98b568..cdf104d587 100644 --- a/biogeochem/EDPatchDynamicsMod.F90 +++ b/biogeochem/EDPatchDynamicsMod.F90 @@ -1895,9 +1895,13 @@ subroutine TransLitterNewPatch(currentSite, & curr_litt => currentPatch%litter(el) new_litt => newPatch%litter(el) - ! Distribute the fragmentation litter flux rates. This is only used for diagnostics - ! at this point. Litter fragmentation has already been passed to the output - ! boundary flux arrays. + ! Distribute the fragmentation litter flux rates. The mean site-level + ! flux rate must be preserved, so when we create new patches + ! from disturbance, we must area weight the contributions of the + ! donor patches. This is because the host model will call + ! FatesSoilBGCFluxMod:FluxIntoLitterPools() which uses these + ! litt%<>_frac() arrays to fill site level output fluxes, and + ! this is called over the next day on the model timestep. do c = 1,ncwd new_litt%ag_cwd_frag(c) = new_litt%ag_cwd_frag(c) + & From 638ae670d4b48b235e487a439940d7ffab9c74c1 Mon Sep 17 00:00:00 2001 From: Ryan Knox Date: Sun, 14 Sep 2025 19:02:45 -0400 Subject: [PATCH 8/8] zeroing cmass%gpp for mass checking on restart --- main/EDMainMod.F90 | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/main/EDMainMod.F90 b/main/EDMainMod.F90 index 81b8ea3bb7..8bc045a454 100644 --- a/main/EDMainMod.F90 +++ b/main/EDMainMod.F90 @@ -841,13 +841,23 @@ subroutine ed_update_site( currentSite, bc_in, bc_out, is_restarting ) real(r8) :: total_stock ! dummy variable for receiving from sitemassstock !----------------------------------------------------------------------- + site_cmass => currentSite%mass_balance(element_pos(carbon12_element)) + ! check patch order (set second argument to true) if (debug) then call set_patchno(currentSite,.true.,1) end if + + ! Pass site-level mass fluxes to output boundary conditions + ! [kg/site/day] * [site/m2 day/sec] = [kgC/m2/s] + bc_out%gpp_site = site_cmass%gpp_acc * area_inv / sec_per_day + bc_out%ar_site = site_cmass%aresp_acc * area_inv / sec_per_day if(hlm_use_sp.eq.ifalse .and. (.not.is_restarting))then - call canopy_spread(currentSite) + call canopy_spread(currentSite) + else + site_cmass%gpp_acc = 0._r8 + site_cmass%aresp_acc = 0._r8 end if call TotalBalanceCheck(currentSite,6) @@ -916,14 +926,11 @@ subroutine ed_update_site( currentSite, bc_in, bc_out, is_restarting ) ! Set boundary condition to HLM for carbon loss to atm from fires and grazing ! [kgC/ha/day]*[ha/m2]*[day/s] = [kg/m2/s] - site_cmass => currentSite%mass_balance(element_pos(carbon12_element)) + bc_out%fire_closs_to_atm_si = site_cmass%burn_flux_to_atm * ha_per_m2 * days_per_sec bc_out%grazing_closs_to_atm_si = site_cmass%herbivory_flux_out * ha_per_m2 * days_per_sec - ! Pass site-level mass fluxes to output boundary conditions - ! [kg/site/day] * [site/m2 day/sec] = [kgC/m2/s] - bc_out%gpp_site = site_cmass%gpp_acc * area_inv / sec_per_day - bc_out%ar_site = site_cmass%aresp_acc * area_inv / sec_per_day + end subroutine ed_update_site