test_write_read_simple_attribute Subroutine

public subroutine test_write_read_simple_attribute()

Arguments

None

Calls

proc~~test_write_read_simple_attribute~~CallsGraph proc~test_write_read_simple_attribute test_write_read_simple_attribute assertequal assertequal proc~test_write_read_simple_attribute->assertequal asserttrue asserttrue proc~test_write_read_simple_attribute->asserttrue none~add_attribute~3 FileMetadata%add_attribute proc~test_write_read_simple_attribute->none~add_attribute~3 none~add_dimension FileMetadata%add_dimension proc~test_write_read_simple_attribute->none~add_dimension none~create NetCDF4_FileFormatter%create proc~test_write_read_simple_attribute->none~create none~add_attribute_0d~2 FileMetadata%add_attribute_0d none~add_attribute~3->none~add_attribute_0d~2 none~add_attribute_1d~2 FileMetadata%add_attribute_1d none~add_attribute~3->none~add_attribute_1d~2 insert insert none~add_dimension->insert proc~mapl_return MAPL_Return none~add_dimension->proc~mapl_return nf90_create nf90_create none~create->nf90_create none~create->proc~mapl_return proc~mapl_verify MAPL_Verify none~create->proc~mapl_verify none~add_attribute_0d~2->proc~mapl_return none~add_attribute~2 Variable%add_attribute none~add_attribute_0d~2->none~add_attribute~2 none~add_attribute_1d~2->proc~mapl_return none~add_attribute_1d~2->none~add_attribute~2 proc~mapl_return->insert at at proc~mapl_return->at proc~mapl_throw_exception MAPL_throw_exception proc~mapl_return->proc~mapl_throw_exception proc~mapl_verify->proc~mapl_throw_exception none~add_attribute_1d Variable%add_attribute_1d none~add_attribute~2->none~add_attribute_1d

Source Code

   subroutine test_write_read_simple_attribute()
      type (NetCDF4_FileFormatter) :: formatter
      type (FileMetadata) :: cf_expected
      type (FileMetadata) :: cf_found
      integer :: status

      call cf_expected%add_dimension('x',1)
      call cf_expected%add_dimension('y',2)
      call cf_expected%add_attribute('attr', [1,2])

      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_simple_attribute