-
Notifications
You must be signed in to change notification settings - Fork 106
Testing Framework Update #1519
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
adrifoster
wants to merge
57
commits into
NGEET:main
Choose a base branch
from
adrifoster:directory_update
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
Testing Framework Update #1519
Changes from all commits
Commits
Show all changes
57 commits
Select commit
Hold shift + click to select a range
55b1e61
created filesystem
bed774d
updated template writing
9fae481
updates for better abstraction
1095dbb
bug fix for relative path
73d4572
update class template
ebe84e1
refactor build
487308d
rename builder file
05fc451
updates to cime_setup
79cc9f3
more updates for cime config
91d9a4a
get rid of file_system.py
12d4893
rename file
a4fb778
merge in json params update
d7d6134
fix typo
e615581
updates
71aa830
Merge branch 'json-params' into testing_update
0d30da3
fixing issues
2f7beb0
fixing import statement
15389e1
fix
989ce86
should work now
1946d25
fix logging level
3b3ae23
move tests into a new directory
7cfd933
update test protocol
a4fca2c
move testing_shr and data
fc6a91b
move configs into config dir
c8bd9ef
renamed some files
b3b0871
created framework dir
fef6cd2
trying to fix paths
b868194
runs
7a59aed
updates
5a4ab05
create run class
0781cc2
move cime path into module
e8c9ae1
unit test class
38025df
updated templates
52b2292
pylint updates
a9e5d42
updates for generator
71e8a71
remove print
6af4ed8
trying to fix
f89de9f
fixing generators
628d27b
fixing issues
cc5baec
black updates
3d2a5e3
updated docs
c6c693b
typos
75868ff
updates
d7fea2d
no longer need extra class
63594a8
fix loader
df370b1
adding init
d411dd1
adding init
f7c71e7
adding great circle functional tests
b0f287c
added quadratic unit test
9a8efdf
update cmakelists
c7df592
adding great circle unit tests
215c463
great circle test update
d4d5b93
add environment check
24b0277
fix error message
19d0b9a
update
a8dad79
moved data to .cdl
3237507
add BONA netcdf data
glemieux 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 |
|---|---|---|
| @@ -1,18 +1,19 @@ | ||
| # This is where you add specific test directories | ||
|
|
||
| ## Functional tests | ||
| add_subdirectory(functional_testing/allometry fates_allom_ftest) | ||
| add_subdirectory(functional_testing/math_utils fates_math_ftest) | ||
| add_subdirectory(functional_testing/fire/fuel fates_fuel_ftest) | ||
| add_subdirectory(functional_testing/fire/ros fates_ros_ftest) | ||
| add_subdirectory(functional_testing/patch fates_patch_ftest) | ||
| add_subdirectory(functional_testing/fire/mortality fates_firemort_ftest) | ||
| add_subdirectory(tests/functional/allometry fates_allom_ftest) | ||
| add_subdirectory(tests/functional/fire/fuel fates_fuel_ftest) | ||
| add_subdirectory(tests/functional/fire/ros fates_ros_ftest) | ||
| add_subdirectory(tests/functional/patch fates_patch_ftest) | ||
| add_subdirectory(tests/functional/fire/mortality fates_firemort_ftest) | ||
|
|
||
| ## Unit tests | ||
| add_subdirectory(unit_testing/fire_weather_test fates_fire_weather_utest) | ||
| add_subdirectory(unit_testing/fire_fuel_test fates_fire_fuel_utest) | ||
| add_subdirectory(unit_testing/sort_cohorts_test fates_sort_cohorts_utest) | ||
| add_subdirectory(unit_testing/insert_cohort_test fates_insert_cohort_utest) | ||
| add_subdirectory(unit_testing/validate_cohorts_test fates_validate_cohorts_utest) | ||
| add_subdirectory(unit_testing/count_cohorts_test fates_count_cohorts_utest) | ||
| add_subdirectory(unit_testing/fire_equations_test fates_fire_equations_utest) | ||
| add_subdirectory(tests/unit/fire_weather_test fates_fire_weather_utest) | ||
| add_subdirectory(tests/unit/fire_fuel_test fates_fire_fuel_utest) | ||
| add_subdirectory(tests/unit/sort_cohorts_test fates_sort_cohorts_utest) | ||
| add_subdirectory(tests/unit/insert_cohort_test fates_insert_cohort_utest) | ||
| add_subdirectory(tests/unit/validate_cohorts_test fates_validate_cohorts_utest) | ||
| add_subdirectory(tests/unit/count_cohorts_test fates_count_cohorts_utest) | ||
| add_subdirectory(tests/unit/fire_equations_test fates_fire_equations_utest) | ||
| add_subdirectory(tests/unit/quadratic_roots_test fates_quadratic_roots_utest) | ||
| add_subdirectory(tests/unit/great_circle_test fates_great_circle_utest) | ||
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,116 @@ | ||
| # FATES Testing Framework | ||
|
|
||
| This directory contains the infratstructure to set up, build, and execute FATES functional | ||
| and unit tests. | ||
|
|
||
| ## Test Definitions | ||
|
|
||
| * **Functional Tests**: Standalone Fortran programs that exercse specific modules of the | ||
| FATES production code. They often output NetCDF data and include a Python class for | ||
| automated plotting and science validation. These are "hands-on" tests for developers. | ||
|
|
||
| * **Unit Tests**: Discrete tests with a clear Pass/Fail status, utilizing **pfUnit** or | ||
| **CTest**. These are best for testing edge cases, error handling, and logical branches | ||
| within individual subroutines. | ||
|
|
||
| ## Environment Setup | ||
|
|
||
| ### Python Requirements | ||
|
|
||
| The framework requires Python 3.12+ with `xarray`, `pandas`, `scipy`, `netCDF`, `numpy`, | ||
| and `matplotlib`. You can create a compatible environment using the provided file: | ||
|
|
||
| ```bash | ||
| conda env create --file=environment.yml | ||
| conda activate fates_testing | ||
| ``` | ||
|
|
||
| ### System Requirements | ||
|
|
||
| While these tests do not require a host land model (e.g., CTSM/ELM), they require: | ||
|
|
||
| * **CIME and shr**: These must be present in your source tree. | ||
| * **Libraries**: NetCDF (C and Fortran), ESMF, and pfUnit. | ||
| * **Machine Tags**: Valid machine and compiler configurations (e.g., NCAR Derecho/Izumi). | ||
| If FATES is already running on your machine, these scripts should work out of the box. | ||
|
|
||
| See `docs/cime_setup.md` for a step-by-step guide to setting up the environment on your | ||
| own machine (Mac/Linux). | ||
|
|
||
| ## Execution | ||
|
|
||
| ### Running Functional Tests | ||
|
|
||
| ```bash | ||
| # Run all functional tests using default parameters | ||
| ./run_functional_tests.py | ||
|
|
||
| # Run specific tests with a custom parameter file | ||
| ./run_functional_tests.py --test-list allometry,fire --param-file my_params.json | ||
| ``` | ||
|
|
||
| ### Running Unit Tests | ||
|
|
||
| ```bash | ||
| # Run all unit tests | ||
| ./run_unit_tests.py | ||
| ``` | ||
|
|
||
| *Note: Use the `--help` flag on either script to see full options for build directories, | ||
| skipping runs, and saving figures.* | ||
|
|
||
| ## Creating New Tests | ||
|
|
||
| To maintain consistency, always use the boilerplate generator to start a new test. | ||
|
|
||
| ### Step 1. Generate Scaffolding | ||
|
|
||
| Run the generator script. This updates the CMake system, adds config entries, and creates | ||
| your test directory. | ||
|
|
||
| ```bash | ||
| # Example: Create a new functional test named 'hydro_stress' | ||
| ./generate_empty_test.py functional --test-name hydro_stress | ||
| ``` | ||
|
|
||
| ### Step 2: Implement the Fortran Logic | ||
|
|
||
| Navigate to `tests/[unit|functional]/[test_name]` and edit the generated `.F90` or `.pf` | ||
| file. | ||
|
|
||
| * **Functional**: Write a standard Fortran program. | ||
| * **Unit**: Write a pfUnit-compatible test module. | ||
|
|
||
| ### Step 3: Configure Metadata | ||
|
|
||
| Edit `config/functional.cfg` or `config/unit.cfg`. The generator provides defaults, but | ||
| you may need to update: | ||
|
|
||
| * `out_file`: The name of the NetCDF file your Fortran code generates. | ||
| * `use_param_file`: Set to `True` to pass the FATES JSON parameter file to your binary. | ||
| * `datm_file`: (Optional) Driver file name. All driver data should be placed in `testing/tests/data` | ||
|
|
||
| ### Step 4: Python Analysis (Functional Only) | ||
|
|
||
| The generator creates a Python file (`[test_name]_test.py`) in your test directory. Edit | ||
| the `plot_output` method to define how your test results should be visualized or validated. | ||
|
|
||
| ## Directory Structure | ||
|
|
||
| * `framework/`: Core logic for loading, building, and executing tests. | ||
| * `config/`: Registry of all active tests and their arguments. | ||
| * `tests/`: The source code for individual test cases. | ||
| * `templates/`: Boilerplate files used by the generator. | ||
|
|
||
| ## Troubleshooting | ||
|
|
||
| * **Missing Drivers**: If a functional tests requires a `datm_file`, ensure the file name0 in | ||
| the `.cfg` is correct and the data is in `testing/tests/data`. | ||
| The script will perform a pre-flight check and fail if the file is missing. | ||
|
|
||
| * **Build Failures**: Ensure your environment modules (compiler, netcdf, esmf) match the | ||
| configuration in your CIME machine tags. Also, if you are using a Fortran module that is | ||
| in a file that is not currently listed in one of the `CMakeLists.txt` files, you will | ||
| need to add it. There should be a `CMakeLists.txt` file in each subdirectory of the FATES | ||
| source code. Add the file to the corresponding `CMakeLists.txt` inside the `fates_sources` | ||
| list. |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
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.
👍