12#ifndef ARCANE_HDF5_HDF5UTILS_H
13#define ARCANE_HDF5_HDF5UTILS_H
18#include "arcane/utils/String.h"
19#include "arcane/utils/Array.h"
20#include "arcane/utils/NumericTypes.h"
22#include "arcane/datatype/DataTypes.h"
24#include "arcane/hdf5/ArcaneHdf5Global.h"
35#if (H5_VERS_MAJOR<2) && (H5_VERS_MAJOR==1 && H5_VERS_MINOR<10)
36#error "This version of HDF5 is too old. Version 1.10+ is required"
40#define ARCANE_HDF5_1_6_AND_AFTER
41#define ARCANE_HDF5_1_8_AND_AFTER
63 ARCANE_HDF5_EXPORT herr_t _ArcaneHdf5UtilsGroupIterateMe(hid_t,
const char*,
void*);
73class ARCANE_HDF5_EXPORT HInit
92class ARCANE_HDF5_EXPORT Hid
108 void _setId(hid_t
id) { m_id = id; }
109 void _setNullId() { m_id = -1; }
113 Hid& operator=(
const Hid& hid) =
delete;
117 hid_t id()
const {
return m_id; }
118 bool isBad()
const {
return m_id < 0; }
130class ARCANE_HDF5_EXPORT HProperty
135 HProperty() { _setId(H5P_DEFAULT); }
140 HProperty(HProperty&& rhs)
145 HProperty& operator=(HProperty&& rhs)
154 HProperty(
const HProperty& v) =
delete;
155 HProperty& operator=(
const HProperty& hid) =
delete;
167 void create(hid_t cls_id);
168 void setId(hid_t new_id)
206class ARCANE_HDF5_EXPORT HFile
212 ~HFile() { _close(); }
218 HFile& operator=(HFile&& rhs)
224 HFile& operator=(
const HFile& hid) =
delete;
228 ARCANE_DEPRECATED_REASON(
"Y2023: Copy constructor is deprecated. This class has unique ownership")
229 HFile(
const HFile& rhs)
235 void openTruncate(
const String& var);
236 void openAppend(
const String& var);
237 void openRead(
const String& var);
238 void openTruncate(
const String& var, hid_t plist_id);
239 void openAppend(
const String& var, hid_t plist_id);
240 void openRead(
const String& var, hid_t plist_id);
253class ARCANE_HDF5_EXPORT HGroupSearch
256 HGroupSearch(
const String& group_name)
257 : m_group_name(group_name)
261 herr_t iterateMe(
const char* member_name)
264 if (m_group_name==member_name)
277class ARCANE_HDF5_EXPORT HGroup
283 ~HGroup() { close(); }
289 HGroup& operator=(HGroup&& rhs)
295 HGroup& operator=(
const HGroup& hid) =
delete;
299 ARCANE_DEPRECATED_REASON(
"Y2023: Copy constructor is deprecated. This class has unique ownership")
300 HGroup(
const HGroup& rhs)
306 void create(
const Hid& loc_id,
const String& group_name);
307 void openOrCreate(
const Hid& loc_id,
const String& group_name);
308 void recursiveCreate(
const Hid& loc_id,
const String& var);
309 void recursiveCreate(
const Hid& loc_id,
const Array<String>& paths);
310 void checkDelete(
const Hid& loc_id,
const String& var);
311 void recursiveOpen(
const Hid& loc_id,
const String& var);
312 void open(
const Hid& loc_id,
const String& var);
313 void openIfExists(
const Hid& loc_id,
const Array<String>& var);
314 bool hasChildren(
const String& var);
316 static bool hasChildren(hid_t loc_id,
const String& var);
320 hid_t _checkOrCreate(hid_t loc_id,
const String& group_name);
321 hid_t _checkExist(hid_t loc_id,
const String& group_name);
331class ARCANE_HDF5_EXPORT HSpace
337 explicit HSpace(hid_t
id)
350 HSpace& operator=(HSpace&& rhs)
356 HSpace& operator=(
const HSpace& hid) =
delete;
360 ARCANE_DEPRECATED_REASON(
"Y2023: Copy constructor is deprecated. This class has unique ownership")
361 HSpace(
const HSpace& v)
367 void createSimple(
int nb, hsize_t dims[]);
368 void createSimple(
int nb, hsize_t dims[], hsize_t max_dims[]);
370 herr_t getDimensions(hsize_t dims[], hsize_t max_dims[]);
378class ARCANE_HDF5_EXPORT HDataset
384 ~HDataset() { close(); }
385 HDataset(HDataset&& rhs)
390 HDataset& operator=(HDataset&& rhs)
396 HDataset& operator=(
const HDataset& hid) =
delete;
400 ARCANE_DEPRECATED_REASON(
"Y2023: Copy constructor is deprecated. This class has unique ownership")
401 HDataset(
const HDataset& v)
413 void create(
const Hid& loc_id,
const String& var, hid_t save_type,
const HSpace& space_id, hid_t plist);
414 void create(
const Hid& loc_id,
const String& var,hid_t save_type,
417 void recursiveCreate(
const Hid& loc_id,
const String& var, hid_t save_type,
const HSpace& space_id, hid_t plist);
418 void open(
const Hid& loc_id,
const String& var);
419 void openIfExists(
const Hid& loc_id,
const String& var);
420 herr_t write(hid_t native_type,
const void* array);
421 herr_t write(hid_t native_type,
const void* array,
const HSpace& memspace_id,
422 const HSpace& filespace_id, hid_t plist);
423 herr_t write(hid_t native_type,
const void* array,
const HSpace& memspace_id,
425 herr_t read(hid_t native_type,
void* array)
427 return H5Dread(
id(), native_type, H5S_ALL, H5S_ALL, H5P_DEFAULT, array);
429 void readWithException(hid_t native_type,
void* array);
431 herr_t setExtent(
const hsize_t new_dims[]);
435 void _remove(hid_t hid,
const String& var);
443class ARCANE_HDF5_EXPORT HAttribute
454 HAttribute(HAttribute&& rhs)
459 HAttribute& operator=(HAttribute&& rhs)
465 HAttribute& operator=(
const HAttribute& hid) =
delete;
469 ARCANE_DEPRECATED_REASON(
"Y2023: Copy constructor is deprecated. This class has unique ownership")
470 HAttribute(
const HAttribute& v)
476 void remove(
const Hid& loc_id,
const String& var)
478 _setId(H5Adelete(loc_id.id(), var.
localstr()));
480 void create(
const Hid& loc_id,
const String& var, hid_t save_type,
const HSpace& space_id)
482 _setId(H5Acreate2(loc_id.id(), var.
localstr(), save_type, space_id.id(), H5P_DEFAULT, H5P_DEFAULT));
484 void open(
const Hid& loc_id,
const String& var)
486 _setId(H5Aopen_name(loc_id.id(), var.
localstr()));
488 herr_t write(hid_t native_type,
void* array)
490 return H5Awrite(
id(), native_type, array);
492 herr_t read(hid_t native_type,
void* array)
494 return H5Aread(
id(), native_type, array);
498 return HSpace(H5Aget_space(
id()));
508class ARCANE_HDF5_EXPORT HType
524 HType& operator=(HType&& rhs)
530 HType& operator=(
const HType& hid) =
delete;
534 ARCANE_DEPRECATED_REASON(
"Y2023: Copy constructor is deprecated. This class has unique ownership")
535 HType(
const HType& v)
541 void setId(hid_t new_id)
573 ARCANE_DEPRECATED_REASON(
"Y2023: Copy constructor is deprecated. This class has unique ownership")
587 hid_t nativeType(
float)
const {
return H5T_NATIVE_FLOAT; }
588 hid_t nativeType(
double)
const {
return H5T_NATIVE_DOUBLE; }
593 hid_t nativeType(
long double)
const {
return H5T_NATIVE_LDOUBLE; }
594 hid_t nativeType(
unsigned int)
const {
return H5T_NATIVE_UINT; }
595 hid_t nativeType(
unsigned long)
const {
return H5T_NATIVE_ULONG; }
596 hid_t nativeType(
unsigned long long)
const {
return H5T_NATIVE_ULLONG; }
597 hid_t nativeType(
int)
const {
return H5T_NATIVE_INT; }
598 hid_t nativeType(
long long)
const {
return H5T_NATIVE_LLONG; }
599 hid_t nativeType(
long)
const {
return H5T_NATIVE_LONG; }
600 hid_t nativeType(
char)
const {
return H5T_NATIVE_CHAR; }
601 hid_t nativeType(
unsigned char)
const {
return H5T_NATIVE_UCHAR; }
602 hid_t nativeType(
signed char)
const {
return H5T_NATIVE_SCHAR; }
603 hid_t nativeType(
unsigned short)
const {
return H5T_NATIVE_USHORT; }
604 hid_t nativeType(
short)
const {
return H5T_NATIVE_SHORT; }
605#ifdef ARCANE_REAL_NOT_BUILTIN
606 hid_t nativeType(
Real)
const;
614 hid_t saveType(
float)
const
618 hid_t saveType(
double)
const
622 hid_t saveType(
Real2)
const
626 hid_t saveType(
Real3)
const
638 hid_t saveType(
long double)
const
642 hid_t saveType(
short)
const
646 hid_t saveType(
unsigned short)
const
650 hid_t saveType(
unsigned int)
const
654 hid_t saveType(
unsigned long)
const
658 hid_t saveType(
unsigned long long)
const
662 hid_t saveType(
int)
const
666 hid_t saveType(
long)
const
670 hid_t saveType(
long long)
const
674 hid_t saveType(
char)
const
678 hid_t saveType(
unsigned char)
const
682 hid_t saveType(
signed char)
const
694#ifdef ARCANE_REAL_NOT_BUILTIN
695 hid_t saveType(
Real)
const
735 void _H5Tinsert(hid_t type,
const char* name,
Integer offset, hid_t field_id);
744class ARCANE_HDF5_EXPORT StandardArray
748 StandardArray(hid_t hfile,
const String& hpath);
749 virtual ~StandardArray() {}
762 virtual bool exists()
const;
766 void _write(
const void* buffer,
Integer nb_element, hid_t save_type, hid_t native_type);
785template<
typename DataType>
786class ARCANE_HDF5_EXPORT StandardArrayT
787:
public StandardArray
796 bool operator<(
const ValueWithUid& rhs)
const
798 return m_uid < rhs.m_uid;
802 StandardArrayT(hid_t hfile,
const String& hpath);
832template<
typename DataType>
Déclarations des types utilisés dans Arcane.
Vue modifiable d'un tableau d'un type T.
Classe de base des vecteurs 1D de données.
Vue constante d'un tableau de type T.
Type flottant demi-précision.
Encapsule un hid_t pour un dataset.
Classe servant d'initialiseur pour HDF.
static bool hasParallelHdf5()
Vrai HDF5 est compilé avec le support de MPI.
Encapsule un hid_t pour une propriété (H5P*).
void createDatasetTransfertCollectiveMPIIO()
Créé une propriété de dataset pour MPIIO.
void createFilePropertyMPIIO(IParallelMng *pm)
Créé une propriété de fichier pour MPIIO.
Encapsule un hid_t pour un dataspace.
Encapsule un hid_t pour un type.
void read(StandardTypes &st, ArrayView< DataType > buffer)
Lit le dataset d'un tableau 1D. Cette opération n'est valide qu'après un appel à readDim()....
void directRead(StandardTypes &st, Array< DataType > &buffer)
Lit le dataset d'un tableau 1D.
void setIdsPath(const String &ids_path)
En lecture, positionne le chemin dans hfile du dataset contenant les unique_ids.
StandardScalarT(hid_t hfile, const String &hpath)
Constructeur.
Définition des types standards Arcane pour hdf5.
HType m_bfloat16_id
Identifiant HDF pour les BFloat16.
HType m_real2x2_id
Identifiant HDF pour les Real2x2.
StandardTypes()
Créé une instance en initialisant les types.
HType m_long_id
Identifiant HDF des entiers long signés.
HType m_int_id
Identifiant HDF des entiers signés.
HType m_short_id
Identifiant HDF des entiers signés.
HType m_real3x3_id
Identifiant HDF pour les Real3x3.
HType m_real_id
Identifiant HDF des réels.
HType m_ushort_id
Identifiant HDF des entiers long signés.
HType m_ulong_id
Identifiant HDF des entiers long non signés.
HType m_schar_id
Identifiant HDF des caractères signés.
HType m_uchar_id
Identifiant HDF des caractères non-signés.
HType m_real2_id
Identifiant HDF pour les Real2.
HType m_float32_id
Identifiant HDF pour les Float16.
HType m_float16_id
Identifiant HDF pour les Float16.
HType m_char_id
Identifiant HDF des charactères.
void initialize()
Initialise les types.
HType m_uint_id
Identifiant HDF des entiers non signés.
HType m_real3_id
Identifiant HDF pour les Real3.
Interface du gestionnaire de parallélisme pour un sous-domaine.
Interface du gestionnaire de traces.
Classe gérant un vecteur de réel de dimension 2.
Classe gérant une matrice de réel de dimension 2x2.
Classe gérant un vecteur de réel de dimension 3.
Classe gérant une matrice de réel de dimension 3x3.
Chaîne de caractères unicode.
const char * localstr() const
Retourne la conversion de l'instance dans l'encodage UTF-8.
Fonctions utilitaires pour Hdf5.
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
Array< Int64 > Int64Array
Tableau dynamique à une dimension d'entiers 64 bits.
UniqueArray< Int64 > Int64UniqueArray
Tableau dynamique à une dimension d'entiers 64 bits.
std::int64_t Int64
Type entier signé sur 64 bits.
Int32 Integer
Type représentant un entier.
bool operator<(const Item &item1, const Item &item2)
Compare deux entités.
ConstArrayView< Int64 > Int64ConstArrayView
Equivalent C d'un tableau à une dimension d'entiers 64 bits.
double Real
Type représentant un réel.
eDataType
Type d'une donnée.