Changeset 475


Ignore:
Timestamp:
05/31/11 15:12:20 (13 years ago)
Author:
sdipsl
Message:
  • Better error handling within libGCM
  • Pre requisite to have more robust post-processing workflow
  • Improve verbosity to help users identify problem
  • Cosmetic
  • backward compatible
Location:
trunk/libIGCM
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/libIGCM/AA_TimeSeries_Checker

    r436 r475  
    177177                IGCM_card_DefineArrayFromOption ${card} ${flag_post} TimeSeriesVars 
    178178                IGCM_card_DefineArrayFromOption ${card} ${flag_post} Patches 
    179                 if [ X"$( eval echo \${${compname}_${flag_post}_TimeSeriesVars[*]} )" = X"Option not found ${flag_post}" ] ; then 
     179                if [ X"$( eval echo \${${compname}_${flag_post}_TimeSeriesVars[*]} )" = X"Option not" ] ; then 
    180180                    # New TimeSeriesVar description, with 2D, 3D and associate ChunckJob. 
    181181                    unset ListDimension 
  • trunk/libIGCM/AA_job

    r473 r475  
    166166#D- Increased verbosity (1, 2, 3) 
    167167Verbosity=3 
     168#D- Experience type : DEB(ug), DEV(elopment), RUN (default) 
     169JobType=RUN 
    168170#D- Number of execution in one job 
    169171PeriodNb=1 
     
    171173 
    172174#D- 
    173 # -------------------------------------------------------------------- 
    174 #D- ! Optionnal features /!\ Use with care ! 
    175 # -------------------------------------------------------------------- 
     175# --------------------------------------------------------------------------------------------------# 
     176#D-                          ! Optionnal features /!\ Use with care !                               # 
     177# --------------------------------------------------------------------------------------------------# 
     178 
    176179 
    177180#D- Low level debug : to bypass lib test checks and stack construction 
     
    183186#DEBUG_sys=false 
    184187 
    185 #D- Experience type : DEB(ug), DEV(elopment), RUN (default) 
    186 JobType=RUN 
    187  
    188188#D- Define running directory 
    189189#D- Default=${TMPDIR} ie temporary batch directory 
     
    198198#BIG_DIR=/somewhere/with/lot/of/space/scratchdir/may/be 
    199199 
     200#D- Define input file root directory 
     201#D- Default=/IGCMG/common/account/of/this/machine 
     202#R_IN=/u/rech/por/rpor111/DATA 
     203 
    200204#D- Turn in dry run mode ? (0,1,2,3) 
    201205#D- Default=0 
    202206#DRYRUN=3 
    203 # YOU MUST COMPILE YOUR EXE FILES FOR DRYRUN MODE ! 
     207# YOU HAVE TO COMPILE YOUR EXE FILES to USE DRYRUN MODE ! 
    204208# ------------------------------------------------------------------------------------- 
    205209# | DRYRUN=  |  Date computations, | sys_Get    |  Exe    | sys_Put_Out; sys_Put_Rest | 
     
    216220# ------------------------------------------------------------------------------------- 
    217221 
    218 #D- Define input file root directory 
    219 #D- Default=/IGCMG/common/account/of/this/machine 
    220 #R_IN=/u/rech/por/rpor111/DATA 
     222#D- 
     223# --------------------------------------------------------------------------------------------------# 
     224#D- ! End of optionnal features /!\ Do not modify anything below unless you know what you are doing # 
     225# --------------------------------------------------------------------------------------------------# 
    221226 
    222227#D- 
  • trunk/libIGCM/libIGCM_card/IGCM_card_PrintOption.awk

    r425 r475  
    124124 
    125125if (section_found == 0) { 
    126         print "Error: Section not found", section, option 
     126        print "Error: Section not found" 
    127127} else if (option_found == 0) { 
    128         print "Error: Option not found", section, option 
     128        print "Error: Option not found" 
    129129} else { 
    130130        print option_value 
  • trunk/libIGCM/libIGCM_card/IGCM_card_PrintSection.awk

    r373 r475  
    109109        print "Error: Section not found" 
    110110} else if (match(option_list,"null")) { 
    111         print "Error: Options not found" 
     111        print "Error: Option not found" 
    112112} else { 
    113113        print option_list 
  • trunk/libIGCM/libIGCM_card/IGCM_card_WriteOption.awk

    r373 r475  
    106106         
    107107        if (section_found == 0) { 
    108             print "Error: Section not found", section, option 
     108            print "Error: Section not found" 
    109109        } else if (option_found == 0) { 
    110             print "Error: Option not found", section, option 
     110            print "Error: Option not found" 
    111111        }        
    112112         
  • trunk/libIGCM/libIGCM_card/libIGCM_card.ksh

    r472 r475  
    5252#D-* Purpose: Print an option from a given file.card and section 
    5353#D-* Usage: IGCM_card_PrintOption file.card section option 
     54#D-* Only used by IGCM_card_Test.ksh 
    5455#D- 
    5556function IGCM_card_PrintOption 
    5657{ 
    5758    IGCM_debug_PushStack "IGCM_card_PrintOption" $@ 
    58     if [ -r "$1" ] ; then 
     59    if ( [ -r "$1" ] && [ -f "$1" ] ) ; then 
    5960        gawk -f ${libIGCM}/libIGCM_card/IGCM_card_PrintOption.awk "$@" 
    6061    else 
    61         echo "--Error--> IGCM_card_PrintOption $@" 
    62         echo "           $1 is not readable" 
     62        echo 
     63        IGCM_debug_Print 1 "--Error--> IGCM_card_PrintOption $@" 
     64        IGCM_debug_Print 1 "           $1 is not readable" 
    6365        IGCM_debug_Exit "IGCM_card_PrintOption" 
    6466    fi 
     
    7072#D-* Purpose: Print all options from a given file.card and section 
    7173#D-* Usage: IGCM_card_PrintSection file.card section 
     74#D-* Only used by IGCM_card_Test.ksh 
    7275#D- 
    7376function IGCM_card_PrintSection 
    7477{ 
    7578    IGCM_debug_PushStack "IGCM_card_PrintSection" $@ 
    76     if [ -r "$1" ] ; then 
     79    if ( [ -r "$1" ] && [ -f "$1" ] ) ; then 
    7780        gawk -f ${libIGCM}/libIGCM_card/IGCM_card_PrintSection.awk -- "$@" 
    7881    else 
    79         echo "--Error--> IGCM_card_PrintSection $@" 
    80         echo "           $1 is not readable" 
     82        IGCM_debug_Print 1 "--Error--> IGCM_card_PrintSection $@" 
     83        IGCM_debug_Print 1 "           $1 is not readable" 
    8184        IGCM_debug_Exit "IGCM_card_PrintSection" 
    8285    fi 
     
    9396{ 
    9497    IGCM_debug_PushStack "IGCM_card_DefineVariableFromOption" $@ 
    95     if [ -r "$1" ] ; then 
     98    if ( [ -r "$1" ] && [ -f "$1" ] ) ; then 
    9699        # Get basename of card file ($1) 
    97100        typeset name1=${1##*/} 
     
    100103        typeset value=$( gawk -f ${libIGCM}/libIGCM_card/IGCM_card_PrintOption.awk -- "$@" ) 
    101104 
    102         if [ "${value}" = "Error: Option not found" ] ; then 
    103             echo "Error with readding of ${name} variable in ${1} ." 
    104             echo "Error: Option not found." 
     105        # Only if a section is missing we exit the job. 
     106        # We must allow missing option to keep backward compatibilty. 
     107        if [ "${value}" = "Error: Section not found" ] ; then 
     108            echo 
     109            IGCM_debug_Print 1 "Error with readding of ${name} variable in ${1}." 
     110            IGCM_debug_Print 1 "Error: Section ${2} not found" 
    105111            IGCM_debug_Exit 
    106112            IGCM_debug_Verif_Exit 
     
    108114        eval ${name}=${value} 
    109115    else 
    110         echo "--Error--> IGCM_card_DefineVariableFromOption $@" 
    111         echo "           $1 is not readable" 
     116        echo 
     117        IGCM_debug_Print 1 "--Error--> IGCM_card_DefineVariableFromOption" 
     118        IGCM_debug_Print 1 "--Error--> $1 is not readable" 
    112119        IGCM_debug_Exit "IGCM_card_DefineVariableFromOption" 
     120        IGCM_debug_Verif_Exit 
    113121    fi 
    114122    IGCM_debug_PopStack "IGCM_card_DefineVariableFromOption" 
     
    124132{ 
    125133    IGCM_debug_PushStack "IGCM_card_DefineArrayFromOption" $@ 
    126     if [ -r "$1" ] ; then 
     134    if ( [ -r "$1" ] && [ -f "$1" ] ) ; then 
    127135        # Get basename of card file ($1) 
    128136        typeset name1=${1##*/} 
     
    133141        set +A ${name} -- $( gawk -f ${libIGCM}/libIGCM_card/IGCM_card_PrintOption.awk -- "$@" | gawk -- 'BEGIN {FS="[() ,]+"} {for (i=2; i <= NF-1; i++) printf("%s ",$i)}' ) 
    134142    else 
    135         echo "--Error--> IGCM_card_DefineArrayFromOption $@" 
    136         echo "           $1 is not readable" 
     143        echo 
     144        IGCM_debug_Print 1 "--Error--> IGCM_card_DefineArrayFromOption $@" 
     145        IGCM_debug_Print 1 "           $1 is not readable" 
    137146        IGCM_debug_Exit "IGCM_card_DefineArrayFromOption" 
    138147    fi 
     
    149158{ 
    150159    IGCM_debug_PushStack "IGCM_card_DefineArrayFromSection" $@ 
    151     if [ -r "$1" ] ; then 
     160    if ( [ -r "$1" ] && [ -f "$1" ] ) ; then 
    152161        # Get basename of card file ($1) 
    153162        typeset name1=${1##*/} 
     
    157166        eval ${name}[0]=${NULL_STR} 
    158167        set +A ${name} -- $( gawk -f ${libIGCM}/libIGCM_card/IGCM_card_PrintSection.awk -- "$@" ) 
    159     else 
    160         echo "--Error--> IGCM_card_DefineArrayFromSection $@" 
    161         echo "           $1 is not readable" 
     168        if [ "$( eval echo \${${name}[@]} )" = "Error: Section not found" ] ; then 
     169            echo 
     170            IGCM_debug_Print 1 "Error with readding of ${name} variable in ${1}." 
     171            IGCM_debug_Print 1 "Error: Section ${2} not found" 
     172            IGCM_debug_Exit 
     173            IGCM_debug_Verif_Exit 
     174        fi 
     175    else 
     176        IGCM_debug_Print 1 "--Error--> IGCM_card_DefineArrayFromSection $@" 
     177        IGCM_debug_Print 1 "           $1 is not readable" 
    162178        IGCM_debug_Exit "IGCM_card_DefineArrayFromSection" 
    163179    fi 
     
    178194{ 
    179195    IGCM_debug_PushStack "IGCM_card_WriteOption" $@ 
    180     if [ -r "$1" ] && [ -w "$1" ] ; then 
     196    if ( [ -r "$1" ] && [ -w "$1" ]  && [ -f "$1" ] ) ; then 
    181197        typeset tmpfile=tmpfile_$$ 
    182198        ( IGCM_card_PrintOption "$1" "$2" "$3" | grep "not found" ) > ${tmpfile} 
     
    185201            echo "!!! Problem with IGCM_card_WriteOption !!!" 
    186202            echo "Try to write : " $@ 
    187             echo "You have to correcte some script."  
     203            echo "You have to correct some script."  
    188204            echo "We won't do anything else !" 
    189205            exit 1 
    190206        fi 
    191         rm ${tmpfile} 
     207        \rm ${tmpfile} 
    192208 
    193209        # The tmpfile uses now the real path of the card to be modified,  
     
    204220 
    205221    else 
    206         echo "--Error--> IGCM_card_WriteOption $@" 
    207         echo "           $1 is not readable or not writable" 
     222        echo 
     223        IGCM_debug_Print 1 "--Error--> IGCM_card_WriteOption $@" 
     224        IGCM_debug_Print 1 "           $1 is not readable or not writable" 
    208225        IGCM_debug_Exit "IGCM_card_WriteOption" 
    209226    fi 
     
    249266    IGCM_debug_PushStack "IGCM_card_WriteArrayOption" $@ 
    250267 
    251     if [ -r "$1" ] && [ -w "$1" ] ; then 
     268    if ( [ -r "$1" ] && [ -w "$1" ]  && [ -f "$1" ] ) ; then 
    252269        typeset tmpfile=tmpfile_$$ 
    253270        if [ X"${4}" != X"" ]; then 
     
    258275        fi 
    259276    else 
    260         echo "--Error--> IGCM_card_WriteArrayOption $@" 
    261         echo "           $1 is not readable or not writable" 
     277        echo 
     278        IGCM_debug_Print 1 "--Error--> IGCM_card_WriteArrayOption $@" 
     279        IGCM_debug_Print 1 "           $1 is not readable or not writable" 
    262280        IGCM_debug_Exit "IGCM_card_WriteArrayOption" 
    263281    fi 
     
    294312    if diff IGCM_card_Test.ref.failed ${libIGCM}/libIGCM_card/IGCM_card_Test.ref > /dev/null 2>&1 ; then  
    295313        echo "Check libIGCM_card ...............................................[ OK ]" 
    296         rm -f IGCM_card_Test.ref.failed 
     314        IGCM_sys_Rm IGCM_card_Test.ref.failed 
    297315    else  
    298316        echo "Check libIGCM_card ...........................................[ FAILED ]" 
  • trunk/libIGCM/libIGCM_comp/libIGCM_comp.ksh

    r465 r475  
    142142                    IGCM_card_DefineArrayFromOption ${card} ${flag_post} TimeSeriesVars 
    143143                    IGCM_card_DefineArrayFromOption ${card} ${flag_post} Patches 
    144                     if [ X"$( eval echo \${${compname}_${flag_post}_TimeSeriesVars[*]} )" = X"Option not found ${flag_post}" ] ; then 
     144                    if [ X"$( eval echo \${${compname}_${flag_post}_TimeSeriesVars[*]} )" = X"Option not" ] ; then 
    145145                        # New TimeSeriesVar description, with 2D, 3D and associate ChunckJob. 
    146146                        ListDimension[0]=2D 
Note: See TracChangeset for help on using the changeset viewer.