Skip to content

Commit

Permalink
Add remaining updates from NCO to scripts.
Browse files Browse the repository at this point in the history
  • Loading branch information
GeorgeGayno-NOAA committed Nov 20, 2024
1 parent 9117111 commit 818bc78
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 16 deletions.
1 change: 1 addition & 0 deletions reg_tests/snow2mdl/driver.hera.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ module use ../../modulefiles
module load build.$target.$compiler
module load grib-util
module load wgrib2/2.0.8
module load prod_util/2.1.1
module list

# Because of a bug in the grib-util module, need to construct this
Expand Down
2 changes: 1 addition & 1 deletion reg_tests/snow2mdl/snow2mdl.global.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

set -x

export IMS_FILE=$HOMEreg/input_data/imssnow96.afwa.global.grb
export IMS_FILE=$HOMEreg/input_data/imssnow96.afwa.global.grb2
export AFWA_GLOBAL_FILE="$HOMEreg/input_data/afwa.global.grb2"

export MODEL_LATITUDE_FILE=$HOMEgfs/fix/am/global_latitudes.t1534.3072.1536.grb
Expand Down
59 changes: 44 additions & 15 deletions ush/emcsfc_snow.sh
Original file line number Diff line number Diff line change
Expand Up @@ -129,31 +129,30 @@ fi
cd $DATA

#------------------------------------------------------------------------
# Do a quick check of the ims data to ensure it is not corrupt.
# WGRIB2 works for a grib 1 or grib 2 file. If IMS is bad,
# don't run emcsfc_snow2mdl program because afwa data alone is
# unreliable.
# Do a quick check of the ims data to ensure it exists and is
# not corrupt.
#------------------------------------------------------------------------

$WGRIB2 ${IMS_FILE}
rc1=$?

if ((rc1 != 0));then
echo "WARNING: ${pgm} detects corrupt IMS data. Can not run."
exit $rc1
if [[ ! -f $IMS_FILE ]]; then
set +x
echo "WARNING: ${pgm} detects missing ims data. Will not run."
set -x
exit 7
fi

#------------------------------------------------------------------------
# The model analysis time is set to the ims valid time, because the
# ims data has highest priority of all input data.
#------------------------------------------------------------------------

$WGRIB2 -Sec0 ${IMS_FILE} 2>&1 | grep "grib1 message"
$WGRIB2 -d 1 ${IMS_FILE}
status=$?
if (( status == 0 )); then # grib 1 file
tempdate=$($WGRIB -v $IMS_FILE | head -1)
IMSDATE=${tempdate#*D=}
else # grib 2 file
if (( status != 0 )); then
set +x
echo "WARNING: ${pgm} detects corrupt ims data. Will not run."
set -x
exit 9
else
tempdate=$($WGRIB2 -t $IMS_FILE | head -1)
IMSDATE=${tempdate#*d=}
fi
Expand All @@ -163,6 +162,36 @@ IMSMONTH=$(echo $IMSDATE10 | cut -c5-6)
IMSDAY=$(echo $IMSDATE10 | cut -c7-8)
IMSHOUR=0 # emc convention is to use 00Z.

#------------------------------------------------------------------------
# Ensure AFWA data exists and is not too old.
#------------------------------------------------------------------------

if [[ ! -f $AFWA_GLOBAL_FILE ]]; then
set +x
echo "WARNING: ${pgm} detects missing afwa data. Will not run."
set -x
exit 3
else
$WGRIB2 -d 1 $AFWA_GLOBAL_FILE
status=$?
if ((status != 0));then
set +x
echo "WARNING: ${pgm} detects corrupt afwa data. Will not run."
set -x
exit $status
else
tempdate=$($WGRIB2 -d 1 -t $AFWA_GLOBAL_FILE)
AFWADATE=${tempdate#*d=}
two_days_ago=$($NDATE -48 $IMSDATE10)
if ((AFWADATE < two_days_ago)); then
set +x
echo "WARNING: ${pgm} detects old afwa data. Will not run."
set -x
exit 4
fi
fi
fi

pgmout=${pgmout:-OUTPUT}

if test "$use_prod_util" = "true" ; then
Expand Down

0 comments on commit 818bc78

Please sign in to comment.