#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