Skip to content

Commit

Permalink
Remove Direct Linking to COM from DATA for wavepostsbs Job (NOAA-EM…
Browse files Browse the repository at this point in the history
…C#3303)

In the current GFS version, some jobs directly write to COMOUT via
links in the working directories. This approach is risky, as downstream
jobs might receive incomplete files and fail. In order to resolve this
issue direct linking to COM from DATA should be removed. This PR
addresses this issue in the `wavepostsbs` job.

Resolves NOAA-EMC#3302 
Refs NOAA-EMC#712 
Refs NOAA-EMC#3273
---------

Co-authored-by: Rahul Mahajan <aerorahul@users.noreply.github.com>
  • Loading branch information
AntonMFernando-NOAA and aerorahul authored Feb 21, 2025
1 parent c902645 commit 08a14bd
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 12 deletions.
45 changes: 34 additions & 11 deletions ush/wave_grib2_sbs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -169,11 +169,11 @@ if [[ ! -s "${com_dir}/${outfile}.idx" ]]; then
fi

if (( fhr > 0 )); then
${WGRIB2} gribfile -set_date "${PDY}${cyc}" -set_ftime "${fhr} hour fcst" -grib "${com_dir}/${outfile}"
${WGRIB2} gribfile -set_date "${PDY}${cyc}" -set_ftime "${fhr} hour fcst" -grib "${outfile}"
err=$?
else
${WGRIB2} gribfile -set_date "${PDY}${cyc}" -set_ftime "${fhr} hour fcst" \
-set table_1.4 1 -set table_1.2 1 -grib "${com_dir}/${outfile}"
-set table_1.4 1 -set table_1.2 1 -grib "${outfile}"
err=$?
fi

Expand All @@ -183,27 +183,52 @@ if [[ ! -s "${com_dir}/${outfile}.idx" ]]; then
echo '********************************************* '
echo "*** FATAL ERROR : ERROR IN ${pgm} *** " # FIXME: This is not an error in $pgm, but in WGRIB2
echo '********************************************* '
echo ' '
echo " "
set_trace
exit 3
fi

# Create index
${WGRIB2} -s "${com_dir}/${outfile}" > "${com_dir}/${outfile}.idx"
${WGRIB2} -s "${outfile}" > "${outfile}.idx"

# Create grib2 subgrid is this is the source grid
# Create grib2 subgrid if this is the source grid
if [[ "${grdID}" = "${WAV_SUBGRBSRC}" ]]; then
for subgrb in ${WAV_SUBGRB}; do
subgrbref=$(echo ${!subgrb} | cut -d " " -f 1-20)
subgrbnam=$(echo ${!subgrb} | cut -d " " -f 21)
subgrbres=$(echo ${!subgrb} | cut -d " " -f 22)
subfnam="${WAV_MOD_TAG}.${cycle}${ENSTAG}.${subgrbnam}.${subgrbres}.f${FH3}.grib2"
${COPYGB2} -g "${subgrbref}" -i0 -x "${com_dir}/${outfile}" "${com_dir}/${subfnam}"
${WGRIB2} -s "${com_dir}/${subfnam}" > "${com_dir}/${subfnam}.idx"
${COPYGB2} -g "${subgrbref}" -i0 -x "${outfile}" "${subfnam}"
${WGRIB2} -s "${subfnam}" > "${subfnam}.idx"
done
fi

# 1.e Save in /com
# Move grib files to COM directory
if [[ -s "${outfile}" ]] && [[ -s "${outfile}.idx" ]]; then
cpfs "${outfile}" "${com_dir}/${outfile}"
cpfs "${outfile}.idx" "${com_dir}/${outfile}.idx"
echo "Copied ${outfile} and ${outfile}.idx from ${GRIBDATA} to COM"
else
echo "FATAL ERROR: ${outfile} and ${outfile}.idx not found in ${GRIBDATA} to copy to COM"
exit 4
fi

if [[ "${grdID}" = "${WAV_SUBGRBSRC}" ]]; then
for subgrb in ${WAV_SUBGRB}; do
subgrbnam=$(echo "${!subgrb}" | cut -d " " -f 21)
subgrbres=$(echo "${!subgrb}" | cut -d " " -f 22)
subfnam="${WAV_MOD_TAG}.${cycle}${ENSTAG}.${subgrbnam}.${subgrbres}.f${FH3}.grib2"
if [[ -s "${subfnam}" ]] && [[ -s "${subfnam}.idx" ]]; then
cpfs "${subfnam}" "${com_dir}/${subfnam}"
cpfs "${subfnam}.idx" "${com_dir}/${subfnam}.idx"
echo "Copied ${subfnam} and ${subfnam}.idx from ${GRIBDATA} to COM"
else
echo "FATAL ERROR: ${subfnam} and ${subfnam}.idx not found in ${GRIBDATA} to copy to COM"
exit 4
fi
done
fi

if [[ ! -s "${com_dir}/${outfile}" ]]; then
set +x
Expand Down Expand Up @@ -232,16 +257,14 @@ if [[ ! -s "${com_dir}/${outfile}.idx" ]]; then

if [[ "${SENDDBN}" = 'YES' ]] && [[ ${outfile} != *global.0p50* ]]; then
set +x
echo " Alerting GRIB file as ${com_dir}/${outfile}"
echo " Alerting GRIB index file as ${com_dir}/${outfile}.idx"
echo " Alerting GRIB file as ${outfile}"
echo " Alerting GRIB index file as ${outfile}.idx"
set_trace
"${DBNROOT}/bin/dbn_alert" MODEL "${alertName}_WAVE_GB2" "${job}" "${com_dir}/${outfile}"
"${DBNROOT}/bin/dbn_alert" MODEL "${alertName}_WAVE_GB2_WIDX" "${job}" "${com_dir}/${outfile}.idx"
else
echo "${outfile} is global.0p50 or SENDDBN is NO, no alert sent"
fi


# --------------------------------------------------------------------------- #
# 3. Clean up the directory

Expand Down
2 changes: 1 addition & 1 deletion ush/wave_grid_interp_sbs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ source "${USHgfs}/preamble.sh"
for ID in ${waveGRD} ${grdID}; do
${NLN} "${DATA}/mod_def.${ID}" "mod_def.${ID}"
done


# --------------------------------------------------------------------------- #
# 1. Generate GRID file with all data
Expand Down

0 comments on commit 08a14bd

Please sign in to comment.