x_comp_get_config Subroutine

private subroutine x_comp_get_config(xdata, xstate, rc)

Arguments

Type IntentOptional Attributes Name
type(ESMF_GridComp) :: xdata
type(xdata_state), intent(inout), pointer :: xstate
integer, intent(out) :: rc

Source Code

  subroutine x_comp_get_config(xdata, xstate, rc)
    ! arguments
    type(ESMF_GridComp)                       :: xdata
    type(xdata_state), pointer, intent(inout) :: xstate
    integer, intent(out)                      :: rc
    ! local variables
    logical            :: isPresent
    integer            :: stat
    logical            :: check
    type(ESMF_Config)  :: config
    type(ESMF_HConfig) :: hconfig
    type(ESMF_HConfig) :: xdatacfg

    rc = ESMF_SUCCESS

    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

    call ESMF_GridCompGet(xdata, configIsPresent=isPresent, rc=rc)
    if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
      line=__LINE__, file=__FILE__)) return
    if (isPresent) then
      ! get config from component
      call ESMF_GridCompGet(xdata, config=config, rc=rc)
      if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
        line=__LINE__, file=__FILE__)) return
      ! access hconfig
      call ESMF_ConfigGet(config, hconfig=hconfig, rc=rc)
      if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
        line=__LINE__, file=__FILE__)) return
      isPresent = ESMF_HConfigIsDefined(hconfig, &
        keyString=xstate%cname, rc=rc)
      if (isPresent) then
        ! access xdatacfg
        xdatacfg = ESMF_HConfigCreateAt(hconfig, &
          keyString=xstate%cname, rc=rc)
        if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
          line=__LINE__, file=__FILE__)) return
        call x_comp_read_output(xdatacfg, xstate, rc=rc)
        if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
          line=__LINE__, file=__FILE__)) return
        call x_comp_read_geom(xdatacfg, xstate, rc=rc)
        if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
          line=__LINE__, file=__FILE__)) return
        call x_comp_read_fields(xdatacfg, xstate, rc=rc)
        if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
          line=__LINE__, file=__FILE__)) return
        call ESMF_HConfigDestroy(xdatacfg, rc=rc)
        if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
          line=__LINE__, file=__FILE__)) return
      endif ! xdatacfg
    endif ! config

  endsubroutine x_comp_get_config