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
File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.