ESMF_RunTestForwards Subroutine

subroutine ESMF_RunTestForwards(YYl, MM, DD, Dl, cal)

Arguments

Type IntentOptional Attributes Name
integer(kind=ESMF_KIND_I8), intent(inout) :: YYl
integer, intent(inout) :: MM
integer, intent(inout) :: DD
integer(kind=ESMF_KIND_I8), intent(inout) :: Dl
type(ESMF_Calendar), intent(inout) :: cal

Source Code

      subroutine ESMF_RunTestForwards(YYl, MM, DD, Dl, cal)

! !ARGUMENTS:
      integer(ESMF_KIND_I8), intent(inout) :: YYl
      integer, intent(inout) :: MM
      integer, intent(inout) :: DD
      integer(ESMF_KIND_I8), intent(inout) :: Dl
      type(ESMF_Calendar), intent(inout) :: cal
        
! !DESCRIPTION:
!     Goes forwards one day at a time until the calendar conversion 
!     algorithm breaks.
!
!EOPI
      integer :: daysInThisMonth
      logical :: broken 

      broken = .false.
      do while (.not.broken)
    
        ! calculate what next Julian Day number should be
        Dl = Dl + 1

        ! calculate what the next date in given calendar should be
        DD = DD + 1
        daysInThisMonth = DaysPerMonth(MM)
        ! check if leap year
        if (MM.eq.2 .and. DD.eq.29) then
          if (ESMF_IsLeapYear(YYl, cal)) then
            daysInThisMonth = 29
          end if
        end if
        if (DD.gt.daysInThisMonth) then
          DD = 1
          MM = MM + 1
          if (MM.eq.13) then
            MM = 1
            YYl = YYl + 1
          end if
        end if

        ! check calculated dates against ESMF dates
        broken = ESMF_CheckTime(CONVERT_TO_BOTH, YYl, MM, DD, Dl, cal, rc)
      end do

      end subroutine ESMF_RunTestForwards