test_same_n_levels_do_not_reallocate Subroutine

public subroutine test_same_n_levels_do_not_reallocate(this)

Arguments

Type IntentOptional Attributes Name
class(ESMF_TestMethod), intent(inout) :: this

Calls

proc~~test_same_n_levels_do_not_reallocate~~CallsGraph proc~test_same_n_levels_do_not_reallocate test_same_n_levels_do_not_reallocate ESMF_GeomCreate ESMF_GeomCreate proc~test_same_n_levels_do_not_reallocate->ESMF_GeomCreate ESMF_GeomDestroy ESMF_GeomDestroy proc~test_same_n_levels_do_not_reallocate->ESMF_GeomDestroy ESMF_GridCreateNoPeriDim ESMF_GridCreateNoPeriDim proc~test_same_n_levels_do_not_reallocate->ESMF_GridCreateNoPeriDim ESMF_GridDestroy ESMF_GridDestroy proc~test_same_n_levels_do_not_reallocate->ESMF_GridDestroy anyexceptions anyexceptions proc~test_same_n_levels_do_not_reallocate->anyexceptions assert_that assert_that proc~test_same_n_levels_do_not_reallocate->assert_that esmf_fielddestroy esmf_fielddestroy proc~test_same_n_levels_do_not_reallocate->esmf_fielddestroy esmf_fieldget esmf_fieldget proc~test_same_n_levels_do_not_reallocate->esmf_fieldget interface~mapl_fieldcreate~2 MAPL_FieldCreate proc~test_same_n_levels_do_not_reallocate->interface~mapl_fieldcreate~2 none~add_dim UngriddedDims%add_dim proc~test_same_n_levels_do_not_reallocate->none~add_dim none~reallocate_field FieldDelta%reallocate_field proc~test_same_n_levels_do_not_reallocate->none~reallocate_field sourcelocation sourcelocation proc~test_same_n_levels_do_not_reallocate->sourcelocation true true proc~test_same_n_levels_do_not_reallocate->true interface~mapl_assert MAPL_Assert none~add_dim->interface~mapl_assert none~get_name~6 UngriddedDim%get_name none~add_dim->none~get_name~6 none~get_num_ungridded UngriddedDims%get_num_ungridded none~add_dim->none~get_num_ungridded none~push_back~79 UngriddedDimVector%push_back none~add_dim->none~push_back~79 proc~mapl_return MAPL_Return none~add_dim->proc~mapl_return none~reallocate_field->esmf_fieldget esmf_arraydestroy esmf_arraydestroy none~reallocate_field->esmf_arraydestroy esmf_fieldemptycomplete esmf_fieldemptycomplete none~reallocate_field->esmf_fieldemptycomplete esmf_fieldemptyset esmf_fieldemptyset none~reallocate_field->esmf_fieldemptyset interface~fieldgetlocalelementcount FieldGetLocalElementCount none~reallocate_field->interface~fieldgetlocalelementcount none~reallocate_field->interface~mapl_assert interface~mapl_fieldget MAPL_FieldGet none~reallocate_field->interface~mapl_fieldget none~reallocate_field->proc~mapl_return proc~mapl_verify MAPL_Verify none~reallocate_field->proc~mapl_verify none~capacity~469 UngriddedDimVector%capacity none~push_back~79->none~capacity~469 none~resize~158 UngriddedDimVector%resize none~push_back~79->none~resize~158 at at proc~mapl_return->at insert insert proc~mapl_return->insert proc~mapl_throw_exception MAPL_throw_exception proc~mapl_return->proc~mapl_throw_exception proc~mapl_verify->proc~mapl_throw_exception none~resize_size_kind~25 UngriddedDimVector%resize_size_kind none~resize~158->none~resize_size_kind~25

Source Code

   subroutine test_same_n_levels_do_not_reallocate(this)
      class(ESMF_TestMethod), intent(inout) :: this
      type(ESMF_Field) :: f
      type(ESMF_Grid) :: grid
      type(ESMF_Geom) :: geom, other_geom

      integer :: status
      type(ESMF_FieldStatus_Flag) :: field_status
      real(ESMF_KIND_R4), pointer :: x(:,:,:,:)
      type(ESMF_TypeKind_Flag) :: typekind
      type(FieldDelta) :: delta
      type(UngriddedDims) :: ungridded_dims

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

      call ungridded_dims%add_dim(UngriddedDim(3))
      f = MAPL_FieldCreate(geom=geom, typekind=ESMF_TYPEKIND_R4, &
          num_levels=ORIG_VGRID_LEVELS,  ungridded_dims=ungridded_dims, &
          vert_staggerloc=VERTICAL_STAGGER_CENTER, _RC)
      call ESMF_FieldGet(f, fArrayPtr=x, _RC)
      x = FILL_VALUE

      delta = FieldDelta(num_levels=ORIG_VGRID_LEVELS)
      call delta%reallocate_field(f, _RC)

      call ESMF_FieldGet(f, status=field_status, typekind=typekind, geom=other_geom, _RC)
      @assert_that(field_status == ESMF_FIELDSTATUS_COMPLETE, is(true()))
      @assert_that(typekind == ESMF_TYPEKIND_R4, is(true()))
      @assert_that(other_geom == geom, is(true()))

      ! Check that Field data is unchanged
      call ESMF_FieldGet(f, fArrayPtr=x, _RC)
      @assert_that(all(x == FILL_VALUE), is(true()))

      call ESMF_FieldDestroy(f, _RC)
      call ESMF_GridDestroy(grid, _RC)
      call ESMF_GeomDestroy(geom, _RC)

      _UNUSED_DUMMY(this)
   end subroutine test_same_n_levels_do_not_reallocate