-
Notifications
You must be signed in to change notification settings - Fork 92
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
removing large 3D radiation arrays from restarts #428
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That makes sense to me. I always thought that these things had made it into the restart file as some sort of unpleasant consequence of the timing of the albedo calls relative to everything else, so it's a good idea to find a work around for that.
… the 3D radiation patch variables, thus decreasing restart file sizes.
exactly, the albedo calls come before the calls to Norman radiation, so the initial values needed for the albedo calculations are not available. I wonder if cold-starts have un-initialized values for that first albedo call, I should check that... |
For cold-starts, I don't believe we go through the process of "perfectly" initializing the canopy albedo for the first time-step. We initialize all the absorption fractions as 0, which I'm guessing makes the vegetation perfectly reflective for that first time step. Part of me thinks this is not-a-big-deal because:
|
@@ -329,6 +329,13 @@ module EDTypesMod | |||
integer :: ncan(nclmax,maxpft) ! number of total leaf layers for each canopy layer and pft | |||
|
|||
!RADIATION FLUXES | |||
|
|||
integer :: solar_zenith_flag ! integer flag specifying daylight (based on zenith angle) | |||
real(r8) :: solar_zenith_angle ! solar zenith angle (radians) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why are solar_zenith_flag and solar_zenith_angle defined as patch variables? Couldn't that info be held at the site level?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it could. I was just following the precedent of the flag that is passed in from the HLM.
biogeophys/EDSurfaceAlbedoMod.F90
Outdated
@@ -195,756 +125,918 @@ subroutine ED_Norman_Radiation (nsites, sites, bc_in, bc_out ) | |||
bc_out(s)%fabd_parb(ifp,:) = 0.0_r8 | |||
bc_out(s)%fabi_parb(ifp,:) = 0.0_r8 | |||
do ib = 1,hlm_numSWb | |||
|
|||
! Requires a fix here, abld vs albi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so are we going to fix this here, or in https://github.com/NGEET/fates/pull/431/files#diff-68b652d39e00b970fbcf3d5b8d6f1165L199 ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i was going to fix this, but didn't realize @jkshuman got to it first until I saw that PR. I think it depends on which one gets integrated first. There will be a conflict between the two either way (so they both will?)
For testing purposes, I will first run tests maintaining the status quo to test b4b. Then I will implement that fix.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add in the fix since b4b testing is complete.
biogeophys/EDSurfaceAlbedoMod.F90
Outdated
real(r8) :: angle | ||
|
||
real(r8),parameter :: tolerance = 0.000000001_r8 | ||
real(r8), parameter :: pi = 3.141592654 ! PI |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ahem
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use FatesConstantsMod, only : pi => pi_const?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, that would be better, will do
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
biogeophys/EDSurfaceAlbedoMod.F90
Outdated
!++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++! | ||
cosz = max(0.001_r8, currentPatch%solar_zenith_angle ) !copied from previous radiation code... | ||
do ft = 1,numpft | ||
sb = (90._r8 - (acos(cosz)*180/pi)) * (pi / 180._r8) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sb = (90._r8 - (acos(cosz)*180/pi)) * (pi / 180._r8) | |
sb = (90._r8 - (acos(cosz)*180._r8/pi)) * (pi / 180._r8) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
got that change in my current working version, I'm currently working through a bug so will issue more changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
biogeophys/EDSurfaceAlbedoMod.F90
Outdated
tr_dif_z(L,ft,:) = 0._r8 | ||
do iv = 1,currentPatch%nrad(L,ft) | ||
do j = 1,9 | ||
angle = (5._r8 + dble(j - 1) * 10._r8) * 3.142_r8 / 180._r8 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what's 3.142_r8?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is code is all copied and pasted, so I didn't do too much of a pass on numerics and constants and such.
I essentially just pulled all the code in the norman radiation routine that was inside the patch loop, and made it a subroutine. The only things that are different, are how the variables forc_dir and forc_dif are constructed, and the bc_ variables are processed before the patch level subroutine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah i know, just giving a hard time. but if it is okay not to be b4b, no reason not to clean this stuff up while we're looking at it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, good point, I will do a pass through targeting b4b, and then after I'm satisfied, I will do a cleaning pass
biogeophys/EDSurfaceAlbedoMod.F90
Outdated
if (L == currentPatch%NCL_p.and.currentPatch%NCL_p > 1)then !is this the (incomplete) understorey? | ||
!Add on the radiation coming up through the canopy gaps. | ||
!diffuse to diffuse | ||
weighted_dif_up(L) = weighted_dif_up(L) +(1.0-sum(ftweight(L,1:numpft,1))) * & |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
weighted_dif_up(L) = weighted_dif_up(L) +(1.0-sum(ftweight(L,1:numpft,1))) * & | |
weighted_dif_up(L) = weighted_dif_up(L) +(1.0_r8-sum(ftweight(L,1:numpft,1))) * & |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
biogeophys/EDSurfaceAlbedoMod.F90
Outdated
weighted_dif_down(L-1) * currentPatch%gnd_alb_dif(ib) | ||
!direct to diffuse | ||
weighted_dif_up(L) = weighted_dif_up(L) + forc_dir(radtype) * & | ||
weighted_dir_tr(L-1) * (1.0-sum(ftweight(L,1:numpft,1))) * currentPatch%gnd_alb_dir(ib) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
weighted_dir_tr(L-1) * (1.0-sum(ftweight(L,1:numpft,1))) * currentPatch%gnd_alb_dir(ib) | |
weighted_dir_tr(L-1) * (1.0_r8-sum(ftweight(L,1:numpft,1))) * currentPatch%gnd_alb_dir(ib) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
biogeophys/EDSurfaceAlbedoMod.F90
Outdated
if (L == 1)then !is this the top layer? | ||
Dif_dn(L,ft,1) = forc_dif(radtype) | ||
else | ||
Dif_dn(L,ft,1) = weighted_di |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dif_dn(L,ft,1) = weighted_di | |
(1.0_r8-sum(ftweight(L,1:numpft,1))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that suggestion got messed up somehow i think? beta...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
think I got that in, done
if (L == 1)then !is this the top layer? | ||
Dif_dn(L,ft,1) = forc_dif(radtype) | ||
else | ||
Dif_dn(L,ft,1) = weighted_di |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dif_dn(L,ft,1) = weighted_di | |
if ( abs(error) > 0.0001_r8)then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
another suggestion got messed up?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actually should this .0001 be a constant, and used elsewhere?, e.g. https://github.com/NGEET/fates/pull/428/files#diff-68b652d39e00b970fbcf3d5b8d6f1165R941
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would rather punt on that number for now and keeping scope limited
main/FatesRestartInterfaceMod.F90
Outdated
@@ -1416,6 +1410,7 @@ subroutine create_patchcohort_structure(this, nc, nsites, sites, bc_in) | |||
use EDTypesMod, only : ed_cohort_type | |||
use EDTypesMod, only : ed_patch_type | |||
use EDTypesMod, only : ncwd | |||
use EDTypesMod, only : maxSWb | |||
use EDTypesMod, only : nlevleaf |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use EDTypesMod, only : nlevleaf |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note -- I'm suggesting we pull nlevleaf out of the restart infrastructure entirely as it should no longer be needed in this module. is that correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also there's a call to it in
fates/main/FatesRestartInterfaceMod.F90
Line 1031 in 44f66d6
use EDTypesMod, only : nlevleaf |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
main/FatesRestartInterfaceMod.F90
Outdated
@@ -1613,6 +1608,7 @@ subroutine get_restart_vectors(this, nc, nsites, sites) | |||
use EDTypesMod, only : ed_cohort_type | |||
use EDTypesMod, only : ed_patch_type | |||
use EDTypesMod, only : ncwd | |||
use EDTypesMod, only : maxSWb | |||
use EDTypesMod, only : nlevleaf |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use EDTypesMod, only : nlevleaf |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed
main/FatesRestartInterfaceMod.F90
Outdated
|
||
if ( debug ) write(fates_log(),*) 'CLTV io_idx_pa_sunz 2 ',io_idx_pa_sunz | ||
if ( debug ) write(fates_log(),*) 'CLTV 1186 ',nlevleaf,numpft,nclmax |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if ( debug ) write(fates_log(),*) 'CLTV 1186 ',nlevleaf,numpft,nclmax | |
if ( debug ) write(fates_log(),*) 'CLTV 1186 ',numpft,nclmax |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed refs
main/FatesRestartInterfaceMod.F90
Outdated
@@ -1058,7 +1061,7 @@ subroutine set_restart_vectors(this,nc,nsites,sites) | |||
integer :: io_idx_co ! cohort index | |||
integer :: io_idx_pa_pft ! each pft within each patch (pa_pft) | |||
integer :: io_idx_pa_cwd ! each cwd class within each patch (pa_cwd) | |||
integer :: io_idx_pa_sunz ! index for the combined dimensions for radiation | |||
integer :: io_idx_pa_sb ! each SW band (vis/ir) per patch (pa_sb) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the wavelength band has a terminology (IB?) in CTSM already, so maybe we should mirror that? Altternatively, I think '_SWb' is more understandable than '_sb'.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated naming suffix to _ib
I had to revert some changes I made to the precision of constants and some math that had marginally changed answers, but after reverting the changes, this PR is now B4B with master. |
all tests pass, will integrate early next week unless I hear other comments or requests. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this looks great, thanks @rgknox!
Description:
This PR is a refactor that removes the need to remember large 3D arrays in restart files. These arrays were storing the fraction of absorbed radiation, as dimensioned by crown layer x leaf layer x pft. These variables were forcing the restart files to maintain very large cohort dataspaces which were acting as surrogates to hold this data.
For example, with 14 PFTs, 4 crown layers and 30 leaf layers, this would necessitate space for 1680 values per each column. Since we were using the cohort dimension to hold these, this forces massive restart files.
The refactor instead saves 4 smaller variables related to ground albedo and solar zenith angle, and then reproduces these 3D arrays from existing information, immediately after the restart information is read in.
Fixes: #12 !
Collaborators:
@jenniferholm has identified that runs with multiple PFTs are really slow, which motivated this work.
Expectation of Answer Changes:
There should not be answer changes.
Checklist:
Test Results:
CTSM (or) E3SM (specify which) test hash-tag:
CTSM (or) E3SM (specify which) baseline hash-tag:
FATES baseline hash-tag:
Test Output:
All PASS: cheyenne, intel, fates test suite:
/gpfs/fs1/scratch/rgknox/clmed-tests/fates.cheyenne.intel.C46895e9-F3c87f2a-pft-arrays-vf3