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

Stem area index AND canopy snow radiation fixes. #750

Merged
merged 34 commits into from
Nov 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
227ded7
sai bug changes first pass
rosiealice Jun 1, 2021
54f158b
addeding LAI+SAI criteria to radiation loop check
rosiealice Jun 1, 2021
ff4c61a
added error checking, and zero lai+sai capacity
rosiealice Jun 1, 2021
789342d
added tracking of residual radiation error for diagnosis
rosiealice Jun 2, 2021
c892b4e
removed frac_lai dummy args
rosiealice Jun 2, 2021
6f8acfb
rewind tracking of radiation errors
rosiealice Jun 7, 2021
f2b207e
removing Hui's bugfix
rosiealice Jun 7, 2021
63e35d7
whitespace corrections
rosiealice Jun 7, 2021
fa3874b
revert lgerror changes
rosiealice Jun 7, 2021
870b36c
removed total_lai_sai to simplify changes
rosiealice Jun 9, 2021
4e81d3e
reformatted esai statemnts, made laifrac=1
rosiealice Jun 23, 2021
89729a2
whitespace changes
rosiealice Jun 23, 2021
f796749
more whitespace changes
rosiealice Jun 23, 2021
6919a2f
revert ftid change
rosiealice Jun 23, 2021
17b7688
removed fraclai=1
rosiealice Jun 23, 2021
924c551
remove f_abs line, add fraclai check an zero out new indicies
rosiealice Jun 23, 2021
848bc48
modified photosynthetic radiation
rosiealice Jun 24, 2021
e670674
adding in error tracking variable
rosiealice Jun 30, 2021
a717efc
added radiation error output term
rosiealice Jul 2, 2021
1fbcb7d
snow on canopy implementation
rosiealice Jul 16, 2021
764827e
Merge branch 'master' into SAI_bugfix
ckoven Sep 27, 2021
11eeacc
auto-set margins and deleted trailing whitespace
ckoven Sep 27, 2021
ed515e8
Merge pull request #8 from ckoven/SAI_bugfix
rosiealice Oct 4, 2021
2f1ba5e
added fcansno to restart variables
ckoven Oct 5, 2021
14c57c5
Merge pull request #9 from ckoven/SAI_bugfix
rosiealice Oct 5, 2021
e760438
updates to fabs and fabs_leaf
rosiealice Oct 21, 2021
356dbd5
scaling patch%rad_error by patch vegetated fraction
ckoven Nov 3, 2021
56746e0
adding further logic to ignore rad_error when veg-covered patch fract…
ckoven Nov 3, 2021
0dfa707
removed FatesPFTIndexSwapper_rf.py
ckoven Nov 3, 2021
1ce8c80
Merge pull request #10 from ckoven/SAI_bugfix
rosiealice Nov 4, 2021
fc4a301
zeroing out the rad error if no leaves are present
glemieux Nov 4, 2021
9eaa0e4
Merge tag 'sci.1.49.0_api.17.0.0' into SAI_bugfix-nradcheckzero
glemieux Nov 4, 2021
3e098e5
adding comments to radiation_error calcs
glemieux Nov 4, 2021
0837c3c
Merge tag 'sci.1.50.0_api.17.0.0' into SAI_bugfix
glemieux Nov 20, 2021
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
15 changes: 9 additions & 6 deletions biogeochem/EDPatchDynamicsMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ subroutine disturbance_rates( site_in, bc_in)
enddo !patch loop

end subroutine disturbance_rates

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

subroutine spawn_patches( currentSite, bc_in)
Expand All @@ -451,7 +451,7 @@ subroutine spawn_patches( currentSite, bc_in)
! !USES:

use EDParamsMod , only : ED_val_understorey_death, logging_coll_under_frac
use EDCohortDynamicsMod , only : zero_cohort, copy_cohort, terminate_cohorts
use EDCohortDynamicsMod , only : zero_cohort, copy_cohort, terminate_cohorts
use FatesConstantsMod , only : rsnbl_math_prec

!
Expand Down Expand Up @@ -2201,6 +2201,7 @@ subroutine zero_patch(cp_p)
currentPatch%c_stomata = 0.0_r8 ! This is calculated immediately before use
currentPatch%c_lblayer = 0.0_r8
currentPatch%fragmentation_scaler(:) = 0.0_r8
currentPatch%radiation_error = 0.0_r8

! diagnostic radiation profiles
currentPatch%nrmlzd_parprof_pft_dir_z(:,:,:,:) = 0._r8
Expand All @@ -2210,6 +2211,7 @@ subroutine zero_patch(cp_p)

currentPatch%solar_zenith_flag = .false.
currentPatch%solar_zenith_angle = nan
currentPatch%fcansno = nan

currentPatch%gnd_alb_dir(:) = nan
currentPatch%gnd_alb_dif(:) = nan
Expand Down Expand Up @@ -2397,7 +2399,7 @@ subroutine fuse_patches( csite, bc_in )
!-------------------------------------------------------------------------!

if(fuse_flag == 1)then

!-----------------------!
! fuse the two patches !
!-----------------------!
Expand Down Expand Up @@ -2552,7 +2554,8 @@ subroutine fuse_2_patches(csite, dp, rp)
rp%zstar = (dp%zstar*dp%area + rp%zstar*rp%area) * inv_sum_area
rp%c_stomata = (dp%c_stomata*dp%area + rp%c_stomata*rp%area) * inv_sum_area
rp%c_lblayer = (dp%c_lblayer*dp%area + rp%c_lblayer*rp%area) * inv_sum_area

rp%radiation_error = (dp%radiation_error*dp%area + rp%radiation_error*rp%area) * inv_sum_area

rp%area = rp%area + dp%area !THIS MUST COME AT THE END!

!insert donor cohorts into recipient patch
Expand Down Expand Up @@ -2674,9 +2677,9 @@ subroutine terminate_patches(currentSite)

currentPatch => currentSite%youngest_patch
do while(associated(currentPatch))

if(currentPatch%area <= min_patch_area)then


! Even if the patch area is small, avoid fusing it into its neighbor
! if it is the youngest of all patches. We do this in attempts to maintain
Expand Down
221 changes: 144 additions & 77 deletions biogeophys/EDSurfaceAlbedoMod.F90

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions main/EDTypesMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ module EDTypesMod
real(r8) :: elai_profile(nclmax,maxpft,nlevleaf) ! exposed leaf area in each canopy layer, pft, and leaf layer
real(r8) :: tsai_profile(nclmax,maxpft,nlevleaf) ! total stem area in each canopy layer, pft, and leaf layer
real(r8) :: esai_profile(nclmax,maxpft,nlevleaf) ! exposed stem area in each canopy layer, pft, and leaf layer

real(r8) :: radiation_error ! radiation error (w/m2)
real(r8) :: layer_height_profile(nclmax,maxpft,nlevleaf)
real(r8) :: canopy_area_profile(nclmax,maxpft,nlevleaf) ! fraction of crown area per canopy area in each layer
! they will sum to 1.0 in the fully closed canopy layers
Expand All @@ -444,6 +444,7 @@ module EDTypesMod
integer :: ncan(nclmax,maxpft) ! number of total leaf layers for each canopy layer and pft

!RADIATION FLUXES
real(r8) :: fcansno ! Fraction of canopy covered in snow

logical :: solar_zenith_flag ! integer flag specifying daylight (based on zenith angle)
real(r8) :: solar_zenith_angle ! solar zenith angle (radians)
Expand Down Expand Up @@ -661,7 +662,7 @@ module EDTypesMod
procedure :: ZeroMassBalFlux

end type site_massbal_type


!************************************
!** Site type structure **
Expand All @@ -685,7 +686,7 @@ module EDTypesMod
! Global index of this site in the history output file
integer :: h_gid


! INDICES
real(r8) :: lat ! latitude: degrees
real(r8) :: lon ! longitude: degrees
Expand Down
13 changes: 13 additions & 0 deletions main/FatesHistoryInterfaceMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@ module FatesHistoryInterfaceMod

integer :: ih_c_stomata_si
integer :: ih_c_lblayer_si
integer :: ih_rad_error_si

integer :: ih_fire_c_to_atm_si

Expand Down Expand Up @@ -3431,6 +3432,7 @@ subroutine update_history_hifrq(this,nc,nsites,sites,bc_in,dt_tstep)
hio_growth_resp_si => this%hvars(ih_growth_resp_si)%r81d, &
hio_c_stomata_si => this%hvars(ih_c_stomata_si)%r81d, &
hio_c_lblayer_si => this%hvars(ih_c_lblayer_si)%r81d, &
hio_rad_error_si => this%hvars(ih_rad_error_si)%r81d, &
hio_nep_si => this%hvars(ih_nep_si)%r81d, &
hio_hr_si => this%hvars(ih_hr_si)%r81d, &
hio_ar_si_scpf => this%hvars(ih_ar_si_scpf)%r82d, &
Expand Down Expand Up @@ -3537,6 +3539,9 @@ subroutine update_history_hifrq(this,nc,nsites,sites,bc_in,dt_tstep)
hio_c_lblayer_si(io_si) = hio_c_lblayer_si(io_si) + &
cpatch%c_lblayer * cpatch%total_canopy_area

hio_rad_error_si(io_si) = hio_rad_error_si(io_si) + &
cpatch%radiation_error * cpatch%area * AREA_INV

ccohort => cpatch%shortest
do while(associated(ccohort))

Expand Down Expand Up @@ -4910,6 +4915,14 @@ subroutine define_history_vars(this, initialize_variables)
avgflag='A', vtype=site_r8, hlms='CLM:ALM', flushval=0.0_r8, upfreq=2, &
ivar=ivar, initialize=initialize_variables, index = ih_c_lblayer_si )

! radiation error

call this%set_history_var(vname='RAD_ERROR', units='W m-2 ', &
long='radiation error in FATES RTM', use_default='active', &
avgflag='A', vtype=site_r8, hlms='CLM:ALM', flushval=0.0_r8, upfreq=2, &
ivar=ivar, initialize=initialize_variables, index = ih_rad_error_si )



! Ecosystem Carbon Fluxes (updated rapidly, upfreq=2)

Expand Down
16 changes: 9 additions & 7 deletions main/FatesInterfaceMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ subroutine zero_bcs(fates,s)
fates%bc_in(s)%h2o_liqvol_sl(:) = 0.0_r8
fates%bc_in(s)%filter_vegzen_pa(:) = .false.
fates%bc_in(s)%coszen_pa(:) = 0.0_r8
fates%bc_in(s)%fcansno_pa(:) = 0.0_r8
fates%bc_in(s)%albgr_dir_rb(:) = 0.0_r8
fates%bc_in(s)%albgr_dif_rb(:) = 0.0_r8
fates%bc_in(s)%max_rooting_depth_index_col = 0
Expand Down Expand Up @@ -337,7 +338,7 @@ subroutine zero_bcs(fates,s)
fates%bc_out(s)%z0m_pa(:) = 0.0_r8
fates%bc_out(s)%dleaf_pa(:) = 0.0_r8
fates%bc_out(s)%nocomp_pft_label_pa(:) = 0

fates%bc_out(s)%canopy_fraction_pa(:) = 0.0_r8
fates%bc_out(s)%frac_veg_nosno_alb_pa(:) = 0.0_r8

Expand All @@ -346,7 +347,7 @@ subroutine zero_bcs(fates,s)
fates%bc_out(s)%qflx_ro_sisl(:) = 0.0_r8
end if
fates%bc_out(s)%plant_stored_h2o_si = 0.0_r8

return
end subroutine zero_bcs

Expand Down Expand Up @@ -488,6 +489,7 @@ subroutine allocate_bcin(bc_in, nlevsoil_in, nlevdecomp_in, num_lu_harvest_cats)
! Canopy Radiation
allocate(bc_in%filter_vegzen_pa(maxPatchesPerSite))
allocate(bc_in%coszen_pa(maxPatchesPerSite))
allocate(bc_in%fcansno_pa(maxPatchesPerSite))
allocate(bc_in%albgr_dir_rb(hlm_numSWb))
allocate(bc_in%albgr_dif_rb(hlm_numSWb))

Expand Down Expand Up @@ -606,7 +608,7 @@ subroutine allocate_bcout(bc_out, nlevsoil_in, nlevdecomp_in)
bc_out%rootfr_pa(0,1:nlevsoil_in)=1._r8/real(nlevsoil_in,r8)
end if


! Fates -> BGC fragmentation mass fluxes
select case(hlm_parteh_mode)
case(prt_carbon_allom_hyp)
Expand Down Expand Up @@ -650,7 +652,7 @@ subroutine allocate_bcout(bc_out, nlevsoil_in, nlevdecomp_in)

allocate(bc_out%canopy_fraction_pa(maxPatchesPerSite))
allocate(bc_out%frac_veg_nosno_alb_pa(maxPatchesPerSite))

allocate(bc_out%nocomp_pft_label_pa(maxPatchesPerSite))

! Plant-Hydro BC's
Expand Down Expand Up @@ -1521,9 +1523,9 @@ subroutine set_fates_ctrlparms(tag,ival,rval,cval)
call endrun(msg=errMsg(sourcefile, __LINE__))
end if
end if


if(hlm_use_fixed_biogeog.eq.unset_int) then

if(hlm_use_fixed_biogeog.eq.unset_int) then
if(fates_global_verbose()) then
write(fates_log(), *) 'switch for fixed biogeog unset: him_use_fixed_biogeog, exiting'
end if
Expand Down Expand Up @@ -1824,7 +1826,7 @@ subroutine FatesReportParameters(masterproc)
call PRTDerivedParams() ! Update PARTEH derived constants
call PRTCheckParams(masterproc) ! Check PARTEH parameters
call SpitFireCheckParams(masterproc)



return
Expand Down
11 changes: 7 additions & 4 deletions main/FatesInterfaceTypesMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ module FatesInterfaceTypesMod
! 2 = patch is currently marked for photosynthesis
! 3 = patch has been called for photosynthesis at least once
integer, allocatable :: filter_photo_pa(:)

! atmospheric pressure (Pa)
real(r8) :: forc_pbot

Expand Down Expand Up @@ -447,7 +447,10 @@ module FatesInterfaceTypesMod
! I am leaving it at this scale for simplicity. Patches should
! have no spacially variable information
real(r8), allocatable :: coszen_pa(:)


! fraction of canopy that is covered in snow
real(r8), allocatable :: fcansno_pa(:)

! Abledo of the ground for direct radiation, by site broadband (0-1)
real(r8), allocatable :: albgr_dir_rb(:)

Expand Down Expand Up @@ -681,7 +684,7 @@ module FatesInterfaceTypesMod

integer, allocatable :: nocomp_pft_label_pa(:) ! in nocomp and SP mode, each patch has a PFT identity.

! FATES Hydraulics
! FATES Hydraulics



Expand Down Expand Up @@ -735,7 +738,7 @@ module FatesInterfaceTypesMod
! increasing, or all 1s)

end type bc_pconst_type



contains
Expand Down
10 changes: 10 additions & 0 deletions main/FatesRestartInterfaceMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ module FatesRestartInterfaceMod
integer :: ir_lmort_infra_co

! Radiation
integer :: ir_fcansno_pa
integer :: ir_solar_zenith_flag_pa
integer :: ir_solar_zenith_angle_pa
integer :: ir_gnd_alb_dif_pasb
Expand Down Expand Up @@ -654,6 +655,10 @@ subroutine define_restart_vars(this, initialize_variables)
long_name='the number of cohorts per patch', units='unitless', flushval = flushinvalid, &
hlms='CLM:ALM', initialize=initialize_variables, ivar=ivar, index = ir_ncohort_pa )

call this%set_restart_var(vname='fates_fcansno_pa', vtype=cohort_r8, &
long_name='Fraction of canopy covered in snow', units='unitless', flushval = flushinvalid, &
hlms='CLM:ALM', initialize=initialize_variables, ivar=ivar, index = ir_fcansno_pa )

call this%set_restart_var(vname='fates_solar_zenith_flag_pa', vtype=cohort_int, &
long_name='switch specifying if zenith is positive', units='unitless', flushval = flushinvalid, &
hlms='CLM:ALM', initialize=initialize_variables, ivar=ivar, index = ir_solar_zenith_flag_pa )
Expand Down Expand Up @@ -1651,6 +1656,7 @@ subroutine set_restart_vectors(this,nc,nsites,sites)
rio_snow_depth_si => this%rvars(ir_snow_depth_si)%r81d, &
rio_trunk_product_si => this%rvars(ir_trunk_product_si)%r81d, &
rio_ncohort_pa => this%rvars(ir_ncohort_pa)%int1d, &
rio_fcansno_pa => this%rvars(ir_fcansno_pa)%r81d, &
rio_solar_zenith_flag_pa => this%rvars(ir_solar_zenith_flag_pa)%int1d, &
rio_solar_zenith_angle_pa => this%rvars(ir_solar_zenith_angle_pa)%r81d, &
rio_canopy_layer_co => this%rvars(ir_canopy_layer_co)%int1d, &
Expand Down Expand Up @@ -1971,6 +1977,8 @@ subroutine set_restart_vectors(this,nc,nsites,sites)
! set cohorts per patch for IO
rio_ncohort_pa( io_idx_co_1st ) = cohortsperpatch

rio_fcansno_pa( io_idx_co_1st ) = cpatch%fcansno

! Set zenith angle info
if ( cpatch%solar_zenith_flag ) then
rio_solar_zenith_flag_pa(io_idx_co_1st) = itrue
Expand Down Expand Up @@ -2466,6 +2474,7 @@ subroutine get_restart_vectors(this, nc, nsites, sites)
rio_snow_depth_si => this%rvars(ir_snow_depth_si)%r81d, &
rio_trunk_product_si => this%rvars(ir_trunk_product_si)%r81d, &
rio_ncohort_pa => this%rvars(ir_ncohort_pa)%int1d, &
rio_fcansno_pa => this%rvars(ir_fcansno_pa)%r81d, &
rio_solar_zenith_flag_pa => this%rvars(ir_solar_zenith_flag_pa)%int1d, &
rio_solar_zenith_angle_pa => this%rvars(ir_solar_zenith_angle_pa)%r81d, &
rio_canopy_layer_co => this%rvars(ir_canopy_layer_co)%int1d, &
Expand Down Expand Up @@ -2770,6 +2779,7 @@ subroutine get_restart_vectors(this, nc, nsites, sites)
cpatch%nocomp_pft_label = rio_nocomp_pft_label_pa(io_idx_co_1st)
cpatch%area = rio_area_pa(io_idx_co_1st)
cpatch%age_class = get_age_class_index(cpatch%age)
cpatch%fcansno = rio_fcansno_pa(io_idx_co_1st)

! Set zenith angle info
cpatch%solar_zenith_flag = ( rio_solar_zenith_flag_pa(io_idx_co_1st) .eq. itrue )
Expand Down