ESMF_AttributeGetInfoByNumField Subroutine

private subroutine ESMF_AttributeGetInfoByNumField(target, attributeIndex, name, convention, purpose, attnestflag, typekind, itemCount, isPresent, rc)

Arguments

Type IntentOptional Attributes Name
type(ESMF_Field), intent(in) :: target
integer, intent(in) :: attributeIndex
character(len=*), intent(out) :: name
character(len=*), intent(in), optional :: convention
character(len=*), intent(in), optional :: purpose
type(ESMF_AttNest_Flag), intent(in), optional :: attnestflag
type(ESMF_TypeKind_Flag), intent(out), optional :: typekind
integer, intent(out), optional :: itemCount
logical, intent(out), optional :: isPresent
integer, intent(out), optional :: rc

Source Code

subroutine ESMF_AttributeGetInfoByNumField(target, attributeIndex, name, convention, purpose, attnestflag, typekind, itemCount, isPresent, rc)
  type(ESMF_Field), intent(in) :: target
  integer, intent(in) :: attributeIndex
  character(len=*), intent(out) :: name
  character(len=*), intent(in), optional :: convention
  character(len=*), intent(in), optional :: purpose
  type(ESMF_AttNest_Flag), intent(in), optional :: attnestflag
  type(ESMF_TypeKind_Flag), intent(out), optional :: typekind
  integer, intent(out), optional :: itemCount
  logical, intent(out), optional :: isPresent
  integer, intent(out), optional :: rc

  integer :: localrc
  character(:), allocatable :: key
  type(ESMF_Info) :: info
  type(ESMF_InfoDescribe) :: eidesc
  type(ESMF_AttNest_Flag) :: local_attnestflag
  logical :: is_structured, is_null

  localrc = ESMF_FAILURE
  if (present(rc)) rc = ESMF_RC_NOT_IMPL
  ! Check object initialization
  ESMF_INIT_CHECK_DEEP(ESMF_FieldGetInit, target, rc)

  if (present(attnestflag)) then
    local_attnestflag = attnestflag
  else
    local_attnestflag = ESMF_ATTR_DEFAULT_ATTNEST
  end if

  call ESMF_InfoFormatKey(key, "", localrc, convention=convention, purpose=purpose)
  if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, ESMF_CONTEXT, rcToReturn=rc)) return

  info = eidesc%GetInfo(target, rc=localrc)
  if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, ESMF_CONTEXT, rcToReturn=rc)) return

  call ESMF_InfoGet(info, key=key, size=itemCount, typekind=typekind, &
    idx=attributeIndex, ikey=name, isPresent=isPresent, isNull=is_null, attnestflag=local_attnestflag, &
    isStructured=is_structured, attrCompliance=.true., rc=localrc)
  if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, ESMF_CONTEXT, rcToReturn=rc)) return
  if (.not. is_structured) then
    if (present(itemCount)) then
      if (is_null) then
        itemCount = 0
      else
        itemCount = 1
      endif
    end if
  end if

  if (present(rc)) rc = ESMF_SUCCESS
end subroutine ESMF_AttributeGetInfoByNumField