Greetings,
I’m new to hdf5 I’m trying to get to grips with it by following some examples from this page:
https://portal.hdfgroup.org/display/HDF5/Introduction+to+HDF5
I’m using c++ (c++11) and CentOs7 (CentOS Linux release 7.9.2009 (Core), gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44))
The code is shown below:
//set up HDF5 file here
hid_t file_id;
herr_t status;
file_id = H5Fcreate ("file.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
status = H5Fclose (file_id);
//Create the dataspace for the dataset.
hsize_t dims[2];
dims[0] = 4;
dims[1] = 6;
hid_t dataspace_id = H5Screate_simple(2, dims, NULL);
// Create the dataset.
hid_t dataset_id = H5Dcreate (file_id, "/dset", H5T_STD_I32BE, dataspace_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
// Close the dataset and dataspace
status = H5Dclose(dataset_id);
status = H5Sclose(dataspace_id);
As I understand it this should be a simple process but I get the following error:
HDF5-DIAG: Error detected in HDF5 (1.12.1) thread 0:
#000: /user/rcollins/programs/hdf5-1.12.1/src/H5D.c line 132 in H5Dcreate2(): invalid location identifier
major: Invalid arguments to routine
minor: Inappropriate type
HDF5-DIAG: Error detected in HDF5 (1.12.1) thread 0:
#000: /user/rcollins/programs/hdf5-1.12.1/src/H5D.c line 320 in H5Dclose(): not a dataset ID
major: Invalid arguments to routine
minor: Inappropriate type
This is very confusing to me, browsing an old thread apparently this could be a memory issue. With such a simple example how is that the case? Have I made a basic error somewhere? The issue seems to be in H5Dcreate and H5Dclose() but everything else seems to be working fine I can see that a file called “file.h5” is written to disk. Any help would be greatly appreciated.
Kind regards, Ron.