type = Layout(8); type= 1 (contiguous) storageSize = (10,16) dataSize=0 dataAddress=2048
*/
public void testStructureWithArrayMember() throws IOException {
NetcdfFile ncfile = TestH5.openH5("support/DSwith_array_member.h5");
Variable v = ncfile.findVariable("ArrayOfStructures");
v.setCaching(false);
assert( null != v);
assert( v.getDataType() == DataType.STRUCTURE);
assert( v instanceof Structure);
assert( v.getRank() == 1);
assert( v.getShape()[0] == 10);
try {
Array data = v.read(new int[] {4}, new int[] {3});
assert(data.getElementType() == StructureData.class);
assert (data instanceof ArrayStructure);
assert (data.getSize() == 3) : data.getSize();
assert (data.getRank() == 1);
int count = 0;
IndexIterator iter = data.getIndexIterator();
while (iter.hasNext()) {
Object o = iter.next();
assert (o instanceof StructureData);
StructureData d = (StructureData) o;
Array arr = d.getArray("a_name");
assert (arr != null);
assert (arr.getElementType() == int.class);
assert (arr instanceof ArrayInt);
assert (arr.getInt( arr.getIndex()) == 4 + count);
NCdump.printArray( arr, "a_name", out, null);
arr = d.getArray("b_name");
assert (arr != null);
assert (arr.getElementType() == float.class);
assert (arr instanceof ArrayFloat);
assert (arr.getSize() == 3);
assert (arr.getFloat( arr.getIndex()) == (float) 4.0 + count);
NCdump.printArray( arr, "b_name", out, null);
count++;
}
}
catch (InvalidRangeException e) { assert false; }
catch (IOException e) { assert false; }
try {
Array data = v.read();
assert(data.getElementType() == StructureData.class);
assert (data instanceof ArrayStructure);
assert (data.getSize() == 10);
assert (data.getRank() == 1);