aboutsummaryrefslogtreecommitdiff
path: root/CarpetDev/CarpetIOF5/src/utils.hh
blob: ae7cb65a1d16da66bb01171165be4fda5ae49b4c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#ifndef UTILS_HH
#define UTILS_HH

// force HDF5 1.8.x installations to use the new API
#ifdef H5Gopen_vers
#undef H5Gopen_vers
#endif
#ifdef H5Gcreate_vers
#undef H5Gcreate_vers
#endif
#ifdef H5Acreate_vers
#undef H5Acreate_vers
#endif
#ifdef H5Tarray_create_vers
#undef H5Tarray_create_vers
#endif
#define H5Gopen_vers 2
#define H5Gcreate_vers 2
#define H5Acreate_vers 2
#define H5Tarray_create_vers 2

#include <hdf5.h>

#include "cctk.h"

#include "vect.hh"



namespace CarpetIOF5 {
  
  namespace F5 {
    
    hid_t
    hdf5_datatype_from_dummy (signed char const & dummy);
    hid_t
    hdf5_datatype_from_dummy (short const & dummy);
    hid_t
    hdf5_datatype_from_dummy (int const & dummy);
    hid_t
    hdf5_datatype_from_dummy (long const & dummy);
    hid_t
    hdf5_datatype_from_dummy (long long const & dummy);
    hid_t
    hdf5_datatype_from_dummy (float const & dummy);
    hid_t
    hdf5_datatype_from_dummy (double const & dummy);
    hid_t
    hdf5_datatype_from_dummy (long double const & dummy);
#ifdef HAVE_CCTK_COMPLEX8
    hid_t
    hdf5_datatype_from_dummy (CCTK_COMPLEX8 const & dummy);
#endif
#ifdef HAVE_CCTK_COMPLEX16
    hid_t
    hdf5_datatype_from_dummy (CCTK_COMPLEX16 const & dummy);
#endif
#ifdef HAVE_CCTK_COMPLEX32
    hid_t
    hdf5_datatype_from_dummy (CCTK_COMPLEX32 const & dummy);
#endif
    
    template<typename T, typename R>
    hid_t
    hdf5_complex_datatype_from_dummy (T const & dummy, R const & real);
    
    hid_t
    hdf5_datatype_from_cactus_datatype (int cactus_datatype);
    
    
    
    hid_t
    open_or_create_group (hid_t where,
                          char const * name);
    
    
    
    template<typename T>
    void
    write_or_check_attribute (hid_t where,
                              char const * name,
                              T const * values,
                              int num_values);
    
    template<typename T>
    void
    write_or_check_attribute (hid_t where,
                              char const * name,
                              T const & value);
    
    template<typename T, int D>
    void
    write_or_check_attribute (hid_t where,
                              char const * name,
                              vect<T,D> const & value);
    
  } // namespace F5

} // namespace CarpetIOF5

#endif  // #ifndef UTILS_HH