subroutine ESMF_InfoInquire(info, keywordEnforcer, size, key, attrCount, attrCountTotal, jsonType, &
isArray, isDirty, attPackCount, attPackCountTotal, attnestflag, idx, typekind, &
ikey, isPresent, isStructured, isNull, attrCompliance, rc)
type(ESMF_Info), intent(in) :: info
type(ESMF_KeywordEnforcer), optional:: keywordEnforcer ! must use keywords below
integer(C_INT), intent(out), optional :: size
character(len=*), intent(in), optional :: key
integer(C_INT), intent(out), optional :: attrCount
integer(C_INT), intent(out), optional :: attrCountTotal
character(len=*), intent(out), optional :: jsonType
logical, intent(out), optional :: isArray
logical, intent(out), optional :: isDirty
integer(C_INT), intent(out), optional :: attPackCount
integer(C_INT), intent(out), optional :: attPackCountTotal
type(ESMF_AttNest_Flag), intent(in), optional :: attnestflag
integer(C_INT), intent(in), optional :: idx
type(ESMF_TypeKind_Flag), intent(out), optional :: typekind
character(len=*), intent(out), optional :: ikey
logical, intent(out), optional :: isPresent
logical, intent(out), optional :: isStructured
logical, intent(out), optional :: isNull
logical, intent(in), optional :: attrCompliance
integer, intent(out), optional :: rc
integer :: localrc, esmc_typekind, local_size
type(ESMF_Info) :: inq, inq2
character(:), allocatable :: local_key
integer :: recursive, local_attrCompliance
integer(C_INT), target :: local_idx
type(C_PTR) :: local_idx_ptr
if (present(rc)) rc = ESMF_FAILURE
localrc = ESMF_FAILURE
recursive = 0 !false
local_attrCompliance = 0 !false
if (present(key)) then
local_key = trim(key)
else
local_key = ""
end if
if (present(attnestflag)) then
if (attnestflag%value==ESMF_ATTNEST_ON%value) recursive = 1 !true
end if
if (present(idx)) then
local_idx = idx - 1 ! Shift to C (zero-based) indexing
local_idx_ptr = C_LOC(local_idx)
else
local_idx_ptr = C_NULL_PTR
end if
if (present(attrCompliance)) then
if (attrCompliance) local_attrCompliance = 1 !true
end if
if (present(isPresent)) then
if (LEN(key) > 0) then
isPresent = ESMF_InfoIsPresent(info, local_key, isPointer=.true., &
attnestflag=attnestflag, rc=localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, ESMF_CONTEXT, rcToReturn=rc)) return
else
isPresent = .true.
end if
end if
inq = ESMF_InfoCreate(rc=localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, ESMF_CONTEXT, rcToReturn=rc)) return
call c_info_inquire(info%ptr, inq%ptr, local_key//C_NULL_CHAR, recursive, &
local_idx_ptr, local_attrCompliance, localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, ESMF_CONTEXT, rcToReturn=rc)) return
if (present(size)) then
call ESMF_InfoGet(inq, "size", size, rc=localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, ESMF_CONTEXT, rcToReturn=rc)) return
end if
if (present(attrCount)) then
call ESMF_InfoGet(inq, "attrCount", attrCount, rc=localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, ESMF_CONTEXT, rcToReturn=rc)) return
end if
if (present(attrCountTotal)) then
call ESMF_InfoGet(inq, "attrCountTotal", attrCountTotal, rc=localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, ESMF_CONTEXT, rcToReturn=rc)) return
end if
if (present(jsonType)) then
call ESMF_InfoGet(inq, "jsonType", jsonType, rc=localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, ESMF_CONTEXT, rcToReturn=rc)) return
end if
if (present(isArray)) then
call ESMF_InfoGet(inq, "isArray", isArray, rc=localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, ESMF_CONTEXT, rcToReturn=rc)) return
end if
if (present(isDirty)) then
call ESMF_InfoGet(inq, "isDirty", isDirty, rc=localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, ESMF_CONTEXT, rcToReturn=rc)) return
end if
if (present(attPackCount)) then
call ESMF_InfoGet(inq, "attPackCount", attPackCount, rc=localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, ESMF_CONTEXT, rcToReturn=rc)) return
end if
if (present(attPackCountTotal)) then
call ESMF_InfoGet(inq, "attPackCountTotal", attPackCountTotal, rc=localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, ESMF_CONTEXT, rcToReturn=rc)) return
end if
if (present(typekind)) then
call ESMF_InfoGet(inq, "ESMC_TypeKind_Flag", esmc_typekind, rc=localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, ESMF_CONTEXT, rcToReturn=rc)) return
typekind = ESMF_TypeKind_Flag(esmc_typekind)
end if
if (present(ikey)) then
call ESMF_InfoGet(inq, "key", ikey, rc=localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, ESMF_CONTEXT, rcToReturn=rc)) return
end if
if (present(idx)) then
if (present(isPresent)) then
if (isPresent) then
inq2 = ESMF_InfoCreate(rc=localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, ESMF_CONTEXT, rcToReturn=rc)) return
call c_info_inquire(info%ptr, inq2%ptr, local_key//C_NULL_CHAR, recursive, &
C_NULL_PTR, local_attrCompliance, localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, ESMF_CONTEXT, rcToReturn=rc)) return
call ESMF_InfoGet(inq2, "size", local_size, rc=localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, ESMF_CONTEXT, rcToReturn=rc)) return
if (idx > local_size) then
isPresent = .false.
end if
call ESMF_InfoDestroy(inq2, rc=localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, ESMF_CONTEXT, rcToReturn=rc)) return
end if
end if
end if
if (present(isStructured)) then
call ESMF_InfoGet(inq, "isStructured", isStructured, rc=localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, ESMF_CONTEXT, rcToReturn=rc)) return
end if
if (present(isNull)) then
call ESMF_InfoGet(inq, "isNull", isNull, rc=localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, ESMF_CONTEXT, rcToReturn=rc)) return
end if
call ESMF_InfoDestroy(inq, rc=rc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, ESMF_CONTEXT, rcToReturn=rc)) return
if (present(rc)) rc = ESMF_SUCCESS
end subroutine ESMF_InfoInquire