H5.c 7.92 KB
Newer Older
1
/*
gsell's avatar
gsell committed
2
  Copyright (c) 2006-2015, The Regents of the University of California,
3 4 5 6 7 8 9 10
  through Lawrence Berkeley National Laboratory (subject to receipt of any
  required approvals from the U.S. Dept. of Energy) and the Paul Scherrer
  Institut (Switzerland).  All rights reserved.

  License: see file COPYING in top level of source distribution.
*/

#include "h5_private.h"
gsell's avatar
gsell committed
11

12
#include "h5core/h5_log.h"
gsell's avatar
gsell committed
13 14 15
#include "h5core/h5_file.h"

#include <hdf5.h>
16

gsell's avatar
gsell committed
17 18
#define h5_createprop_file FC_MANGLING(    \
                h5_createprop_file,	   \
gsell's avatar
gsell committed
19
                H5_CREATEPROP_FILE)
20
h5_int64_t
gsell's avatar
gsell committed
21 22 23 24 25
h5_createprop_file (
        void
        ) {
        H5_API_ENTER (h5_int64_t, "%s", "");
        H5_API_RETURN ((h5_int64_t)h5_create_prop (H5_PROP_FILE));
26 27
}

28
#if defined(H5_HAVE_PARALLEL)
gsell's avatar
gsell committed
29 30
#define h5_setprop_file_mpio FC_MANGLING( \
                h5_setprop_file_mpio,	  \
gsell's avatar
gsell committed
31
                H5_SETPROP_FILE_MPIO)
32
h5_int64_t
gsell's avatar
gsell committed
33
h5_setprop_file_mpio (
gsell's avatar
gsell committed
34 35 36 37 38 39 40 41
        h5_int64_t* _prop,
	MPI_Fint* _comm
        ) {
        H5_API_ENTER (h5_int64_t,
                      "prop=%lld, comm=%lld",
                      (long long int)*_prop, (long long int)*_comm);
        h5_prop_t prop = (h5_prop_t)*_prop;
        MPI_Comm comm = MPI_Comm_f2c (*_comm);
gsell's avatar
gsell committed
42
        H5_API_RETURN ((h5_int64_t)h5_set_prop_file_mpio_collective (prop, &comm));
gsell's avatar
gsell committed
43 44
}

gsell's avatar
gsell committed
45 46
#define h5_setprop_file_mpio_collective FC_MANGLING( \
                h5_setprop_file_mpio_collective,     \
gsell's avatar
gsell committed
47
                H5_SETPROP_FILE_MPIO_COLLECTIVE)
gsell's avatar
gsell committed
48
h5_int64_t
gsell's avatar
gsell committed
49 50 51 52 53 54 55 56 57 58 59 60
h5_setprop_file_mpio_collective (
        h5_int64_t* _prop,
	MPI_Fint* _comm
        ) {
        H5_API_ENTER (h5_int64_t,
                      "prop=%lld, comm=%lld",
                      (long long int)*_prop, (long long int)*_comm);
        h5_prop_t prop = (h5_prop_t)*_prop;
        MPI_Comm comm = MPI_Comm_f2c (*_comm);
        H5_API_RETURN ((h5_int64_t)h5_set_prop_file_mpio_collective (prop, &comm));
}

gsell's avatar
gsell committed
61 62
#define h5_setprop_file_mpio_independent FC_MANGLING( \
                h5_setprop_file_mpio_independent,     \
gsell's avatar
gsell committed
63 64 65 66 67 68 69 70 71 72 73 74 75 76
                H5_SETPROP_FILE_MPIO_INDEPENDENT)
h5_int64_t
h5_setprop_file_mpio_independent (
        h5_int64_t* _prop,
	MPI_Fint* _comm
        ) {
        H5_API_ENTER (h5_int64_t,
                      "prop=%lld, comm=%lld",
                      (long long int)*_prop, (long long int)*_comm);
        h5_prop_t prop = (h5_prop_t)*_prop;
        MPI_Comm comm = MPI_Comm_f2c (*_comm);
        H5_API_RETURN ((h5_int64_t)h5_set_prop_file_mpio_independent (prop, &comm));
}

gsell's avatar
gsell committed
77
#if H5_VERSION_LE(1,8,12)
gsell's avatar
gsell committed
78
#define h5_setprop_file_mpio_posix FC_MANGLING( \
gsell's avatar
gsell committed
79 80 81 82 83 84 85 86 87 88 89 90 91 92
                h5_setprop_file_mpio_posix,  \
                H5_SETPROP_FILE_MPIO_POSIX)
h5_int64_t
h5_setprop_file_mpio_posix (
        h5_int64_t* _prop,
	MPI_Fint* _comm
        ) {
        H5_API_ENTER (h5_int64_t,
                      "prop=%lld, comm=%lld",
                      (long long int)*_prop, (long long int)*_comm);
        h5_prop_t prop = (h5_prop_t)*_prop;
        MPI_Comm comm = MPI_Comm_f2c (*_comm);
        H5_API_RETURN ((h5_int64_t)h5_set_prop_file_mpio_posix (prop, &comm));
}
gsell's avatar
gsell committed
93
#endif
gsell's avatar
gsell committed
94

gsell's avatar
gsell committed
95 96
#endif

gsell's avatar
gsell committed
97 98
#define h5_setprop_file_corevfd FC_MANGLING( \
                h5_setprop_file_corevfd,     \
gsell's avatar
gsell committed
99 100 101
                H5_SETPROP_FILE_COREVFD)
h5_int64_t
h5_setprop_file_corevfd (
102 103
        h5_int64_t* _prop,
	h5_int64_t* increment
gsell's avatar
gsell committed
104 105
        ) {
        H5_API_ENTER (h5_int64_t,
106 107
                      "prop=%lld, increment=%lld",
                      (long long int)*_prop, (long long int)*increment);
gsell's avatar
gsell committed
108
        h5_prop_t prop = (h5_prop_t)*_prop;
gsell's avatar
gsell committed
109
        H5_API_RETURN ((h5_int64_t)h5_set_prop_file_core_vfd (prop, *increment));
gsell's avatar
gsell committed
110 111
}

gsell's avatar
gsell committed
112 113
#define h5_setprop_file_align FC_MANGLING (  \
                h5_setprop_file_align,	     \
gsell's avatar
gsell committed
114 115 116
                H5_SETPROP_FILE_ALIGN)
h5_int64_t
h5_setprop_file_align (
gsell's avatar
gsell committed
117 118 119 120 121 122 123 124
        h5_int64_t* _prop,
        h5_int64_t* align
        ) {
        H5_API_ENTER (h5_err_t,
                      "prop=%lld, align=%lld",
                      (long long int)*_prop, (long long int)*align);
        h5_prop_t prop = (h5_prop_t)*_prop;
        H5_API_RETURN (h5_set_prop_file_align (prop, *align));
125 126
}

gsell's avatar
gsell committed
127
#define h5_setprop_file_throttle FC_MANGLING (		  \
gsell's avatar
gsell committed
128 129
                h5_setprop_file_throttle,                 \
                H5_SETPROP_FILE_THROTTLE)
130 131

h5_int64_t
gsell's avatar
gsell committed
132
h5_setprop_file_throttle (
gsell's avatar
gsell committed
133 134 135 136 137 138 139 140 141
        h5_int64_t* _prop,
        h5_int64_t* throttle
        ) {
        H5_API_ENTER (
                h5_err_t,
                "prop=%lld, throttle=%lld",
                (long long int)*_prop, (long long int)*throttle);
        h5_prop_t prop = (h5_prop_t)*_prop;
        H5_API_RETURN (h5_set_prop_file_throttle (prop, *throttle));
142 143
}

gsell's avatar
gsell committed
144
#define h5_closeprop FC_MANGLING (		\
gsell's avatar
gsell committed
145 146
                h5_closeprop,                   \
                H5_CLOSEPROP)
147
h5_int64_t
gsell's avatar
gsell committed
148 149 150 151 152 153 154 155 156 157
h5_closeprop (
        h5_int64_t* _prop
        ) {
        H5_API_ENTER (h5_err_t,
                      "prop=%lld",
                      (long long int)*_prop);
        h5_prop_t prop = (h5_prop_t)*_prop;
        H5_API_RETURN (h5_close_prop (prop));
}

gsell's avatar
gsell committed
158
#define h5_openfile FC_MANGLING( \
gsell's avatar
gsell committed
159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179
                h5_openfile,  \
                H5_OPENFILE)
h5_int64_t
h5_openfile (
	const char* _fname,
        h5_int64_t* _mode,
        h5_int64_t* _props,
	const int _len_fname
        ) {
        int len_fname = strlenf (_fname, _len_fname);
        H5_API_ENTER (h5_int64_t,
                      "fname = %*s, mode=%lld, props=%lld",
                      len_fname, _fname, (long long int)*_mode, (long long int)*_props);
        char* fname = h5_strdupfor2c (_fname, _len_fname);
        h5_int64_t mode = *_mode;
        h5_prop_t props = (h5_prop_t)*_props;
        h5_file_t f = h5_open_file2 (fname, mode, props);
        free (fname);
        H5_API_RETURN ((h5_int64_t)f);
}

gsell's avatar
gsell committed
180 181
#define h5_closefile FC_MANGLING(                  \
                h5_closefile,			   \
gsell's avatar
gsell committed
182 183 184 185
                H5_CLOSEFILE)
h5_int64_t
h5_closefile (
	const h5_int64_t *f
186
	) {
gsell's avatar
gsell committed
187 188 189
	h5_file_t fh = h5_filehandlefor2c(f);
	H5_API_ENTER (h5_int64_t, "f=%p", (h5_file_p)fh);
	H5_API_RETURN (h5_close_file (fh));
190 191
}

gsell's avatar
gsell committed
192 193
#define h5_checkfile FC_MANGLING(                  \
                h5_checkfile,			   \
gsell's avatar
gsell committed
194
                H5_CHECKFILE)
195
h5_int64_t
gsell's avatar
gsell committed
196 197
h5_checkfile (
	const h5_int64_t *f
198
	) {
gsell's avatar
gsell committed
199 200 201
	h5_file_t fh = h5_filehandlefor2c(f);
	H5_API_ENTER (h5_int64_t, "f=%p", (h5_file_p)fh);
	H5_API_RETURN (h5_check_filehandle (fh));
202 203
}

gsell's avatar
gsell committed
204 205
#define h5_flushfile FC_MANGLING(                      \
                h5_flushfile,			       \
gsell's avatar
gsell committed
206
                H5_FLUSHFILE)
207
h5_int64_t
gsell's avatar
gsell committed
208 209
h5_flushfile (
	const h5_int64_t* f
210
	) {
gsell's avatar
gsell committed
211 212 213
	h5_file_t fh = h5_filehandlefor2c(f);
	H5_API_ENTER (h5_int64_t, "f=%p", (h5_file_p)fh);
	H5_API_RETURN (h5_flush_file (fh));
214 215
}

gsell's avatar
gsell committed
216
#define h5_flushstep FC_MANGLING(		    \
gsell's avatar
gsell committed
217 218
                h5_flushstep,                       \
                H5_FLUSHSTEP)
219
h5_int64_t
gsell's avatar
gsell committed
220 221
h5_flushstep (
	const h5_int64_t* f
222 223 224
	) {
	h5_file_t fh = h5_filehandlefor2c(f);
	H5_API_ENTER (h5_int64_t, "f=%p", (h5_file_p)fh);
gsell's avatar
gsell committed
225
	H5_API_RETURN (h5_flush_step (fh));
226 227
}

gsell's avatar
gsell committed
228
#define h5_finalize FC_MANGLING(		   \
229 230 231 232 233 234 235
                h5_finalize,                       \
                H5_FINALIZE)
h5_int64_t
h5_finalize (
	void
	) {
	H5_API_ENTER (h5_int64_t, "%s", "");
gsell's avatar
gsell committed
236
	H5_API_RETURN (h5_close_h5hut ());
237 238 239 240 241
}



/* debug output */
gsell's avatar
gsell committed
242
#define h5_set_verbosity_level FC_MANGLING(	\
243 244 245 246 247 248 249 250
                h5_set_verbosity_level,         \
                H5_SET_VERBOSITY_LEVEL)
h5_int64_t
h5_set_verbosity_level (
	const h5_int64_t *level
	) {

	H5_API_ENTER (h5_int64_t, "level=%lld", (long long)*level);
251
	H5_API_RETURN(h5_set_loglevel (*level));
252 253
}

gsell's avatar
gsell committed
254 255
#define h5_abort_on_error FC_MANGLING( \
                h5_abort_on_error,     \
gsell's avatar
gsell committed
256 257 258 259 260 261
                H5_ABORT_ON_ERROR)
h5_int64_t
h5_abort_on_error (
        void
        ) {
	H5_API_ENTER (h5_int64_t, "%s", "");
262
        h5_set_loglevel (1);
gsell's avatar
gsell committed
263 264 265
        H5_API_RETURN (h5_set_errorhandler (h5_abort_errorhandler));
}

gsell's avatar
gsell committed
266 267
#define h5_get_error_number FC_MANGLING(	\
                h5_get_error_number,		\
268 269 270 271 272 273 274 275
                H5_GET_ERROR_NUMBER)
h5_int64_t
h5_get_error_number (
        void
        ) {
	H5_API_ENTER (h5_int64_t, "%s", "");
        H5_API_RETURN (h5_get_errno ());
}