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/libIGCM_date/libIGCM_date.ksh

    r544 r554  
    825825 
    826826#D-#================================================================== 
     827#D-function IGCM_date_DaysInPreviousPeriod () 
     828#D-* Purpose: Give the numbers of days during the previous prd1 period from grg1 date # OLD create_ts_begin_date 
     829#D-* Usage: IGCM_date_DaysInPreviousPeriod grg1 prd1 [end] 
     830#D-         where grg1 gregorian date is in the form yyyymmdd 
     831#D-         where prd1 period is in the form N[Yy], N[Mm], N[Dd]. N integer 
     832#D-         where [end] is an optionnal keyword to specify grg1 is the end of prd1 
     833#D- 
     834function IGCM_date_DaysInPreviousPeriod { 
     835  IGCM_debug_PushStack "IGCM_date_DaysInPreviousPeriod" $@ 
     836  typeset Length Period 
     837  Period=${2} 
     838  case ${Period} in 
     839  *Y|*y) 
     840    PeriodLengthInYears=$( echo ${Period} | awk -F '[yY]' '{print $1}' ) 
     841    IGCM_date_GetYearMonth ${1} year month 
     842    year=$( IGCM_date_SupressZeros ${year} ) 
     843    if [ X${2} = Xend ] ; then 
     844      (( year = year - PeriodLengthInYears + 1)) 
     845    fi 
     846    (( Length=0 )) 
     847    (( i=0 )) 
     848    until [ $i -ge $PeriodLengthInYears ] ; do 
     849      (( Length = Length + $( IGCM_date_DaysInYear $(( year + i )) ) ))  
     850      (( i=i+1 )) 
     851    done 
     852    ;; 
     853  *M|*m) 
     854    PeriodLengthInMonths=$( echo ${Period} | awk -F '[mM]' '{print $1}' ) 
     855    IGCM_date_GetYearMonth ${1} year month 
     856    year=$( IGCM_date_SupressZeros ${year} ) 
     857    if [ X${2} = Xend ] ; then 
     858      (( month = month - PeriodLengthInMonths + 1 )) 
     859    fi       
     860    (( year0 = year )) 
     861    if [ $month -le 0 ] ; then 
     862      (( month = month + 12 )) 
     863      year=$( printf "%04i\n" $(( year - 1 )) ) 
     864    fi 
     865    month=$( printf "%02i\n" ${month} ) 
     866    (( Length=0 )) 
     867    (( i=0 )) 
     868    until [ $i -ge $PeriodLengthInMonths ] ; do 
     869      if [ $(( month + i )) -lt 13 ] ; then 
     870        (( Length = Length + $( IGCM_date_DaysInMonth $year $(( month + i )) ) )) 
     871      else 
     872        (( year = year0 + 1 )) 
     873        (( Length = Length + $( IGCM_date_DaysInMonth $year $(( month + i - 12 )) ) )) 
     874      fi 
     875      (( i=i+1 )) 
     876    done 
     877    ;; 
     878  *D|*d) 
     879    Length=$( echo ${Period} | sed -e "s/[dD]//" ) ;; 
     880  *) 
     881    IGCM_debug_Exit "IGCM_date_DaysInPreviousPeriod " ${Period} " invalid PeriodLength : choose in *Y, *M, *D." 
     882    IGCM_debug_Verif_Exit_Post ;; 
     883  esac 
     884  echo ${Length} 
     885 
     886  IGCM_debug_PopStack "IGCM_date_DaysInPreviousPeriod" 
     887} 
     888 
     889#D-#================================================================== 
     890#D-function IGCM_date_DaysInNextPeriod () 
     891#D-* Purpose: Give the numbers of days during the next prd1 period from grg1 date # OLD create_ts_next_date 
     892#D-* Usage: IGCM_date_DaysInNextPeriod grg1 prd1 
     893#D-         where grg1 gregorian date is in the form yyyymmdd 
     894#D-         where prd1 period is in the form N[Yy], N[Mm], N[Dd]. N integer 
     895#D- 
     896function IGCM_date_DaysInNextPeriod { 
     897  IGCM_debug_PushStack "IGCM_date_DaysInNextPeriod" $@ 
     898  typeset Length Period 
     899  Period=${2} 
     900  case ${Period} in 
     901  *Y|*y)  
     902    PeriodLengthInYears=$( echo ${Period} | awk -F '[yY]' '{print $1}' ) 
     903    IGCM_date_GetYearMonth ${1} year month 
     904    year=$( IGCM_date_SupressZeros ${year} ) 
     905    (( Length=0 )) 
     906    (( i=0 )) 
     907    until [ $i -ge $PeriodLengthInYears ] ; do 
     908      (( Length = Length + $( IGCM_date_DaysInYear $(( year + i + 1 )) ) ))  
     909      (( i=i+1 )) 
     910    done 
     911    ;; 
     912  *M|*m)  
     913    PeriodLengthInMonths=$( echo ${Period} | awk -F '[mM]' '{print $1}' ) 
     914    IGCM_date_GetYearMonth ${1} year month 
     915    year=$( IGCM_date_SupressZeros ${year} ) 
     916    (( year0 = year )) 
     917    if [ $(( month + 1 )) -lt 13 ] ; then 
     918      month0=$(( month + 1 )) 
     919    else 
     920      month0=$(( month + 1 - 12 )) 
     921      (( year = year0 + 1 )) 
     922    fi 
     923    (( Length=0 )) 
     924    (( i=0 )) 
     925    until [ $i -ge $PeriodLengthInMonths ] ; do 
     926      if [ $(( month0 + i )) -lt 13 ] ; then 
     927        (( Length = Length + $( IGCM_date_DaysInMonth $year $(( month0 + i )) ) )) 
     928      else 
     929        (( year = year0 + 1 )) 
     930        (( Length = Length + $( IGCM_date_DaysInMonth $year $(( month0 + i - 12 )) ) )) 
     931      fi 
     932      (( i=i+1 )) 
     933    done 
     934    ;; 
     935  *D|*d) 
     936    Length=$( echo ${Period} | sed -e "s/[dD]//" ) ;; 
     937  *) 
     938    IGCM_debug_Exit "IGCM_date_DaysInNextPeriod " ${Period} " invalid PeriodLength : choose in *Y, *M, *D." 
     939    IGCM_debug_Verif_Exit_Post ;; 
     940  esac 
     941  echo ${Length} 
     942 
     943  IGCM_debug_PopStack "IGCM_date_DaysInNextPeriod" 
     944} 
     945 
     946 
     947#D-#================================================================== 
    827948#D-function IGCM_date_Check 
    828949#D- * Purpose: Check the present file by comparison with a reference file 
Note: See TracChangeset for help on using the changeset viewer.