From d0a3b53c8117676c351c50287d4583951c94d42c Mon Sep 17 00:00:00 2001 From: "Lin.Gan" Date: Fri, 24 Jan 2020 14:30:29 +0000 Subject: [PATCH 1/4] init commit for exception handling branch --- sorc/build_all.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sorc/build_all.sh b/sorc/build_all.sh index 1af1b2b16b..60bac3268d 100755 --- a/sorc/build_all.sh +++ b/sorc/build_all.sh @@ -1,6 +1,8 @@ #!/bin/sh set -eu #------------------------------------ +# Exception handling is now included. +# # USER DEFINED STUFF: # # USE_PREINST_LIBS: set to "true" to use preinstalled libraries. From 4d5713d3983c6cc6a8e497e892760752e09f15a0 Mon Sep 17 00:00:00 2001 From: "Lin.Gan" Date: Fri, 24 Jan 2020 15:51:28 +0000 Subject: [PATCH 2/4] Testing github commit --- sorc/build_all.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sorc/build_all.sh b/sorc/build_all.sh index 60bac3268d..7eb450d6b7 100755 --- a/sorc/build_all.sh +++ b/sorc/build_all.sh @@ -1,7 +1,7 @@ #!/bin/sh set -eu #------------------------------------ -# Exception handling is now included. +# Including Exception Handling. # # USER DEFINED STUFF: # From c12e87987113fa6f4b543bc0dae61d4259703c03 Mon Sep 17 00:00:00 2001 From: "Lin.Gan" Date: Mon, 27 Jan 2020 19:38:19 +0000 Subject: [PATCH 3/4] Implement exception handling in build_all script --- sorc/build_all.sh | 48 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 46 insertions(+), 2 deletions(-) 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 From bdbecaa7220f2462cc75e802570845809ebcfc75 Mon Sep 17 00:00:00 2001 From: "Lin.Gan" Date: Wed, 29 Jan 2020 15:15:52 +0000 Subject: [PATCH 4/4] Display exception handling message for individual package with location of the log file --- sorc/build_all.sh | 68 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 66 insertions(+), 2 deletions(-) diff --git a/sorc/build_all.sh b/sorc/build_all.sh index d6f18804ec..b24e32e111 100755 --- a/sorc/build_all.sh +++ b/sorc/build_all.sh @@ -1,5 +1,5 @@ #!/bin/sh -set -xu +set +x #------------------------------------ # Exception handling is now included. # @@ -62,6 +62,10 @@ $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)) } @@ -72,6 +76,10 @@ $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)) } @@ -82,6 +90,10 @@ $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)) } @@ -92,6 +104,10 @@ $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)) } @@ -100,8 +116,12 @@ rc=$? #------------------------------------ $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)) } @@ -112,6 +132,10 @@ $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)) } @@ -122,6 +146,10 @@ $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)) } @@ -132,6 +160,10 @@ $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)) } @@ -142,6 +174,10 @@ $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)) } @@ -152,6 +188,10 @@ $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)) } @@ -162,6 +202,10 @@ $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)) } @@ -172,6 +216,10 @@ $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)) } @@ -182,6 +230,10 @@ $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)) } @@ -192,6 +244,10 @@ $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)) } @@ -202,6 +258,10 @@ $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)) } @@ -214,6 +274,10 @@ if [ $target = wcoss -o $target = wcoss_cray -o $target = wcoss_dell_p3 ]; then 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