check_item_type Subroutine

public subroutine check_item_type(expectations, state, short_name, description, rc)

Arguments

Type IntentOptional Attributes Name
type(ESMF_HConfig), intent(in) :: expectations
type(ESMF_State), intent(inout) :: state
character(len=*), intent(in) :: short_name
character(len=*), intent(in) :: description
integer, intent(out) :: rc

Calls

proc~~check_item_type~~CallsGraph proc~check_item_type check_item_type anyexceptions anyexceptions proc~check_item_type->anyexceptions assert_that assert_that proc~check_item_type->assert_that esmf_hconfigasstring esmf_hconfigasstring proc~check_item_type->esmf_hconfigasstring esmf_hconfigisdefined esmf_hconfigisdefined proc~check_item_type->esmf_hconfigisdefined proc~get_itemtype get_itemtype proc~check_item_type->proc~get_itemtype sourcelocation sourcelocation proc~check_item_type->sourcelocation true true proc~check_item_type->true proc~get_itemtype->anyexceptions proc~get_itemtype->assert_that proc~get_itemtype->sourcelocation esmf_stateget esmf_stateget proc~get_itemtype->esmf_stateget

Source Code

   subroutine check_item_type(expectations, state, short_name, description, rc)
      type(ESMF_HConfig), intent(in) :: expectations
      type(ESMF_State), intent(inout) :: state
      character(*), intent(in) :: short_name
      character(*), intent(in) :: description
      integer, intent(out) :: rc

      type(ESMF_StateItem_Flag) :: expected_itemtype, itemtype
      character(len=:), allocatable :: msg
      integer :: status
      integer :: idx

      msg = description
      expected_itemtype = get_expected_itemtype(expectations, _RC)

      itemtype = get_itemtype(state, short_name, _RC)
      @assert_that(msg // ':: check item type of '//short_name, expected_itemtype == itemtype, is(true()))

      rc = 0

   contains

      function get_expected_itemtype(expectations, rc) result(expected_itemtype)
         type(ESMF_StateItem_Flag) :: expected_itemtype
         type(ESMF_HConfig), intent(in) :: expectations
         integer, intent(out) :: rc

         character(:), allocatable :: itemtype_str
         integer :: status

         if (.not. ESMF_HConfigIsDefined(expectations,keyString='class')) then
            expected_itemtype = ESMF_STATEITEM_FIELD
            rc=0
            return
         end if

         itemtype_str= ESMF_HConfigAsString(expectations,keyString='class',_RC)
         
         select case (itemtype_str)
         case ('field')
            expected_itemtype = ESMF_STATEITEM_FIELD
         case ('bundle')
            expected_itemtype = ESMF_STATEITEM_FIELDBUNDLE
         case default
            expected_itemtype = ESMF_STATEITEM_UNKNOWN
         end select

         rc = 0
         
      end function get_expected_itemtype
         
   end subroutine check_item_type