Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor of LAI-by-patch-age history (FATES_LAI_AP) #1174

Merged
merged 5 commits into from
May 1, 2024
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 28 additions & 25 deletions main/FatesHistoryInterfaceMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,8 @@ module FatesHistoryInterfaceMod
integer :: ih_h2oveg_growturn_err_si
integer :: ih_h2oveg_hydro_err_si
integer :: ih_lai_si

integer :: ih_elai_si

integer :: ih_site_cstatus_si
integer :: ih_gdd_si
integer :: ih_site_nchilldays_si
Expand Down Expand Up @@ -2420,7 +2421,8 @@ subroutine update_history_dyn1(this,nc,nsites,sites,bc_in)
hio_tveg24 => this%hvars(ih_tveg24_si)%r81d, &
hio_tlongterm => this%hvars(ih_tlongterm_si)%r81d, &
hio_tgrowth => this%hvars(ih_tgrowth_si)%r81d, &
hio_lai_si => this%hvars(ih_lai_si)%r81d )
hio_lai_si => this%hvars(ih_lai_si)%r81d, &
hio_elai_si => this%hvars(ih_elai_si)%r81d)


! ---------------------------------------------------------------------------------
Expand Down Expand Up @@ -2585,9 +2587,12 @@ subroutine update_history_dyn1(this,nc,nsites,sites,bc_in)
hio_npatches_sec_si(io_si) = hio_npatches_sec_si(io_si) + 1._r8
end if

hio_lai_si(io_si) = hio_lai_si(io_si) + sum( cpatch%canopy_area_profile(:,:,:) * cpatch%elai_profile(:,:,:) ) * &
hio_lai_si(io_si) = hio_lai_si(io_si) + sum( cpatch%canopy_area_profile(:,:,:) * cpatch%tlai_profile(:,:,:) ) * &
cpatch%total_canopy_area * AREA_INV


hio_elai_si(io_si) = hio_elai_si(io_si) + sum( cpatch%canopy_area_profile(:,:,:) * cpatch%elai_profile(:,:,:) ) * &
cpatch%total_canopy_area * AREA_INV

! 24hr veg temperature
hio_tveg24(io_si) = hio_tveg24(io_si) + &
(cpatch%tveg24%GetMean()- t_water_freeze_k_1atm)*cpatch%area*AREA_INV
Expand Down Expand Up @@ -2922,6 +2927,10 @@ subroutine update_history_dyn1(this,nc,nsites,sites,bc_in)
hio_lai_secondary_si(io_si) = 0._r8
end if

! Normalize crown-area weighted height
if(site_ca>nearzero)then
hio_ca_weighted_height_si(io_si) = hio_ca_weighted_height_si(io_si)/site_ca
end if
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BA weighted height is set to zero if site_ba is not > nearzero. Seems like it would be a very small number anyway but do we want the same thing for CA weighted height?

Also the comment on 2867 could be updated to say that ca_weighted_height and ba_weighted_height are normalized outside of the patch loop.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left it out because we zero everything in an automated function anyway, we don't actually need to zero the ba weighted output. But now that you bring the point up, its probably confusing to anyone reading the code why we do things differently. I think its better to have these outputs processed consistently to avoid confusion. I'll do a look through and see if I can make things more consistent in other places as well.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, that makes sense.


! divide basal-area-weighted height by basal area to get mean
if ( site_ba .gt. nearzero ) then
Expand Down Expand Up @@ -3346,10 +3355,11 @@ subroutine update_history_dyn2(this,nc,nsites,sites,bc_in)

! Increment some patch-age-resolved diagnostics
hio_lai_si_age(io_si,cpatch%age_class) = hio_lai_si_age(io_si,cpatch%age_class) &
+ sum(cpatch%tlai_profile(:,:,:)) * cpatch%area

+ sum(cpatch%tlai_profile(:,:,:) * cpatch%canopy_area_profile(:,:,:) ) * cpatch%total_canopy_area
hio_ncl_si_age(io_si,cpatch%age_class) = hio_ncl_si_age(io_si,cpatch%age_class) &
+ cpatch%ncl_p * cpatch%area

hio_npatches_si_age(io_si,cpatch%age_class) = hio_npatches_si_age(io_si,cpatch%age_class) + 1._r8


Expand Down Expand Up @@ -5008,6 +5018,8 @@ subroutine update_history_hifrq1(this,nc,nsites,sites,bc_in,bc_out,dt_tstep)
if_notnew: if ( .not. ccohort%isnew ) then

! scale up cohort fluxes to the site level
! these fluxes have conversions of [kg/plant/timestep] -> [kg/m2/s]

hio_npp_si(io_si) = hio_npp_si(io_si) + &
ccohort%npp_tstep * n_perm2 * dt_tstep_inv

Expand Down Expand Up @@ -5059,9 +5071,9 @@ subroutine update_history_hifrq1(this,nc,nsites,sites,bc_in,bc_out,dt_tstep)
* n_perm2

! accumulate fluxes on canopy- and understory- separated fluxes
! these fluxes have conversions of [kg/plant/timestep] -> [kg/m2/s]
if (ccohort%canopy_layer .eq. 1) then

! bulk fluxes are in gC / m2 / s
hio_gpp_canopy_si(io_si) = hio_gpp_canopy_si(io_si) + &
ccohort%gpp_tstep * n_perm2 * dt_tstep_inv

Expand All @@ -5070,7 +5082,6 @@ subroutine update_history_hifrq1(this,nc,nsites,sites,bc_in,bc_out,dt_tstep)

else

! bulk fluxes are in gC / m2 / s
hio_gpp_understory_si(io_si) = hio_gpp_understory_si(io_si) + &
ccohort%gpp_tstep * n_perm2 * dt_tstep_inv

Expand Down Expand Up @@ -6145,11 +6156,17 @@ subroutine define_history_vars(this, initialize_variables)
index=ih_canopy_spread_si)

call this%set_history_var(vname='FATES_LAI', units='m2 m-2', &
long='leaf area index per m2 land area', &
long='total leaf area index per m2 land area', &
use_default='active', avgflag='A', vtype=site_r8, hlms='CLM:ALM', &
upfreq=group_dyna_simple, ivar=ivar, initialize=initialize_variables, &
index=ih_lai_si)


call this%set_history_var(vname='FATES_ELAI', units='m2 m-2', &
long='exposed (non snow-occluded) leaf area index per m2 land area', &
use_default='active', avgflag='A', vtype=site_r8, hlms='CLM:ALM', &
upfreq=group_dyna_simple, ivar=ivar, initialize=initialize_variables, &
index=ih_elai_si)

call this%set_history_var(vname='FATES_LAI_SECONDARY', units='m2 m-2', &
long='leaf area index per m2 land area, secondary patches', &
use_default='active', avgflag='A', vtype=site_r8, hlms='CLM:ALM', &
Expand Down Expand Up @@ -6897,7 +6914,7 @@ subroutine define_history_vars(this, initialize_variables)
initialize=initialize_variables, index=ih_area_si_age)

call this%set_history_var(vname='FATES_LAI_AP', units='m2 m-2', &
long='leaf area index by age bin per m2 land area', &
long='total leaf area index by age bin per m2 land area', &
use_default='active', avgflag='A', vtype=site_age_r8, hlms='CLM:ALM', &
upfreq=group_dyna_complx, ivar=ivar, initialize=initialize_variables, &
index=ih_lai_si_age)
Expand Down Expand Up @@ -8476,10 +8493,6 @@ subroutine define_history_vars(this, initialize_variables)
avgflag='A', vtype=site_r8, hlms='CLM:ALM', upfreq=group_hifr_simple, &
ivar=ivar, initialize=initialize_variables, index = ih_nir_rad_err_si)

call this%set_history_var(vname='FATES_AR', units='gC/m^2/s', &
long='autotrophic respiration', use_default='active', &
avgflag='A', vtype=site_r8, hlms='CLM:ALM', upfreq=group_hifr_simple, &
ivar=ivar, initialize=initialize_variables, index = ih_aresp_si )
! Ecosystem Carbon Fluxes (updated rapidly, upfreq=group_hifr_simple)

call this%set_history_var(vname='FATES_NPP', units='kg m-2 s-1', &
Expand Down Expand Up @@ -8542,16 +8555,6 @@ subroutine define_history_vars(this, initialize_variables)
upfreq=group_hifr_simple, ivar=ivar, initialize=initialize_variables, &
index = ih_maint_resp_secondary_si)

call this%set_history_var(vname='FATES_AR_CANOPY', units='gC/m^2/s', &
long='autotrophic respiration of canopy plants', use_default='active', &
avgflag='A', vtype=site_r8, hlms='CLM:ALM', upfreq=group_hifr_simple, &
ivar=ivar, initialize=initialize_variables, index = ih_ar_canopy_si )

call this%set_history_var(vname='FATES_AR_UNDERSTORY', units='gC/m^2/s', &
long='autotrophic respiration of understory plants', use_default='active', &
avgflag='A', vtype=site_r8, hlms='CLM:ALM', upfreq=group_hifr_simple, &
ivar=ivar, initialize=initialize_variables, index = ih_ar_understory_si )

! fast fluxes separated canopy/understory
call this%set_history_var(vname='FATES_GPP_CANOPY', units='kg m-2 s-1', &
long='gross primary production of canopy plants in kg carbon per m2 per second', &
Expand Down