integer function ESMF_ConfigGetLen(config, keywordEnforcer, label, rc)
! !ARGUMENTS:
type(ESMF_Config), intent(inout) :: config
type(ESMF_KeywordEnforcer), optional:: keywordEnforcer ! must use keywords below
character(len=*), intent(in), optional :: label
integer, intent(out), optional :: rc
!
!
! !STATUS:
! \begin{itemize}
! \item\apiStatusCompatibleVersion{5.2.0r}
! \end{itemize}
!
! !DESCRIPTION:
! Gets the length of the line in words by counting words
! disregarding types. Returns the word count as an integer.
!
! The arguments are:
! \begin{description}
! \item [config]
! Already created {\tt ESMF\_Config} object.
! \item [{[label]}]
! Identifying label. If not specified, use the current line.
! \item [{[rc]}]
! Return code; equals {\tt ESMF\_SUCCESS} if there are no errors.
! \end{description}
!
!EOP -------------------------------------------------------------------
character(len=LSZ) :: string
integer :: localrc
integer :: count
logical :: eol, found
! Initialize return code; assume routine not implemented
if (present(rc)) rc = ESMF_RC_NOT_IMPL
localrc = ESMF_SUCCESS
count = 0
ESMF_ConfigGetLen = -1 ! assume error
!check variables
ESMF_INIT_CHECK_DEEP(ESMF_ConfigGetInit,config,rc)
if( present( label )) then
call ESMF_ConfigFindLabel(config, label=label, &
isPresent=found, rc=localrc)
if (ESMF_LogFoundError (localrc, ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
if (.not. found) then
localrc = ESMF_RC_NOT_FOUND
if (present( rc )) then
rc = localrc
endif
return
endif
endif
do
call ESMF_ConfigGetString( config, string, eolFlag=eol, rc = localrc )
if (eol) exit
if ( localrc == ESMF_SUCCESS ) then
count = count + 1
else
exit
endif
enddo
ESMF_ConfigGetLen = count
if( present ( rc )) then
rc = localrc
endif
end function ESMF_ConfigGetLen