hdf5_tools.hpp 3.59 KB
Newer Older
1
2
3
4
5
/**********************************************************************
*                                                                     *
*  Copyright 2017 Max Planck Institute                                *
*                 for Dynamics and Self-Organization                  *
*                                                                     *
Cristian Lalescu's avatar
Cristian Lalescu committed
6
*  This file is part of TurTLE.                                       *
7
*                                                                     *
Cristian Lalescu's avatar
Cristian Lalescu committed
8
*  TurTLE is free software: you can redistribute it and/or modify     *
9
10
11
12
*  it under the terms of the GNU General Public License as published  *
*  by the Free Software Foundation, either version 3 of the License,  *
*  or (at your option) any later version.                             *
*                                                                     *
Cristian Lalescu's avatar
Cristian Lalescu committed
13
*  TurTLE is distributed in the hope that it will be useful,          *
14
15
16
17
18
*  but WITHOUT ANY WARRANTY; without even the implied warranty of     *
*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the      *
*  GNU General Public License for more details.                       *
*                                                                     *
*  You should have received a copy of the GNU General Public License  *
Cristian Lalescu's avatar
Cristian Lalescu committed
19
*  along with TurTLE.  If not, see <http://www.gnu.org/licenses/>     *
20
21
22
23
24
25
26
27
28
29
*                                                                     *
* Contact: Cristian.Lalescu@ds.mpg.de                                 *
*                                                                     *
**********************************************************************/



#ifndef HDF5_TOOLS_HPP
#define HDF5_TOOLS_HPP

30
31
#include <vector>
#include <hdf5.h>
32
33
34
35
#include "base.hpp"

namespace hdf5_tools
{
36
37
38
    // see https://support.hdfgroup.org/HDF5/doc/H5.user/Datatypes.html
    template <typename data_type> hid_t hdf5_type_id();

39
40
41
42
43
44
45
46
47
48
49
50
51
    int grow_single_dataset(
            hid_t dset,
            int tincrement);

    herr_t grow_dataset_visitor(
        hid_t o_id,
        const char *name,
        const H5O_info_t *info,
        void *op_data);

    int grow_file_datasets(
            const hid_t stat_file,
            const std::string group_name,
52
            int tincrement);
53

54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
    int require_size_single_dataset(
            hid_t dset,
            int tincrement);

    herr_t require_size_dataset_visitor(
        hid_t o_id,
        const char *name,
        const H5O_info_t *info,
        void *op_data);

    int require_size_file_datasets(
            const hid_t stat_file,
            const std::string group_name,
            int tincrement);

69
70
71
72
73
74
75
76
77
78
79
80
    template <typename number>
    std::vector<number> read_vector(
            const hid_t group,
            const std::string dset_name);

    template <typename number>
    std::vector<number> read_vector_with_single_rank(
            const int myrank,
            const int rank_to_use,
            const MPI_Comm COMM,
            const hid_t group,
            const std::string dset_name);
Cristian Lalescu's avatar
Cristian Lalescu committed
81
82
83
84

    std::string read_string(
            const hid_t group,
            const std::string dset_name);
Cristian Lalescu's avatar
Cristian Lalescu committed
85
86
87
88
89

    template <typename number>
    number read_value(
            const hid_t group,
            const std::string dset_name);
90
91
92
93
94
95

    template <typename number>
    int write_value_with_single_rank(
            const hid_t group,
            const std::string dset_name,
            const number value);
96
97
98
99
100
101

    template <class partsize_t>
    int write_particle_ID_pairs_with_single_rank(
            const std::vector<partsize_t> v,
            const hid_t group,
            const std::string dset_name);
102
103
104
105
}

#endif//HDF5_TOOLS_HPP