Skip to content

Commit 396ab0f

Browse files
committed
test_array: add subarray read/write that show c_loc h5dwrite/h5dread not suitable
1 parent 6670ba4 commit 396ab0f

File tree

2 files changed

+38
-10
lines changed

2 files changed

+38
-10
lines changed

test/mpi/test_array.f90

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -63,19 +63,22 @@ subroutine test_basic_array(filename)
6363
i2(i,:) = i2(1,:) * i
6464
enddo
6565

66+
i2_8(3:6, 4:7) = i2
67+
6668
r1 = i1
6769
r2 = i2
6870

69-
if(mpi_id == 0) then
70-
call h%open(filename, action='w', comp_lvl=1, mpi=.false.)
71+
call h%open(filename, action='w', comp_lvl=1, mpi=.true.)
7172

72-
call h%write('/int32-1d', i1)
73-
call h%write('/test/group2/int32-2d', i2)
74-
call h%write('/real32-2d', r2)
75-
call h%write('/nan', nan)
73+
call h%write('/int32-1d', i1)
74+
call h%write('/test/group2/int32-2d', i2)
75+
call h%write('/real32-2d', r2)
76+
call h%write('/nan', nan)
77+
!> write from subarray
78+
call h%write('/sub-int32-2d', i2_8(3:6, 4:7))
79+
print '(4i3)', i2_8(3:6, 4:7)
7680

77-
call h%close()
78-
endif
81+
call h%close()
7982

8083
!! read
8184
call h%open(filename, action='r', mpi=.true.)
@@ -90,7 +93,17 @@ subroutine test_basic_array(filename)
9093
!> verify reading into larger array
9194
i2_8 = 0
9295
call h%read('/test/group2/int32-2d', i2_8(2:5,3:6))
93-
if (.not.all(i2_8(2:5,3:6) == i2)) error stop 'read into larger array fail'
96+
if (.not.all(i2_8(2:5,3:6) == i2)) then
97+
write(stderr, '(a,4i3)') 'read 2-D: int32 slice does not match write: ', i2_8(2:5,3:6)
98+
error stop 'ERROR: read into larger array fail'
99+
endif
100+
101+
!> verify reading written subarray
102+
call h%read('/sub-int32-2d', i2t)
103+
if (.not.all(i2==i2t)) then
104+
write(stderr, '(a,4i3)') 'read 2-D: int32 write subarray slice does not match: ', i2t
105+
error stop 'ERROR: read into larger array fail'
106+
endif
94107

95108
!> real
96109
call h%shape('/real32-2d',dims)

test/nompi/test_array.f90

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ subroutine test_basic_array(filename)
4949
i2(i,:) = i2(1,:) * i
5050
enddo
5151

52+
i2_8(3:6, 4:7) = i2
53+
5254
r1 = i1
5355
r2 = i2
5456

@@ -58,6 +60,9 @@ subroutine test_basic_array(filename)
5860
call h%write('/test/group2/int32-2d', i2)
5961
call h%write('/real32-2d', r2)
6062
call h%write('/nan', nan)
63+
!> write from subarray
64+
call h%write('/sub-int32-2d', i2_8(3:6, 4:7))
65+
print '(4i3)', i2_8(3:6, 4:7)
6166

6267
call h%close()
6368

@@ -74,7 +79,17 @@ subroutine test_basic_array(filename)
7479
!> verify reading into larger array
7580
i2_8 = 0
7681
call h%read('/test/group2/int32-2d', i2_8(2:5,3:6))
77-
if (.not.all(i2_8(2:5,3:6) == i2)) error stop 'read into larger array fail'
82+
if (.not.all(i2_8(2:5,3:6) == i2)) then
83+
write(stderr, '(a,4i3)') 'read 2-D: int32 slice does not match write: ', i2_8(2:5,3:6)
84+
error stop 'ERROR: read into larger array fail'
85+
endif
86+
87+
!> verify reading written subarray
88+
call h%read('/sub-int32-2d', i2t)
89+
if (.not.all(i2==i2t)) then
90+
write(stderr, '(a,4i3)') 'read 2-D: int32 write subarray slice does not match: ', i2t
91+
error stop 'ERROR: read into larger array fail'
92+
endif
7893

7994
!> real
8095
call h%shape('/real32-2d',dims)

0 commit comments

Comments
 (0)