ESMF_AttributeWriteLocStream Subroutine

private subroutine ESMF_AttributeWriteLocStream(target, fileName, keywordEnforcer, convention, purpose, attwriteflag, rc)

Arguments

Type IntentOptional Attributes Name
type(ESMF_LocStream), intent(inout) :: target
character(len=*), intent(in) :: fileName
type(ESMF_KeywordEnforcer), optional :: keywordEnforcer
character(len=*), intent(in), optional :: convention
character(len=*), intent(in), optional :: purpose
type(ESMF_AttWriteFlag), intent(in), optional :: attwriteflag
integer, intent(out), optional :: rc

Source Code

subroutine ESMF_AttributeWriteLocStream(target, filename, keywordenforcer, convention, purpose, attwriteflag, rc)
  ! 39.11.42 - attwrite flag only supports JSON
  type(ESMF_LocStream), intent(inout) :: target
  character(len=*), intent(in) :: fileName
type(ESMF_KeywordEnforcer), optional :: keywordEnforcer ! must use keywords below
  character(len=*), intent(in), optional :: convention
  character(len=*), intent(in), optional :: purpose
  type(ESMF_AttWriteFlag), intent(in), optional :: attwriteflag
  integer, intent(out), optional :: rc

  integer :: localrc
  type(ESMF_InfoDescribe) :: eidesc
  type(ESMF_Info) :: info, isrc
  character(:), allocatable :: key

  localrc = ESMF_FAILURE
  if (present(rc)) rc = ESMF_RC_NOT_IMPL
  ! Check object initialization
  ESMF_INIT_CHECK_DEEP(ESMF_LocStreamGetInit, target, rc)

  isrc = eidesc%GetInfo(target, rc=localrc)
  if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, ESMF_CONTEXT, rcToReturn=rc)) return

  if (present(convention)) then
    call ESMF_InfoFormatKey(key, "", localrc, convention=convention, purpose=purpose)
    if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, ESMF_CONTEXT, rcToReturn=rc)) return

    info = ESMF_InfoCreate(isrc, key, rc=localrc)
    if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, ESMF_CONTEXT, rcToReturn=rc)) return
  else
    info = isrc
  endif

  call ESMF_InfoWriteJSON(info, filename, rc=localrc)
  if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, ESMF_CONTEXT, rcToReturn=rc)) return

  if (present(convention)) then
    deallocate(key)
    call ESMF_InfoDestroy(info, rc=localrc)
    if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, ESMF_CONTEXT, rcToReturn=rc)) return
  endif

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