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 leaf_c calculation after cohort area and number adjustment in SP mode calcuations #1063

Open
glemieux opened this issue Aug 18, 2023 · 0 comments

Comments

@glemieux
Copy link
Contributor

glemieux commented Aug 18, 2023

In the course of dealing with some testing for #1024, I noticed that we are currently updating the cohort area and number after we calculate the leaf_c in calculate_SP_properties:

leaf_c = leafc_from_treelai(tlai, pft, c_area, cohort_n, canopy_layer, vcmax25top)
! check that the inverse calculation of leafc from treelai is the same as the
! standard calculation of treelai from leafc. Maybe can delete eventually?
check_treelai = tree_lai(leaf_c, pft, c_area, cohort_n, canopy_layer, &
canopylai, vcmax25top)
if (abs(tlai - check_treelai) .gt. 1.0e-12) then !this is not as precise as nearzero
write(fates_log(),*) 'error in validate treelai', tlai, check_treelai, tlai - check_treelai
write(fates_log(),*) 'tree_lai inputs: ', pft, c_area, cohort_n, &
canopy_layer, vcmax25top
call endrun(msg=errMsg(sourcefile, __LINE__))
end if
! the carea_allom routine sometimes generates precision-tolerance level errors in the canopy area
! these mean that the canopy area does not exactly add up to the patch area, which causes chaos in
! the radiation routines. Correct both the area and the 'n' to remove error, and don't use
! carea_allom in SP mode after this point.
if (abs(c_area - parea) .gt. nearzero) then ! there is an error
if (abs(c_area - parea) .lt. 10.e-9) then ! correct this if it's a very small error
oldcarea = c_area
! generate new cohort area
c_area = c_area - (c_area - parea)
cohort_n = cohort_n*(c_area/oldcarea)

I believe we should defer the leaf_c calculation until after the area and number adjustments since they are inputs to leafc_from_treelai.

See discussion starting from #1024 (comment) for more context.

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

No branches or pull requests

1 participant