<p><b>croesch@ucar.edu</b> 2012-03-05 16:43:52 -0700 (Mon, 05 Mar 2012)</p><p>TRUNK COMMIT<br>
<br>
Updated ESMF library to correctly handle rollover from one year to the next for the 360day and gregorian_noleap calendars<br>
<br>
M src/external/esmf_time_f90/ESMF_Calendar.F90<br>
M src/external/esmf_time_f90/Meat.F90<br>
</p><hr noshade><pre><font color="gray">Modified: trunk/mpas/src/external/esmf_time_f90/ESMF_Calendar.F90
===================================================================
--- trunk/mpas/src/external/esmf_time_f90/ESMF_Calendar.F90        2012-03-05 23:16:32 UTC (rev 1595)
+++ trunk/mpas/src/external/esmf_time_f90/ESMF_Calendar.F90        2012-03-05 23:43:52 UTC (rev 1596)
@@ -78,7 +78,6 @@
! ! F90 "enum" type to match C++ ESMC_CalendarType enum
type ESMF_CalendarType
- private
integer :: caltype
end type
@@ -162,7 +161,9 @@
! !PUBLIC MEMBER FUNCTIONS:
public ESMF_CalendarCreate
public ESMF_CalendarDestroy
+ public ESMF_GetCalendarType
+
! Required inherited and overridden ESMF_Base class methods
public ESMF_CalendarInitialized ! Only in this implementation, intended
@@ -175,6 +176,14 @@
!==============================================================================
+
+
+ type(ESMF_CalendarType) function ESMF_GetCalendarType()
+ ESMF_GetCalendarType = defaultCal % Type
+ end function ESMF_GetCalendarType
+
+
+!==============================================================================
!BOP
! !IROUTINE: ESMF_CalendarCreate - Create a new ESMF Calendar of built-in type
Modified: trunk/mpas/src/external/esmf_time_f90/Meat.F90
===================================================================
--- trunk/mpas/src/external/esmf_time_f90/Meat.F90        2012-03-05 23:16:32 UTC (rev 1595)
+++ trunk/mpas/src/external/esmf_time_f90/Meat.F90        2012-03-05 23:43:52 UTC (rev 1596)
@@ -169,26 +169,34 @@
! added from share/module_date_time in WRF.
FUNCTION nfeb ( year ) RESULT (num_days)
+ USE ESMF_CalendarMod
+
! Compute the number of days in February for the given year
IMPLICIT NONE
INTEGER :: year
INTEGER :: num_days
-! TBH: TODO: Replace this hack with run-time decision based on
-! TBH: TODO: passed-in calendar.
-#ifdef NO_LEAP_CALENDAR
- num_days = 28 ! By default, February has 28 days ...
-#else
- num_days = 28 ! By default, February has 28 days ...
- IF (MOD(year,4).eq.0) THEN
- num_days = 29 ! But every four years, it has 29 days ...
- IF (MOD(year,100).eq.0) THEN
- num_days = 28 ! Except every 100 years, when it has 28 days ...
- IF (MOD(year,400).eq.0) THEN
- num_days = 29 ! Except every 400 years, when it has 29 days.
+
+ type(ESMF_CalendarType) :: calendarType
+
+ calendarType = ESMF_GetCalendarType()
+
+ IF (calendarType % caltype == ESMF_CAL_NOLEAP % caltype) then
+ num_days = 28
+ ELSE IF (calendarType % caltype == ESMF_CAL_360DAY % caltype) then
+ num_days = 30
+ ELSE
+ num_days = 28 ! By default, February has 28 days ...
+ IF (MOD(year,4).eq.0) THEN
+ num_days = 29 ! But every four years, it has 29 days ...
+ IF (MOD(year,100).eq.0) THEN
+ num_days = 28 ! Except every 100 years, when it has 28 days ...
+ IF (MOD(year,400).eq.0) THEN
+ num_days = 29 ! Except every 400 years, when it has 29 days.
+ END IF
END IF
END IF
END IF
-#endif
+
END FUNCTION nfeb
@@ -206,6 +214,8 @@
#else
IF ( nfeb( year ) .EQ. 29 ) THEN
num_diy = 366
+ ELSE IF ( nfeb( year ) .EQ. 30 ) THEN
+ num_diy = 360
ELSE
num_diy = 365
ENDIF
</font>
</pre>