Introduction to HDF5 
HDF5 User Guide 
Other HDF5 documents and links 
And in this document, the HDF5 Reference Manual  
H5   H5A   H5D   H5E   H5F   H5G   H5I   H5P  
H5R   H5RA   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:
             

The FORTRAN90 Interfaces:
In general, each FORTRAN90 subroutine performs exactly the same task as the corresponding C function. The links below go to the C function descriptions, which serve as general descriptions for both. A button, under Non-C API(s) at the end of the C function description, opens an external browser window displaying the FORTRAN90-specific information. You will probably want to adjust the size and location of this external window so that both browser windows are visible and to facilitate moving easily between them.
             


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 a dataset identifier for success or negative for failure. The identifier should eventually be closed by calling H5Dclose() to release resources it uses.

Parameters:
hid_t loc_id
Identifier of the file or group to create the dataset within.
const char * name
The name of the dataset to create.
hid_t type_id
Identifier of the datatype to use when creating the dataset.
hid_t space_id
Identifier of the dataspace to use when creating the dataset.
hid_t create_plist_id
Identifier of the set creation property list.
Returns:
Returns a dataset identifier if successful; otherwise returns a negative value.
Non-C API(s):

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
Identifier of the file or group to access the dataset within.
const char * name
The name of the dataset to access.
Returns:
Returns a dataset identifier if successful; otherwise returns a negative value.
Non-C API(s):

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
Identifier of the dataset to query.
Returns:
Returns a dataspace identifier if successful; otherwise returns a negative value.
Non-C API(s):

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
Identifier of the dataset to query.
Returns:
Returns a datatype identifier if successful; otherwise returns a negative value.
Non-C API(s):

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
Identifier of the dataset to query.
Returns:
Returns a dataset creation property list identifier if successful; otherwise returns a negative value.
Non-C API(s):

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
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).

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
Identifier of the dataset to query.
hid_t type_id
Datatype identifier.
hid_t space_id
Dataspace identifier.
hsize_t *size
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.

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
Identifier of the datatype.
hid_t space_id
Identifier of the dataspace.
hid_t plist_id
Identifier of the property list used to create the buffer.
void *buf
Pointer to the buffer to be reclaimed.
Returns:
Returns non-negative value if successful; otherwise returns a negative value.

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 the specified dataset into buf, converting from file datatype and dataspace to memory datatype and dataspace.
Description:
H5Dread reads a (partial) dataset, specified by its identifier dataset_id, from the file into the 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 can be the constant H5S_ALL, which indicates that the entire file data space is to be referenced.

mem_space_id can be the constant H5S_ALL, in which case the memory data space is the same as the file data space defined when the dataset was created.

The number of elements in the memory data space must match the number of elements in the file data space.

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 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
Identifier of the dataset read from.
hid_t mem_type_id
Identifier of the memory datatype.
hid_t mem_space_id
Identifier of the memory dataspace.
hid_t file_space_id
Identifier of the dataset's dataspace in the file.
hid_t xfer_plist_id
Identifier of a transfer property list for this I/O operation.
void * buf
Buffer to store data read from the file.
Returns:
Returns a non-negative value if successful; otherwise returns a negative value.
Non-C API(s):

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 an application buffer buf to the specified dataset, converting from memory datatype and dataspace to file datatype and dataspace.
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 can be the constant H5S_ALL. which indicates that the entire file data space is to be referenced.

mem_space_id can be the constant H5S_ALL, in which case the memory data space is the same as the file data space defined when the dataset was created.

The number of elements in the memory data space must match the number of elements in the file data space.

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

Writing to an external dataset will fail if the HDF5 file is not open for writing.

Datatype conversion takes place at the time of a read or write and is automatic. 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
Identifier of the dataset read from.
hid_t mem_type_id
Identifier of the memory datatype.
hid_t mem_space_id
Identifier of the memory dataspace.
hid_t file_space_id
Identifier of the dataset's dataspace in the file.
hid_t xfer_plist_id
Identifier of a transfer property list for this I/O operation.
const void * buf
Buffer with data to be written to the file.
Returns:
Returns a non-negative value if successful; otherwise returns a negative value.
Non-C API(s):

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.
Parameters:
hid_t dataset_id
Identifier of the dataset.
const hsize_t * size
Array containing the new magnitude of each dimension.
Returns:
Returns a non-negative value if successful; otherwise returns a negative value.
Non-C API(s):

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
Identifier of the dataset to finish access to.
Returns:
Returns a non-negative value if successful; otherwise returns a negative value.
Non-C API(s):

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.

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

HDF Help Desk
Last modified: 13 November 2000
Describes HDF5 Release 1.4 Beta, December 2000