Skip to content

Commit

Permalink
Merge pull request #1114 from rgknox/hetresp_restart_v2
Browse files Browse the repository at this point in the history
fixes required for FATES-E3SM soil coupling restarts
  • Loading branch information
rgknox authored Nov 6, 2023
2 parents 1d18bb6 + c925928 commit 1874511
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 26 deletions.
11 changes: 8 additions & 3 deletions biogeochem/FatesCohortMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -476,13 +476,18 @@ subroutine ZeroValues(this)
this%size_class_lasttimestep = 0
this%gpp_tstep = 0._r8
this%gpp_acc = 0._r8
this%gpp_acc_hold = 0._r8
this%npp_tstep = 0._r8
this%npp_acc = 0._r8
this%npp_acc_hold = 0._r8
this%resp_tstep = 0._r8
this%resp_acc = 0._r8
this%resp_acc_hold = 0._r8

! do not zero these, they are not built
! so more appropriate to leave unzerod
! to prevent uninitialized use
! this%gpp_acc_hold = nan
! this%npp_acc_hold = nan
! this%resp_acc_hold = nan

this%c13disc_clm = 0._r8
this%c13disc_acc = 0._r8

Expand Down
6 changes: 5 additions & 1 deletion biogeophys/EDAccumulateFluxesMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,11 @@ subroutine AccumulateFluxes_ED(nsites, sites, bc_in, bc_out, dt_time)
do s = 1, nsites

ifp = 0


! Note: Do not attempt to accumulate or log any
! heterotrophic respiration fluxes from the HLM here
! It is likely this has not been calculated yet (ELM/CLM)

cpatch => sites(s)%oldest_patch
do while (associated(cpatch))
if(cpatch%nocomp_pft_label.ne.nocomp_bareground)then
Expand Down
1 change: 0 additions & 1 deletion main/EDInitMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,6 @@ subroutine zero_site( site_in )
site_in%imort_abg_flux(:,:) = 0._r8
site_in%fmort_abg_flux(:,:) = 0._r8


! fusoin-induced growth flux of individuals
site_in%growthflux_fusion(:,:) = 0._r8

Expand Down
1 change: 1 addition & 0 deletions main/EDTypesMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ module EDTypesMod
! Total area of patches in each age bin [m2]
real(r8), allocatable :: area_by_age(:)


! Nutrient relevant
real(r8), allocatable :: rec_l2fr(:,:) ! A running mean of the l2fr's for the newly
! recruited, pft x canopy_layer
Expand Down
30 changes: 15 additions & 15 deletions main/FatesHistoryInterfaceMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -3047,20 +3047,6 @@ subroutine update_history_dyn(this,nc,nsites,sites,bc_in)
ccohort%c_area * AREA_INV
end if

! update pft-resolved NPP and GPP fluxes
hio_gpp_si_pft(io_si, ft) = hio_gpp_si_pft(io_si, ft) + &
ccohort%gpp_acc_hold * n_perm2 / days_per_year / sec_per_day

hio_npp_si_pft(io_si, ft) = hio_npp_si_pft(io_si, ft) + &
ccohort%npp_acc_hold * n_perm2 / days_per_year / sec_per_day

if ( cpatch%anthro_disturbance_label .eq. secondaryforest ) then
hio_gpp_sec_si_pft(io_si, ft) = hio_gpp_sec_si_pft(io_si, ft) + &
ccohort%gpp_acc_hold * n_perm2 / days_per_year / sec_per_day
hio_npp_sec_si_pft(io_si, ft) = hio_npp_sec_si_pft(io_si, ft) + &
ccohort%npp_acc_hold * n_perm2 / days_per_year / sec_per_day
end if

! Site by Size-Class x PFT (SCPF)
! ------------------------------------------------------------------------

Expand All @@ -3070,6 +3056,20 @@ subroutine update_history_dyn(this,nc,nsites,sites,bc_in)
! have any meaning, otherwise they are just inialization values
notnew: if( .not.(ccohort%isnew) ) then

! update pft-resolved NPP and GPP fluxes
hio_gpp_si_pft(io_si, ft) = hio_gpp_si_pft(io_si, ft) + &
ccohort%gpp_acc_hold * n_perm2 / days_per_year / sec_per_day

hio_npp_si_pft(io_si, ft) = hio_npp_si_pft(io_si, ft) + &
ccohort%npp_acc_hold * n_perm2 / days_per_year / sec_per_day

if ( cpatch%anthro_disturbance_label .eq. secondaryforest ) then
hio_gpp_sec_si_pft(io_si, ft) = hio_gpp_sec_si_pft(io_si, ft) + &
ccohort%gpp_acc_hold * n_perm2 / days_per_year / sec_per_day
hio_npp_sec_si_pft(io_si, ft) = hio_npp_sec_si_pft(io_si, ft) + &
ccohort%npp_acc_hold * n_perm2 / days_per_year / sec_per_day
end if

! Turnover pools [kgC/day] * [day/yr] = [kgC/yr]
sapw_m_turnover = ccohort%prt%GetTurnover(sapw_organ, carbon12_element) * days_per_year
store_m_turnover = ccohort%prt%GetTurnover(store_organ, carbon12_element) * days_per_year
Expand Down Expand Up @@ -4509,7 +4509,7 @@ subroutine update_history_hifrq(this,nc,nsites,sites,bc_in,dt_tstep)

do s = 1,nsites

call this%zero_site_hvars(sites(s), upfreq_in=2)
call this%zero_site_hvars(sites(s), upfreq_in=2)

io_si = sites(s)%h_gid

Expand Down
15 changes: 9 additions & 6 deletions main/FatesInterfaceMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1976,14 +1976,15 @@ end subroutine FatesReportParameters

! =====================================================================================

subroutine UpdateFatesRMeansTStep(sites,bc_in)
subroutine UpdateFatesRMeansTStep(sites,bc_in, bc_out)

! In this routine, we update any FATES buffers where
! we calculate running means. It is assumed that this buffer is updated
! on the model time-step.

type(ed_site_type), intent(inout) :: sites(:)
type(bc_in_type), intent(in) :: bc_in(:)
type(bc_out_type), intent(inout) :: bc_out(:)

type(fates_patch_type), pointer :: cpatch
type(fates_cohort_type), pointer :: ccohort
Expand Down Expand Up @@ -2060,11 +2061,11 @@ subroutine UpdateFatesRMeansTStep(sites,bc_in)
ccohort => cpatch%tallest
do while (associated(ccohort))
! call ccohort%tveg_lpa%UpdateRMean(bc_in(s)%t_veg_pa(ifp))

! [kgC/plant/yr] -> [gC/m2/s]
site_npp = site_npp + ccohort%npp_acc_hold * ccohort%n*area_inv * &
g_per_kg * hlm_days_per_year / sec_per_day

if(.not.ccohort%isnew)then
! [kgC/plant/yr] -> [gC/m2/s]
site_npp = site_npp + ccohort%npp_acc_hold * ccohort%n*area_inv * &
g_per_kg * hlm_days_per_year / sec_per_day
end if
ccohort => ccohort%shorter
end do

Expand All @@ -2080,6 +2081,8 @@ subroutine UpdateFatesRMeansTStep(sites,bc_in)
sites(s)%ema_npp = (1._r8-1._r8/ema_npp_tscale)*sites(s)%ema_npp + (1._r8/ema_npp_tscale)*site_npp
end if

bc_out(s)%ema_npp = sites(s)%ema_npp

end do

return
Expand Down
1 change: 1 addition & 0 deletions main/FatesRestartInterfaceMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ module FatesRestartInterfaceMod
integer :: ir_gdd_si
integer :: ir_snow_depth_si
integer :: ir_trunk_product_si

integer :: ir_ncohort_pa
integer :: ir_canopy_layer_co
integer :: ir_canopy_layer_yesterday_co
Expand Down

0 comments on commit 1874511

Please sign in to comment.