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"
37#if (H5_VERS_MAJOR<2) && (H5_VERS_MAJOR==1 && H5_VERS_MINOR<10)
38#error "This version of HDF5 is too old. Version 1.10+ is required"
42#define ARCANE_HDF5_1_6_AND_AFTER
43#define ARCANE_HDF5_1_8_AND_AFTER
65 ARCANE_HDF5_EXPORT herr_t _ArcaneHdf5UtilsGroupIterateMe(hid_t,
const char*,
void*);
71class ARCANE_HDF5_EXPORT Hdf5Mutex
76 Hdf5Mutex(std::mutex& mutex,
bool& is_active)
78 , m_is_active(is_active)
103extern "C++" ARCANE_HDF5_EXPORT
Hdf5Mutex&
104_ArcaneHdf5UtilsMutex();
113class ARCANE_HDF5_EXPORT HInit
146class ARCANE_HDF5_EXPORT Hid
162 void _setId(hid_t
id) { m_id = id; }
163 void _setNullId() { m_id = -1; }
167 Hid& operator=(
const Hid& hid) =
delete;
171 hid_t id()
const {
return m_id; }
172 bool isBad()
const {
return m_id < 0; }
184class ARCANE_HDF5_EXPORT HProperty
189 HProperty() { _setId(H5P_DEFAULT); }
194 HProperty(HProperty&& rhs)
199 HProperty& operator=(HProperty&& rhs)
208 HProperty(
const HProperty& v) =
delete;
209 HProperty& operator=(
const HProperty& hid) =
delete;
215 void create(hid_t cls_id);
216 void setId(hid_t new_id)
254class ARCANE_HDF5_EXPORT HFile
260 ~HFile() { _close(); }
266 HFile& operator=(HFile&& rhs)
272 HFile& operator=(
const HFile& hid) =
delete;
276 ARCANE_DEPRECATED_REASON(
"Y2023: Copy constructor is deprecated. This class has unique ownership")
277 HFile(
const HFile& rhs)
283 void openTruncate(
const String& var);
284 void openAppend(
const String& var);
285 void openRead(
const String& var);
286 void openTruncate(
const String& var, hid_t plist_id);
287 void openAppend(
const String& var, hid_t plist_id);
288 void openRead(
const String& var, hid_t plist_id);
301class ARCANE_HDF5_EXPORT HGroupSearch
304 HGroupSearch(
const String& group_name)
305 : m_group_name(group_name)
309 herr_t iterateMe(
const char* member_name)
312 if (m_group_name==member_name)
325class ARCANE_HDF5_EXPORT HGroup
331 ~HGroup() { close(); }
337 HGroup& operator=(HGroup&& rhs)
343 HGroup& operator=(
const HGroup& hid) =
delete;
347 ARCANE_DEPRECATED_REASON(
"Y2023: Copy constructor is deprecated. This class has unique ownership")
348 HGroup(
const HGroup& rhs)
354 void create(
const Hid& loc_id,
const String& group_name);
355 void openOrCreate(
const Hid& loc_id,
const String& group_name);
356 void recursiveCreate(
const Hid& loc_id,
const String& var);
357 void recursiveCreate(
const Hid& loc_id,
const Array<String>& paths);
358 void checkDelete(
const Hid& loc_id,
const String& var);
359 void recursiveOpen(
const Hid& loc_id,
const String& var);
360 void open(
const Hid& loc_id,
const String& var);
361 void openIfExists(
const Hid& loc_id,
const Array<String>& var);
362 bool hasChildren(
const String& var);
364 static bool hasChildren(hid_t loc_id,
const String& var);
368 hid_t _checkOrCreate(hid_t loc_id,
const String& group_name);
369 hid_t _checkExist(hid_t loc_id,
const String& group_name);
379class ARCANE_HDF5_EXPORT HSpace
385 explicit HSpace(hid_t
id)
394 HSpace& operator=(HSpace&& rhs)
400 HSpace& operator=(
const HSpace& hid) =
delete;
404 ARCANE_DEPRECATED_REASON(
"Y2023: Copy constructor is deprecated. This class has unique ownership")
405 HSpace(
const HSpace& v)
411 void createSimple(
int nb, hsize_t dims[]);
412 void createSimple(
int nb, hsize_t dims[], hsize_t max_dims[]);
414 herr_t getDimensions(hsize_t dims[], hsize_t max_dims[]);
422class ARCANE_HDF5_EXPORT HDataset
428 ~HDataset() { close(); }
429 HDataset(HDataset&& rhs)
434 HDataset& operator=(HDataset&& rhs)
440 HDataset& operator=(
const HDataset& hid) =
delete;
444 ARCANE_DEPRECATED_REASON(
"Y2023: Copy constructor is deprecated. This class has unique ownership")
445 HDataset(
const HDataset& v)
452 void create(
const Hid& loc_id,
const String& var, hid_t save_type,
const HSpace& space_id, hid_t plist);
453 void create(
const Hid& loc_id,
const String& var,hid_t save_type,
456 void recursiveCreate(
const Hid& loc_id,
const String& var, hid_t save_type,
const HSpace& space_id, hid_t plist);
457 void open(
const Hid& loc_id,
const String& var);
458 void openIfExists(
const Hid& loc_id,
const String& var);
459 herr_t write(hid_t native_type,
const void* array);
460 herr_t write(hid_t native_type,
const void* array,
const HSpace& memspace_id,
461 const HSpace& filespace_id, hid_t plist);
462 herr_t write(hid_t native_type,
const void* array,
const HSpace& memspace_id,
464 herr_t read(hid_t native_type,
void* array);
465 void readWithException(hid_t native_type,
void* array);
467 herr_t setExtent(
const hsize_t new_dims[]);
471 void _remove(hid_t hid,
const String& var);
479class ARCANE_HDF5_EXPORT HAttribute
486 HAttribute(HAttribute&& rhs)
491 HAttribute& operator=(HAttribute&& rhs)
497 HAttribute& operator=(
const HAttribute& hid) =
delete;
501 ARCANE_DEPRECATED_REASON(
"Y2023: Copy constructor is deprecated. This class has unique ownership")
502 HAttribute(
const HAttribute& v)
508 void remove(
const Hid& loc_id,
const String& var);
509 void create(
const Hid& loc_id,
const String& var, hid_t save_type,
const HSpace& space_id);
510 void open(
const Hid& loc_id,
const String& var);
511 herr_t write(hid_t native_type,
void* array);
512 herr_t read(hid_t native_type,
void* array);
522class ARCANE_HDF5_EXPORT HType
534 HType& operator=(HType&& rhs)
540 HType& operator=(
const HType& hid) =
delete;
544 ARCANE_DEPRECATED_REASON(
"Y2023: Copy constructor is deprecated. This class has unique ownership")
545 HType(
const HType& v)
551 void setId(hid_t new_id)
583 ARCANE_DEPRECATED_REASON(
"Y2023: Copy constructor is deprecated. This class has unique ownership")
597 hid_t nativeType(
float)
const {
return H5T_NATIVE_FLOAT; }
598 hid_t nativeType(
double)
const {
return H5T_NATIVE_DOUBLE; }
603 hid_t nativeType(
long double)
const {
return H5T_NATIVE_LDOUBLE; }
604 hid_t nativeType(
unsigned int)
const {
return H5T_NATIVE_UINT; }
605 hid_t nativeType(
unsigned long)
const {
return H5T_NATIVE_ULONG; }
606 hid_t nativeType(
unsigned long long)
const {
return H5T_NATIVE_ULLONG; }
607 hid_t nativeType(
int)
const {
return H5T_NATIVE_INT; }
608 hid_t nativeType(
long long)
const {
return H5T_NATIVE_LLONG; }
609 hid_t nativeType(
long)
const {
return H5T_NATIVE_LONG; }
610 hid_t nativeType(
char)
const {
return H5T_NATIVE_CHAR; }
611 hid_t nativeType(
unsigned char)
const {
return H5T_NATIVE_UCHAR; }
612 hid_t nativeType(
signed char)
const {
return H5T_NATIVE_SCHAR; }
613 hid_t nativeType(
unsigned short)
const {
return H5T_NATIVE_USHORT; }
614 hid_t nativeType(
short)
const {
return H5T_NATIVE_SHORT; }
615#ifdef ARCANE_REAL_NOT_BUILTIN
616 hid_t nativeType(
Real)
const;
624 hid_t saveType(
float)
const
628 hid_t saveType(
double)
const
632 hid_t saveType(
Real2)
const
636 hid_t saveType(
Real3)
const
648 hid_t saveType(
long double)
const
652 hid_t saveType(
short)
const
656 hid_t saveType(
unsigned short)
const
660 hid_t saveType(
unsigned int)
const
664 hid_t saveType(
unsigned long)
const
668 hid_t saveType(
unsigned long long)
const
672 hid_t saveType(
int)
const
676 hid_t saveType(
long)
const
680 hid_t saveType(
long long)
const
684 hid_t saveType(
char)
const
688 hid_t saveType(
unsigned char)
const
692 hid_t saveType(
signed char)
const
704#ifdef ARCANE_REAL_NOT_BUILTIN
705 hid_t saveType(
Real)
const
745 void _H5Tinsert(hid_t type,
const char* name,
Integer offset, hid_t field_id);
754class ARCANE_HDF5_EXPORT StandardArray
758 StandardArray(hid_t hfile,
const String& hpath);
759 virtual ~StandardArray() {}
772 virtual bool exists()
const;
776 void _write(
const void* buffer,
Integer nb_element, hid_t save_type, hid_t native_type);
795template<
typename DataType>
796class ARCANE_HDF5_EXPORT StandardArrayT
797:
public StandardArray
806 bool operator<(
const ValueWithUid& rhs)
const
808 return m_uid < rhs.m_uid;
812 StandardArrayT(hid_t hfile,
const String& hpath);
842template<
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 void useMutex(bool is_active, IParallelMng *pm)
Fonction permettant d'activer ou de désactiver les verrous à chaque appel à HDF5.
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.
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.