MAPL_CFIOCreatewrite Subroutine

public subroutine MAPL_CFIOCreatewrite(MCFIO, nsteps, RC)

Arguments

Type IntentOptional Attributes Name
type(MAPL_CFIO), intent(inout) :: MCFIO
integer, intent(in), optional :: nsteps
integer, intent(out), optional :: RC

Calls

proc~~mapl_cfiocreatewrite~~CallsGraph proc~mapl_cfiocreatewrite MAPL_CFIOCreatewrite ESMF_AlarmIsRinging ESMF_AlarmIsRinging proc~mapl_cfiocreatewrite->ESMF_AlarmIsRinging ESMF_ClockGet ESMF_ClockGet proc~mapl_cfiocreatewrite->ESMF_ClockGet ESMF_ClockGetAlarm ESMF_ClockGetAlarm proc~mapl_cfiocreatewrite->ESMF_ClockGetAlarm ESMF_TimeGet ESMF_TimeGet proc~mapl_cfiocreatewrite->ESMF_TimeGet ESMF_TimeIntervalGet ESMF_TimeIntervalGet proc~mapl_cfiocreatewrite->ESMF_TimeIntervalGet ESMF_TimeSet ESMF_TimeSet proc~mapl_cfiocreatewrite->ESMF_TimeSet proc~esmf_cfiofilecreate ESMF_CFIOFileCreate proc~mapl_cfiocreatewrite->proc~esmf_cfiofilecreate proc~esmf_cfioset ESMF_CFIOSet proc~mapl_cfiocreatewrite->proc~esmf_cfioset proc~mapl_return MAPL_Return proc~mapl_cfiocreatewrite->proc~mapl_return proc~mapl_verify MAPL_Verify proc~mapl_cfiocreatewrite->proc~mapl_verify proc~esmf_cfiofilecreate->proc~esmf_cfioset ESMF_UtilStringUpperCase ESMF_UtilStringUpperCase proc~esmf_cfiofilecreate->ESMF_UtilStringUpperCase proc~esmf_cfiosdffilecreate ESMF_CFIOSdfFileCreate proc~esmf_cfiofilecreate->proc~esmf_cfiosdffilecreate proc~addlist addList proc~esmf_cfioset->proc~addlist proc~err err proc~esmf_cfioset->proc~err proc~strtoint strToInt proc~esmf_cfioset->proc~strtoint at at proc~mapl_return->at insert insert proc~mapl_return->insert proc~mapl_throw_exception MAPL_throw_exception proc~mapl_return->proc~mapl_throw_exception proc~mapl_verify->proc~mapl_throw_exception

Source Code

  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