forked from ornladios/ADIOS2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
adios2_c_io.h
380 lines (344 loc) · 15.2 KB
/
adios2_c_io.h
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
/*
* Distributed under the OSI-approved Apache License, Version 2.0. See
* accompanying file Copyright.txt for details.
*
* adios2_c_io.h
*
* Created on: Nov 8, 2017
* Author: William F Godoy godoywf@ornl.gov
*/
#ifndef ADIOS2_BINDINGS_C_C_ADIOS2_C_IO_H_
#define ADIOS2_BINDINGS_C_C_ADIOS2_C_IO_H_
#include "adios2_c_types.h"
#if ADIOS2_USE_MPI
#include <mpi.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Check if io exists in a config file passed to the adios handler that
* created this io
* @param result output adios2_true=1: in config file, adios2_false=0: not in
* config file
* @param io handler
* @return adios2_error 0: success, see enum adios2_error for errors
*/
adios2_error adios2_in_config_file(adios2_bool *result, const adios2_io *io);
/**
* @brief Set the engine type for current io handler
* @param io handler
* @param engine_type predefined engine type, default is bpfile
* @return adios2_error 0: success, see enum adios2_error for errors
*/
adios2_error adios2_set_engine(adios2_io *io, const char *engine_type);
/**
* @brief Set several parameters at once.
* @param io handler
* @param string parameters in the format "param1=value1 , param2 = value2"
* @return adios2_error 0: success, see enum adios2_error for errors
*/
adios2_error adios2_set_parameters(adios2_io *io, const char *parameters);
/**
* @brief Set a single parameter. Overwrites value if key exists
* @param io handler
* @param key parameter key
* @param value parameter value
* @return adios2_error 0: success, see enum adios2_error for errors
*/
adios2_error adios2_set_parameter(adios2_io *io, const char *key, const char *value);
/**
* Return IO parameter value string and length without '\0\ character
* For safe use, call this function first with NULL name parameter
* to get the size, then preallocate the buffer (with room for '\0'
* if desired), then call the function again with the buffer.
* Then '\0' terminate it if desired.
* @param value output
* @param size output, value size without '\0'
* @param io input handler
* @param key input parameter key, if not found return size = 0 and value is
* untouched
* @return adios2_error 0: success, see enum adios2_error for errors
*/
adios2_error adios2_get_parameter(char *value, size_t *size, const adios2_io *io, const char *key);
/**
* @brief Clear all parameters.
* @param io handler
* @return adios2_error 0: success, see enum adios2_error for errors
*/
adios2_error adios2_clear_parameters(adios2_io *io);
/**
* @brief Add a transport to current io handler. Must be supported by current
* engine type.
* @param transport_index handler used for setting transport parameters or at
* adios2_close
* @param io handler
* @param type must be a supported transport type for a particular Engine.
* CAN'T use the keywords "Transport" or "transport"
* @return adios2_error 0: success, see enum adios2_error for errors
*/
adios2_error adios2_add_transport(size_t *transport_index, adios2_io *io, const char *type);
/**
* @brief Set a single parameter to an existing transport identified
* with a transport_index handler from adios2_add_transport.
* Overwrites existing parameter with the same key.
* @param io handler
* @param transport_index handler from adios2_add_transport
* @param key parameter key
* @param value parameter value
* @return adios2_error 0: success, see enum adios2_error for errors
*/
adios2_error adios2_set_transport_parameter(adios2_io *io, const size_t transport_index,
const char *key, const char *value);
/**
* @brief Define a variable within io
* @param io handler that owns the variable
* @param name unique variable identifier
* @param type primitive type from enum adios2_type in adios2_c_types.h
* @param ndims number of dimensions
* @param shape global dimension
* @param start local offset
* @param count local dimension
* @param constant_dims adios2_constant_dims_true:: shape, start, count
* won't change; adios2_constant_dims_false: shape, start, count will change
* after definition
* @return success: handler, failure: NULL
*/
adios2_variable *adios2_define_variable(adios2_io *io, const char *name, const adios2_type type,
const size_t ndims, const size_t *shape,
const size_t *start, const size_t *count,
const adios2_constant_dims constant_dims);
#ifdef ADIOS2_HAVE_DERIVED_VARIABLE
/**
* @brief Define a derived variable within io
* @param io handler that owns the variable
* @param name unique variable identifier
* @param type primitive type from enum adios2_type in adios2_c_types.h
* @param ndims number of dimensions
* @param shape global dimension
* @param start local offset
* @param count local dimension
* @param constant_dims adios2_constant_dims_true:: shape, start, count
* won't change; adios2_constant_dims_false: shape, start, count will change
* after definition
* @return success: handler, failure: NULL
*/
adios2_derived_variable *adios2_define_derived_variable(adios2_io *io, const char *name,
const char *expression,
const adios2_derived_var_type type);
#endif
/**
* @brief Retrieve a variable handler within current io handler
* @param io handler to variable io owner
* @param name unique variable identifier within io handler
* @return found: handler, not found: NULL
*/
adios2_variable *adios2_inquire_variable(adios2_io *io, const char *name);
/**
* Returns an array of variable handlers for all variable present in the io
* group
* @param variables output array of variable pointers (pointer to an
* adios2_variable**)
* @param size output number of variables
* @param io handler to variables io owner
* @return adios2_error 0: success, see enum adios2_error for errors
*/
adios2_error adios2_inquire_all_variables(adios2_variable ***variables, size_t *size,
adios2_io *io);
/*
* list all variables under full_group_name
*/
adios2_error adios2_inquire_group_variables(adios2_variable ***variables,
const char *full_group_name, size_t *size,
adios2_io *io);
/**
* @brief Define an attribute value inside io
* @param io handler that owns the attribute
* @param name unique attribute name inside IO handler
* @param type primitive type from enum adios2_type in adios2_c_types.h
* @param value attribute single value
* @return success: handler, failure: NULL
*/
adios2_attribute *adios2_define_attribute(adios2_io *io, const char *name, const adios2_type type,
const void *value);
/**
* @brief Define an attribute array inside io
* @param io handler that owns the attribute
* @param name unique attribute name inside IO handler
* @param type primitive type from enum adios2_type in adios2_c_types.h
* @param data attribute data array
* @param size number of elements of data array
* @return success: handler, failure: NULL
*/
adios2_attribute *adios2_define_attribute_array(adios2_io *io, const char *name,
const adios2_type type, const void *data,
const size_t size);
/**
* Define an attribute single value associated to an existing variable by its
* name
* @param io handler that owns the variable and attribute
* @param name unique attribute name inside a variable in io handler
* @param type primitive type from enum adios2_type in adios2_c_types.h
* @param value attribute single value
* @param variable_name unique variable identifier in io handler. If variable
* doesn't exist adios2_error is adios2_error_invalid_argument.
* @param separator hierarchy separator (e.g. "/" in variable_name/name )
* @return success: handler, failure: NULL
*/
adios2_attribute *adios2_define_variable_attribute(adios2_io *io, const char *name,
const adios2_type type, const void *value,
const char *variable_name,
const char *separator);
/**
* Define an attribute array associated to an existing variable by its name
* @param io handler that owns the variable and attribute
* @param name unique attribute name inside a variable in io handler
* @param type primitive type from enum adios2_type in adios2_c_types.h
* @param data attribute data single value or array
* @param size number of elements of data array
* @param variable_name unique variable identifier in io handler. If variable
* doesn't exist adios2_error is true.
* @param separator hierarchy separator (e.g. "/" in variable/attribute )
* @return success: handler, failure: NULL
*/
adios2_attribute *adios2_define_variable_attribute_array(adios2_io *io, const char *name,
const adios2_type type, const void *data,
const size_t size,
const char *variable_name,
const char *separator);
/**
* Returns a handler to a previously defined attribute by name
* @param io handler to attribute io owner
* @param name unique attribute identifier within io handler
* @return found: handler, not found: NULL
*/
adios2_attribute *adios2_inquire_attribute(adios2_io *io, const char *name);
/**
* Retrieve a handler to a previously defined attribute associated to a variable
* @param io handler to attribute and variable io owner
* @param name unique attribute name inside a variable in io handler
* @param variable_name name of the variable associate with this attribute
* @param separator hierarchy separator (e.g. "/" in variable/attribute )
* @return found: handler, not found: NULL
*/
adios2_attribute *adios2_inquire_variable_attribute(adios2_io *io, const char *name,
const char *variable_name,
const char *separator);
/**
* Returns an array of attribute handlers for all attribute present in the io
* group
* @param attributes output array of attribute pointers (pointer to an
* adios2_attribute**)
* @param size output number of attributes
* @param io handler to attributes io owner
* @return adios2_error 0: success, see enum adios2_error for errors
*/
adios2_error adios2_inquire_all_attributes(adios2_attribute ***attributes, size_t *size,
adios2_io *io);
adios2_error adios2_inquire_group_attributes(adios2_attribute ***attributes,
const char *full_prefix, size_t *size, adios2_io *io);
/**
* Return a list of list sub group names
*
*/
adios2_error adios2_inquire_subgroups(char ***subGroupNames, const char *full_prefix, size_t *size,
adios2_io *io);
/**
* @brief DANGEROUS! Removes a variable identified by name. Might create
* dangling pointers
* @param result output adios2_true(1): found and removed variable,
* adios2_false(0): not found, nothing to remove
* @param io handler variable io owner
* @param name unique variable name within io handler
* @return adios2_error 0: success, see enum adios2_error for errors
*/
adios2_error adios2_remove_variable(adios2_bool *result, adios2_io *io, const char *name);
/**
* @brief DANGEROUS! Removes all existing variables in current IO object.
* Might create dangling pointers
* @param io handler variables io owner
* @return adios2_error 0: success, see enum adios2_error for errors
*/
adios2_error adios2_remove_all_variables(adios2_io *io);
/**
* @brief returns an array or c strings for names of available variables
* Might create dangling pointers
* @param io handler variables io owner
* @param length of array of strings
* @return names of variables as an array of strings
*/
char **adios2_available_variables(adios2_io *io, size_t *size);
/**
* @brief returns an array or c strings for names of available attributes
* Might create dangling pointers
* @param io handler variables io owner
* @param length of array of strings
* @return names of variables as an array of strings
*/
char **adios2_available_attributes(adios2_io *io, size_t *size);
/**
* @brief DANGEROUS! Removes an attribute identified by name. Might create
* dangling pointers
* @param result output adios2_true(1): found and removed attribute,
* adios2_false(0): not found, nothing to remove
* @param io handler attribute io owner
* @param name unique attribute name within io handler
* @return adios2_error 0: success, see enum adios2_error for errors
*/
adios2_error adios2_remove_attribute(adios2_bool *result, adios2_io *io, const char *name);
/**
* @brief DANGEROUS! Removes all existing attributes in current IO object.
* Might create dangling pointers
* @param io handler attributes io owner
* @return adios2_error 0: success, see enum adios2_error for errors
*/
adios2_error adios2_remove_all_attributes(adios2_io *io);
/**
* Open an Engine to start heavy-weight input/output operations.
* In MPI version reuses the communicator from adios2_init or adios2_init_config
* MPI Collective function as it calls MPI_Comm_dup
* @param io engine owner
* @param name unique engine identifier
* @param mode adios2_mode_write, adios2_mode_read, adios2_mode_append, and
* adios2_mode_readRandomAccess
* @return success: handler, failure: NULL
*/
adios2_engine *adios2_open(adios2_io *io, const char *name, const adios2_mode mode);
#if ADIOS2_USE_MPI
/**
* Open an Engine to start heavy-weight input/output operations.
* MPI Collective function as it calls MPI_Comm_dup
* @param io engine owner
* @param name unique engine identifier
* @param mode adios2_mode_write, adios2_mode_read, adios2_mode_append, and
* adios2_mode_readRandomAccess
* @param comm communicator other than adios' handler comm. MPI only.
* @return success: handler, failure: NULL
*/
adios2_engine *adios2_open_new_comm(adios2_io *io, const char *name, const adios2_mode mode,
MPI_Comm comm);
#endif
/**
* Flushes all engines created with current io handler using adios2_open
* @param io handler whose engine will be flushed
* @return adios2_error 0: success, see enum adios2_error for errors
*/
adios2_error adios2_flush_all_engines(adios2_io *io);
/**
* return engine type string and length without null character
* For safe use, call this function first with NULL name parameter
* to get the size, then preallocate the buffer (with room for '\0'
* if desired), then call the function again with the buffer.
* Then '\0' terminate it if desired.
* @param engine_type output, string without trailing '\0', NULL or preallocated
* buffer
* @param size output, engine_type size without '\0'
* @param io handler
* @return adios2_error 0: success, see enum adios2_error for errors
*/
adios2_error adios2_engine_type(char *engine_type, size_t *size, const adios2_io *io);
adios2_engine *adios2_get_engine(adios2_io *io, const char *name);
#ifdef __cplusplus
} // end extern C
#endif
#endif /* ADIOS2_BINDINGS_C_C_ADIOS2_C_IO_H_ */