Skip to content

Commit

Permalink
Move product functions to separate function
Browse files Browse the repository at this point in the history
PR NOAA-EMC#1822 converted some formerly stand-alone scripts and moved them
inside one of the standard product scripts. However, `trim_rh.sh`
is also used by gempak and AWIPS, so this change caused those jobs
to start failing (they are not yet tested by CI).

Those functions have now been moved into a separate product functions
script that can be sourced by all the scripts that need the functions.
A third similar script was also eliminated and converted into a
function.

Additionally fixes a base bug in AWIPS and updates some scripts to
satisfy (or at least mostly satisfy) the linter. AWIPS is still failing
when creating GRIB1 products.

Resolves NOAA-EMC#1890
  • Loading branch information
WalterKolczynski-NOAA committed Sep 27, 2023
1 parent e886e8a commit d342e30
Show file tree
Hide file tree
Showing 10 changed files with 138 additions and 170 deletions.
11 changes: 6 additions & 5 deletions jobs/JGFS_ATMOS_AWIPS_20KM_1P0DEG
Original file line number Diff line number Diff line change
Expand Up @@ -47,21 +47,22 @@ export pgmout=OUTPUT.$$

########################################################
# Execute the script.
${HOMEgfs}/scripts/exgfs_atmos_awips_20km_1p0deg.sh ${fcsthrs}
"${HOMEgfs}/scripts/exgfs_atmos_awips_20km_1p0deg.sh" "${fcsthrs}"
export err=$?; err_chk
########################################################

############################################
# print exec I/O output
############################################
if [ -e "${pgmout}" ] ; then
cat ${pgmout}
if [[ -e "${pgmout}" ]] ; then
cat "${pgmout}"
fi

###################################
# Remove temp directories
###################################
if [ "${KEEPDATA}" != "YES" ] ; then
rm -rf ${DATA}
cd "${DATAROOT}" || pass
if [[ "${KEEPDATA}" != "YES" ]] ; then
rm -rf "${DATA}"
fi

7 changes: 3 additions & 4 deletions jobs/rocoto/awips.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,17 @@ fhrlst=$(echo ${FHRLST} | sed -e 's/_/ /g; s/f/ /g; s/,/ /g')
echo
echo "=============== BEGIN AWIPS ==============="

for fhr in ${fhrlst}; do
for fhr3 in ${fhrlst}; do
fhr=$(( 10#${fhr3} ))
if (( fhr > FHMAX_GFS )); then
echo "Nothing to process for FHR = ${fhr}, cycle"
echo "Nothing to process for FHR = ${fhr3}, cycle"
continue
fi

fhmin=0
fhmax=84
if (( fhr >= fhmin && fhr <= fhmax )); then
if ((fhr % 3 == 0)); then
fhr3=$(printf %03d $((10#${fhr})))
export fcsthrs=${fhr3}
${AWIPS20SH}
fi
Expand All @@ -58,7 +58,6 @@ for fhr in ${fhrlst}; do
fhmax=240
if (( fhr >= fhmin && fhr <= fhmax )); then
if ((fhr % 6 == 0)); then
fhr3=$(printf %03i $((10#${fhr})))
export fcsthrs=${fhr3}
${AWIPS20SH}
${AWIPSG2SH}
Expand Down
2 changes: 0 additions & 2 deletions scripts/exgdas_atmos_post.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ cd "${DATA}" || exit 1
export POSTGPSH=${POSTGPSH:-${USHgfs}/gfs_post.sh}
export GFSDOWNSH=${GFSDOWNSH:-${USHgfs}/fv3gfs_downstream_nems.sh}
export GFSDWNSH=${GFSDWNSH:-${USHgfs}/fv3gfs_dwn_nems.sh}
export TRIMRH=${TRIMRH:-${USHgfs}/trim_rh.sh}
export MODICEC=${MODICEC:-${USHgfs}/mod_icec.sh}
export INLINE_POST=${INLINE_POST:-".false."}

############################################################
Expand Down
50 changes: 20 additions & 30 deletions scripts/exgfs_atmos_awips_20km_1p0deg.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ fi

cd "${DATA}" || exit 2

# "Import" functions used in this script
source "${HOMEgfs}/ush/product_functions.sh"

###############################################
# Wait for the availability of the pgrb file
###############################################
Expand All @@ -51,6 +54,7 @@ while (( icnt < 1000 )); do
if (( icnt >= 180 )); then
msg="FATAL ERROR: No GFS pgrb2 file after 30 min of waiting"
err_exit "${msg}"
exit 5
fi
done

Expand Down Expand Up @@ -79,8 +83,6 @@ export opt25=":(APCP|ACPCP|PRATE|CPRAT):"
export opt26=' -set_grib_max_bits 25 -fi -if '
export opt27=":(APCP|ACPCP|PRATE|CPRAT|DZDT):"
export opt28=' -new_grid_interpolation budget -fi '
export TRIMRH=${TRIMRH:-$USHgfs/trim_rh.sh}
export SCALEDEC=${SCALDEC:-$USHgfs/scale_dec.sh}

###############################################################
# Process GFS GRIB AWIP PRODUCTS IN GRIB2 #
Expand Down Expand Up @@ -109,51 +111,37 @@ export err=$?; err_chk
cat temp_gfs gfs_pwat_levels_10.grb > tmp_masterfile

for GRID in conus ak prico pac 003; do
# shellcheck disable=SC2086
case ${GRID} in
conus)
# Grid 20km_conus - CONUS - 20 km Quadruple Resolution (Lambert Conformal)
# export grid_20km_conus="30 6 0 0 0 0 0 0 369 257 12190000 226541000 8 25000000 265000000 20318000 20318000 0 64 25000000 25000000 0 0"
# $COPYGB2 -g "$grid_20km_conus" -i0 -x tmp_masterfile awps_file_f${fcsthrs}_${GRID}

export gridconus="lambert:265.0:25.0:25.0 226.541:369:20318.0 12.19:257:20318.0"
gridconus="lambert:265.0:25.0:25.0 226.541:369:20318.0 12.19:257:20318.0"
# shellcheck disable=SC2086,SC2248
${WGRIB2} tmp_masterfile ${opt1uv} ${opt21} ${opt22} ${opt23} ${opt24} ${opt25} ${opt26} \
${opt27} ${opt28} -new_grid ${gridconus} "awps_file_f${fcsthrs}_${GRID}"
;;
ak)
# Grid 20km_ak - Alaska - Double Resolution (Polar Stereographic)
# Redefined grid 217 for Alaska region
# export grid_20km_ak="20 6 0 0 0 0 0 0 277 213 30000000 187000000 8 60000000 225000000 22500000 22500000 0 64"
# $COPYGB2 -g "$grid_20km_ak" -i0 -x tmp_masterfile awps_file_f${fcsthrs}_${GRID}

export gridak="nps:210.0:60.0 170.0:277:22500 35.0:225:22500"
gridak="nps:210.0:60.0 170.0:277:22500 35.0:225:22500"
# shellcheck disable=SC2086,SC2248
${WGRIB2} tmp_masterfile ${opt1uv} ${opt21} ${opt22} ${opt23} ${opt24} ${opt25} ${opt26} \
${opt27} ${opt28} -new_grid ${gridak} "awps_file_f${fcsthrs}_${GRID}"
;;
prico)
# Grid 20km_prico - 0.25 degree Lat/Lon grid for Puerto Rico (20km)
# export grid_20km_prico="0 6 0 0 0 0 0 0 275 205 0 0 50750000 271750000 48 -250000 340250000 250000 250000 0"
# $COPYGB2 -g "$grid_20km_prico" -i0 -x tmp_masterfile awps_file_f${fcsthrs}_${GRID}

export gridprico="latlon 271.75:275:0.25 50.75:205:-0.25"
gridprico="latlon 271.75:275:0.25 50.75:205:-0.25"
# shellcheck disable=SC2086,SC2248
${WGRIB2} tmp_masterfile ${opt1} ${opt21} ${opt22} ${opt23} ${opt24} ${opt25} ${opt26} \
${opt27} ${opt28} -new_grid ${gridprico} "awps_file_f${fcsthrs}_${GRID}"
;;
pac)
# Grid 20km_pac - 20 km Mercator grid for Pacific Region
# export grid_20km_pac="10 6 0 0 0 0 0 0 837 692 -45000000 110000000 48 20000000 65720000 270000000 64 0 20000000 20000000"
# NEW export grid_20km_pac="10 6 0 0 0 0 0 0 837 725 -45000000 110000000 48 20000000 65734500 270000000 64 0 20000000 20000000"
# $COPYGB2 -g "$grid_20km_pac" -i0 -x tmp_masterfile awps_file_f${fcsthrs}_${GRID}

export gridpac="mercator:20.0 110.0:837:20000:270.0 -45.0:725:20000:65.7345"
gridpac="mercator:20.0 110.0:837:20000:270.0 -45.0:725:20000:65.7345"
# shellcheck disable=SC2086,SC2248
${WGRIB2} tmp_masterfile ${opt1} ${opt21} ${opt22} ${opt23} ${opt24} ${opt25} ${opt26} \
${opt27} ${opt28} -new_grid ${gridpac} "awps_file_f${fcsthrs}_${GRID}"
;;
003)
######################################################################
# Process GFS GRIB AWIP 1.0 DEGREE (GRID 003) PRODUCTS IN GRIB2 #
######################################################################
export grid003="latlon 0:360:1.0 90:181:-1.0"
grid003="latlon 0:360:1.0 90:181:-1.0"
# shellcheck disable=SC2086,SC2248
${WGRIB2} tmp_masterfile ${opt1} ${opt21} ${opt22} ${opt23} ${opt24} ${opt25} ${opt26} \
${opt27} ${opt28} -new_grid ${grid003} "awps_file_f${fcsthrs}_${GRID}"
;;
Expand All @@ -162,9 +150,8 @@ for GRID in conus ak prico pac 003; do
exit 2
;;
esac
# shellcheck disable=
${TRIMRH} "awps_file_f${fcsthrs}_${GRID}"
${SCALEDEC} "awps_file_f${fcsthrs}_${GRID}"
trim_rh "awps_file_f${fcsthrs}_${GRID}"
scale_dec "awps_file_f${fcsthrs}_${GRID}"
${GRB2INDEX} "awps_file_f${fcsthrs}_${GRID}" "awps_file_fi${fcsthrs}_${GRID}"

###########################################################################
Expand Down Expand Up @@ -201,7 +188,8 @@ for GRID in conus ak prico pac 003; do

${TOCGRIB2} < "parm_list" >> "${pgmout}" 2> errfile
export err=$?; err_chk
echo " error from tocgrib2=",$err
# TODO: Should this be fatal?
echo "error from tocgrib2=${err}"

if [[ ${SENDCOM} == "YES" ]]; then
##############################
Expand Down Expand Up @@ -243,6 +231,8 @@ for GRID in conus ak prico pac 003; do
# Post Files to ${COM_ATMOS_WMO}
##############################

pwd

mv "grib2.awpgfs_20km_${GRID}_f${fcsthrs}" \
"${COM_ATMOS_WMO}/grib2.awpgfs_20km_${GRID}_f${fcsthrs}.${job_name}"

Expand Down
14 changes: 6 additions & 8 deletions scripts/exgfs_atmos_grib_awips.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,10 @@ if (( num != 1 )); then
exit 16
fi

cd "${DATA}" || exit 2
cd "${DATA}/awips_g1" || exit 2

fcsthrs=$(printf "%03d" "${fcsthrs}")

export SCALEDEC=${SCALDEC:-${USHgfs}/scale_dec.sh}

cd ${DATA}/awips_g1 || exit 2
# "Import" functions used in this script
source "${HOMEgfs}/ush/product_functions.sh"

###############################################
# Wait for the availability of the pgrb file
Expand All @@ -59,6 +56,7 @@ while (( icnt < 1000 )); do
if (( icnt >= 180 )); then
msg="FATAL ERROR: No GFS pgrb2 file after 30 min of waiting"
err_exit "${msg}"
exit 5
fi
done

Expand All @@ -79,7 +77,7 @@ cp "${COM_ATMOS_GRIB_0p25}/gfs.t${cyc}z.pgrb2b.0p25.f${fcsthrs}" "tmpfile2b"
cat tmpfile2 tmpfile2b > tmpfile
${WGRIB2} tmpfile | grep -F -f "${PARMproduct}/gfs_awips_parmlist_g2" | \
${WGRIB2} -i -grib masterfile tmpfile
${SCALEDEC} masterfile
scale_dec masterfile
${CNVGRIB} -g21 masterfile masterfile.grib1

ln -s masterfile.grib1 fort.11
Expand Down Expand Up @@ -130,7 +128,7 @@ if [[ "${SENDCOM}" = 'YES' ]]; then
fi

if [[ -e "${pgmout}" ]] ; then
cat ${pgmout}
cat "${pgmout}"
fi

###############################################################################
Expand Down
Loading

0 comments on commit d342e30

Please sign in to comment.