hdf5tools.cpp
Go to the documentation of this file.
79 errmsg << "Failed to "<<VERB<<" "<<OUTPUTNAME<<" for HDF5 dataset! The supplied id does not point to a successfully opened "<<INPUTNAME<<"!"; \ 86 errmsg << "Failed to "<<VERB<<" "<<OUTPUTNAME<<" for HDF5 dataset! See HDF5 error output for more details."; \ 97 errmsg << "Failed to close HDF5 file with ID "<<id<<"! The supplied id does not point to a successfully opened file."; 101 // Check for any open objects! These should all be closed before the file is closed for maximum safety 106 logger() << "Warning! "<<count<<" open objects detected when closing HDF5 file with ID "<<id<<"! Please check your code and ensure that all datasets, groups, selections, etc. are closed before closing the files they belong to."<<std::endl; 109 if(count>1) logger() << " "<<count<<" H5F_OBJ_FILE detected (should only be 1, for the open file itself)"<<std::endl; 125 errmsg << "Failed to close HDF5 file with ID "<<id<<"! See HDF5 error output for more details."; 150 hid_t hdftype_id = get_hdf5_data_type<bool>::type(); // It is assumed that you already know this is the right type for the dataset! 156 errmsg << "Error retrieving chunk (offset="<<offset<<", length="<<length<<") from dataset in HDF5 file. H5Dread failed." << std::endl; 185 //std::cerr<<"Attempting to open file "<<fname<<" in mode "<<access_type<<" (overwrite="<<overwrite<<")"<<std::endl; 201 errmsg << "Unrecognised access mode requested while trying to open HDF5 file! Saw '"<<access_type<<"'; only 'r' (read-only) and 'w' (read/wrtie) are valid. File was ("<<fname<<")"; 212 logger()<<LogTags::utils<<LogTags::warn<<"Failed to delete file '"<<fname<<"'! Maybe it didn't exist in the first place."<<EOM; 216 logger()<<LogTags::utils<<LogTags::info<<"Deleted pre-existing file "<<fname<<" (because overwrite=true)"<<EOM; 235 errmsg << "Failed to open existing HDF5 file, then failed to create new one! ("<<fname<<"). The file may exist but be unreadable. You can check this by trying to inspect it with the 'h5ls' command line tool."; 248 errmsg << "Failed to open existing HDF5 file, and did not create new one since read-only access was specified. ("<<fname<<")"; 260 std::cout<<"Opened file "<<fname<<" in mode "<<access_type<<", and assigned it ID "<<file_id<<std::endl; 289 errmsg << "Failed to properly close HDF5 file after successfully checking that it was readable! ("<<fname<<")"; 296 std::cout<<"Checked that file "<<fname<<" was readable (had RDONLY access and ID "<<file_id<<")"<<std::endl; 314 errmsg<<"H5Gopen failed (tried to open '"<<groupname<<"' from location with id "<<location<<")"; 324 errmsg << "Failed to properly close HDF5 group after successfully checking that it was readable! ("<<groupname<<")"; 333 std::pair<bool,std::size_t> _checkDatasetReadable_helper(hid_t dset_id, const std::string dset_name) 416 err<<"Dataset "<<dset_name<<" was determined to be partially unreadable (corrupted), however we were unable to determine the largest readable index. You will have to investigate the HDF5 file manually."; 461 err << "Did not recognise retrieved HDF5 type for dataset '"<<dsetname<<"'! This may indicate a bug in the GAMBIT HDF5 tools library, please report it."; 519 errmsg << "Error opening HDF5 group '"<<name<<"'. The supplied file_id does not point to a successfully opened file!"; 530 errmsg << "Error opening HDF5 group '"<<name<<"'. Group (probably) does not exist, and 'nocreate' flag is set to 'true', so we will not attempt to create one"; 553 errmsg << "Error while recursively creating/opening group '"<<name<<"'. Failed to create group '"<<path.str()<<"'"; 570 errmsg << "Error opening HDF5 group '"<<name<<"' after recursive creation supposedly succeeded! There must be a bug in this routine, please fix."; 598 errmsg << "Error inspecting HDF5 group. The supplied group_id does not point to an open group object!"; 608 errmsg << "Error encountering while iterating through HDF5 group! See HDF5 error for more details (stderr)."; 623 errmsg << "Attempt to check if object named '"<<name<<"' is a dataset failed! See HDF5 error for more details (stderr)."; 637 errmsg << "Failed to open dataset '"<<dset_name<<"' while attempting to check its HDF5 data type! See stderr output for more details."; 644 errmsg << "Failed to get HDF5 type of dataset '"<<dset_name<<"'. See stderr output for more details."; 698 errmsg << "Error opening HDF5 dataset '"<<name<<"'. The supplied group_id in which the dataset should be located does not point to a successfully opened group!"; 706 errmsg << "Error opening HDF5 dataset '"<<name<<"'. Dataset may not exist at the specified location."; 720 SIMPLE_CALL(hssize_t, getSimpleExtentNpoints, hid_t, H5Sget_simple_extent_npoints, "get", "simple_extent_npoints", "dataspace") 744 errmsg << "Error selecting chunk from dataset in HDF5 file. Tried to select a hyperslab which extends beyond the dataset extents:" << std::endl; 758 herr_t err_hs = H5Sselect_hyperslab(dspace_id, H5S_SELECT_SET, offsets, NULL, selection_dims, NULL); 762 errmsg << "Error selecting chunk from dataset (offset="<<offset<<", length="<<selection_dims[0]<<") in HDF5 file. H5Sselect_hyperslab failed." << std::endl; 777 return std::make_pair(memspace_id, dspace_id); // Be sure to close these identifiers after using them! 838 std::cout << " Type: " << STRINGIFY(elem) << ", H5 type code: " << get_hdf5_data_type<elem>::type() << std::endl; #define PRINTTYPEID(r, data, elem) herr_t group_ls(hid_t g_id, const char *name, const H5L_info_t *, void *op_data) Definition: hdf5tools.cpp:578 std::pair< bool, std::size_t > checkDatasetReadable(hid_t location, const std::string &dsetname) Check if a dataset exists and can be read from fully (Reads through entire dataset to make sure! May ... Definition: hdf5tools.cpp:432 hid_t openDataset(hid_t dset_id, const std::string &name, bool error_off=false) Dataset and dataspace manipulation. Definition: hdf5tools.cpp:691 constexpr int h5v2_type< long long >() Definition: hdf5tools.hpp:283 dataset H5Sget_simple_extent_npoints Definition: hdf5tools.cpp:720 Definition: log_tags.hpp:54 #define RUN_TYPE_DEPENDENT_CHECK(r, data, elem) std::pair< bool, std::size_t > _checkDatasetReadable_helper(hid_t dset_id, const std::string dset_name) Definition: hdf5tools.cpp:333 constexpr int h5v2_type< unsigned long >() Definition: hdf5tools.hpp:282 LOCAL_INFO macro. const hid_t H5P_GAMBIT(create_GAMBIT_fapl()) Const global for the GAMBIT fapl. STL namespace. dataset getSimpleExtentNpoints Definition: hdf5tools.cpp:720 hid_t openFile(const std::string &fname, bool overwrite, bool &oldfile, const char access_type='r') File and group manipulation. Definition: hdf5tools.cpp:182 Logging access header for GAMBIT. constexpr int h5v2_type< unsigned int >() Definition: hdf5tools.hpp:280 void errorsOff() Silence error report (e.g. while probing for file existence) Definition: hdf5tools.cpp:671 dataset simple_extent_npoints Definition: hdf5tools.cpp:720 Definition: log_tags.hpp:38 int inttype_from_h5type(hid_t h5type) Definition: hdf5tools.cpp:783 hid_t createFile(const std::string &fname) Create hdf5 file (always overwrite existing files) Definition: hdf5tools.cpp:471 hid_t createGroup(hid_t location, const std::string &name) Create a group inside the specified location. Definition: hdf5tools.cpp:486 Definition: log_tags.hpp:44 Definition: log_tags.hpp:36 Definition: log_tags.hpp:37 const Logging::endofmessage EOM Explicit const instance of the end of message struct in Gambit namespace. Definition: logger.hpp:100 EXPORT_SYMBOLS Logging::LogMaster & logger() Function to retrieve a reference to the Gambit global log object. Definition: logger.cpp:95 hid_t getH5DatasetType(hid_t group_id, const std::string &dset_name) Get type of an object in a group. Definition: hdf5tools.cpp:631 std::vector< T > getChunk(const hid_t dset_id, std::size_t offset, std::size_t length) Retrieve a chunk of data from a simple dataset NOTE! Doesn't work for T=bool! Have a custom specialis... Definition: hdf5tools.hpp:179 bool checkFileReadable(const std::string &fname, std::string &msg) Check if hdf5 file exists and can be opened in read/write mode. Definition: hdf5tools.cpp:268 std::vector< std::string > lsGroup(hid_t group_id) List object names in a group. Definition: hdf5tools.cpp:593 #define ELSEIF(r, data, elem) constexpr int h5v2_type< double >() Definition: hdf5tools.hpp:286 hid_t openGroup(hid_t file_id, const std::string &name, bool nocreate=false) Definition: hdf5tools.cpp:512 bool checkGroupReadable(hid_t location, const std::string &groupname, std::string &msg) Check if a group exists and can be accessed. Definition: hdf5tools.cpp:302 bool isDataSet(hid_t group_id, const std::string &name) Check if an object in a group is a dataset. Definition: hdf5tools.cpp:616 A collection of tools for interacting with HDF5 databases. Base template is left undefined in order to raise a compile error if specialisation doesn't exist... Definition: hdf5tools.hpp:77 constexpr int h5v2_type< unsigned long long >() Definition: hdf5tools.hpp:284 std::pair< hid_t, hid_t > selectChunk(const hid_t dset_id, std::size_t offset, std::size_t length) Select a simple hyperslab in a 1D dataset. Definition: hdf5tools.cpp:733 SIMPLE_CALL(hid_t, closeType, hid_t, H5Tclose, "close", "type ID", "type ID") SIMPLE_CALL(hid_t Close hdf5 type ID. |