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
2 changes: 1 addition & 1 deletion zppy/templates/tc_analysis.bash
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ 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
if [[ ${topography_file##*/} =~ [^_]*_([^_]*)_.*nc ]]; 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.

On the command line:

Perlmutter:

# What caused the error before
> tf=/dvs_ro/cfs/cdirs/e3sm/inputdata/atm/cam/topo/USGS-gtopo30_ne120np4pg2_x6t_forOroDrag.c20241019.nc
> [[ ${tf##*/} =~ [^_]*_([^_]*)_.*nc ]]
> echo ${BASH_REMATCH[1]}
ne120np4pg2

# Make sure it works even without the early underscore
> tf2=/dvsro/cfs/cdirs/e3sm/inputdata/atm/cam/topo/USGS-gtopo30_ne120np4pg2_x6t_forOroDrag.c20241019.nc
> [[ ${tf2##*/} =~ [^_]*_([^_]*)_.*nc ]]
> echo ${BASH_REMATCH[1]}
ne120np4pg2

Chrysalis:

# What caused the error before
> tf=/dvs_ro/cfs/cdirs/e3sm/inputdata/atm/cam/topo/USGS-gtopo30_ne120np4pg2_x6t_forOroDrag.c20241019.nc
> [[ ${tf##*/} =~ [^_]*_([^_]*)_.*nc ]]
> echo ${BASH_REMATCH[1]}
ne120np4pg2

# Make sure it works even without the early underscore
> tf2=/dvsro/cfs/cdirs/e3sm/inputdata/atm/cam/topo/USGS-gtopo30_ne120np4pg2_x6t_forOroDrag.c20241019.nc
> [[ ${tf2##*/} =~ [^_]*_([^_]*)_.*nc ]]
> echo ${BASH_REMATCH[1]}
ne120np4pg2

It appears all the cases work out.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I'm thinking we can use following to make it more robust:

filename="${topography_file##*/}"
if [[ $filename =~ ne[0-9]+np4pg2+ ]]; then
grid="${BASH_REMATCH[0]}"
echo "grid=${grid}"
else
echo "Pattern not found in filename: $filename"
fi

This will robustly extract the grid substring from filenames with the pattern neXnp4pg2.

grid=${BASH_REMATCH[1]}
echo "grid=${grid}"
if [[ -z "${res}" ]]; then
Expand Down
Loading