subroutine test_get_attribute_scalar() type (FileMetadata), target :: cf type (Attribute), pointer :: attr integer, allocatable :: shape(:) class (*), pointer :: value integer :: i = 4 real(REAL32) :: x32 = 1.234 real(REAL64) :: x64 = 2.345_REAL64 logical :: flag = .true. character(len=*), parameter :: str = 'kitty' call cf%add_attribute('i', i) call cf%add_attribute('x32', x32) call cf%add_attribute('x64', x64) call cf%add_attribute('flag', flag) call cf%add_attribute('string', str) attr => cf%get_attribute('i') @assertTrue(associated(attr)) shape = attr%get_shape() @assertEqual(EMPTY, shape) value => attr%get_value() @assertTrue(associated(value)) select type (v => value) type is (integer) @assertEqual(i, v) class default @assertTrue(.false., 'incorrect type') end select attr => cf%get_attribute('x32') @assertTrue(associated(attr)) shape = attr%get_shape() @assertEqual(EMPTY, shape) value => attr%get_value() @assertTrue(associated(value)) select type (v => value) type is (real(REAL32)) @assertEqual(x32, v) class default @assertTrue(.false., 'incorrect type') end select attr => cf%get_attribute('x64') @assertTrue(associated(attr)) shape = attr%get_shape() @assertEqual(EMPTY, shape) value => attr%get_value() @assertTrue(associated(value)) select type (v => value) type is (real(REAL64)) @assertEqual(x64, v) class default @assertTrue(.false., 'incorrect type') end select attr => cf%get_attribute('flag') @assertTrue(associated(attr)) shape = attr%get_shape() @assertEqual(EMPTY, shape) value => attr%get_value() @assertTrue(associated(value)) select type (v => value) type is (logical) @assertTrue(flag .eqv. v) class default @assertTrue(.false., 'incorrect type') end select attr => cf%get_attribute('string') @assertTrue(associated(attr)) shape = attr%get_shape() @assertEqual(EMPTY, shape) value => attr%get_value() @assertTrue(associated(value)) select type (v => value) type is (character(len=*)) @assertEqual(str, v) type is (StringWrap) @assertEqual(str, v%value) class default @assertTrue(.false., 'incorrect type') end select end subroutine test_get_attribute_scalar