This web site is no longer maintained (but will remain online).
Please see The HDF Group's new Support Portal for the latest information.

# HDF5 Tutorial:   Advanced Topics Selecting Individual Points

## Description

This topic shows how to select and write to independent points in a dataset.

## Programming Example

### Description

The H5Sselect_elements / h5sselect_elements_f call allows you to select individual points in a dataspace. By use of it, you can read and write to individual points in a dataset.

For details on compiling an HDF5 application click here.

### Remarks

• H5Sselect_elements / h5sselect_elements_f selects array elements to be included in the selection for a dataspace.

The coord array is a two-dimensional array of size NUMP x RANK in C (RANK x NUMP in FORTRAN) where NUMP is the number of selected points and RANK is the rank of the dataset.

Note that these coordinates are 0-based in C and 1-based in FORTRAN.

Consider the non-zero elements of the following array:

0  59   0  53
0   0   0   0
0   0   1   0
In C, the coord array selecting these points would be as follows:
0   1
0   3
2   2
While in FORTRAN, the coord array would be as follows:
1   1   3
2   4   3

• The example code calls H5Scopy / h5scopy_f to create an exact copy of a dataspace.

### File Contents

Following is the DDL for copy1.h5 and copy2.h5, as viewed with the following commands:
h5dump copy1.h5
h5dump copy2.h5

C:

Fig. S.1a   copy1.h5 in DDL

HDF5 "copy1.h5" {
GROUP "/" {
DATASET "Copy1" {
DATATYPE { H5T_STD_I32BE }
DATASPACE { SIMPLE ( 3, 4 ) / ( 3, 4 ) }
DATA {
0, 59, 0, 53,
0, 0, 0, 0,
0, 0, 0, 0
}
}
}
}
Fig. S.1b   copy2.h5 in DDL
HDF5 "copy2.h5" {
GROUP "/" {
DATASET "Copy2" {
DATATYPE { H5T_STD_I32BE }
DATASPACE { SIMPLE ( 3, 4 ) / ( 3, 4 ) }
DATA {
1, 59, 1, 53,
1, 1, 1, 1,
1, 1, 1, 1
}
}
}
}

FORTRAN:

Fig. S.2a   copy1.h5 in DDL

HDF5 "copy1.h5" {
GROUP "/" {
DATASET "Copy1" {
DATATYPE { H5T_STD_I32BE }
DATASPACE { SIMPLE ( 4, 3 ) / ( 4, 3 ) }
DATA {
0, 0, 0,
53, 0, 0,
0, 0, 0,
59, 0, 0
}
}
}
}
Fig. S.2b   copy2.h5 in DDL
HDF5 "copy2.h5" {
GROUP "/" {
DATASET "Copy2" {
DATATYPE { H5T_STD_I32BE }
DATASPACE { SIMPLE ( 4, 3 ) / ( 4, 3 ) }
DATA {
1, 1, 1,
53, 1, 1,
1, 1, 1,
59, 1, 1
}
}
}
}

- - Last modified: 21 December 2016