Skip to content

Commit

Permalink
Stop checking for restarts on non-GFS CDUMPs (#1179)
Browse files Browse the repository at this point in the history
The forecast was attempting to check `RSTDIR_ATM` for restart files, but that variable is not defined for gdas, resulting in an unbound variable error. Because the error occurred in a subshell, the error had no impact on the execution, just an unwanted error message in the log. Now that directory is only checked when the `$CDUMP` is 'gfs'.

Also fixes some linter warnings.

Fixes #1140
  • Loading branch information
lgannoaa committed Dec 15, 2022
1 parent f2ecf3a commit 5b454c3
Showing 1 changed file with 25 additions and 25 deletions.
50 changes: 25 additions & 25 deletions ush/forecast_det.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,55 +19,55 @@ FV3_GFS_det(){
res_latlon_dynamics="''"

# Determine if this is a warm start or cold start
if [ -f $gmemdir/RESTART/${sPDY}.${scyc}0000.coupler.res ]; then
if [[ -f "${gmemdir}/RESTART/${sPDY}.${scyc}0000.coupler.res" ]]; then
export warm_start=".true."
fi

# turn IAU off for cold start
DOIAU_coldstart=${DOIAU_coldstart:-"NO"}
if [ $DOIAU = "YES" -a $warm_start = ".false." ] || [ $DOIAU_coldstart = "YES" -a $warm_start = ".true." ]; then
if [ ${DOIAU} = "YES" -a ${warm_start} = ".false." ] || [ ${DOIAU_coldstart} = "YES" -a ${warm_start} = ".true." ]; then
export DOIAU="NO"
echo "turning off IAU since warm_start = $warm_start"
echo "turning off IAU since warm_start = ${warm_start}"
DOIAU_coldstart="YES"
IAU_OFFSET=0
sCDATE=$CDATE
sPDY=$PDY
scyc=$cyc
tPDY=$sPDY
tcyc=$cyc
sCDATE=${CDATE}
sPDY=${PDY}
scyc=${cyc}
tPDY=${sPDY}
tcyc=${cyc}
fi

#-------------------------------------------------------
# determine if restart IC exists to continue from a previous forecast
RERUN="NO"
filecount=$(find $RSTDIR_ATM -type f | wc -l)
if [ $CDUMP = "gfs" -a $rst_invt1 -gt 0 -a $FHMAX -gt $rst_invt1 -a $filecount -gt 10 ]; then
[[ ${CDUMP} = "gfs" ]] && filecount=$(find "${RSTDIR_ATM}" -type f | wc -l)
if [ ${CDUMP} = "gfs" -a ${rst_invt1} -gt 0 -a ${FHMAX} -gt ${rst_invt1} -a ${filecount} -gt 10 ]; then
reverse=$(echo "${restart_interval[@]} " | tac -s ' ')
for xfh in $reverse ; do
for xfh in ${reverse} ; do
yfh=$((xfh-(IAU_OFFSET/2)))
SDATE=$($NDATE +$yfh $CDATE)
PDYS=$(echo $SDATE | cut -c1-8)
cycs=$(echo $SDATE | cut -c9-10)
flag1=$RSTDIR_ATM/${PDYS}.${cycs}0000.coupler.res
flag2=$RSTDIR_ATM/coupler.res
SDATE=$(${NDATE} +${yfh} "${CDATE}")
PDYS=$(echo "${SDATE}" | cut -c1-8)
cycs=$(echo "${SDATE}" | cut -c9-10)
flag1=${RSTDIR_ATM}/${PDYS}.${cycs}0000.coupler.res
flag2=${RSTDIR_ATM}/coupler.res

#make sure that the wave restart files also exist if cplwav=true
waverstok=".true."
if [ $cplwav = ".true." ]; then
for wavGRD in $waveGRD ; do
if [ ! -f ${RSTDIR_WAVE}/${PDYS}.${cycs}0000.restart.${wavGRD} ]; then
if [[ "${cplwav}" = ".true." ]]; then
for wavGRD in ${waveGRD} ; do
if [[ ! -f "${RSTDIR_WAVE}/${PDYS}.${cycs}0000.restart.${wavGRD}" ]]; then
waverstok=".false."
fi
done
fi

if [ -s $flag1 -a $waverstok = ".true." ]; then
CDATE_RST=$SDATE
[[ $RERUN = "YES" ]] && break
mv $flag1 ${flag1}.old
if [ -s $flag2 ]; then mv $flag2 ${flag2}.old ;fi
if [[ -s "${flag1}" ]] && [[ ${waverstok} = ".true." ]]; then
CDATE_RST=${SDATE}
[[ ${RERUN} = "YES" ]] && break
mv "${flag1}" "${flag1}.old"
if [[ -s "${flag2}" ]]; then mv "${flag2}" "${flag2}.old" ;fi
RERUN="YES"
[[ $xfh = $rst_invt1 ]] && RERUN="NO"
[[ ${xfh} = ${rst_invt1} ]] && RERUN="NO"
fi
done
fi
Expand Down

0 comments on commit 5b454c3

Please sign in to comment.