-
Notifications
You must be signed in to change notification settings - Fork 357
alpha-ctsm5.4.CMIP7.18.ctsm5.3.082: fsurdat validation tool #3612
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
Merged
slevis-lmwg
merged 2 commits into
ESCOMP:alpha-ctsm5.4.CMIP7
from
slevis-lmwg:fsurdat_validation_tool
Nov 18, 2025
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,126 @@ | ||
| #!/bin/bash | ||
|
|
||
| # Validation/verification of new fsurdat files | ||
| # -------------------------------------------- | ||
| # WRITTEN by slevis after discussions with ekluzek. | ||
| # | ||
| # LOCATION: slevis first used this script in the directory | ||
| # .../inputdata/lnd/clm2/surfdata_esmf/ctsm5.4.0/validation | ||
| # | ||
| # CAVEAT: For new CTSM versions, use this script as a template with the | ||
| # understanding that aspects of the code will need to change. Search | ||
| # the string "current" for items that may need to change in the future. | ||
| # | ||
| # PURPOSE and DETAILS | ||
| # ------------------- | ||
| # This script | ||
| # 1) uses cprnc to compare NEW_VERSION versus OLD_VERSION files by generating | ||
| # cprnc.out files. | ||
| # 2) greps for fields with differences (RMS or NORMALIZED) that are >=1. | ||
| # The strictest grep threshold that I found isolates potentially | ||
| # unexpected changes is E-03. I determined this empirically using two | ||
| # types of problematic fsurdat files from the recent past: | ||
| # - No LAI, SAI, and heights for pfts 15 and 16. | ||
| # - No soil textures in parts of the world in unstructured grids. | ||
| # These "unexpected" fields appear alongside expected diffs (discussed | ||
| # below) when grepping for E+. Grepping for less than E-03 starts to | ||
| # capture fields with smaller differences and is likely to miss | ||
| # unexpected problematic fields. | ||
| # | ||
| # Step after running the script | ||
| # ----------------------------- | ||
| # Interactively and iteratively build this grep command to confirm that | ||
| # all fields in the script's grep output are expected. This list of | ||
| # fields here is ctsm5.4-specific: | ||
| # >>> grep NORM grep_E+_surfdata_cprnc.out | grep -v ROOF | grep -v WALL | grep -v URBAN | grep -v BUILDING | grep -v abm | grep -v CANYON | grep -v CONST_HARVEST | grep -v ROAD | grep -v UNREPRESENTED_PFT | grep -v PCT_NATVEG | ||
|
slevis-lmwg marked this conversation as resolved.
|
||
| # | ||
| # If the grep command reveals unexpected fields, investigate. | ||
| # The list of fields to check depends on which fields you expect to have | ||
| # answer changes. The magnitude of the differences will depend on the | ||
| # specifics of what changed. Ensure you only see the answer changes that | ||
| # you expect. | ||
| # | ||
| # ----------------------------- | ||
| # | ||
| # Separate subjective comparison | ||
| # ------------------------------ | ||
| # >>> ncdiff surfdata_new.nc surfdata_old.nc surfdata_new_vs_old.nc | ||
| # >>> ncview surfdata_new_vs_old.nc | ||
| # - Focus on fields with larger RMS diffs in the cprnc output. | ||
| # - ncvis works like ncview for unstructured grids (e.g. ne30), though | ||
| # slevis found ncvis to crash when reading a "diff" file generated by ncdiff. | ||
| # | ||
| # Another validation step | ||
| # ----------------------- | ||
| # Run mksurfdata_esmf with a different number of processors and confirm | ||
| # bit-for-bit same results. | ||
|
|
||
| # Settings to be used in the comparisons below. | ||
| # Paths are hardwired to derecho currently. | ||
| newdatestamp=c251022 # USER DEFINED | ||
| newdir=ctsm5.4.0 # USER DEFINED | ||
| olddir=ctsm5.3.0 # USER DEFINED | ||
| olddatestamp=c240908 # USER DEFINED | ||
| olddatestamp_ne3np4=c240925 # USER DEFINED | ||
| cimetoolspath=/glade/campaign/cesm/cesmdata/cseg/tools/cime/tools | ||
| CPRNC=$cimetoolspath/cprnc/cprnc | ||
|
|
||
| echo "starting grids loop" | ||
|
|
||
| # The first loop of grids (unlike the other loops) uses olddatestamp_ne3np4 currently. | ||
| # Skip ne3np4.pg2 as present only in NEW_VERSION currently so may wish to add in future versions. | ||
| grids=("ne3np4") | ||
|
|
||
|
slevis-lmwg marked this conversation as resolved.
|
||
| for grid in "${grids[@]}" | ||
|
|
||
| # 1850_78pft files | ||
| do $CPRNC ../surfdata_$grid\_hist_1850_78pfts_$newdatestamp.nc ../../$olddir/surfdata_$grid\_hist_1850_78pfts_$olddatestamp_ne3np4.nc >& surfdata_$grid\_hist_1850_78pfts_$newdir\_vs_$olddir.cprnc.out | ||
| # 2000_78pft files | ||
| $CPRNC ../surfdata_$grid\_hist_2000_78pfts_$newdatestamp.nc ../../$olddir/surfdata_$grid\_hist_2000_78pfts_$olddatestamp_ne3np4.nc >& surfdata_$grid\_hist_2000_78pfts_$newdir\_vs_$olddir.cprnc.out | ||
| echo "done $grid" | ||
|
|
||
| done | ||
|
|
||
| # Second loop of grids. | ||
|
slevis-lmwg marked this conversation as resolved.
|
||
| grids=("C96" "360x720cru" "4x5" "10x15" "0.9x1.25" "1.9x2.5" "mpasa120" "mpasa480" "ne16np4.pg3" "ne120np4.pg3" "ne3np4.pg3" "ne30np4" "ne30np4.pg2" "ne30np4.pg3") | ||
| for grid in "${grids[@]}" | ||
|
|
||
|
slevis-lmwg marked this conversation as resolved.
|
||
| # 1850_78pft files | ||
| do $CPRNC ../surfdata_$grid\_hist_1850_78pfts_$newdatestamp.nc ../../$olddir/surfdata_$grid\_hist_1850_78pfts_$olddatestamp.nc >& surfdata_$grid\_hist_1850_78pfts_$newdir\_vs_$olddir.cprnc.out | ||
| # 2000_78pft files | ||
| $CPRNC ../surfdata_$grid\_hist_2000_78pfts_$newdatestamp.nc ../../$olddir/surfdata_$grid\_hist_2000_78pfts_$olddatestamp.nc >& surfdata_$grid\_hist_2000_78pfts_$newdir\_vs_$olddir.cprnc.out | ||
| echo "done $grid" | ||
|
|
||
| done | ||
|
|
||
| # Third loop of grids. | ||
|
slevis-lmwg marked this conversation as resolved.
|
||
| # Skip 1850 as only 2000 is present currently. | ||
| # Skip mpasa30 as present only in NEW_VERSION currently so may wish to add in future versions. | ||
| # Skip mpasa3p75 because cprnc runs out of memory at that resolution currently. | ||
| grids=("mpasa60" "mpasa15") | ||
| for grid in "${grids[@]}" | ||
|
|
||
| # 2000_16pft files | ||
| do $CPRNC ../surfdata_$grid\_hist_2000_16pfts_$newdatestamp.nc ../../$olddir/surfdata_$grid\_hist_2000_16pfts_$olddatestamp.nc >& surfdata_$grid\_hist_2000_16pfts_$newdir\_vs_$olddir.cprnc.out | ||
| echo "done $grid" | ||
|
|
||
| done | ||
|
|
||
| # Fourth loop of grids: for 1979 files. | ||
| # Skip ne0np4.NATL.ne30x8 and ne120np4.pg3 as present only in NEW_VERSION currently so may wish to add in future versions. | ||
| grids=("ne0np4.ARCTICGRIS.ne30x8" "ne0np4.ARCTIC.ne30x4" "ne0np4CONUS.ne30x8" "ne0np4.POLARCAP.ne30x4") | ||
|
|
||
| for grid in "${grids[@]}" | ||
|
|
||
| # 1979_78pft files | ||
| do $CPRNC ../surfdata_$grid\_hist_1979_78pfts_$newdatestamp.nc ../../$olddir/surfdata_$grid\_hist_1979_78pfts_$olddatestamp.nc >& surfdata_$grid\_hist_1979_78pfts_$newdir\_vs_$olddir.cprnc.out | ||
| echo "done $grid" | ||
|
|
||
| done | ||
|
|
||
| # grep for E+ to catch larger diffs. | ||
| for file in surfdata_*cprnc.out | ||
| do grep -H NORM $file | grep 'E+' >> grep_E+_surfdata_cprnc.out | ||
| done | ||
|
|
||
| exit | ||
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.
Uh oh!
There was an error while loading. Please reload this page.