@@ -63,19 +63,22 @@ subroutine test_basic_array(filename)
6363 i2(i,:) = i2(1 ,:) * i
6464enddo
6565
66+ i2_8(3 :6 , 4 :7 ) = i2
67+
6668r1 = i1
6769r2 = 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
8184call h% open (filename, action= ' r' , mpi= .true. )
@@ -90,7 +93,17 @@ subroutine test_basic_array(filename)
9093! > verify reading into larger array
9194i2_8 = 0
9295call 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
96109call h% shape (' /real32-2d' ,dims)
0 commit comments