Hyperslab read crashes JVM

I’m trying to read one element of a dataset of doubles [360][719][10][17] at [179][358][0][0] with the following code which crashes performing the H5Dread. Ideas?

Thanks,
Scott

	long[] start = { 179, 358, 0, 0 };
	long[] stride = { 1, 1, 1, 1 };
	long[] count = { 1, 1, 1, 1 };
	long[] block = { 1, 1, 1, 1 };
	double[][][][] dsetData = new double[1][1][1][1];
	dsetData[0][0][0][0] = -423.1958;
	long filespaceId;
	
	try {
		filespaceId = H5.H5Dget_space(valuesDatasetId);
		int ndims = H5.H5Sget_simple_extent_ndims(filespaceId);
		long[] dims = new long[ndims];
		long[] maxdims = new long[ndims];
		H5.H5Sget_simple_extent_dims(filespaceId, dims, maxdims);
		H5.H5Sselect_hyperslab(filespaceId, HDF5Constants.H5S_SELECT_SET, start, stride, count, block);
		H5.H5Dread(valuesDatasetId, HDF5Constants.H5T_NATIVE_DOUBLE, HDF5Constants.H5S_ALL, filespaceId,
					HDF5Constants.H5P_DEFAULT, dsetData);
	} catch (NullPointerException | IllegalArgumentException | HDF5Exception e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}

Hi Scott,

If you specify H5S_ALL for the memory dataspace then the file dataspace is used for the memory dataspace (which can be big).

Can you specify a memory dataspace that is the size of the selection rather than using H5S_ALL, as shown in the attached example?

h5scott.c (4.9 KB)

To create a memory dataspace see:
H5S_CREATE_SIMPLE

In the example I tried to match what you were doing (except I used H5Dwrite), and then I could verify that the value was written, using h5dump:

$ h5dump -d MyArray -s 179,358,0,0 scott.h5
HDF5 “scott.h5” {
DATASET “MyArray” {
DATATYPE H5T_IEEE_F64LE
DATASPACE SIMPLE { ( 360, 719, 10, 17 ) / ( 360, 719, 10, 17 ) }
SUBSET {
START ( 179, 358, 0, 0 );
STRIDE ( 1, 1, 1, 1 );
COUNT ( 1, 1, 1, 1 );
BLOCK ( 1, 1, 1, 1 );
DATA {
(179,358,0,0): -423.196
}
}
}
}

There is also the H5Sselect_elements API for selecting one element at a time.

-Barbara