test_write_read_variable_attribute Subroutine

public subroutine test_write_read_variable_attribute()

Arguments

None

Calls

proc~~test_write_read_variable_attribute~~CallsGraph proc~test_write_read_variable_attribute test_write_read_variable_attribute assertequal assertequal proc~test_write_read_variable_attribute->assertequal asserttrue asserttrue proc~test_write_read_variable_attribute->asserttrue none~add_attribute~2 Variable%add_attribute proc~test_write_read_variable_attribute->none~add_attribute~2 none~add_dimension FileMetadata%add_dimension proc~test_write_read_variable_attribute->none~add_dimension none~add_variable FileMetadata%add_variable proc~test_write_read_variable_attribute->none~add_variable none~create~2 NetCDF4_FileFormatter%create proc~test_write_read_variable_attribute->none~create~2 none~add_attribute_1d Variable%add_attribute_1d none~add_attribute~2->none~add_attribute_1d insert insert none~add_dimension->insert proc~mapl_return MAPL_Return none~add_dimension->proc~mapl_return at at none~add_variable->at begin begin none~add_variable->begin get get none~add_variable->get interface~mapl_assert MAPL_Assert none~add_variable->interface~mapl_assert next next none~add_variable->next none~get_const_value Variable%get_const_value none~add_variable->none~get_const_value none~get_dimensions Variable%get_dimensions none~add_variable->none~get_dimensions none~get_shape UnlimitedEntity%get_shape none~add_variable->none~get_shape none~insert~104 StringVariableMap%insert none~add_variable->none~insert~104 none~is_empty UnlimitedEntity%is_empty none~add_variable->none~is_empty none~add_variable->proc~mapl_return push_back push_back none~add_variable->push_back nf90_create nf90_create none~create~2->nf90_create none~create~2->proc~mapl_return proc~mapl_verify MAPL_Verify none~create~2->proc~mapl_verify none~add_attribute_1d->proc~mapl_return none~insert~170 StringAttributeMap%insert none~add_attribute_1d->none~insert~170 none~get_shape->proc~mapl_return none~insert_pair~11 StringVariableMap%insert_pair none~insert~104->none~insert_pair~11 none~is_empty->proc~mapl_return none~get_value UnlimitedEntity%get_value none~is_empty->none~get_value proc~mapl_return->at 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~get_value->proc~mapl_return none~insert_pair~18 StringAttributeMap%insert_pair none~insert~170->none~insert_pair~18

Source Code

   subroutine test_write_read_variable_attribute()
      type (NetCDF4_FileFormatter) :: formatter
      type (FileMetadata) :: cf_expected
      type (FileMetadata) :: cf_found
      type (Variable) :: v
      integer :: status

      call cf_expected%add_dimension('x',1)
      call cf_expected%add_dimension('y',2)

      v = Variable(type=pFIO_INT32, dimensions='x,y')
      call v%add_attribute('attr', [1.,2.,3.])
      call cf_expected%add_variable('var', v)

      call formatter%create('test.nc', rc=status)
      @assertEqual(NF90_NOERR, status)
      call formatter%write(cf_expected, rc=status)
      @assertEqual(0, NF90_NOERR)
      call formatter%close(rc=status)
      @assertEqual(0, NF90_NOERR)

      call formatter%open('test.nc', mode=NF90_NOWRITE, rc=status)
      @assertEqual(0, NF90_NOERR)
      cf_found = formatter%read(rc=status)
      call formatter%close(rc=status)
      @assertEqual(0, NF90_NOERR)

      @assertTrue(cf_expected == cf_found)

   end subroutine test_write_read_variable_attribute