subroutine Advertise(xdata, rc)
! arguments
type(ESMF_GridComp) :: xdata
integer, intent(out) :: rc
! local variables
integer :: stat
type(xstate_wrap) :: is
type(ESMF_State) :: importState, exportState
type(xdata_state), pointer :: xstate
type(xdata_field), pointer :: xfield => null()
rc = ESMF_SUCCESS
! query component for internal state
nullify(is%ptr)
call ESMF_GridCompGetInternalState(xdata, is, rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
line=__LINE__, file=__FILE__)) return
xstate => is%ptr
if (.not. associated(xstate)) then
call ESMF_LogSetError(ESMF_RC_PTR_NOTALLOC, &
msg='XDATA: xstate has not been associated', &
line=__LINE__, file=__FILE__, rcToReturn=rc)
return
endif
! get configuration information
call x_comp_get_config(xdata, xstate, rc=rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
line=__LINE__, file=__FILE__)) return
! query component for information
call NUOPC_CompGet(xdata, name=xstate%cname, &
verbosity=xstate%verbosity, diagnostic=xstate%diagnostic, rc=rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
line=__LINE__, file=__FILE__)) return
! query for importState and exportState
call NUOPC_ModelGet(xdata, importState=importState, &
exportState=exportState, rc=rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
line=__LINE__, file=__FILE__)) return
! advertise import fields
xfield => xstate%imp_flds_head
do while (associated(xfield))
call NUOPC_Advertise(importState, xfield%stdn, rc=rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
line=__LINE__, file=__FILE__)) return
xfield => xfield%nfld
enddo
! advertise export fields
xfield => xstate%exp_flds_head
do while (associated(xfield))
call NUOPC_Advertise(exportState, xfield%stdn, rc=rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
line=__LINE__, file=__FILE__)) return
xfield => xfield%nfld
enddo
endsubroutine Advertise