H5D_WRITE 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_type_id is either a fixed-length or variable-length string, it is important to set the string length when defining the datatype. String datatypes are derived from
H5T_FORTRAN_S1 for Fortran codes), which defaults to 1 character in size. See H5T_SET_SIZE and Creating variable-length string datatypes.
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:
|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 a dataset will fail if the HDF5 file was not opened with write access permissions.
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.
If the dataset's space allocation time is set to
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_ALLOC. (Also see H5P_SET_FILL_TIME and H5P_SET_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.