check_field_typekind Subroutine

public subroutine check_field_typekind(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_field_typekind~~CallsGraph proc~check_field_typekind check_field_typekind anyexceptions anyexceptions proc~check_field_typekind->anyexceptions assert_that assert_that proc~check_field_typekind->assert_that esmf_fieldget esmf_fieldget proc~check_field_typekind->esmf_fieldget esmf_hconfigasstring esmf_hconfigasstring proc~check_field_typekind->esmf_hconfigasstring esmf_hconfigisdefined esmf_hconfigisdefined proc~check_field_typekind->esmf_hconfigisdefined esmf_stateget esmf_stateget proc~check_field_typekind->esmf_stateget sourcelocation sourcelocation proc~check_field_typekind->sourcelocation true true proc~check_field_typekind->true

Source Code

   subroutine check_field_typekind(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

      character(len=:), allocatable :: expected_field_typekind_str
      type(ESMF_TypeKind_Flag) :: expected_field_typekind
      type(ESMF_TypeKind_Flag) :: found_field_typekind
      type(ESMF_StateItem_Flag) :: itemtype
      integer :: status
      character(len=:), allocatable :: msg
      type(ESMF_Field) :: field

      msg = description

      call ESMF_StateGet(state, short_name, itemtype=itemtype, _RC)
      if (itemtype /= ESMF_STATEITEM_FIELD) then
         rc = 0
         return
      end if


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

      expected_field_typekind_str = ESMF_HConfigAsString(expectations,keyString='typekind',_RC)
      select case (expected_field_typekind_str)
      case ('R4')
         expected_field_typekind = ESMF_TYPEKIND_R4
      case ('R8')
         expected_field_typekind = ESMF_TYPEKIND_R8
      case default
         _VERIFY(-1)
      end select
      
      call ESMF_StateGet(state, short_name, field, _RC)
      call ESMF_FieldGet(field, typekind=found_field_typekind, _RC)
      @assert_that(msg // ' field typekind: ',expected_field_typekind == found_field_typekind, is(true()))

      rc = 0
   end subroutine check_field_typekind