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

Fix: uninitialised variables in cable_canopy.F90 #352

Merged
merged 4 commits into from
Aug 15, 2024

Conversation

ccarouge
Copy link
Member

@ccarouge ccarouge commented Jul 25, 2024

CABLE

Thank you for submitting a pull request to the CABLE Project.

Description

Fixes #351.

Move the definition of sum_rad_gradis and sum_rad_rniso out of the NITER loop in define_canopy() since these variables do not change in the loop. Having a quick comparison between the outputs before and after this commit the effect is negligeable.

Use sum_rad_gradis and sum_rad_rniso as calculated in define_canopy() everywhere in define_canopy(), dryLeaf() and wetLeaf(), instead of recalculating them sometimes.

Move the initialisation of canopy%DvLitt and canopy%kthLitt to the top of define_canopy() since these variables are constant throughout the run. We also want these variables to be defined in all cases to avoid errors in function calls, but only used with cable_user%litter turned on.

Type of change

Please delete options that are not relevant.

  • Bug fix

Testing

benchcab/me.org analysis: https://modelevaluation.org/analyses/anywhere/BPLvifw3DyARokYdg/s6k22L3WajmiS9uGv/CJGXP5GQWhGf3nH28/all

Tested in benchcab the changes for DvLitt and kthLitt on their own. benchcab showed bitwise identical results when moving the initialisation compared to the previous implementation with the litter option on.

Please add a reviewer when ready for review.


📚 Documentation preview 📚: https://cable--352.org.readthedocs.build/en/352/

@ccarouge
Copy link
Member Author

Since we are introducing 2 changes that will break reproducibility I have decided to document some of the differences separately.
In the first commit we only move the calculation of sum_rad_gradis before calling wetLeaf. benchcab shows differences in the results compared to the main branch but these are minimal. Here are the timeseries for Qle and Qh for the start of the runs for a random flux site:
Qh
Qle

@ccarouge ccarouge changed the title Use sum_rad_gradis and sum_rad_rniso correctly and consistently Fix: uninitialised variables in cable_canopy.F90 Aug 14, 2024
@ccarouge ccarouge marked this pull request as ready for review August 15, 2024 03:49
@ccarouge ccarouge requested a review from rml599gh August 15, 2024 03:50
@rml599gh
Copy link
Contributor

Also noting that my tests showed that without the sum_rad_gradis bug fixed, site runs were not consistently reproducible.

Copy link
Contributor

@rml599gh rml599gh left a comment

Choose a reason for hiding this comment

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

Reference at line 192. Matthews not Mathews. Title is 'of fine fuel' not 'of offine fuel'. Probably useful to include the doi (https://doi.org/10.1071/WF05063)

@ccarouge ccarouge merged commit 04e8171 into main Aug 15, 2024
7 checks passed
@ccarouge ccarouge deleted the 351-sum_rad_gradis-bug-in-canopy-routines branch August 15, 2024 23:42
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

Successfully merging this pull request may close these issues.

Uninitialised variables in canopy routines (sum_rad_gradis, DvLitt)
2 participants