Changeset 29


Ignore:
Timestamp:
11/03/08 19:02:57 (15 years ago)
Author:
sdipsl
Message:

SD,MM : - Continue merging AllPostFred? branch and trunk

  • This give more flexibility to PeriodLenght? (*Y|y, *M|m, *D|d)
  • Need more test concerning userchoices consistency
  • only create_se is missing now
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libIGCM/AA_create_ts

    r18 r29  
    241241        FlagDir=$( echo ${FILE} | awk -F "_" '{print $1}' ) 
    242242        case ${FlagDir} in 
    243             1Y)    TS_Dir=TS_YE  ;; 
    244             1M)    TS_Dir=TS_MO  ;; 
    245             5D|1D) TS_Dir=TS_DA  ;; 
    246             HF)    TS_Dir=TS_HF  ;; 
    247             INS)   TS_Dir=TS_INS ;; 
     243            *Y)  TS_Dir=TS_YE  ;;  
     244            *M)  TS_Dir=TS_MO  ;;  
     245            *D)  TS_Dir=TS_DA  ;;  
     246            HF)  TS_Dir=TS_HF  ;; 
     247            INS) TS_Dir=TS_INS ;; 
    248248        esac 
    249249 
     
    297297    IGCM_debug_PushStack "create_ts_next_date" $@ 
    298298    typeset year month Length 
    299     case ${1} in 
    300         1Y|1y) 
    301             IGCM_date_GetYearMonth ${2} year month 
    302             Length=$( IGCM_date_DaysInYear $(( year + 1 )) ) ;; 
    303         1M|1m) 
    304             IGCM_date_GetYearMonth ${2} year month 
    305             if [ $month -lt 12 ] ; then 
    306                 Length=$( IGCM_date_DaysInMonth $year $(( month + 1 )) ) 
     299    case ${config_UserChoices_PeriodLength} in 
     300        *Y|*y)  
     301            PeriodLengthInYears=$( echo ${config_UserChoices_PeriodLength} | awk -F '[yY]' '{print $1}' ) 
     302            IGCM_date_GetYearMonth ${1} year month 
     303            (( Length=0 )) 
     304            (( i=0 )) 
     305            until [ $i -ge $PeriodLengthInYears ] ; do 
     306                (( Length = Length + $( IGCM_date_DaysInYear $(( year + i + 1 )) ) ))  
     307                (( i=i+1 )) 
     308            done 
     309            ;; 
     310        *M|*m)  
     311            PeriodLengthInMonths=$( echo ${config_UserChoices_PeriodLength} | awk -F '[mM]' '{print $1}' ) 
     312            IGCM_date_GetYearMonth ${1} year month 
     313            (( year0=year )) 
     314            if [ $(( month + 1 )) -lt 13 ] ; then 
     315                month0=$(( month + 1 )) 
    307316            else 
    308                 Length=$( IGCM_date_DaysInMonth $(( year + 1 )) 1 ) 
    309             fi ;; 
     317                month0=$(( month + 1 - 12 )) 
     318                (( year = year0 + 1 )) 
     319            fi 
     320            (( Length=0 )) 
     321            (( i=0 )) 
     322            until [ $i -ge $PeriodLengthInMonths ] ; do 
     323                if [ $(( month0 + i )) -lt 13 ] ; then 
     324                    (( Length = Length + $( IGCM_date_DaysInMonth $year $(( month0 + i )) ) )) 
     325                else 
     326                    (( year = year0 + 1 )) 
     327                    (( Length = Length + $( IGCM_date_DaysInMonth $year $(( month0 + i - 12 )) ) )) 
     328                fi 
     329                (( i=i+1 )) 
     330            done 
     331            ;; 
    310332        *D|*d) 
    311             Length=$( echo ${1} | sed -e "s/[dD]//" ) ;; 
     333            Length=$( echo ${config_UserChoices_PeriodLength} | sed -e "s/[dD]//" ) ;; 
    312334        *) 
    313             IGCM_debug_Exit "create_ts " ${1} " invalid PeriodLength : choose in 1Y, 1M, 5D, 1D." 
     335            IGCM_debug_Exit "create_ts " ${config_UserChoices_PeriodLength} " invalid PeriodLength : choose in 1Y, *M, *D." 
    314336            IGCM_debug_Verif_Exit_Post ;; 
    315337    esac 
     
    323345    IGCM_debug_PushStack "create_ts_begin_date" $@ 
    324346    typeset year month Length 
    325     case ${1} in 
    326         1Y|1y) 
    327             IGCM_date_GetYearMonth ${2} year month 
    328             Length=$( IGCM_date_DaysInYear $year ) ;; 
    329         1M|1m) 
    330             IGCM_date_GetYearMonth ${2} year month 
    331             Length=$( IGCM_date_DaysInMonth $year $month ) ;; 
     347    case ${config_UserChoices_PeriodLength} in 
     348        *Y|*y)  
     349            PeriodLengthInYears=$( echo ${config_UserChoices_PeriodLength} | awk -F '[yY]' '{print $1}' ) 
     350            IGCM_date_GetYearMonth ${1} year month 
     351            if [ X${2} = Xend ] ; then 
     352                (( year = year - PeriodLengthInYears + 1)) 
     353            fi 
     354            (( Length=0 )) 
     355            (( i=0 )) 
     356            until [ $i -ge $PeriodLengthInYears ] ; do 
     357                (( Length = Length + $( IGCM_date_DaysInYear $(( year + i )) ) ))  
     358                (( i=i+1 )) 
     359            done 
     360            ;; 
     361        *M|*m)  
     362            PeriodLengthInMonths=$( echo ${config_UserChoices_PeriodLength} | awk -F '[mM]' '{print $1}' ) 
     363            IGCM_date_GetYearMonth ${1} year month 
     364            if [ X${2} = Xend ] ; then 
     365                (( month = $month - $PeriodLengthInMonths + 1 )) 
     366            fi       
     367            (( year0=$year )) 
     368            if [ $month -le 0 ] ; then 
     369                (( month = $month + 12 )) 
     370                year=$( printf "%04i\n" $(( year - 1 )) ) 
     371            fi 
     372            month=$( printf "%02i\n" ${month} ) 
     373            (( Length=0 )) 
     374            (( i=0 )) 
     375            until [ $i -ge $PeriodLengthInMonths ] ; do 
     376                if [ $(( month + i )) -lt 13 ] ; then 
     377                    (( Length = Length + $( IGCM_date_DaysInMonth $year $(( month + i )) ) )) 
     378                else 
     379                    (( year = year0 + 1 )) 
     380                    (( Length = Length + $( IGCM_date_DaysInMonth $year $(( month + i - 12 )) ) )) 
     381                fi 
     382                (( i=i+1 )) 
     383            done 
     384            ;; 
    332385        *D|*d) 
    333             Length=$( echo ${1} | sed -e "s/[dD]//" ) ;; 
     386            Length=$( echo ${config_UserChoices_PeriodLength} | sed -e "s/[dD]//" ) ;; 
    334387        *) 
    335             IGCM_debug_Exit "create_ts " ${1} " invalid PeriodLength : choose in 1Y, 1M, 5D, 1D." 
     388            IGCM_debug_Exit "create_ts " ${config_UserChoices_PeriodLength} " invalid PeriodLength : choose in 1Y, *M, *D." 
    336389            IGCM_debug_Verif_Exit_Post ;; 
    337390    esac 
     
    375428    # First Time Series Submission 
    376429    FIRST_PASS=TRUE 
    377     Length=$( create_ts_begin_date ${config_UserChoices_PeriodLength} ${DateBegin} ) 
     430    Length=$( create_ts_begin_date ${DateBegin} begin) 
    378431    DATE_FIN_JOB_B=$( IGCM_date_AddDaysToGregorianDate ${DateBegin} $(( Length - 1 )) ) 
    379432else 
     
    402455            FlagDir=$( echo ${file} | awk -F "_" '{print $1}' ) 
    403456            case ${FlagDir} in 
    404                 1Y)    TS_Dir=TS_YE  ;; 
    405                 1M)    TS_Dir=TS_MO  ;; 
    406                 5D|1D) TS_Dir=TS_DA  ;; 
    407                 HF)    TS_Dir=TS_HF  ;; 
    408                 INS)   TS_Dir=TS_INS ;; 
     457                *Y)  TS_Dir=TS_YE  ;; 
     458                *M)  TS_Dir=TS_MO  ;; 
     459                *D) TS_Dir=TS_DA  ;; 
     460                HF)  TS_Dir=TS_HF  ;; 
     461                INS) TS_Dir=TS_INS ;; 
    409462            esac 
    410463            for var in $( eval echo \${LISTE_VARS_${file}[*]} ) ; do 
     
    438491    while [ ${DATE_COUNT} -lt ${PeriodDateEnd} ] ; do 
    439492        (( NBRE_FILE_TOT = NBRE_FILE_TOT + 1 )) 
    440         Length=$( create_ts_next_date ${config_UserChoices_PeriodLength} ${DATE_COUNT} ) 
     493        Length=$( create_ts_next_date ${DATE_COUNT} ) 
    441494        DATE_COUNT=$( IGCM_date_AddDaysToGregorianDate ${DATE_COUNT} ${Length} ) 
    442495    done 
     
    469522            DATE_COURANTE=${DATE_FIN_JOB_B_LOOP} 
    470523        else 
    471             Length=$( create_ts_next_date ${config_UserChoices_PeriodLength} ${DATE_FIN_JOB_B_LOOP} ) 
     524            Length=$( create_ts_next_date ${DATE_FIN_JOB_B_LOOP} ) 
    472525            DATE_COURANTE=$( IGCM_date_AddDaysToGregorianDate ${DATE_FIN_JOB_B_LOOP} ${Length} ) 
    473526        fi 
     
    486539 
    487540        if [ ! ${FIRST_PASS} = TRUE ] && [ ${CURRENT_LOOP} -eq 1 ] ; then 
    488             Length=$( create_ts_next_date ${config_UserChoices_PeriodLength} ${DATE_FIN_JOB_B_LOOP} ) 
     541            Length=$( create_ts_next_date ${DATE_FIN_JOB_B_LOOP} ) 
    489542            DATE_COURANTE=$( IGCM_date_AddDaysToGregorianDate ${DATE_FIN_JOB_B_LOOP} ${Length} ) 
    490543        elif [ -z "${DATE_COURANTE}" ] ; then 
    491544            DATE_COURANTE=${DATE_FIN_JOB_B} 
    492545        else 
    493             Length=$( create_ts_next_date ${config_UserChoices_PeriodLength} ${DATE_FIN} ) 
     546            Length=$( create_ts_next_date ${DATE_FIN} ) 
    494547            DATE_COURANTE=$( IGCM_date_AddDaysToGregorianDate ${DATE_FIN} ${Length} ) 
    495548        fi 
     
    501554        while [ ${COMPTEUR} -lt ${NBRE_FILE_LOOP} ] ; do 
    502555            # 
    503             Length=$( create_ts_next_date ${config_UserChoices_PeriodLength} ${DATE_LOOP} ) 
     556            Length=$( create_ts_next_date ${DATE_LOOP} ) 
    504557            DATE_LOOP=$( IGCM_date_AddDaysToGregorianDate ${DATE_LOOP} ${Length} ) 
    505558            (( TotLength = TotLength + Length )) 
     
    518571        [ ${NBRE_FILE_LOOP} -eq 0 ] && NBRE_FILE_LOOP=${UNIX_MAX_LIMIT} 
    519572 
    520         Length=$( create_ts_next_date ${config_UserChoices_PeriodLength} ${DATE_FIN} ) 
     573        Length=$( create_ts_next_date ${DATE_FIN} ) 
    521574        DATE_COURANTE=$(IGCM_date_AddDaysToGregorianDate ${DATE_FIN} ${Length} ) 
    522575        DATE_FIN=${PeriodDateEnd} 
     
    546599            FlagDir=$( echo ${file} | awk -F "_" '{print $1}' ) 
    547600            case ${FlagDir} in 
    548                 1Y)    TS_Dir=TS_YE  ; FreqDir=AN  ;; 
    549                 1M)    TS_Dir=TS_MO  ; FreqDir=MO  ;; 
     601                *Y)    TS_Dir=TS_YE  ; FreqDir=YE  ;; 
     602                *M)    TS_Dir=TS_MO  ; FreqDir=MO  ;; 
    550603                *D)    TS_Dir=TS_DA  ; FreqDir=DA  ;; 
    551604                HF)    TS_Dir=TS_HF  ; FreqDir=HF  ;; 
     
    567620            while [ ${COMPTEUR} -le ${NBRE_FILE_LOOP} ] ; do 
    568621                # 
    569                 Length1=$( create_ts_begin_date ${config_UserChoices_PeriodLength} ${DATE_LOOP} ) 
     622                Length1=$( create_ts_begin_date ${DATE_LOOP} end) 
    570623                DATE_TAB=$(  IGCM_date_AddDaysToGregorianDate ${DATE_LOOP} $(( 1 - Length1 )) )_${DATE_LOOP} 
    571624 
    572                 Length2=$( create_ts_next_date ${config_UserChoices_PeriodLength} ${DATE_LOOP} ) 
     625                Length2=$( create_ts_next_date ${DATE_LOOP} end) 
    573626                DATE_LOOP=$( IGCM_date_AddDaysToGregorianDate ${DATE_LOOP} ${Length2} ) 
    574627 
     
    596649            # WE CAN CONCATENATE FILES AT THIS POINT 
    597650            [ "${FLAG_B}" = "TRUE" ] && DATE_BUILD_B=${DateBegin}_${DATE_FIN_JOB_B_LOOP_PREC} 
    598             Length=$( create_ts_begin_date ${config_UserChoices_PeriodLength} ${DATE_COURANTE} ) 
     651            Length=$( create_ts_begin_date ${DATE_COURANTE} end) 
    599652            DATE_BUILD1=$( IGCM_date_AddDaysToGregorianDate ${DATE_COURANTE} -$(( Length - 1 )) ) 
    600653            DATE_BUILD=${DATE_BUILD1}_${DATE_FIN} 
Note: See TracChangeset for help on using the changeset viewer.