Ignore:
Timestamp:
02/04/13 17:03:47 (11 years ago)
Author:
labetoulle
Message:

Cosmetics :

  • Tabs replacement, round 2.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libIGCM/libIGCM_card/libIGCM_card.ksh

    r772 r786  
    5858    IGCM_debug_PushStack "IGCM_card_PrintOption" $@ 
    5959    if ( [ -r "$1" ] && [ -f "$1" ] ) ; then 
    60         gawk -f ${libIGCM}/libIGCM_card/IGCM_card_PrintOption.awk "$@" 
    61     else 
    62         echo 
    63         IGCM_debug_Print 1 "--Error--> IGCM_card_PrintOption $@" 
    64         IGCM_debug_Print 1 "           $1 is not readable" 
    65         IGCM_debug_Exit "IGCM_card_PrintOption" 
     60      gawk -f ${libIGCM}/libIGCM_card/IGCM_card_PrintOption.awk "$@" 
     61    else 
     62      echo 
     63      IGCM_debug_Print 1 "--Error--> IGCM_card_PrintOption $@" 
     64      IGCM_debug_Print 1 "           $1 is not readable" 
     65      IGCM_debug_Exit "IGCM_card_PrintOption" 
    6666    fi 
    6767    IGCM_debug_PopStack "IGCM_card_PrintOption" 
     
    7878    IGCM_debug_PushStack "IGCM_card_PrintSection" $@ 
    7979    if ( [ -r "$1" ] && [ -f "$1" ] ) ; then 
    80         gawk -f ${libIGCM}/libIGCM_card/IGCM_card_PrintSection.awk -- "$@" 
    81     else 
    82         IGCM_debug_Print 1 "--Error--> IGCM_card_PrintSection $@" 
    83         IGCM_debug_Print 1 "           $1 is not readable" 
    84         IGCM_debug_Exit "IGCM_card_PrintSection" 
     80      gawk -f ${libIGCM}/libIGCM_card/IGCM_card_PrintSection.awk -- "$@" 
     81    else 
     82      IGCM_debug_Print 1 "--Error--> IGCM_card_PrintSection $@" 
     83      IGCM_debug_Print 1 "           $1 is not readable" 
     84      IGCM_debug_Exit "IGCM_card_PrintSection" 
    8585    fi 
    8686    IGCM_debug_PopStack "IGCM_card_PrintSection" 
     
    9797    IGCM_debug_PushStack "IGCM_card_DefineVariableFromOption" $@ 
    9898    if ( [ -r "$1" ] && [ -f "$1" ] ) ; then 
    99         # Get basename of card file ($1) 
    100         typeset name1=${1##*/} 
    101         # Build name of variable as $1_$2_$3 (cardname_Section_Option) 
    102         typeset name=${name1%%.*}_${2}_${3} 
    103         typeset value=$( gawk -f ${libIGCM}/libIGCM_card/IGCM_card_PrintOption.awk -- "$@" ) 
    104  
    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" 
    111             IGCM_debug_Exit 
    112             IGCM_debug_Verif_Exit 
    113         fi 
    114         eval ${name}=${value} 
    115     else 
    116         echo 
    117         IGCM_debug_Print 1 "--Error--> IGCM_card_DefineVariableFromOption" 
    118         IGCM_debug_Print 1 "--Error--> $1 is not readable" 
    119         IGCM_debug_Exit "IGCM_card_DefineVariableFromOption" 
    120         IGCM_debug_Verif_Exit 
     99      # Get basename of card file ($1) 
     100      typeset name1=${1##*/} 
     101      # Build name of variable as $1_$2_$3 (cardname_Section_Option) 
     102      typeset name=${name1%%.*}_${2}_${3} 
     103      typeset value=$( gawk -f ${libIGCM}/libIGCM_card/IGCM_card_PrintOption.awk -- "$@" ) 
     104 
     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" 
     111        IGCM_debug_Exit 
     112        IGCM_debug_Verif_Exit 
     113      fi 
     114      eval ${name}=${value} 
     115    else 
     116      echo 
     117      IGCM_debug_Print 1 "--Error--> IGCM_card_DefineVariableFromOption" 
     118      IGCM_debug_Print 1 "--Error--> $1 is not readable" 
     119      IGCM_debug_Exit "IGCM_card_DefineVariableFromOption" 
     120      IGCM_debug_Verif_Exit 
    121121    fi 
    122122    IGCM_debug_PopStack "IGCM_card_DefineVariableFromOption" 
     
    133133    IGCM_debug_PushStack "IGCM_card_DefineArrayFromOption" $@ 
    134134    if ( [ -r "$1" ] && [ -f "$1" ] ) ; then 
    135         # Get basename of card file ($1) 
    136         typeset name1=${1##*/} 
    137         # Build name of array as $1_$2_$3 (cardname_Section_Option) 
    138         typeset name=${name1%%.*}_${2}_${3} 
    139         eval unset ${name} 
    140         eval ${name}[0]=${NULL_STR} 
    141         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)}' ) 
    142     else 
    143         echo 
    144         IGCM_debug_Print 1 "--Error--> IGCM_card_DefineArrayFromOption $@" 
    145         IGCM_debug_Print 1 "           $1 is not readable" 
    146         IGCM_debug_Exit "IGCM_card_DefineArrayFromOption" 
     135      # Get basename of card file ($1) 
     136      typeset name1=${1##*/} 
     137      # Build name of array as $1_$2_$3 (cardname_Section_Option) 
     138      typeset name=${name1%%.*}_${2}_${3} 
     139      eval unset ${name} 
     140      eval ${name}[0]=${NULL_STR} 
     141      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)}' ) 
     142    else 
     143      echo 
     144      IGCM_debug_Print 1 "--Error--> IGCM_card_DefineArrayFromOption $@" 
     145      IGCM_debug_Print 1 "           $1 is not readable" 
     146      IGCM_debug_Exit "IGCM_card_DefineArrayFromOption" 
    147147    fi 
    148148    IGCM_debug_PopStack "IGCM_card_DefineArrayFromOption" 
     
    159159    IGCM_debug_PushStack "IGCM_card_DefineArrayFromSection" $@ 
    160160    if ( [ -r "$1" ] && [ -f "$1" ] ) ; then 
    161         # Get basename of card file ($1) 
    162         typeset name1=${1##*/} 
    163         # Build name of array as $1_$2 (cardname_Section) 
    164         typeset name=${name1%%.*}_${2} 
    165         eval unset ${name} 
    166         eval ${name}[0]=${NULL_STR} 
    167         set +A ${name} -- $( gawk -f ${libIGCM}/libIGCM_card/IGCM_card_PrintSection.awk -- "$@" ) 
    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         if [ "$( eval echo \${${name}[@]} )" = "Error: Section not found" ] ; then 
    176           echo 
    177           IGCM_debug_Print 1 "Warning with readding of ${name} variable in ${1}." 
    178           IGCM_debug_Print 1 "Warning: Section ${2} not found" 
    179           eval unset ${name} 
    180         fi 
    181     else 
    182         IGCM_debug_Print 1 "--Error--> IGCM_card_DefineArrayFromSection $@" 
    183         IGCM_debug_Print 1 "           $1 is not readable" 
    184         IGCM_debug_Exit "IGCM_card_DefineArrayFromSection" 
     161      # Get basename of card file ($1) 
     162      typeset name1=${1##*/} 
     163      # Build name of array as $1_$2 (cardname_Section) 
     164      typeset name=${name1%%.*}_${2} 
     165      eval unset ${name} 
     166      eval ${name}[0]=${NULL_STR} 
     167      set +A ${name} -- $( gawk -f ${libIGCM}/libIGCM_card/IGCM_card_PrintSection.awk -- "$@" ) 
     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      if [ "$( eval echo \${${name}[@]} )" = "Error: Section not found" ] ; then 
     176        echo 
     177        IGCM_debug_Print 1 "Warning with readding of ${name} variable in ${1}." 
     178        IGCM_debug_Print 1 "Warning: Section ${2} not found" 
     179        eval unset ${name} 
     180      fi 
     181    else 
     182      IGCM_debug_Print 1 "--Error--> IGCM_card_DefineArrayFromSection $@" 
     183      IGCM_debug_Print 1 "           $1 is not readable" 
     184      IGCM_debug_Exit "IGCM_card_DefineArrayFromSection" 
    185185    fi 
    186186    IGCM_debug_PopStack "IGCM_card_DefineArrayFromSection" 
     
    201201    IGCM_debug_PushStack "IGCM_card_WriteOption" $@ 
    202202    if ( [ -r "$1" ] && [ -w "$1" ]  && [ -f "$1" ] ) ; then 
    203         typeset tmpfile=tmpfile_$$ 
    204         ( IGCM_card_PrintOption "$1" "$2" "$3" | grep "not found" ) > ${tmpfile} 
    205         if [ $( cat ${tmpfile} | wc -l ) -gt 0 ] ; then 
    206             echo "-------------------------------------------" 
    207             echo "!!! Problem with IGCM_card_WriteOption !!!" 
    208             echo "Try to write : " $@ 
    209             echo "You have to correct some script."  
    210             echo "We won't do anything else !" 
    211             exit 1 
    212         fi 
    213         \rm ${tmpfile} 
    214  
    215         # The tmpfile uses now the real path of the card to be modified,  
    216         # not just a local tmpfile with PID. 
    217         tmpfile=$1_mutex_$$ 
    218  
    219         IGCM_card_CheckConflict $1 
    220  
    221         # Do the job 
    222         ( gawk -f ${libIGCM}/libIGCM_card/IGCM_card_WriteOption.awk -- "$@" 2> /dev/null ) > ${tmpfile} 
    223  
    224         cp $1 $1.bak 
    225         mv ${tmpfile} $1 
    226  
    227     else 
    228         echo 
    229         IGCM_debug_Print 1 "--Error--> IGCM_card_WriteOption $@" 
    230         IGCM_debug_Print 1 "           $1 is not readable or not writable" 
    231         IGCM_debug_Exit "IGCM_card_WriteOption" 
     203      typeset tmpfile=tmpfile_$$ 
     204      ( IGCM_card_PrintOption "$1" "$2" "$3" | grep "not found" ) > ${tmpfile} 
     205      if [ $( cat ${tmpfile} | wc -l ) -gt 0 ] ; then 
     206        echo "-------------------------------------------" 
     207        echo "!!! Problem with IGCM_card_WriteOption !!!" 
     208        echo "Try to write : " $@ 
     209        echo "You have to correct some script."  
     210        echo "We won't do anything else !" 
     211        exit 1 
     212      fi 
     213      \rm ${tmpfile} 
     214 
     215      # The tmpfile uses now the real path of the card to be modified,  
     216      # not just a local tmpfile with PID. 
     217      tmpfile=$1_mutex_$$ 
     218 
     219      IGCM_card_CheckConflict $1 
     220 
     221      # Do the job 
     222      ( gawk -f ${libIGCM}/libIGCM_card/IGCM_card_WriteOption.awk -- "$@" 2> /dev/null ) > ${tmpfile} 
     223 
     224      cp $1 $1.bak 
     225      mv ${tmpfile} $1 
     226 
     227    else 
     228      echo 
     229      IGCM_debug_Print 1 "--Error--> IGCM_card_WriteOption $@" 
     230      IGCM_debug_Print 1 "           $1 is not readable or not writable" 
     231      IGCM_debug_Exit "IGCM_card_WriteOption" 
    232232    fi 
    233233    IGCM_debug_PopStack "IGCM_card_WriteOption" 
     
    244244    ((isleep=0)) 
    245245    while [ ${#tmpfiles[@]} -gt 0 ] ; do  
    246         echo "Conflict between two processes working on " $1 "!!!" ${tmpfiles[@]} 
    247         sleep 1 
    248         ((isleep=isleep+1)) 
    249         if [ isleep -gt 20 ] ; then 
    250             echo "Too many loops waiting for other process working on " $1 ". We continue." 
    251             echo "You should see if one process of your run or post-treatment may have terminated suddenly." 
    252             echo "Afer, you should erase this(those) file(s) : " ${tmpfiles[@]} 
     246      echo "Conflict between two processes working on " $1 "!!!" ${tmpfiles[@]} 
     247      sleep 1 
     248      ((isleep=isleep+1)) 
     249      if [ isleep -gt 20 ] ; then 
     250        echo "Too many loops waiting for other process working on " $1 ". We continue." 
     251        echo "You should see if one process of your run or post-treatment may have terminated suddenly." 
     252        echo "Afer, you should erase this(those) file(s) : " ${tmpfiles[@]} 
    253253# Send a mail to USER ?? 
    254             break ; 
    255         fi 
    256         unset tmpfiles 
    257         set +A tmpfiles -- $( ls $1_mutex_[0-9]* 2>/dev/null ) 
     254        break ; 
     255      fi 
     256      unset tmpfiles 
     257      set +A tmpfiles -- $( ls $1_mutex_[0-9]* 2>/dev/null ) 
    258258    done 
    259259 
     
    273273 
    274274    if ( [ -r "$1" ] && [ -w "$1" ]  && [ -f "$1" ] ) ; then 
    275         typeset tmpfile=tmpfile_$$ 
    276         if [ X"${4}" != X"" ]; then 
    277             tab=$4 
    278             IGCM_card_WriteOption $1 $2 $3 '('$( eval echo \${${tab}[@]} | sed -e 's/ /,/g' )')' 
    279         else 
    280             IGCM_card_WriteOption $1 $2 $3 '()' 
    281         fi 
    282     else 
    283         echo 
    284         IGCM_debug_Print 1 "--Error--> IGCM_card_WriteArrayOption $@" 
    285         IGCM_debug_Print 1 "           $1 is not readable or not writable" 
    286         IGCM_debug_Exit "IGCM_card_WriteArrayOption" 
     275      typeset tmpfile=tmpfile_$$ 
     276      if [ X"${4}" != X"" ]; then 
     277        tab=$4 
     278        IGCM_card_WriteOption $1 $2 $3 '('$( eval echo \${${tab}[@]} | sed -e 's/ /,/g' )')' 
     279      else 
     280        IGCM_card_WriteOption $1 $2 $3 '()' 
     281      fi 
     282    else 
     283      echo 
     284      IGCM_debug_Print 1 "--Error--> IGCM_card_WriteArrayOption $@" 
     285      IGCM_debug_Print 1 "           $1 is not readable or not writable" 
     286      IGCM_debug_Exit "IGCM_card_WriteArrayOption" 
    287287    fi 
    288288    IGCM_debug_PopStack "IGCM_card_WriteArrayOption" 
     
    299299#--------------------- 
    300300    if [ ! -n "${libIGCM}" ] ; then 
    301         echo "Check libIGCM_card ...........................................[ FAILED ]" 
    302         echo "--Error--> libIGCM variable is not defined" 
    303         IGCM_debug_Exit "IGCM_card_Check" 
     301      echo "Check libIGCM_card ...........................................[ FAILED ]" 
     302      echo "--Error--> libIGCM variable is not defined" 
     303      IGCM_debug_Exit "IGCM_card_Check" 
    304304    fi 
    305305 
     
    307307    whence -v gawk > /dev/null 2>&1 
    308308    if [ ! $? -eq 0 ] ; then 
    309         echo "Check libIGCM_card ...........................................[ FAILED ]" 
    310         echo "--Error--> gawk command is not defined" 
    311         IGCM_debug_Exit "IGCM_card_Check" 
     309      echo "Check libIGCM_card ...........................................[ FAILED ]" 
     310      echo "--Error--> gawk command is not defined" 
     311      IGCM_debug_Exit "IGCM_card_Check" 
    312312    fi 
    313313 
     
    317317 
    318318    if diff IGCM_card_Test.ref.failed ${libIGCM}/libIGCM_card/IGCM_card_Test.ref > /dev/null 2>&1 ; then  
    319         echo "Check libIGCM_card ...............................................[ OK ]" 
    320         rm -f IGCM_card_Test.ref.failed 
     319      echo "Check libIGCM_card ...............................................[ OK ]" 
     320      rm -f IGCM_card_Test.ref.failed 
    321321    else  
    322         echo "Check libIGCM_card ...........................................[ FAILED ]" 
    323         echo "--Error--> Execution of ${libIGCM}/libIGCM_card/IGCM_card_Test.ksh" 
    324         echo "           has produced the file IGCM_card_Test.ref.failed" 
    325         echo "           Please analyse differences with the reference file by typing:" 
    326         echo "           diff IGCM_card_Test.ref.failed ${libIGCM}/libIGCM_card/IGCM_card_Test.ref" 
    327         echo "           Report errors to the author: Patrick.Brockmann@cea.fr" 
    328         IGCM_debug_Exit "IGCM_card_Check" 
     322      echo "Check libIGCM_card ...........................................[ FAILED ]" 
     323      echo "--Error--> Execution of ${libIGCM}/libIGCM_card/IGCM_card_Test.ksh" 
     324      echo "           has produced the file IGCM_card_Test.ref.failed" 
     325      echo "           Please analyse differences with the reference file by typing:" 
     326      echo "           diff IGCM_card_Test.ref.failed ${libIGCM}/libIGCM_card/IGCM_card_Test.ref" 
     327      echo "           Report errors to the author: Patrick.Brockmann@cea.fr" 
     328      IGCM_debug_Exit "IGCM_card_Check" 
    329329    fi 
    330330 
Note: See TracChangeset for help on using the changeset viewer.