subroutine MAPL_CFIOCreatewrite ( MCFIO, nsteps, RC )
type(MAPL_CFIO), intent(INOUT) :: MCFIO
integer, optional, intent( IN) :: nsteps
integer, optional, intent( OUT) :: RC
type(ESMF_Time) :: CurrTime
type(ESMF_Alarm) :: PERPETUAL
character(len=ESMF_MAXSTR) :: StartTime
character(len=ESMF_MAXSTR) :: ClockName
logical :: LPERP
integer :: YY,MM,DD,H,M,S
integer :: noffset
integer :: STATUS
if(present(nsteps)) then
call ESMF_CFIOSet(MCFIO%CFIO, nsteps=nsteps, RC=STATUS)
_VERIFY(STATUS)
else
call ESMF_CFIOSet(MCFIO%CFIO, nsteps=1, RC=STATUS)
_VERIFY(STATUS)
endif
! Get time info from the clock. Note the optional offset
!-------------------------------------------------------
call ESMF_ClockGet(mCFIO%CLOCK, name=clockname, CurrTime=CurrTime, 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 ( mCFIO%CLOCK, alarmName='PERPETUAL', alarm=PERPETUAL, rc=status )
_VERIFY(STATUS)
if( ESMF_AlarmIsRinging(PERPETUAL) ) then
call ESMF_TimeGet ( CurrTime, YY = YY, &
MM = MM, &
DD = DD, &
H = H , &
M = M , &
S = S, rc=status )
MM = MM + 1
call ESMF_TimeSet ( CurrTime, YY = YY, &
MM = MM, &
DD = DD, &
H = H , &
M = M , &
S = S, rc=status )
endif
endif
endif
CurrTime = CurrTime - mCFIO%OFFSET
call ESMF_TimeGet (CurrTime, timeString=StartTime, RC=STATUS)
_VERIFY(STATUS)
call ESMF_CFIOSet(MCFIO%CFIO, TimeString=trim(StartTime), RC=STATUS)
_VERIFY(STATUS)
call ESMF_CFIOSet(MCFIO%CFIO, fName=trim(mCFIO%fName), RC=STATUS)
_VERIFY(STATUS)
if (MCFIO%JM == 6 * MCFIO%IM) then
if (MCFIO%newFormat) then
call ESMF_CFIOSet(MCFIO%CFIO, formatVersion=2.90, RC=STATUS)
_VERIFY(STATUS)
MCFIO%useFaceDim = .true.
end if
end if
! Create FILE from the root of the partition working on this bundle.
!------------------------------------------------------------------
AMROOT: if (mCFIO%MYPE==mCFIO%RootRank) then
call ESMF_CFIOFileCreate(MCFIO%CFIO, format=MCFIO%format, &
expid=MCFIO%EXPID, RC=STATUS)
_VERIFY(STATUS)
! print *, ' Created CFIO File: ', trim(mCFIO%fName)
end if AMROOT
_RETURN(ESMF_SUCCESS)
end subroutine MAPL_CFIOCreateWrite