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_NetCDF4_FileFormatter::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 pFIO_VariableMod::Variable%add_attribute proc~test_write_read_variable_attribute->none~add_attribute none~add_dimension pFIO_FileMetadataMod::FileMetadata%add_dimension proc~test_write_read_variable_attribute->none~add_dimension none~add_variable pFIO_FileMetadataMod::FileMetadata%add_variable proc~test_write_read_variable_attribute->none~add_variable none~create pFIO_NetCDF4_FileFormatterMod::NetCDF4_FileFormatter%create proc~test_write_read_variable_attribute->none~create none~add_attribute_1d pFIO_VariableMod::Variable%add_attribute_1d none~add_attribute->none~add_attribute_1d insert insert none~add_dimension->insert proc~mapl_return MAPL_ErrorHandlingMod::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_ErrorHandlingMod::MAPL_Assert none~add_variable->interface~mapl_assert next next none~add_variable->next none~get_const_value pFIO_VariableMod::Variable%get_const_value none~add_variable->none~get_const_value none~get_dimensions pFIO_VariableMod::Variable%get_dimensions none~add_variable->none~get_dimensions none~get_shape pFIO_UnlimitedEntityMod::UnlimitedEntity%get_shape none~add_variable->none~get_shape none~insert~4 pFIO_StringVariableMapMod::StringVariableMap%insert none~add_variable->none~insert~4 none~is_empty pFIO_UnlimitedEntityMod::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->nf90_create none~create->proc~mapl_return proc~mapl_verify MAPL_ErrorHandlingMod::MAPL_Verify none~create->proc~mapl_verify none~add_attribute_1d->proc~mapl_return none~insert~2 pFIO_StringAttributeMapMod::StringAttributeMap%insert none~add_attribute_1d->none~insert~2 none~get_shape->proc~mapl_return none~insert_pair~3 pFIO_StringVariableMapMod::StringVariableMap%insert_pair none~insert~4->none~insert_pair~3 none~is_empty->proc~mapl_return none~get_value pFIO_UnlimitedEntityMod::UnlimitedEntity%get_value none~is_empty->none~get_value proc~mapl_return->at proc~mapl_return->insert proc~mapl_throw_exception MAPL_ThrowMod::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 pFIO_StringAttributeMapMod::StringAttributeMap%insert_pair none~insert~2->none~insert_pair

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