Skip to content
Merged
Changes from 1 commit
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
98 changes: 98 additions & 0 deletions tools/mksurfdata_esmf/validate_fsurdat_files.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
#!/bin/bash

# Validation/verification of new fsurdat files
# --------------------------------------------
# WRITTEN by slevis after discussions with ekluzek.
# DATE of original script 2025/11/11.
Comment thread
slevis-lmwg marked this conversation as resolved.
Outdated
#
# LOCATION: I 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.
#
# PURPOSE and DETAILS
# -------------------
# This script
# 1) uses cprnc to compare ctsm5.4 versus ctsm5.3 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 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.
#
# -----------------------------
#
# 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.
# For ctsm5.4 I got approval for expected diffs from
Comment thread
slevis-lmwg marked this conversation as resolved.
Outdated
# - Keith Oleson for diffs in urban fields
# - Peter Lawrence for diffs in const_harvest, unrep_pft, pct_natveg, pct_nat_pft
# - Fang Li (a few months ago) for diffs in abm.
# ncvis works like ncview for unstructured grids (e.g. ne30), though it
# seems to crash when I give it 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.

echo "starting grids loop"

# The first loop of grids has different ctsm5.3 date stamp.
Comment thread
slevis-lmwg marked this conversation as resolved.
Outdated
# Skip ne3np4.pg2 as present only in ctsm5.4.
grids=("ne3np4")

Comment thread
slevis-lmwg marked this conversation as resolved.
for grid in "${grids[@]}"

do /glade/campaign/cesm/cesmdata/cseg/tools/cime/tools/cprnc/cprnc ../surfdata_$grid\_hist_1850_78pfts_c251022.nc ../../ctsm5.3.0/surfdata_$grid\_hist_1850_78pfts_c240925.nc >& surfdata_$grid\_hist_1850_78pfts_ctsm5.4v5.3.cprnc.out
Comment thread
slevis-lmwg marked this conversation as resolved.
Outdated
/glade/campaign/cesm/cesmdata/cseg/tools/cime/tools/cprnc/cprnc ../surfdata_$grid\_hist_2000_78pfts_c251022.nc ../../ctsm5.3.0/surfdata_$grid\_hist_2000_78pfts_c240925.nc >& surfdata_$grid\_hist_2000_78pfts_ctsm5.4v5.3.cprnc.out
echo "done $grid"

done

# Second loop of grids.
Comment thread
slevis-lmwg marked this conversation as resolved.
grids=("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.
do /glade/campaign/cesm/cesmdata/cseg/tools/cime/tools/cprnc/cprnc ../surfdata_$grid\_hist_1850_78pfts_c251022.nc ../../ctsm5.3.0/surfdata_$grid\_hist_1850_78pfts_c240908.nc >& surfdata_$grid\_hist_1850_78pfts_ctsm5.4v5.3.cprnc.out
/glade/campaign/cesm/cesmdata/cseg/tools/cime/tools/cprnc/cprnc ../surfdata_$grid\_hist_2000_78pfts_c251022.nc ../../ctsm5.3.0/surfdata_$grid\_hist_2000_78pfts_c240908.nc >& surfdata_$grid\_hist_2000_78pfts_ctsm5.4v5.3.cprnc.out
Comment thread
slevis-lmwg marked this conversation as resolved.
Outdated
echo "done $grid"

done

# Third loop of grids.
Comment thread
slevis-lmwg marked this conversation as resolved.
# Skip mpasa30 as present only in ctsm5.4.
Comment thread
slevis-lmwg marked this conversation as resolved.
Outdated
# Skip 1850 as only 2000 is present.
grids=("mpasa3p75" "mpasa15" "mpasa60")
for grid in "${grids[@]}"

do /glade/campaign/cesm/cesmdata/cseg/tools/cime/tools/cprnc/cprnc ../surfdata_$grid\_hist_2000_16pfts_c251022.nc ../../ctsm5.3.0/surfdata_$grid\_hist_2000_16pfts_c240908.nc >& surfdata_$grid\_hist_2000_78pfts_ctsm5.4v5.3.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