-
Notifications
You must be signed in to change notification settings - Fork 109
test: add leaf biophysics pFUnit unit test suite #1589
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
Open
johnpaulalex
wants to merge
1
commit into
NGEET:main
Choose a base branch
from
johnpaulalex:test/leaf-biophysics
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| set(pfunit_sources test_LeafBiophysics.pf) | ||
|
|
||
| add_pfunit_ctest(LeafBiophysics | ||
| TEST_SOURCES "${pfunit_sources}" | ||
| LINK_LIBRARIES fates csm_share) | ||
|
|
81 changes: 81 additions & 0 deletions
81
testing/tests/unit/leaf_biophysics_test/test_LeafBiophysics.pf
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| module test_LeafBiophysics | ||
| ! | ||
| ! DESCRIPTION: | ||
| ! Unit tests for LeafBiophysicsMod routines in FATES. | ||
| ! | ||
| use FatesConstantsMod, only : r8 => fates_r8, tfrz => t_water_freeze_k_1atm | ||
| use LeafBiophysicsMod, only : QSat, & | ||
| StomatalCondMedlyn, & | ||
| StomatalCondBallBerry, & | ||
| LowstorageMainRespReduction, & | ||
| LeafLayerMaintenanceRespiration_Ryan_1991, & | ||
| LeafLayerMaintenanceRespiration_Atkin_etal_2017, & | ||
| GetCanopyGasParameters, & | ||
| DecayCoeffVcmax, & | ||
| GetConstrainedVPress, & | ||
| VeloToMolarCF, & | ||
| LeafHumidityStomaResis, & | ||
| rsmax0, & | ||
| lb_params, & | ||
| c3_path_index, & | ||
| c4_path_index | ||
| use funit | ||
|
|
||
| implicit none | ||
|
|
||
| @TestCase | ||
| type, extends(TestCase) :: TestLeafBiophysics | ||
| contains | ||
| procedure :: setUp | ||
| procedure :: tearDown | ||
| end type TestLeafBiophysics | ||
|
|
||
| ! 1.e-13_r8: Precision tolerance near the 64-bit float limit used for exact matching. | ||
| real(r8), parameter :: tol = 1.e-13_r8 | ||
|
|
||
| contains | ||
|
|
||
| subroutine setUp(this) | ||
| ! lb_params is normally loaded from the FATES NetCDF parameter file at run-time; | ||
| ! here we manually set the minimum fields needed for two synthetic PFTs (C3, C4). | ||
| class(TestLeafBiophysics), intent(inout) :: this | ||
|
|
||
| allocate(lb_params%c3psn(2)) | ||
| allocate(lb_params%maintresp_leaf_ryan1991_baserate(2)) | ||
| allocate(lb_params%maintresp_leaf_atkin2017_baserate(2)) | ||
| allocate(lb_params%maintresp_reduction_curvature(2)) | ||
| allocate(lb_params%maintresp_reduction_intercept(2)) | ||
|
|
||
| ! Pathway flags; module-level constants from LeafBiophysicsMod. | ||
| lb_params%c3psn(1) = c3_path_index | ||
| lb_params%c3psn(2) = c4_path_index | ||
|
|
||
| ! FATES default (fates_params_default.cdl): 2.525e-06 gC gN-1 s-1 for all PFTs. | ||
| lb_params%maintresp_leaf_ryan1991_baserate(1) = 2.525e-6_r8 | ||
| lb_params%maintresp_leaf_ryan1991_baserate(2) = 2.525e-6_r8 | ||
|
|
||
| ! FATES default r0 for PFT 1 (tropical broadleaf evergreen): 1.756 umol CO2 m-2 s-1. | ||
| lb_params%maintresp_leaf_atkin2017_baserate(1) = 1.756_r8 | ||
| lb_params%maintresp_leaf_atkin2017_baserate(2) = 1.756_r8 | ||
|
|
||
| ! Non-default values chosen to exercise two branches of LowstorageMainRespReduction: | ||
| ! 1.0 -> linear branch (FATES default is 0.01; 1=linear, 0=maximally curved) | ||
| ! 0.5 -> curved power-law branch | ||
| lb_params%maintresp_reduction_curvature(1) = 1.0_r8 | ||
| lb_params%maintresp_reduction_curvature(2) = 0.5_r8 | ||
|
|
||
| ! Non-default (FATES default=1.0); 0.8 gives non-trivial hand-calculable values. | ||
| lb_params%maintresp_reduction_intercept(1) = 0.8_r8 | ||
| lb_params%maintresp_reduction_intercept(2) = 0.8_r8 | ||
| end subroutine setUp | ||
|
|
||
| subroutine tearDown(this) | ||
| class(TestLeafBiophysics), intent(inout) :: this | ||
| deallocate(lb_params%c3psn) | ||
| deallocate(lb_params%maintresp_leaf_ryan1991_baserate) | ||
| deallocate(lb_params%maintresp_leaf_atkin2017_baserate) | ||
| deallocate(lb_params%maintresp_reduction_curvature) | ||
| deallocate(lb_params%maintresp_reduction_intercept) | ||
| end subroutine tearDown | ||
|
|
||
| end module test_LeafBiophysics | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
We actually need to start migrating to using this constant in more of the models internal code.