Page tree

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »









Iterates over all selected elements in a dataspace. 


H5D_ITERATE(buf, type_id, space_id, operator, operator_data)


herr_t H5Diterate( void *buf, hid_t type_id, hid_t space_id, H5D_operator_t operator, void *operator_data )

void *bufIN/OUT: Pointer to the buffer in memory containing the elements to iterate over
hid_t type_idIN: Datatype identifier for the elements stored in buf
hid_t space_idIN: Dataspace identifier for buf
H5D_operator_t operator    IN: Function pointer to the routine to be called for each element in buf iterated over
void *operator_dataIN/OUT: Pointer to any user-defined data associated with the operation


H5Diterate iterates over all the data elements in the memory buffer buf, executing the callback function operator once for each such data element.

The protoype of the callback function operator is as follows (as defined in the source code file H5Lpublic.h):

herr_t (*H5D_operator_t)(void elem, hid_t type_id, unsigned ndim, 
                         const hsize_t *point, void *operator_data)

The parameters of this callback function have the following values or meanings:

void *elemIN/OUT: Pointer to the memory buffer containing the current data element
hid_t type_idIN: Datatype identifier for the elements stored in elem
unsigned ndimIN: Number of dimensions for the point array
const hsize_t *pointIN: Array containing the location of the element within the original dataspace
void *operator_dataIN/OUT: Pointer to any user-defined data associated with the operation

The possible return values from the callback function, and the effect of each, are as follows:

  • Zero causes the iterator to continue, returning zero when all data elements have been processed.
  • A positive value causes the iterator to immediately return that positive value, indicating short-circuit success.
  • A negative value causes the iterator to immediately return that value, indicating failure.

The H5Diterate operator_data parameter is a user-defined pointer to the data required to process dataset elements in the course of the iteration. If operator needs to pass data back to the application, such data can be returned in this same buffer. This pointer is passed back to each step of the iteration in the operator callback function’s operator_data parameter.

Unlike other HDF5 iterators, this iteration operation cannot be restarted at the point of exit; a second H5Diterate call will always restart at the beginning.


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.


examples / h5_subset.c [32:42]
 1.10/master  HDFFV/hdf5  Copy
main (void)
    hsize_t     dims[2], dimsm[2];   
    int         data[DIM0][DIM1];           /* data to write */
    int         sdata[DIM0_SUB][DIM1_SUB];  /* subset to write */
    int         rdata[DIM0][DIM1];          /* buffer for read */
    hid_t       file_id, dataset_id;        /* handles */
    hid_t       dataspace_id, memspace_id; 

fortran / examples / compound.f90 [25:35]
 1.10/master  HDFFV/hdf5  Copy

     USE HDF5 ! This module contains all necessary modules


     CHARACTER(LEN=11), PARAMETER :: filename = "compound.h5" ! File name
     CHARACTER(LEN=8), PARAMETER :: dsetname = "Compound"     ! Dataset name
     INTEGER, PARAMETER :: dimsize = 6 ! Size of the dataset

     INTEGER(HID_T) :: file_id       ! File identifier

c++ / examples / create.cpp [33:43]
 1.10/master  HDFFV/hdf5  Copy
int main (void)
    * Data initialization.
   int i, j;
   int data[NX][NY];          // buffer for data to write
   for (j = 0; j < NX; j++)
      for (i = 0; i < NY; i++)

public class H5Ex_D_Chunk {
    private static String FILENAME = "H5Ex_D_Chunk.h5";
    private static String DATASETNAME = "DS1";
    private static final int DIM_X = 6;
    private static final int DIM_Y = 8;
    private static final int CHUNK_X = 4;
    private static final int CHUNK_Y = 4;
    private static final int RANK = 2;
    private static final int NDIMS = 2;

Release    C
1.6.4The following changes occured in the H5D_operator_t function in this release:
   ndim parameter type was changed to unsigned
   point parameter type was changed to const hsize_t

--- Last Modified: November 03, 2017 | 08:26 AM