Skip to content

Commit 1ca4870

Browse files
authored
Add H5Dread_chunk2() (#5506)
1 parent 6beb047 commit 1ca4870

File tree

20 files changed

+1029
-186
lines changed

20 files changed

+1029
-186
lines changed

.github/workflows/netcdf.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ jobs:
7474
repository: unidata/netcdf-c
7575
path: netcdf-c
7676

77+
7778
- name: Test netCDF
7879
run: |
7980
cd netcdf-c

doxygen/dox/H5.format.2.0.dox

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ Values for all fields in this document should be treated as unsigned integers, u
143143
the description of a field. Additionally, all metadata fields are stored in little-endian byte order.
144144

145145
All checksums used in the format are computed with the
146-
<a href="http://www.burtleburtle.net/bob/hash/doobs.html">Jenkins&rsquo; lookup3</a> algorithm.
146+
<a href="https://www.burtleburtle.net/bob/hash/doobs.html">Jenkins&rsquo; lookup3</a> algorithm.
147147

148148
Whenever a bit flag or field is mentioned for an entry, bits are numbered from the lowest bit position
149149
in the entry.

doxygen/dox/H5.format.3.0.dox

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ Values for all fields in this document should be treated as unsigned integers, u
170170
the description of a field. Additionally, all metadata fields are stored in little-endian byte order.
171171

172172
All checksums used in the format are computed with the
173-
<a href="http://www.burtleburtle.net/bob/hash/doobs.html">Jenkins&rsquo; lookup3</a> algorithm.
173+
<a href="https://www.burtleburtle.net/bob/hash/doobs.html">Jenkins&rsquo; lookup3</a> algorithm.
174174

175175
Whenever a bit flag or field is mentioned for an entry, bits are numbered from the lowest bit position
176176
in the entry.

doxygen/examples/tables/volAPIs.dox

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,11 @@
5252
<td></td>
5353
</tr>
5454
<tr>
55-
<td>#H5Dread_chunk</td>
55+
<td>#H5Dread_chunk1</td>
56+
<td></td>
57+
</tr>
58+
<tr>
59+
<td>#H5Dread_chunk2</td>
5660
<td></td>
5761
</tr>
5862
<tr>
@@ -461,7 +465,7 @@
461465
<td>#H5VL_NATIVE_DATASET_GET_CHUNK_INFO_BY_COORD</td>
462466
</tr>
463467
<tr>
464-
<td>#H5Dread_chunk</td>
468+
<td>#H5Dread_chunk1 / #H5Dread_chunk2</td>
465469
<td>#H5VL_NATIVE_DATASET_CHUNK_READ</td>
466470
</tr>
467471
<tr>

fortran/src/H5Dff.F90

Lines changed: 194 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,12 @@ INTEGER FUNCTION h5dfill_c(f_ptr_fill_value, fill_type_id, space_id, &
203203
INTEGER(HID_T) :: mem_type_id
204204
END FUNCTION h5dfill_c
205205
END INTERFACE
206+
207+
INTERFACE h5dread_chunk_f
208+
MODULE PROCEDURE h5dread_chunk1_f
209+
MODULE PROCEDURE h5dread_chunk2_f
210+
END INTERFACE
211+
206212
#endif
207213

208214
CONTAINS
@@ -1780,6 +1786,62 @@ SUBROUTINE h5dfill_f(fill_value, fill_type_id, buf, buf_type_id, space_id, hdfer
17801786
INTEGER(HID_T), INTENT(IN) :: space_id
17811787
END SUBROUTINE h5dfill_f
17821788

1789+
!>
1790+
!! \ingroup FH5D
1791+
!!
1792+
!! \brief Reads a raw data chunk directly from a dataset in a file into a buffer.
1793+
!!
1794+
!! \param dset_id Identifier of the dataset to read from
1795+
!! \param offset Logical position of the chunk&apos;s first element in the dataspace, \Bold{0-based indices}
1796+
!! \param filters Mask for identifying the filters in use
1797+
!! \param buf Buffer containing data to be read from the chunk, if passed \p C_NULL_PTR then returns the
1798+
!! needed size of \p buf in \p buf_size
1799+
!! \param buf_size Size of \p buf in bytes
1800+
!! \param hdferr \fortran_error
1801+
!! \param dxpl_id Dataset transfer property list identifier
1802+
!!
1803+
!! See C API: @ref H5Dread_chunk2()
1804+
!!
1805+
SUBROUTINE h5dread_chunk_f(dset_id, offset, filters, buf, buf_size, hdferr, dxpl_id)
1806+
IMPLICIT NONE
1807+
1808+
INTEGER(HID_T) , INTENT(IN) :: dset_id
1809+
INTEGER(HSIZE_T) , INTENT(IN), DIMENSION(:) :: offset
1810+
INTEGER , INTENT(INOUT) :: filters
1811+
TYPE(C_PTR) :: buf
1812+
INTEGER(SIZE_T) , INTENT(INOUT) :: buf_size
1813+
INTEGER , INTENT(OUT) :: hdferr
1814+
INTEGER(HID_T) , INTENT(IN), OPTIONAL :: dxpl_id
1815+
END SUBROUTINE h5dread_chunk_f
1816+
1817+
!>
1818+
!! \ingroup FH5D
1819+
!!
1820+
!! \important If HDF5 was built without deprecated symbols, the API \p h5dread_chunk_f will return an error
1821+
!! since there is no equivalent C API to call.
1822+
!!
1823+
!! \brief Reads a raw data chunk directly from a dataset in a file into a buffer.
1824+
!!
1825+
!! \param dset_id Identifier of the dataset to read from
1826+
!! \param offset Logical position of the chunk&apos;s first element in the dataspace, \Bold{0-based indices}
1827+
!! \param filters Mask for identifying the filters in use
1828+
!! \param buf Buffer containing data to be read from the chunk
1829+
!! \param hdferr \fortran_error
1830+
!! \param dxpl_id Dataset transfer property list identifier
1831+
!!
1832+
!! See C API: Deprecated @ref H5Dread_chunk1()
1833+
!!
1834+
SUBROUTINE h5dread_chunk_f(dset_id, offset, filters, buf, hdferr, dxpl_id)
1835+
IMPLICIT NONE
1836+
1837+
INTEGER(HID_T) , INTENT(IN) :: dset_id
1838+
INTEGER(HSIZE_T) , INTENT(IN), DIMENSION(:) :: offset
1839+
INTEGER , INTENT(INOUT) :: filters
1840+
TYPE(C_PTR) :: buf
1841+
INTEGER , INTENT(OUT) :: hdferr
1842+
INTEGER(HID_T) , INTENT(IN), OPTIONAL :: dxpl_id
1843+
END SUBROUTINE h5dread_chunk_f
1844+
17831845
#else
17841846

17851847
SUBROUTINE h5dwrite_reference_obj(dset_id, mem_type_id, buf, dims, hdferr, &
@@ -2266,6 +2328,138 @@ SUBROUTINE h5dfill_char(fill_value, space_id, buf, hdferr)
22662328

22672329
END SUBROUTINE h5dfill_char
22682330

2331+
SUBROUTINE h5dread_chunk2_f(dset_id, offset, filters, buf, buf_size, hdferr, dxpl_id)
2332+
IMPLICIT NONE
2333+
2334+
INTEGER(HID_T) , INTENT(IN) :: dset_id
2335+
INTEGER(HSIZE_T) , INTENT(IN), DIMENSION(:) :: offset
2336+
INTEGER , INTENT(INOUT) :: filters
2337+
TYPE(C_PTR) :: buf
2338+
INTEGER(SIZE_T) , INTENT(INOUT) :: buf_size
2339+
INTEGER , INTENT(OUT) :: hdferr
2340+
INTEGER(HID_T) , INTENT(IN), OPTIONAL :: dxpl_id
2341+
2342+
INTEGER(HID_T) :: dxpl_id_default
2343+
INTEGER(HSIZE_T), DIMENSION(:), ALLOCATABLE :: c_offset
2344+
INTEGER(HSIZE_T) :: i, rank
2345+
INTEGER(C_INT32_T) :: c_filters
2346+
INTEGER(C_SIZE_T) :: cbuf_size
2347+
2348+
INTERFACE
2349+
INTEGER(C_INT) FUNCTION H5Dread_chunk2(dset_id, dxpl_id, offset, filters, buf, buf_size) &
2350+
BIND(C, NAME='H5Dread_chunk2')
2351+
IMPORT :: SIZE_T, HSIZE_T, HID_T
2352+
IMPORT :: C_PTR, C_INT32_T, C_INT, C_SIZE_T
2353+
IMPLICIT NONE
2354+
INTEGER(HID_T) , VALUE :: dset_id
2355+
INTEGER(HID_T) , VALUE :: dxpl_id
2356+
INTEGER(HSIZE_T) , DIMENSION(*) :: offset
2357+
INTEGER(C_INT32_T) :: filters
2358+
TYPE(C_PTR) , VALUE :: buf
2359+
INTEGER(C_SIZE_T) :: buf_size
2360+
END FUNCTION H5Dread_chunk2
2361+
END INTERFACE
2362+
2363+
dxpl_id_default = H5P_DEFAULT_F
2364+
IF (PRESENT(dxpl_id)) dxpl_id_default = dxpl_id
2365+
2366+
c_filters = INT(filters, KIND=C_INT32_T)
2367+
2368+
rank = SIZE(offset, KIND=HSIZE_T)
2369+
2370+
ALLOCATE(c_offset(rank), STAT=hdferr)
2371+
IF (hdferr .NE. 0 ) THEN
2372+
hdferr = -1
2373+
RETURN
2374+
ENDIF
2375+
2376+
!
2377+
! Reverse dimensions due to C-FORTRAN storage order
2378+
!
2379+
DO i = 1, rank
2380+
c_offset(i) = offset(rank - i + 1)
2381+
ENDDO
2382+
2383+
IF(.NOT. C_ASSOCIATED(buf) )THEN
2384+
cbuf_size = 0_C_SIZE_T
2385+
hdferr = INT(H5Dread_chunk2(dset_id, dxpl_id_default, c_offset, c_filters, C_NULL_PTR, cbuf_size))
2386+
buf_size = INT(cbuf_size, SIZE_T)
2387+
RETURN
2388+
ELSE
2389+
cbuf_size = INT(buf_size, C_SIZE_T)
2390+
ENDIF
2391+
2392+
hdferr = INT(H5Dread_chunk2(dset_id, dxpl_id_default, c_offset, c_filters, buf, cbuf_size))
2393+
2394+
filters = INT(c_filters)
2395+
buf_size = INT(cbuf_size, SIZE_T)
2396+
2397+
DEALLOCATE(c_offset)
2398+
2399+
END SUBROUTINE h5dread_chunk2_f
2400+
2401+
SUBROUTINE h5dread_chunk1_f(dset_id, offset, filters, buf, hdferr, dxpl_id)
2402+
IMPLICIT NONE
2403+
2404+
INTEGER(HID_T) , INTENT(IN) :: dset_id
2405+
INTEGER(HSIZE_T) , INTENT(IN), DIMENSION(:) :: offset
2406+
INTEGER , INTENT(INOUT) :: filters
2407+
TYPE(C_PTR) :: buf
2408+
INTEGER , INTENT(OUT) :: hdferr
2409+
INTEGER(HID_T) , INTENT(IN), OPTIONAL :: dxpl_id
2410+
2411+
#ifdef H5_NO_DEPRECATED_SYMBOLS
2412+
buf = C_NULL_PTR
2413+
hdferr = -1
2414+
RETURN
2415+
#else
2416+
INTEGER(HID_T) :: dxpl_id_default
2417+
INTEGER(HSIZE_T), DIMENSION(:), ALLOCATABLE :: c_offset
2418+
INTEGER(HSIZE_T) :: i, rank
2419+
INTEGER(C_INT32_T) :: c_filters
2420+
2421+
INTERFACE
2422+
INTEGER(C_INT) FUNCTION H5Dread_chunk1(dset_id, dxpl_id, offset, filters, buf) &
2423+
BIND(C, NAME='H5Dread_chunk1')
2424+
IMPORT :: SIZE_T, HSIZE_T, HID_T
2425+
IMPORT :: C_PTR, C_INT32_T, C_INT
2426+
IMPLICIT NONE
2427+
INTEGER(HID_T) , VALUE :: dset_id
2428+
INTEGER(HID_T) , VALUE :: dxpl_id
2429+
INTEGER(HSIZE_T) , DIMENSION(*) :: offset
2430+
INTEGER(C_INT32_T) :: filters
2431+
TYPE(C_PTR) , VALUE :: buf
2432+
END FUNCTION H5Dread_chunk1
2433+
END INTERFACE
2434+
2435+
dxpl_id_default = H5P_DEFAULT_F
2436+
IF (PRESENT(dxpl_id)) dxpl_id_default = dxpl_id
2437+
2438+
c_filters = INT(filters, KIND=C_INT32_T)
2439+
2440+
rank = SIZE(offset, KIND=HSIZE_T)
2441+
2442+
ALLOCATE(c_offset(rank), STAT=hdferr)
2443+
IF (hdferr .NE. 0 ) THEN
2444+
hdferr = -1
2445+
RETURN
2446+
ENDIF
2447+
2448+
!
2449+
! Reverse dimensions due to C-FORTRAN storage order
2450+
!
2451+
DO i = 1, rank
2452+
c_offset(i) = offset(rank - i + 1)
2453+
ENDDO
2454+
2455+
hdferr = INT(H5Dread_chunk1(dset_id, dxpl_id_default, c_offset, c_filters, buf))
2456+
2457+
filters = INT(c_filters)
2458+
2459+
DEALLOCATE(c_offset)
2460+
#endif
2461+
END SUBROUTINE h5dread_chunk1_f
2462+
22692463
#endif
22702464

22712465
!>
@@ -2376,77 +2570,6 @@ END FUNCTION H5Dwrite_multi
23762570

23772571
END SUBROUTINE h5dwrite_multi_f
23782572

2379-
!>
2380-
!! \ingroup FH5D
2381-
!!
2382-
!! \brief Reads a raw data chunk directly from a dataset in a file into a buffer.
2383-
!!
2384-
!! \param dset_id Identifier of the dataset to read from
2385-
!! \param offset Logical position of the chunk&apos;s first element in the dataspace, \Bold{0-based indices}
2386-
!! \param filters Mask for identifying the filters in use
2387-
!! \param buf Buffer containing data to be read from the chunk
2388-
!! \param hdferr \fortran_error
2389-
!! \param dxpl_id Dataset transfer property list identifier
2390-
!!
2391-
!! See C API: @ref H5Dread_chunk()
2392-
!!
2393-
SUBROUTINE h5dread_chunk_f(dset_id, offset, filters, buf, hdferr, dxpl_id)
2394-
IMPLICIT NONE
2395-
2396-
INTEGER(HID_T) , INTENT(IN) :: dset_id
2397-
INTEGER(HSIZE_T) , INTENT(IN), DIMENSION(:) :: offset
2398-
INTEGER , INTENT(INOUT) :: filters
2399-
TYPE(C_PTR) :: buf
2400-
INTEGER , INTENT(OUT) :: hdferr
2401-
INTEGER(HID_T) , INTENT(IN), OPTIONAL :: dxpl_id
2402-
2403-
INTEGER(HID_T) :: dxpl_id_default
2404-
INTEGER(HSIZE_T), DIMENSION(:), ALLOCATABLE :: c_offset
2405-
INTEGER(HSIZE_T) :: i, rank
2406-
INTEGER(C_INT32_T) :: c_filters
2407-
2408-
INTERFACE
2409-
INTEGER(C_INT) FUNCTION H5Dread_chunk(dset_id, dxpl_id, offset, filters, buf) &
2410-
BIND(C, NAME='H5Dread_chunk')
2411-
IMPORT :: SIZE_T, HSIZE_T, HID_T
2412-
IMPORT :: C_PTR, C_INT32_T, C_INT
2413-
IMPLICIT NONE
2414-
INTEGER(HID_T) , VALUE :: dset_id
2415-
INTEGER(HID_T) , VALUE :: dxpl_id
2416-
INTEGER(HSIZE_T) , DIMENSION(*) :: offset
2417-
INTEGER(C_INT32_T) :: filters
2418-
TYPE(C_PTR) , VALUE :: buf
2419-
END FUNCTION H5Dread_chunk
2420-
END INTERFACE
2421-
2422-
dxpl_id_default = H5P_DEFAULT_F
2423-
IF (PRESENT(dxpl_id)) dxpl_id_default = dxpl_id
2424-
2425-
c_filters = INT(filters, KIND=C_INT32_T)
2426-
2427-
rank = SIZE(offset, KIND=HSIZE_T)
2428-
2429-
ALLOCATE(c_offset(rank), STAT=hdferr)
2430-
IF (hdferr .NE. 0 ) THEN
2431-
hdferr = -1
2432-
RETURN
2433-
ENDIF
2434-
2435-
!
2436-
! Reverse dimensions due to C-FORTRAN storage order
2437-
!
2438-
DO i = 1, rank
2439-
c_offset(i) = offset(rank - i + 1)
2440-
ENDDO
2441-
2442-
hdferr = INT(H5Dread_chunk(dset_id, dxpl_id_default, c_offset, c_filters, buf))
2443-
2444-
filters = INT(c_filters)
2445-
2446-
DEALLOCATE(c_offset)
2447-
2448-
END SUBROUTINE h5dread_chunk_f
2449-
24502573
!>
24512574
!! \ingroup FH5D
24522575
!!

fortran/src/hdf5_fortrandll.def.in

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,8 @@ H5D_mp_H5DWRITE_MULTI_F
103103
H5D_mp_H5DWRITE_ASYNC_F
104104
H5D_mp_H5DREAD_ASYNC_F
105105
H5D_mp_H5DWRITE_CHUNK_F
106-
H5D_mp_H5DREAD_CHUNK_F
106+
H5D_mp_H5DREAD_CHUNK1_F
107+
H5D_mp_H5DREAD_CHUNK2_F
107108
; H5E
108109
H5E_mp_H5ECLEAR_F
109110
H5E_mp_H5EPRINT1_F

0 commit comments

Comments
 (0)