Changeset 412


Ignore:
Timestamp:
01/28/11 17:22:24 (13 years ago)
Author:
sdipsl
Message:
  • Bug fix due to the scope of function variables.

Doing aux=$( myfunction ) : this makes the function be called in a separate ksh process, which cannot dynamically share variables back to the parent shell.

File:
1 edited

Legend:

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

    r409 r412  
    306306{ 
    307307    IGCM_debug_PushStack "IGCM_SmoothModulo" 
     308 
     309    set -vx 
    308310    typeset defVector ModValue 
    309311 
    310312    eval set +A defVector -- $( echo "${1}" | \ 
    311313        gawk -F ':' '{print ($1 == "" ? 1 : $1) " " (NF==3 ? ($2 == "" ? 1 : $2) : 1) " " (NF==3 ? ($3 == "" ? -1 : $3) : ($2 == "" ? -1 : $2))}' ) 
     314 
     315    # Save Smooth Min and Max. Needed to call IGCM_sys_Get when appropriate 
     316    arr[1]=${defVector[0]} 
     317    arr[2]=${defVector[2]} 
    312318 
    313319    # Test limits :  
     
    317323         ( [ ${2} -le ${defVector[2]} ] || \ 
    318324           [ ${defVector[2]} -lt 0 ] ) ) ; then 
    319  
    320         # Save Smooth Min and Max. Needed to call IGCM_sys_Get when appropriate 
    321         SmoothMin=${defVector[0]} 
    322         SmoothMax=${defVector[2]} 
    323325        # Test modulo 
    324326        ModValue=$( expr \( ${2} - ${defVector[0]} \) % ${defVector[1]} ) 
    325327        if [ ${ModValue} -eq 0 ] ;  then 
    326             echo true 
     328            arr[3]=true 
     329            echo ${arr[@]} 
    327330            IGCM_debug_PopStack "IGCM_SmoothModulo" 
    328331            return 1 
    329332        else 
    330             echo false 
     333            arr[3]=false 
     334            echo ${arr[@]} 
    331335            IGCM_debug_PopStack "IGCM_SmoothModulo" 
    332336            return 0 
    333337        fi 
    334338    else 
    335         echo false 
     339        arr[3]=false 
     340        echo ${arr[@]} 
    336341        IGCM_debug_PopStack "IGCM_SmoothModulo" 
    337342        return 0 
     
    344349    IGCM_debug_PushStack "IGCM_comp_GetInputSmoothFiles" 
    345350 
     351    set -vx 
     352 
    346353    # Debug Print : 
    347354    echo 
     
    349356    echo 
    350357 
    351     typeset comp compname comptagname card ListFilesName FileName0 NbFiles i i_ i__ 
    352     typeset file_in_ file_in file_out_ file_out ret SmoothDef 
     358    typeset comp compname comptagname card ListFilesName FileName0 NbFiles j i i_ i__ 
     359    typeset file_in_ file_in file_out_ file_out ret SmoothDef aux val 
    353360 
    354361    for comp in ${config_ListOfComponents[*]} ; do 
    355  
    356362        echo "-----" 
    357363        # Define component 
     
    373379            (( i=0 )) 
    374380            until [ $i -ge $NbFiles ]; do 
    375  
    376381                eval file_in_=\${${ListFilesName}[$i]} > /dev/null 2>&1 
    377382                eval file_in=${file_in_} 
     
    384389                eval SmoothDef=\${${ListFilesName}[$i__]} 
    385390                IGCM_debug_Print 3 "  ${file_in} ${SmoothDef}" 
    386                 eval ret=$( IGCM_SmoothModulo ${SmoothDef} ${CumulPeriod} ) 
    387                 if ( [ X${ret} = Xtrue ] || ( [ ${Period} -eq 1 ] && [ ${CumulPeriod} -ge ${SmoothMin} ] && [ ${CumulPeriod} -le ${SmoothMax} ) ) ; then 
     391                aux=$( IGCM_SmoothModulo ${SmoothDef} ${CumulPeriod} ) 
     392                j=1 
     393                for val in ${aux} ; do 
     394                    [ ${j} -eq 1 ] && SmoothMin=${val} 
     395                    [ ${j} -eq 2 ] && SmoothMax=${val} 
     396                    [ ${j} -eq 3 ] && ret=${val} 
     397                    (( j=j+1 )) 
     398                done 
     399                if ( [ X${ret} = Xtrue ] || ( [ ${Period} -eq 1 ] && [ ${CumulPeriod} -ge ${SmoothMin} ] && [ ${CumulPeriod} -le ${SmoothMax} ] ) ) ; then 
    388400                    IGCM_sys_Get ${file_in} ${file_out} 
    389401                    #IGCM_comp_PrepareDeletedFiles ${file_in} ${file_out} 
Note: See TracChangeset for help on using the changeset viewer.