Test_FieldInfo.pf Source File


This file depends on

sourcefile~~test_fieldinfo.pf~~EfferentGraph sourcefile~test_fieldinfo.pf Test_FieldInfo.pf sourcefile~basicverticalgrid.f90 BasicVerticalGrid.F90 sourcefile~test_fieldinfo.pf->sourcefile~basicverticalgrid.f90 sourcefile~fieldspec.f90~2 FieldSpec.F90 sourcefile~test_fieldinfo.pf->sourcefile~fieldspec.f90~2 sourcefile~ungriddeddim.f90 UngriddedDim.F90 sourcefile~test_fieldinfo.pf->sourcefile~ungriddeddim.f90 sourcefile~ungriddeddims.f90 UngriddedDims.F90 sourcefile~test_fieldinfo.pf->sourcefile~ungriddeddims.f90 sourcefile~verticaldimspec.f90 VerticalDimSpec.F90 sourcefile~test_fieldinfo.pf->sourcefile~verticaldimspec.f90 sourcefile~errorhandling.f90 ErrorHandling.F90 sourcefile~basicverticalgrid.f90->sourcefile~errorhandling.f90 sourcefile~griddedcomponentdriver.f90 GriddedComponentDriver.F90 sourcefile~basicverticalgrid.f90->sourcefile~griddedcomponentdriver.f90 sourcefile~verticalgrid.f90 VerticalGrid.F90 sourcefile~basicverticalgrid.f90->sourcefile~verticalgrid.f90 sourcefile~fieldspec.f90~2->sourcefile~basicverticalgrid.f90 sourcefile~fieldspec.f90~2->sourcefile~ungriddeddims.f90 sourcefile~fieldspec.f90~2->sourcefile~verticaldimspec.f90 sourcefile~abstractactionspec.f90 AbstractActionSpec.F90 sourcefile~fieldspec.f90~2->sourcefile~abstractactionspec.f90 sourcefile~actualconnectionpt.f90 ActualConnectionPt.F90 sourcefile~fieldspec.f90~2->sourcefile~actualconnectionpt.f90 sourcefile~actualptspecptrmap.f90 ActualPtSpecPtrMap.F90 sourcefile~fieldspec.f90~2->sourcefile~actualptspecptrmap.f90 sourcefile~actualptvector.f90 ActualPtVector.F90 sourcefile~fieldspec.f90~2->sourcefile~actualptvector.f90 sourcefile~convertunitsaction.f90 ConvertUnitsAction.F90 sourcefile~fieldspec.f90~2->sourcefile~convertunitsaction.f90 sourcefile~copyaction.f90 CopyAction.F90 sourcefile~fieldspec.f90~2->sourcefile~copyaction.f90 sourcefile~fieldspec.f90~2->sourcefile~errorhandling.f90 sourcefile~esmf_utilities.f90 ESMF_Utilities.F90 sourcefile~fieldspec.f90~2->sourcefile~esmf_utilities.f90 sourcefile~extensionaction.f90 ExtensionAction.F90 sourcefile~fieldspec.f90~2->sourcefile~extensionaction.f90 sourcefile~fielddictionary.f90 FieldDictionary.F90 sourcefile~fieldspec.f90~2->sourcefile~fielddictionary.f90 sourcefile~geom_mgr.f90 geom_mgr.F90 sourcefile~fieldspec.f90~2->sourcefile~geom_mgr.f90 sourcefile~fieldspec.f90~2->sourcefile~griddedcomponentdriver.f90 sourcefile~keywordenforcer.f90 KeywordEnforcer.F90 sourcefile~fieldspec.f90~2->sourcefile~keywordenforcer.f90 sourcefile~lu_bound.f90 LU_Bound.F90 sourcefile~fieldspec.f90~2->sourcefile~lu_bound.f90 sourcefile~multistate.f90 MultiState.F90 sourcefile~fieldspec.f90~2->sourcefile~multistate.f90 sourcefile~nullaction.f90 NullAction.F90 sourcefile~fieldspec.f90~2->sourcefile~nullaction.f90 sourcefile~regridaction.f90 RegridAction.F90 sourcefile~fieldspec.f90~2->sourcefile~regridaction.f90 sourcefile~stateitemspec.f90 StateItemSpec.F90 sourcefile~fieldspec.f90~2->sourcefile~stateitemspec.f90 sourcefile~udunits2f.f90 udunits2f.F90 sourcefile~fieldspec.f90~2->sourcefile~udunits2f.f90 sourcefile~variablespec.f90 VariableSpec.F90 sourcefile~fieldspec.f90~2->sourcefile~variablespec.f90 sourcefile~fieldspec.f90~2->sourcefile~verticalgrid.f90 sourcefile~verticalregridaction.f90 VerticalRegridAction.F90 sourcefile~fieldspec.f90~2->sourcefile~verticalregridaction.f90 sourcefile~wildcardspec.f90 WildcardSpec.F90 sourcefile~fieldspec.f90~2->sourcefile~wildcardspec.f90 sourcefile~ungriddeddim.f90->sourcefile~errorhandling.f90 sourcefile~ungriddeddim.f90->sourcefile~lu_bound.f90 sourcefile~ungriddeddims.f90->sourcefile~ungriddeddim.f90 sourcefile~ungriddeddims.f90->sourcefile~errorhandling.f90 sourcefile~ungriddeddims.f90->sourcefile~lu_bound.f90 sourcefile~ungriddeddimvector.f90 UngriddedDimVector.F90 sourcefile~ungriddeddims.f90->sourcefile~ungriddeddimvector.f90 sourcefile~verticaldimspec.f90->sourcefile~errorhandling.f90

Source Code

#include "MAPL_TestErr.h"
module Test_FieldInfo
   use mapl3g_FieldSpec
   use mapl3g_VerticalDimSpec
   use mapl3g_BasicVerticalGrid
   use mapl3g_UngriddedDims
   use mapl3g_UngriddedDim
   use esmf
   use funit
   implicit none

contains

   @test
   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
end module Test_FieldInfo