Skip to content

Commit a4d9ffc

Browse files
committed
bugfix: explict slice length, fixes old stability issues with ifort and old gcc
1 parent d5f1d46 commit a4d9ffc

File tree

4 files changed

+22
-48
lines changed

4 files changed

+22
-48
lines changed

codemeta.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"downloadUrl": "https://github.com/scivision/h5fortran/releases",
88
"issueTracker": "https://github.com/scivision/h5fortran/issues",
99
"name": "h5fortran",
10-
"version": "4.4.3",
10+
"version": "4.4.4",
1111
"identifier": "10.5281/zenodo.3757269",
1212
"description": "Lightweight object-oriented HDF5 Fortran interface",
1313
"applicationCategory": "file I/O",

src/interface.f90

Lines changed: 19 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ module subroutine hdf_create(self, dname, dtype, dims, sid, did, chunk_size, ist
110110
integer(HID_T), intent(in) :: dtype
111111
integer(HSIZE_T), intent(in) :: dims(:)
112112
integer(HID_T), intent(out), optional :: sid, did
113-
integer, intent(in), optional :: chunk_size(:), istart(:), iend(:), stride(:)
113+
integer, intent(in), dimension(size(dims)), optional :: chunk_size, istart, iend, stride
114114
logical, intent(in), optional :: compact
115115
!! keep istart, iend, stride for future slice shape check
116116
end subroutine hdf_create
@@ -137,37 +137,31 @@ module logical function h5exist(filename, dname)
137137
character(*), intent(in) :: filename, dname
138138
end function h5exist
139139

140-
141140
module subroutine lt0write(filename, dname, value)
142141
character(*), intent(in) :: filename, dname
143142
class(*), intent(in) :: value
144143
end subroutine lt0write
145144

146-
147145
module subroutine lt1write(filename, dname, value)
148146
character(*), intent(in) :: filename, dname
149147
class(*), intent(in) :: value(:)
150148
end subroutine lt1write
151149

152-
153150
module subroutine lt2write(filename, dname, value)
154151
character(*), intent(in) :: filename, dname
155152
class(*), intent(in) :: value(:,:)
156153
end subroutine lt2write
157154

158-
159155
module subroutine lt3write(filename, dname, value)
160156
character(*), intent(in) :: filename, dname
161157
class(*), intent(in) :: value(:,:,:)
162158
end subroutine lt3write
163159

164-
165160
module subroutine lt4write(filename, dname, value)
166161
character(*), intent(in) :: filename, dname
167162
class(*), intent(in) :: value(:,:,:,:)
168163
end subroutine lt4write
169164

170-
171165
module subroutine lt5write(filename, dname, value)
172166
character(*), intent(in) :: filename, dname
173167
class(*), intent(in) :: value(:,:,:,:,:)
@@ -185,6 +179,7 @@ end subroutine lt7write
185179

186180
end interface
187181

182+
188183
interface !< reader_lt.f90
189184
module subroutine lt0read(filename, dname, value)
190185
character(*), intent(in) :: filename, dname
@@ -242,62 +237,55 @@ module subroutine h5write_1d(self, dname, value, chunk_size, istart, iend, strid
242237
class(hdf5_file), intent(inout) :: self
243238
character(*), intent(in) :: dname
244239
class(*), intent(in) :: value(:)
245-
integer, intent(in), optional :: chunk_size(1)
246-
integer, intent(in), optional, dimension(:) :: istart, iend, stride
240+
integer, intent(in), dimension(1), optional :: chunk_size, istart, iend, stride
247241
logical, intent(in), optional :: compact
248242
end subroutine h5write_1d
249243

250244
module subroutine h5write_2d(self, dname, value, chunk_size, istart, iend, stride, compact)
251245
class(hdf5_file), intent(inout) :: self
252246
character(*), intent(in) :: dname
253247
class(*), intent(in) :: value(:,:)
254-
integer, intent(in), optional :: chunk_size(2)
255-
integer, intent(in), optional, dimension(:) :: istart, iend, stride
248+
integer, intent(in), dimension(2), optional :: chunk_size, istart, iend, stride
256249
logical, intent(in), optional :: compact
257250
end subroutine h5write_2d
258251

259252
module subroutine h5write_3d(self, dname, value, chunk_size, istart, iend, stride, compact)
260253
class(hdf5_file), intent(inout) :: self
261254
character(*), intent(in) :: dname
262255
class(*), intent(in) :: value(:,:,:)
263-
integer, intent(in), optional :: chunk_size(3)
264-
integer, intent(in), optional, dimension(:) :: istart, iend, stride
256+
integer, intent(in), dimension(3), optional :: chunk_size, istart, iend, stride
265257
logical, intent(in), optional :: compact
266258
end subroutine h5write_3d
267259

268260
module subroutine h5write_4d(self, dname, value, chunk_size, istart, iend, stride, compact)
269261
class(hdf5_file), intent(inout) :: self
270262
character(*), intent(in) :: dname
271263
class(*), intent(in) :: value(:,:,:,:)
272-
integer, intent(in), optional :: chunk_size(4)
273-
integer, intent(in), optional, dimension(:) :: istart, iend, stride
264+
integer, intent(in), dimension(4), optional :: chunk_size, istart, iend, stride
274265
logical, intent(in), optional :: compact
275266
end subroutine h5write_4d
276267

277268
module subroutine h5write_5d(self, dname, value, chunk_size, istart, iend, stride, compact)
278269
class(hdf5_file), intent(inout) :: self
279270
character(*), intent(in) :: dname
280271
class(*), intent(in) :: value(:,:,:,:,:)
281-
integer, intent(in), optional :: chunk_size(5)
282-
integer, intent(in), optional, dimension(:) :: istart, iend, stride
272+
integer, intent(in), dimension(5), optional :: chunk_size, istart, iend, stride
283273
logical, intent(in), optional :: compact
284274
end subroutine h5write_5d
285275

286276
module subroutine h5write_6d(self, dname, value, chunk_size, istart, iend, stride, compact)
287277
class(hdf5_file), intent(inout) :: self
288278
character(*), intent(in) :: dname
289279
class(*), intent(in) :: value(:,:,:,:,:,:)
290-
integer, intent(in), optional :: chunk_size(6)
291-
integer, intent(in), optional, dimension(:) :: istart, iend, stride
280+
integer, intent(in), dimension(6), optional :: chunk_size, istart, iend, stride
292281
logical, intent(in), optional :: compact
293282
end subroutine h5write_6d
294283

295284
module subroutine h5write_7d(self,dname,value, chunk_size, istart, iend, stride, compact)
296285
class(hdf5_file), intent(inout) :: self
297286
character(*), intent(in) :: dname
298287
class(*), intent(in) :: value(:,:,:,:,:,:,:)
299-
integer, intent(in), optional :: chunk_size(7)
300-
integer, intent(in), optional, dimension(:) :: istart, iend, stride
288+
integer, intent(in), dimension(7), optional :: chunk_size, istart, iend, stride
301289
logical, intent(in), optional :: compact
302290
end subroutine h5write_7d
303291

@@ -357,49 +345,49 @@ module subroutine h5read_1d(self, dname, value, istart, iend, stride)
357345
class(hdf5_file), intent(in) :: self
358346
character(*), intent(in) :: dname
359347
class(*), intent(inout) :: value(:)
360-
integer, intent(in), optional, dimension(:) :: istart, iend, stride
348+
integer, intent(in), dimension(1), optional :: istart, iend, stride
361349
end subroutine h5read_1d
362350

363351
module subroutine h5read_2d(self, dname, value, istart, iend, stride)
364352
class(hdf5_file), intent(in) :: self
365353
character(*), intent(in) :: dname
366354
class(*), intent(inout) :: value(:,:)
367-
integer, intent(in), optional, dimension(:) :: istart, iend, stride
355+
integer, intent(in), dimension(2), optional :: istart, iend, stride
368356
end subroutine h5read_2d
369357

370358
module subroutine h5read_3d(self, dname, value, istart, iend, stride)
371359
class(hdf5_file), intent(in) :: self
372360
character(*), intent(in) :: dname
373361
class(*), intent(inout) :: value(:,:,:)
374-
integer, intent(in), optional, dimension(:) :: istart, iend, stride
362+
integer, intent(in), dimension(3), optional :: istart, iend, stride
375363
end subroutine h5read_3d
376364

377365
module subroutine h5read_4d(self, dname, value, istart, iend, stride)
378366
class(hdf5_file), intent(in) :: self
379367
character(*), intent(in) :: dname
380368
class(*), intent(inout) :: value(:,:,:,:)
381-
integer, intent(in), optional, dimension(:) :: istart, iend, stride
369+
integer, intent(in), dimension(4), optional :: istart, iend, stride
382370
end subroutine h5read_4d
383371

384372
module subroutine h5read_5d(self, dname, value, istart, iend, stride)
385373
class(hdf5_file), intent(in) :: self
386374
character(*), intent(in) :: dname
387375
class(*), intent(inout) :: value(:,:,:,:,:)
388-
integer, intent(in), optional, dimension(:) :: istart, iend, stride
376+
integer, intent(in), dimension(5), optional :: istart, iend, stride
389377
end subroutine h5read_5d
390378

391379
module subroutine h5read_6d(self, dname, value, istart, iend, stride)
392380
class(hdf5_file), intent(in) :: self
393381
character(*), intent(in) :: dname
394382
class(*), intent(inout) :: value(:,:,:,:,:,:)
395-
integer, intent(in), optional, dimension(:) :: istart, iend, stride
383+
integer, intent(in), dimension(6), optional :: istart, iend, stride
396384
end subroutine h5read_6d
397385

398386
module subroutine h5read_7d(self, dname, value, istart, iend, stride)
399387
class(hdf5_file), intent(in) :: self
400388
character(*), intent(in) :: dname
401389
class(*), intent(inout) :: value(:,:,:,:,:,:,:)
402-
integer, intent(in), optional, dimension(:) :: istart, iend, stride
390+
integer, intent(in), dimension(7), optional :: istart, iend, stride
403391
end subroutine h5read_7d
404392
end interface
405393

@@ -736,17 +724,13 @@ subroutine hdf_get_slice(self, dname, did, sid, mem_sid, i0, i1, i2)
736724
character(*), intent(in) :: dname
737725
integer(HID_T), intent(inout) :: did !< inout for sentinel value
738726
integer(hid_t), intent(out) :: sid, mem_sid
739-
class(*), intent(in), dimension(:) :: i0, i1
740-
class(*), intent(in), optional, dimension(:) :: i2
727+
class(*), intent(in), dimension(:) :: i0
728+
class(*), intent(in), dimension(size(i0)) :: i1
729+
class(*), intent(in), dimension(size(i0)), optional :: i2
741730

742731
integer(hsize_t), dimension(size(i0)) :: istart, iend, stride, mem_dims
743732
integer :: ierr
744733

745-
if (size(i0) /= size(i1)) error stop "istart and iend must have equal length"
746-
if (present(i2)) then
747-
if (size(i0) /= size(i2)) error stop "istride must be same length as istart and iend"
748-
endif
749-
750734
if(.not.self%is_open) error stop 'h5fortran:slice: file handle is not open'
751735

752736
!! istart

src/read/reader_template.f90

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,7 @@
99
dims = shape(value, HSIZE_T)
1010

1111
if(present(istart) .and. present(iend)) then
12-
if (present(stride)) then
13-
!! necessary to use this present check for Intel and GCC
14-
call hdf_get_slice(self, dname, dset_id, file_space_id, mem_space_id, istart, iend, stride)
15-
else
16-
call hdf_get_slice(self, dname, dset_id, file_space_id, mem_space_id, istart, iend)
17-
endif
12+
call hdf_get_slice(self, dname, dset_id, file_space_id, mem_space_id, istart, iend, stride)
1813
else
1914
call hdf_shape_check(self, dname, dims)
2015
call h5dopen_f(self%lid, dname, dset_id, ier)

src/write/writer_template.f90

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,7 @@
2424
mem_space_id = H5S_ALL_F !< default
2525

2626
if(present(istart) .and. present(iend)) then
27-
if(present(stride)) then
28-
!! necessary to use this present check for Intel and GCC
29-
call hdf_get_slice(self, dname, dset_id, file_space_id, mem_space_id, istart, iend, stride)
30-
else
31-
call hdf_get_slice(self, dname, dset_id, file_space_id, mem_space_id, istart, iend)
32-
endif
27+
call hdf_get_slice(self, dname, dset_id, file_space_id, mem_space_id, istart, iend, stride)
3328
endif
3429

3530
select type (value)

0 commit comments

Comments
 (0)