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#if (defined(H5_HAVE_THREADSAFE) || defined(H5_HAVE_CONCURRENCY))
93 pm->traceMng()->info(4) <<
"HDF5 -- Is HDF5 threadsafe: 1 -- Is Mutex enabled: " << global_hdf5_mutex_is_active;
95 bool env_is_enable =
true;
97 env_is_enable = (v.value() == 0);
100 global_hdf5_mutex.lock();
101 global_hdf5_mutex_is_active = env_is_enable && is_active;
102 global_hdf5_mutex.unlock();
104 pm->traceMng()->info(4) <<
"HDF5 -- Is HDF5 threadsafe: 0 -- Is Mutex enabled: " << global_hdf5_mutex_is_active;
114hid_t _H5Gopen(hid_t loc_id,
const char *name)
116 return H5Gopen2(loc_id,name,H5P_DEFAULT);
119hid_t _H5Gcreate(hid_t loc_id,
const char *name)
121 return H5Gcreate2(loc_id, name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
128extern "C" ARCANE_HDF5_EXPORT herr_t
129_ArcaneHdf5UtilsGroupIterateMe(hid_t g,
const char* mn,
void* ptr)
133 return rw->iterateMe(mn);
140splitString(
const String& str,Array<String>& str_array,
char c)
142 const char* str_str = str.localstr();
146 if (str_str[i]==c && i!=offset){
147 str_array.add(std::string_view(str_str+offset,i-offset));
152 str_array.add(std::string_view(str_str+offset,len-offset));
159openTruncate(
const String& var)
164 _setId(H5Fcreate(var.localstr(), H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT));
167 ARCANE_THROW(ReaderWriterException,
"Can not open file '{0}'",var);
171openAppend(
const String& var)
176 _setId(H5Fopen(var.localstr(), H5F_ACC_RDWR, H5P_DEFAULT));
179 ARCANE_THROW(ReaderWriterException,
"Can not open file '{0}'",var);
183openRead(
const String& var)
188 _setId(H5Fopen(var.localstr(), H5F_ACC_RDONLY, H5P_DEFAULT));
191 ARCANE_THROW(ReaderWriterException,
"Can not open file '{0}'",var);
195openTruncate(
const String& var,hid_t plist_id)
200 _setId(H5Fcreate(var.localstr(), H5F_ACC_TRUNC, H5P_DEFAULT, plist_id));
203 ARCANE_THROW(ReaderWriterException,
"Can not open file '{0}'",var);
207openAppend(
const String& var,hid_t plist_id)
212 _setId(H5Fopen(var.localstr(), H5F_ACC_RDWR, plist_id));
215 ARCANE_THROW(ReaderWriterException,
"Can not open file '{0}'",var);
219openRead(
const String& var,hid_t plist_id)
224 _setId(H5Fopen(var.localstr(), H5F_ACC_RDONLY, plist_id));
227 ARCANE_THROW(ReaderWriterException,
"Can not open file '{0}'",var);
253 ARCANE_THROW(ReaderWriterException,
"Can not close file");
260recursiveCreate(
const Hid& loc_id,
const String& var)
262 UniqueArray<String> bufs;
263 splitString(var,bufs,
'/');
264 recursiveCreate(loc_id,bufs);
268recursiveCreate(
const Hid& loc_id,
const Array<String>& bufs)
271 hid_t last_hid = loc_id.id();
272 Integer nb_create = bufs.size();
273 UniqueArray<hid_t> ref_ids(nb_create);
274 for (
Integer i = 0; i < nb_create; ++i) {
275 last_hid = _checkOrCreate(last_hid,bufs[i]);
276 ref_ids[i] = last_hid;
280 for (
Integer i = 0; i < nb_create - 1; ++i) {
281 H5Gclose(ref_ids[i]);
290checkDelete(
const Hid& loc_id,
const String& var)
292 UniqueArray<String> bufs;
293 splitString(var,bufs,
'/');
294 hid_t last_hid = loc_id.id();
295 hid_t parent_hid = last_hid;
298 for( ; i<size; ++i ){
299 parent_hid = last_hid;
300 last_hid = _checkExist(last_hid,bufs[i]);
305 if (last_hid>0 && parent_hid>0 && i==size){
308 H5Gunlink(parent_hid, bufs[size - 1].localstr());
316recursiveOpen(
const Hid& loc_id,
const String& var)
319 UniqueArray<String> bufs;
320 splitString(var,bufs,
'/');
321 hid_t last_hid = loc_id.id();
323 UniqueArray<hid_t> ref_ids(nb_open);
325 for (
Integer i = 0; i < nb_open; ++i) {
326 last_hid = _H5Gopen(last_hid,bufs[i].localstr());
327 ref_ids[i] = last_hid;
330 for (
Integer i = 0; i < nb_open - 1; ++i) {
331 H5Gclose(ref_ids[i]);
340openIfExists(
const Hid& loc_id,
const Array<String>& paths)
343 hid_t last_hid = loc_id.id();
344 bool is_valid =
true;
345 Integer nb_open = paths.size();
346 UniqueArray<hid_t> ref_ids;
347 ref_ids.reserve(nb_open);
348 for (
Integer i = 0; i < nb_open; ++i) {
349 if (HGroup::hasChildren(last_hid, paths[i].localstr())) {
351 last_hid = _H5Gopen(last_hid,paths[i].localstr());
352 ref_ids.add(last_hid);
363 for (
Integer i = 0; i < ref_ids.size(); ++i) {
364 if (ref_ids[i] != last_hid) {
365 H5Gclose(ref_ids[i]);
374hasChildren(
const String& var)
376 return hasChildren(
id(),var);
383hasChildren(hid_t loc_id,
const String& var)
385 HGroupSearch gs(var);
387 herr_t v = H5Giterate(loc_id,
".",0,_ArcaneHdf5UtilsGroupIterateMe,&gs);
388 bool has_children = v>0;
397_checkOrCreate(hid_t loc_id,
const String& group_name)
403 HGroupSearch gs(group_name);
406 herr_t v = H5Giterate(loc_id,
".",0,_ArcaneHdf5UtilsGroupIterateMe,&gs);
413 return _H5Gopen(loc_id,group_name.localstr());
415 hid_t new_id = _H5Gcreate(loc_id,group_name.localstr());
424create(
const Hid& loc_id,
const String& group_name)
427 _setId(H5Gcreate2(loc_id.id(), group_name.localstr(), H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT));
434openOrCreate(
const Hid& loc_id,
const String& group_name)
436 hid_t
id = _checkOrCreate(loc_id.id(),group_name);
438 ARCANE_THROW(ReaderWriterException,
"Can not open or create group named '{0}'",group_name);
446open(
const Hid& loc_id,
const String& var)
451 id = _H5Gopen(loc_id.id(), var.localstr());
454 ARCANE_THROW(ReaderWriterException,
"Can not find group named '{0}'",var);
475_checkExist(hid_t loc_id,
const String& group_name)
481 HGroupSearch gs(group_name);
484 herr_t v = H5Giterate(loc_id,
".",0,_ArcaneHdf5UtilsGroupIterateMe,&gs);
491 return _H5Gopen(loc_id,group_name.localstr());
517createSimple(
int nb, hsize_t dims[])
520 _setId(H5Screate_simple(nb, dims,
nullptr));
527createSimple(
int nb, hsize_t dims[], hsize_t max_dims[])
530 _setId(H5Screate_simple(nb, dims, max_dims));
540 return H5Sget_simple_extent_ndims(
id());
547getDimensions(hsize_t dims[], hsize_t max_dims[])
550 return H5Sget_simple_extent_dims(
id(), dims, max_dims);
573create(
const Hid& loc_id,
const String& var,hid_t save_type,
574 const HSpace& space_id, hid_t plist)
577 hid_t hid = H5Dcreate2(loc_id.id(), var.localstr(), save_type, space_id.id(),
578 plist, H5P_DEFAULT, H5P_DEFAULT);
587create(
const Hid& loc_id,
const String& var,hid_t save_type,
592 hid_t hid = H5Dcreate2(loc_id.id(), var.localstr(), save_type, space_id.id(),
593 link_plist.id(),creation_plist.id(),access_plist.id());
602write(hid_t native_type,
const void* array)
606 return H5Dwrite(
id(), native_type, H5S_ALL, H5S_ALL, H5P_DEFAULT, array);
613write(hid_t native_type,
const void* array,
const HSpace& memspace_id,
614 const HSpace& filespace_id,hid_t plist)
618 return H5Dwrite(
id(),native_type,memspace_id.id(),filespace_id.id(),plist,array);
625write(hid_t native_type,
const void* array,
const HSpace& memspace_id,
630 return H5Dwrite(
id(),native_type,memspace_id.id(),filespace_id.id(),plist.id(),array);
637read(hid_t native_type,
void* array)
640 return H5Dread(
id(), native_type, H5S_ALL, H5S_ALL, H5P_DEFAULT, array);
647readWithException(hid_t native_type,
void* array)
652 err = H5Dread(
id(), native_type, H5S_ALL, H5S_ALL, H5P_DEFAULT, array);
665 return HSpace(H5Dget_space(
id()));
672setExtent(
const hsize_t new_dims[])
675 return H5Dset_extent(
id(),new_dims);
682recursiveCreate(
const Hid& loc_id,
const String& var,hid_t save_type,
683 const HSpace& space_id,hid_t plist)
687 UniqueArray<String> paths;
688 splitString(var,paths,
'/');
689 Integer nb_path = paths.size();
691 if (HGroup::hasChildren(loc_id.id(),var)){
692 _remove(loc_id.id(),var);
694 create(loc_id,var,save_type,space_id,plist);
697 String last_name = paths[nb_path-1];
698 paths.resize(nb_path-1);
700 group.recursiveCreate(loc_id,paths);
701 if (group.hasChildren(last_name)){
702 _remove(group.id(),last_name);
704 create(group.id(),last_name,save_type,space_id,plist);
711_remove(hid_t hid,
const String& var)
714 H5Gunlink(hid, var.localstr());
733remove(
const Hid& loc_id,
const String& var)
736 _setId(H5Adelete(loc_id.id(), var.localstr()));
743create(
const Hid& loc_id,
const String& var, hid_t save_type,
const HSpace& space_id)
746 _setId(H5Acreate2(loc_id.id(), var.localstr(), save_type, space_id.id(), H5P_DEFAULT, H5P_DEFAULT));
753open(
const Hid& loc_id,
const String& var)
756 _setId(H5Aopen_name(loc_id.id(), var.localstr()));
763write(hid_t native_type,
void* array)
766 return H5Awrite(
id(), native_type, array);
773read(hid_t native_type,
void* array)
776 return H5Aread(
id(), native_type, array);
786 return HSpace(H5Aget_space(
id()));
811open(
const Hid& loc_id,
const String& var)
815 _setId(H5Dopen2(loc_id.id(), var.localstr(), H5P_DEFAULT));
818 ARCANE_THROW(IOException,
"Can not open dataset '{0}'",var);
825openIfExists(
const Hid& loc_id,
const String& var)
827 UniqueArray<String> paths;
828 splitString(var,paths,
'/');
829 Integer nb_path = paths.size();
831 String last_name = var;
833 last_name = paths[nb_path-1];
834 paths.resize(nb_path-1);
835 parent_group.openIfExists(loc_id,paths);
838 parent_group.open(loc_id,
".");
840 if (parent_group.isBad())
842 if (parent_group.hasChildren(last_name))
843 open(loc_id.id(),var.localstr());
870 _setId(H5Pcreate(cls_id));
879#ifdef H5_HAVE_PARALLEL
883 MPI_Comm mpi_comm = *((MPI_Comm*)arcane_comm);
884 MPI_Info mpi_info = MPI_INFO_NULL;
886 create(H5P_FILE_ACCESS);
887 H5Pset_fapl_mpio(
id(), mpi_comm, mpi_info);
900#ifdef H5_HAVE_PARALLEL
901 create(H5P_DATASET_XFER);
902 H5Pset_dxpl_mpio(
id(), H5FD_MPIO_COLLECTIVE);
904#if (H5_VERS_MAJOR >= 2 || H5_VERS_MINOR >= 14)
905 H5Pset_selection_io(
id(), H5D_SELECTION_IO_MODE_OFF);
919#ifdef H5_HAVE_PARALLEL
920 create(H5P_DATASET_XFER);
921 H5Pset_dxpl_mpio(
id(), H5FD_MPIO_INDEPENDENT);
923#if (H5_VERS_MAJOR >= 2 || H5_VERS_MINOR >= 14)
924 H5Pset_selection_io(
id(), H5D_SELECTION_IO_MODE_OFF);
962 hid_t type_id = H5Tcopy(H5T_NATIVE_CHAR);
966 hid_t type_id = H5Tcopy(H5T_NATIVE_UCHAR);
970 hid_t type_id = H5Tcopy(H5T_NATIVE_SCHAR);
974 hid_t type_id = H5Tcopy(H5T_NATIVE_SHORT);
975 H5Tset_precision(type_id,8*
sizeof(
short));
976 H5Tset_order(type_id,H5T_ORDER_LE);
980 hid_t type_id = H5Tcopy(H5T_NATIVE_INT);
981 H5Tset_precision(type_id,8*
sizeof(
int));
982 H5Tset_order(type_id,H5T_ORDER_LE);
986 hid_t type_id = H5Tcopy(H5T_NATIVE_LONG);
987 H5Tset_precision(type_id,8*
sizeof(
long));
988 H5Tset_order(type_id,H5T_ORDER_LE);
992 hid_t type_id = H5Tcopy(H5T_NATIVE_USHORT);
993 H5Tset_precision(type_id,8*
sizeof(
unsigned short));
994 H5Tset_order(type_id,H5T_ORDER_LE);
998 hid_t type_id = H5Tcopy(H5T_NATIVE_UINT);
999 H5Tset_precision(type_id,8*
sizeof(
unsigned int));
1000 H5Tset_order(type_id,H5T_ORDER_LE);
1004 hid_t type_id = H5Tcopy(H5T_NATIVE_ULONG);
1005 H5Tset_precision(type_id,8*
sizeof(
unsigned long));
1006 H5Tset_order(type_id,H5T_ORDER_LE);
1010 hid_t type_id = H5Tcopy(H5T_NATIVE_FLOAT);
1011 H5Tset_precision(type_id,8*
sizeof(
float));
1012 H5Tset_order(type_id,H5T_ORDER_LE);
1016 hid_t type_id = H5Tcopy(H5T_NATIVE_DOUBLE);
1017 H5Tset_precision(type_id,8*
sizeof(
double));
1018 H5Tset_order(type_id,H5T_ORDER_LE);
1022 hid_t type_id = H5Tcreate(H5T_COMPOUND,
sizeof(
Real2POD));
1023 _H5Tinsert(type_id,
"X",HOFFSET(
Real2POD,x),H5T_NATIVE_DOUBLE);
1024 _H5Tinsert(type_id,
"Y",HOFFSET(
Real2POD,y),H5T_NATIVE_DOUBLE);
1028 hid_t type_id = H5Tcreate(H5T_COMPOUND,
sizeof(
Real3POD));
1029 _H5Tinsert(type_id,
"X",HOFFSET(
Real3POD,x),H5T_NATIVE_DOUBLE);
1030 _H5Tinsert(type_id,
"Y",HOFFSET(
Real3POD,y),H5T_NATIVE_DOUBLE);
1031 _H5Tinsert(type_id,
"Z",HOFFSET(
Real3POD,z),H5T_NATIVE_DOUBLE);
1035 hid_t type_id = H5Tcreate(H5T_COMPOUND,
sizeof(
Real2x2POD));
1036 _H5Tinsert(type_id,
"XX",HOFFSET(
Real2x2POD,x.x),H5T_NATIVE_DOUBLE);
1037 _H5Tinsert(type_id,
"XY",HOFFSET(
Real2x2POD,x.y),H5T_NATIVE_DOUBLE);
1038 _H5Tinsert(type_id,
"YX",HOFFSET(
Real2x2POD,y.x),H5T_NATIVE_DOUBLE);
1039 _H5Tinsert(type_id,
"YY",HOFFSET(
Real2x2POD,y.y),H5T_NATIVE_DOUBLE);
1043 hid_t type_id = H5Tcreate(H5T_COMPOUND,
sizeof(
Real3x3POD));
1044 _H5Tinsert(type_id,
"XX",HOFFSET(
Real3x3POD,x.x),H5T_NATIVE_DOUBLE);
1045 _H5Tinsert(type_id,
"XY",HOFFSET(
Real3x3POD,x.y),H5T_NATIVE_DOUBLE);
1046 _H5Tinsert(type_id,
"XZ",HOFFSET(
Real3x3POD,x.z),H5T_NATIVE_DOUBLE);
1047 _H5Tinsert(type_id,
"YX",HOFFSET(
Real3x3POD,y.x),H5T_NATIVE_DOUBLE);
1048 _H5Tinsert(type_id,
"YY",HOFFSET(
Real3x3POD,y.y),H5T_NATIVE_DOUBLE);
1049 _H5Tinsert(type_id,
"YZ",HOFFSET(
Real3x3POD,y.z),H5T_NATIVE_DOUBLE);
1050 _H5Tinsert(type_id,
"ZX",HOFFSET(
Real3x3POD,z.x),H5T_NATIVE_DOUBLE);
1051 _H5Tinsert(type_id,
"ZY",HOFFSET(
Real3x3POD,z.y),H5T_NATIVE_DOUBLE);
1052 _H5Tinsert(type_id,
"ZZ",HOFFSET(
Real3x3POD,z.z),H5T_NATIVE_DOUBLE);
1062 hid_t type_id = H5Tcopy(H5T_NATIVE_B16);
1067 hid_t type_id = H5Tcopy(H5T_NATIVE_B16);
1086_H5Tinsert(hid_t type,
const char* name,
Integer offset,hid_t field_id)
1089 herr_t herr = H5Tinsert(type,name,offset,field_id);
1098#ifdef ARCANE_REAL_NOT_BUILTIN
1099hid_t StandardTypes::
1100nativeType(
Real)
const
1106hid_t StandardTypes::
1112 case DT_Real2:
return saveType(Real2());
1114 case DT_Real3:
return saveType(Real3());
1124 throw ArgumentException(String::format(
"Bad type '{0}'",sd));
1131hid_t StandardTypes::
1137 case DT_Real2:
return nativeType(Real2());
1138 case DT_Real2x2:
return nativeType(Real2x2());
1139 case DT_Real3:
return nativeType(Real3());
1140 case DT_Real3x3:
return nativeType(Real3x3());
1149 throw ArgumentException(String::format(
"Bad type '{0}'",sd));
1160StandardArray(hid_t hfile,
const String& hpath)
1163, m_ids_hpath(hpath +
"_Ids")
1177 m_hdataset.open(m_hfile,m_hpath);
1178 HSpace hspace(m_hdataset.getSpace());
1180 const int max_dim = 256;
1181 hsize_t hdf_dims[max_dim];
1182 hsize_t max_dims[max_dim];
1186 nb_dim = H5Sget_simple_extent_ndims(hspace.id());
1187 H5Sget_simple_extent_dims(hspace.id(), hdf_dims, max_dims);
1189 for (
Integer i = 0; i < nb_dim; ++i) {
1192 m_dimensions.add((
Int64)hdf_dims[i]);
1197 m_ids_dataset.openIfExists(m_hfile,m_ids_hpath);
1207 m_ids_hpath = ids_path;
1214_write(
const void* buffer,
Integer nb_element,hid_t save_type,hid_t native_type)
1218 dims[0] = nb_element;
1221 hspace.createSimple(1,dims);
1225 m_dimensions.
clear();
1226 m_dimensions.
add(nb_element);
1228 m_hdataset.recursiveCreate(m_hfile,m_hpath,save_type,hspace,H5P_DEFAULT);
1229 if (m_hdataset.isBad())
1235 m_hdataset.write(native_type,buffer);
1245 dataset.openIfExists(m_hfile,m_hpath);
1246 return dataset.id()>0;
1264 m_hdataset.readWithException(st.nativeType(DataType()),buffer.
data());
1274 buffer.
resize(m_dimensions[0]);
1286 bool has_ids =
false;
1290 if (m_ids_dataset.id()>0){
1292 m_ids_dataset.read(st.nativeType(
Int64()),unique_ids.
data());
1295 infos[0] = buf_size;
1296 infos[1] = has_ids ? 1 : 0;
1298 pm->broadcast(iav,master_rank);
1299 pm->broadcast(buffer,master_rank);
1300 pm->broadcast(unique_ids,master_rank);
1305 pm->broadcast(iav,master_rank);
1307 has_ids = infos[1]!=0;
1309 unique_ids.
resize(buf_size);
1310 pm->broadcast(buffer,master_rank);
1311 pm->broadcast(unique_ids,master_rank);
1314 for(
Integer i=0, is=unique_ids.
size(); i<is; ++i )
1325 Integer nb_element = buffer.size();
1326 _write(buffer.data(),nb_element,st.saveType(DataType()),st.nativeType(DataType()));
1334 ConstArrayView<DataType> buffer,
1339 Integer total_size = buffer.size();
1340 Integer nb_element = unique_ids.size();
1342 if (nb_element != total_size){
1343 if (nb_element == 0)
1344 ARCANE_THROW(ArgumentException,
"unique_ids size is zero but not buffer size ({0})",
1346 dim2_size = total_size / nb_element;
1347 if (dim2_size*nb_element != total_size)
1348 ARCANE_THROW(ArgumentException,
"buffer size ({0}) is not a multiple of unique_ids size ({1})",
1349 total_size,nb_element);
1352 UniqueArray<ValueWithUid> values_to_sort(nb_element);
1353 UniqueArray<DataType> out_buffer(total_size);
1356 for(
Integer i=0; i<nb_element; ++i ){
1357 values_to_sort[i].m_uid = unique_ids[i];
1358 values_to_sort[i].m_index = i;
1362 std::sort(std::begin(values_to_sort),std::end(values_to_sort));
1363 for(
Integer i=0; i<nb_element; ++i ){
1364 Integer old_index = values_to_sort[i].m_index;
1365 for(
Integer j=0; j<dim2_size; ++j ){
1366 Integer pos = (i*dim2_size)+j;
1367 out_buffer[pos] = buffer[(old_index*dim2_size)+j];
1373 write(st,out_buffer);
1392 bool is_parallel = pm->isParallel();
1393 ITraceMng* tm = pm->traceMng();
1396 _writeSortedValues(tm,st,buffer,unique_ids);
1400 bool is_master = pm->isMasterIO();
1401 Integer master_rank = pm->masterIORank();
1402 Integer nb_rank = pm->commSize();
1403 Integer buf_size = buffer.size();
1404 Integer unique_id_size = unique_ids.size();
1412 buf[1] = unique_id_size;
1414 pm->allGather(iav,rank_sizes);
1416 Integer buffer_total_size = 0;
1417 Integer unique_id_total_size = 0;
1421 for(
Integer i=0; i<nb_rank; ++i ){
1422 buffer_rank_index[i] = buffer_total_size;
1423 buffer_total_size += rank_sizes[(i*2)];
1424 unique_id_rank_index[i] = unique_id_total_size;
1425 unique_id_total_size += rank_sizes[(i*2)+1];
1428 UniqueArray<DataType> full_buffer(buffer_total_size);
1431 for(
Integer i=0; i<nb_rank; ++i ){
1433 if (rank_sizes[(i*2)]==0)
1435 ArrayView<DataType> local_buf(rank_sizes[(i*2)],&full_buffer[ buffer_rank_index[i] ]);
1436 Int64ArrayView local_unique_ids(rank_sizes[(i*2)+1],&full_unique_ids[ unique_id_rank_index[i] ]);
1437 if (i==master_rank){
1438 local_buf.copy(buffer);
1439 local_unique_ids.copy(unique_ids);
1442 pm->recv(local_buf,i);
1443 pm->recv(local_unique_ids,i);
1446 tm->info(5) <<
"PARALLEL WRITE path=" << m_hpath <<
" total_size=" << full_buffer.size();
1447 _writeSortedValues(tm,st,full_buffer,full_unique_ids);
1452 buf[1] = unique_id_size;
1454 pm->allGather(iav,rank_sizes);
1456 if (buffer.size()>0){
1457 pm->send(buffer,master_rank);
1458 pm->send(unique_ids,master_rank);
1486template<
typename DataType> DataType
1491 m_hdataset.open(m_hfile,m_hpath);
1494 const int max_dim = 256;
1495 hsize_t hdf_dims[max_dim];
1496 hsize_t max_dims[max_dim];
1500 nb_dim = H5Sget_simple_extent_ndims(hspace.id());
1501 H5Sget_simple_extent_dims(hspace.id(), hdf_dims, max_dims);
1503 if (nb_dim != 1 || hdf_dims[0] != 1)
1508 m_hdataset.read(st.nativeType(DataType()),&dummy);
1522 m_hdataset.open(m_hfile,m_hpath);
1525 const int max_dim = 256;
1526 hsize_t hdf_dims[max_dim];
1527 hsize_t max_dims[max_dim];
1531 nb_dim = H5Sget_simple_extent_ndims(hspace.id());
1532 H5Sget_simple_extent_dims(hspace.id(), hdf_dims, max_dims);
1537 utf8_bytes.
resize(hdf_dims[0]);
1540 m_hdataset.read(st.nativeType(
Byte()),utf8_bytes.
data());
1541 return String(utf8_bytes);
1546template<
typename DataType>
void
1550 hsize_t dims[1] = { 1 };
1552 hspace.createSimple(1,dims);
1557 m_hdataset.recursiveCreate(m_hfile,m_hpath,st.saveType(DataType()),hspace,H5P_DEFAULT);
1558 if (m_hdataset.isBad())
1561 herr_t herr = m_hdataset.write(st.nativeType(DataType()),&t);
1575 dims[0] = utf8_bytes.
size() + 1;
1578 hspace.createSimple(1,dims);
1583 m_hdataset.recursiveCreate(m_hfile,m_hpath,st.saveType(
Byte()),hspace,H5P_DEFAULT);
1584 if (m_hdataset.isBad())
1587 herr_t herr = m_hdataset.write(st.nativeType(
Byte()),utf8_bytes.
data());