function ESMF_CheckTime(testType, YYl, MM, DD, Dl, cal, rc)
! !RETURN VALUE:
logical :: ESMF_CheckTime
! !ARGUMENTS:
integer, intent(in) :: testType
integer(ESMF_KIND_I8), intent(in) :: YYl
integer, intent(in) :: MM
integer, intent(in) :: DD
integer(ESMF_KIND_I8), intent(in) :: Dl
type(ESMF_Calendar), intent(inout) :: cal
integer, intent(out), optional :: rc
!character(ESMF_MAXSTR) :: calName
! !DESCRIPTION:
! Checks given values against those set/get with ESMF
!
!EOPI
! ESMF returned variables
integer(ESMF_KIND_I8) :: rYYl, rDl
integer :: rMM, rDD
logical :: broken
type(ESMF_Time) :: time
broken = .false.
if(testType.eq.CONVERT_TO_TIME .or. testType.eq.CONVERT_TO_BOTH) then
!
! Input calendar conversion test
!
! set date via given ESMF calendar
call ESMF_TimeSet(time, yy_i8=YYl, mm=MM, dd=DD, calendar=cal, rc=rc)
if (rc .ne. ESMF_SUCCESS) then
ESMF_CheckTime = .true.
return
endif
! see what we get back
call ESMF_TimeGet(time, yy_i8=rYYl, mm=rMM, dd=rDD, d_i8=rDl)
! must match
if (.not.(rYYl.eq.YYl .and. rMM.eq.MM .and. rDD.eq.DD .and. &
rDl.eq.Dl)) then
broken = .true.
!call ESMF_CalendarGet(cal, name=calName)
!print *, trim(calName), " Set/Get breaks,"
!print *, " should be = ", YYl, "/", MM, "/", DD, " ", Dl
!print *, " returned = ", rYYl, "/", rMM, "/", rDD, " ", rDl
!print *
end if
!
! Input calendar Set/Julian Day Get test
!
! see what we get back via Julian Day calendar
call ESMF_TimeSet(time, calendar=julianDayCalendar)
call ESMF_TimeGet(time, d_i8=rDl)
if (.not.(rDl.eq.Dl)) then
broken = .true.
!call ESMF_CalendarGet(cal, name=calName)
!print *, trim(calName), " Set/Julian Day Get breaks,"
!print *, " should be = ", Dl
!print *, " returned = ", rDl
!print *
end if
end if
if(testType.eq.CONVERT_TO_DATE .or. testType.eq.CONVERT_TO_BOTH) then
!
! Julian Day test
!
! set date via ESMF Julian Day calendar
call ESMF_TimeSet(time, d_i8=Dl, calendar=julianDayCalendar)
! see what we get back
call ESMF_TimeGet(time, d_i8=rDl)
if (.not.(rDl.eq.Dl)) then
broken = .true.
!print *, "Julian Day Set/Get breaks,"
!print *, " should be = ", Dl
!print *, " returned = ", rDl
!print *
end if
!
! Julian Day Set/Input calendar Get test
!
! see what we get back via input calendar
call ESMF_TimeSet(time, calendar=cal)
call ESMF_TimeGet(time, yy_i8=rYYl, mm=rMM, dd=rDD, d_i8=rDl, rc=rc)
if (rc /= ESMF_SUCCESS) then
broken = .true.
else
if (.not.(rYYl.eq.YYl .and. rMM.eq.MM .and. rDD.eq.DD .and. &
rDl.eq.Dl)) then
broken = .true.
!print *, "Julian Day Set/"
!call ESMF_CalendarGet(cal, name=calName)
!print *, trim(calName), " Get breaks,"
!print *, " should be = ", YYl, "/", MM, "/", DD, " ", Dl
!print *, " returned = ", rYYl, "/", rMM, "/", rDD, " ", rDl
!print *
end if
end if
end if
! function return value
ESMF_CheckTime = broken
end function ESMF_CheckTime