Ignore:
Timestamp:
02/20/12 17:39:05 (12 years ago)
Author:
sdipsl
Message:
  • Mechanism in place to submit pack jobs.
  • Add a PackFrequency? ; default to RebuildFrequency? if not present in config.card
  • Add coherence checks between PackFrequency? and relevant dependant frequencies
  • pack_restart and pack_debug ready in batch mode. Testing in progress. Submission is still a comment in libIGCM_post
  • Move and generalize create_ts_next_date from AA_create_ts to libIGCM_date. Rename to IGCM_date_DaysInNextPeriod
  • Move and generalyze create_ts_begin_date from AA_create_ts to libIGCM_date. Rename to IGCM_date_DaysInPreviousPeriod
  • Cosmetics
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libIGCM/AA_create_ts

    r546 r554  
    136136StandAlone=${StandAlone:=true} 
    137137 
    138 #D- Low level debug : to bypass lib test checks and stack construction 
     138#D- Path to libIGCM 
    139139#D- Default : value from AA_job if any 
     140# WARNING For StandAlone use : To run this script on some machine (ulam and cesium) 
     141# WARNING you must check MirrorlibIGCM variable in sys library. 
     142# WARNING If this variable is true, you must use libIGCM_POST path instead 
     143# WARNING of your running libIGCM directory. 
    140144libIGCM=${libIGCM:=::modipsl::/libIGCM} 
    141 # WARNING for StandAlone used : To run this script on some machine, 
    142 # you must check MirrorlibIGCM variable in sys library. 
    143 # If this variable is true, you must use libIGCM_POST path instead 
    144 # of your running libIGCM directory. 
    145145 
    146146#D- Flag to determine allready produced time series. Empty if you start from the beginning 
     
    462462######################################################################## 
    463463# 
    464 #                          DEFINE DATE FUNCTIONS 
    465 # 
    466 ######################################################################## 
    467  
    468 # Give the end of the next $1 period from $2 date 
    469 function create_ts_next_date { 
    470     IGCM_debug_PushStack "create_ts_next_date" $@ 
    471     typeset Length 
    472     case ${config_UserChoices_PeriodLength} in 
    473         *Y|*y)  
    474             PeriodLengthInYears=$( echo ${config_UserChoices_PeriodLength} | awk -F '[yY]' '{print $1}' ) 
    475             IGCM_date_GetYearMonth ${1} year month 
    476             year=$( IGCM_date_SupressZeros ${year} ) 
    477             (( Length=0 )) 
    478             (( i=0 )) 
    479             until [ $i -ge $PeriodLengthInYears ] ; do 
    480                 (( Length = Length + $( IGCM_date_DaysInYear $(( year + i + 1 )) ) ))  
    481                 (( i=i+1 )) 
    482             done 
    483             ;; 
    484         *M|*m)  
    485             PeriodLengthInMonths=$( echo ${config_UserChoices_PeriodLength} | awk -F '[mM]' '{print $1}' ) 
    486             IGCM_date_GetYearMonth ${1} year month 
    487             year=$( IGCM_date_SupressZeros ${year} ) 
    488             (( year0 = year )) 
    489             if [ $(( month + 1 )) -lt 13 ] ; then 
    490                 month0=$(( month + 1 )) 
    491             else 
    492                 month0=$(( month + 1 - 12 )) 
    493                 (( year = year0 + 1 )) 
    494             fi 
    495             (( Length=0 )) 
    496             (( i=0 )) 
    497             until [ $i -ge $PeriodLengthInMonths ] ; do 
    498                 if [ $(( month0 + i )) -lt 13 ] ; then 
    499                     (( Length = Length + $( IGCM_date_DaysInMonth $year $(( month0 + i )) ) )) 
    500                 else 
    501                     (( year = year0 + 1 )) 
    502                     (( Length = Length + $( IGCM_date_DaysInMonth $year $(( month0 + i - 12 )) ) )) 
    503                 fi 
    504                 (( i=i+1 )) 
    505             done 
    506             ;; 
    507         *D|*d) 
    508             Length=$( echo ${config_UserChoices_PeriodLength} | sed -e "s/[dD]//" ) ;; 
    509         *) 
    510             IGCM_debug_Exit "create_ts " ${config_UserChoices_PeriodLength} " invalid PeriodLength : choose in *Y, *M, *D." 
    511             IGCM_debug_Verif_Exit_Post ;; 
    512     esac 
    513     echo ${Length} 
    514  
    515     IGCM_debug_PopStack "create_ts_next_date" 
    516 } 
    517  
    518 # Give the end of the actual $1 period from $2 date 
    519 function create_ts_begin_date { 
    520     IGCM_debug_PushStack "create_ts_begin_date" $@ 
    521     typeset Length 
    522     case ${config_UserChoices_PeriodLength} in 
    523         *Y|*y)  
    524             PeriodLengthInYears=$( echo ${config_UserChoices_PeriodLength} | awk -F '[yY]' '{print $1}' ) 
    525             IGCM_date_GetYearMonth ${1} year month 
    526             year=$( IGCM_date_SupressZeros ${year} ) 
    527             if [ X${2} = Xend ] ; then 
    528                 (( year = year - PeriodLengthInYears + 1)) 
    529             fi 
    530             (( Length=0 )) 
    531             (( i=0 )) 
    532             until [ $i -ge $PeriodLengthInYears ] ; do 
    533                 (( Length = Length + $( IGCM_date_DaysInYear $(( year + i )) ) ))  
    534                 (( i=i+1 )) 
    535             done 
    536             ;; 
    537         *M|*m)  
    538             PeriodLengthInMonths=$( echo ${config_UserChoices_PeriodLength} | awk -F '[mM]' '{print $1}' ) 
    539             IGCM_date_GetYearMonth ${1} year month 
    540             year=$( IGCM_date_SupressZeros ${year} ) 
    541             if [ X${2} = Xend ] ; then 
    542                 (( month = month - PeriodLengthInMonths + 1 )) 
    543             fi       
    544             (( year0 = year )) 
    545             if [ $month -le 0 ] ; then 
    546                 (( month = month + 12 )) 
    547                 year=$( printf "%04i\n" $(( year - 1 )) ) 
    548             fi 
    549             month=$( printf "%02i\n" ${month} ) 
    550             (( Length=0 )) 
    551             (( i=0 )) 
    552             until [ $i -ge $PeriodLengthInMonths ] ; do 
    553                 if [ $(( month + i )) -lt 13 ] ; then 
    554                     (( Length = Length + $( IGCM_date_DaysInMonth $year $(( month + i )) ) )) 
    555                 else 
    556                     (( year = year0 + 1 )) 
    557                     (( Length = Length + $( IGCM_date_DaysInMonth $year $(( month + i - 12 )) ) )) 
    558                 fi 
    559                 (( i=i+1 )) 
    560             done 
    561             ;; 
    562         *D|*d) 
    563             Length=$( echo ${config_UserChoices_PeriodLength} | sed -e "s/[dD]//" ) ;; 
    564         *) 
    565             IGCM_debug_Exit "create_ts " ${config_UserChoices_PeriodLength} " invalid PeriodLength : choose in *Y, *M, *D." 
    566             IGCM_debug_Verif_Exit_Post ;; 
    567     esac 
    568     echo ${Length} 
    569  
    570     IGCM_debug_PopStack "create_ts_begin_date" 
    571 } 
    572  
    573 ######################################################################## 
    574 # 
    575464#               IS THERE SOME ALLREADY PRODUCED TIME SERIES ? 
    576465#                 IF SO BRING THEM IN THE WORKING DIRECTORY 
     
    615504    # First Time Series Submission 
    616505    FIRST_PASS=TRUE 
    617     Length=$( create_ts_begin_date ${DateBegin} begin) 
     506    Length=$( IGCM_date_DaysInPreviousPeriod ${DateBegin} ${config_UserChoices_PeriodLength} begin) 
    618507    DATE_FIN_JOB_B=$( IGCM_date_AddDaysToGregorianDate ${DateBegin} $(( Length - 1 )) ) 
    619508else 
     
    685574    while [ ${DATE_COUNT} -lt ${PeriodDateEnd} ] ; do 
    686575        (( NBRE_FILE_TOT = NBRE_FILE_TOT + 1 )) 
    687         Length=$( create_ts_next_date ${DATE_COUNT} ) 
     576        Length=$( IGCM_date_DaysInNextPeriod ${DATE_COUNT} ${config_UserChoices_PeriodLength} ) 
    688577        DATE_COUNT=$( IGCM_date_AddDaysToGregorianDate ${DATE_COUNT} ${Length} ) 
    689578    done 
     
    716605            DATE_COURANTE=${DATE_FIN_JOB_B_LOOP} 
    717606        else 
    718             Length=$( create_ts_next_date ${DATE_FIN_JOB_B_LOOP} ) 
     607            Length=$( IGCM_date_DaysInNextPeriod ${DATE_FIN_JOB_B_LOOP} ${config_UserChoices_PeriodLength} ) 
    719608            DATE_COURANTE=$( IGCM_date_AddDaysToGregorianDate ${DATE_FIN_JOB_B_LOOP} ${Length} ) 
    720609        fi 
     
    733622 
    734623        if [ ! ${FIRST_PASS} = TRUE ] && [ ${CURRENT_LOOP} -eq 1 ] ; then 
    735             Length=$( create_ts_next_date ${DATE_FIN_JOB_B_LOOP} ) 
     624            Length=$( IGCM_date_DaysInNextPeriod ${DATE_FIN_JOB_B_LOOP} ${config_UserChoices_PeriodLength} ) 
    736625            DATE_COURANTE=$( IGCM_date_AddDaysToGregorianDate ${DATE_FIN_JOB_B_LOOP} ${Length} ) 
    737626        elif [ -z "${DATE_COURANTE}" ] ; then 
    738627            DATE_COURANTE=${DATE_FIN_JOB_B} 
    739628        else 
    740             Length=$( create_ts_next_date ${DATE_FIN} ) 
     629            Length=$( IGCM_date_DaysInNextPeriod ${DATE_FIN} ${config_UserChoices_PeriodLength} ) 
    741630            DATE_COURANTE=$( IGCM_date_AddDaysToGregorianDate ${DATE_FIN} ${Length} ) 
    742631        fi 
     
    748637        while [ ${COMPTEUR} -lt ${NBRE_FILE_LOOP} ] ; do 
    749638            # 
    750             Length=$( create_ts_next_date ${DATE_LOOP} ) 
     639            Length=$( IGCM_date_DaysInNextPeriod ${DATE_LOOP} ${config_UserChoices_PeriodLength} ) 
    751640            DATE_LOOP=$( IGCM_date_AddDaysToGregorianDate ${DATE_LOOP} ${Length} ) 
    752641            (( TotLength = TotLength + Length )) 
     
    765654        [ ${NBRE_FILE_LOOP} -eq 0 ] && NBRE_FILE_LOOP=${UNIX_MAX_LIMIT} 
    766655 
    767         Length=$( create_ts_next_date ${DATE_FIN} ) 
     656        Length=$( IGCM_date_DaysInNextPeriod ${DATE_FIN} ${config_UserChoices_PeriodLength} ) 
    768657        DATE_COURANTE=$(IGCM_date_AddDaysToGregorianDate ${DATE_FIN} ${Length} ) 
    769658        DATE_FIN=${PeriodDateEnd} 
     
    816705            while [ ${COMPTEUR} -le ${NBRE_FILE_LOOP} ] ; do 
    817706                # 
    818                 Length1=$( create_ts_begin_date ${DATE_LOOP} end) 
     707                Length1=$( IGCM_date_DaysInPreviousPeriod ${DATE_LOOP} ${config_UserChoices_PeriodLength} end) 
    819708                DATE_TAB=$(  IGCM_date_AddDaysToGregorianDate ${DATE_LOOP} $(( 1 - Length1 )) )_${DATE_LOOP} 
    820709 
    821                 Length2=$( create_ts_next_date ${DATE_LOOP} end) 
     710                Length2=$( IGCM_date_DaysInNextPeriod ${DATE_LOOP} ${config_UserChoices_PeriodLength} ) 
    822711                DATE_LOOP=$( IGCM_date_AddDaysToGregorianDate ${DATE_LOOP} ${Length2} ) 
    823712 
     
    849738            # WE CAN CONCATENATE FILES AT THIS POINT 
    850739            [ "${FLAG_B}" = "TRUE" ] && DATE_BUILD_B=${DateBegin}_${DATE_FIN_JOB_B_LOOP_PREC} 
    851             Length=$( create_ts_begin_date ${DATE_COURANTE} end) 
     740            Length=$( IGCM_date_DaysInPreviousPeriod ${DATE_COURANTE} ${config_UserChoices_PeriodLength} end) 
    852741            DATE_BUILD1=$( IGCM_date_AddDaysToGregorianDate ${DATE_COURANTE} -$(( Length - 1 )) ) 
    853742            DATE_BUILD=${DATE_BUILD1}_${DATE_FIN} 
Note: See TracChangeset for help on using the changeset viewer.