41std::once_flag h5open_once_flag;
43#if (defined(H5_HAVE_THREADSAFE) || defined(H5_HAVE_CONCURRENCY))
44bool global_hdf5_mutex_is_active =
false;
46bool global_hdf5_mutex_is_active =
true;
49std::mutex global_hdf5_mutex;
50Hdf5Mutex hdf5_mutex(global_hdf5_mutex, global_hdf5_mutex_is_active);
52#if (defined(H5_HAVE_THREADSAFE) || defined(H5_HAVE_CONCURRENCY))
53#define ARCANE_HDF5_MUTEX
66#define ARCANE_HDF5_MUTEX ScopedMutex scoped_mutex
83 std::call_once(h5open_once_flag, [](){ H5open(); });
92#ifdef H5_HAVE_PARALLEL
105#if (defined(H5_HAVE_THREADSAFE) || defined(H5_HAVE_CONCURRENCY))
106 pm->traceMng()->info(4) <<
"HDF5 -- Is HDF5 threadsafe: 1 -- Is Mutex enabled: " << global_hdf5_mutex_is_active;
108 bool env_is_enable =
true;
110 env_is_enable = (v.value() == 0);
113 global_hdf5_mutex.lock();
114 global_hdf5_mutex_is_active = env_is_enable && is_active;
115 global_hdf5_mutex.unlock();
117 pm->traceMng()->info(4) <<
"HDF5 -- Is HDF5 threadsafe: 0 -- Is Mutex enabled: " << global_hdf5_mutex_is_active;
127hid_t _H5Gopen(hid_t loc_id,
const char *name)
129 return H5Gopen2(loc_id,name,H5P_DEFAULT);
132hid_t _H5Gcreate(hid_t loc_id,
const char *name)
134 return H5Gcreate2(loc_id, name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
141extern "C" ARCANE_HDF5_EXPORT herr_t
142_ArcaneHdf5UtilsGroupIterateMe(hid_t g,
const char* mn,
void* ptr)
146 return rw->iterateMe(mn);
153splitString(
const String& str,Array<String>& str_array,
char c)
155 const char* str_str = str.localstr();
159 if (str_str[i]==c && i!=offset){
160 str_array.add(std::string_view(str_str+offset,i-offset));
165 str_array.add(std::string_view(str_str+offset,len-offset));
172openTruncate(
const String& var)
177 _setId(H5Fcreate(var.localstr(), H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT));
180 ARCANE_THROW(ReaderWriterException,
"Can not open file '{0}'",var);
184openAppend(
const String& var)
189 _setId(H5Fopen(var.localstr(), H5F_ACC_RDWR, H5P_DEFAULT));
192 ARCANE_THROW(ReaderWriterException,
"Can not open file '{0}'",var);
196openRead(
const String& var)
201 _setId(H5Fopen(var.localstr(), H5F_ACC_RDONLY, H5P_DEFAULT));
204 ARCANE_THROW(ReaderWriterException,
"Can not open file '{0}'",var);
208openTruncate(
const String& var,hid_t plist_id)
213 _setId(H5Fcreate(var.localstr(), H5F_ACC_TRUNC, H5P_DEFAULT, plist_id));
216 ARCANE_THROW(ReaderWriterException,
"Can not open file '{0}'",var);
220openAppend(
const String& var,hid_t plist_id)
225 _setId(H5Fopen(var.localstr(), H5F_ACC_RDWR, plist_id));
228 ARCANE_THROW(ReaderWriterException,
"Can not open file '{0}'",var);
232openRead(
const String& var,hid_t plist_id)
237 _setId(H5Fopen(var.localstr(), H5F_ACC_RDONLY, plist_id));
240 ARCANE_THROW(ReaderWriterException,
"Can not open file '{0}'",var);
266 ARCANE_THROW(ReaderWriterException,
"Can not close file");
273recursiveCreate(
const Hid& loc_id,
const String& var)
275 UniqueArray<String> bufs;
276 splitString(var,bufs,
'/');
277 recursiveCreate(loc_id,bufs);
281recursiveCreate(
const Hid& loc_id,
const Array<String>& bufs)
284 hid_t last_hid = loc_id.id();
285 Integer nb_create = bufs.size();
286 UniqueArray<hid_t> ref_ids(nb_create);
287 for (
Integer i = 0; i < nb_create; ++i) {
288 last_hid = _checkOrCreate(last_hid,bufs[i]);
289 ref_ids[i] = last_hid;
293 for (
Integer i = 0; i < nb_create - 1; ++i) {
294 H5Gclose(ref_ids[i]);
303checkDelete(
const Hid& loc_id,
const String& var)
305 UniqueArray<String> bufs;
306 splitString(var,bufs,
'/');
307 hid_t last_hid = loc_id.id();
308 hid_t parent_hid = last_hid;
311 for( ; i<size; ++i ){
312 parent_hid = last_hid;
313 last_hid = _checkExist(last_hid,bufs[i]);
318 if (last_hid>0 && parent_hid>0 && i==size){
321 H5Gunlink(parent_hid, bufs[size - 1].localstr());
329recursiveOpen(
const Hid& loc_id,
const String& var)
332 UniqueArray<String> bufs;
333 splitString(var,bufs,
'/');
334 hid_t last_hid = loc_id.id();
336 UniqueArray<hid_t> ref_ids(nb_open);
338 for (
Integer i = 0; i < nb_open; ++i) {
339 last_hid = _H5Gopen(last_hid,bufs[i].localstr());
340 ref_ids[i] = last_hid;
343 for (
Integer i = 0; i < nb_open - 1; ++i) {
344 H5Gclose(ref_ids[i]);
353openIfExists(
const Hid& loc_id,
const Array<String>& paths)
356 hid_t last_hid = loc_id.id();
357 bool is_valid =
true;
358 Integer nb_open = paths.size();
359 UniqueArray<hid_t> ref_ids;
360 ref_ids.reserve(nb_open);
361 for (
Integer i = 0; i < nb_open; ++i) {
362 if (HGroup::hasChildren(last_hid, paths[i].localstr())) {
364 last_hid = _H5Gopen(last_hid,paths[i].localstr());
365 ref_ids.add(last_hid);
376 for (
Integer i = 0; i < ref_ids.size(); ++i) {
377 if (ref_ids[i] != last_hid) {
378 H5Gclose(ref_ids[i]);
387hasChildren(
const String& var)
389 return hasChildren(
id(),var);
396hasChildren(hid_t loc_id,
const String& var)
398 HGroupSearch gs(var);
400 herr_t v = H5Giterate(loc_id,
".",0,_ArcaneHdf5UtilsGroupIterateMe,&gs);
401 bool has_children = v>0;
410_checkOrCreate(hid_t loc_id,
const String& group_name)
416 HGroupSearch gs(group_name);
419 herr_t v = H5Giterate(loc_id,
".",0,_ArcaneHdf5UtilsGroupIterateMe,&gs);
426 return _H5Gopen(loc_id,group_name.localstr());
428 hid_t new_id = _H5Gcreate(loc_id,group_name.localstr());
437create(
const Hid& loc_id,
const String& group_name)
440 _setId(H5Gcreate2(loc_id.id(), group_name.localstr(), H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT));
447openOrCreate(
const Hid& loc_id,
const String& group_name)
449 hid_t
id = _checkOrCreate(loc_id.id(),group_name);
451 ARCANE_THROW(ReaderWriterException,
"Can not open or create group named '{0}'",group_name);
459open(
const Hid& loc_id,
const String& var)
464 id = _H5Gopen(loc_id.id(), var.localstr());
467 ARCANE_THROW(ReaderWriterException,
"Can not find group named '{0}'",var);
488_checkExist(hid_t loc_id,
const String& group_name)
494 HGroupSearch gs(group_name);
497 herr_t v = H5Giterate(loc_id,
".",0,_ArcaneHdf5UtilsGroupIterateMe,&gs);
504 return _H5Gopen(loc_id,group_name.localstr());
530createSimple(
int nb, hsize_t dims[])
533 _setId(H5Screate_simple(nb, dims,
nullptr));
540createSimple(
int nb, hsize_t dims[], hsize_t max_dims[])
543 _setId(H5Screate_simple(nb, dims, max_dims));
553 return H5Sget_simple_extent_ndims(
id());
560getDimensions(hsize_t dims[], hsize_t max_dims[])
563 return H5Sget_simple_extent_dims(
id(), dims, max_dims);
586create(
const Hid& loc_id,
const String& var,hid_t save_type,
587 const HSpace& space_id, hid_t plist)
590 hid_t hid = H5Dcreate2(loc_id.id(), var.localstr(), save_type, space_id.id(),
591 plist, H5P_DEFAULT, H5P_DEFAULT);
600create(
const Hid& loc_id,
const String& var,hid_t save_type,
605 hid_t hid = H5Dcreate2(loc_id.id(), var.localstr(), save_type, space_id.id(),
606 link_plist.id(),creation_plist.id(),access_plist.id());
615write(hid_t native_type,
const void* array)
619 return H5Dwrite(
id(), native_type, H5S_ALL, H5S_ALL, H5P_DEFAULT, array);
626write(hid_t native_type,
const void* array,
const HSpace& memspace_id,
627 const HSpace& filespace_id,hid_t plist)
631 return H5Dwrite(
id(),native_type,memspace_id.id(),filespace_id.id(),plist,array);
638write(hid_t native_type,
const void* array,
const HSpace& memspace_id,
643 return H5Dwrite(
id(),native_type,memspace_id.id(),filespace_id.id(),plist.id(),array);
650read(hid_t native_type,
void* array)
653 return H5Dread(
id(), native_type, H5S_ALL, H5S_ALL, H5P_DEFAULT, array);
660readWithException(hid_t native_type,
void* array)
665 err = H5Dread(
id(), native_type, H5S_ALL, H5S_ALL, H5P_DEFAULT, array);
678 return HSpace(H5Dget_space(
id()));
685setExtent(
const hsize_t new_dims[])
688 return H5Dset_extent(
id(),new_dims);
695recursiveCreate(
const Hid& loc_id,
const String& var,hid_t save_type,
696 const HSpace& space_id,hid_t plist)
700 UniqueArray<String> paths;
701 splitString(var,paths,
'/');
702 Integer nb_path = paths.size();
704 if (HGroup::hasChildren(loc_id.id(),var)){
705 _remove(loc_id.id(),var);
707 create(loc_id,var,save_type,space_id,plist);
710 String last_name = paths[nb_path-1];
711 paths.resize(nb_path-1);
713 group.recursiveCreate(loc_id,paths);
714 if (group.hasChildren(last_name)){
715 _remove(group.id(),last_name);
717 create(group.id(),last_name,save_type,space_id,plist);
724_remove(hid_t hid,
const String& var)
727 H5Gunlink(hid, var.localstr());
746remove(
const Hid& loc_id,
const String& var)
749 _setId(H5Adelete(loc_id.id(), var.localstr()));
756create(
const Hid& loc_id,
const String& var, hid_t save_type,
const HSpace& space_id)
759 _setId(H5Acreate2(loc_id.id(), var.localstr(), save_type, space_id.id(), H5P_DEFAULT, H5P_DEFAULT));
766open(
const Hid& loc_id,
const String& var)
769 _setId(H5Aopen_name(loc_id.id(), var.localstr()));
776write(hid_t native_type,
void* array)
779 return H5Awrite(
id(), native_type, array);
786read(hid_t native_type,
void* array)
789 return H5Aread(
id(), native_type, array);
799 return HSpace(H5Aget_space(
id()));
824open(
const Hid& loc_id,
const String& var)
828 _setId(H5Dopen2(loc_id.id(), var.localstr(), H5P_DEFAULT));
831 ARCANE_THROW(IOException,
"Can not open dataset '{0}'",var);
838openIfExists(
const Hid& loc_id,
const String& var)
840 UniqueArray<String> paths;
841 splitString(var,paths,
'/');
842 Integer nb_path = paths.size();
844 String last_name = var;
846 last_name = paths[nb_path-1];
847 paths.resize(nb_path-1);
848 parent_group.openIfExists(loc_id,paths);
851 parent_group.open(loc_id,
".");
853 if (parent_group.isBad())
855 if (parent_group.hasChildren(last_name))
856 open(loc_id.id(),var.localstr());
883 _setId(H5Pcreate(cls_id));
892#ifdef H5_HAVE_PARALLEL
896 MPI_Comm mpi_comm = *((MPI_Comm*)arcane_comm);
897 MPI_Info mpi_info = MPI_INFO_NULL;
899 create(H5P_FILE_ACCESS);
900 H5Pset_fapl_mpio(
id(), mpi_comm, mpi_info);
913#ifdef H5_HAVE_PARALLEL
914 create(H5P_DATASET_XFER);
915 H5Pset_dxpl_mpio(
id(), H5FD_MPIO_COLLECTIVE);
951 hid_t type_id = H5Tcopy(H5T_NATIVE_CHAR);
955 hid_t type_id = H5Tcopy(H5T_NATIVE_UCHAR);
959 hid_t type_id = H5Tcopy(H5T_NATIVE_SCHAR);
963 hid_t type_id = H5Tcopy(H5T_NATIVE_SHORT);
964 H5Tset_precision(type_id,8*
sizeof(
short));
965 H5Tset_order(type_id,H5T_ORDER_LE);
969 hid_t type_id = H5Tcopy(H5T_NATIVE_INT);
970 H5Tset_precision(type_id,8*
sizeof(
int));
971 H5Tset_order(type_id,H5T_ORDER_LE);
975 hid_t type_id = H5Tcopy(H5T_NATIVE_LONG);
976 H5Tset_precision(type_id,8*
sizeof(
long));
977 H5Tset_order(type_id,H5T_ORDER_LE);
981 hid_t type_id = H5Tcopy(H5T_NATIVE_USHORT);
982 H5Tset_precision(type_id,8*
sizeof(
unsigned short));
983 H5Tset_order(type_id,H5T_ORDER_LE);
987 hid_t type_id = H5Tcopy(H5T_NATIVE_UINT);
988 H5Tset_precision(type_id,8*
sizeof(
unsigned int));
989 H5Tset_order(type_id,H5T_ORDER_LE);
993 hid_t type_id = H5Tcopy(H5T_NATIVE_ULONG);
994 H5Tset_precision(type_id,8*
sizeof(
unsigned long));
995 H5Tset_order(type_id,H5T_ORDER_LE);
999 hid_t type_id = H5Tcopy(H5T_NATIVE_FLOAT);
1000 H5Tset_precision(type_id,8*
sizeof(
float));
1001 H5Tset_order(type_id,H5T_ORDER_LE);
1005 hid_t type_id = H5Tcopy(H5T_NATIVE_DOUBLE);
1006 H5Tset_precision(type_id,8*
sizeof(
double));
1007 H5Tset_order(type_id,H5T_ORDER_LE);
1011 hid_t type_id = H5Tcreate(H5T_COMPOUND,
sizeof(
Real2POD));
1012 _H5Tinsert(type_id,
"X",HOFFSET(
Real2POD,x),H5T_NATIVE_DOUBLE);
1013 _H5Tinsert(type_id,
"Y",HOFFSET(
Real2POD,y),H5T_NATIVE_DOUBLE);
1017 hid_t type_id = H5Tcreate(H5T_COMPOUND,
sizeof(
Real3POD));
1018 _H5Tinsert(type_id,
"X",HOFFSET(
Real3POD,x),H5T_NATIVE_DOUBLE);
1019 _H5Tinsert(type_id,
"Y",HOFFSET(
Real3POD,y),H5T_NATIVE_DOUBLE);
1020 _H5Tinsert(type_id,
"Z",HOFFSET(
Real3POD,z),H5T_NATIVE_DOUBLE);
1024 hid_t type_id = H5Tcreate(H5T_COMPOUND,
sizeof(
Real2x2POD));
1025 _H5Tinsert(type_id,
"XX",HOFFSET(
Real2x2POD,x.x),H5T_NATIVE_DOUBLE);
1026 _H5Tinsert(type_id,
"XY",HOFFSET(
Real2x2POD,x.y),H5T_NATIVE_DOUBLE);
1027 _H5Tinsert(type_id,
"YX",HOFFSET(
Real2x2POD,y.x),H5T_NATIVE_DOUBLE);
1028 _H5Tinsert(type_id,
"YY",HOFFSET(
Real2x2POD,y.y),H5T_NATIVE_DOUBLE);
1032 hid_t type_id = H5Tcreate(H5T_COMPOUND,
sizeof(
Real3x3POD));
1033 _H5Tinsert(type_id,
"XX",HOFFSET(
Real3x3POD,x.x),H5T_NATIVE_DOUBLE);
1034 _H5Tinsert(type_id,
"XY",HOFFSET(
Real3x3POD,x.y),H5T_NATIVE_DOUBLE);
1035 _H5Tinsert(type_id,
"XZ",HOFFSET(
Real3x3POD,x.z),H5T_NATIVE_DOUBLE);
1036 _H5Tinsert(type_id,
"YX",HOFFSET(
Real3x3POD,y.x),H5T_NATIVE_DOUBLE);
1037 _H5Tinsert(type_id,
"YY",HOFFSET(
Real3x3POD,y.y),H5T_NATIVE_DOUBLE);
1038 _H5Tinsert(type_id,
"YZ",HOFFSET(
Real3x3POD,y.z),H5T_NATIVE_DOUBLE);
1039 _H5Tinsert(type_id,
"ZX",HOFFSET(
Real3x3POD,z.x),H5T_NATIVE_DOUBLE);
1040 _H5Tinsert(type_id,
"ZY",HOFFSET(
Real3x3POD,z.y),H5T_NATIVE_DOUBLE);
1041 _H5Tinsert(type_id,
"ZZ",HOFFSET(
Real3x3POD,z.z),H5T_NATIVE_DOUBLE);
1051 hid_t type_id = H5Tcopy(H5T_NATIVE_B16);
1056 hid_t type_id = H5Tcopy(H5T_NATIVE_B16);
1075_H5Tinsert(hid_t type,
const char* name,
Integer offset,hid_t field_id)
1078 herr_t herr = H5Tinsert(type,name,offset,field_id);
1087#ifdef ARCANE_REAL_NOT_BUILTIN
1088hid_t StandardTypes::
1089nativeType(
Real)
const
1095hid_t StandardTypes::
1101 case DT_Real2:
return saveType(Real2());
1103 case DT_Real3:
return saveType(Real3());
1113 throw ArgumentException(String::format(
"Bad type '{0}'",sd));
1120hid_t StandardTypes::
1126 case DT_Real2:
return nativeType(Real2());
1127 case DT_Real2x2:
return nativeType(Real2x2());
1128 case DT_Real3:
return nativeType(Real3());
1129 case DT_Real3x3:
return nativeType(Real3x3());
1138 throw ArgumentException(String::format(
"Bad type '{0}'",sd));
1149StandardArray(hid_t hfile,
const String& hpath)
1152, m_ids_hpath(hpath +
"_Ids")
1166 m_hdataset.open(m_hfile,m_hpath);
1167 HSpace hspace(m_hdataset.getSpace());
1169 const int max_dim = 256;
1170 hsize_t hdf_dims[max_dim];
1171 hsize_t max_dims[max_dim];
1175 nb_dim = H5Sget_simple_extent_ndims(hspace.id());
1176 H5Sget_simple_extent_dims(hspace.id(), hdf_dims, max_dims);
1178 for (
Integer i = 0; i < nb_dim; ++i) {
1181 m_dimensions.add((
Int64)hdf_dims[i]);
1186 m_ids_dataset.openIfExists(m_hfile,m_ids_hpath);
1196 m_ids_hpath = ids_path;
1203_write(
const void* buffer,
Integer nb_element,hid_t save_type,hid_t native_type)
1207 dims[0] = nb_element;
1210 hspace.createSimple(1,dims);
1214 m_dimensions.
clear();
1215 m_dimensions.
add(nb_element);
1217 m_hdataset.recursiveCreate(m_hfile,m_hpath,save_type,hspace,H5P_DEFAULT);
1218 if (m_hdataset.isBad())
1224 m_hdataset.write(native_type,buffer);
1234 dataset.openIfExists(m_hfile,m_hpath);
1235 return dataset.id()>0;
1253 m_hdataset.readWithException(st.nativeType(DataType()),buffer.
data());
1263 buffer.
resize(m_dimensions[0]);
1275 bool has_ids =
false;
1279 if (m_ids_dataset.id()>0){
1281 m_ids_dataset.read(st.nativeType(
Int64()),unique_ids.
data());
1284 infos[0] = buf_size;
1285 infos[1] = has_ids ? 1 : 0;
1287 pm->broadcast(iav,master_rank);
1288 pm->broadcast(buffer,master_rank);
1289 pm->broadcast(unique_ids,master_rank);
1294 pm->broadcast(iav,master_rank);
1296 has_ids = infos[1]!=0;
1298 unique_ids.
resize(buf_size);
1299 pm->broadcast(buffer,master_rank);
1300 pm->broadcast(unique_ids,master_rank);
1303 for(
Integer i=0, is=unique_ids.
size(); i<is; ++i )
1314 Integer nb_element = buffer.size();
1315 _write(buffer.data(),nb_element,st.saveType(DataType()),st.nativeType(DataType()));
1323 ConstArrayView<DataType> buffer,
1328 Integer total_size = buffer.size();
1329 Integer nb_element = unique_ids.size();
1331 if (nb_element != total_size){
1332 if (nb_element == 0)
1333 ARCANE_THROW(ArgumentException,
"unique_ids size is zero but not buffer size ({0})",
1335 dim2_size = total_size / nb_element;
1336 if (dim2_size*nb_element != total_size)
1337 ARCANE_THROW(ArgumentException,
"buffer size ({0}) is not a multiple of unique_ids size ({1})",
1338 total_size,nb_element);
1341 UniqueArray<ValueWithUid> values_to_sort(nb_element);
1342 UniqueArray<DataType> out_buffer(total_size);
1345 for(
Integer i=0; i<nb_element; ++i ){
1346 values_to_sort[i].m_uid = unique_ids[i];
1347 values_to_sort[i].m_index = i;
1351 std::sort(std::begin(values_to_sort),std::end(values_to_sort));
1352 for(
Integer i=0; i<nb_element; ++i ){
1353 Integer old_index = values_to_sort[i].m_index;
1354 for(
Integer j=0; j<dim2_size; ++j ){
1355 Integer pos = (i*dim2_size)+j;
1356 out_buffer[pos] = buffer[(old_index*dim2_size)+j];
1362 write(st,out_buffer);
1381 bool is_parallel = pm->isParallel();
1382 ITraceMng* tm = pm->traceMng();
1385 _writeSortedValues(tm,st,buffer,unique_ids);
1389 bool is_master = pm->isMasterIO();
1390 Integer master_rank = pm->masterIORank();
1391 Integer nb_rank = pm->commSize();
1392 Integer buf_size = buffer.size();
1393 Integer unique_id_size = unique_ids.size();
1401 buf[1] = unique_id_size;
1403 pm->allGather(iav,rank_sizes);
1405 Integer buffer_total_size = 0;
1406 Integer unique_id_total_size = 0;
1410 for(
Integer i=0; i<nb_rank; ++i ){
1411 buffer_rank_index[i] = buffer_total_size;
1412 buffer_total_size += rank_sizes[(i*2)];
1413 unique_id_rank_index[i] = unique_id_total_size;
1414 unique_id_total_size += rank_sizes[(i*2)+1];
1417 UniqueArray<DataType> full_buffer(buffer_total_size);
1420 for(
Integer i=0; i<nb_rank; ++i ){
1422 if (rank_sizes[(i*2)]==0)
1424 ArrayView<DataType> local_buf(rank_sizes[(i*2)],&full_buffer[ buffer_rank_index[i] ]);
1425 Int64ArrayView local_unique_ids(rank_sizes[(i*2)+1],&full_unique_ids[ unique_id_rank_index[i] ]);
1426 if (i==master_rank){
1427 local_buf.copy(buffer);
1428 local_unique_ids.copy(unique_ids);
1431 pm->recv(local_buf,i);
1432 pm->recv(local_unique_ids,i);
1435 tm->info(5) <<
"PARALLEL WRITE path=" << m_hpath <<
" total_size=" << full_buffer.size();
1436 _writeSortedValues(tm,st,full_buffer,full_unique_ids);
1441 buf[1] = unique_id_size;
1443 pm->allGather(iav,rank_sizes);
1445 if (buffer.size()>0){
1446 pm->send(buffer,master_rank);
1447 pm->send(unique_ids,master_rank);
1475template<
typename DataType> DataType
1480 m_hdataset.open(m_hfile,m_hpath);
1483 const int max_dim = 256;
1484 hsize_t hdf_dims[max_dim];
1485 hsize_t max_dims[max_dim];
1489 nb_dim = H5Sget_simple_extent_ndims(hspace.id());
1490 H5Sget_simple_extent_dims(hspace.id(), hdf_dims, max_dims);
1492 if (nb_dim != 1 || hdf_dims[0] != 1)
1497 m_hdataset.read(st.nativeType(DataType()),&dummy);
1511 m_hdataset.open(m_hfile,m_hpath);
1514 const int max_dim = 256;
1515 hsize_t hdf_dims[max_dim];
1516 hsize_t max_dims[max_dim];
1520 nb_dim = H5Sget_simple_extent_ndims(hspace.id());
1521 H5Sget_simple_extent_dims(hspace.id(), hdf_dims, max_dims);
1526 utf8_bytes.
resize(hdf_dims[0]);
1529 m_hdataset.read(st.nativeType(
Byte()),utf8_bytes.
data());
1530 return String(utf8_bytes);
1535template<
typename DataType>
void
1539 hsize_t dims[1] = { 1 };
1541 hspace.createSimple(1,dims);
1546 m_hdataset.recursiveCreate(m_hfile,m_hpath,st.saveType(DataType()),hspace,H5P_DEFAULT);
1547 if (m_hdataset.isBad())
1550 herr_t herr = m_hdataset.write(st.nativeType(DataType()),&t);
1564 dims[0] = utf8_bytes.
size() + 1;
1567 hspace.createSimple(1,dims);
1572 m_hdataset.recursiveCreate(m_hfile,m_hpath,st.saveType(
Byte()),hspace,H5P_DEFAULT);
1573 if (m_hdataset.isBad())
1576 herr_t herr = m_hdataset.write(st.nativeType(
Byte()),utf8_bytes.
data());