Ignore:
Timestamp:
05/29/08 21:32:29 (16 years ago)
Author:
mmaipsl
Message:

MM: Add SmoothFiles? with last commit (r6) corrections.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/SmoothFiles/libIGCM_comp/libIGCM_comp.ksh

    r5 r8  
    9494            for option in ${card_UserChoices[*]} ; do 
    9595                IGCM_card_DefineVariableFromOption ${card} UserChoices ${option} 
    96                 eval IGCM_debug_Print 3 "${compname}_UserChoices_values: ${card_UserChoices[*]}" 
     96                eval IGCM_debug_Print 3 "${compname}_UserChoices_values: ${option} \${card_UserChoices_${option}}" 
    9797            done 
    9898        fi 
     
    198198 
    199199#======================================================================= 
     200# Definition of Smooth modulo function 
     201# usage :  
     202# IGCM_SmoothModulo StringModulo value 
     203# 
     204# StringModulo : A string of min max and modulo like definition of Scilab vectors. 
     205# [min]:[modulo:][max] 
     206# where : 
     207# [] value are optionnals;  
     208# empty min equal 1 
     209# empty max equal infinity 
     210# modulo not given or empty equal 1 
     211# empty string or just ':' equal always. 
     212# 
     213# value : the value to test with the definition 
     214# 
     215# return : true(1)/false(0)  
     216function IGCM_SmoothModulo 
     217{ 
     218    IGCM_debug_PushStack "IGCM_SmoothModulo" 
     219    typeset defVector ModValue 
     220 
     221    eval set +A defVector -- $( echo "${1}" | \ 
     222        awk -F ':' '{print ($1 == "" ? 1 : $1) " " (NF==3 ? ($2 == "" ? 1 : $2) : 1) " " (NF==3 ? ($3 == "" ? -1 : $3) : ($2 == "" ? -1 : $2))}' ) 
     223 
     224    # Test limits :  
     225    # ${defVector[0]} <= ${2} <= ${defVector[2]}  
     226    #                                      or ${defVector[2]} == -1 
     227    if ( [ ${2} -ge ${defVector[0]} ] && \ 
     228         ( [ ${2} -le ${defVector[2]} ] || \ 
     229           [ ${defVector[2]} -lt 0 ] ) ) ; then 
     230 
     231        # Test modulo 
     232        ModValue=$( expr \( ${2} - ${defVector[0]} \) % ${defVector[1]} ) 
     233        if [ ${ModValue} -eq 0 ] ;  then 
     234            echo true 
     235            IGCM_debug_PopStack "IGCM_SmoothModulo" 
     236            return 1 
     237        else 
     238            echo false 
     239            IGCM_debug_PopStack "IGCM_SmoothModulo" 
     240            return 0 
     241        fi 
     242    else 
     243        echo false 
     244        IGCM_debug_PopStack "IGCM_SmoothModulo" 
     245        return 0 
     246    fi 
     247} 
     248 
     249#======================================================================= 
     250function IGCM_comp_GetInputSmoothFiles 
     251{ 
     252    IGCM_debug_PushStack "IGCM_comp_GetInputSmoothFiles" 
     253 
     254    # Debug Print : 
     255    echo 
     256    IGCM_debug_Print 1 "IGCM_comp_GetInputSmoothFiles :" 
     257    echo 
     258 
     259    typeset comp compname comptagname card ListFilesName FileName0 NbFiles i i_ i__ 
     260    typeset file_in_ file_in file_out_ file_out ret SmoothDef 
     261 
     262    for comp in ${config_ListOfComponents[*]} ; do 
     263 
     264        echo "-----" 
     265        # Define component 
     266        eval compname=\${config_ListOfComponents_${comp}[0]} > /dev/null 2>&1 
     267        eval comptagname=\${config_ListOfComponents_${comp}[1]} > /dev/null 2>&1 
     268 
     269        # Debug Print : 
     270        IGCM_debug_Print 3 "Smooth files ${compname}" 
     271 
     272        card=${SUBMIT_DIR}/COMP/${compname}.card 
     273 
     274        IGCM_card_DefineArrayFromOption ${card} SmoothFiles List 
     275        ListFilesName=${compname}_SmoothFiles_List 
     276        eval FileName0=\${${ListFilesName}[0]} > /dev/null 2>&1 
     277 
     278        if [ X${FileName0} != X${NULL_STR} ] ; then 
     279            eval NbFiles=\${#${ListFilesName}[@]} > /dev/null 2>&1 
     280 
     281            (( i=0 )) 
     282            until [ $i -ge $NbFiles ]; do 
     283 
     284                eval file_in_=\${${ListFilesName}[$i]} > /dev/null 2>&1 
     285                eval file_in=${file_in_} 
     286                (( i_ = i+1 )) 
     287                eval file_out_=\${${ListFilesName}[$i_]} > /dev/null 2>&1 
     288                eval file_out=${file_out_} 
     289 
     290                # define CumulPeriod definition for this file 
     291                (( i__ = i+2 )) 
     292                eval SmoothDef=\${${ListFilesName}[$i__]} 
     293                IGCM_debug_Print 3 "  ${file_in} ${SmoothDef}" 
     294                eval ret=$( IGCM_SmoothModulo ${SmoothDef} ${CumulPeriod} ) 
     295                if [ X${ret} = Xtrue ] ; then 
     296                    IGCM_sys_Get ${file_in} ${file_out} 
     297 
     298                    IGCM_comp_PrepareDeletedFiles ${file_in} ${file_out} 
     299                fi 
     300                (( i=i+3 )) 
     301            done 
     302        fi 
     303    done 
     304     
     305    IGCM_debug_PopStack "IGCM_comp_GetInputSmoothFiles" 
     306} 
     307 
     308#======================================================================= 
    200309function IGCM_comp_GetInputBoundaryFiles 
    201310{ 
Note: See TracChangeset for help on using the changeset viewer.