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

Move calculation of frac_lai to outside the hlm_numSWb loop #843

Closed
adrifoster opened this issue Mar 10, 2022 · 2 comments
Closed

Move calculation of frac_lai to outside the hlm_numSWb loop #843

adrifoster opened this issue Mar 10, 2022 · 2 comments

Comments

@adrifoster
Copy link
Contributor

In looking at the radiation code, I noticed that we are potentially unnecessarily recalculating frac_lai and frac_sai for visible and NIR bands (

if (currentPatch%canopy_area_profile(L,ft,iv) > 0._r8)then
):

      do  iv = 1, currentPatch%nrad(L,ft)
         if (currentPatch%canopy_area_profile(L,ft,iv) > 0._r8)then
            currentPatch%canopy_mask(L,ft) = 1
            ! layer level reflectance qualities
            do ib = 1,hlm_numSWb !vis, nir
               if(currentPatch%elai_profile(L,ft,iv)+ currentPatch%esai_profile(L,ft,iv).gt.0.0_r8) then
                  frac_lai = currentPatch%elai_profile(L,ft,iv)/&
                       (currentPatch%elai_profile(L,ft,iv)+ currentPatch%esai_profile(L,ft,iv))
               else
                  frac_lai = 1.0_r8
               endif
               !frac_lai = 1.0_r8 ! make the same as previous codebase, in theory.
               frac_sai = 1.0_r8 - frac_lai

These calculations occur inside the do ib = 1, hlm_numSWb loop, but I don't think they are actually affected by the ib value. Should we move this to just before the do ib... loop? It may save us a modicum of computation time, and helps with code understandability.

Alternatively, I may be wrong! I conferred with @glemieux, but if others could chime in that would be helpful!

@rgknox
Copy link
Contributor

rgknox commented Mar 15, 2022

we checked in on this in the software meeting, and there was agreement with @adrifoster that her plan to improve the algorithm is solid

@adrifoster
Copy link
Contributor Author

I think we can close this now!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants