Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace sleep with wait_for_file #2586

Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
126ec91
Updated GEMPAK version and APRUN launcher.
HenryRWinterbottom Apr 29, 2024
3e8557a
Implementing wait_for_file.
henrywinterbottom-wxdev May 6, 2024
cbea5c5
Addressed reviewer requests.
henrywinterbottom-wxdev May 28, 2024
308708c
Merge branch 'develop' into feature/gwdev_issue_2444.r002
HenryRWinterbottom May 28, 2024
c4b1f15
Corrected conflicts.
henrywinterbottom-wxdev May 28, 2024
5888129
Manual corrections.
henrywinterbottom-wxdev May 28, 2024
58f94ee
Merge branch 'develop' into feature/gwdev_issue_2444.r002
HenryRWinterbottom May 28, 2024
f10df4b
Working through linter complaints.
henrywinterbottom-wxdev May 28, 2024
1f3d521
Fixing linter flags.
henrywinterbottom-wxdev May 28, 2024
30f977c
Debugging from linter.
henrywinterbottom-wxdev May 28, 2024
601da99
Linter corrections.
henrywinterbottom-wxdev May 29, 2024
9589a22
Linter debugging.
henrywinterbottom-wxdev May 29, 2024
c3dcccb
Linter fixes.
henrywinterbottom-wxdev May 29, 2024
1416e46
Linter fixes.
henrywinterbottom-wxdev May 29, 2024
5c7b417
Update ush/wave_tar.sh
HenryRWinterbottom May 29, 2024
063e0f6
Addresses reviewer comment.
henrywinterbottom-wxdev May 29, 2024
e0e4c6b
Update wave_tar.sh
HenryRWinterbottom May 29, 2024
f4f365d
Addresses reviewer comment.
henrywinterbottom-wxdev May 29, 2024
d19a649
Merge branch 'develop' into feature/gwdev_issue_2444.r002
HenryRWinterbottom May 29, 2024
90dfb15
Update exgfs_wave_post_gridded_sbs.sh
HenryRWinterbottom May 29, 2024
c7679b6
Addressed reviewer comment.
henrywinterbottom-wxdev May 30, 2024
9c8b695
Merge branch 'NOAA-EMC:develop' into feature/gwdev_issue_2444.r002
HenryRWinterbottom May 30, 2024
911c8f4
Corrected globbing issue.
HenryRWinterbottom May 31, 2024
ee9c709
Merge branch 'develop' into feature/gwdev_issue_2444.r002
HenryRWinterbottom May 31, 2024
3e42e51
Merge branch 'NOAA-EMC:develop' into feature/gwdev_issue_2444.r002
HenryRWinterbottom Jun 3, 2024
65b3b53
Merge branch 'develop' into feature/gwdev_issue_2444.r002
HenryRWinterbottom Jun 4, 2024
0c41c04
Reverting linter complaint to account for a missing environment varia…
henrywinterbottom-wxdev Jun 4, 2024
088d124
Merge branch 'develop' into feature/gwdev_issue_2444.r002
HenryRWinterbottom Jun 6, 2024
8a113c4
Merge branch 'develop' into feature/gwdev_issue_2444.r002
HenryRWinterbottom Jun 7, 2024
3830494
Merge branch 'NOAA-EMC:develop' into feature/gwdev_issue_2444.r002
HenryRWinterbottom Jun 12, 2024
17e5149
Bug fix related to bash integer expansion.
HenryRWinterbottom Jun 12, 2024
4465617
Merge branch 'develop' into feature/gwdev_issue_2444.r002
HenryRWinterbottom Jun 12, 2024
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
1 change: 0 additions & 1 deletion env/HERA.env
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,6 @@ elif [[ "${step}" = "gempak" ]]; then
export NTHREADS_GEMPAK=${nth_gempak:-1}
[[ ${NTHREADS_GEMPAK} -gt ${nth_max} ]] && export NTHREADS_GEMPAK=${nth_max}


elif [[ "${step}" = "fit2obs" ]]; then

nth_max=$((npe_node_max / npe_node_fit2obs))
Expand Down
22 changes: 8 additions & 14 deletions scripts/exgfs_atmos_awips_20km_1p0deg.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,20 +43,14 @@ source "${USHgfs}/product_functions.sh"
###############################################
# Wait for the availability of the pgrb file
###############################################
icnt=1
while (( icnt < 1000 )); do
if [[ -s "${COM_ATMOS_GRIB_0p25}/${RUN}.${cycle}.pgrb2b.0p25.f${fcsthrs}.idx" ]]; then
break
fi

sleep 10
icnt=$((icnt + 1))
if (( icnt >= 180 )); then
msg="FATAL ERROR: No GFS pgrb2 file after 30 min of waiting"
err_exit "${msg}"
exit 5
fi
done
sleep_interval=10
max_tries=180
idxfile="${COM_ATMOS_GRIB_0p25}/${RUN}.${cycle}.pgrb2b.0p25.f${fcsthrs}.idx"
if ! wait_for_file "${idxfile}" "${sleep_interval}" "${max_tries}"; then
msg="FATAL ERROR: No GFS pgrb2 file after waiting"
err_exit "${msg}"
exit 5
fi

########################################

Expand Down
24 changes: 8 additions & 16 deletions scripts/exgfs_atmos_postsnd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ declare -x LEVS

### Loop for the hour and wait for the sigma and surface flux file:
export FSTART=$STARTHOUR
sleep_interval=10
HenryRWinterbottom marked this conversation as resolved.
Show resolved Hide resolved
max_tries=360
#
while [ $FSTART -lt $ENDHOUR ]
do
Expand All @@ -69,28 +71,18 @@ export FINT=$NINT1
export MAKEBUFR=YES
fi

ic=0
while [ $ic -lt 1000 ]; do
if [[ ! -f "${COM_ATMOS_HISTORY}/${RUN}.${cycle}.atm.logf${FEND}.${logfm}" ]]; then
sleep 10
ic=$(expr $ic + 1)
else
break
fi

if [ $ic -ge 360 ]
then
err_exit "COULD NOT LOCATE logf$FEND file AFTER 1 HOUR"
fi
done
filename="${COM_ATMOS_HISTORY}/${RUN}.${cycle}.atm.logf${FEND}.${logfm}"
if ! wait_for_file "${filename}" "${sleep_interval}" "${max_tries}"; then
err_exit "FATAL ERROR: logf${FEND} not found after waiting $((sleep_interval * ( max_tries - 1) )) secs"
fi

## 1-hourly output before $NEND1, 3-hourly output after
if [ $FEND -gt $NEND1 ]; then
if [[ "${FEND}" -gt "${NEND1}" ]]; then
export FINT=$NINT3
fi
${USHgfs}/gfs_bufr.sh

export FSTART=$FEND
export FSTART="${FEND}"
done

##############################################################
Expand Down
28 changes: 6 additions & 22 deletions scripts/exgfs_wave_nawips.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ pdsext=no
g2tbls=g2varswmo2.tbl
NAGRIB=nagrib2

sleep_interval=20
maxtries=15
fhcnt=${fstart}
while [ ${fhcnt} -le ${FHMAX_WAV} ]; do
Expand Down Expand Up @@ -72,28 +73,11 @@ while [ ${fhcnt} -le ${FHMAX_WAV} ]; do
esac
GRIBIN="${COM_WAVE_GRID}/${RUNwave}.${cycle}.${grdIDin}.f${fhr}.grib2"
GRIBIN_chk=${GRIBIN}.idx

icnt=1
while [ ${icnt} -lt 1000 ]; do
if [ -r ${GRIBIN_chk} ] ; then
break
else
let "icnt=icnt+1"
sleep 20
fi
if [ ${icnt} -ge ${maxtries} ]; then
msg="ABORTING after 5 minutes of waiting for ${GRIBIN}."
echo ' '
echo '**************************** '
echo '*** ERROR : NO GRIB FILE *** '
echo '**************************** '
echo ' '
echo ${msg}
set_trace
echo "${RUNwave} ${grdID} ${fhr} prdgen ${date} ${cycle} : GRIB file missing." >> ${wavelog}
err=1;export err;${errchk} || exit ${err}
fi
done
if ! wait_for_file "${GRIBIN_chk}" "${sleep_interval}" "${maxtries}"; then
echo "FATAL ERROR: ${GRIBIN_chk} not found after waiting $((sleep_interval * ( max_tries - 1))) secs"
echo "${RUNwave} ${grdID} ${fhr} prdgen ${date} ${cycle} : GRIB file missing." >> "${wavelog}"
err=1;export err;"${errchk}" || exit "${err}"
fi

#if [ "$grdIDin" = "global.0p25" && "$grid" = "glo_30m" ]; then
if [ "${grdIDin}" = "global.0p25" ]; then
Expand Down
26 changes: 11 additions & 15 deletions scripts/exgfs_wave_post_gridded_sbs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ source "${USHgfs}/preamble.sh"
fhr=$FHMIN_WAV
fi
fhrg=$fhr
sleep_interval=10
iwaitmax=120 # Maximum loop cycles for waiting until wave component output file is ready (fails after max)
while [ $fhr -le $FHMAX_WAV ]; do

Expand All @@ -253,26 +254,21 @@ source "${USHgfs}/preamble.sh"
export GRDIDATA=${DATA}/output_$YMDHMS

# Gridded data (main part, need to be run side-by-side with forecast
WalterKolczynski-NOAA marked this conversation as resolved.
Show resolved Hide resolved

if [ $fhr = $fhrg ]
WalterKolczynski-NOAA marked this conversation as resolved.
Show resolved Hide resolved
then
iwait=0
for wavGRD in ${waveGRD} ; do
gfile=${COM_WAVE_HISTORY}/${WAV_MOD_TAG}.out_grd.${wavGRD}.${YMD}.${HMS}
while [ ! -s ${gfile} ]; do sleep 10; let iwait=iwait+1; done
if [ $iwait -eq $iwaitmax ]; then
echo '*************************************************** '
echo " FATAL ERROR : NO RAW FIELD OUTPUT FILE out_grd.$grdID "
echo '*************************************************** '
echo ' '
set_trace

for wavGRD in ${waveGRD}; do
gfile="${COM_WAVE_HISTORY}/${WAV_MOD_TAG}.out_grd.${wavGRD}.${YMD}.${HMS}"
if ! wait_for_file "${gfile}" "${sleep_interval}" "${iwaitmax}"; then
echo " FATAL ERROR : NO RAW FIELD OUTPUT FILE out_grd.${grdID}"
echo "${WAV_MOD_TAG} post ${grdID} ${PDY} ${cycle} : field output missing."
err=3; export err;${errchk}
exit $err
err=3; export err; "${errchk}"
exit "${err}"
fi
${NLN} ${gfile} ./out_grd.${wavGRD}
${NLN} "${gfile}" "./out_grd.${wavGRD}"
done

if [ "$DOGRI_WAV" = 'YES' ]
then
nigrd=1
Expand Down
32 changes: 8 additions & 24 deletions scripts/exgfs_wave_prdgen_gridded.sh
Original file line number Diff line number Diff line change
Expand Up @@ -96,30 +96,14 @@ grids=${grids:-ak_10m at_10m ep_10m wc_10m glo_30m}
#

GRIBIN="${COM_WAVE_GRID}/${RUNwave}.${cycle}.${grdID}.f${fhr}.grib2"
HenryRWinterbottom marked this conversation as resolved.
Show resolved Hide resolved
GRIBIN_chk=$GRIBIN.idx

icnt=1
while [ $icnt -lt 1000 ]; do
if [ -r $GRIBIN_chk ] ; then
break
else
echo "Waiting for input file: $GRIBIN"
let "icnt=icnt+1"
sleep 5
fi
if [ $icnt -ge $maxtries ]; then
msg="ABNORMAL EXIT: NO GRIB FILE FOR GRID $GRIBIN"
echo ' '
echo '**************************** '
echo '*** ERROR : NO GRIB FILE *** '
echo '**************************** '
echo ' '
echo $msg
set_trace
echo "$RUNwave $grdID ${fhr} prdgen $date $cycle : GRIB file missing." >> $wavelog
err=1;export err;${errchk} || exit ${err}
fi
done
GRIBIN_chk="${GRIBIN}.idx"
sleep_interval=5
max_tries=1000
if ! wait_for_file "${GRIBIN_chk}" "${sleep_interval}" "${max_tries}"; then
echo "FATAL ERROR: ${GRIBIN_chk} not found after waiting $((sleep_interval * ( max_tries - 1))) secs"
echo "$RUNwave $grdID ${fhr} prdgen $date $cycle : GRIB file missing." >> $wavelog
err=1;export err;${errchk} || exit ${err}
fi

GRIBOUT=$RUNwave.$cycle.$grdID.f${fhr}.clipped.grib2

Expand Down
28 changes: 11 additions & 17 deletions ush/gfs_bufr.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#
source "${USHgfs}/preamble.sh"

if [[ "${F00FLAG}" == "YES" ]]; then
if [[ "${f00flag}" == "YES" ]]; then
f00flag=".true."
else
f00flag=".false."
Expand Down Expand Up @@ -51,26 +51,20 @@ cat << EOF > gfsparm
/
EOF

sleep_interval=10
max_tries=1000
for (( hr = 10#${FSTART}; hr <= 10#${FEND}; hr = hr + 10#${FINT} )); do
hh2=$(printf %02i "${hr}")
hh3=$(printf %03i "${hr}")

#---------------------------------------------------------
# Make sure all files are available:
ic=0
while (( ic < 1000 )); do
if [[ ! -f "${COM_ATMOS_HISTORY}/${RUN}.${cycle}.atm.logf${hh3}.${logfm}" ]]; then
sleep 10
ic=$((ic + 1))
else
break
fi

if (( ic >= 360 )); then
echo "FATAL: COULD NOT LOCATE logf${hh3} file AFTER 1 HOUR"
exit 2
fi
done
filename="${COM_ATMOS_HISTORY}/${RUN}.${cycle}.atm.logf${hh3}.${logfm}"
if ! wait_for_file "${filename}" "${sleep_interval}" "${max_tries}"; then
echo "FATAL ERROR: COULD NOT LOCATE logf${hh3} file"
exit 2
fi

#------------------------------------------------------------------
${NLN} "${COM_ATMOS_HISTORY}/${RUN}.${cycle}.atmf${hh3}.${atmfm}" "sigf${hh2}"
${NLN} "${COM_ATMOS_HISTORY}/${RUN}.${cycle}.sfcf${hh3}.${atmfm}" "flxf${hh2}"
Expand All @@ -96,11 +90,11 @@ esac
${APRUN_POSTSND} "${EXECgfs}/${pgm}" < gfsparm > "out_gfs_bufr_${FEND}"
export err=$?

if [ $err -ne 0 ]; then
if [[ "${err}" -ne 0 ]]; then
echo "GFS postsnd job error, Please check files "
echo "${COM_ATMOS_HISTORY}/${RUN}.${cycle}.atmf${hh2}.${atmfm}"
echo "${COM_ATMOS_HISTORY}/${RUN}.${cycle}.sfcf${hh2}.${atmfm}"
err_chk
fi

exit ${err}
exit "${err}"
24 changes: 7 additions & 17 deletions ush/gfs_bufr_netcdf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ hh=$FSTART
hh1=$(echo "${hh#"${hh%??}"}")
hh=$hh1
fi

sleep_interval=10
max_tries=360
while test $hh -le $FEND
do
if test $hh -lt 100
Expand All @@ -75,24 +78,11 @@ do
hh2=$hh
fi

#---------------------------------------------------------
# Make sure all files are available:
ic=0
while [ $ic -lt 1000 ]
do
if [ ! -f $COMIN/${RUN}.${cycle}.logf${hh2}.txt ]
then
sleep 10
ic=$(expr $ic + 1)
else
break
fi
filename="${COMIN}/${RUN}.${cycle}.logf${hh2}.txt"
if ! wait_for_file "${filename}" "${sleep_interval}" "${max_tries}" ; then
err_exit "FATAL ERROR COULD NOT LOCATE logf${hh2} file"
fi

if [ $ic -ge 360 ]
then
err_exit "COULD NOT LOCATE logf${hh2} file AFTER 1 HOUR"
fi
done
#------------------------------------------------------------------
${NLN} $COMIN/${RUN}.${cycle}.atmf${hh2}.nc sigf${hh}
${NLN} $COMIN/${RUN}.${cycle}.${SFCF}f${hh2}.nc flxf${hh}
Expand Down
Loading
Loading