Skip to content

Commit

Permalink
The error handling has been improved by switching to use the NCO SPA
Browse files Browse the repository at this point in the history
recommended produtil err_check method for j-jobs, exscripts and ush
scripts.
  • Loading branch information
BinLiu-NOAA committed Apr 10, 2024
1 parent e4cf12a commit e5501aa
Show file tree
Hide file tree
Showing 44 changed files with 126 additions and 103 deletions.
4 changes: 2 additions & 2 deletions jobs/JHAFS_ANALYSIS
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ cd $DATA

# Execute ex-script
${HOMEhafs}/scripts/exhafs_analysis.sh
status=$?; [[ $status -ne 0 ]] && exit $status
export err=$?; err_chk

# Cleanup DATA dir
cd ${WORKhafs}
Expand Down Expand Up @@ -184,7 +184,7 @@ cd $DATA

# Execute ex-script
${HOMEhafs}/scripts/exhafs_analysis.sh
status=$?; [[ $status -ne 0 ]] && exit $status
export err=$?; err_chk

# Cleanup DATA dir
cd ${WORKhafs}
Expand Down
2 changes: 1 addition & 1 deletion jobs/JHAFS_ATM_IC
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ cd $DATA

# Execute ex-script
${HOMEhafs}/scripts/exhafs_atm_ic.sh
status=$?; [[ $status -ne 0 ]] && exit $status
export err=$?; err_chk

# Cleanup DATA dir
cd ${WORKhafs}
Expand Down
6 changes: 3 additions & 3 deletions jobs/JHAFS_ATM_INIT
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ cd $DATA

# Execute ex-script
${HOMEhafs}/scripts/exhafs_forecast.sh
status=$?; [[ $status -ne 0 ]] && exit $status
export err=$?; err_chk

#===============================================================================
# post
Expand All @@ -119,7 +119,7 @@ cd $DATA

# Execute ex-script
${HOMEhafs}/scripts/exhafs_atm_post.sh
status=$?; [[ $status -ne 0 ]] && exit $status
export err=$?; err_chk

#===============================================================================
# product
Expand Down Expand Up @@ -161,7 +161,7 @@ for ng in $(seq 1 ${ngrids}); do
done
chmod +x cmdfile_product
${APRUNC} ${MPISERIAL} -m cmdfile_product
status=$?; [[ $status -ne 0 ]] && exit $status
export err=$?; err_chk

# Check if product/tracker run successfully
for ng in $(seq 1 ${ngrids}); do
Expand Down
2 changes: 1 addition & 1 deletion jobs/JHAFS_ATM_LBC
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ cd $DATA

# Execute ex-script
${HOMEhafs}/scripts/exhafs_atm_lbc.sh
status=$?; [[ $status -ne 0 ]] && exit $status
export err=$?; err_chk

# Cleanup DATA dir
cd ${WORKhafs}
Expand Down
2 changes: 1 addition & 1 deletion jobs/JHAFS_ATM_POST
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ cd $DATA

# Execute ex-script
${HOMEhafs}/scripts/exhafs_atm_post.sh
status=$?; [[ $status -ne 0 ]] && exit $status
export err=$?; err_chk

# Cleanup DATA dir
cd ${WORKhafs}
Expand Down
4 changes: 2 additions & 2 deletions jobs/JHAFS_ATM_PREP
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,10 @@ cd $DATA
# Execute ex-script
if [[ "${run_datm:-no}" = "yes" ]]; then
${HOMEhafs}/scripts/exhafs_datm_prep.sh
status=$?; [[ $status -ne 0 ]] && exit $status
export err=$?; err_chk
else
${HOMEhafs}/scripts/exhafs_atm_prep.sh
status=$?; [[ $status -ne 0 ]] && exit $status
export err=$?; err_chk
fi

# Cleanup DATA dir
Expand Down
2 changes: 1 addition & 1 deletion jobs/JHAFS_ATM_VI
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ cd $DATA

# Execute ex-script
${HOMEhafs}/scripts/exhafs_atm_vi.sh
status=$?; [[ $status -ne 0 ]] && exit $status
export err=$?; err_chk

# Cleanup DATA dir
cd ${WORKhafs}
Expand Down
2 changes: 1 addition & 1 deletion jobs/JHAFS_ENKF
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ cd $DATA

# Execute ex-script
${HOMEhafs}/scripts/exhafs_enkf.sh
status=$?; [[ $status -ne 0 ]] && exit $status
export err=$?; err_chk

# Cleanup DATA dir
cd ${WORKhafs}
Expand Down
2 changes: 1 addition & 1 deletion jobs/JHAFS_ENKF_HX
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ cd $DATA

# Execute ex-script
${HOMEhafs}/scripts/exhafs_enkf_hx.sh
status=$?; [[ $status -ne 0 ]] && exit $status
export err=$?; err_chk

# Cleanup DATA dir
cd ${WORKhafs}
Expand Down
2 changes: 1 addition & 1 deletion jobs/JHAFS_FORECAST
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ cd $DATA

# Execute ex-script
${HOMEhafs}/scripts/exhafs_forecast.sh
status=$?; [[ $status -ne 0 ]] && exit $status
export err=$?; err_chk

# Cleanup DATA dir
cd ${WORKhafs}
Expand Down
2 changes: 1 addition & 1 deletion jobs/JHAFS_GEMPAK
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ cd $DATA

# Execute ex-script
${HOMEhafs}/scripts/exhafs_gempak.sh
status=$?; [[ $status -ne 0 ]] && exit $status
export err=$?; err_chk

# Cleanup DATA dir
cd ${WORKhafs}
Expand Down
2 changes: 1 addition & 1 deletion jobs/JHAFS_GRAPHICS
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ cd $DATA

# Execute ex-script
${HOMEhafs}/scripts/${exscript}
status=$?; [[ $status -ne 0 ]] && exit $status
export err=$?; err_chk

# Cleanup DATA dir
cd ${WORKhafs}
Expand Down
2 changes: 1 addition & 1 deletion jobs/JHAFS_LAUNCH
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ configmore=" ${HAFS_LAUNCH_EXTRA_CONFIG:-}"

# Execute ex-script
${HOMEhafs}/scripts/exhafs_launch.py "$PDY$cyc" "$storm" FORECAST $PARMhafs $configmore
status=$?; [[ $status -ne 0 ]] && exit $status
export err=$?; err_chk

# Cleanup DATA dir
cd ${WORKhafs}
Expand Down
2 changes: 1 addition & 1 deletion jobs/JHAFS_MERGE
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ cd $DATA

# Execute ex-script
${HOMEhafs}/scripts/exhafs_merge.sh
status=$?; [[ $status -ne 0 ]] && exit $status
export err=$?; err_chk

# Cleanup DATA dir
cd ${WORKhafs}
Expand Down
2 changes: 1 addition & 1 deletion jobs/JHAFS_MSG_CHECK
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export COMINmsg=${COMINmsg:-$(compath.py ${envir}/${NET}/${hafs_ver})/inp${RUN}}

# Execute ex-script
${HOMEhafs}/scripts/exhafs_msg_check.py "${PDY:2:6}" "$cyc"
status=$?; [[ $status -ne 0 ]] && exit $status
export err=$?; err_chk

# Cleanup DATA dir
cd ${DATAROOT}
Expand Down
2 changes: 1 addition & 1 deletion jobs/JHAFS_OBS_PREP
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ cd $DATA

# Execute ex-script
${HOMEhafs}/scripts/exhafs_obs_prep.sh
status=$?; [[ $status -ne 0 ]] && exit $status
export err=$?; err_chk

# Cleanup DATA dir
cd ${WORKhafs}
Expand Down
4 changes: 2 additions & 2 deletions jobs/JHAFS_OCN_POST
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,12 @@ cd $DATA
# Execute ex-script
if [[ "${run_ocean:-no}" == yes ]] && [[ "${ocean_model}" == mom6 ]] ; then
${HOMEhafs}/scripts/exhafs_ocn_post.sh
status=$?; [[ $status -ne 0 ]] && exit $status
export err=$?; err_chk
fi

if [[ "${run_ocean:-no}" == yes ]] && [[ "${ocean_model}" == hycom ]] ; then
${HOMEhafs}/scripts/exhafs_ocn_post.py
status=$?; [[ $status -ne 0 ]] && exit $status
export err=$?; err_chk
fi

# Cleanup DATA dir
Expand Down
6 changes: 3 additions & 3 deletions jobs/JHAFS_OCN_PREP
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,12 @@ cd $DATA
# Execute ex-script
if [[ "${run_docn:-no}" == yes ]] ; then
${HOMEhafs}/scripts/exhafs_docn_prep.sh
status=$?; [[ $status -ne 0 ]] && exit $status
export err=$?; err_chk
fi

if [[ "${run_ocean:-no}" == yes ]] && [[ "${ocean_model}" == hycom ]] ; then
${HOMEhafs}/scripts/exhafs_ocn_prep.py
status=$?; [[ $status -ne 0 ]] && exit $status
export err=$?; err_chk
fi

if [[ "${run_ocean:-no}" == yes ]] && [[ "${ocean_model}" == mom6 ]] ; then
Expand All @@ -97,7 +97,7 @@ if [[ "${run_ocean:-no}" == yes ]] && [[ "${ocean_model}" == mom6 ]] ; then
fi
export PYTHONPATH=$PYTHONPATH:${HOMEhafs}/ush/mom6_obc
${HOMEhafs}/scripts/exhafs_ocn_prep.sh
status=$?; [[ $status -ne 0 ]] && exit $status
export err=$?; err_chk
fi

# Cleanup DATA dir
Expand Down
2 changes: 1 addition & 1 deletion jobs/JHAFS_OUTPUT
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ cd $DATA

# Execute ex-script
${HOMEhafs}/scripts/exhafs_output.sh
status=$?; [[ $status -ne 0 ]] && exit $status
export err=$?; err_chk

# Cleanup DATA dir
cd ${WORKhafs}
Expand Down
2 changes: 1 addition & 1 deletion jobs/JHAFS_PRODUCT
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ for ng in $(seq 1 ${ngrids}); do
done
chmod +x cmdfile_product
${APRUNC} ${MPISERIAL} -m cmdfile_product
status=$?; [[ $status -ne 0 ]] && exit $status
export err=$?; err_chk

# Check if product/tracker run successfully
for ng in $(seq 1 ${ngrids}); do
Expand Down
2 changes: 1 addition & 1 deletion jobs/JHAFS_UNPOST
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ cd $DATA

# Execute ex-script
${HOMEhafs}/scripts/exhafs_unpost.sh
status=$?; [[ $status -ne 0 ]] && exit $status
export err=$?; err_chk

# Cleanup DATA dir
cd ${WORKhafs}
Expand Down
2 changes: 1 addition & 1 deletion jobs/JHAFS_WAV_POST
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ cd $DATA

# Execute ex-script
${HOMEhafs}/scripts/exhafs_wav_post.py
status=$?; [[ $status -ne 0 ]] && exit $status
export err=$?; err_chk

# Cleanup DATA dir
cd ${WORKhafs}
Expand Down
2 changes: 1 addition & 1 deletion jobs/JHAFS_WAV_PREP
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ cd $DATA

# Execute ex-script
${HOMEhafs}/scripts/exhafs_wav_prep.py
status=$?; [[ $status -ne 0 ]] && exit $status
export err=$?; err_chk

# Cleanup DATA dir
cd ${WORKhafs}
Expand Down
1 change: 1 addition & 0 deletions scripts/exhafs_analysis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,7 @@ ${NCP} -p ${ANALYSISEXEC} ./hafs_gsi.x
set -o pipefail
${APRUNC} ./hafs_gsi.x 2>&1 | tee ./stdout
set +o pipefail
export err=$?; err_chk

cat ./stdout > ${GSISOUT}

Expand Down
4 changes: 2 additions & 2 deletions scripts/exhafs_atm_ic.sh
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ EOF

${NCP} -p ${CHGRESCUBEEXEC} ./hafs_chgres_cube.x
${APRUNC} ./hafs_chgres_cube.x
status=$?; [[ $status -ne 0 ]] && exit $status
export err=$?; err_chk

if [ $gtype = uniform ] || [ $gtype = stretch ] || [ $gtype = nest ]; then
mv gfs_ctrl.nc ${OUTDIR}/gfs_ctrl.nc
Expand Down Expand Up @@ -378,7 +378,7 @@ cat>./fort.41<<EOF
EOF
#${NCP} -p ${CHGRESCUBEEXEC} ./hafs_chgres_cube.x
${APRUNC} ./hafs_chgres_cube.x
status=$?; [[ $status -ne 0 ]] && exit $status
export err=$?; err_chk
mv out.atm.tile1.nc ${OUTDIR}/gfs_data.tile${itile}.nc
mv out.sfc.tile1.nc ${OUTDIR}/sfc_data.tile${itile}.nc

Expand Down
2 changes: 1 addition & 1 deletion scripts/exhafs_atm_lbc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ EOF

${NCP} -p ${CHGRESCUBEEXEC} ./hafs_chgres_cube.x
${APRUNC} ./hafs_chgres_cube.x
status=$?; [[ $status -ne 0 ]] && exit $status
export err=$?; err_chk
# Move output files to save directory
if [ $gtype = regional ]; then
if [ $REGIONAL = 1 ]; then
Expand Down
1 change: 1 addition & 0 deletions scripts/exhafs_atm_post.sh
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,7 @@ ${NCP} -p ${POSTEXEC} ./hafs_post.x
set -o pipefail
${APRUNC} ./hafs_post.x < itag 2>&1 | tee ./outpost_${NEWDATE}
set +o pipefail
export err=$?; err_chk

mv HURPRS.GrbF${FHR2} ${grb2post}
if [ ${satpost} = .true. ]; then
Expand Down
62 changes: 27 additions & 35 deletions scripts/exhafs_atm_prep.sh
Original file line number Diff line number Diff line change
Expand Up @@ -581,32 +581,28 @@ if [[ ! -e ./hafs_sfc_climo_gen.x ]]; then
${NCP} -p $SFCCLIMOEXEC ./hafs_sfc_climo_gen.x
fi
$APRUNC ./hafs_sfc_climo_gen.x
rc=$?

if [[ $rc == 0 ]]; then
if [[ $GRIDTYPE != "regional" ]]; then
for files in *.nc; do
if [[ -f $files ]]; then
mv $files ${sfc_climo_savedir}/${CASE}.${files}
fi
done
else
for files in *.halo.nc; do
if [[ -f $files ]]; then
file2=${files%.halo.nc}
mv $files ${sfc_climo_savedir}/${CASE}.${file2}.halo${HALO}.nc
fi
done
for files in *.nc; do
if [[ -f $files ]]; then
file2=${files%.nc}
mv $files ${sfc_climo_savedir}/${CASE}.${file2}.halo0.nc
fi
done
fi # is regional?
export err=$?; err_chk

if [[ $GRIDTYPE != "regional" ]]; then
for files in *.nc; do
if [[ -f $files ]]; then
mv $files ${sfc_climo_savedir}/${CASE}.${files}
fi
done
else
exit $rc
fi
for files in *.halo.nc; do
if [[ -f $files ]]; then
file2=${files%.halo.nc}
mv $files ${sfc_climo_savedir}/${CASE}.${file2}.halo${HALO}.nc
fi
done
for files in *.nc; do
if [[ -f $files ]]; then
file2=${files%.nc}
mv $files ${sfc_climo_savedir}/${CASE}.${file2}.halo0.nc
fi
done
fi # is regional?

if [ $gtype = regional ]; then
rm -f $out_dir/${CASE}_grid.tile${tile}.nc
Expand Down Expand Up @@ -660,17 +656,13 @@ if [[ ! -e ./hafs_sfc_climo_gen.x ]]; then
${NCP} -p $SFCCLIMOEXEC ./hafs_sfc_climo_gen.x
fi
$APRUNC ./hafs_sfc_climo_gen.x
rc=$?
export err=$?; err_chk

if [[ $rc == 0 ]]; then
for files in *.nc; do
if [[ -f $files ]]; then
mv $files ${sfc_climo_savedir}/${CASE}.${files}
fi
done
else
exit $rc
fi
for files in *.nc; do
if [[ -f $files ]]; then
mv $files ${sfc_climo_savedir}/${CASE}.${files}
fi
done

done

Expand Down
Loading

0 comments on commit e5501aa

Please sign in to comment.