ESMF_InfoDump Function

public function ESMF_InfoDump(info, keywordEnforcer, key, indent, rc) result(output)

Arguments

Type IntentOptional Attributes Name
type(ESMF_Info), intent(in) :: info
type(ESMF_KeywordEnforcer), optional :: keywordEnforcer
character(len=*), intent(in), optional :: key
integer, intent(in), optional :: indent
integer, intent(out), optional :: rc

Return Value character(len=:), allocatable


Source Code

function ESMF_InfoDump(info, keywordEnforcer, key, indent, rc) result(output)
! !ARGUMENTS:
  type(ESMF_Info), intent(in) :: info
type(ESMF_KeywordEnforcer), optional:: keywordEnforcer ! must use keywords below
  character(*), intent(in), optional :: key
  integer, intent(in), optional :: indent
  integer, intent(out), optional :: rc
! RESULT:
  character(:), allocatable :: output
!
! !DESCRIPTION:
!     Dump the contents of an \texttt{ESMF\_Info} object as a JSON string.
!
!     The arguments are:
!     \begin{description}
!     \item [info]
!       Target \texttt{ESMF\_Info} object.
!     \item [{[key]}]
!       String key to access in \texttt{ESMF\_Info} storage. See section \ref{info_key_format}
!       for an overview of the key format.
!     \item [{[indent]}]
!       Default is 0. Specifying an indentation greater than 0 will result in a
!       "pretty print" for JSON output string (string includes new line breaks).
!     \item [{[rc]}]
!       Return code; equals {\tt ESMF\_SUCCESS} if there are no errors.
!     \end{description}
!EOP

  character(:), allocatable :: l_key
  integer :: dump_length, localrc, local_indent

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

  if (present(key)) then
    l_key = key
  else
    l_key = ""
  endif
  if (present(indent)) then
    local_indent = indent
  else
    local_indent = 0
  endif

  call c_info_dump_len(info%ptr, dump_length, localrc, local_indent)
  if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, ESMF_CONTEXT)) return

  allocate(character(dump_length)::output)

  call c_info_dump(info%ptr, output, localrc, local_indent)
  if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, ESMF_CONTEXT)) return

  if (present(rc)) rc = ESMF_SUCCESS
end function ESMF_InfoDump