subroutine MAPL_CFIOGetTimeString(mcfio,Clock,Date,rc)
type(MAPL_CFIO ), intent(inout) :: MCFIO
type(ESMF_Clock), intent(in ) :: Clock
character(len=ESMF_MAXSTR), intent(inout) :: Date
integer, optional, intent(out ) :: rc
integer :: status
type(ESMF_Time) :: time
integer :: YY,MM,DD,H,M,S
integer :: noffset
logical :: LPERP
type(ESMF_Alarm) :: PERPETUAL
character(len=ESMF_MAXSTR) :: ClockName
call ESMF_ClockGet (CLOCK, name=ClockName, CurrTime =TIME, RC=STATUS)
_VERIFY(STATUS)
call ESMF_TimeIntervalGet( MCFIO%OFFSET, S=noffset, rc=status )
_VERIFY(STATUS)
if( noffset /= 0 ) then
LPERP = ( index( trim(clockname),'_PERPETUAL' ).ne.0 )
if( LPERP ) then
call ESMF_ClockGetAlarm ( clock, alarmName='PERPETUAL', alarm=PERPETUAL, rc=status )
_VERIFY(STATUS)
if( ESMF_AlarmIsRinging(PERPETUAL) ) then
call ESMF_TimeGet ( Time, YY = YY, &
MM = MM, &
DD = DD, &
H = H , &
M = M , &
S = S, rc=status )
MM = MM + 1
call ESMF_TimeSet ( Time, YY = YY, &
MM = MM, &
DD = DD, &
H = H , &
M = M , &
S = S, rc=status )
endif
endif
endif
TIME = TIME - MCFIO%OFFSET
call ESMF_TimeGet (TIME, timeString=DATE, RC=STATUS)
_VERIFY(STATUS)
_RETURN(ESMF_SUCCESS)
end subroutine MAPL_CFIOGetTimeString