Skip to content

Commit

Permalink
Merge pull request NOAA-EMC#18 from lgannoaa/exception_handling
Browse files Browse the repository at this point in the history
Exception handling
  • Loading branch information
KateFriedman-NOAA committed Feb 7, 2020
2 parents 3ed9267 + bdbecaa commit 1d9a1f0
Showing 1 changed file with 112 additions and 2 deletions.
114 changes: 112 additions & 2 deletions sorc/build_all.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/bin/sh
set -eu
set +x
#------------------------------------
# Exception handling is now included.
#
# USER DEFINED STUFF:
#
# USE_PREINST_LIBS: set to "true" to use preinstalled libraries.
Expand Down Expand Up @@ -38,6 +40,12 @@ source ./machine-setup.sh > /dev/null 2>&1

. ./partial_build.sh

#------------------------------------
# Exception Handling Init
#------------------------------------
ERRSCRIPT=${ERRSCRIPT:-'eval [[ $err = 0 ]]'}
err=0

#------------------------------------
# build libraries first
#------------------------------------
Expand All @@ -53,6 +61,12 @@ echo " .... Library build not currently supported .... "
$Build_fv3gfs && {
echo " .... Building fv3 .... "
./build_fv3.sh > $logs_dir/build_fv3.log 2>&1
rc=$?
if [[ $rc -ne 0 ]] ; then
echo "Fatal error in building fv3."
echo "The log file is in $logs_dir/build_fv3.log"
fi
((err+=$rc))
}

#------------------------------------
Expand All @@ -61,6 +75,12 @@ echo " .... Building fv3 .... "
$Build_gsi && {
echo " .... Building gsi .... "
./build_gsi.sh > $logs_dir/build_gsi.log 2>&1
rc=$?
if [[ $rc -ne 0 ]] ; then
echo "Fatal error in building gsi."
echo "The log file is in $logs_dir/build_gsi.log"
fi
((err+=$rc))
}

#------------------------------------
Expand All @@ -69,6 +89,12 @@ echo " .... Building gsi .... "
$Build_ncep_post && {
echo " .... Building ncep_post .... "
./build_ncep_post.sh > $logs_dir/build_ncep_post.log 2>&1
rc=$?
if [[ $rc -ne 0 ]] ; then
echo "Fatal error in building ncep_post."
echo "The log file is in $logs_dir/build_ncep_post.log"
fi
((err+=$rc))
}

#------------------------------------
Expand All @@ -77,14 +103,26 @@ echo " .... Building ncep_post .... "
$Build_ufs_utils && {
echo " .... Building ufs_utils .... "
./build_ufs_utils.sh > $logs_dir/build_ufs_utils.log 2>&1
rc=$?
if [[ $rc -ne 0 ]] ; then
echo "Fatal error in building ufs_utils."
echo "The log file is in $logs_dir/build_ufs_utils.log"
fi
((err+=$rc))
}

#------------------------------------
# build gfs_wafs
#------------------------------------
$Build_gfs_wafs && {
echo " .... Building gfs_wafs .... "
./build_gfs_wafs.sh > $logs_dir/build_gfs_wafs .log 2>&1
./build_gfs_wafs.sh > $logs_dir/build_gfs_wafs.log 2>&1
rc=$?
if [[ $rc -ne 0 ]] ; then
echo "Fatal error in building gfs_wafs."
echo "The log file is in $logs_dir/build_gfs_wafs.log"
fi
((err+=$rc))
}

#------------------------------------
Expand All @@ -93,6 +131,12 @@ echo " .... Building gfs_wafs .... "
$Build_sfcanl_nsttfchg && {
echo " .... Building gaussian_sfcanl and nst_tf_chg .... "
./build_sfcanl_nsttfchg.sh > $logs_dir/build_sfcanl_nsttfchg.log 2>&1
rc=$?
if [[ $rc -ne 0 ]] ; then
echo "Fatal error in building gaussian_sfcanl and nst_tf_chg."
echo "The log file is in $logs_dir/build_sfcanl_nsttfchg.log"
fi
((err+=$rc))
}

#------------------------------------
Expand All @@ -101,6 +145,12 @@ echo " .... Building gaussian_sfcanl and nst_tf_chg .... "
$Build_enkf_chgres_recenter && {
echo " .... Building enkf_chgres_recenter .... "
./build_enkf_chgres_recenter.sh > $logs_dir/build_enkf_chgres_recenter.log 2>&1
rc=$?
if [[ $rc -ne 0 ]] ; then
echo "Fatal error in building enkf_chgres_recenter."
echo "The log file is in $logs_dir/build_enkf_chgres_recenter.log"
fi
((err+=$rc))
}

#------------------------------------
Expand All @@ -109,6 +159,12 @@ echo " .... Building enkf_chgres_recenter .... "
$Build_tropcy && {
echo " .... Building tropcy_NEMS .... "
./build_tropcy_NEMS.sh > $logs_dir/build_tropcy_NEMS.log 2>&1
rc=$?
if [[ $rc -ne 0 ]] ; then
echo "Fatal error in building tropcy_NEMS."
echo "The log file is in $logs_dir/build_tropcy_NEMS.log"
fi
((err+=$rc))
}

#------------------------------------
Expand All @@ -117,6 +173,12 @@ echo " .... Building tropcy_NEMS .... "
$Build_gdas && {
echo " .... Building gdas .... "
./build_gdas.sh > $logs_dir/build_gdas.log 2>&1
rc=$?
if [[ $rc -ne 0 ]] ; then
echo "Fatal error in building gdas."
echo "The log file is in $logs_dir/build_gdas.log"
fi
((err+=$rc))
}

#------------------------------------
Expand All @@ -125,6 +187,12 @@ echo " .... Building gdas .... "
$Build_gfs_fbwndgfs && {
echo " .... Building gfs_fbwndgfs .... "
./build_gfs_fbwndgfs.sh > $logs_dir/build_gfs_fbwndgfs.log 2>&1
rc=$?
if [[ $rc -ne 0 ]] ; then
echo "Fatal error in building gfs_fbwndgfs."
echo "The log file is in $logs_dir/build_gfs_fbwndgfs.log"
fi
((err+=$rc))
}

#------------------------------------
Expand All @@ -133,6 +201,12 @@ echo " .... Building gfs_fbwndgfs .... "
$Build_gfs_overpdtg2 && {
echo " .... Building gfs_overpdtg2 .... "
./build_gfs_overpdtg2.sh > $logs_dir/build_gfs_overpdtg2.log 2>&1
rc=$?
if [[ $rc -ne 0 ]] ; then
echo "Fatal error in building gfs_overpdtg2."
echo "The log file is in $logs_dir/build_gfs_overpdtg2.log"
fi
((err+=$rc))
}

#------------------------------------
Expand All @@ -141,6 +215,12 @@ echo " .... Building gfs_overpdtg2 .... "
$Build_gfs_wintemv && {
echo " .... Building gfs_wintemv .... "
./build_gfs_wintemv.sh > $logs_dir/build_gfs_wintemv.log 2>&1
rc=$?
if [[ $rc -ne 0 ]] ; then
echo "Fatal error in building gfs_wintemv."
echo "The log file is in $logs_dir/build_gfs_wintemv.log"
fi
((err+=$rc))
}

#------------------------------------
Expand All @@ -149,6 +229,12 @@ echo " .... Building gfs_wintemv .... "
$Build_gfs_bufrsnd && {
echo " .... Building gfs_bufrsnd .... "
./build_gfs_bufrsnd.sh > $logs_dir/build_gfs_bufrsnd.log 2>&1
rc=$?
if [[ $rc -ne 0 ]] ; then
echo "Fatal error in building gfs_bufrsnd."
echo "The log file is in $logs_dir/build_gfs_bufrsnd.log"
fi
((err+=$rc))
}

#------------------------------------
Expand All @@ -157,6 +243,12 @@ echo " .... Building gfs_bufrsnd .... "
$Build_fv3nc2nemsio && {
echo " .... Building fv3nc2nemsio .... "
./build_fv3nc2nemsio.sh > $logs_dir/build_fv3nc2nemsio.log 2>&1
rc=$?
if [[ $rc -ne 0 ]] ; then
echo "Fatal error in building fv3nc2nemsio."
echo "The log file is in $logs_dir/build_fv3nc2nemsio.log"
fi
((err+=$rc))
}

#------------------------------------
Expand All @@ -165,6 +257,12 @@ echo " .... Building fv3nc2nemsio .... "
$Build_regrid_nemsio && {
echo " .... Building regrid_nemsio .... "
./build_regrid_nemsio.sh > $logs_dir/build_regrid_nemsio.log 2>&1
rc=$?
if [[ $rc -ne 0 ]] ; then
echo "Fatal error in building regrid_nemsio."
echo "The log file is in $logs_dir/build_regrid_nemsio.log"
fi
((err+=$rc))
}

#------------------------------------
Expand All @@ -175,6 +273,12 @@ if [ $target = wcoss -o $target = wcoss_cray -o $target = wcoss_dell_p3 ]; then
$Build_gfs_util && {
echo " .... Building gfs_util .... "
./build_gfs_util.sh > $logs_dir/build_gfs_util.log 2>&1
rc=$?
if [[ $rc -ne 0 ]] ; then
echo "Fatal error in building gfs_util."
echo "The log file is in $logs_dir/build_gfs_util.log"
fi
((err+=$rc))
}
fi

Expand All @@ -196,6 +300,12 @@ echo " .... grib_util build not currently supported .... "
#./build_grib_util.sh > $logs_dir/build_grib_util.log 2>&1
}

#------------------------------------
# Exception Handling
#------------------------------------
[[ $err -ne 0 ]] && echo "FATAL BUILD ERROR: Please check the log file for detail, ABORT!"
$ERRSCRIPT || exit $err

echo;echo " .... Build system finished .... "

exit 0

0 comments on commit 1d9a1f0

Please sign in to comment.