diff --git a/sorc/build_all.sh b/sorc/build_all.sh index 1af1b2b16b..b24e32e111 100755 --- a/sorc/build_all.sh +++ b/sorc/build_all.sh @@ -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. @@ -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 #------------------------------------ @@ -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)) } #------------------------------------ @@ -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)) } #------------------------------------ @@ -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)) } #------------------------------------ @@ -77,6 +103,12 @@ 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)) } #------------------------------------ @@ -84,7 +116,13 @@ echo " .... Building ufs_utils .... " #------------------------------------ $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)) } #------------------------------------ @@ -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)) } #------------------------------------ @@ -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)) } #------------------------------------ @@ -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)) } #------------------------------------ @@ -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)) } #------------------------------------ @@ -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)) } #------------------------------------ @@ -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)) } #------------------------------------ @@ -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)) } #------------------------------------ @@ -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)) } #------------------------------------ @@ -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)) } #------------------------------------ @@ -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)) } #------------------------------------ @@ -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 @@ -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