ESMF_AttPackStreamJSON Subroutine

public subroutine ESMF_AttPackStreamJSON(attpack, output, rc)

Arguments

Type IntentOptional Attributes Name
type(ESMF_AttPack), intent(in) :: attpack
character(len=*), intent(out), optional :: output
integer, intent(out), optional :: rc

Source Code

subroutine ESMF_AttPackStreamJSON(attpack, output, rc)
  type(ESMF_AttPack), intent(in) :: attpack
  character(len=*), intent(out), optional :: output
  integer, intent(out), optional :: rc

  integer :: localrc
  character(:), allocatable :: c_output, key

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

  key = attpack%formatKey(rc=localrc)
  if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, ESMF_CONTEXT, rcToReturn=rc)) return

  c_output = ESMF_InfoDump(attpack%getPayload(), key=key, rc=localrc)
  if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, ESMF_CONTEXT, rcToReturn=rc)) return

  if (LEN(output) < LEN(c_output)) then
    if (ESMF_LogFoundError(ESMF_RC_ARG_BAD, msg="output buffer length too small", ESMF_CONTEXT, rcToReturn=rc)) return
  endif
  output = c_output

  if (present(rc)) rc = ESMF_SUCCESS
end subroutine ESMF_AttPackStreamJSON