Skip to content
Merged
Changes from 2 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
12 changes: 7 additions & 5 deletions zppy/templates/tc_analysis.bash
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,20 @@ topography_file=`echo $(ncks --trd -M -m ${first_file} | grep -E -i "^global att
echo "topography_file=${topography_file}"
res={{ res }}
pg2=false
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Question 1) So should I add a pg2 parameter or is it fine to leave it auto-determined?

if [[ $topography_file =~ /[^_]*_([^_]*)_.*nc ]]; then
grid=${BASH_REMATCH[1]}
filename="${topography_file##*/}"
echo "filename=${filename}"
if [[ $filename =~ ne[0-9]+np4pg2+ ]]; then
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chengzhuzhang I implemented your suggestion and tested with the following. Please approve the PR or suggest further changes, thanks.

Testing description

cfg:

[default]
  
input = /global/cfs/cdirs/e3sm/ndk/tmpdata/20250313.v3HR.F20TR-ORO-GWD.wSLtraj.tuning.ni14_p3rain20.so4.c12-apr8.alvarez-cpu 
output = /global/cfs/cdirs/e3sm/forsyth/debug_issue688_20250521_try10
case = 20250313.v3HR.F20TR-ORO-GWD.wSLtraj.tuning.ni14_p3rain20.so4.c12-apr8.alvarez-cpu
www = /global/cfs/cdirs/e3sm/www/forsyth/debug_issue688_20250521_try10
constraint = "cpu"
partition = ""
qos = "debug"
environment_commands = "source /global/common/software/e3sm/anaconda_envs/load_latest_e3sm_unified_pm-cpu.sh"
campaign = "water_cycle"

[tc_analysis]
active = True
input_subdir = "run"
walltime = "00:30:00"
#walltime = "06:00:00"
#years = "1996:2001:6",
years = "1996:1998:2",

Runs:

# pip install . && zppy -c ../zppy_cfgs/issue688_20250521/issue688_20250521_v2.cfg
# cd /global/cfs/cdirs/e3sm/forsyth/debug_issue688_20250521_try10/post/scripts/ && grep -v "OK" *status
# No errors when running ../zppy_cfgs/issue688_20250521/issue688_20250521_v2.cfg (try10)
filename="${topography_file##*/}"
echo "filename=${filename}"
if [[ $filename =~ ne[0-9]+np4pg2+ ]]; then
    grid="${BASH_REMATCH[0]}"
    echo "grid=${grid}"
    if [[ -z "${res}" ]]; then
        echo "Inferring res from grid"
        if [[ $grid =~ ne([0-9]*) ]]; then
            res=${BASH_REMATCH[1]}
        fi
    fi
    pg2=true
else
    echo "Pattern not found in filename: $filename"
fi
echo "res=${res}" # 120
echo "pg2=${pg2}" # true
# pip install . && zppy -c ../zppy_cfgs/issue688_20250521/issue688_20250521_v2.cfg
# cd /global/cfs/cdirs/e3sm/forsyth/debug_issue688_20250521_try9/post/scripts/ && grep -v "OK" *status
# No errors when running ../zppy_cfgs/issue688_20250521/issue688_20250521_v2.cfg (try9)
if [[ ${topography_file##*/} =~ [^_]*_([^_]*)_.*nc ]]; then
    grid=${BASH_REMATCH[1]}
    echo "grid=${grid}"
    if [[ -z "${res}" ]]; then
        echo "Inferring res from grid"
        if [[ $grid =~ ne([0-9]*) ]]; then
            res=${BASH_REMATCH[1]}
        fi
    fi
    if [[ $grid =~ pg2 ]]; then
	pg2=true
    fi
fi
echo "res=${res}" # 120
echo "pg2=${pg2}" # true
# pip install . && zppy -c ../zppy_cfgs/issue688_20250521/issue688_20250521_v2.cfg
# cd /global/cfs/cdirs/e3sm/forsyth/debug_issue688_20250521_try8/post/scripts/ && grep -v "OK" *status
# Causes `Error: Insufficient values for option --res` when running ../zppy_cfgs/issue688_20250521/issue688_20250521_v2.cfg (try8)
if [[ $topography_file =~ /[^_]*_([^_]*)_.*nc ]]; then 
    grid=${BASH_REMATCH[1]}
    echo "grid=${grid}"
    if [[ -z "${res}" ]]; then
        echo "Inferring res from grid"
        if [[ $grid =~ ne([0-9]*) ]]; then
            res=${BASH_REMATCH[1]}
        fi
    fi
    if [[ $grid =~ pg2 ]]; then
	pg2=true
    fi
fi
echo "res=${res}" # empty
echo "pg2=${pg2}" # false

grid="${BASH_REMATCH[0]}"
echo "grid=${grid}"
if [[ -z "${res}" ]]; then
echo "Inferring res from grid"
if [[ $grid =~ ne([0-9]*) ]]; then
res=${BASH_REMATCH[1]}
fi
fi
if [[ $grid =~ pg2 ]]; then
pg2=true
fi
pg2=true
else
echo "Pattern not found in filename: $filename"
fi
echo "res=${res}"
echo "pg2=${pg2}"
Expand Down
Loading