ESMF_InfoFormatKey Subroutine

public subroutine ESMF_InfoFormatKey(key, name, rc, convention, purpose)

Arguments

Type IntentOptional Attributes Name
character(len=:), intent(out), allocatable :: key
character(len=*), intent(in) :: name
integer, intent(out) :: rc
character(len=*), intent(in), optional :: convention
character(len=*), intent(in), optional :: purpose

Source Code

subroutine ESMF_InfoFormatKey(key, name, rc, convention, purpose)
  character(:), allocatable, intent(out) :: key
  character(len=*), intent(in) :: name
  integer, intent(out) :: rc
  character(len=*), intent(in), optional :: convention
  character(len=*), intent(in), optional :: purpose

  character(*), parameter :: msg="Both convention & purpose are required if either is present"

  if (present(convention)) then
    if (.not. present(purpose)) then
      if (ESMF_LogFoundError(ESMF_RC_ARG_BAD, msg=msg, ESMF_CONTEXT, rcToReturn=rc)) return
    endif
  endif
  if (present(purpose)) then
    if (.not. present(convention)) then
      if (ESMF_LogFoundError(ESMF_RC_ARG_BAD, msg=msg, ESMF_CONTEXT, rcToReturn=rc)) return
    endif
  endif

  if (present(convention)) then
    if (LEN(name) > 0) then
      key = "/"//trim(convention)//"/"//trim(purpose)//"/"//trim(name)
    else
      key = "/"//trim(convention)//"/"//trim(purpose)
    end if
  else
    if (LEN(name) > 0) then
      key = ESMF_ATTR_DEFAULT_ROOTKEY//"/"//trim(name)
    else
      key = ESMF_ATTR_DEFAULT_ROOTKEY
    end if
  endif

  rc = ESMF_SUCCESS
end subroutine ESMF_InfoFormatKey