test_add_variable Subroutine

public subroutine test_add_variable()

Arguments

None

Calls

proc~~test_add_variable~~CallsGraph proc~test_add_variable test_add_variable assertequal assertequal proc~test_add_variable->assertequal asserttrue asserttrue proc~test_add_variable->asserttrue none~add_attribute~2 Variable%add_attribute proc~test_add_variable->none~add_attribute~2 none~add_dimension FileMetadata%add_dimension proc~test_add_variable->none~add_dimension none~add_variable~2 FileMetadata%add_variable proc~test_add_variable->none~add_variable~2 none~create NetCDF4_FileFormatter%create proc~test_add_variable->none~create 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~2->at begin begin none~add_variable~2->begin get get none~add_variable~2->get interface~mapl_assert MAPL_Assert none~add_variable~2->interface~mapl_assert next next none~add_variable~2->next none~get_const_value Variable%get_const_value none~add_variable~2->none~get_const_value none~get_dimensions Variable%get_dimensions none~add_variable~2->none~get_dimensions none~get_shape UnlimitedEntity%get_shape none~add_variable~2->none~get_shape none~insert~7 StringVariableMap%insert none~add_variable~2->none~insert~7 none~is_empty UnlimitedEntity%is_empty none~add_variable~2->none~is_empty none~add_variable~2->proc~mapl_return push_back push_back none~add_variable~2->push_back 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_1d->proc~mapl_return none~insert~98 StringAttributeMap%insert none~add_attribute_1d->none~insert~98 none~get_shape->proc~mapl_return none~insert_pair StringVariableMap%insert_pair none~insert~7->none~insert_pair 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~12 StringAttributeMap%insert_pair none~insert~98->none~insert_pair~12

Source Code

   subroutine test_add_variable()
      type (NetCDF4_FileFormatter) :: formatter
      type (FileMetadata) :: cf_expected
      type (FileMetadata) :: cf_found
      type (Variable) :: v,v1
      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_WRITE, rc=status)
      @assertEqual(NF90_NOERR, status)
      v1 = Variable(type=pFIO_INT32, dimensions='x,y')
      call cf_expected%add_variable('new_var', v1)
      call formatter%add_variable(cf_expected,'new_var', rc=status)
      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_add_variable