ESMF_ConfigValidate Subroutine

public subroutine ESMF_ConfigValidate(config, keywordEnforcer, options, rc)

Arguments

Type IntentOptional Attributes Name
type(ESMF_Config), intent(inout) :: config
type(ESMF_KeywordEnforcer), optional :: keywordEnforcer
character(len=*), intent(in), optional :: options
integer, intent(out), optional :: rc

Source Code

    subroutine ESMF_ConfigValidate(config, &
      keywordEnforcer, options, rc)

! !ARGUMENTS:
      type(ESMF_Config), intent(inout)          :: config 
type(ESMF_KeywordEnforcer), optional:: keywordEnforcer ! must use keywords below
      character (len=*), intent(in),   optional :: options
      integer,           intent(out),  optional :: rc 
!
!
! !STATUS:
! \begin{itemize}
! \item\apiStatusCompatibleVersion{5.2.0r}
! \end{itemize}
!
! !DESCRIPTION: 
!   Checks whether a {\tt config} object is valid.
!
!   The arguments are:
!   \begin{description}
!   \item [config]
!     {\tt ESMF\_Config} object to be validated.
!   \item[{[options]}]
!     \begin{sloppypar}
!     If none specified:  simply check that the buffer is not full and the
!       pointers are within range.
!     "unusedAttributes" - Report to the default logfile all attributes not
!       retrieved via a call to {\tt ESMF\_ConfigGetAttribute()} or
!       {\tt ESMF\_ConfigGetChar()}.  The attribute name (label) will be
!       logged via {\tt ESMF\_LogErr} with the WARNING log message type.
!       For an array-valued attribute, retrieving at least one value via
!       {\tt ESMF\_ConfigGetAttribute()} or {\tt ESMF\_ConfigGetChar()}
!       constitutes being "used."
!     \end{sloppypar}
!   \item [{[rc]}]
!     Return code; equals {\tt ESMF\_SUCCESS} if there are no errors.
!     Equals {\tt ESMF\_RC\_ATTR\_UNUSED} if any unused attributes are found
!     with option "unusedAttributes" above.
!   \end{description}

!EOP -------------------------------------------------------------------
      character(len=ESMF_MAXSTR) :: logmsg
      integer :: i, localrc

      if (present(rc)) then
        rc = ESMF_RC_NOT_IMPL
      endif
      localrc = ESMF_RC_NOT_IMPL

      ! check variables
      ESMF_INIT_CHECK_DEEP(ESMF_ConfigGetInit,config,rc)

      ! validate internal buffer indices

      if (config%cptr%nbuf < 0 .or. config%cptr%nbuf > NBUF_MAX) then
        if (ESMF_LogFoundError(ESMF_RC_INTNRL_LIST, &
                                  msg="config%cptr%nbuf out-of-range.", &
                                  ESMF_CONTEXT, rcToReturn=rc)) return
      endif

      if (config%cptr%next_line < 0 .or. config%cptr%next_line >= config%cptr%nbuf) then
        if (ESMF_LogFoundError(ESMF_RC_INTNRL_LIST, &
                                  msg="config%cptr%next_line out-of-range.", &
                                  ESMF_CONTEXT, rcToReturn=rc)) return
      endif

      if (config%cptr%nattr < 0 .or. config%cptr%nattr > NATT_MAX) then
        if (ESMF_LogFoundError(ESMF_RC_INTNRL_LIST, &
                                  msg="config%cptr%nattr out-of-range.", &
                                  ESMF_CONTEXT, rcToReturn=rc)) return
      endif

      ! optional validations

      if (present(options)) then
        if (options == "unusedAttributes") then
          do i = 1, config%cptr%nattr
            if (.not.(config%cptr%attr_used(i)%used)) then
              logmsg = "Config attribute label '" // &
                  ESMF_UtilArray2String (config%cptr%attr_used(i)%label) // &
                  "' unused (not retrieved via ESMF_ConfigGetAttribute() " // &
                  "or ESMF_ConfigGetChar())."
              call ESMF_LogWrite(logmsg, ESMF_LOGMSG_WARNING, ESMF_CONTEXT)
                localrc = ESMF_RC_ATTR_UNUSED
            endif
          enddo
        endif
      endif

      if (present(rc)) then
        if (localrc == ESMF_RC_ATTR_UNUSED) then
          rc = localrc
        else
          rc = ESMF_SUCCESS
        end if
      end if

      return

    end subroutine ESMF_ConfigValidate