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

two-stream - b4b Norman and no history changes #1141

Merged
merged 114 commits into from
Jan 16, 2024
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
114 commits
Select commit Hold shift + click to select a range
1a7fdb1
Added two-stream code and common globals
rgknox May 15, 2023
282d8ca
Refactor some fates radiation code. New shared memory, and renamed dr…
rgknox May 15, 2023
013e07f
two-stream changes, updated photosynthesis calls to protect against n…
rgknox May 16, 2023
a11d4ae
cleaning up two-stream calls and comments
rgknox May 16, 2023
b786308
Added fsun to history diagnostics,testing different fsun formulations…
rgknox May 19, 2023
882e02a
added type definition
rgknox May 19, 2023
53ee4a2
All sorts of two-stream and general radiation clean up
rgknox Jun 1, 2023
e7b58da
Updated error logging in twostream to use logging file units and erro…
rgknox Jun 5, 2023
6ccedd5
removed cold init argument for radiation driver start
rgknox Jun 12, 2023
783639b
bug fix related to two-stream radiation updates
rgknox Jun 19, 2023
8e34f39
Various updates and fixes to two-stream, including error checking and…
rgknox Jun 23, 2023
5211412
Fix to the restart order issue
rgknox Jun 23, 2023
5b2129a
moved nlevsclass calculation earlier in subroutine
rgknox Jun 23, 2023
28eab39
Added site level scratch array for the 2stream solver
rgknox Jul 12, 2023
22b6b36
Updated unit tests to handle scratch arrays in twostream
rgknox Jul 14, 2023
ae56d63
Merge up two-stream part 1
rgknox Aug 24, 2023
3e959a8
merge resolution between two-stream and patch/cohort refactor
rgknox Aug 24, 2023
6782b4a
removing layer height profile, for now
rgknox Aug 24, 2023
fe3c57f
Merge branch 'main' into two-stream-clean-api26-v2
rgknox Sep 11, 2023
7dc7c47
conflict resolutions for two-stream
rgknox Sep 12, 2023
6d59ea5
add readme to init bld directory
rgknox Sep 19, 2023
3a6b2dc
Updates to two-stream functional unit tests
rgknox Sep 19, 2023
fd0d926
Connected the radiation model switch in the parameter file to the in-…
rgknox Sep 20, 2023
e2aac37
Merge branch 'two-stream-clean-api26-v2' into two-stream-clean-api26
rgknox Sep 20, 2023
d7396b1
Updated radiation model checks to allow for norman and two-stream. Up…
rgknox Sep 21, 2023
bc03f65
Started a new radiation unit test that is used to target specific can…
rgknox Sep 27, 2023
174f292
Updates to two-stream error reporting, checking the linear solution, …
rgknox Sep 29, 2023
b282476
Merge branch 'two-stream-clean' of github.com:rgknox/fates into two-s…
rgknox Oct 4, 2023
e10595c
Applied higher threshold to two-stream closure check, added forced cl…
rgknox Oct 4, 2023
5217289
Set albedo correction to true in fates two-stream
rgknox Oct 4, 2023
f44848b
Merge branch 'two-stream-clean-albedo' into two-stream-clean
rgknox Oct 4, 2023
713bbad
small updates to two-stream unit tests
rgknox Oct 6, 2023
3c6dee2
Added error tracking in two-stream
rgknox Oct 9, 2023
3966cc8
Updates to error tracking of two-stream
rgknox Oct 16, 2023
1f6eb83
Update biogeochem/FatesAllometryMod.F90
rgknox Oct 17, 2023
25923bc
Update radiation/TwoStreamMLPEMod.F90
rgknox Oct 17, 2023
169a8bd
Updates to functional unit test code
rgknox Oct 17, 2023
b74b021
Merge branch 'two-stream-clean-errcheck' into two-stream-clean
rgknox Oct 17, 2023
4d8bebc
Updates to the history file for twostream
rgknox Oct 18, 2023
b3370b9
Cleaning two-stream and radiation drivers to get correct history diag…
rgknox Oct 18, 2023
460645d
more cleaning of radiation history
rgknox Oct 18, 2023
bd33520
updates to the radiation history diagnostics
rgknox Oct 18, 2023
1a3ae69
Changed the avmu radiation parameter to a constant remembered in the …
rgknox Oct 18, 2023
156a17a
Added isnan() functions instead of comparing to self
rgknox Oct 19, 2023
a26146d
Removed old optional two-stream derivations and now using only B1 and…
rgknox Oct 24, 2023
a9260d0
Added checks on scattering coefficient
rgknox Oct 25, 2023
772d57e
Merge branch 'two-stream-clean' into two-stream-clean-v3solution
rgknox Oct 25, 2023
df2dee1
fixed typo
rgknox Oct 25, 2023
8ff6444
Merge branch 'two-stream-clean-v3solution' into two-stream-clean
rgknox Oct 25, 2023
391a4f6
merge resolution and reverting of inventory init to not dump output
rgknox Oct 25, 2023
c3da9e6
Updated messaging on the param check failure if the fates_rad_model i…
rgknox Oct 26, 2023
789c36a
Updated fail message on rad parameter bounds
rgknox Oct 26, 2023
7f14138
Addressing reviewer comments
rgknox Oct 26, 2023
1aa2ead
removed unused alias in fateshistoryinterface
rgknox Oct 26, 2023
dbb2cfe
fixes to lingering merge conflict resolutions
rgknox Oct 26, 2023
83f8156
Adding in protections to avoid Kb==a in two-stream
rgknox Nov 6, 2023
904c0e4
Merge branch 'two-stream-clean' of github.com:rgknox/fates into two-s…
rgknox Nov 6, 2023
7112368
clean up comments and old text in two-stream code
rgknox Nov 6, 2023
6ca1ccb
Conflict resolution two-stream and api30
rgknox Nov 7, 2023
2e140be
small tweaks to error tracking in fates two-stream
rgknox Nov 8, 2023
9f6f5c2
cleaning up conservation error diagnostics
rgknox Nov 9, 2023
3fa96a3
Tweaking the correction to beam optical depth, needs provisions for n…
rgknox Nov 12, 2023
cb6b677
Initializing two-stream error with the ignore flag
rgknox Nov 17, 2023
24760aa
Tweaks to area squeezing in two-stream
rgknox Nov 21, 2023
d35b9b1
bug fix in area squeezing during two-stream
rgknox Nov 21, 2023
0d7b490
Merge two-stream with api31
rgknox Nov 21, 2023
31ed39b
cleaned up canopy mask logic
rgknox Nov 22, 2023
38c3f1f
Added in code to preserve leaf to cohort scaling in norman mode, will…
rgknox Nov 28, 2023
33c83cb
trivial merge resolution between two-stream and inventory uppdates
rgknox Nov 28, 2023
46ecf39
altnerate reverted form of leaf layer calculation
rgknox Nov 30, 2023
624293b
testing out b4b corrections
rgknox Dec 1, 2023
5f4a8b6
Reverted incorrect nscalar
rgknox Dec 1, 2023
33cb3ae
Merge branch 'two-stream-clean' into two-stream-clean-b4b
rgknox Dec 2, 2023
b88f636
More b4b attempts at two-stream
rgknox Dec 4, 2023
3c0051e
debugging logic ends
rgknox Dec 7, 2023
c71dadb
more b4b attempts at two-stream
rgknox Dec 8, 2023
e0c564f
Merge branch 'two-stream-clean-b4b' into two-stream-clean-b4b2
rgknox Dec 8, 2023
1d64107
making switches in b4b check consistent
rgknox Dec 8, 2023
d4ac49b
reverting history code in two-stream to match main for b4b
rgknox Dec 8, 2023
da54174
attempts to revert history code in 2str to get b4b
rgknox Dec 8, 2023
1df494a
small b4b changes to two-stream
rgknox Dec 12, 2023
56aa325
Creating seperate module for norman rad
rgknox Dec 12, 2023
8cc57c9
fixed some typos
rgknox Dec 13, 2023
7abc732
cleaning up photosynthesis code w/two-stream
rgknox Dec 13, 2023
40f1a2a
Merge branch 'two-stream-clean-b4b-hist' into two-stream-clean-b4b2
rgknox Dec 13, 2023
a3754a1
Reverted history code to be as similar to base as possible
rgknox Dec 13, 2023
a972ff3
more two-stream b4b work
rgknox Dec 14, 2023
c34773a
reinstated ed_laisun_z and ed_laisha_z for b4b tests
rgknox Dec 14, 2023
0c1e890
reverting canopy mask for b4b
rgknox Dec 14, 2023
89aecd1
reworking towards b4b
rgknox Dec 15, 2023
c6da2fe
b4b stuff
rgknox Dec 15, 2023
f6b879e
b4b stuff for two-stream
rgknox Dec 18, 2023
140e6ff
b4b for two-stream
rgknox Dec 18, 2023
36105c3
more b4b stuff
rgknox Dec 19, 2023
312593f
revert history to match main
rgknox Dec 20, 2023
36be028
merge two-stream with lu1
rgknox Dec 20, 2023
62a37f9
removed solver error (redundant with conservation error)
rgknox Dec 20, 2023
893d8cf
merge updates on two-stream with luh2, as well as consolidation of ra…
rgknox Dec 21, 2023
b743547
two-stream cleaning up
rgknox Dec 22, 2023
0366819
adding text around preserve_b4b
rgknox Dec 27, 2023
5e4c6df
removed redundant declaration
rgknox Dec 27, 2023
f416029
Updating scipy module importing to work for both new and old conventions
rgknox Jan 3, 2024
9fa0153
added try clause to scipy module loading
rgknox Jan 3, 2024
64eb770
deleted unnecessary comment
rgknox Jan 3, 2024
6935a40
removed unncecessary comment
rgknox Jan 3, 2024
5daf737
set intent in on veg_tempk
rgknox Jan 3, 2024
1642919
removed unused global declarations in history
rgknox Jan 3, 2024
200f024
removing hlm_numSWb use in code, it is redundant
rgknox Jan 3, 2024
f6832c3
two-stream responding to reviewer comments
rgknox Jan 4, 2024
d127f51
resolving more reviewer comments
rgknox Jan 4, 2024
0079a85
Fixing zero protections on two-stream zenith calcualtions
rgknox Jan 10, 2024
9c6f822
Merge branch 'main' into two-stream-clean-b4b-nohist
rgknox Jan 10, 2024
af2c3b9
Fixes to nan checks in fates two-stream
rgknox Jan 12, 2024
7b2cdbe
fixed try statement on module importing in python scipy
rgknox Jan 12, 2024
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
22 changes: 13 additions & 9 deletions biogeochem/EDCanopyStructureMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ module EDCanopyStructureMod
use FatesCohortMod, only : fates_cohort_type
use EDParamsMod , only : nclmax
use EDParamsMod , only : nlevleaf
use EDParamsMod , only : radiation_model
use EDtypesMod , only : AREA
use EDLoggingMortalityMod , only : UpdateHarvestC
use FatesGlobals , only : endrun => fates_endrun
Expand All @@ -46,6 +47,7 @@ module EDCanopyStructureMod
use PRTGenericMod, only : carbon12_element
use FatesAllometryMod , only : VegAreaLayer
use FatesTwoStreamInterfaceMod, only : FatesConstructRadElements
use FatesRadiationMemMod , only : twostr_solver

! CIME Globals
use shr_log_mod , only : errMsg => shr_log_errMsg
Expand Down Expand Up @@ -1436,9 +1438,10 @@ subroutine canopy_summarization( nsites, sites, bc_in )
end do !patch loop

call leaf_area_profile(sites(s))

call FatesConstructRadElements(sites(s),bc_in(s)%fcansno_pa,bc_in(s)%coszen_pa)

if(radiation_model.eq.twostr_solver) then
call FatesConstructRadElements(sites(s),bc_in(s)%fcansno_pa,bc_in(s)%coszen_pa)
end if

end do ! site loop

Expand Down Expand Up @@ -1519,16 +1522,16 @@ subroutine leaf_area_profile( currentSite )
integer :: iv ! Vertical leaf layer index
integer :: cl ! Canopy layer index
real(r8) :: fraction_exposed ! how much of this layer is not covered by snow?
real(r8) :: frac_canopy(N_HITE_BINS) ! amount of canopy in each height class
real(r8) :: minh(N_HITE_BINS) ! minimum height in height class (m)
real(r8) :: maxh(N_HITE_BINS) ! maximum height in height class (m)
real(r8) :: frac_canopy(N_HEIGHT_BINS) ! amount of canopy in each height class
real(r8) :: minh(N_HEIGHT_BINS) ! minimum height in height class (m)
real(r8) :: maxh(N_HEIGHT_BINS) ! maximum height in height class (m)
real(r8) :: dh ! vertical detph of height class (m)
real(r8) :: min_chite ! bottom of cohort canopy (m)
real(r8) :: max_chite ! top of cohort canopy (m)
real(r8) :: min_cheight ! bottom of cohort canopy (m)
real(r8) :: max_cheight ! top of cohort canopy (m)
real(r8) :: elai_layer,tlai_layer ! leaf area per canopy area
real(r8) :: esai_layer,tsai_layer ! stem area per canopy area
real(r8) :: vai_top,vai_bot ! integrated top down veg area index at boundary of layer

!----------------------------------------------------------------------


Expand Down Expand Up @@ -1581,12 +1584,13 @@ subroutine leaf_area_profile( currentSite )

call VegAreaLayer(currentCohort%treelai, &
currentCohort%treesai, &
currentCohort%hite, &
currentCohort%height, &
iv,currentCohort%nv,currentCohort%pft, &
currentSite%snow_depth, &
vai_top,vai_bot, &
elai_layer,esai_layer,tlai_layer,tsai_layer)


currentPatch%tlai_profile(cl,ft,iv) = currentPatch%tlai_profile(cl,ft,iv) + &
tlai_layer * currentCohort%c_area/currentPatch%total_canopy_area

Expand Down
2 changes: 1 addition & 1 deletion biogeophys/FatesPlantRespPhotosynthMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ subroutine FatesPlantRespPhotosynthDrive (nsites, sites,bc_in,bc_out,dtime)
do iv = 1,currentCohort%nv
call VegAreaLayer(currentCohort%treelai, &
currentCohort%treesai, &
currentCohort%hite, &
currentCohort%height, &
iv, &
currentCohort%nv, &
currentCohort%pft, &
Expand Down
8 changes: 4 additions & 4 deletions main/EDPftvarcon.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1792,9 +1792,9 @@ subroutine FatesCheckParams(is_master)
if(.not.is_master) return

if(.not.any(radiation_model == [norman_solver,twostr_solver])) then
write(fates_log(),*) 'The only available canopy radiation model'
write(fates_log(),*) 'is the Norman scheme: fates_rad_model = 1'
write(fates_log(),*) 'The two-stream scheme is not available yet'
write(fates_log(),*) 'The only available canopy radiation models'
write(fates_log(),*) 'are the Norman and Two-stream schemes, '
write(fates_log(),*) 'fates_rad_model = 1 or 2 ...'
write(fates_log(),*) 'You specified fates_rad_model = ',radiation_model
write(fates_log(),*) 'Aborting'
call endrun(msg=errMsg(sourcefile, __LINE__))
Expand Down Expand Up @@ -1920,7 +1920,7 @@ subroutine FatesCheckParams(is_master)
! xl must be between -0.4 and 0.6 according to Bonan (2019) doi:10.1017/9781107339217 pg. 238
!-----------------------------------------------------------------------------------
if (EDPftvarcon_inst%xl(ipft) < -0.4 .or. EDPftvarcon_inst%xl(ipft) > 0.6) then
write(fates_log(),*) 'fates_rad_leaf_xl for pft ', ipft, ' is outside the allowed range of -0.6 to 0.4'
write(fates_log(),*) 'fates_rad_leaf_xl for pft ', ipft, ' is outside the allowed range of -0.4 to 0.6'
write(fates_log(),*) 'Aborting'
call endrun(msg=errMsg(sourcefile, __LINE__))
end if
Expand Down
7 changes: 3 additions & 4 deletions main/FatesInventoryInitMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ module FatesInventoryInitMod
! defined in model memory and a physical
! site listed in the file

logical, parameter :: do_inventory_out = .true.
logical, parameter :: do_inventory_out = .false.


public :: initialize_sites_by_inventory
Expand Down Expand Up @@ -1033,9 +1033,8 @@ subroutine set_inventory_edcohort_type1(csite,bc_in,css_file_unit,npatches, &
temp_cohort%dbh = c_dbh
temp_cohort%crowndamage = 1 ! assume undamaged



call h_allom(c_dbh,temp_cohort%pft,temp_cohort%hite)
call h_allom(c_dbh,temp_cohort%pft,temp_cohort%height)

temp_cohort%canopy_trim = 1.0_r8

! Determine the phenology status and the elongation factors.
Expand Down
9 changes: 5 additions & 4 deletions main/FatesRestartInterfaceMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ module FatesRestartInterfaceMod
use PRTGenericMod, only : num_elements
use FatesRunningMeanMod, only : rmean_type
use FatesRunningMeanMod, only : ema_lpa
use FatesRadiationMemMod, only : num_swb,norman_solver
use FatesRadiationMemMod, only : num_swb,norman_solver,twostr_solver
use TwoStreamMLPEMod, only : normalized_upper_boundary
use EDParamsMod, only : regeneration_model
use EDParamsMod, only : radiation_model
Expand Down Expand Up @@ -3655,7 +3655,8 @@ subroutine update_3dpatch_radiation(this, nsites, sites, bc_out)
enddo
else

if_solver: if(radiation_model.eq.norman_solver) then
select case(radiation_model)
case(norman_solver)

call PatchNormanRadiation (currentPatch, &
bc_out(s)%albd_parb(ifp,:), &
Expand All @@ -3667,7 +3668,7 @@ subroutine update_3dpatch_radiation(this, nsites, sites, bc_out)
bc_out(s)%ftii_parb(ifp,:))


else
case(twostr_solver)
associate( twostr => currentPatch%twostr)

call twostr%CanopyPrep(currentPatch%fcansno)
Expand Down Expand Up @@ -3698,7 +3699,7 @@ subroutine update_3dpatch_radiation(this, nsites, sites, bc_out)

end associate

end if if_solver
end select

endif ! is there vegetation?

Expand Down
10 changes: 6 additions & 4 deletions radiation/FatesRadiationDriveMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,8 @@ subroutine FatesNormalizedCanopyRadiation(nsites, sites, bc_in, bc_out )

else

if_solver: if(radiation_model.eq.norman_solver) then
select case(radiation_model)
case(norman_solver)

call PatchNormanRadiation (currentPatch, &
bc_out(s)%albd_parb(ifp,:), & ! Surface Albedo direct
Expand All @@ -178,9 +179,9 @@ subroutine FatesNormalizedCanopyRadiation(nsites, sites, bc_in, bc_out )
bc_out(s)%ftid_parb(ifp,:), & ! Down diffuse flux below canopy per unit direct at top
bc_out(s)%ftii_parb(ifp,:)) ! Down diffuse flux below canopy per unit diffuse at top

else
case(twostr_solver)

associate( twostr => currentPatch%twostr)
associate( twostr => currentPatch%twostr)

!call twostr%CanopyPrep(bc_in(s)%fcansno_pa(ifp))
!call twostr%ZenithPrep(bc_in(s)%coszen_pa(ifp))
Expand Down Expand Up @@ -225,7 +226,8 @@ subroutine FatesNormalizedCanopyRadiation(nsites, sites, bc_in, bc_out )
end do
end associate

end if if_solver
end select

end if if_nrad

endif if_zenith_flag
Expand Down
8 changes: 3 additions & 5 deletions radiation/FatesTwoStreamInterfaceMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ Module FatesTwoStreamInterfaceMod
use TwoStreamMLPEMod , only : AllocateRadParams
use TwoStreamMLPEMod , only : rel_err_thresh,area_err_thresh
use EDPftvarcon , only : EDPftvarcon_inst
use FatesRadiationMemMod , only : twostr_solver
use FatesAllometryMod , only : VegAreaLayer
use EDParamsMod , only : radiation_model

implicit none

Expand Down Expand Up @@ -89,7 +87,7 @@ subroutine FatesConstructRadElements(site,fcansno_pa,coszen_pa)
!type(fates_cohort_type), pointer :: elem_co_ptrs(ncl*max_el_per_layer,100)


if(radiation_model.ne.twostr_solver)return


max_elements = -1
ifp=0
Expand Down Expand Up @@ -195,7 +193,7 @@ subroutine FatesConstructRadElements(site,fcansno_pa,coszen_pa)
! it will return the total plant LAIs and SAIs
call VegAreaLayer(cohort%treelai, &
cohort%treesai, &
cohort%hite, &
cohort%height, &
0, &
cohort%nv, &
cohort%pft, &
Expand Down Expand Up @@ -415,7 +413,7 @@ subroutine CheckPatchRadiationBalance(patch, snow_depth, ib, fabd, fabi)
do iv = 1,cohort%nv
call VegAreaLayer(cohort%treelai, &
cohort%treesai, &
cohort%hite, &
cohort%height, &
iv, &
cohort%nv, &
cohort%pft, &
Expand Down
26 changes: 25 additions & 1 deletion radiation/TwoStreamMLPEMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -680,10 +680,34 @@ subroutine ParamPrep()

do ib = 1, nbands
rad_params%Kd_leaf(ft) = rad_params%clumping_index(ft)/rad_params%avmu(ft)
rad_params%Kd_stem(ft) = 1._r8 ! Isotropic assumption
rad_params%Kd_stem(ft) = 1._r8

rad_params%om_leaf(ib,ft) = rad_params%rhol(ib,ft) + rad_params%taul(ib,ft)
rad_params%om_stem(ib,ft) = rad_params%rhos(ib,ft) + rad_params%taus(ib,ft)

if( rad_params%om_leaf(ib,ft) > 0.99_r8 ) then
write(log_unit,*) "In: TwoStreamMLPEMod.F90:ParamPrep()"
write(log_unit,*) "An extremely high leaf scattering coefficient was generated:"
write(log_unit,*) "om = tau + rho"
write(log_unit,*) "band = ",ib
write(log_unit,*) "pft = ",ft
write(log_unit,*) "om_leaf = ",rad_params%om_leaf(ib,ft)
write(log_unit,*) "rhol = ",rad_params%rhol(ib,ft)
write(log_unit,*) "taul = ",rad_params%taul(ib,ft)
call endrun(msg=errMsg(sourcefile, __LINE__))
end if
if( rad_params%om_stem(ib,ft) > 0.99_r8 ) then
write(log_unit,*) "In: TwoStreamMLPEMod.F90:ParamPrep()"
write(log_unit,*) "An extremely high stem scattering coefficient was generated:"
write(log_unit,*) "om = tau + rho"
write(log_unit,*) "band = ",ib
write(log_unit,*) "pft = ",ft
write(log_unit,*) "om_stem = ",rad_params%om_stem(ib,ft)
write(log_unit,*) "rhos = ",rad_params%rhos(ib,ft)
write(log_unit,*) "taus = ",rad_params%taus(ib,ft)
call endrun(msg=errMsg(sourcefile, __LINE__))
end if

end do

end do
Expand Down