Skip to content

Commit

Permalink
[develop] Bug fix to support the %H format in METplus via printf. (#1102
Browse files Browse the repository at this point in the history
)

This bug was encountered when verifying forecast output that has a 2-digit forecast hour in its name. It turns out specifying the METplus format %H to obtain a 2-digit forecast hour in the workflow/verification configuration variable FCST_FN_TEMPLATE (and others) causes an error in the shell script eval_METplus_timestr_tmpl.sh because bash's printf utility does not support the %H format. This fixes that error using a similar approach to the %HHH format for obtaining 3-digit hours.
  • Loading branch information
gsketefian authored Jul 12, 2024
1 parent fe8fc68 commit e5832d1
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion ush/bash_utils/eval_METplus_timestr_tmpl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,23 @@ cannot be empty:
#-----------------------------------------------------------------------
#
case "${METplus_time_fmt}" in
"%Y%m%d%H"|"%Y%m%d"|"%H%M%S"|"%H")
"%Y%m%d%H"|"%Y%m%d"|"%H%M%S")
fmt="${METplus_time_fmt}"
;;
"%H")
#
# The "%H" format needs to be treated differently depending on if it's
# formatting a "lead" time type or another (e.g. "init" or "vald") because
# for "lead", the printf function is used below (which doesn't understand
# the "%H" format) whereas for the others, the date utility is used (which
# does understand "%H").
#
if [ "${METplus_time_type}" = "lead" ]; then
fmt="%02.0f"
else
fmt="${METplus_time_fmt}"
fi
;;
"%HHH")
#
# Print format assumes that the argument to printf (i.e. the number to
Expand Down

0 comments on commit e5832d1

Please sign in to comment.