Skip to content
Snippets Groups Projects

HDF5 minimal example

Merged Tobias Meisel requested to merge without_odds into main
1 file
+ 6
28
Compare changes
  • Side-by-side
  • Inline
+ 6
28
@@ -48,8 +48,8 @@ main (void)
"the 5 lazy dogs"},
*rdata2,
*name;
int ndims;
hsize_t i;
int ndims,
i;
/*
* Create a new file using the default properties.
@@ -88,49 +88,27 @@ main (void)
/*
* Create the dataset and write the region references to it.
*/
dset = H5Dcreate (file, DATASET, H5T_STD_REF_DSETREG, space, H5P_DEFAULT,
H5P_DEFAULT, H5P_DEFAULT);
status = H5Dwrite (dset, H5T_STD_REF_DSETREG, H5S_ALL, H5S_ALL, H5P_DEFAULT,
wdata);
status = H5Dclose (dset);
/*
* Close and release resources.
*/
status = H5Dclose (dset);
status = H5Dclose (dset2);
status = H5Sclose (space);
status = H5Fclose (file);
/*
* Now we begin the read section of this example. Here we assume
* the dataset has the same name and rank, but can have any size.
* Therefore we must allocate a new array to read in data using
* malloc().
*/
/*
* Open file and dataset.
*/
file = H5Fopen (FILE, H5F_ACC_RDONLY, H5P_DEFAULT);
dset = H5Dopen (file, DATASET, H5P_DEFAULT);
/*
* Get dataspace and allocate memory for read buffer.
*/
space = H5Dget_space (dset);
ndims = H5Sget_simple_extent_dims (space, dims, NULL);
rdata = (hdset_reg_ref_t *) malloc (dims[0] * sizeof (hdset_reg_ref_t));
status = H5Sclose (space);
/*
* Close and release resources.
*/
free (rdata);
status = H5Dclose (dset);
status = H5Fclose (file);
return 0;
}
Loading