subroutine updateGeneric(self, root_key, name, etype, base, keywordEnforcer, base_is_valid, uname, rc)
class(ESMF_InfoDescribe), intent(inout) :: self
character(*), intent(in) :: root_key
character(*), intent(in) :: name
character(*), intent(in) :: etype
type(ESMF_Base), intent(in) :: base
type(ESMF_KeywordEnforcer), optional:: keywordEnforcer ! must use keywords below
logical, intent(in), optional :: base_is_valid
character(:), allocatable, optional :: uname
integer, intent(inout), optional :: rc
integer :: id_base, localrc, vmid_int, ii
character(:), allocatable :: c_id_base, l_uname, c_vmid, local_root_key
logical :: l_base_is_valid
type(ESMF_Info) :: object_info
character(len=9), dimension(4), parameter :: geom_etypes = (/"Grid ", "Mesh ", "LocStream", "XGrid "/)
integer(C_INT) :: found_as_int
type(ESMF_VMId) :: curr_vmid
logical :: vmids_are_equal, should_search_for_vmid
character(len=ESMF_MAXSTR) :: logmsg
localrc = ESMF_FAILURE
if (.not. self%is_initialized) then
if (ESMF_LogFoundError(ESMF_RC_OBJ_NOT_CREATED, msg="ESMF_InfoDescribe is not initialized", &
ESMF_CONTEXT, rcToReturn=rc)) return
endif
if (present(rc)) rc = ESMF_RC_NOT_IMPL
if (present(base_is_valid)) then
l_base_is_valid = base_is_valid
else
l_base_is_valid = .true.
end if
self%curr_base_is_valid = l_base_is_valid
self%curr_base = base
self%curr_base_is_geom = .false.
do ii=1,SIZE(geom_etypes)
if (trim(etype) == trim(geom_etypes(ii))) then
self%curr_base_is_geom = .true.
exit
end if
end do
if (self%createInfo) then
! If a VM identifier map is provided and the current Base object is valid,
! search the map for its integer identifier.
should_search_for_vmid = associated(self%vmIdMap)
if (.not. l_base_is_valid) then
should_search_for_vmid = .false.
end if
if (should_search_for_vmid) then
call ESMF_BaseGetVMId(base, curr_vmid, rc=localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, ESMF_CONTEXT, rcToReturn=rc)) return
do vmid_int=1,size(self%vmIdMap)
vmids_are_equal = ESMF_VMIdCompare(curr_vmid, self%vmIdMap(vmid_int), rc=localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, ESMF_CONTEXT, rcToReturn=rc)) return
if (vmids_are_equal) exit
end do
else
vmids_are_equal = .false.
end if
if (l_base_is_valid) then
call ESMF_BaseGetId(base, id_base, rc=localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, ESMF_CONTEXT, rcToReturn=rc)) return
call itoa(id_base, c_id_base)
if (vmids_are_equal) then
call itoa(vmid_int, c_vmid)
l_uname = trim(c_vmid)//"-"//trim(c_id_base)//"-"//trim(name)
else
l_uname = trim(c_id_base)//"-"//trim(name)
end if
else
l_uname = trim(name)
end if
allocate(character(len(trim(root_key))+len(l_uname)+1)::local_root_key)
local_root_key = trim(root_key)//"/"//l_uname
if (should_search_for_vmid) then
call ESMF_InfoSet(self%info, local_root_key//"/vmid_int", vmid_int, rc=localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, ESMF_CONTEXT, rcToReturn=rc)) return
else
call ESMF_InfoSetNULL(self%info, local_root_key//"/vmid_int", rc=localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, ESMF_CONTEXT, rcToReturn=rc)) return
end if
call ESMF_InfoSet(self%info, local_root_key//"/base_name", trim(name), force=.false., rc=localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, ESMF_CONTEXT, rcToReturn=rc)) return
call ESMF_InfoSet(self%info, local_root_key//"/esmf_type", etype, force=.false., rc=localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, ESMF_CONTEXT, rcToReturn=rc)) return
call ESMF_InfoSet(self%info, local_root_key//"/base_is_valid", l_base_is_valid, force=.false., rc=localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, ESMF_CONTEXT, rcToReturn=rc)) return
call ESMF_InfoSetNULL(self%info, local_root_key//"/members", force=.false., rc=localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, ESMF_CONTEXT, rcToReturn=rc)) return
if (self%addBaseAddress) then
call ESMF_InfoSet(self%info, local_root_key//"/base_address", base%this%ptr, force=.false., rc=localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, ESMF_CONTEXT, rcToReturn=rc)) return
end if
if (l_base_is_valid) then
call ESMF_InfoSet(self%info, local_root_key//"/base_id", id_base, force=.false., rc=localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, ESMF_CONTEXT, rcToReturn=rc)) return
else
call ESMF_InfoSetNULL(self%info, local_root_key//"/base_id", force=.false., rc=localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, ESMF_CONTEXT, rcToReturn=rc)) return
end if
call ESMF_InfoSet(self%info, local_root_key//"/is_geom", self%curr_base_is_geom, force=.false., rc=localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, ESMF_CONTEXT, rcToReturn=rc)) return
if (self%addObjectInfo) then
if (l_base_is_valid) then
call ESMF_InfoGetFromBase(base, object_info, rc=localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, ESMF_CONTEXT, rcToReturn=rc)) return
call ESMF_InfoSet(self%info, local_root_key//"/info", object_info, force=.false., rc=localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, ESMF_CONTEXT, rcToReturn=rc)) return
else
call ESMF_InfoSetNULL(self%info, local_root_key//"/info", force=.false., rc=localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, ESMF_CONTEXT, rcToReturn=rc)) return
end if
end if
if (present(uname)) then
allocate(character(len(l_uname))::uname)
uname = l_uname
end if
if (associated(self%searchCriteria)) then
found_as_int = 0 !false
localrc = c_infodescribe_search(self%info%ptr, trim(local_root_key)//C_NULL_CHAR, &
self%searchCriteria%ptr, found_as_int)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, ESMF_CONTEXT, rcToReturn=rc)) return
self%found = .false.
if (found_as_int == 1) self%found = .true.
end if
deallocate(local_root_key, l_uname)
endif
if (present(rc)) rc = ESMF_SUCCESS
end subroutine updateGeneric