test_field_set_info Subroutine

public subroutine test_field_set_info()

Arguments

None

Calls

proc~~test_field_set_info~~CallsGraph proc~test_field_set_info test_field_set_info ESMF_GeomCreate ESMF_GeomCreate proc~test_field_set_info->ESMF_GeomCreate ESMF_GridCreateNoPeriDim ESMF_GridCreateNoPeriDim proc~test_field_set_info->ESMF_GridCreateNoPeriDim ESMF_InfoGet ESMF_InfoGet proc~test_field_set_info->ESMF_InfoGet ESMF_InfoGetAlloc ESMF_InfoGetAlloc proc~test_field_set_info->ESMF_InfoGetAlloc ESMF_InfoGetCharAlloc ESMF_InfoGetCharAlloc proc~test_field_set_info->ESMF_InfoGetCharAlloc ESMF_InfoGetFromHost ESMF_InfoGetFromHost proc~test_field_set_info->ESMF_InfoGetFromHost ESMF_InfoIsPresent ESMF_InfoIsPresent proc~test_field_set_info->ESMF_InfoIsPresent anyexceptions anyexceptions proc~test_field_set_info->anyexceptions assert_that assert_that proc~test_field_set_info->assert_that equal_to equal_to proc~test_field_set_info->equal_to esmf_fieldcreate esmf_fieldcreate proc~test_field_set_info->esmf_fieldcreate none~add_dim UngriddedDims%add_dim proc~test_field_set_info->none~add_dim none~set_info FieldSpec%set_info proc~test_field_set_info->none~set_info sourcelocation sourcelocation proc~test_field_set_info->sourcelocation true true proc~test_field_set_info->true interface~mapl_assert MAPL_Assert none~add_dim->interface~mapl_assert none~get_name~15 UngriddedDim%get_name none~add_dim->none~get_name~15 none~get_num_ungridded UngriddedDims%get_num_ungridded none~add_dim->none~get_num_ungridded none~push_back~21 UngriddedDimVector%push_back none~add_dim->none~push_back~21 proc~mapl_return MAPL_Return none~add_dim->proc~mapl_return none~set_info->ESMF_InfoGetFromHost ESMF_InfoDestroy ESMF_InfoDestroy none~set_info->ESMF_InfoDestroy ESMF_InfoSet ESMF_InfoSet none~set_info->ESMF_InfoSet none~make_info~3 UngriddedDims%make_info none~set_info->none~make_info~3 none~set_info->proc~mapl_return proc~mapl_verify MAPL_Verify none~set_info->proc~mapl_verify

Source Code

   subroutine test_field_set_info
      type(FieldSpec) :: spec
      type(ESMF_Geom) :: geom
      type(ESMF_Grid) :: grid
      type(BasicVerticalGrid) :: vertical_grid
      type(ESMF_Field) :: f
      type(ESMF_Info) :: info
      type(UngriddedDims) :: ungridded_dims
      integer :: status
      logical :: found
      real, allocatable :: coords(:)
      character(len=:), allocatable :: temp_string
      integer :: temp_int

      grid = ESMF_GridCreateNoPeriDim(maxIndex=[4,4], name='I_AM_GROOT', _RC)
      geom = ESMF_GeomCreate(grid, _RC)
      vertical_grid = BasicVerticalGrid(4)

      call ungridded_dims%add_dim(UngriddedDim([1.,2.], name='a', units='m'))
      call ungridded_dims%add_dim(UngriddedDim([1.,2.,3.], name='b', units='s'))

      spec = FieldSpec(geom=geom, vertical_grid=vertical_grid, &
           vertical_dim_spec=VERTICAL_DIM_CENTER, &
           typekind=ESMF_TYPEKIND_R4, ungridded_dims=ungridded_dims, &
           standard_name='t', long_name='p', units='unknown')

      f = ESMF_FieldCreate(geom, ESMF_TYPEKIND_R4, ungriddedLbound=[1,1], ungriddedUbound=[2,3], _RC)
      call spec%set_info(f, _RC)

      call ESMF_InfoGetFromHost(f, info, _RC)

      found = ESMF_InfoIsPresent(info, key='MAPL/vertical_dim', _RC)
      @assert_that(found, is(true()))
      found = ESMF_InfoIsPresent(info, key='MAPL/vertical_dim/vloc', _RC)
      @assert_that(found, is(true()))

      found = ESMF_InfoIsPresent(info, key='MAPL/vertical_grid', _RC)
      @assert_that(found, is(true()))
      found = ESMF_InfoIsPresent(info, key='MAPL/vertical_grid/num_levels', _RC)
      @assert_that(found, is(true()))
      call ESMF_InfoGet(info, 'MAPL/vertical_grid/num_levels',temp_int , _RC)
      @assert_that(temp_int, equal_to(4))

      found = ESMF_InfoIsPresent(info, key='MAPL/ungridded_dims', _RC)
      @assert_that(found, is(true()))

      found = ESMF_InfoIsPresent(info, key='MAPL/ungridded_dims/dim_1', _RC)
      @assert_that(found, is(true()))
      found = ESMF_InfoIsPresent(info, key='MAPL/ungridded_dims/dim_1/name', _RC)
      @assert_that(found, is(true()))
      found = ESMF_InfoIsPresent(info, key='MAPL/ungridded_dims/dim_1/units', _RC)
      @assert_that(found, is(true()))
      found = ESMF_InfoIsPresent(info, key='MAPL/ungridded_dims/dim_1/coordinates', _RC)
      @assert_that(found, is(true()))
      call ESMF_InfoGetAlloc(info, 'MAPL/ungridded_dims/dim_1/coordinates', coords, _RC)
      @assert_that(coords, equal_to([1.,2.]))

      found = ESMF_InfoIsPresent(info, key='MAPL/ungridded_dims/dim_2', _RC)
      @assert_that(found, is(true()))
      found = ESMF_InfoIsPresent(info, key='MAPL/ungridded_dims/dim_2/name', _RC)
      @assert_that(found, is(true()))
      found = ESMF_InfoIsPresent(info, key='MAPL/ungridded_dims/dim_2/units', _RC)
      @assert_that(found, is(true()))
      found = ESMF_InfoIsPresent(info, key='MAPL/ungridded_dims/dim_2/coordinates', _RC)
      @assert_that(found, is(true()))
      call ESMF_InfoGetAlloc(info, 'MAPL/ungridded_dims/dim_2/coordinates', coords, _RC)
      @assert_that(coords, equal_to([1.,2.,3.]))

      found = ESMF_InfoIsPresent(info, key='MAPL/standard_name', _RC)
      @assert_that(found, is(true()))
      call ESMF_InfoGetCharAlloc(info, 'MAPL/standard_name', temp_string, _RC)
      @assert_that(temp_string, equal_to("t"))

      found = ESMF_InfoIsPresent(info, key='MAPL/long_name', _RC)
      @assert_that(found, is(true()))
      call ESMF_InfoGetCharAlloc(info, 'MAPL/long_name', temp_string, _RC)
      @assert_that(temp_string, equal_to("p"))

      found = ESMF_InfoIsPresent(info, key='MAPL/units', _RC)
      @assert_that(found, is(true()))
      call ESMF_InfoGetCharAlloc(info, 'MAPL/units', temp_string, _RC)
      @assert_that(temp_string, equal_to("unknown"))

   end subroutine test_field_set_info