I have code that uses H5Literate and I want to update to a newer HDF5, necessitating using H5Literate2.
The problem is my existing code no longer works:
HDF5-DIAG: Error detected in HDF5 (1.14.3) MPI-process 0:
#000: /var/folders/tr/v_kqwm7x25x3y68l_p5qh1gw0000gn/T/cmarsh/spack-stage/spack-stage-hdf5-1.14.3-vtw2x4axrhoixpcmxjbzlcn6yykcl7oq/spack-src/src/H5L.c line 1647 in H5Literate2(): synchronous link iteration failed
major: Links
minor: Iteration failed
#001: /var/folders/tr/v_kqwm7x25x3y68l_p5qh1gw0000gn/T/cmarsh/spack-stage/spack-stage-hdf5-1.14.3-vtw2x4axrhoixpcmxjbzlcn6yykcl7oq/spack-src/src/H5L.c line 1598 in H5L__iterate_api_common(): can't set object access arguments
major: Links
minor: Can't set value
#002: /var/folders/tr/v_kqwm7x25x3y68l_p5qh1gw0000gn/T/cmarsh/spack-stage/spack-stage-hdf5-1.14.3-vtw2x4axrhoixpcmxjbzlcn6yykcl7oq/spack-src/src/H5VLint.c line 2634 in H5VL_setup_self_args(): invalid location identifier
major: Invalid arguments to routine
minor: Inappropriate type
#003: /var/folders/tr/v_kqwm7x25x3y68l_p5qh1gw0000gn/T/cmarsh/spack-stage/spack-stage-hdf5-1.14.3-vtw2x4axrhoixpcmxjbzlcn6yykcl7oq/spack-src/src/H5VLint.c line 1733 in H5VL_vol_object(): invalid identifier
major: Invalid arguments to routine
minor: Inappropriate type
Where the usage is as follows:
typedef struct _MeshParameters {
std::vector<std::string> names;
} MeshParameters;
herr_t
group_info(hid_t loc_id, const char *name, const H5L_info_t *linfo, void *opdata)
{
hid_t group;
MeshParameters *pars = (MeshParameters*)opdata;
std::string str(name);
group = H5Gopen2(loc_id, name, H5P_DEFAULT);
// cout << "Name : " << str << endl; // Display the group name.
(pars->names).push_back(str);
H5Gclose(group);
return 0;
}
// Open an existing file and dataset.
H5File file(param_filename, H5F_ACC_RDONLY);
// Space for extracting the parameter info
std::unique_ptr<MeshParameters> pars(new MeshParameters);
// Extract all of the parameter info (names) from the file
Group group = file.openGroup("parameters");
herr_t idx = H5Literate(group.getId(), H5_INDEX_NAME, H5_ITER_INC, NULL, group_info, (void*)pars.get());
Tracing the code through suggests the problem is with group.getId() causing it to abort, but it isn’t clear /why/.
The documentation on H5Literate1 and H5Literate2 doesn’t indicate (unless I’m totally missing it) what is different between the two functions and what I might be doing wrong.