Ignore:
Timestamp:
10/28/08 18:42:58 (16 years ago)
Author:
sdipsl
Message:

PB + MM : - great optimisation for libIGCM_date

  • add IGCM_card_WriteArrayOption. Write an array option for a given file.card and section
Location:
trunk/libIGCM/libIGCM_card
Files:
3 edited

Legend:

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

    r5 r23  
    8282 
    8383diff ${libIGCM}/libIGCM_card/TestFile.card NewTestFile.card 
    84 rm -f NewTestFile.card 
     84rm -f NewTestFile.card NewTestFile.card.bak 
    8585 
  • trunk/libIGCM/libIGCM_card/IGCM_card_WriteOption.awk

    r5 r23  
    102102END { 
    103103 
    104 if (! exit_value ) { 
     104    if (! exit_value ) { 
    105105 
    106 myprint("###############################") 
    107 myprint("section      ====> " section) 
    108 myprint("option       ====> " option) 
    109 myprint("value        ====> " value) 
     106        myprint("###############################") 
     107        myprint("section      ====> " section) 
     108        myprint("option       ====> " option) 
     109        myprint("value        ====> " value) 
     110         
     111        if (section_found == 0) { 
     112            print "Error: Section not found", section, option 
     113        } else if (option_found == 0) { 
     114            print "Error: Option not found", section, option 
     115        }        
     116         
     117    } else { 
    110118 
    111 if (section_found == 0) { 
    112         print "Error: Section not found" 
    113 } else if (option_found == 0) { 
    114         print "Error: Option not found" 
    115 }        
     119        print "Error in with IGCM_WriteOption : ", section, option 
    116120 
    117 } 
     121    } 
    118122 
    119123} 
  • trunk/libIGCM/libIGCM_card/libIGCM_card.ksh

    r5 r23  
    167167#D-#================================================================== 
    168168#D-function IGCM_card_WriteOption 
    169 #D-* Purpose: Write an option from a given file.card and section 
     169#D-* Purpose: Write an option in a given file.card and section 
    170170#D-* Usage: IGCM_card_WriteOption file.card section newvalue 
    171171#D-* Examples: IGCM_card_WriteOption file.card Recipes Red 150 
     
    181181        typeset tmpfile=tmpfile_$$ 
    182182        ( awk -f ${libIGCM}/libIGCM_card/IGCM_card_WriteOption.awk -- "$@" 2> /dev/null ) > ${tmpfile} 
     183        cp $1 $1.bak 
    183184        mv ${tmpfile} $1 
    184185    else 
     
    188189    fi 
    189190    IGCM_debug_PopStack "IGCM_card_WriteOption" 
     191} 
     192 
     193#D-#================================================================== 
     194#D-function IGCM_card_WriteArrayOption 
     195#D-* Purpose: Write an array option a given file.card and section 
     196#D-* Usage: IGCM_card_WriteArrayOption file.card section option newarray 
     197#D-* Examples: set -A MyArray -- 1 2 3 
     198#D-            IGCM_card_WriteArrayOption file.card Recipes List MyArray 
     199#D- 
     200function IGCM_card_WriteArrayOption 
     201{ 
     202    IGCM_debug_PushStack "IGCM_card_WriteArrayOption" $@ 
     203 
     204    if [ -r "$1" ] && [ -w "$1" ] ; then 
     205        typeset tmpfile=tmpfile_$$ 
     206        if [ X"${4}" != X"" ]; then 
     207            tab=$4 
     208            IGCM_card_WriteOption $1 $2 $3 '('$( eval echo \${${tab}[@]} | sed -e 's/ /,/g' )')' 
     209        else 
     210            IGCM_card_WriteOption $1 $2 $3 '()' 
     211        fi 
     212    else 
     213        echo "--Error--> IGCM_card_WriteArrayOption $@" 
     214        echo "           $1 is not readable or not writable" 
     215        IGCM_debug_Exit "IGCM_card_WriteArrayOption" 
     216    fi 
     217    IGCM_debug_PopStack "IGCM_card_WriteArrayOption" 
    190218} 
    191219 
Note: See TracChangeset for help on using the changeset viewer.