HDF5 documents and links 
Introduction to HDF5 
HDF5 User Guide 
And in this document, the HDF5 Reference Manual  
H5   H5A   H5D   H5E   H5F   H5G   H5I   H5P  
H5R   H5S   H5T   H5Z   Tools   Datatypes  

H5D: Datasets Interface

Dataset Object API Functions

These functions create and manipulate dataset objects, and set and retrieve their constant or persistent properties.

The C Interfaces:
             

Alphabetical Listing
             

The FORTRAN90 Interfaces:
In general, each FORTRAN90 subroutine performs exactly the same task as the corresponding C function.
             


Name: H5Dclose
Signature:
herr_t H5Dclose(hid_t dataset_id )
Purpose:
Closes the specified dataset.
Description:
H5Dclose ends access to a dataset specified by dataset_id and releases resources used by it. Further use of the dataset identifier is illegal in calls to the dataset API.
Parameters:
hid_t dataset_id
IN: Identifier of the dataset to close access to.
Returns:
Returns a non-negative value if successful; otherwise returns a negative value.
Fortran90 Interface: h5dclose_f
SUBROUTINE h5dclose_f(dset_id, hdferr)
  IMPLICIT NONE
  INTEGER(HID_T), INTENT(IN) :: dset_id ! Dataset identifier  
  INTEGER, INTENT(OUT) :: hdferr        ! Error code  
                                        ! 0 on success and -1 on failure
END SUBROUTINE h5dclose_f
	

Name: H5Dcreate
Signature:
hid_t H5Dcreate(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id, hid_t create_plist_id )
Purpose:
Creates a dataset at the specified location.
Description:
H5Dcreate creates a data set with a name, name, in the file or in the group specified by the identifier loc_id. The dataset has the datatype and dataspace identified by type_id and space_id, respectively. The specified datatype and dataspace are the datatype and dataspace of the dataset as it will exist in the file, which may be different than in application memory. Dataset creation properties are specified by the argument create_plist_id.

Dataset names within a group are unique: H5Dcreate will return an error if a dataset with the name specified in name already exists at the location specified in loc_id.

create_plist_id is a H5P_DATASET_CREATE property list created with H5Pcreate and initialized with the various functions described above.

H5Dcreate returns an error if the dataset's datatype includes a variable-length (VL) datatype and the fill value is undefined, i.e., set to NULL in the dataset creation property list. Such a VL datatype may be directly included, indirectly included as part of a compound or array datatype, or indirectly included as part of a nested compound or array datatype.

H5Dcreate returns a dataset identifier for success or a negative value for failure. The dataset identifier should eventually be closed by calling H5Dclose to release resources it uses.

Fill values and space allocation:
The HDF5 library provides flexible means of specifying a fill value, of specifying when space will be allocated for a dataset, and of specifying when fill values will be written to a dataset. For further information on these topics, see the document Fill Value and Dataset Storage Allocation Issues in HDF5 and the descriptions of the following HDF5 functions in this HDF5 Reference Manual:
  H5Dfill
H5Pset_fill_value
H5Pget_fill_value
H5Pfill_value_defined
H5Pset_fill_time
H5Pget_fill_time
H5Pset_alloc_time
H5Pget_alloc_time
This information is also included in the “HDF5 Datasets” chapter of the new HDF5 User's Guide, which is being prepared for release.

Parameters:
hid_t loc_id
IN: Identifier of the file or group within which to create the dataset.
const char * name
IN: The name of the dataset to create.
hid_t type_id
IN: Identifier of the datatype to use when creating the dataset.
hid_t space_id
IN: Identifier of the dataspace to use when creating the dataset.
hid_t create_plist_id
IN: Identifier of the set creation property list.
Returns:
Returns a dataset identifier if successful; otherwise returns a negative value.
Fortran90 Interface: h5dcreate_f
SUBROUTINE h5dcreate_f(loc_id, name, type_id, space_id, dset_id, & 
                       hdferr, creation_prp) 
  IMPLICIT NONE 
  INTEGER(HID_T), INTENT(IN) :: loc_id   ! File or group identifier
  CHARACTER(LEN=*), INTENT(IN) :: name   ! Name of the dataset 
  INTEGER(HID_T), INTENT(IN) :: type_id  ! Datatype identifier 
  INTEGER(HID_T), INTENT(IN) :: space_id ! Dataspace identifier
  INTEGER(HID_T), INTENT(OUT) :: dset_id ! Dataset identifier
  INTEGER, INTENT(OUT) :: hdferr         ! Error code 
                                         ! 0 on success and -1 on failure
  INTEGER(HID_T), OPTIONAL, INTENT(IN) :: creation_prp
                                         ! Dataset creation propertly 
                                         ! list identifier , default
                                         ! value is H5P_DEFAULT_F (6) 
END SUBROUTINE h5dcreate_f
	

Name: H5Dextend
Signature:
herr_t H5Dextend(hid_t dataset_id, const hsize_t * size )
Purpose:
Extends a dataset with unlimited dimension.
Description:
H5Dextend verifies that the dataset is at least of size size. The dimensionality of size is the same as that of the dataspace of the dataset being changed. This function cannot be applied to a dataset with fixed dimensions.

Space on disk is immediately allocated for the new dataset extent if the dataset's space allocation time is set to H5D_ALLOC_TIME_EARLY. Fill values will be written to the dataset if the dataset's fill time is set to H5D_FILL_TIME_IFSET or H5D_FILL_TIME_ALLOC. (Also see H5Pset_fill_time and H5Pset_alloc_time.)

Parameters:
hid_t dataset_id
IN: Identifier of the dataset.
const hsize_t * size
IN: Array containing the new magnitude of each dimension.
Returns:
Returns a non-negative value if successful; otherwise returns a negative value.
Fortran90 Interface: h5dextend_f
SUBROUTINE h5dextend_f(dataset_id, size, hdferr) 
  IMPLICIT NONE 
  INTEGER(HID_T), INTENT(IN) :: dataset_id   ! Dataset identifier
  INTEGER(HSIZE_T), DIMENSION(*), INTENT(IN)  :: size
                                             ! Array containing 
                                             ! dimensions' sizes 
  INTEGER, INTENT(OUT) :: hdferr             ! Error code 
                                             ! 0 on success and -1 on failure
END SUBROUTINE h5dextend_f 
	

Name: H5Dfill
Signature:
herr_t H5Dfill( const void *fill, hid_t fill_type_id, void *buf, hid_t buf_type_id, hid_t space_id )
Purpose:
Fills dataspace elements with a fill value in a memory buffer.
Description:
H5Dfill explicitly fills the dataspace selection in memory, space_id, with the fill value specified in fill. If fill is NULL, a fill value of 0 (zero) is used.

fill_type_id specifies the datatype of the fill value.
buf specifies the buffer in which the dataspace elements will be written.
buf_type_id specifies the datatype of those data elements.

Note that if the fill value datatype differs from the memory buffer datatype, the fill value will be converted to the memory buffer datatype before filling the selection.

Note:
Applications sometimes write data only to portions of an allocated dataset. It is often useful in such cases to fill the unused space with a known fill value. See H5Pset_fill_value for further discussion. Other related functions include H5Pget_fill_value, H5Pfill_value_defined, H5Pset_fill_time, H5Pget_fill_time, and H5Dcreate.
Parameters:
const void *fill
IN: Pointer to the fill value to be used.
hid_t fill_type_id
IN: Fill value datatype identifier.
void *buf
IN/OUT: Pointer to the memory buffer containing the selection to be filled.
hid_t buf_type_id
IN: Datatype of dataspace elements to be filled.
hid_t space_id
IN: Dataspace describing memory buffer and containing the selection to be filled.
Returns:
Returns a non-negative value if successful; otherwise returns a negative value.
Fortran90 Interface: h5dfill_f
SUBROUTINE h5dfill_f(fill_value, space_id, buf, hdferr)
  IMPLICIT NONE
  TYPE, INTENET(IN) :: fill_value        ! Fill value; may be have one of the
                                         ! following types:
                                         ! INTEGER, REAL, DOUBLE PRECISION, 
                                         ! CHARACTER
  INTEGER(HID_T), INTENT(IN) :: space_id ! Memory dataspace selection identifier 
  TYPE, DIMENSION(*) :: buf              ! Memory buffer to fill in; must have
                                         ! the same datatype as fill value
  INTEGER, INTENT(OUT) :: hdferr         ! Error code  
                                         ! 0 on success and -1 on failure
END SUBROUTINE h5dfill_f
	

Name: H5Dget_create_plist
Signature:
hid_t H5Dget_create_plist(hid_t dataset_id )
Purpose:
Returns an identifier for a copy of the dataset creation property list for a dataset.
Description:
H5Dget_create_plist returns an identifier for a copy of the dataset creation property list for a dataset. The creation property list identifier should be released with the H5Pclose function.
Parameters:
hid_t dataset_id
IN: Identifier of the dataset to query.
Returns:
Returns a dataset creation property list identifier if successful; otherwise returns a negative value.
Fortran90 Interface: h5dget_create_plist_f
SUBROUTINE h5dget_create_plist_f(dataset_id, creation_prp, hdferr) 
  IMPLICIT NONE 
  INTEGER(HID_T), INTENT(IN) :: dataset_id    ! Dataset identifier
  INTEGER(HID_T), INTENT(OUT) :: creation_id  ! Dataset creation
                                              ! property list identifier
  INTEGER, INTENT(OUT) :: hdferr              ! Error code 
                                              ! 0 on success and -1 on failure
END SUBROUTINE h5dget_create_plist_f  

	

Name: H5Dget_offset
Signature:
haddr_t H5Dget_offset(hid_t dset_id)
Purpose:
Returns dataset address in file.
Description:
H5Dget_offset returns the address in the file of the dataset dset_id. That address is expressed as the offset in bytes from the beginning of the file.
Parameters:
hid_t dset_id
Dataset identifier.
Returns:
Returns the offset in bytes; otherwise returns HADDR_UNDEF, a negative value.
Fortran90 Interface:
None.

Name: H5Dget_space
Signature:
hid_t H5Dget_space(hid_t dataset_id )
Purpose:
Returns an identifier for a copy of the dataspace for a dataset.
Description:
H5Dget_space returns an identifier for a copy of the dataspace for a dataset. The dataspace identifier should be released with the H5Sclose function.
Parameters:
hid_t dataset_id
IN: Identifier of the dataset to query.
Returns:
Returns a dataspace identifier if successful; otherwise returns a negative value.
Fortran90 Interface: h5dget_space_f
SUBROUTINE h5dget_space_f(dataset_id, dataspace_id, hdferr) 
  IMPLICIT NONE 
  INTEGER(HID_T), INTENT(IN) :: dataset_id      ! Dataset identifier
  INTEGER(HID_T), INTENT(OUT) :: dataspace_id   ! Dataspace identifier
  INTEGER, INTENT(OUT) :: hdferr                ! Error code 
                                                ! 0 on success and -1 on failure
END SUBROUTINE h5dget_space_f
	

Name: H5Dget_space_status
Signature:
herr_t H5Dget_space_status(hid_t dset_id, H5D_space_status_t *status)
Purpose:
Determines whether space has been allocated for a dataset.
Description:
H5Dget_space_status determines whether space has been allocated for the dataset dset_id.

Space allocation status is returned in status, which will have one of the following values:

     H5D_SPACE_STATUS_NOT_ALLOCATED Space has not been allocated for this dataset.
H5D_SPACE_STATUS_ALLOCATED Space has been allocated for this dataset.
H5D_SPACE_STATUS_PART_ALLOCATED   Space has been partially allocated for this dataset. (Used only for datasets with chunked storage.)
Parameters:
hid_t dset_id
IN: Identifier of the dataset to query.
H5D_space_status_t *status
OUT: Space allocation status.
Returns:
Returns a non-negative value if successful; otherwise returns a negative value.
Fortran90 Interface: h5dget_space_status_f
SUBROUTINE h5dget_space_status_f(dset_id, flag, hdferr)
  IMPLICIT NONE
  INTEGER(HID_T), INTENT(IN) :: dset_id  ! Dataset identifier 
  INTEGER, INTENET(OUT)      :: flag     ! Status flag ; possible values:
                                         ! H5D_SPACE_STS_ERROR_F
                                         ! H5D_SPACE_STS_NOT_ALLOCATED_F
                                         ! H5D_SPACE_STS_PART_ALLOCATED_F
                                         ! H5D_SPACE_STS_ALLOCATED_F
  INTEGER, INTENT(OUT) :: hdferr         ! Error code  
                                         ! 0 on success and -1 on failure
END SUBROUTINE h5dget_space_status_f
	

Name: H5Dget_storage_size
Signature:
hsize_t H5Dget_storage_size(hid_t dataset_id )
Purpose:
Returns the amount of storage required for a dataset.
Description:
H5Dget_storage_size returns the amount of storage that is required for the specified dataset, dataset_id. For chunked datasets, this is the number of allocated chunks times the chunk size. The return value may be zero if no data has been stored.
Parameters:
hid_t dataset_id
IN: Identifier of the dataset to query.
Returns:
Returns the amount of storage space allocated for the dataset, not counting meta data; otherwise returns 0 (zero).
Fortran90 Interface: h5dget_storage_size_f
SUBROUTINE h5dget_storage_size_f(dset_id, size, hdferr)
  IMPLICIT NONE
  INTEGER(HID_T), INTENT(IN) :: dset_id  ! Dataset identifier  
  INTEGER(HSIZE_T), INTENT(OUT)  :: size ! Amount of storage required 
                                         ! for dataset
  INTEGER, INTENT(OUT) :: hdferr         ! Error code  
                                         ! 0 on success and -1 on failure
END SUBROUTINE h5dget_storage_size_f
	

Name: H5Dget_type
Signature:
hid_t H5Dget_type(hid_t dataset_id )
Purpose:
Returns an identifier for a copy of the datatype for a dataset.
Description:
H5Dget_type returns an identifier for a copy of the datatype for a dataset. The datatype should be released with the H5Tclose function.

If a dataset has a named datatype, then an identifier to the opened datatype is returned. Otherwise, the returned datatype is read-only. If atomization of the datatype fails, then the datatype is closed.

Parameters:
hid_t dataset_id
IN: Identifier of the dataset to query.
Returns:
Returns a datatype identifier if successful; otherwise returns a negative value.
Fortran90 Interface: h5dget_type_f
SUBROUTINE h5dget_type_f(dataset_id, datatype_id, hdferr) 
  IMPLICIT NONE 
  INTEGER(HID_T), INTENT(IN) :: dataset_id    ! Dataset identifier
  INTEGER(HID_T), INTENT(OUT) :: datatype_id  ! Datatype identifier
  INTEGER, INTENT(OUT) :: hdferr              ! Error code 
                                              ! 0 on success and -1 on failure
END SUBROUTINE h5dget_type_f 
	

Name: H5Diterate
Signature:
herr_t H5Diterate( void *buf, hid_t type_id, hid_t space_id, H5D_operator_t operator, void *operator_data )
Purpose:
Iterates over all selected elements in a dataspace.
Description:
H5Diterate iterates over all the elements selected in a memory buffer. The callback function is called once for each element selected in the dataspace.

The selection in the dataspace is modified so that any elements already iterated over are removed from the selection if the iteration is interrupted (by the H5D_operator_t function returning non-zero) before the iteration is complete; the iteration may then be re-started by the user where it left off.

Parameters:
void *buf
IN/OUT: Pointer to the buffer in memory containing the elements to iterate over.
hid_t type_id
IN: Datatype identifier for the elements stored in buf.
hid_t space_id
IN: Dataspace identifier for buf. Also contains the selection to iterate over.
H5D_operator_t operator
IN: Function pointer to the routine to be called for each element in buf iterated over.
void *operator_data
IN/OUT: Pointer to any user-defined data associated with the operation.
Returns:
Returns the return value of the last operator if it was non-zero, or zero if all elements have been processed. Otherwise returns a negative value.
Fortran90 Interface:
None.

Name: H5Dopen
Signature:
hid_t H5Dopen(hid_t loc_id, const char *name )
Purpose:
Opens an existing dataset.
Description:
H5Dopen opens an existing dataset for access in the file or group specified in loc_id. name is a dataset name and is used to identify the dataset in the file.
Parameters:
hid_t loc_id
IN: Identifier of the file or group within which the dataset to be accessed will be found.
const char * name
IN: The name of the dataset to access.
Returns:
Returns a dataset identifier if successful; otherwise returns a negative value.
Fortran90 Interface: h5dopen_f
SUBROUTINE h5dopen_f(loc_id, name, dset_id, hdferr) 
  IMPLICIT NONE 
  INTEGER(HID_T), INTENT(IN) :: loc_id   ! File or group identifier
  CHARACTER(LEN=*), INTENT(IN) :: name   ! Name of the dataset 
  INTEGER(HID_T), INTENT(OUT) :: dset_id ! Dataset identifier
  INTEGER, INTENT(OUT) :: hdferr         ! Error code 
                                         ! 0 on success and -1 on failure
END SUBROUTINE h5dopen_f
	

Name: H5Dread
Signature:
herr_t H5Dread(hid_t dataset_id, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, hid_t xfer_plist_id, void * buf )
Purpose:
Reads raw data from a dataset into a buffer.
Description:
H5Dread 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 identifier valid dataspace identifier mem_space_id specifies the memory dataspace and the selection within it. file_space_id specifies the selection within the file dataset's dataspace.
H5S_ALL valid dataspace identifier The 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 identifier H5S_ALL mem_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_ALL H5S_ALL The 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.

Data is automatically converted from the file datatype and dataspace to the memory datatype and dataspace at the time of the read. See the Data Conversion section of The Data Type Interface (H5T) in the HDF5 User's Guide for a discussion of data conversion, including the range of conversions currently supported by the HDF5 libraries.

Parameters:
hid_t dataset_id
IN: Identifier of the dataset read from.
hid_t mem_type_id
IN: Identifier of the memory datatype.
hid_t mem_space_id
IN: Identifier of the memory dataspace.
hid_t file_space_id
IN: 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 * buf
OUT: Buffer to receive data read from file.
Returns:
Returns a non-negative value if successful; otherwise returns a negative value.
Fortran90 Interface: h5dread_f
There are seperate versions of this interface. Their use depends on the datatype of the object being read.

Use the following h5dread_f call for all datatypes except object and dataset region references:

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
	

Use this h5dread_f call for object reference and dataset region reference datatypes:

SUBROUTINE h5dread_f(dset_id, mem_type_id, buf, n, 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
  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
  TYPE(hobj_ref_t_f), DIMENSION(dims(1)), INTENT(INOUT) :: buf
                                            ! Data buffer of rank 1
  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
	

Name: H5Dvlen_get_buf_size
Signature:
herr_t H5Dvlen_get_buf_size(hid_t dataset_id, hid_t type_id, hid_t space_id, hsize_t *size )
Purpose:
Determines the number of bytes required to store VL data.
Description:
H5Dvlen_get_buf_size determines the number of bytes required to store the VL data from the dataset, using the space_id for the selection in the dataset on disk and the type_id for the memory representation of the VL data in memory.

*size is returned with the number of bytes required to store the VL data in memory.

Parameters:
hid_t dataset_id
IN: Identifier of the dataset to query.
hid_t type_id
IN: Datatype identifier.
hid_t space_id
IN: Dataspace identifier.
hsize_t *size
OUT: The size in bytes of the memory buffer required to store the VL data.
Returns:
Returns non-negative value if successful; otherwise returns a negative value.
Fortran90 Interface: h5dvlen_get_max_len_f
There is no direct FORTRAN couterpart for the C function H5Dvlen_get_buf_size; corresponding functionality is provided by the FORTRAN function h5dvlen_get_max_len_f.
SUBROUTINE h5dvlen_get_max_len_f(dset_id, size, hdferr)
  IMPLICIT NONE
  INTEGER(HID_T), INTENT(IN) :: dset_id     ! Dataset identifier  
  INTEGER(HID_T), INTENT(IN) :: type_id     ! Datatype identifier  
  INTEGER(HID_T), INTENT(IN) :: space_id    ! Dataspace identifier  
            
  INTEGER(SIZE_T), INTENT(OUT)  :: elem_len ! Maximum length of the element
  INTEGER, INTENT(OUT) :: hdferr            ! Error code  
                                            ! 0 on success and -1 on failure
END SUBROUTINE h5dvlen_get_max_len_f
	

Name: H5Dvlen_reclaim
Signature:
herr_t H5Dvlen_reclaim(hid_t type_id, hid_t space_id, hid_t plist_id, void *buf )
Purpose:
Reclaims VL datatype memory buffers.
Description:
H5Dvlen_reclaim reclaims memory buffers created to store VL datatypes.

The type_id must be the datatype stored in the buffer. The space_id describes the selection for the memory buffer to free the VL datatypes within. The plist_id is the dataset transfer property list which was used for the I/O transfer to create the buffer. And buf is the pointer to the buffer to be reclaimed.

The VL structures (hvl_t) in the user's buffer are modified to zero out the VL information after the memory has been reclaimed.

If nested VL datatypes were used to create the buffer, this routine frees them from the bottom up, releasing all the memory without creating memory leaks.

Parameters:
hid_t type_id
IN: Identifier of the datatype.
hid_t space_id
IN: Identifier of the dataspace.
hid_t plist_id
IN: Identifier of the property list used to create the buffer.
void *buf
IN: Pointer to the buffer to be reclaimed.
Returns:
Returns non-negative value if successful; otherwise returns a negative value.
Fortran90 Interface:
None.

Name: H5Dwrite
Signature:
herr_t H5Dwrite(hid_t dataset_id, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, hid_t xfer_plist_id, const void * buf )
Purpose:
Writes raw data from a buffer to a dataset.
Description:
H5Dwrite writes a (partial) dataset, specified by its identifier dataset_id, from the application memory buffer buf into the file. 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 write 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.

The behavior of the library for the various combinations of valid dataspace IDs 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 identifier valid dataspace identifier mem_space_id specifies the memory dataspace and the selection within it. file_space_id specifies the selection within the file dataset's dataspace.
H5S_ALL valid dataspace identifier The 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 identifier H5S_ALL mem_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_ALL H5S_ALL The 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 "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.

Writing to an dataset will fail if the HDF5 file was not opened with write access permissions.

Data is automatically converted from the memory datatype and dataspace to the file datatype and dataspace at the time of the write. See the Data Conversion section of The Data Type Interface (H5T) in the HDF5 User's Guide for a discussion of data conversion, including the range of conversions currently supported by the HDF5 libraries.

If the dataset's space allocation time is set to H5D_ALLOC_TIME_LATE or H5D_ALLOC_TIME_INCR and the space for the dataset has not yet been allocated, that space is allocated when the first raw data is written to the dataset. Unused space in the dataset will be written with fill values at the same time if the dataset's fill time is set to H5D_FILL_TIME_IFSET or H5D_FILL_TIME_ALLOC. (Also see H5Pset_fill_time and H5Pset_alloc_time.)

If a dataset's storage layout is 'compact', care must be taken when writing data to the dataset in parallel. A compact dataset's raw data is cached in memory and may be flushed to the file from any of the parallel processes, so parallel applications should always attempt to write identical data to the dataset from all processes.

Parameters:
hid_t dataset_id
IN: Identifier of the dataset to write to.
hid_t mem_type_id
IN: Identifier of the memory datatype.
hid_t mem_space_id
IN: Identifier of the memory dataspace.
hid_t file_space_id
IN: 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.
const void * buf
IN: Buffer with data to be written to the file.
Returns:
Returns a non-negative value if successful; otherwise returns a negative value.
Fortran90 Interface: h5dwrite_f
There are seperate versions of this interface. Their use depends on the datatype of the object being written.

Use the following h5dwrite_f call for all datatypes except object and dataset region references:

SUBROUTINE h5dwrite_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(IN) :: 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 h5dwrite_f
	

Use the following h5dwrite_f call for object reference and dataset region reference datatypes:

SUBROUTINE h5dwrite_f(dset_id, mem_type_id, buf, n, 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
  DIMENSION(*), INTEGER(HSIZE_T), INTENT(IN)  :: dims 
                                            ! Array to hold corresponding 
                                            ! dimension sizes of data 
                                            ! buffer buf 
                                            ! dim(k) has valueof the k-th 
                                            ! dimension of buffer buf; 
                                            ! values are ignored if buf
                                            ! is a scalar
  TYPE(hobj_ref_t_f), DIMENSION(dims(1)), INTENT(INOUT) :: buf
                                            ! Data buffer of rank 1
  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 h5dwrite_f
	

HDF5 documents and links 
Introduction to HDF5 
HDF5 User Guide 
And in this document, the HDF5 Reference Manual  
H5   H5A   H5D   H5E   H5F   H5G   H5I   H5P  
H5R   H5S   H5T   H5Z   Tools   Datatypes  

HDF Help Desk
Describes HDF5 Release 1.7, the unreleased development branch; working toward HDF5 Release 1.8.0