Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
126 changes: 126 additions & 0 deletions tools/mksurfdata_esmf/validate_fsurdat_files.sh
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
Comment thread
slevis-lmwg marked this conversation as resolved.
#
# 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
Comment thread
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")

Comment thread
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.
Comment thread
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[@]}"

Comment thread
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.
Comment thread
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