test_equal_diff_variables Subroutine

public subroutine test_equal_diff_variables()

Arguments

None

Calls

proc~~test_equal_diff_variables~~CallsGraph proc~test_equal_diff_variables test_equal_diff_variables assertfalse assertfalse proc~test_equal_diff_variables->assertfalse asserttrue asserttrue proc~test_equal_diff_variables->asserttrue none~add_attribute~3 Variable%add_attribute proc~test_equal_diff_variables->none~add_attribute~3 none~add_dimension FileMetadata%add_dimension proc~test_equal_diff_variables->none~add_dimension none~add_variable~2 FileMetadata%add_variable proc~test_equal_diff_variables->none~add_variable~2 none~modify_variable FileMetadata%modify_variable proc~test_equal_diff_variables->none~modify_variable none~add_attribute_1d~2 Variable%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 at at none~add_variable~2->at begin begin none~add_variable~2->begin 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~3 Variable%get_dimensions none~add_variable~2->none~get_dimensions~3 none~get_shape UnlimitedEntity%get_shape none~add_variable~2->none~get_shape none~insert~198 StringVariableMap%insert none~add_variable~2->none~insert~198 none~is_empty UnlimitedEntity%is_empty none~add_variable~2->none~is_empty of of none~add_variable~2->of none~add_variable~2->proc~mapl_return push_back push_back none~add_variable~2->push_back none~modify_variable->at none~modify_variable->begin none~modify_variable->interface~mapl_assert none~modify_variable->next none~modify_variable->none~get_dimensions~3 none~set~104 StringVariableMap%set none~modify_variable->none~set~104 none~modify_variable->of none~modify_variable->proc~mapl_return none~add_attribute_1d~2->proc~mapl_return none~insert~179 StringAttributeMap%insert none~add_attribute_1d~2->none~insert~179 none~get_shape->proc~mapl_return none~insert_pair~16 StringVariableMap%insert_pair none~insert~198->none~insert_pair~16 none~is_empty->proc~mapl_return none~get_value~23 UnlimitedEntity%get_value none~is_empty->none~get_value~23 proc~mapl_return->at proc~mapl_return->insert proc~mapl_throw_exception MAPL_throw_exception proc~mapl_return->proc~mapl_throw_exception none~get_value~23->proc~mapl_return none~insert_pair~15 StringAttributeMap%insert_pair none~insert~179->none~insert_pair~15

Source Code

   subroutine test_equal_diff_variables()
      type (FileMetadata) :: cf1, cf2
      type (Variable) :: v1, v2, v3

      call cf1%add_dimension('x', 10)
      call cf1%add_dimension('y', 20)
      call cf1%add_dimension('z', 30)
      cf2 = cf1

      v1 = Variable(type=pFIO_INT32, dimensions='x')
      v2 = Variable(type=pFIO_REAL64, dimensions='x,y,z')
      call v3%add_attribute('flag', .true.)

      call cf1%add_variable('v1', v1)
      @assertTrue(cf1 == cf1)
      @assertFalse(cf1 /= cf1)
      
      call cf1%add_variable('v2', v2)
      @assertFalse(cf1 == cf2)
      @assertFalse(cf2 == cf1)

      call cf2%add_variable('v2', v2)
      @assertFalse(cf1 == cf2)
      @assertFalse(cf2 == cf1)

      call cf2%add_variable('v1', v1)
      @assertTrue(cf1 == cf2)

      v3 = v1
      call cf1%add_variable('v3', v3)
      ! Modify v3 before adding to cf2
      ! Deep copy means v3 in cf1 is not affected.
      call v3%add_attribute('other', [1,2,3])
      call cf2%add_variable('v3', v3)
      @assertFalse(cf1 == cf2)

      ! get back to v1 
      call cf2%modify_variable('v3',v1)
      @assertTrue(cf1 == cf2)
      
   end subroutine test_equal_diff_variables