subroutine ESMF_ConfigGetDim(config, lineCount, columnCount, &
keywordEnforcer, label, rc)
! !ARGUMENTS:
type(ESMF_Config), intent(inout) :: config
integer, intent(out) :: lineCount
integer, intent(out) :: columnCount
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:
! Returns the number of lines in the table in {\tt lineCount} and
! the maximum number of words in a table line in {\tt columnCount}.
!
! After the call, the line pointer is positioned to the end of the table.
! To reset it to the beginning of the table, use {\tt ESMF\_ConfigFindLabel}.
!
! The arguments are:
! \begin{description}
! \item [config]
! Already created {\tt ESMF\_Config} object.
! \item [lineCount]
! Returned number of lines in the table.
! \item [columnCount]
! Returned maximum number of words in a table line.
! \item [{[label]}]
! Identifying label (if present), otherwise current line.
! \item [{[rc]}]
! Return code; equals {\tt ESMF\_SUCCESS} if there are no errors.
! \end{description}
!
!EOP -------------------------------------------------------------------
!
integer :: localrc
integer :: n
logical :: found
logical :: tend
! Initialize return code; assume routine not implemented
if (present(rc)) rc = ESMF_RC_NOT_IMPL
localrc = ESMF_RC_NOT_IMPL
lineCount = 0
columnCount = 0
!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_ConfigNextLine(config, tableEnd=tend, rc=localrc)
if (localrc /= ESMF_SUCCESS ) then
lineCount = 0
columnCount = 0
exit
endif
if ( tend ) then
exit
else
lineCount = lineCount + 1
n = ESMF_ConfigGetLen( config, rc = localrc)
if ( localrc /= ESMF_SUCCESS ) then
lineCount = 0
columnCount = 0
if ( present( rc )) then
rc = localrc
endif
return
else
columnCount = max(columnCount, n)
endif
endif
enddo
if ( present( rc )) then
rc = localrc
endif
end subroutine ESMF_ConfigGetDim