Page tree

 

JAVA

FORTRAN

C++

C

 

Link

H5D_READ

Reads raw data from a dataset into a buffer

Procedure:

H5D_READ(dataset_id, mem_type_id, mem_space_id, file_space_id, xfer_plist_id, buf)

Signature:

herr_t H5Dreadhid_t dataset_idhid_t mem_type_idhid_t mem_space_idhid_t file_space_idhid_t xfer_plist_idvoid * buf ) 

Fortran2003:

 SUBROUTINE h5dread_f(dset_id, mem_type_id, buf, hdferr, &
                       mem_space_id, file_space_id, xfer_prp)
    INTEGER(HID_T), INTENT(IN)              :: dset_id
    INTEGER(HID_T), INTENT(IN)              :: mem_type_id
    TYPE(C_PTR)   , INTENT(INOUT)           :: buf
    INTEGER       , INTENT(OUT)             :: hdferr
    INTEGER(HID_T), INTENT(IN)   , OPTIONAL :: mem_space_id
    INTEGER(HID_T), INTENT(IN)   , OPTIONAL :: file_space_id
    INTEGER(HID_T), INTENT(IN)   , OPTIONAL :: xfer_prp

Fortran90:

There is no direct Fortran90 counterpart for the C function H5Dread. Instead, that functionality is provided by two Fortran90 subroutines:

h5dread_fPurpose: Reads data other than variable-length data.
h5dread_vl_fPurpose: Reads variable-length data.
 
SUBROUTINE h5dread_f(dset_id, mem_type_id, buf, dims, hdferr, & 
                     mem_space_id, file_space_id, xfer_prp)
  IMPLICIT NONE
  INTEGER(HID_T), INTENT(IN) :: dset_id     ! Dataset identifier
  INTEGER(HID_T), INTENT(IN) :: mem_type_id ! Memory datatype identifier
  TYPE, INTENT(INOUT) :: buf                ! Data buffer; may be a scalar 
                                            ! or an array
  DIMENSION(*), INTEGER(HSIZE_T), INTENT(IN)  :: dims 
                                            ! Array to hold corresponding 
                                            ! dimension sizes of data 
                                            ! buffer buf 
                                            ! dim(k) has value of the k-th 
                                            ! dimension of buffer buf
                                            ! Values are ignored if buf is 
                                            ! a scalar
  INTEGER, INTENT(OUT) :: hdferr            ! Error code 
                                            ! 0 on success and -1 on failure
  INTEGER(HID_T), OPTIONAL, INTENT(IN) :: mem_space_id 
                                            ! Memory dataspace identfier 
                                            ! Default value is H5S_ALL_F 
  INTEGER(HID_T), OPTIONAL, INTENT(IN) :: file_space_id 
                                            ! File dataspace identfier 
                                            ! Default value is H5S_ALL_F
  INTEGER(HID_T), OPTIONAL, INTENT(IN) :: xfer_prp 
                                            ! Transfer property list identifier
                                            ! Default value is H5P_DEFAULT_F 
END SUBROUTINE h5dread_f
 SUBROUTINE h5dread_vl_f(dset_id, mem_type_id, buf, dims, len, hdferr, & 
                     mem_space_id, file_space_id, xfer_prp)     
  IMPLICIT NONE
  INTEGER(HID_T), INTENT(IN) :: dset_id     ! Dataset identifier
  INTEGER(HID_T), INTENT(IN) :: mem_type_id ! Memory datatype identifier
  TYPE, INTENT(INOUT), & DIMENSION(dims(1),dims(2)) :: buf
                                            ! Data buffer; may be a scalar 
                                            ! or an array
                                            ! TYPE must be one of the following
                                            !     INTEGER
                                            !     REAL
                                            !     CHARACTER

  INTEGER(HSIZE_T), INTENT(IN), DIMENSION(2)  :: dims 
                                            ! Array to hold corresponding 
                                            ! dimension sizes of data 
                                            ! buffer buf 
                                            ! dim(k) has value of the k-th 
                                            ! dimension of buffer buf
                                            ! Values are ignored if buf is 
                                            ! a scalar
  INTEGER(SIZE_T), INTENT(INOUT), DIMENSION(*)  :: len 
                                            ! Array to store length of
                                            ! each element
  INTEGER, INTENT(OUT) :: hdferr            ! Error code 
                                            ! 0 on success and -1 on failure
  INTEGER(HID_T), OPTIONAL, INTENT(IN) :: mem_space_id 
                                            ! Memory dataspace identfier 
                                            ! Default value is H5S_ALL_F 
  INTEGER(HID_T), OPTIONAL, INTENT(IN) :: file_space_id 
                                            ! File dataspace identfier 
                                            ! Default value is H5S_ALL_F
  INTEGER(HID_T), OPTIONAL, INTENT(IN) :: xfer_prp 
                                            ! Transfer property list identifier
                                            ! Default value is H5P_DEFAULT_F
END SUBROUTINE h5dread_vl_f

Parameters:
hid_t dataset_idIN: Identifier of the dataset read from
hid_t mem_type_idIN: Identifier of the memory datatype
hid_t mem_space_idIN: Identifier of the memory dataspace
hid_t file_space_idIN: Identifier of the dataset's dataspace in the file
hid_t xfer_plist_id    IN: Identifier of a transfer property list for this I/O operation
void * bufOUT: Buffer to receive data read from file

Description:

H5D_READ reads a (partial) dataset, specified by its identifier dataset_id, from the file into an application memory buffer buf. Data transfer properties are defined by the argument xfer_plist_id. The memory datatype of the (partial) dataset is identified by the identifier mem_type_id. The part of the dataset to read is defined by mem_space_id and file_space_id.

file_space_id is used to specify only the selection within the file dataset's dataspace. Any dataspace specified in file_space_id is ignored by the library and the dataset's dataspace is always used. file_space_id can be the constant H5S_ALL. which indicates that the entire file dataspace, as defined by the current dimensions of the dataset, is to be selected.

mem_space_id is used to specify both the memory dataspace and the selection within that dataspace. mem_space_id can be the constant H5S_ALL, in which case the file dataspace is used for the memory dataspace and the selection defined with file_space_id is used for the selection within that dataspace.

If raw data storage space has not been allocated for the dataset and a fill value has been defined, the returned buffer buf is filled with the fill value.

The behavior of the library for the various combinations of valid dataspace identifiers and H5S_ALL for the mem_space_id and the file_space_id parameters is described below: 

mem_space_id  file_space_id  Behavior
valid dataspace identifiervalid dataspace identifiermem_space_id specifies the memory dataspace and the selection within it. file_space_id specifies the selection within the file dataset's dataspace.
H5S_ALLvalid dataspace identifierThe file dataset's dataspace is used for the memory dataspace and the selection specified with file_space_id specifies the selection within it. The combination of the file dataset's dataspace and the selection from file_space_id is used for memory also.
valid dataspace identifierH5S_ALLmem_space_id specifies the memory dataspace and the selection within it. The selection within the file dataset's dataspace is set to the "all" selection.
H5S_ALLH5S_ALLThe file dataset's dataspace is used for the memory dataspace and the selection within the memory dataspace is set to the "all" selection. The selection within the file dataset's dataspace is set to the "all" selection.

 

Setting an H5S_ALL selection indicates that the entire dataspace, as defined by the current dimensions of a dataspace, will be selected. The number of elements selected in the memory dataspace must match the number of elements selected in the file dataspace.

xfer_plist_id can be the constant H5P_DEFAULT. in which case the default data transfer properties are used.

Datatype conversion takes place at the time of a read or write and is automatic. See the Data Transfer: Datatype Conversion and Selection section in the “HDF5 Datatypes” chapter of the HDF5 User’s Guide for a discussion of data conversion.

Returns:

Returns a non-negative value if successful; otherwise returns a negative value.

Example:

Coming Soon!

History:
Release    Change
1.8.8Fortran updated to Fortran2003.
1.4.2dims parameter added in Fortran interface.

--- Last Modified: December 18, 2018 | 01:33 PM