H5.c 7.93 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 13

#include "h5core/h5.h"
#include "h5core/h5_debug.h"
14 15
#include "h5core/h5_model.h"

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

gsell's avatar
gsell committed
27 28 29
#if defined(PARALLEL_IO)
#define h5_setprop_file_mpio FC_MANGLING( \
                h5_setprop_file_mpio,	  \
gsell's avatar
gsell committed
30
                H5_SETPROP_FILE_MPIO)
31
h5_int64_t
gsell's avatar
gsell committed
32
h5_setprop_file_mpio (
gsell's avatar
gsell committed
33 34 35 36 37 38 39 40
        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
41
        H5_API_RETURN ((h5_int64_t)h5_set_prop_file_mpio_collective (prop, &comm));
gsell's avatar
gsell committed
42 43
}

gsell's avatar
gsell committed
44 45
#define h5_setprop_file_mpio_collective FC_MANGLING( \
                h5_setprop_file_mpio_collective,     \
gsell's avatar
gsell committed
46
                H5_SETPROP_FILE_MPIO_COLLECTIVE)
gsell's avatar
gsell committed
47
h5_int64_t
gsell's avatar
gsell committed
48 49 50 51 52 53 54 55 56 57 58 59
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
60 61
#define h5_setprop_file_mpio_independent FC_MANGLING( \
                h5_setprop_file_mpio_independent,     \
gsell's avatar
gsell committed
62 63 64 65 66 67 68 69 70 71 72 73 74 75
                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
76
#if H5_VERSION_LE(1,8,12)
gsell's avatar
gsell committed
77
#define h5_setprop_file_mpio_posix FC_MANGLING( \
gsell's avatar
gsell committed
78 79 80 81 82 83 84 85 86 87 88 89 90 91
                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
92
#endif
gsell's avatar
gsell committed
93

gsell's avatar
gsell committed
94 95
#endif

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

gsell's avatar
gsell committed
111 112
#define h5_setprop_file_align FC_MANGLING (  \
                h5_setprop_file_align,	     \
gsell's avatar
gsell committed
113 114 115
                H5_SETPROP_FILE_ALIGN)
h5_int64_t
h5_setprop_file_align (
gsell's avatar
gsell committed
116 117 118 119 120 121 122 123
        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));
124 125
}

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

h5_int64_t
gsell's avatar
gsell committed
131
h5_setprop_file_throttle (
gsell's avatar
gsell committed
132 133 134 135 136 137 138 139 140
        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));
141 142
}

gsell's avatar
gsell committed
143
#define h5_closeprop FC_MANGLING (		\
gsell's avatar
gsell committed
144 145
                h5_closeprop,                   \
                H5_CLOSEPROP)
146
h5_int64_t
gsell's avatar
gsell committed
147 148 149 150 151 152 153 154 155 156
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
157
#define h5_openfile FC_MANGLING( \
gsell's avatar
gsell committed
158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178
                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
179 180
#define h5_closefile FC_MANGLING(                  \
                h5_closefile,			   \
gsell's avatar
gsell committed
181 182 183 184
                H5_CLOSEFILE)
h5_int64_t
h5_closefile (
	const h5_int64_t *f
185
	) {
gsell's avatar
gsell committed
186 187 188
	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));
189 190
}

gsell's avatar
gsell committed
191 192
#define h5_checkfile FC_MANGLING(                  \
                h5_checkfile,			   \
gsell's avatar
gsell committed
193
                H5_CHECKFILE)
194
h5_int64_t
gsell's avatar
gsell committed
195 196
h5_checkfile (
	const h5_int64_t *f
197
	) {
gsell's avatar
gsell committed
198 199 200
	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));
201 202
}

gsell's avatar
gsell committed
203 204
#define h5_flushfile FC_MANGLING(                      \
                h5_flushfile,			       \
gsell's avatar
gsell committed
205
                H5_FLUSHFILE)
206
h5_int64_t
gsell's avatar
gsell committed
207 208
h5_flushfile (
	const h5_int64_t* f
209
	) {
gsell's avatar
gsell committed
210 211 212
	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));
213 214
}

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

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



/* debug output */
gsell's avatar
gsell committed
241
#define h5_set_verbosity_level FC_MANGLING(	\
242 243 244 245 246 247 248 249 250 251 252
                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);
	H5_API_RETURN(h5_set_debuglevel (*level));
}

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

gsell's avatar
gsell committed
265 266
#define h5_get_error_number FC_MANGLING(	\
                h5_get_error_number,		\
267 268 269 270 271 272 273 274
                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 ());
}