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
124#ifdef H5_HAVE_PARALLEL
153class ARCANE_HDF5_EXPORT Hid
169 void _setId(hid_t
id) { m_id = id; }
170 void _setNullId() { m_id = -1; }
174 Hid& operator=(
const Hid& hid) =
delete;
178 hid_t id()
const {
return m_id; }
179 bool isBad()
const {
return m_id < 0; }
191class ARCANE_HDF5_EXPORT HProperty
196 HProperty() { _setId(H5P_DEFAULT); }
201 HProperty(HProperty&& rhs)
206 HProperty& operator=(HProperty&& rhs)
215 HProperty(
const HProperty& v) =
delete;
216 HProperty& operator=(
const HProperty& hid) =
delete;
222 void create(hid_t cls_id);
223 void setId(hid_t new_id)
276class ARCANE_HDF5_EXPORT HFile
282 ~HFile() { _close(); }
288 HFile& operator=(HFile&& rhs)
294 HFile& operator=(
const HFile& hid) =
delete;
298 ARCANE_DEPRECATED_REASON(
"Y2023: Copy constructor is deprecated. This class has unique ownership")
299 HFile(
const HFile& rhs)
305 void openTruncate(
const String& var);
306 void openAppend(
const String& var);
307 void openRead(
const String& var);
308 void openTruncate(
const String& var, hid_t plist_id);
309 void openAppend(
const String& var, hid_t plist_id);
310 void openRead(
const String& var, hid_t plist_id);
323class ARCANE_HDF5_EXPORT HGroupSearch
326 HGroupSearch(
const String& group_name)
327 : m_group_name(group_name)
331 herr_t iterateMe(
const char* member_name)
334 if (m_group_name==member_name)
347class ARCANE_HDF5_EXPORT HGroup
353 ~HGroup() { close(); }
359 HGroup& operator=(HGroup&& rhs)
365 HGroup& operator=(
const HGroup& hid) =
delete;
369 ARCANE_DEPRECATED_REASON(
"Y2023: Copy constructor is deprecated. This class has unique ownership")
370 HGroup(
const HGroup& rhs)
376 void create(
const Hid& loc_id,
const String& group_name);
377 void openOrCreate(
const Hid& loc_id,
const String& group_name);
378 void recursiveCreate(
const Hid& loc_id,
const String& var);
379 void recursiveCreate(
const Hid& loc_id,
const Array<String>& paths);
380 void checkDelete(
const Hid& loc_id,
const String& var);
381 void recursiveOpen(
const Hid& loc_id,
const String& var);
382 void open(
const Hid& loc_id,
const String& var);
383 void openIfExists(
const Hid& loc_id,
const Array<String>& var);
384 bool hasChildren(
const String& var);
386 static bool hasChildren(hid_t loc_id,
const String& var);
390 hid_t _checkOrCreate(hid_t loc_id,
const String& group_name);
391 hid_t _checkExist(hid_t loc_id,
const String& group_name);
401class ARCANE_HDF5_EXPORT HSpace
407 explicit HSpace(hid_t
id)
416 HSpace& operator=(HSpace&& rhs)
422 HSpace& operator=(
const HSpace& hid) =
delete;
426 ARCANE_DEPRECATED_REASON(
"Y2023: Copy constructor is deprecated. This class has unique ownership")
427 HSpace(
const HSpace& v)
433 void createSimple(
int nb, hsize_t dims[]);
434 void createSimple(
int nb, hsize_t dims[], hsize_t max_dims[]);
436 herr_t getDimensions(hsize_t dims[], hsize_t max_dims[]);
444class ARCANE_HDF5_EXPORT HDataset
450 ~HDataset() { close(); }
451 HDataset(HDataset&& rhs)
456 HDataset& operator=(HDataset&& rhs)
462 HDataset& operator=(
const HDataset& hid) =
delete;
466 ARCANE_DEPRECATED_REASON(
"Y2023: Copy constructor is deprecated. This class has unique ownership")
467 HDataset(
const HDataset& v)
474 void create(
const Hid& loc_id,
const String& var, hid_t save_type,
const HSpace& space_id, hid_t plist);
475 void create(
const Hid& loc_id,
const String& var,hid_t save_type,
478 void recursiveCreate(
const Hid& loc_id,
const String& var, hid_t save_type,
const HSpace& space_id, hid_t plist);
479 void open(
const Hid& loc_id,
const String& var);
480 void openIfExists(
const Hid& loc_id,
const String& var);
481 herr_t write(hid_t native_type,
const void* array);
482 herr_t write(hid_t native_type,
const void* array,
const HSpace& memspace_id,
483 const HSpace& filespace_id, hid_t plist);
484 herr_t write(hid_t native_type,
const void* array,
const HSpace& memspace_id,
486 herr_t read(hid_t native_type,
void* array);
487 void readWithException(hid_t native_type,
void* array);
489 herr_t setExtent(
const hsize_t new_dims[]);
493 void _remove(hid_t hid,
const String& var);
501class ARCANE_HDF5_EXPORT HAttribute
508 HAttribute(HAttribute&& rhs)
513 HAttribute& operator=(HAttribute&& rhs)
519 HAttribute& operator=(
const HAttribute& hid) =
delete;
523 ARCANE_DEPRECATED_REASON(
"Y2023: Copy constructor is deprecated. This class has unique ownership")
524 HAttribute(
const HAttribute& v)
530 void remove(
const Hid& loc_id,
const String& var);
531 void create(
const Hid& loc_id,
const String& var, hid_t save_type,
const HSpace& space_id);
532 void open(
const Hid& loc_id,
const String& var);
533 herr_t write(hid_t native_type,
void* array);
534 herr_t read(hid_t native_type,
void* array);
544class ARCANE_HDF5_EXPORT HType
556 HType& operator=(HType&& rhs)
562 HType& operator=(
const HType& hid) =
delete;
566 ARCANE_DEPRECATED_REASON(
"Y2023: Copy constructor is deprecated. This class has unique ownership")
567 HType(
const HType& v)
573 void setId(hid_t new_id)
605 ARCANE_DEPRECATED_REASON(
"Y2023: Copy constructor is deprecated. This class has unique ownership")
619 hid_t nativeType(
float)
const {
return H5T_NATIVE_FLOAT; }
620 hid_t nativeType(
double)
const {
return H5T_NATIVE_DOUBLE; }
625 hid_t nativeType(
long double)
const {
return H5T_NATIVE_LDOUBLE; }
626 hid_t nativeType(
unsigned int)
const {
return H5T_NATIVE_UINT; }
627 hid_t nativeType(
unsigned long)
const {
return H5T_NATIVE_ULONG; }
628 hid_t nativeType(
unsigned long long)
const {
return H5T_NATIVE_ULLONG; }
629 hid_t nativeType(
int)
const {
return H5T_NATIVE_INT; }
630 hid_t nativeType(
long long)
const {
return H5T_NATIVE_LLONG; }
631 hid_t nativeType(
long)
const {
return H5T_NATIVE_LONG; }
632 hid_t nativeType(
char)
const {
return H5T_NATIVE_CHAR; }
633 hid_t nativeType(
unsigned char)
const {
return H5T_NATIVE_UCHAR; }
634 hid_t nativeType(
signed char)
const {
return H5T_NATIVE_SCHAR; }
635 hid_t nativeType(
unsigned short)
const {
return H5T_NATIVE_USHORT; }
636 hid_t nativeType(
short)
const {
return H5T_NATIVE_SHORT; }
637#ifdef ARCANE_REAL_NOT_BUILTIN
638 hid_t nativeType(
Real)
const;
646 hid_t saveType(
float)
const
650 hid_t saveType(
double)
const
654 hid_t saveType(
Real2)
const
658 hid_t saveType(
Real3)
const
670 hid_t saveType(
long double)
const
674 hid_t saveType(
short)
const
678 hid_t saveType(
unsigned short)
const
682 hid_t saveType(
unsigned int)
const
686 hid_t saveType(
unsigned long)
const
690 hid_t saveType(
unsigned long long)
const
694 hid_t saveType(
int)
const
698 hid_t saveType(
long)
const
702 hid_t saveType(
long long)
const
706 hid_t saveType(
char)
const
710 hid_t saveType(
unsigned char)
const
714 hid_t saveType(
signed char)
const
726#ifdef ARCANE_REAL_NOT_BUILTIN
727 hid_t saveType(
Real)
const
767 void _H5Tinsert(hid_t type,
const char* name,
Integer offset, hid_t field_id);
776class ARCANE_HDF5_EXPORT StandardArray
780 StandardArray(hid_t hfile,
const String& hpath);
781 virtual ~StandardArray() {}
794 virtual bool exists()
const;
798 void _write(
const void* buffer,
Integer nb_element, hid_t save_type, hid_t native_type);
817template<
typename DataType>
818class ARCANE_HDF5_EXPORT StandardArrayT
819:
public StandardArray
828 bool operator<(
const ValueWithUid& rhs)
const
830 return m_uid < rhs.m_uid;
834 StandardArrayT(hid_t hfile,
const String& hpath);
864template<
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 constexpr 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.
void createDatasetTransfertIndependentMPIIO()
Créé une propriété de dataset 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.