subroutine ESMF_IO_YAMLContentGet(yaml, keywordEnforcer, &
    content, contentSize, lineCount, rc)
!
! !ARGUMENTS:
    type(ESMF_IO_YAML)                                  :: yaml
type(ESMF_KeywordEnforcer), optional:: keywordEnforcer ! must use keywords below
    character(len=*),             intent(out), optional :: content(:)
    integer,                      intent(out), optional :: contentSize
    integer,                      intent(out), optional :: lineCount
    integer,                      intent(out), optional :: rc
! !DESCRIPTION:
!     Retrieve the parsed content of a {\tt ESMF\_YAML\_IO} object.
!
!     The arguments are:
!     \begin{description}
!     \item[{yaml}]
!          Output parsed content of this {\tt ESMF\_IO_YAML} object.
!     \item[{content}]
!          A character(1) array that will hold the content. It must be
!          at least of size {\tt contentSize}.
!     \item[{contentSize}]
!          The number of characters of the available content. It should be
!          retrieved first, to properly allocate the {\tt content} array.
!     \item[{lineCount}]
!          The number of lines of the available content. It should be
!          retrieved first, to properly allocate the {\tt content} array.
!     \item[{[rc]}]
!          Return code; equals {\tt ESMF\_SUCCESS} if there are no errors.
!     \end{description}
!     
!EOPI
    ! local return codes
    integer :: localrc, stat
    ! local variables
    integer :: i, j, k
    integer :: contentLineCount, contentStringLen, contentLen
    character(len=1), allocatable :: buffer(:)
!
!   ! Assume failure until success
    if (present(rc)) rc = ESMF_RC_NOT_IMPL
    if (present(contentSize)) then
      call c_ESMC_IO_YAMLCSize(yaml, contentSize, localrc)
      if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
        ESMF_CONTEXT, rcToReturn=rc)) return
    end if
    if (present(lineCount)) then
      call c_ESMC_IO_YAMLCLineC(yaml, lineCount, localrc)
      if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
        ESMF_CONTEXT, rcToReturn=rc)) return
    end if
    if (present(content)) then
      ! setup receiving buffer for parsed content
      contentStringLen = len(content(1))
      contentLineCount = size(content)
      contentLen = contentStringLen * contentLineCount
      allocate(buffer(contentLen), stat=stat)
      if (ESMF_LogFoundAllocError(statusToCheck=stat, &
        msg="Allocation of string buffer.", &
        ESMF_CONTEXT, rcToReturn=rc)) return
      ! initialize buffer
      buffer = ""
      call c_ESMC_IO_YAMLCGet(yaml, buffer, contentLen, localrc)
      if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
        ESMF_CONTEXT, rcToReturn=rc)) return
      ! convert received content from 1-d to array of strings, delimited by newline characters
      content = ""
      k = 0
      i = 1
      do j = 1, size(buffer)
        if (buffer(j) == achar(0)) exit
        if (buffer(j) == achar(10)) then
            k = 0
            i = i + 1
            if (i > contentLineCount) exit
            cycle
        else
            k = k + 1
            if (k > contentStringLen) cycle
        end if
        content(i)(k:k) = buffer(j)
      end do
      ! release buffer memory
      deallocate(buffer, stat=stat)
      if (ESMF_LogFoundDeallocError(statusToCheck=stat, &
        msg="Free memory associated with string buffer.", &
        ESMF_CONTEXT, rcToReturn=rc)) return
    end if
    ! Return success
    if (present(rc)) rc = ESMF_SUCCESS
  end subroutine ESMF_IO_YAMLContentGet