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 1 commit
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
Prev Previous commit
Next Next commit
more two-stream b4b work
  • Loading branch information
rgknox committed Dec 14, 2023
commit a972ff3f6803b8e8ef273861dcb75b6cec0d4bcb
155 changes: 128 additions & 27 deletions biogeochem/EDCanopyStructureMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ module EDCanopyStructureMod
real(r8), parameter :: similar_height_tol = 1.0E-3_r8 ! I think trees that differ by 1mm
! can be roughly considered the same right?

logical, parameter :: preserve_b4b = .true.

! 10/30/09: Created by Rosie Fisher
! 2017/2018: Modifications and updates by Ryan Knox
Expand Down Expand Up @@ -1532,6 +1533,7 @@ subroutine leaf_area_profile( currentSite )
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

real(r8) :: layer_bottom_height,layer_top_height,lai,sai ! Can be removed later
!----------------------------------------------------------------------


Expand Down Expand Up @@ -1579,35 +1581,134 @@ subroutine leaf_area_profile( currentSite )
do while(associated(currentCohort))
ft = currentCohort%pft
cl = currentCohort%canopy_layer

do iv = 1,currentCohort%NV

call VegAreaLayer(currentCohort%treelai, &
currentCohort%treesai, &
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

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

currentPatch%tsai_profile(cl,ft,iv) = currentPatch%tsai_profile(cl,ft,iv) + &
tsai_layer * currentCohort%c_area/currentPatch%total_canopy_area
! ----------------------------------------------------------------
! How much of each tree is stem area index? Assuming that there is
! This may indeed be zero if there is a sensecent grass
! ----------------------------------------------------------------
if_preserve_b4b: if(preserve_b4b) then
lai = currentCohort%treelai * currentCohort%c_area/currentPatch%total_canopy_area
sai = currentCohort%treesai * currentCohort%c_area/currentPatch%total_canopy_area
if( (currentCohort%treelai+currentCohort%treesai) > nearzero)then

! See issue: https://github.com/NGEET/fates/issues/899
! fleaf = currentCohort%treelai / (currentCohort%treelai + currentCohort%treesai)
fleaf = lai / (lai+sai)
else
fleaf = 0._r8
endif

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

currentPatch%canopy_area_profile(cl,ft,iv) = currentPatch%canopy_area_profile(cl,ft,iv) + &
currentCohort%c_area/currentPatch%total_canopy_area

end do

currentPatch%nrad(cl,ft) = currentPatch%ncan(cl,ft)

if (currentPatch%nrad(cl,ft) > nlevleaf ) then
write(fates_log(), *) 'Number of radiative leaf layers is larger'
write(fates_log(), *) ' than the maximum allowed.'
write(fates_log(), *) ' cl: ',cl
write(fates_log(), *) ' ft: ',ft
write(fates_log(), *) ' nlevleaf: ',nlevleaf
write(fates_log(), *) ' currentPatch%nrad(cl,ft): ', currentPatch%nrad(cl,ft)
call endrun(msg=errMsg(sourcefile, __LINE__))
end if

! --------------------------------------------------------------------------
! Whole layers. Make a weighted average of the leaf area in each layer
! before dividing it by the total area. Fill up layer for whole layers.
! --------------------------------------------------------------------------

do iv = 1,currentCohort%NV

! This loop builds the arrays that define the effective (not snow covered)
! and total (includes snow covered) area indices for leaves and stems
! We calculate the absolute elevation of each layer to help determine if the layer
! is obscured by snow.

layer_top_height = currentCohort%height - &
( real(iv-1,r8)/currentCohort%NV * currentCohort%height * &
prt_params%crown_depth_frac(currentCohort%pft) )

layer_bottom_height = currentCohort%height - &
( real(iv,r8)/currentCohort%NV * currentCohort%height * &
prt_params%crown_depth_frac(currentCohort%pft) )

fraction_exposed = 1.0_r8
if(currentSite%snow_depth > layer_top_height)then
fraction_exposed = 0._r8
endif
if(currentSite%snow_depth < layer_bottom_height)then
fraction_exposed = 1._r8
endif
if(currentSite%snow_depth >= layer_bottom_height .and. &
currentSite%snow_depth <= layer_top_height) then !only partly hidden...
fraction_exposed = 1._r8 - max(0._r8,(min(1.0_r8,(currentSite%snow_depth -layer_bottom_height)/ &
(layer_top_height-layer_bottom_height ))))
endif

if(iv==currentCohort%NV) then
remainder = (currentCohort%treelai + currentCohort%treesai) - &
(dlower_vai(iv) - dinc_vai(iv))
if(remainder > dinc_vai(iv) )then
write(fates_log(), *)'ED: issue with remainder', &
currentCohort%treelai,currentCohort%treesai,dinc_vai(iv), &
currentCohort%NV,remainder

call endrun(msg=errMsg(sourcefile, __LINE__))
endif
else
remainder = dinc_vai(iv)
end if

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

currentPatch%elai_profile(cl,ft,iv) = currentPatch%elai_profile(cl,ft,iv) + &
remainder * fleaf * currentCohort%c_area/currentPatch%total_canopy_area * &
fraction_exposed

currentPatch%tsai_profile(cl,ft,iv) = currentPatch%tsai_profile(cl,ft,iv) + &
remainder * (1._r8 - fleaf) * currentCohort%c_area/currentPatch%total_canopy_area

currentPatch%esai_profile(cl,ft,iv) = currentPatch%esai_profile(cl,ft,iv) + &
remainder * (1._r8 - fleaf) * currentCohort%c_area/currentPatch%total_canopy_area * &
fraction_exposed

currentPatch%canopy_area_profile(cl,ft,iv) = currentPatch%canopy_area_profile(cl,ft,iv) + &
currentCohort%c_area/currentPatch%total_canopy_area


end do

else !if_preserve_b4b

do iv = 1,currentCohort%NV

call VegAreaLayer(currentCohort%treelai, &
currentCohort%treesai, &
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

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

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

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

currentPatch%canopy_area_profile(cl,ft,iv) = currentPatch%canopy_area_profile(cl,ft,iv) + &
currentCohort%c_area/currentPatch%total_canopy_area

end do

end if if_preserve_b4b

currentCohort => currentCohort%taller

enddo !cohort
Expand Down
4 changes: 2 additions & 2 deletions main/EDInitMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ module EDInitMod
private

logical :: debug = .false.

logical, parameter :: preserve_b4b = .true.
integer :: istat ! return status code
character(len=255) :: smsg ! Message string for deallocation errors
character(len=*), parameter, private :: sourcefile = &
Expand Down Expand Up @@ -602,7 +602,7 @@ subroutine init_patches( nsites, sites, bc_in)
call SiteMassStock(sites(s),el,sites(s)%mass_balance(el)%old_stock, &
biomass_stock,litter_stock,seed_stock)
end do
call set_patchno(sites(s))
if(.not.preserve_b4b) call set_patchno(sites(s))
Copy link
Contributor

@glemieux glemieux Dec 21, 2023

Choose a reason for hiding this comment

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

Was this correcting an issue in the code? I.e should we have been setting the patch number here all along?

enddo

else
Expand Down