diff --git a/main/EDMainMod.F90 b/main/EDMainMod.F90 index 159e942c6a..06e4b74c80 100644 --- a/main/EDMainMod.F90 +++ b/main/EDMainMod.F90 @@ -166,12 +166,6 @@ subroutine ed_ecosystem_dynamics(currentSite, bc_in, bc_out) call currentSite%flux_diags(el)%ZeroFluxDiags() end do - ! zero dynamics (upfreq_in = 1) output history variables - call fates_hist%zero_site_hvars(currentSite,upfreq_in=1) - - ! zero nutrient fluxes (upfreq_in=5) output hist variables - call fates_hist%zero_site_hvars(currentSite,upfreq_in=5) - ! Call a routine that simply identifies if logging should occur ! This is limited to a global event until more structured event handling is enabled call IsItLoggingTime(hlm_masterproc,currentSite) diff --git a/main/EDTypesMod.F90 b/main/EDTypesMod.F90 index 9c92871f1f..b482370058 100644 --- a/main/EDTypesMod.F90 +++ b/main/EDTypesMod.F90 @@ -150,8 +150,13 @@ module EDTypesMod type, public :: site_fluxdiags_type ! ---------------------------------------------------------------------------------- - ! Diagnostics for fluxes into the litter pool from plants - ! these fluxes are the total from + ! Diagnostics of fluxes + ! These act as an intermediary to write fluxes to the history + ! file after number densities of plants have changed. They also + ! allow the history flux diagnostics to be rebuilt during restart + ! + ! + ! Litter fluxes are the total from ! (1) turnover from living plants ! (2) mass transfer from non-disturbance inducing mortality events ! (3) mass transfer from disturbance inducing mortality events @@ -162,6 +167,13 @@ module EDTypesMod real(r8) :: cwd_bg_input(1:ncwd) real(r8),allocatable :: leaf_litter_input(:) real(r8),allocatable :: root_litter_input(:) + + ! This variable is slated as to-do, but the fluxdiags type needs + ! to be refactored first. Currently this type is allocated + ! by chemical species (ie C, N or P). GPP is C, but not N or P (RGK 0524) + ! Previous day GPP [kgC/m2/year], partitioned by size x pft + !real(r8),allocatable :: gpp_prev_scpf(:) + contains @@ -464,6 +476,11 @@ subroutine ZeroFluxDiags(this) this%cwd_bg_input(:) = 0._r8 this%leaf_litter_input(:) = 0._r8 this%root_litter_input(:) = 0._r8 + + ! We don't zero gpp_prev_scpf because this is not + ! incremented like others, it is assigned at the end + ! of the daily history write process + return end subroutine ZeroFluxDiags diff --git a/main/FatesHistoryInterfaceMod.F90 b/main/FatesHistoryInterfaceMod.F90 index fdd459f9c3..6c34f48292 100644 --- a/main/FatesHistoryInterfaceMod.F90 +++ b/main/FatesHistoryInterfaceMod.F90 @@ -33,6 +33,7 @@ module FatesHistoryInterfaceMod use FatesIOVariableKindMod , only : group_dyna_simple, group_dyna_complx use FatesIOVariableKindMod , only : group_hifr_simple, group_hifr_complx use FatesIOVariableKindMod , only : group_hydr_simple, group_hydr_complx + use FatesIOVariableKindMod , only : group_nflx_simple, group_nflx_complx use FatesConstantsMod , only : N_DIST_TYPES use FatesConstantsMod , only : dtype_ifall use FatesConstantsMod , only : dtype_ifire @@ -899,7 +900,7 @@ module FatesHistoryInterfaceMod procedure, public :: flush_hvars procedure, public :: zero_site_hvars - + procedure, public :: flush_all_hvars end type fates_history_interface_type @@ -1811,6 +1812,38 @@ subroutine zero_site_hvars(this, currentSite, upfreq_in) return end subroutine zero_site_hvars + + ! ====================================================================================== + + subroutine flush_all_hvars(this,nc) + + ! A wrapper to flush all active history + ! groups to their flush value + + class(fates_history_interface_type) :: this + integer,intent(in) :: nc + + if(hlm_hist_level_hifrq>0) then + call this%flush_hvars(nc,upfreq_in=group_hifr_simple) + if (hlm_use_planthydro.eq.itrue) call this%flush_hvars(nc,upfreq_in=group_hydr_simple) + if(hlm_hist_level_hifrq>1) then + call this%flush_hvars(nc,upfreq_in=group_hifr_complx) + if (hlm_use_planthydro.eq.itrue) call this%flush_hvars(nc,upfreq_in=group_hydr_complx) + end if + end if + + if(hlm_hist_level_dynam>0) then + call this%flush_hvars(nc,upfreq_in=group_dyna_simple) + call this%flush_hvars(nc,upfreq_in=group_nflx_simple) + if(hlm_hist_level_dynam>1) then + call this%flush_hvars(nc,upfreq_in=group_dyna_complx) + call this%flush_hvars(nc,upfreq_in=group_nflx_complx) + end if + end if + + return + end subroutine flush_all_hvars + ! ====================================================================================== subroutine flush_hvars(this,nc,upfreq_in) @@ -2093,6 +2126,9 @@ subroutine update_history_nutrflux(this,csite) ! history site index io_si = csite%h_gid + ! zero nutrient fluxes + call this%zero_site_hvars(csite,upfreq_in=group_nflx_simple) + cpatch => csite%youngest_patch do while(associated(cpatch)) @@ -2161,7 +2197,9 @@ subroutine update_history_nutrflux(this,csite) ! Demand this%hvars(ih_pdemand_si)%r81d(io_si) = & + this%hvars(ih_pdemand_si)%r81d(io_si) + & ccohort%daily_p_demand*uconv + end select end do @@ -2178,10 +2216,11 @@ subroutine update_history_nutrflux(this,csite) if_dynam2: if(hlm_hist_level_dynam>1) then - ! history site index io_si = csite%h_gid + call this%zero_site_hvars(csite,upfreq_in=group_nflx_complx) + cpatch => csite%youngest_patch do while(associated(cpatch)) @@ -2436,8 +2475,7 @@ subroutine update_history_dyn1(this,nc,nsites,sites,bc_in) site_ba = 0._r8 site_ca = 0._r8 - ! This should be removed from the interface and put here (RGK 04-24) - ! call this%zero_site_hvars(sites(s),upfreq_in=group_dyna_simple) + call this%zero_site_hvars(sites(s),upfreq_in=group_dyna_simple) ! set the fates fraction to one, since it is zero on non-fates columns, & ! the average is the total gridcell fates fraction @@ -3031,8 +3069,9 @@ subroutine update_history_dyn2(this,nc,nsites,sites,bc_in) integer :: iscagpft ! size-class x age x pft index integer :: icdpf, icdsc, icdam ! iterators for the crown damage level integer :: i_agefuel ! age x fuel size class index - real(r8) :: gpp_cached ! variable used to cache gpp value in previous time step; for C13 discrimination + real(r8) :: gpp_cached ! gpp from previous timestep, for c13 discrimination real(r8) :: crown_depth ! Depth of the crown [m] + real(r8) :: gpp_cached_scpf(numpft*nlevsclass) ! variable used to cache gpp value in previous time step; for C13 discrimination real(r8) :: storen_canopy_scpf(numpft*nlevsclass) real(r8) :: storen_understory_scpf(numpft*nlevsclass) real(r8) :: storep_canopy_scpf(numpft*nlevsclass) @@ -3269,10 +3308,18 @@ subroutine update_history_dyn2(this,nc,nsites,sites,bc_in) ! Loop through the FATES scale hierarchy and fill the history IO arrays ! --------------------------------------------------------------------------------- + siteloop: do s = 1,nsites io_si = sites(s)%h_gid + ! C13 will not get b4b restarts on the first day because + ! there is no mechanism to remember the previous day's values + ! through a restart. This should be added with the next refactor + gpp_cached_scpf(:) = hio_gpp_si_scpf(io_si,:) + + call this%zero_site_hvars(sites(s),upfreq_in=group_dyna_complx) + ! These are weighting factors storen_canopy_scpf(:) = 0._r8 storen_understory_scpf(:) = 0._r8 @@ -3328,7 +3375,6 @@ subroutine update_history_dyn2(this,nc,nsites,sites,bc_in) end if end do - ! Loop through patches to sum up diagonistics ipa = 0 cpatch => sites(s)%oldest_patch @@ -3605,16 +3651,16 @@ subroutine update_history_dyn2(this,nc,nsites,sites,bc_in) ! 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 + 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 + ccohort%npp_acc_hold * n_perm2 / (days_per_year*sec_per_day) if ( cpatch%land_use_label .eq. secondaryland ) 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 + 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 + ccohort%npp_acc_hold * n_perm2 / (days_per_year*sec_per_day) end if ! Turnover pools [kgC/day] * [day/yr] = [kgC/yr] @@ -3640,35 +3686,40 @@ subroutine update_history_dyn2(this,nc,nsites,sites,bc_in) capf => ccohort%coage_by_pft_class, & cdam => ccohort%crowndamage) - gpp_cached = (hio_gpp_si_scpf(io_si,scpf)) * & - days_per_year * sec_per_day - - ! [kgC/m2/s] + ! convert [kgC/plant/year] -> [kgC/m2/s] hio_gpp_si_scpf(io_si,scpf) = hio_gpp_si_scpf(io_si,scpf) + & - n_perm2*ccohort%gpp_acc_hold / days_per_year / sec_per_day + n_perm2*ccohort%gpp_acc_hold / (days_per_year*sec_per_day) + hio_npp_totl_si_scpf(io_si,scpf) = hio_npp_totl_si_scpf(io_si,scpf) + & - ccohort%npp_acc_hold * n_perm2 / days_per_year / sec_per_day + ccohort%npp_acc_hold * n_perm2 / (days_per_year*sec_per_day) hio_npp_leaf_si_scpf(io_si,scpf) = hio_npp_leaf_si_scpf(io_si,scpf) + & - leaf_m_net_alloc*n_perm2 / days_per_year / sec_per_day + leaf_m_net_alloc*n_perm2 / (days_per_year*sec_per_day) + hio_npp_fnrt_si_scpf(io_si,scpf) = hio_npp_fnrt_si_scpf(io_si,scpf) + & - fnrt_m_net_alloc*n_perm2 / days_per_year / sec_per_day + fnrt_m_net_alloc*n_perm2 / (days_per_year*sec_per_day) + hio_npp_bgsw_si_scpf(io_si,scpf) = hio_npp_bgsw_si_scpf(io_si,scpf) + & sapw_m_net_alloc*n_perm2*(1._r8-prt_params%allom_agb_frac(ccohort%pft)) / & - days_per_year / sec_per_day + (days_per_year*sec_per_day) + hio_npp_agsw_si_scpf(io_si,scpf) = hio_npp_agsw_si_scpf(io_si,scpf) + & sapw_m_net_alloc*n_perm2*prt_params%allom_agb_frac(ccohort%pft) / & - days_per_year / sec_per_day + (days_per_year*sec_per_day) + hio_npp_bgdw_si_scpf(io_si,scpf) = hio_npp_bgdw_si_scpf(io_si,scpf) + & struct_m_net_alloc*n_perm2*(1._r8-prt_params%allom_agb_frac(ccohort%pft)) / & - days_per_year / sec_per_day + (days_per_year*sec_per_day) + hio_npp_agdw_si_scpf(io_si,scpf) = hio_npp_agdw_si_scpf(io_si,scpf) + & struct_m_net_alloc*n_perm2*prt_params%allom_agb_frac(ccohort%pft) / & - days_per_year / sec_per_day + (days_per_year*sec_per_day) + hio_npp_seed_si_scpf(io_si,scpf) = hio_npp_seed_si_scpf(io_si,scpf) + & - repro_m_net_alloc*n_perm2 / days_per_year / sec_per_day + repro_m_net_alloc*n_perm2 / (days_per_year*sec_per_day) + hio_npp_stor_si_scpf(io_si,scpf) = hio_npp_stor_si_scpf(io_si,scpf) + & - store_m_net_alloc*n_perm2 / days_per_year / sec_per_day + store_m_net_alloc*n_perm2 / (days_per_year*sec_per_day) ! Woody State Variables (basal area growth increment) if ( prt_params%woody(ft) == itrue) then @@ -3746,12 +3797,16 @@ subroutine update_history_dyn2(this,nc,nsites,sites,bc_in) end if !C13 discrimination - if(gpp_cached + ccohort%gpp_acc_hold > 0.0_r8)then + if(abs(gpp_cached_scpf(scpf)-hlm_hio_ignore_val)>nearzero .and. & + (gpp_cached_scpf(scpf) + ccohort%gpp_acc_hold) > 0.0_r8) then + + gpp_cached = gpp_cached_scpf(scpf)*days_per_year*sec_per_day + hio_c13disc_si_scpf(io_si,scpf) = ((hio_c13disc_si_scpf(io_si,scpf) * gpp_cached) + & (ccohort%c13disc_acc * ccohort%gpp_acc_hold)) / (gpp_cached + ccohort%gpp_acc_hold) else hio_c13disc_si_scpf(io_si,scpf) = 0.0_r8 - endif + end if ! number density [/m2] hio_nplant_si_scpf(io_si,scpf) = hio_nplant_si_scpf(io_si,scpf) + ccohort%n / m2_per_ha @@ -4518,8 +4573,6 @@ subroutine update_history_dyn2(this,nc,nsites,sites,bc_in) ! Diagnostics discretized by element type ! ------------------------------------------------------------------------------ - hio_cwd_elcwd(io_si,:) = 0._r8 - do el = 1, num_elements flux_diags => sites(s)%flux_diags(el) @@ -4529,17 +4582,6 @@ subroutine update_history_dyn2(this,nc,nsites,sites,bc_in) sum(flux_diags%cwd_bg_input(:)) + sum(flux_diags%leaf_litter_input(:)) + & sum(flux_diags%root_litter_input(:))) / m2_per_ha / sec_per_day - hio_cwd_ag_elem(io_si,el) = 0._r8 - hio_cwd_bg_elem(io_si,el) = 0._r8 - hio_fines_ag_elem(io_si,el) = 0._r8 - hio_fines_bg_elem(io_si,el) = 0._r8 - - hio_seed_bank_elem(io_si,el) = 0._r8 - hio_seed_germ_elem(io_si,el) = 0._r8 - hio_seed_decay_elem(io_si,el) = 0._r8 - hio_seeds_in_local_elem(io_si,el) = 0._r8 - hio_seed_in_extern_elem(io_si,el) = 0._r8 - hio_litter_out_elem(io_si,el) = 0._r8 ! Plant multi-element states and fluxes ! Zero states, and set the fluxes @@ -4867,10 +4909,6 @@ subroutine update_history_hifrq1(this,nc,nsites,sites,bc_in,bc_out,dt_tstep) type(fates_cohort_type),pointer :: ccohort - ! This routine is only called for hlm_hist_level_hifrq >= 1 - if(hlm_hist_level_hifrq<1) return - - associate( hio_gpp_si => this%hvars(ih_gpp_si)%r81d, & hio_gpp_secondary_si => this%hvars(ih_gpp_secondary_si)%r81d, & hio_npp_si => this%hvars(ih_npp_si)%r81d, & @@ -4899,9 +4937,10 @@ subroutine update_history_hifrq1(this,nc,nsites,sites,bc_in,bc_out,dt_tstep) hio_tveg => this%hvars(ih_tveg_si)%r81d) - ! Flush the relevant history variables + ! THIS CAN BE REMOVED WHEN BOTH CTSM AND E3SM CALL FLUSH_ALL_HVARS + ! THIS IS NOT A LIABILITY, IT IS JUST REDUNDANT call this%flush_hvars(nc,upfreq_in=group_hifr_simple) - + dt_tstep_inv = 1.0_r8/dt_tstep allocate(age_area_rad(size(ED_val_history_ageclass_bin_edges,1)+1)) @@ -5142,9 +5181,6 @@ subroutine update_history_hifrq2(this,nc,nsites,sites,bc_in,bc_out,dt_tstep) type(fates_cohort_type),pointer :: ccohort real(r8) :: dt_tstep_inv ! Time step in frequency units (/s) - ! This routine is only called for hlm_hist_level_hifrq >= 1 - if(hlm_hist_level_hifrq<2) return - associate( hio_ar_si_scpf => this%hvars(ih_ar_si_scpf)%r82d, & hio_ar_grow_si_scpf => this%hvars(ih_ar_grow_si_scpf)%r82d, & hio_ar_maint_si_scpf => this%hvars(ih_ar_maint_si_scpf)%r82d, & @@ -5187,13 +5223,17 @@ subroutine update_history_hifrq2(this,nc,nsites,sites,bc_in,bc_out,dt_tstep) hio_laisun_si_can => this%hvars(ih_laisun_si_can)%r82d, & hio_laisha_si_can => this%hvars(ih_laisha_si_can)%r82d ) - ! Flush the relevant history variables - call this%flush_hvars(nc,upfreq_in=group_hifr_complx) + ! THIS CAN BE REMOVED WHEN BOTH CTSM AND E3SM CALL FLUSH_ALL_HVARS + ! THIS IS NOT A LIABILITY, IT IS JUST REDUNDANT + call this%flush_hvars(nc,upfreq_in=group_hifr_complx) + dt_tstep_inv = 1.0_r8/dt_tstep do_sites: do s = 1,nsites + call this%zero_site_hvars(sites(s), upfreq_in=group_hifr_complx) + site_area_veg_inv = 0._r8 cpatch => sites(s)%oldest_patch do while(associated(cpatch)) @@ -5213,8 +5253,6 @@ subroutine update_history_hifrq2(this,nc,nsites,sites,bc_in,bc_out,dt_tstep) patch_area_by_age(1:nlevage) = 0._r8 canopy_area_by_age(1:nlevage) = 0._r8 - call this%zero_site_hvars(sites(s), upfreq_in=group_hifr_complx) - cpatch => sites(s)%oldest_patch do while(associated(cpatch)) @@ -5617,7 +5655,8 @@ subroutine update_history_hydraulics(this,nc,nsites,sites,bc_in,dt_tstep) if_hifrq0: if(hlm_hist_level_hifrq>0) then - ! Flush the relevant history variables + ! THIS CAN BE REMOVED WHEN BOTH CTSM AND E3SM CALL FLUSH_ALL_HVARS + ! THIS IS NOT A LIABILITY, IT IS JUST REDUNDANT call this%flush_hvars(nc,upfreq_in=group_hydr_simple) associate( hio_h2oveg_hydro_err_si => this%hvars(ih_h2oveg_hydro_err_si)%r81d, & @@ -5724,6 +5763,8 @@ subroutine update_history_hydraulics(this,nc,nsites,sites,bc_in,dt_tstep) hio_rootuptake50_scpf => this%hvars(ih_rootuptake50_scpf)%r82d, & hio_rootuptake100_scpf => this%hvars(ih_rootuptake100_scpf)%r82d ) + ! THIS CAN BE REMOVED WHEN BOTH CTSM AND E3SM CALL FLUSH_ALL_HVARS + ! THIS IS NOT A LIABILITY, IT IS JUST REDUNDANT call this%flush_hvars(nc,upfreq_in=group_hydr_complx) do s = 1,nsites @@ -5810,8 +5851,6 @@ subroutine update_history_hydraulics(this,nc,nsites,sites,bc_in,dt_tstep) hio_rootuptake10_scpf(io_si,iscpf) = site_hydr%rootuptake10_scpf(iscls,ipft) * ha_per_m2 hio_rootuptake50_scpf(io_si,iscpf) = site_hydr%rootuptake50_scpf(iscls,ipft) * ha_per_m2 hio_rootuptake100_scpf(io_si,iscpf) = site_hydr%rootuptake100_scpf(iscls,ipft) * ha_per_m2 - hio_iterh1_scpf(io_si,iscpf) = 0._r8 - hio_iterh2_scpf(io_si,iscpf) = 0._r8 end do end do @@ -6379,31 +6418,31 @@ subroutine define_history_vars(this, initialize_variables) call this%set_history_var(vname='FATES_NH4UPTAKE', units='kg m-2 s-1', & long='ammonium uptake rate by plants in kg NH4 per m2 per second', & use_default='active', avgflag='A', vtype=site_r8, hlms='CLM:ALM', & - upfreq=group_dyna_simple, ivar=ivar, initialize=initialize_variables, & + upfreq=group_nflx_simple, ivar=ivar, initialize=initialize_variables, & index = ih_nh4uptake_si) call this%set_history_var(vname='FATES_NO3UPTAKE', units='kg m-2 s-1', & long='nitrate uptake rate by plants in kg NO3 per m2 per second', & use_default='active', avgflag='A', vtype=site_r8, hlms='CLM:ALM', & - upfreq=group_dyna_simple, ivar=ivar, initialize=initialize_variables, & + upfreq=group_nflx_simple, ivar=ivar, initialize=initialize_variables, & index = ih_no3uptake_si) call this%set_history_var(vname='FATES_NEFFLUX', units='kg m-2 s-1', & long='nitrogen effluxed from plant in kg N per m2 per second (unused)', & use_default='active', avgflag='A', vtype=site_r8, hlms='CLM:ALM', & - upfreq=group_dyna_simple, ivar=ivar, initialize=initialize_variables, & + upfreq=group_nflx_simple, ivar=ivar, initialize=initialize_variables, & index = ih_nefflux_si) call this%set_history_var(vname='FATES_NDEMAND', units='kg m-2 s-1', & long='plant nitrogen need (algorithm dependent) in kg N per m2 per second', & use_default='active', avgflag='A', vtype=site_r8, hlms='CLM:ALM', & - upfreq=group_dyna_simple, ivar=ivar, initialize=initialize_variables, & + upfreq=group_nflx_simple, ivar=ivar, initialize=initialize_variables, & index = ih_ndemand_si) call this%set_history_var(vname='FATES_NFIX_SYM', units='kg m-2 s-1', & long='symbiotic dinitrogen fixation in kg N per m2 per second', & use_default='active', avgflag='A', vtype=site_r8, hlms='CLM:ALM', & - upfreq=group_dyna_simple, ivar=ivar, initialize=initialize_variables, & + upfreq=group_nflx_simple, ivar=ivar, initialize=initialize_variables, & index = ih_nfix_si) call this%set_history_var(vname='FATES_STOREN', units='kg m-2', & @@ -6488,19 +6527,19 @@ subroutine define_history_vars(this, initialize_variables) call this%set_history_var(vname='FATES_PUPTAKE', units='kg m-2 s-1', & long='mineralized phosphorus uptake rate of plants in kg P per m2 per second', & use_default='active', avgflag='A', vtype=site_r8, hlms='CLM:ALM', & - upfreq=group_dyna_simple, ivar=ivar, initialize=initialize_variables, & + upfreq=group_nflx_simple, ivar=ivar, initialize=initialize_variables, & index = ih_puptake_si) call this%set_history_var(vname='FATES_PEFFLUX', units='kg m-2 s-1', & long='phosphorus effluxed from plant in kg P per m2 per second (unused)', & use_default='active', avgflag='A', vtype=site_r8, hlms='CLM:ALM', & - upfreq=group_dyna_simple, ivar=ivar, initialize=initialize_variables, & + upfreq=group_nflx_simple, ivar=ivar, initialize=initialize_variables, & index = ih_pefflux_si) call this%set_history_var(vname='FATES_PDEMAND', units='kg m-2 s-1', & long='plant phosphorus need (algorithm dependent) in kg P per m2 per second', & use_default='active', avgflag='A', vtype=site_r8, hlms='CLM:ALM', & - upfreq=group_dyna_simple, ivar=ivar, initialize=initialize_variables, & + upfreq=group_nflx_simple, ivar=ivar, initialize=initialize_variables, & index = ih_pdemand_si) end if phosphorus_active_if0 @@ -6596,11 +6635,15 @@ subroutine define_history_vars(this, initialize_variables) avgflag='A', vtype=site_r8, hlms='CLM:ALM', upfreq=group_dyna_simple, & ivar=ivar, initialize=initialize_variables, index = ih_harvest_debt_sec_si ) + ! Nutrient flux variables (dynamics call frequency) + ! ---------------------------------------------------- call this%set_history_var(vname='FATES_EXCESS_RESP', units='kg m-2 s-1', & long='respiration of un-allocatable carbon gain', & use_default='active', avgflag='A', vtype=site_r8, hlms='CLM:ALM', & - upfreq=group_dyna_simple, ivar=ivar, initialize=initialize_variables, & + upfreq=group_nflx_simple, ivar=ivar, initialize=initialize_variables, & index = ih_excess_resp_si) + + ! slow carbon fluxes associated with mortality from or transfer betweeen canopy and understory call this%set_history_var(vname='FATES_DEMOTION_CARBONFLUX', & @@ -7111,32 +7154,32 @@ subroutine define_history_vars(this, initialize_variables) units='kg m-2 s-1', & long='ammonium uptake rate by plants by size-class x pft in kg NH4 per m2 per second', & use_default='inactive', avgflag='A', vtype=site_size_pft_r8, & - hlms='CLM:ALM', upfreq=group_dyna_complx, ivar=ivar, & + hlms='CLM:ALM', upfreq=group_nflx_complx, ivar=ivar, & initialize=initialize_variables, index = ih_nh4uptake_scpf) call this%set_history_var(vname='FATES_NO3UPTAKE_SZPF', & units='kg m-2 s-1', & long='nitrate uptake rate by plants by size-class x pft in kg NO3 per m2 per second', & use_default='inactive', avgflag='A', vtype=site_size_pft_r8, & - hlms='CLM:ALM', upfreq=group_dyna_complx, ivar=ivar, & + hlms='CLM:ALM', upfreq=group_nflx_complx, ivar=ivar, & initialize=initialize_variables, index = ih_no3uptake_scpf) call this%set_history_var(vname='FATES_NEFFLUX_SZPF', units='kg m-2 s-1', & long='nitrogen efflux, root to soil, by size-class x pft in kg N per m2 per second', & use_default='inactive', avgflag='A', vtype=site_size_pft_r8, & - hlms='CLM:ALM', upfreq=group_dyna_complx, ivar=ivar, & + hlms='CLM:ALM', upfreq=group_nflx_complx, ivar=ivar, & initialize=initialize_variables, index = ih_nefflux_scpf) call this%set_history_var(vname='FATES_NDEMAND_SZPF', units='kg m-2 s-1', & long='plant N need (algorithm dependent), by size-class x pft in kg N per m2 per second', & use_default='inactive', avgflag='A', vtype=site_size_pft_r8, & - hlms='CLM:ALM', upfreq=group_dyna_complx, ivar=ivar, & + hlms='CLM:ALM', upfreq=group_nflx_complx, ivar=ivar, & initialize=initialize_variables, index = ih_ndemand_scpf) call this%set_history_var(vname='FATES_NFIX_SYM_SZPF', units='kg m-2 s-1', & long='symbiotic dinitrogen fixation, by size-class x pft in kg N per m2 per second', & use_default='inactive', avgflag='A', vtype=site_size_pft_r8, & - hlms='CLM:ALM', upfreq=group_dyna_complx, ivar=ivar, & + hlms='CLM:ALM', upfreq=group_nflx_complx, ivar=ivar, & initialize=initialize_variables, index = ih_nfix_scpf) call this%set_history_var(vname='FATES_VEGN_SZPF', units='kg m-2', & @@ -7248,20 +7291,20 @@ subroutine define_history_vars(this, initialize_variables) units='kg m-2 s-1', & long='phosphorus uptake rate by plants, by size-class x pft in kg P per m2 per second', & use_default='inactive', avgflag='A', vtype=site_size_pft_r8, & - hlms='CLM:ALM', upfreq=group_dyna_complx, ivar=ivar, & + hlms='CLM:ALM', upfreq=group_nflx_complx, ivar=ivar, & initialize=initialize_variables, index = ih_puptake_scpf) call this%set_history_var(vname='FATES_PEFFLUX_SZPF', & units='kg m-2 s-1', & long='phosphorus efflux, root to soil, by size-class x pft in kg P per m2 per second', & use_default='inactive', avgflag='A', vtype=site_size_pft_r8, & - hlms='CLM:ALM', upfreq=group_dyna_complx, ivar=ivar, & + hlms='CLM:ALM', upfreq=group_nflx_complx, ivar=ivar, & initialize=initialize_variables, index = ih_pefflux_scpf) call this%set_history_var(vname='FATES_PDEMAND_SZPF', units='kg m-2 s-1', & long='plant P need (algorithm dependent), by size-class x pft in kg P per m2 per second', & use_default='inactive', avgflag='A', vtype=site_size_pft_r8, & - hlms='CLM:ALM', upfreq=group_dyna_complx, ivar=ivar, & + hlms='CLM:ALM', upfreq=group_nflx_complx, ivar=ivar, & initialize=initialize_variables, index = ih_pdemand_scpf) end if phosphorus_active_if1 diff --git a/main/FatesIOVariableKindMod.F90 b/main/FatesIOVariableKindMod.F90 index 61e2c93c9d..75ea7dbe57 100644 --- a/main/FatesIOVariableKindMod.F90 +++ b/main/FatesIOVariableKindMod.F90 @@ -51,16 +51,36 @@ module FatesIOVariableKindMod character(*), parameter, public :: site_elcwd_r8 = 'SI_ELEMCWD_R8' character(*), parameter, public :: site_elage_r8 = 'SI_ELEMAGE_R8' - + ! ------------------------------------------------------------------ + ! + ! History Variable Groups + ! ! These are group indices for output variables. We use ! these groups to do things like zero-ing and initializing - + ! + ! These groups are updated at the dynamics (daily) step + ! so they are turned on and off with dimlevel(2) + ! + ! active when dimlevel(2)>0 integer, parameter, public :: group_dyna_simple = 1 + integer, parameter, public :: group_nflx_simple = 7 + + ! active when dimlevel(2)>1 integer, parameter, public :: group_dyna_complx = 2 + integer, parameter, public :: group_nflx_complx = 8 + + ! These groups are updated at the fast step + ! so they are turned on and off with dimlevel(1) + ! + ! active when dimlevel(1)>0 integer, parameter, public :: group_hifr_simple = 3 - integer, parameter, public :: group_hifr_complx = 4 integer, parameter, public :: group_hydr_simple = 5 + + ! active when dimlevel(1)>1 + integer, parameter, public :: group_hifr_complx = 4 integer, parameter, public :: group_hydr_complx = 6 + + ! ------------------------------------------------------------------- ! NOTE(RGK, 2016) %active is not used yet. Was intended as a check on the HLM->FATES ! control parameter passing to ensure all active dimension types received all