ESMF_AttributeGetAttPackMesh Subroutine

private subroutine ESMF_AttributeGetAttPackMesh(target, convention, purpose, keywordEnforcer, attpack, attnestflag, isPresent, rc)

Arguments

Type IntentOptional Attributes Name
type(ESMF_Mesh), intent(in) :: target
character(len=*), intent(in) :: convention
character(len=*), intent(in) :: purpose
type(ESMF_KeywordEnforcer), optional :: keywordEnforcer
type(ESMF_AttPack), intent(inout), optional :: attpack
type(ESMF_AttNest_Flag), intent(in), optional :: attnestflag
logical, intent(out), optional :: isPresent
integer, intent(out), optional :: rc

Source Code

subroutine ESMF_AttributeGetAttPackMesh(target, convention, purpose, keywordEnforcer, attpack, attnestflag, isPresent, rc)
  ! 39.11.21
  type(ESMF_Mesh), intent(in) :: target
  character(len=*), intent(in) :: convention
  character(len=*), intent(in) :: purpose
type(ESMF_KeywordEnforcer), optional :: keywordEnforcer ! must use keywords below
  type(ESMF_AttPack), intent(inout), optional :: attpack
  type(ESMF_AttNest_Flag), intent(in), optional :: attnestflag
  logical, intent(out), optional :: isPresent
  integer, intent(out), optional :: rc

  integer :: localrc
  character(:), allocatable :: key
  logical :: is_present
  type(ESMF_Info) :: info
  type(ESMF_InfoDescribe) :: eidesc
  type(ESMF_AttNest_Flag) :: local_attnestflag

  logical, parameter :: debug = .false.

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

  if (present(attnestflag)) then
    local_attnestflag = attnestflag
  else
    local_attnestflag = ESMF_ATTR_DEFAULT_ATTNEST
  end if

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

  if (debug) then
    call ESMF_LogWrite(ESMF_METHOD//": convention="//TRIM(convention))
    call ESMF_LogWrite(ESMF_METHOD//": purpose="//TRIM(purpose))
    call ESMF_LogWrite(ESMF_METHOD//": Info Dump="//ESMF_InfoDump(info, rc=localrc), rc=localrc)
    if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, ESMF_CONTEXT, rcToReturn=rc)) return
  end if

  key = "/"//TRIM(convention)//"/"//TRIM(purpose)
  is_present = ESMF_InfoIsPresent(info, key, attnestflag=local_attnestflag, isPointer=.true., rc=localrc)
  if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, ESMF_CONTEXT, rcToReturn=rc)) return

  if (present(isPresent)) then
    isPresent = is_present
  end if

  ! If the attpack object is provided but it does not exist, then bail out since
  ! the attpack will never be initialized properly
  if (.not. is_present) then
    if (present(attpack)) then
      if (.not. present(isPresent)) then
        if (debug) then
          call ESMF_LogWrite(ESMF_METHOD//": convention="//TRIM(convention))
          call ESMF_LogWrite(ESMF_METHOD//": purpose="//TRIM(purpose))
        end if
        if (ESMF_LogFoundError(ESMF_RC_NOT_FOUND, msg="convention/purpose not found and attpack object present", &
          ESMF_CONTEXT, rcToReturn=rc)) return
      end if
    end if
  end if

  if (is_present) then
    if (present(attpack)) then
      call attpack%initialize(info, convention=convention, purpose=purpose, rc=localrc)
      if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, ESMF_CONTEXT, rcToReturn=rc)) return
      if (debug) then
        call ESMF_LogWrite(ESMF_METHOD//": attpack%root_key="//TRIM(attpack%root_key), rc=localrc)
        if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, ESMF_CONTEXT, rcToReturn=rc)) return
      end if
    end if
  end if

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