Skip to content

Commit 78713b4

Browse files
scivisionjvdp1
andcommitted
correct very-long missing feature of reading with stride
Co-authored-by: jvdp1 <jvdp1@users.noreply.github.com>
1 parent 134fc97 commit 78713b4

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/utils.f90

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,10 +332,12 @@
332332
istride = 1
333333
if(present(stride)) istride = int(stride, HSIZE_T)
334334

335-
!! NOTE: 0-based hyperslab vs. 1-based Fortran
335+
!! NOTE: indices of 0-based hyperslab vs. 1-based Fortran indices
336336
i0 = istart - 1
337337
c_mem_dims = iend - i0
338338

339+
if (any(istride > 1)) c_mem_dims = merge(c_mem_dims/istride, c_mem_dims/istride + 1, mod(c_mem_dims, istride)==0)
340+
339341
if(size(mem_dims) == 0) then
340342
!! rank(dims(0)) == 1, but size(dims(0)) == 0
341343
if (sum(c_mem_dims) /= 1) error stop "ERROR:h5fortran:hdf_get_slice: scalar index of array failed " // dset_name

test/test_array.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ program array_test
1010
print *, 'PASSED: array write'
1111

1212
call test_read_slice('test_array.h5')
13-
print *, 'PASSED: slice read'
13+
print *, 'PASSED: slice read with or without stride'
1414

1515
call test_write_slice('test_array.h5')
1616
print *, 'PASSED: slice write'

0 commit comments

Comments
 (0)