ESMF_LocStreamGetKeyInfo Subroutine

private subroutine ESMF_LocStreamGetKeyInfo(locstream, keyName, keywordEnforcer, keyUnits, keyLongName, typekind, isPresent, rc)

Arguments

Type IntentOptional Attributes Name
type(ESMF_LocStream), intent(in) :: locstream
character(len=*), intent(in) :: keyName
type(ESMF_KeywordEnforcer), optional :: keywordEnforcer
character(len=*), intent(out), optional :: keyUnits
character(len=*), intent(out), optional :: keyLongName
type(ESMF_TypeKind_Flag), intent(out), optional :: typekind
logical, intent(out), optional :: isPresent
integer, intent(out), optional :: rc

Source Code

  subroutine ESMF_LocStreamGetKeyInfo(locstream, keyName, keywordEnforcer, &
       keyUnits, keyLongName, typekind, isPresent, rc)
!
! !ARGUMENTS:
    type(ESMF_Locstream),     intent(in)            :: locstream
    character (len=*),        intent(in)            :: keyName
type(ESMF_KeywordEnforcer), optional:: keywordEnforcer ! must use keywords below
    character (len=*),        intent(out), optional :: keyUnits 
    character (len=*),        intent(out), optional :: keyLongName 
    type(ESMF_TypeKind_Flag), intent(out), optional :: typekind
    logical,                  intent(out), optional :: isPresent
    integer,                  intent(out), optional :: rc
!
! !DESCRIPTION:
! Get ESMF Array associated with key.
!
! The arguments are:
! \begin{description}
! \item [locstream]
! The {\tt ESMF\_LocStream} object to get key from.
! \item [keyName]
! The name of the key to get. 
! \item [{[keyUnits]}]
! The units of the key data. 
! If not specified, then the item remains blank.  
! \item [{[keyLongName]}]
! The long name of the key data. 
! If not specified, then the item remains blank.  
! \item [{[typekind]}]
! The typekind of the key data
! \item [{[isPresent]}]
! Whether or not the keyname is present 
! \item [{[rc]}]
! Return code; equals {\tt ESMF\_SUCCESS} if there are no errors.
! \end{description}
!EOP
!------------------------------------------------------------------------------
    type(ESMF_LocStreamType), pointer :: lstypep
    integer :: i,keyIndex
    integer :: localrc

    ! Initialize
    localrc = ESMF_RC_NOT_IMPL
    if (present(rc)) rc = ESMF_RC_NOT_IMPL

    ! check variables
    ESMF_INIT_CHECK_DEEP(ESMF_LocStreamGetInit,locstream,rc)

    ! get the pointer to the locstream
    lstypep => locstream%lstypep

    ! find the index of the key
    keyIndex=0
    do i=1,lstypep%keyCount
       if (trim(keyName) .eq. trim(lstypep%keyNames(i))) then
          keyIndex=i
          exit 
       endif
    enddo


   if (keyIndex==0) then
     if (present(isPresent) .and. &
         .not. present(keyUnits) .and. &
         .not. present(keyLongName) .and. &
         .not. present(typekind)) then
       isPresent = .false.
     else
       if (ESMF_LogFoundError(ESMF_RC_ARG_WRONG, &
                              msg=" - LocStream info not found for this keyName", &
                              ESMF_CONTEXT, rcToReturn=rc)) return
     endif     
   else

     ! Get Info
     if (present(isPresent)) then
       isPresent=.true.
     endif

     if (present(keyUnits)) then
       keyUnits=lstypep%keyUnits(keyIndex)
     endif

     if (present(keyLongName)) then
       keyLongName=lstypep%keyLongNames(keyIndex)
     endif

     if (present(typekind)) then
       call ESMF_ArrayGet(lstypep%keys(keyIndex), typekind=typekind, rc=localrc)
       if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, & 
           ESMF_CONTEXT, rcToReturn=rc)) return
     endif

   endif

   ! return success
   if (present(rc)) rc = ESMF_SUCCESS

  end subroutine ESMF_LocStreamGetKeyInfo