x_comp_read_output Subroutine

private subroutine x_comp_read_output(xdatacfg, xstate, rc)

Arguments

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

Source Code

  subroutine x_comp_read_output(xdatacfg, xstate, rc)
    ! arguments
    type(ESMF_HConfig)                        :: xdatacfg
    type(xdata_state), pointer, intent(inout) :: xstate
    integer, intent(out)                      :: rc
    ! local variables
    logical            :: isPresent
    integer            :: stat
    logical            :: check
    type(ESMF_HConfig) :: outcfg
    character(:), allocatable :: cfgval
    character(:), allocatable :: badKey

    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

    ! read output configuration
    isPresent = ESMF_HConfigIsDefined(xdatacfg, &
      keyString="output", rc=rc)
    if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
      line=__LINE__, file=__FILE__)) return
    if (isPresent) then
      ! access output
      outcfg = ESMF_HConfigCreateAt(xdatacfg, &
        keyString="output", rc=rc)
      if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
        line=__LINE__, file=__FILE__)) return
      check = ESMF_HConfigValidateMapKeys(outcfg, &
        vocabulary=["write_final"], badKey=badKey, rc=rc)
      if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
        line=__LINE__, file=__FILE__)) return
      if (.not. check) then
        call ESMF_LogSetError(ESMF_RC_NOT_VALID, &
          msg=trim(xstate%cname)//": unknown output option key - "//badKey, &
        line=__LINE__,file=__FILE__, rcToReturn=rc)
        return
      endif
      ! options
      xstate%write_final = x_comp_hconfig_logical(outcfg, "write_final", &
        defaultValue=.true., rc=rc)
      if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
        line=__LINE__, file=__FILE__)) return
      call ESMF_HConfigDestroy(outcfg, rc=rc)
      if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
        line=__LINE__, file=__FILE__)) return
    endif ! outcfg

  endsubroutine x_comp_read_output