sdf-xarray 0.5.0__cp314-cp314t-win_amd64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,804 @@
1
+ /*
2
+ * SDF (Self-Describing Format) Software Library
3
+ * Copyright (c) 2012-2016, SDF Development Team
4
+ *
5
+ * Distributed under the terms of the BSD 3-clause License.
6
+ * See the LICENSE file for details.
7
+ */
8
+
9
+ /**
10
+ @file sdf.h
11
+
12
+ @brief Declarations for the SDF C-library.
13
+ @details Routines for reading and writing SDF files.
14
+ @author Dr Keith Bennett
15
+ @date 15/02/2014
16
+ @version 14.4
17
+ */
18
+
19
+ #ifndef _SDF_COMMON_H_
20
+ #define _SDF_COMMON_H_
21
+
22
+ #include <stdio.h>
23
+ #include <inttypes.h>
24
+
25
+ #include "uthash.h"
26
+
27
+ #ifdef PARALLEL
28
+ #include <mpi.h>
29
+ #endif
30
+
31
+ #define SDF_VERSION 1
32
+ #define SDF_REVISION 4
33
+ #define SDF_LIB_VERSION 14
34
+ #define SDF_LIB_REVISION 4
35
+
36
+ #define SDF_MAGIC "SDF1"
37
+
38
+ #define SDF_MAXDIMS 4
39
+
40
+ #ifdef __cplusplus
41
+ extern "C" {
42
+ #endif
43
+
44
+ /**
45
+ Constants used for identifying the block's type
46
+ */
47
+ enum sdf_blocktype {
48
+ /** Deleted block. Should be ignored. */
49
+ SDF_BLOCKTYPE_SCRUBBED = -1,
50
+ /** Unknown block type. This is an error. */
51
+ SDF_BLOCKTYPE_NULL = 0,
52
+ /** Block describing a plain mesh or grid. */
53
+ SDF_BLOCKTYPE_PLAIN_MESH,
54
+ /** Block describing a point mesh or grid. */
55
+ SDF_BLOCKTYPE_POINT_MESH,
56
+ /** Block describing a variable on a plain mesh. */
57
+ SDF_BLOCKTYPE_PLAIN_VARIABLE,
58
+ /** Block describing a variable on a point mesh. */
59
+ SDF_BLOCKTYPE_POINT_VARIABLE,
60
+ /** A simple constant not associated with a grid. */
61
+ SDF_BLOCKTYPE_CONSTANT,
62
+ /** A simple array not associated with a grid. */
63
+ SDF_BLOCKTYPE_ARRAY,
64
+ /** Information about the simulation. */
65
+ SDF_BLOCKTYPE_RUN_INFO,
66
+ /** Embedded source code block. */
67
+ SDF_BLOCKTYPE_SOURCE,
68
+ /** List of blocks to combine as a tensor or vector. */
69
+ SDF_BLOCKTYPE_STITCHED_TENSOR,
70
+ /** List of blocks to combine as a multi-material mesh. */
71
+ SDF_BLOCKTYPE_STITCHED_MATERIAL,
72
+ /** List of blocks to combine as a multi-material variable. */
73
+ SDF_BLOCKTYPE_STITCHED_MATVAR,
74
+ /** List of blocks to combine as a species mesh. This is similar to a
75
+ * multi-material mesh except there is no interface in a mixed cell. */
76
+ SDF_BLOCKTYPE_STITCHED_SPECIES,
77
+ /** Information about a particle species. */
78
+ SDF_BLOCKTYPE_SPECIES,
79
+ /** This blocktype is never actually written to an SDF file. It is used
80
+ * within the C-library and VisIt to represent a plain variable whose
81
+ * content is generated dynamically based on other data in the file. */
82
+ SDF_BLOCKTYPE_PLAIN_DERIVED,
83
+ /** As above, this blocktype is never actually written to an SDF file. It
84
+ * serves the same purpose as SDF_BLOCKTYPE_PLAIN_DERIVED, except the
85
+ * variable is defined on a point mesh. */
86
+ SDF_BLOCKTYPE_POINT_DERIVED,
87
+ /** This is the same as SDF_BLOCKTYPE_STITCHED_TENSOR, except that all the
88
+ * data for the stitched variables is contained in the data section of
89
+ * this block rather than the blocks which are referenced. */
90
+ SDF_BLOCKTYPE_CONTIGUOUS_TENSOR,
91
+ /** Same as above, for SDF_BLOCKTYPE_STITCHED_MATERIAL */
92
+ SDF_BLOCKTYPE_CONTIGUOUS_MATERIAL,
93
+ /** Same as above, for SDF_BLOCKTYPE_STITCHED_MATVAR */
94
+ SDF_BLOCKTYPE_CONTIGUOUS_MATVAR,
95
+ /** Same as above, for SDF_BLOCKTYPE_STITCHED_SPECIES */
96
+ SDF_BLOCKTYPE_CONTIGUOUS_SPECIES,
97
+ /** Information about the parallel domain decomposition. */
98
+ SDF_BLOCKTYPE_CPU_SPLIT,
99
+ /** List of blocks to combine as an obstacle mesh. */
100
+ SDF_BLOCKTYPE_STITCHED_OBSTACLE_GROUP,
101
+ /** Block describing an unstructured mesh or grid. */
102
+ SDF_BLOCKTYPE_UNSTRUCTURED_MESH,
103
+ /** Block describing a stitched variable.
104
+ * This allows any arbitrary set of variables to be grouped together. */
105
+ SDF_BLOCKTYPE_STITCHED,
106
+ /** This is the same as SDF_BLOCKTYPE_STITCHED, except that all the
107
+ * data for the stitched variables is contained in the data section of
108
+ * this block rather than the blocks which are referenced. */
109
+ SDF_BLOCKTYPE_CONTIGUOUS,
110
+ /** Block describing a Lagrangian mesh or grid. */
111
+ SDF_BLOCKTYPE_LAGRANGIAN_MESH,
112
+ /** Block describing a station point. */
113
+ SDF_BLOCKTYPE_STATION,
114
+ /** As with SDF_BLOCKTYPE_PLAIN_DERIVED, this blocktype is never actually
115
+ * written to an SDF file. It serves the same purpose as
116
+ * SDF_BLOCKTYPE_PLAIN_DERIVED, except the variable is defined as a
117
+ * station variable. */
118
+ SDF_BLOCKTYPE_STATION_DERIVED,
119
+ /** Raw data with a checksum. */
120
+ SDF_BLOCKTYPE_DATABLOCK,
121
+ /** Name/value pairs. */
122
+ SDF_BLOCKTYPE_NAMEVALUE,
123
+ };
124
+
125
+
126
+ /**
127
+ The "geometry_type" specifies the geometry of the current block and it can
128
+ take one of the following values:
129
+ */
130
+ enum sdf_geometry {
131
+ SDF_GEOMETRY_NULL = 0, /**< Unspecified geometry. This is an error. */
132
+ SDF_GEOMETRY_CARTESIAN, /**< Cartesian geometry. */
133
+ SDF_GEOMETRY_CYLINDRICAL, /**< Cylindrical geometry. */
134
+ SDF_GEOMETRY_SPHERICAL, /**< Spherical geometry. */
135
+ };
136
+
137
+
138
+ /**
139
+ The mesh associated with a variable is always node-centred, ie. the values
140
+ written as mesh data specify the nodal values of a grid. Variables may be
141
+ defined at points which are offset from this grid due to grid staggering in
142
+ the code. The "stagger" entry specifies where the variable is defined
143
+ relative to the mesh. Since we have already defined the number of points
144
+ that the associated mesh contains, this determines how many points are required
145
+ to display the variable. The entry is represented by a bit-mask where each
146
+ bit corresponds to a shift in coordinates by half a grid cell in the direction
147
+ given by the bit position. Therefore the value "1" (or "0001" in binary)
148
+ is a shift by \e dx/2 in the \e x direction, "2" (or "0010" in binary) is
149
+ a shift by \e dy/2 in the \e y direction and "4" (or "0100" in binary) is
150
+ a shift by \e dz/2 in the \e z direction. These can be combined to give shifts
151
+ in more than one direction. The system can also be extended to account for
152
+ more than three directions (eg. "8" for direction 4).
153
+
154
+ For convenience, a list of pre-defined constants are defined for the typical
155
+ cases.
156
+ */
157
+ enum sdf_stagger {
158
+ /** Cell centred. At the midpoint between nodes.
159
+ * Implies an <em>(nx,ny,nz)</em> grid. */
160
+ SDF_STAGGER_CELL_CENTRE = 0,
161
+ /** Face centred in X. Located at the midpoint between nodes on the Y-Z
162
+ * plane.
163
+ * Implies an <em>(nx+1,ny,nz)</em> grid. */
164
+ SDF_STAGGER_FACE_X,
165
+ /** Face centred in Y. Located at the midpoint between nodes on the X-Z
166
+ * plane.
167
+ * Implies an <em>(nx,ny+1,nz)</em> grid. */
168
+ SDF_STAGGER_FACE_Y,
169
+ /** Face centred in Z. Located at the midpoint between nodes on the X-Y
170
+ * plane.
171
+ * Implies an <em>(nx,ny,nz+1)</em> grid. */
172
+ SDF_STAGGER_EDGE_Z,
173
+ /** Edge centred along X. Located at the midpoint between nodes along the
174
+ * X-axis.
175
+ * Implies an <em>(nx,ny+1,nz+1)</em> grid. */
176
+ SDF_STAGGER_FACE_Z,
177
+ /** Edge centred along Y. Located at the midpoint between nodes along the
178
+ * Y-axis.
179
+ * Implies an <em>(nx+1,ny,nz+1)</em> grid. */
180
+ SDF_STAGGER_EDGE_Y,
181
+ /** Edge centred along Z. Located at the midpoint between nodes along the
182
+ * Z-axis.
183
+ * Implies an <em>(nx+1,ny+1,nz)</em> grid. */
184
+ SDF_STAGGER_EDGE_X,
185
+ /** Node centred. At the same place as the mesh.
186
+ * Implies an <em>(nx+1,ny+1,nz+1)</em> grid. */
187
+ SDF_STAGGER_VERTEX,
188
+ };
189
+
190
+
191
+ /**
192
+ * The datatype specifies the numberical representation of the block's data
193
+ * array.
194
+ */
195
+ enum sdf_datatype {
196
+ SDF_DATATYPE_NULL = 0, /**< No datatype specified. This is an error. */
197
+ SDF_DATATYPE_INTEGER4, /**< 4-byte integers. */
198
+ SDF_DATATYPE_INTEGER8, /**< 8-byte integers. */
199
+ SDF_DATATYPE_REAL4, /**< 4-byte floating point (ie. single precision). */
200
+ SDF_DATATYPE_REAL8, /**< 8-byte floating point (ie. double precision). */
201
+ SDF_DATATYPE_REAL16, /**< 16-byte floating point (ie. quad precision). */
202
+ SDF_DATATYPE_CHARACTER,/**< 1-byte characters. */
203
+ SDF_DATATYPE_LOGICAL, /**< Logical variables. (Represented as 1-byte
204
+ characters */
205
+ SDF_DATATYPE_OTHER, /**< Unspecified datatype. The type of data in the
206
+ block must be inferred from the block type. */
207
+ };
208
+
209
+
210
+ static const int SDF_TYPE_SIZES[] = {
211
+ 0, // SDF_DATATYPE_NULL = 0,
212
+ 4, // SDF_DATATYPE_INTEGER4,
213
+ 8, // SDF_DATATYPE_INTEGER8,
214
+ 4, // SDF_DATATYPE_REAL4,
215
+ 8, // SDF_DATATYPE_REAL8,
216
+ 16, // SDF_DATATYPE_REAL16,
217
+ 1, // SDF_DATATYPE_CHARACTER,
218
+ 1, // SDF_DATATYPE_LOGICAL,
219
+ 0, // SDF_DATATYPE_OTHER,
220
+ };
221
+
222
+
223
+ enum sdf_dimension {
224
+ SDF_DIMENSION_IRRELEVANT = 0,
225
+ SDF_DIMENSION_1D,
226
+ SDF_DIMENSION_2D,
227
+ SDF_DIMENSION_3D,
228
+ };
229
+
230
+
231
+ enum sdf_error_codes {
232
+ SDF_ERR_SUCCESS = 0,
233
+ SDF_ERR_ACCESS,
234
+ SDF_ERR_AMODE,
235
+ SDF_ERR_BAD_FILE,
236
+ SDF_ERR_CONVERSION,
237
+ SDF_ERR_DUP_DATAREP,
238
+ SDF_ERR_FILE,
239
+ SDF_ERR_FILE_EXISTS,
240
+ SDF_ERR_FILE_IN_USE,
241
+ SDF_ERR_INFO,
242
+ SDF_ERR_INFO_KEY,
243
+ SDF_ERR_INFO_NOKEY,
244
+ SDF_ERR_INFO_VALUE,
245
+ SDF_ERR_IO,
246
+ SDF_ERR_NOT_SAME,
247
+ SDF_ERR_NO_SPACE,
248
+ SDF_ERR_NO_SUCH_FILE,
249
+ SDF_ERR_QUOTA,
250
+ SDF_ERR_READ_ONLY,
251
+ SDF_ERR_UNSUPPORTED_DATAREP,
252
+ SDF_ERR_UNSUPPORTED_OPERATION,
253
+ SDF_ERR_UNKNOWN,
254
+ };
255
+
256
+
257
+ #define SDF_READ 1
258
+ #define SDF_WRITE 2
259
+
260
+ extern const char *sdf_blocktype_c[];
261
+ extern const char *sdf_geometry_c[];
262
+ extern const char *sdf_stagger_c[];
263
+ extern const char *sdf_datatype_c[];
264
+ extern const char *sdf_error_codes_c[];
265
+
266
+ extern const int sdf_blocktype_len;
267
+ extern const int sdf_geometry_len;
268
+ extern const int sdf_stagger_len;
269
+ extern const int sdf_datatype_len;
270
+ extern const int sdf_error_codes_len;
271
+
272
+ #ifdef PARALLEL
273
+ typedef MPI_Comm comm_t;
274
+ #else
275
+ typedef int comm_t;
276
+ #endif
277
+
278
+ typedef struct sdf_block sdf_block_t;
279
+ typedef struct sdf_file sdf_file_t;
280
+
281
+ struct sdf_block {
282
+ // This struct must be changed with care and the SDF_LIB_VERSION bumped
283
+ // if the resulting struct is not aligned the same.
284
+ double *extents, *dim_mults;
285
+ double *station_x, *station_y, *station_z;
286
+ double mult, time, time_increment;
287
+ int64_t dims[SDF_MAXDIMS], local_dims[SDF_MAXDIMS];
288
+ int64_t block_start, next_block_location, data_location;
289
+ int64_t inline_block_start, inline_next_block_location;
290
+ int64_t summary_block_start, summary_next_block_location;
291
+ int64_t nelements, nelements_local, data_length;
292
+ int64_t *nelements_blocks, *data_length_blocks;
293
+ int64_t *array_starts, *array_ends, *array_strides;
294
+ int64_t *global_array_starts, *global_array_ends, *global_array_strides;
295
+ int32_t ndims, geometry, datatype, blocktype, info_length;
296
+ int32_t type_size, stagger, datatype_out, type_size_out;
297
+ int32_t nstations, nvariables, step, step_increment;
298
+ int32_t *dims_in, *station_nvars, *variable_types, *station_index;
299
+ int32_t *station_move;
300
+ int nm, n_ids, opt, ng, nfaces, ngrids, offset, ngb[6];
301
+ char const_value[16];
302
+ char *id, *units, *mesh_id, *material_id;
303
+ char *vfm_id, *obstacle_id, *station_id;
304
+ char *name, *material_name, *must_read;
305
+ char **dim_labels, **dim_units;
306
+ char **station_ids, **variable_ids;
307
+ char **station_names, **material_names;
308
+ int *node_list, *boundary_cells;
309
+ void **grids, *data;
310
+ char done_header, done_info, done_data, dont_allocate, dont_display;
311
+ char dont_own_data, use_mult, next_block_modified, rewrite_metadata;
312
+ char in_file, ng_any, no_internal_ghost;
313
+ sdf_block_t *next, *prev;
314
+ sdf_block_t *subblock, *subblock2;
315
+ sdf_block_t *(*populate_data)(sdf_file_t *, sdf_block_t *);
316
+ int cpu_split[SDF_MAXDIMS], starts[SDF_MAXDIMS];
317
+ int proc_min[3], proc_max[3];
318
+ int ndim_labels, ndim_units;
319
+ int nstation_ids, nvariable_ids;
320
+ int nstation_names, nmaterial_names;
321
+ int option;
322
+ char *mimetype, *checksum_type, *checksum, *mmap;
323
+ int64_t mmap_len;
324
+ char derived;
325
+
326
+ UT_hash_handle hh1, hh2;
327
+
328
+ #ifdef PARALLEL
329
+ MPI_Datatype mpitype, distribution, mpitype_out;
330
+ #endif
331
+ };
332
+
333
+ struct sdf_file {
334
+ int64_t dbg_count;
335
+ int32_t sdf_lib_version, sdf_lib_revision;
336
+ int32_t sdf_extension_version, sdf_extension_revision;
337
+ int32_t file_version, file_revision;
338
+ char *dbg, *dbg_buf, **extension_names;
339
+ // Lines above should never be changed.
340
+ // Lines below must be changed with care and the SDF_LIB_VERSION bumped
341
+ // if the resulting struct is not aligned the same.
342
+ double time;
343
+ int64_t first_block_location, summary_location, start_location, soi, sof;
344
+ int64_t current_location;
345
+ int32_t jobid1, jobid2, endianness, summary_size;
346
+ int32_t block_header_length, string_length, id_length;
347
+ int32_t code_io_version, step;
348
+ int32_t nblocks, nblocks_file, error_code;
349
+ int rank, ncpus, ndomains, rank_master, indent, print;
350
+ char *buffer, *filename;
351
+ char done_header, restart_flag, other_domains, use_float, use_summary;
352
+ char use_random, station_file, swap;
353
+ char inline_metadata_read, summary_metadata_read;
354
+ char inline_metadata_invalid, summary_metadata_invalid, tmp_flag;
355
+ char metadata_modified, can_truncate, first_block_modified;
356
+ char *code_name, *error_message;
357
+ sdf_block_t *blocklist, *tail, *current_block, *last_block_in_file;
358
+ char *mmap;
359
+ void *ext_data;
360
+ void *stack_handle;
361
+ int array_count, fd, purge_duplicated_ids;
362
+ /* Flag to add internal ghost cells for the VisIt reader */
363
+ int internal_ghost_cells;
364
+ int ignore_nblocks;
365
+ #ifdef PARALLEL
366
+ MPI_File filehandle;
367
+ #else
368
+ FILE *filehandle;
369
+ #endif
370
+ comm_t comm;
371
+
372
+ sdf_block_t *hashed_blocks_by_id, *hashed_blocks_by_name;
373
+ };
374
+
375
+ struct run_info {
376
+ int64_t defines;
377
+ int32_t version, revision, compile_date, run_date, io_date, minor_rev;
378
+ char *commit_id, *sha1sum, *compile_machine, *compile_flags;
379
+ };
380
+
381
+
382
+ /**
383
+ @brief Open an SDF file and return a file handle.
384
+
385
+ This routine attempts to open the given filename as an SDF file.
386
+
387
+ @param[in] filename Name of the SDF file to open
388
+ @param[in] comm MPI communicator to use
389
+ @param[in] mode File mode
390
+ @param[in] use_mmap Flag which specifies wether mmap should be used
391
+
392
+ @return SDF filehandle on success, NULL on error
393
+
394
+ Example usage:
395
+ @code
396
+ sdf_file_t *h = sdf_open("myfile.sdf", MPI_COMM_WORLD, SDF_READ, 0);
397
+ @endcode
398
+ */
399
+ sdf_file_t *sdf_open(const char *filename, comm_t comm, int mode, int use_mmap);
400
+
401
+
402
+ /**
403
+ @brief Close an SDF file and free the filehandle
404
+
405
+ This routine closes the SDF file associated with this file handle
406
+ and frees the file handle along with all associated data.
407
+
408
+ @param[in] h SDF file handle
409
+
410
+ @return 0 on success, 1 on error
411
+ */
412
+ int sdf_close(sdf_file_t *h);
413
+
414
+
415
+ /**
416
+ @brief Free all data blocks in the blocklist.
417
+
418
+ This routine cycles through the blocklist and frees any data blocks that
419
+ have been allocated, whilst leaving the metadata intact.
420
+
421
+ @param[in] h SDF file handle
422
+
423
+ @return 0 on success, 1 on error
424
+ */
425
+ int sdf_free_blocklist_data(sdf_file_t *h);
426
+
427
+
428
+ /**
429
+ @brief Find a block with the given ID
430
+
431
+ This function finds a block in file's blocklist whose ID field matches the
432
+ one given.
433
+
434
+ @param[in] h SDF file handle
435
+ @param[in] id ID of the block to find
436
+
437
+ @return Pointer to SDF block on success, NULL on error
438
+ */
439
+ sdf_block_t *sdf_find_block_by_id(sdf_file_t *h, const char *id);
440
+
441
+
442
+ /**
443
+ @brief Find a block with the given name
444
+
445
+ This function finds a block in file's blocklist whose name matches the
446
+ one given.
447
+
448
+ @param[in] h SDF file handle
449
+ @param[in] name Name of the block to find
450
+
451
+ @return Pointer to SDF block on success, NULL on error
452
+ */
453
+ sdf_block_t *sdf_find_block_by_name(sdf_file_t *h, const char *name);
454
+
455
+
456
+ /**
457
+ @ingroup input
458
+ @{
459
+ @brief Read the header of an SDF file
460
+
461
+ The sdf_open reads just enough information to check that the file is a
462
+ valid SDF file. This routine populates information about the file such as
463
+ the number of blocks, etc.
464
+ This information is required in order to read the rest of the file's contents.
465
+
466
+ @param[in] h SDF file handle
467
+
468
+ @return 0 on success, 1 on error
469
+ */
470
+ int sdf_read_header(sdf_file_t *h);
471
+
472
+
473
+ /**
474
+ @brief Read the summary section of an SDF file
475
+
476
+ This routine reads the entire summary section of an SDF file into a buffer.
477
+ No parsing is done. If the file does not contain a summary section then the
478
+ buffer is populated by reading the inline metadata blocks.
479
+
480
+ @param[in] h SDF file handle
481
+
482
+ @return 0 on success, 1 on error
483
+ */
484
+ int sdf_read_summary(sdf_file_t *h);
485
+
486
+
487
+ /**
488
+ @brief Reads the metadata contents of the SDF file and populates a blocklist
489
+
490
+ This routine reads the summary from an SDF file and then parses each of
491
+ the metadata blocks. It builds a linked list of SDF block structures which
492
+ contains the metadata information.
493
+
494
+ @param[in] h SDF file handle
495
+
496
+ @return 0 on success, 1 on error
497
+ */
498
+ int sdf_read_blocklist(sdf_file_t *h);
499
+
500
+
501
+ /**
502
+ @brief Reads the metadata contents of the SDF file and populates a blocklist
503
+ containing both file contents and any derived blocks.
504
+
505
+ This routine reads the summary from an SDF file and then parses each of
506
+ the metadata blocks. It builds a linked list of SDF block structures which
507
+ contains the metadata information.
508
+ In addition, any derived variables which can be calculated based on the files
509
+ contents are added to the blocklist.
510
+
511
+ @param[in] h SDF file handle
512
+
513
+ @return 0 on success, 1 on error
514
+ */
515
+ int sdf_read_blocklist_all(sdf_file_t *h);
516
+
517
+
518
+ /**
519
+ @brief Reads the metadata for a single block in the SDF file
520
+
521
+ This routine reads and parses the metadata for the current block pointer.
522
+
523
+ @param[in] h SDF file handle
524
+
525
+ @return 0 on success, 1 on error
526
+ */
527
+ int sdf_read_block_info(sdf_file_t *h);
528
+
529
+
530
+ /**
531
+ @brief Reads the data for a single block in the SDF file
532
+
533
+ This routine reads the data block for the current block pointer.
534
+
535
+ @param[in] h SDF file handle
536
+
537
+ @return 0 on success, 1 on error
538
+ */
539
+ int sdf_read_data(sdf_file_t *h);
540
+ /**@}*/
541
+
542
+
543
+ /**
544
+ @brief Returns the bounds for the current parallel domain decomposition.
545
+
546
+ @param[in] h SDF file handle
547
+ @param[in] rank The processor rank to return the extents for
548
+ @param[out] starts The starting index within the global domain for each
549
+ dimension.
550
+ @param[out] local_dims The length of the local domain in each dimension.
551
+
552
+ @return 0 on success, 1 on error
553
+ */
554
+ int sdf_get_domain_bounds(sdf_file_t *h, int rank,
555
+ int *starts, int *local_dims);
556
+
557
+
558
+ /**
559
+ @brief Modify an array in-place.
560
+
561
+ This function modifies an entire array in-place.
562
+
563
+ @param[in] h SDF file handle
564
+ @param[in] b SDF block on which to act
565
+ @param[in] data Supplied data array
566
+
567
+ @return 0 on success, 1 on error
568
+ */
569
+ int sdf_modify_array(sdf_file_t *h, sdf_block_t *b, void *data);
570
+
571
+
572
+ /**
573
+ @brief Modify an array slice in-place.
574
+
575
+ This function allows an array to be modified in-place.
576
+
577
+ @param[in] h SDF file handle
578
+ @param[in] b SDF block on which to act
579
+ @param[in] data Supplied data array
580
+ @param[in] starts Array of starts
581
+ @param[in] ends Array of ends
582
+
583
+ @return 0 on success, 1 on error
584
+
585
+ Example usage:
586
+ @code
587
+ memcpy(starts, b->dims, sizeof(*starts));
588
+ memcpy(ends, b->dims, sizeof(*ends));
589
+ starts[2] = 3;
590
+ ends[2] = 4;
591
+ sdf_modify_array_section(h, b, data, starts, ends);
592
+ @endcode
593
+ */
594
+ int sdf_modify_array_section(sdf_file_t *h, sdf_block_t *b, void *data,
595
+ int64_t *starts, int64_t *ends);
596
+
597
+
598
+ /**
599
+ @brief Modify an array element in-place.
600
+
601
+ This function modifies a single element of an array in-place.
602
+
603
+ @param[in] h SDF file handle
604
+ @param[in] b SDF block on which to act
605
+ @param[in] data Supplied data array
606
+ @param[in] index Array containing the element index
607
+
608
+ @return 0 on success, 1 on error
609
+
610
+ Example usage:
611
+ @code
612
+ double value = 2;
613
+ int64_t index[] = {1,2,3};
614
+ sdf_modify_array_element(h, b, &value, index);
615
+ @endcode
616
+ */
617
+ int sdf_modify_array_element(sdf_file_t *h, sdf_block_t *b, void *data,
618
+ int64_t *index);
619
+
620
+
621
+ /**
622
+ @brief Add a block in-place.
623
+
624
+ This function adds the specified block to the SDF file.
625
+ The block is appended to the end of both the file and blocklist and the
626
+ SDF file headers are updated in-place.
627
+
628
+ @param[in] h SDF file handle
629
+ @param[in] block The block to add to the file
630
+
631
+ @return 0 on success, 1 on error
632
+ */
633
+ int sdf_modify_add_block(sdf_file_t *h, sdf_block_t *block);
634
+
635
+
636
+ /**
637
+ @brief Add the copy of a block in-place.
638
+
639
+ This function copies the specified block and adds it to the SDF file.
640
+ The block copy is appended to the end of both the file and blocklist and the
641
+ SDF file headers are updated in-place.
642
+
643
+ @param[in] h SDF file handle
644
+ @param[in] block The block to copy and add to the file
645
+
646
+ @return 0 on success, 1 on error
647
+ */
648
+ int sdf_modify_add_block_copy(sdf_file_t *h, sdf_block_t *block);
649
+
650
+
651
+ /**
652
+ @brief Remove a block in-place.
653
+
654
+ This function removes a block from an SDF file.
655
+ The block's associated pointers are removed and deallocated and the SDF
656
+ file headers are updated in-place.
657
+
658
+ @param[in] h SDF file handle
659
+ @param[in] block The block to remove from the file
660
+
661
+ @return 0 on success, 1 on error
662
+ */
663
+ int sdf_modify_remove_block(sdf_file_t *h, sdf_block_t *block);
664
+
665
+
666
+ /**
667
+ @brief Remove a block in-place by ID.
668
+
669
+ This function removes a block from an SDF file.
670
+ The block's associated pointers are removed and deallocated and the SDF
671
+ file headers are updated in-place.
672
+
673
+ @param[in] h SDF file handle
674
+ @param[in] id The ID string for the block to remove
675
+
676
+ @return 0 on success, 1 on error
677
+ */
678
+ int sdf_modify_remove_block_id(sdf_file_t *h, const char *id);
679
+
680
+
681
+ /**
682
+ @brief Remove a block in-place by name.
683
+
684
+ This function removes a block from an SDF file.
685
+ The block's associated pointers are removed and deallocated and the SDF
686
+ file headers are updated in-place.
687
+
688
+ @param[in] h SDF file handle
689
+ @param[in] name The name of the block to remove
690
+
691
+ @return 0 on success, 1 on error
692
+ */
693
+ int sdf_modify_remove_block_name(sdf_file_t *h, const char *name);
694
+
695
+
696
+ /**
697
+ @brief Add a single material in-place.
698
+
699
+ This function adds a single material to a stitched block.
700
+ The block pointer for the material is added to the blocklist
701
+ and the SDF file headers are updated in-place.
702
+
703
+ @param[in] h SDF file handle
704
+ @param[in] stitched The stitched material block to remove the material from
705
+ @param[in] material The material to remove
706
+
707
+ @return 0 on success, 1 on error
708
+ */
709
+ int sdf_modify_add_material(sdf_file_t *h, sdf_block_t *stitched,
710
+ sdf_block_t *material);
711
+
712
+
713
+ /**
714
+ @brief Remove a single material in-place.
715
+
716
+ This function removes a single material from a stitched block.
717
+ The material's associated block pointers are removed and deallocated
718
+ and the SDF file headers are updated in-place.
719
+
720
+ @param[in] h SDF file handle
721
+ @param[in] stitched The stitched material block to remove the material from
722
+ @param[in] material The material to remove
723
+
724
+ @return 0 on success, 1 on error
725
+ */
726
+ int sdf_modify_remove_material(sdf_file_t *h, sdf_block_t *stitched,
727
+ sdf_block_t *material);
728
+
729
+
730
+ /**
731
+ @brief Rewrites the metadata for the file.
732
+
733
+ The sdf_modify_* routines merely update the blocklist for the file and do
734
+ not actually perform any changes on the file itself. This routine runs through
735
+ the blocklist and updates the metadata in the file where necessary.
736
+
737
+ @param[in] h SDF file handle
738
+
739
+ @return 0 on success, 1 on error
740
+ */
741
+ int sdf_modify_rewrite_metadata(sdf_file_t *h);
742
+
743
+
744
+ /**
745
+ @brief Set the array section to use for a block.
746
+
747
+ This routine sets up parameters for a block so that only a subsection of
748
+ the total array is read into the data block.
749
+
750
+ @param[in] b SDF block on which to act
751
+ @param[in] ndims Size of starts, ends and strides arrays
752
+ @param[in] starts Array of start indices
753
+ @param[in] ends Array of end indices
754
+ @param[in] strides Array of strides
755
+
756
+ @return 0 on success, 1 on error
757
+ */
758
+ int sdf_block_set_array_section(sdf_block_t *b, const int ndims,
759
+ const int64_t *starts, const int64_t *ends,
760
+ const int64_t *strides);
761
+
762
+
763
+ /**
764
+ @brief Reads time history data from a station block.
765
+ */
766
+ int sdf_read_station_timehis(sdf_file_t *h, long *stat, int nstat,
767
+ char **var_names, int nvars, double t0, double t1, char **timehis,
768
+ int *size, int *offset, int *nrows, int *row_size);
769
+
770
+
771
+ /**
772
+ @brief Returns string containing the commit id for the library
773
+ */
774
+ char *sdf_get_library_commit_id(void);
775
+
776
+
777
+ /**
778
+ @brief Returns string containing the commit date for the library
779
+ */
780
+ char *sdf_get_library_commit_date(void);
781
+
782
+
783
+ /**
784
+ @brief Returns 1 if compiled with SDF_DEBUG and 0 otherwise
785
+ */
786
+ int sdf_has_debug_info(void);
787
+
788
+
789
+ /**
790
+ @brief Get string with the name and version of any loaded extension modules
791
+ */
792
+ char *sdf_extension_get_info_string(sdf_file_t *h, char const *prefix);
793
+
794
+
795
+ /**
796
+ @brief Prints the name and version of any loaded extension modules
797
+ */
798
+ void sdf_extension_print_version(sdf_file_t *h);
799
+
800
+ #ifdef __cplusplus
801
+ }
802
+ #endif
803
+
804
+ #endif