Changeset 589


Ignore:
Timestamp:
03/20/12 15:27:33 (12 years ago)
Author:
acosce
Message:

ACo : bugfix affecting the calcul of the date for restart and debug pack

Location:
trunk/libIGCM
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/libIGCM/AA_pack_debug

    r581 r589  
    312312  IGCM_debug_PrintVariables 3 number_pack 
    313313 
    314   DaysTemp=$( IGCM_date_DaysInNextPeriod ${date_begin_pack} ${PeriodPack} ) 
     314  DaysTemp=$( IGCM_date_DaysInCurrentPeriod ${date_begin_pack} ${PeriodPack} ) 
    315315  date_end_pack=$( IGCM_date_AddDaysToGregorianDate ${date_begin_pack} $(( ${DaysTemp} - 1 )) ) 
    316316 
  • trunk/libIGCM/AA_pack_restart

    r581 r589  
    312312  IGCM_debug_PrintVariables 3 number_pack 
    313313 
    314   DaysTemp=$( IGCM_date_DaysInNextPeriod ${date_begin_pack} ${PeriodPack} ) 
     314  DaysTemp=$( IGCM_date_DaysInCurrentPeriod ${date_begin_pack} ${PeriodPack} ) 
    315315  date_end_pack=$( IGCM_date_AddDaysToGregorianDate ${date_begin_pack} $(( ${DaysTemp} - 1 )) ) 
    316316 
  • trunk/libIGCM/libIGCM_date/libIGCM_date.ksh

    r554 r589  
    944944} 
    945945 
     946#D-#================================================================== 
     947#D-function IGCM_date_DaysInCurrentPeriod () 
     948#D-* Purpose: Give the numbers of days during the Current prd1 period from grg1 date  
     949#D-* Usage: IGCM_date_DaysInCurrentPeriod grg1 prd1 
     950#D-         where grg1 gregorian date is in the form yyyymmdd 
     951#D-         where prd1 period is in the form N[Yy], N[Mm], N[Dd]. N integer 
     952#D- 
     953function IGCM_date_DaysInCurrentPeriod { 
     954  IGCM_debug_PushStack "IGCM_date_DaysInCurrentPeriod" $@ 
     955  typeset Length Period 
     956  Period=${2} 
     957  case ${Period} in 
     958  *Y|*y)  
     959    PeriodLengthInYears=$( echo ${Period} | awk -F '[yY]' '{print $1}' ) 
     960    IGCM_date_GetYearMonth ${1} year month 
     961    year=$( IGCM_date_SupressZeros ${year} ) 
     962    (( Length=0 )) 
     963    (( i=0 )) 
     964    until [ $i -ge $PeriodLengthInYears ] ; do 
     965      (( Length = Length + $( IGCM_date_DaysInYear $(( year + i )) ) ))  
     966      (( i=i+1 )) 
     967    done 
     968    ;; 
     969  *M|*m)  
     970    PeriodLengthInMonths=$( echo ${Period} | awk -F '[mM]' '{print $1}' ) 
     971    IGCM_date_GetYearMonth ${1} year month 
     972    year=$( IGCM_date_SupressZeros ${year} ) 
     973    (( year0 = year )) 
     974    (( Length=0 )) 
     975    (( i=0 )) 
     976    until [ $i -ge $PeriodLengthInMonths ] ; do 
     977      if [ $(( month + i )) -lt 13 ] ; then 
     978        (( Length = Length + $( IGCM_date_DaysInMonth $year $(( month + i )) ) )) 
     979      else 
     980        (( year = year0 + 1 )) 
     981        (( Length = Length + $( IGCM_date_DaysInMonth $year $(( month + i - 12 )) ) )) 
     982      fi 
     983      (( i=i+1 )) 
     984    done 
     985    ;; 
     986  *D|*d) 
     987    Length=$( echo ${Period} | sed -e "s/[dD]//" ) ;; 
     988  *) 
     989    IGCM_debug_Exit "IGCM_date_DaysInCurrentPeriod " ${Period} " invalid PeriodLength : choose in *Y, *M, *D." 
     990    IGCM_debug_Verif_Exit_Post ;; 
     991  esac 
     992  echo ${Length} 
     993 
     994  IGCM_debug_PopStack "IGCM_date_DaysInCurrentPeriod" 
     995} 
    946996 
    947997#D-#================================================================== 
Note: See TracChangeset for help on using the changeset viewer.