diff --git a/sorc/build_all.sh b/sorc/build_all.sh index 7eb450d6b7..d6f18804ec 100755 --- a/sorc/build_all.sh +++ b/sorc/build_all.sh @@ -1,7 +1,7 @@ #!/bin/sh -set -eu +set -xu #------------------------------------ -# Including Exception Handling. +# Exception handling is now included. # # USER DEFINED STUFF: # @@ -40,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 #------------------------------------ @@ -55,6 +61,8 @@ echo " .... Library build not currently supported .... " $Build_fv3gfs && { echo " .... Building fv3 .... " ./build_fv3.sh > $logs_dir/build_fv3.log 2>&1 +rc=$? +((err+=$rc)) } #------------------------------------ @@ -63,6 +71,8 @@ echo " .... Building fv3 .... " $Build_gsi && { echo " .... Building gsi .... " ./build_gsi.sh > $logs_dir/build_gsi.log 2>&1 +rc=$? +((err+=$rc)) } #------------------------------------ @@ -71,6 +81,8 @@ echo " .... Building gsi .... " $Build_ncep_post && { echo " .... Building ncep_post .... " ./build_ncep_post.sh > $logs_dir/build_ncep_post.log 2>&1 +rc=$? +((err+=$rc)) } #------------------------------------ @@ -79,6 +91,8 @@ echo " .... Building ncep_post .... " $Build_ufs_utils && { echo " .... Building ufs_utils .... " ./build_ufs_utils.sh > $logs_dir/build_ufs_utils.log 2>&1 +rc=$? +((err+=$rc)) } #------------------------------------ @@ -87,6 +101,8 @@ echo " .... Building ufs_utils .... " $Build_gfs_wafs && { echo " .... Building gfs_wafs .... " ./build_gfs_wafs.sh > $logs_dir/build_gfs_wafs .log 2>&1 +rc=$? +((err+=$rc)) } #------------------------------------ @@ -95,6 +111,8 @@ 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=$? +((err+=$rc)) } #------------------------------------ @@ -103,6 +121,8 @@ 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=$? +((err+=$rc)) } #------------------------------------ @@ -111,6 +131,8 @@ echo " .... Building enkf_chgres_recenter .... " $Build_tropcy && { echo " .... Building tropcy_NEMS .... " ./build_tropcy_NEMS.sh > $logs_dir/build_tropcy_NEMS.log 2>&1 +rc=$? +((err+=$rc)) } #------------------------------------ @@ -119,6 +141,8 @@ echo " .... Building tropcy_NEMS .... " $Build_gdas && { echo " .... Building gdas .... " ./build_gdas.sh > $logs_dir/build_gdas.log 2>&1 +rc=$? +((err+=$rc)) } #------------------------------------ @@ -127,6 +151,8 @@ echo " .... Building gdas .... " $Build_gfs_fbwndgfs && { echo " .... Building gfs_fbwndgfs .... " ./build_gfs_fbwndgfs.sh > $logs_dir/build_gfs_fbwndgfs.log 2>&1 +rc=$? +((err+=$rc)) } #------------------------------------ @@ -135,6 +161,8 @@ echo " .... Building gfs_fbwndgfs .... " $Build_gfs_overpdtg2 && { echo " .... Building gfs_overpdtg2 .... " ./build_gfs_overpdtg2.sh > $logs_dir/build_gfs_overpdtg2.log 2>&1 +rc=$? +((err+=$rc)) } #------------------------------------ @@ -143,6 +171,8 @@ echo " .... Building gfs_overpdtg2 .... " $Build_gfs_wintemv && { echo " .... Building gfs_wintemv .... " ./build_gfs_wintemv.sh > $logs_dir/build_gfs_wintemv.log 2>&1 +rc=$? +((err+=$rc)) } #------------------------------------ @@ -151,6 +181,8 @@ echo " .... Building gfs_wintemv .... " $Build_gfs_bufrsnd && { echo " .... Building gfs_bufrsnd .... " ./build_gfs_bufrsnd.sh > $logs_dir/build_gfs_bufrsnd.log 2>&1 +rc=$? +((err+=$rc)) } #------------------------------------ @@ -159,6 +191,8 @@ echo " .... Building gfs_bufrsnd .... " $Build_fv3nc2nemsio && { echo " .... Building fv3nc2nemsio .... " ./build_fv3nc2nemsio.sh > $logs_dir/build_fv3nc2nemsio.log 2>&1 +rc=$? +((err+=$rc)) } #------------------------------------ @@ -167,6 +201,8 @@ echo " .... Building fv3nc2nemsio .... " $Build_regrid_nemsio && { echo " .... Building regrid_nemsio .... " ./build_regrid_nemsio.sh > $logs_dir/build_regrid_nemsio.log 2>&1 +rc=$? +((err+=$rc)) } #------------------------------------ @@ -177,6 +213,8 @@ 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=$? + ((err+=$rc)) } fi @@ -198,6 +236,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