Changeset 103 for trunk/libIGCM


Ignore:
Timestamp:
04/15/09 17:06:13 (15 years ago)
Author:
mmaipsl
Message:

Enhancement for calendars.
Before we had 360d, noleap and gregorian (or leap) calendars.
There was no bug.
Now we add "all_leap" (for 366 days in year).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libIGCM/libIGCM_date/libIGCM_date.ksh

    r54 r103  
    2323#D-libIGCM_date 
    2424#D-This ksh library handles date calculs and convertions in different calendars.  
     25#D-  types of calendars are possible : 
     26#D- 
     27#D-  - gregorian (other name leap) : 
     28#D-      The normal calendar. The time origin for the 
     29#D-      julian day in this case is 24 Nov -4713. 
     30#D-  - noleap : 
     31#D-      A 365 day year without leap years. 
     32#D-  - all_leap : 
     33#D-      A 366 day year with only leap years. 
     34#D-  - 360d : 
     35#D-      Year of 360 days with month of equal length. 
    2536 
    2637# Number of digit in the year 
     
    158169 
    159170    # What is the calendar : 
    160     if [ "${config_UserChoices_CalendarType}" = "360d" ] ; then 
    161         if [ X$2 = X ] ; then 
    162             echo 360 
    163         else 
    164             eval $2=360 > /dev/null 2>&1 
    165         fi 
     171    case ${config_UserChoices_CalendarType} in 
     172        360d) 
     173            if [ X$2 = X ] ; then 
     174                echo 360 
     175            else 
     176                eval $2=360 > /dev/null 2>&1 
     177            fi 
    166178#       IGCM_debug_PopStack "IGCM_date_DaysInYear" 
    167         return 
    168     else 
    169         if [ "${config_UserChoices_CalendarType}" = "noleap" ] ; then 
     179            return;; 
     180        noleap) 
    170181            if [ X$2 = X ] ; then 
    171182                echo 365 
     
    175186 
    176187#           IGCM_debug_PopStack "IGCM_date_DaysInYear" 
    177             return 
    178         fi 
    179     fi 
     188            return;; 
     189        all_leap) 
     190            if [ X$2 = X ] ; then 
     191                echo 366 
     192            else 
     193                eval $2=366 > /dev/null 2>&1 
     194            fi 
     195 
     196#               IGCM_debug_PopStack "IGCM_date_DaysInYear" 
     197            return;; 
     198    esac 
    180199 
    181200    typeset y a 
     
    616635    elif [ "${config_UserChoices_CalendarType}" = "noleap" ] ; then 
    617636        res=$(( ( ( $yyyy1 - $yyyy2 ) * 365 ) + $res )) 
     637    elif [ "${config_UserChoices_CalendarType}" = "all_leap" ] ; then 
     638        res=$(( ( ( $yyyy1 - $yyyy2 ) * 366 ) + $res )) 
    618639    elif ( [ "${config_UserChoices_CalendarType}" = "leap" ] || [ "${config_UserChoices_CalendarType}" = "gregorian" ] ) ; then 
    619640        while [ $yyyy2 -lt $yyyy1 ] 
     
    724745            noleap) 
    725746                aux=-365;; 
    726             leap)  
     747            all_leap)  
     748                aux=-366;; 
     749            leap|gregorian) 
    727750                aux=-366;; 
    728751        esac 
     
    736759            noleap) 
    737760                aux=364635;; 
    738             leap)  
     761            all_leap)  
     762                aux=365634;; 
     763            leap|gregorian) 
    739764                aux=364877;; 
    740765        esac 
     
    748773            noleap) 
    749774                aux=693135;; 
    750             leap)  
     775            all_leap)  
     776                aux=695034;; 
     777            leap|gregorian) 
    751778                aux=693595;; 
    752779        esac 
Note: See TracChangeset for help on using the changeset viewer.