Added another layer for hdf5_write_array
This commit is contained in:
parent
1180e6ac88
commit
bf0be4fb61
@ -21,7 +21,7 @@ liability.
|
||||
In this respect, the user's attention is drawn to the risks associated
|
||||
with loading, using, modifying and/or developing or reproducing the
|
||||
software by the user in light of its specific status of free software,
|
||||
that may mean that it is complicated to manipulate, and that also
|
||||
sthat may mean that it is complicated to manipulate, and that also
|
||||
therefore means that it is reserved for developers and experienced
|
||||
professionals having in-depth computer knowledge. Users are therefore
|
||||
encouraged to load and test the software's suitability as regards their
|
||||
@ -100,16 +100,39 @@ namespace CosmoTool {
|
||||
template<typename ArrayType, typename hdf5_data_type>
|
||||
void hdf5_write_array(H5::CommonFG& fg, const std::string& data_set_name,
|
||||
const ArrayType& data,
|
||||
const hdf5_data_type& datatype)
|
||||
const hdf5_data_type& datatype,
|
||||
const std::vector<hsize_t>& dimensions,
|
||||
bool doCreate = true,
|
||||
bool useBases = false)
|
||||
{
|
||||
std::vector<hsize_t> dimensions(data.shape(), data.shape() + data.num_dimensions());
|
||||
H5::DataSpace dataspace(data.num_dimensions(), dimensions.data());
|
||||
|
||||
H5::DataSet dataset = fg.createDataSet(data_set_name, datatype, dataspace);
|
||||
if (useBases) {
|
||||
std::vector<hssize_t> offsets(data.index_bases(), data.index_bases() + data.num_dimensions());
|
||||
dataspace.offsetSimple(offsets.data());
|
||||
}
|
||||
|
||||
H5::DataSet dataset;
|
||||
if (doCreate)
|
||||
dataset = fg.createDataSet(data_set_name, datatype, dataspace);
|
||||
else
|
||||
dataset = fg.openDataSet(data_set_name);
|
||||
|
||||
dataset.write(data.data(), datatype);
|
||||
}
|
||||
|
||||
|
||||
template<typename ArrayType, typename hdf5_data_type>
|
||||
void hdf5_write_array(H5::CommonFG& fg, const std::string& data_set_name,
|
||||
const ArrayType& data,
|
||||
const hdf5_data_type& datatype,
|
||||
bool doCreate = true,
|
||||
bool useBases = false)
|
||||
{
|
||||
std::vector<hsize_t> dimensions(data.shape(), data.shape() + data.num_dimensions());
|
||||
hdf5_write_array(fg, data_set_name, data, datatype, dimensions, doCreate, useBases);
|
||||
}
|
||||
|
||||
/* HDF5 complex type */
|
||||
template<typename T>
|
||||
class hdf5_ComplexType
|
||||
|
Loading…
Reference in New Issue
Block a user