Skip to content

Commit f6355b1

Browse files
authored
Merge pull request #1448 from glemieux/nbp-gpp-restart-fix
`gpp_site` restart fix
2 parents 27a5b40 + f847ef7 commit f6355b1

File tree

5 files changed

+54
-34
lines changed

5 files changed

+54
-34
lines changed

biogeochem/EDPatchDynamicsMod.F90

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1966,9 +1966,13 @@ subroutine TransLitterNewPatch(currentSite, &
19661966
curr_litt => currentPatch%litter(el)
19671967
new_litt => newPatch%litter(el)
19681968

1969-
! Distribute the fragmentation litter flux rates. This is only used for diagnostics
1970-
! at this point. Litter fragmentation has already been passed to the output
1971-
! boundary flux arrays.
1969+
! Distribute the fragmentation litter flux rates. The mean site-level
1970+
! flux rate must be preserved, so when we create new patches
1971+
! from disturbance, we must area weight the contributions of the
1972+
! donor patches. This is because the host model will call
1973+
! FatesSoilBGCFluxMod:FluxIntoLitterPools() which uses these
1974+
! litt%<>_frac() arrays to fill site level output fluxes, and
1975+
! this is called over the next day on the model timestep.
19721976

19731977
do c = 1,ncwd
19741978
new_litt%ag_cwd_frag(c) = new_litt%ag_cwd_frag(c) + &

main/EDMainMod.F90

Lines changed: 19 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -426,9 +426,7 @@ subroutine ed_integrate_state_variables(currentSite, bc_in, bc_out )
426426

427427
current_fates_landuse_state_vector = currentSite%get_current_landuse_statevector()
428428

429-
! Clear site GPP and AR passing to HLM
430-
bc_out%gpp_site = 0._r8
431-
bc_out%ar_site = 0._r8
429+
432430

433431
! Patch level biomass are required for C-based harvest
434432
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 )
645643

646644
currentCohort%npp_acc_hold = currentCohort%npp_acc_hold - &
647645
currentCohort%resp_excess_hold*real( hlm_days_per_year,r8)
648-
649-
! Passing gpp_acc_hold to HLM
650-
bc_out%gpp_site = bc_out%gpp_site + currentCohort%gpp_acc_hold * &
651-
AREA_INV * currentCohort%n / real( hlm_days_per_year,r8) / sec_per_day
652-
bc_out%ar_site = bc_out%ar_site + (currentCohort%resp_m_acc_hold + &
653-
currentCohort%resp_g_acc_hold + currentCohort%resp_excess_hold*real(hlm_days_per_year,r8) ) * &
654-
AREA_INV * currentCohort%n / real( hlm_days_per_year,r8) / sec_per_day
655646

656647
! Update the mass balance tracking for the daily nutrient uptake flux
657648
! Then zero out the daily uptakes, they have been used
658649

659-
! -----------------------------------------------------------------------------
660-
661-
662650

663651
call EffluxIntoLitterPools(currentSite, currentPatch, currentCohort, bc_in )
664652

@@ -693,7 +681,9 @@ subroutine ed_integrate_state_variables(currentSite, bc_in, bc_out )
693681
currentCohort%resp_m_acc*currentCohort%n + &
694682
currentCohort%resp_excess_hold*currentCohort%n + &
695683
currentCohort%resp_g_acc_hold*currentCohort%n/real( hlm_days_per_year,r8)
696-
684+
685+
686+
697687
call currentCohort%prt%CheckMassConservation(ft,5)
698688

699689
! Update the leaf biophysical rates based on proportion of leaf
@@ -851,13 +841,23 @@ subroutine ed_update_site( currentSite, bc_in, bc_out, is_restarting )
851841
real(r8) :: total_stock ! dummy variable for receiving from sitemassstock
852842
!-----------------------------------------------------------------------
853843

844+
site_cmass => currentSite%mass_balance(element_pos(carbon12_element))
845+
854846
! check patch order (set second argument to true)
855847
if (debug) then
856848
call set_patchno(currentSite,.true.,1)
857849
end if
850+
851+
! Pass site-level mass fluxes to output boundary conditions
852+
! [kg/site/day] * [site/m2 day/sec] = [kgC/m2/s]
853+
bc_out%gpp_site = site_cmass%gpp_acc * area_inv / sec_per_day
854+
bc_out%ar_site = site_cmass%aresp_acc * area_inv / sec_per_day
858855

859856
if(hlm_use_sp.eq.ifalse .and. (.not.is_restarting))then
860-
call canopy_spread(currentSite)
857+
call canopy_spread(currentSite)
858+
else
859+
site_cmass%gpp_acc = 0._r8
860+
site_cmass%aresp_acc = 0._r8
861861
end if
862862

863863
call TotalBalanceCheck(currentSite,6)
@@ -925,11 +925,13 @@ subroutine ed_update_site( currentSite, bc_in, bc_out, is_restarting )
925925
bc_out%seed_c_si = bc_out%seed_c_si * g_per_kg * AREA_INV
926926

927927
! Set boundary condition to HLM for carbon loss to atm from fires and grazing
928-
! [kgC/ha/day]*[m2/ha]*[day/s] = [kg/m2/s]
929-
site_cmass => currentSite%mass_balance(element_pos(carbon12_element))
928+
! [kgC/ha/day]*[ha/m2]*[day/s] = [kg/m2/s]
929+
930930
bc_out%fire_closs_to_atm_si = site_cmass%burn_flux_to_atm * ha_per_m2 * days_per_sec
931931
bc_out%grazing_closs_to_atm_si = site_cmass%herbivory_flux_out * ha_per_m2 * days_per_sec
932932

933+
934+
933935
end subroutine ed_update_site
934936

935937
!-------------------------------------------------------------------------------!
@@ -1178,14 +1180,6 @@ subroutine bypass_dynamics(currentSite, bc_out)
11781180
! Shouldn't need to zero any nutrient fluxes
11791181
! as they should just be zero, no uptake
11801182
! in ST3 mode.
1181-
1182-
! Passing
1183-
bc_out%gpp_site = bc_out%gpp_site + currentCohort%gpp_acc_hold * &
1184-
AREA_INV * currentCohort%n / real( hlm_days_per_year,r8) / sec_per_day
1185-
bc_out%ar_site = bc_out%ar_site + (currentCohort%resp_m_acc_hold + &
1186-
currentCohort%resp_g_acc_hold + &
1187-
currentCohort%resp_excess_hold*real( hlm_days_per_year,r8)) * &
1188-
AREA_INV * currentCohort%n / real( hlm_days_per_year,r8) / sec_per_day
11891183

11901184
currentCohort => currentCohort%taller
11911185
enddo

main/FatesInterfaceMod.F90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ module FatesInterfaceMod
159159
! instance is fine.
160160

161161
type(bc_pconst_type) :: bc_pconst
162-
162+
163163

164164
end type fates_interface_type
165165

main/FatesInterfaceTypesMod.F90

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -861,6 +861,4 @@ subroutine ZeroBCOutCarbonFluxes(bc_out)
861861

862862
end subroutine ZeroBCOutCarbonFluxes
863863

864-
865-
866864
end module FatesInterfaceTypesMod

main/FatesRestartInterfaceMod.F90

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,9 @@ module FatesRestartInterfaceMod
4949
use EDTypesMod, only : area
5050
use EDTypesMod, only : set_patchno
5151
use EDParamsMod, only : nlevleaf
52-
use PRTGenericMod, only : prt_global
52+
use PRTGenericMod, only : carbon12_element
5353
use PRTGenericMod, only : num_elements
54+
use PRTGenericMod, only : element_pos
5455
use FatesRunningMeanMod, only : rmean_type
5556
use FatesRunningMeanMod, only : ema_lpa
5657
use FatesRadiationMemMod, only : num_swb,norman_solver,twostr_solver
@@ -111,6 +112,9 @@ module FatesRestartInterfaceMod
111112
integer :: ir_area_bareground_si
112113
integer :: ir_snow_depth_si
113114
integer :: ir_landuse_config_si
115+
integer :: ir_gpp_acc_si
116+
integer :: ir_aresp_acc_si
117+
114118
integer :: ir_ncohort_pa
115119
integer :: ir_canopy_layer_co
116120
integer :: ir_canopy_layer_yesterday_co
@@ -341,7 +345,8 @@ module FatesRestartInterfaceMod
341345

342346
! The number of variable dim/kind types we have defined (static)
343347
integer, parameter, public :: fates_restart_num_dimensions = 2 !(cohort,column)
344-
integer, parameter, public :: fates_restart_num_dim_kinds = 4 !(cohort-int,cohort-r8,site-int,site-r8)
348+
integer, parameter, public :: fates_restart_num_dim_kinds = 4 !(cohort-int,cohort-r8,
349+
! site-int,site-r8)
345350

346351
! integer constants for storing logical data
347352
integer, parameter, public :: old_cohort = 0
@@ -769,6 +774,16 @@ subroutine define_restart_vars(this, initialize_variables)
769774
units='kgC/m2', flushval = flushzero, &
770775
hlms='CLM:ALM', initialize=initialize_variables, ivar=ivar, index = ir_landuse_config_si )
771776

777+
call this%set_restart_var(vname='fates_massbal_gpp', vtype=site_r8, &
778+
long_name='accumulated gpp over previous day cycle', &
779+
units='kgC/m2/s', flushval = flushzero, &
780+
hlms='CLM:ALM', initialize=initialize_variables, ivar=ivar, index = ir_gpp_acc_si )
781+
782+
call this%set_restart_var(vname='fates_massbal_ar', vtype=site_r8, &
783+
long_name='accumulated autotrophic respiration over previous day cycle', &
784+
units='kgC/m2/s', flushval = flushzero, &
785+
hlms='CLM:ALM', initialize=initialize_variables, ivar=ivar, index = ir_aresp_acc_si )
786+
772787
! -----------------------------------------------------------------------------------
773788
! Variables stored within cohort vectors
774789
! Note: Some of these are multi-dimensional variables in the patch/site dimension
@@ -2229,6 +2244,7 @@ subroutine set_restart_vectors(this,nc,nsites,sites)
22292244

22302245
integer :: ft ! functional type index
22312246
integer :: el ! element loop index
2247+
integer :: c_el ! element loop index for carbon12
22322248
integer :: ilyr ! soil layer index
22332249
integer :: nlevsoil ! total soil layers in patch of interest
22342250
integer :: k,j,i ! indices to the radiation matrix
@@ -2566,7 +2582,9 @@ subroutine set_restart_vectors(this,nc,nsites,sites)
25662582
end do
25672583
end if
25682584

2569-
2585+
c_el = element_pos(carbon12_element)
2586+
this%rvars(ir_gpp_acc_si)%r81d(io_idx_si) = sites(s)%mass_balance(c_el)%gpp_acc
2587+
this%rvars(ir_aresp_acc_si)%r81d(io_idx_si) = sites(s)%mass_balance(c_el)%aresp_acc
25702588

25712589
! canopy spread term
25722590
rio_spread_si(io_idx_si) = sites(s)%spread
@@ -3281,6 +3299,7 @@ subroutine get_restart_vectors(this, nc, nsites, sites)
32813299
integer :: patchespersite ! number of patches per site
32823300
integer :: cohortsperpatch ! number of cohorts per patch
32833301
integer :: el ! loop counter for elements
3302+
integer :: c_el ! loop counter for carbon12
32843303
integer :: nlevsoil ! number of soil layers
32853304
integer :: ilyr ! soil layer loop counter
32863305
integer :: iscpf ! multiplex loop counter for size x pft
@@ -3599,6 +3618,11 @@ subroutine get_restart_vectors(this, nc, nsites, sites)
35993618

36003619
end do
36013620
end if
3621+
3622+
c_el = element_pos(carbon12_element)
3623+
sites(s)%mass_balance(c_el)%gpp_acc = this%rvars(ir_gpp_acc_si)%r81d(io_idx_si)
3624+
sites(s)%mass_balance(c_el)%aresp_acc = this%rvars(ir_aresp_acc_si)%r81d(io_idx_si)
3625+
36023626

36033627
sites(s)%spread = rio_spread_si(io_idx_si)
36043628

0 commit comments

Comments
 (0)