SDDSlib
Loading...
Searching...
No Matches
sdds3daverage.c
Go to the documentation of this file.
1/**
2 * @file sdds3daverage.c
3 * @brief Averages 3D Vorpal output data, filtering and processing Rho and Jz components.
4 *
5 * ### Overview
6 * This program processes 3D Vorpal simulation outputs containing data for Rho and Jz
7 * components in a grid layout. It computes averages over z, y, and Jz for each x-coordinate,
8 * allowing for filtering of data ranges in x, y, and z dimensions.
9 *
10 * ### Input and Output
11 * - Input: 3D Vorpal output in SDDS format, with multiple pages, rows, and columns.
12 * - Output: Processed averages saved as a new SDDS file.
13 *
14 * ### Functionality
15 * - Reads Rho and Jz data columns for each grid coordinate.
16 * - Filters x, y, and z ranges based on user-provided options.
17 * - Computes weighted averages of z, y, and Jz components over Rho values.
18 * - Outputs processed data to a file with x, ZAve, YAve, and JzAve columns.
19 *
20 * ### Usage
21 * ```
22 * sdds3daverage <inputFile> [<outputRoot>] [OPTIONS]
23 *
24 * Options:
25 * -power=<integer> Set the power for averaging.
26 * -xfilter=minimum=<value>,maximum=<value> Filter x values within the specified range.
27 * -yfilter=minimum=<value>,maximum=<value> Filter y values within the specified range.
28 * -zfilter=minimum=<value>,maximum=<value> Filter z values within the specified range.
29 *
30 * Example:
31 * sdds3daverage data.sdds outputRoot -power=2 -xfilter=minimum=0.1,maximum=1.0
32 * ```
33 *
34 * @copyright
35 * - (c) 2002 The University of Chicago, as Operator of Argonne National Laboratory.
36 * - (c) 2002 The Regents of the University of California, as Operator of Los Alamos National Laboratory.
37 *
38 * @license
39 * This file is distributed under the terms of the Software License Agreement
40 * found in the file LICENSE included with this distribution.
41 *
42 * @author H. Shang, R. Soliday
43 */
44
45#include "mdb.h"
46#include "SDDS.h"
47#include "scan.h"
48
49/* Enumeration for option types */
50enum option_type {
51 SET_POWER,
52 SET_XFILTER,
53 SET_YFILTER,
54 SET_ZFILTER,
55 N_OPTIONS
56};
57
58char *option[N_OPTIONS] = {
59 "power",
60 "xfilter",
61 "yfilter",
62 "zfilter",
63};
64
65char *USAGE =
66 "Usage: sdds3daverage <inputFile> [<outputRoot>] [OPTIONS]\n"
67 "\n"
68 "Options:\n"
69 " -power=<integer> Set the power for averaging.\n"
70 " -xfilter=minimum=<value>,maximum=<value> Filter x values within the specified range.\n"
71 " -yfilter=minimum=<value>,maximum=<value> Filter y values within the specified range.\n"
72 " -zfilter=minimum=<value>,maximum=<value> Filter z values within the specified range.\n"
73 "\n"
74 "Example:\n"
75 " sdds3daverage data.sdds outputRoot -power=2 -xfilter=minimum=0.1,maximum=1.0\n"
76 "\n"
77 "Link date: " __DATE__ " " __TIME__ ", SVN revision: " SVN_VERSION "\n";
78
79void SetupOutputFile(SDDS_DATASET *SDDS_out, char *output, long zdim);
80void free_data_memory(double ***data, long zdim, long ydim);
81
82int main(int argc, char **argv) {
83 SDDS_DATASET SDDS_orig, SDDS_out;
84 int32_t i, j, k, i_arg, rows, xfilter_provided, yfilter_provided, zfilter_provided, row;
85 long power = 1;
86 SCANNED_ARG *s_arg;
87 char *inputFile, *outputRoot, output[1024], tmpcol[256];
88 double xmin, xmax, ymin, ymax, zmin, zmax, xinterval, yinterval, zinterval;
89 int32_t xdim, ydim, zdim, columnNames, outputColumns, page = 0;
90 char **columnName, **outputColumn;
91 double ***Rho, ***Jz, rhoSum, rhoSum1, yRho, zRho, jzRho;
92 double x_min, x_max, y_min, y_max, z_min, z_max, x, y, z;
93 unsigned long dummyFlags = 0;
94
95 x_min = x_max = y_min = y_max = z_min = z_max = 0;
96 xfilter_provided = yfilter_provided = zfilter_provided = 0;
97
98 inputFile = outputRoot = NULL;
100 argc = scanargs(&s_arg, argc, argv);
101 if (argc < 2) {
102 fprintf(stderr, "Error: Insufficient arguments.\n\n%s", USAGE);
103 exit(EXIT_FAILURE);
104 }
105
106 columnNames = outputColumns = 0;
107 columnName = outputColumn = NULL;
108 Rho = Jz = NULL;
109
110 for (i_arg = 1; i_arg < argc; i_arg++) {
111 if (s_arg[i_arg].arg_type == OPTION) {
112 delete_chars(s_arg[i_arg].list[0], "_");
113 switch (match_string(s_arg[i_arg].list[0], option, N_OPTIONS, 0)) {
114 case SET_POWER:
115 if (s_arg[i_arg].n_items != 2) {
116 SDDS_Bomb("Invalid -power syntax.");
117 }
118 if (!get_long(&power, s_arg[i_arg].list[1])) {
119 SDDS_Bomb("Invalid -power value provided.");
120 }
121 break;
122
123 case SET_XFILTER:
124 if (s_arg[i_arg].n_items < 2) {
125 SDDS_Bomb("Invalid -xfilter syntax.");
126 }
127 s_arg[i_arg].n_items--;
128 if (!scanItemList(&dummyFlags, s_arg[i_arg].list + 1, &s_arg[i_arg].n_items, 0,
129 "minimum", SDDS_DOUBLE, &x_min, 1, 0,
130 "maximum", SDDS_DOUBLE, &x_max, 1, 0,
131 NULL)) {
132 SDDS_Bomb("Invalid -xfilter syntax.");
133 }
134 s_arg[i_arg].n_items++;
135 if (x_max <= x_min) {
136 fprintf(stderr, "Error: Invalid -xfilter provided, x_max <= x_min.\n");
137 exit(EXIT_FAILURE);
138 }
139 xfilter_provided = 1;
140 break;
141
142 case SET_YFILTER:
143 if (s_arg[i_arg].n_items < 2) {
144 SDDS_Bomb("Invalid -yfilter syntax.");
145 }
146 s_arg[i_arg].n_items--;
147 if (!scanItemList(&dummyFlags, s_arg[i_arg].list + 1, &s_arg[i_arg].n_items, 0,
148 "minimum", SDDS_DOUBLE, &y_min, 1, 0,
149 "maximum", SDDS_DOUBLE, &y_max, 1, 0,
150 NULL)) {
151 SDDS_Bomb("Invalid -yfilter syntax.");
152 }
153 s_arg[i_arg].n_items++;
154 if (y_max <= y_min) {
155 fprintf(stderr, "Error: Invalid -yfilter provided, y_max <= y_min.\n");
156 exit(EXIT_FAILURE);
157 }
158 yfilter_provided = 1;
159 break;
160
161 case SET_ZFILTER:
162 if (s_arg[i_arg].n_items < 2) {
163 SDDS_Bomb("Invalid -zfilter syntax.");
164 }
165 s_arg[i_arg].n_items--;
166 if (!scanItemList(&dummyFlags, s_arg[i_arg].list + 1, &s_arg[i_arg].n_items, 0,
167 "minimum", SDDS_DOUBLE, &z_min, 1, 0,
168 "maximum", SDDS_DOUBLE, &z_max, 1, 0,
169 NULL)) {
170 SDDS_Bomb("Invalid -zfilter syntax.");
171 }
172 s_arg[i_arg].n_items++;
173 if (z_max <= z_min) {
174 fprintf(stderr, "Error: Invalid -zfilter provided, z_max <= z_min.\n");
175 exit(EXIT_FAILURE);
176 }
177 zfilter_provided = 1;
178 break;
179
180 default:
181 fprintf(stderr, "Error: Unknown option -%s provided.\n", s_arg[i_arg].list[0]);
182 exit(EXIT_FAILURE);
183 }
184 } else {
185 if (!inputFile) {
186 inputFile = s_arg[i_arg].list[0];
187 } else if (!outputRoot) {
188 outputRoot = s_arg[i_arg].list[0];
189 } else {
190 SDDS_Bomb("Error: Too many file names provided.");
191 }
192 }
193 }
194
195 if (!outputRoot) {
196 outputRoot = inputFile;
197 }
198
199 snprintf(output, sizeof(output), "%s.ave", outputRoot);
200
201 if (!SDDS_InitializeInput(&SDDS_orig, inputFile)) {
202 SDDS_PrintErrors(stderr, SDDS_VERBOSE_PrintErrors);
203 exit(EXIT_FAILURE);
204 }
205
206 xdim = ydim = zdim = 1;
207 zmin = zmax = zinterval = 0;
208 while (SDDS_ReadPage(&SDDS_orig) > 0) {
209 if (page == 0) {
210 if (!SDDS_GetParameterAsDouble(&SDDS_orig, "origin1", &xmin) ||
211 !SDDS_GetParameterAsDouble(&SDDS_orig, "max_ext1", &xmax) ||
212 !SDDS_GetParameterAsDouble(&SDDS_orig, "delta1", &xinterval) ||
213 !SDDS_GetParameterAsLong(&SDDS_orig, "numPhysCells1", &xdim) ||
214 !SDDS_GetParameterAsDouble(&SDDS_orig, "origin2", &ymin) ||
215 !SDDS_GetParameterAsDouble(&SDDS_orig, "max_ext2", &ymax) ||
216 !SDDS_GetParameterAsDouble(&SDDS_orig, "delta2", &yinterval) ||
217 !SDDS_GetParameterAsLong(&SDDS_orig, "numPhysCells2", &ydim)) {
218 SDDS_PrintErrors(stderr, SDDS_VERBOSE_PrintErrors);
219 exit(EXIT_FAILURE);
220 }
221
222 if (SDDS_CheckParameter(&SDDS_orig, "origin3", NULL, SDDS_ANY_NUMERIC_TYPE, NULL) == SDDS_CHECK_OK) {
223 if (!SDDS_GetParameterAsDouble(&SDDS_orig, "origin3", &zmin) ||
224 !SDDS_GetParameterAsDouble(&SDDS_orig, "max_ext3", &zmax) ||
225 !SDDS_GetParameterAsDouble(&SDDS_orig, "delta3", &zinterval) ||
226 !SDDS_GetParameterAsLong(&SDDS_orig, "numPhysCells3", &zdim)) {
227 SDDS_PrintErrors(stderr, SDDS_VERBOSE_PrintErrors);
228 exit(EXIT_FAILURE);
229 }
230 }
231
232 if (xfilter_provided) {
233 if (x_min > xmax || x_max < xmin) {
234 fprintf(stderr, "Error: Invalid xfilter provided, it should be between %le and %le.\n", xmin, xmax);
235 if (!SDDS_Terminate(&SDDS_orig))
236 SDDS_PrintErrors(stderr, SDDS_VERBOSE_PrintErrors | SDDS_EXIT_PrintErrors);
237 exit(EXIT_FAILURE);
238 }
239 } else {
240 x_min = xmin;
241 x_max = xmax;
242 }
243
244 if (yfilter_provided) {
245 if (y_min > ymax || y_max < ymin) {
246 fprintf(stderr, "Error: Invalid yfilter provided, it should be between %le and %le.\n", ymin, ymax);
247 if (!SDDS_Terminate(&SDDS_orig))
248 SDDS_PrintErrors(stderr, SDDS_VERBOSE_PrintErrors | SDDS_EXIT_PrintErrors);
249 exit(EXIT_FAILURE);
250 }
251 } else {
252 y_min = ymin;
253 y_max = ymax;
254 }
255
256 if (zfilter_provided && zdim > 1) {
257 if (z_min > zmax || z_max < zmin) {
258 fprintf(stderr, "Error: Invalid zfilter provided, it should be between %le and %le.\n", zmin, zmax);
259 if (!SDDS_Terminate(&SDDS_orig))
260 SDDS_PrintErrors(stderr, SDDS_VERBOSE_PrintErrors | SDDS_EXIT_PrintErrors);
261 exit(EXIT_FAILURE);
262 }
263 } else {
264 z_min = zmin;
265 z_max = zmax;
266 }
267
268 Rho = malloc(sizeof(*Rho) * zdim);
269 if (!Rho) {
270 fprintf(stderr, "Error: Memory allocation failed for Rho.\n");
271 exit(EXIT_FAILURE);
272 }
273
274 Jz = malloc(sizeof(*Jz) * zdim);
275 if (!Jz) {
276 free_data_memory(Rho, zdim, ydim);
277 fprintf(stderr, "Error: Memory allocation failed for Jz.\n");
278 exit(EXIT_FAILURE);
279 }
280
281 for (i = 0; i < zdim; i++) {
282 Rho[i] = malloc(sizeof(**Rho) * ydim);
283 if (!Rho[i]) {
284 free_data_memory(Rho, zdim, ydim);
285 free_data_memory(Jz, zdim, ydim);
286 fprintf(stderr, "Error: Memory allocation failed for Rho[%d].\n", i);
287 exit(EXIT_FAILURE);
288 }
289
290 Jz[i] = malloc(sizeof(**Jz) * ydim);
291 if (!Jz[i]) {
292 free_data_memory(Rho, zdim, ydim);
293 free_data_memory(Jz, zdim, ydim);
294 fprintf(stderr, "Error: Memory allocation failed for Jz[%d].\n", i);
295 exit(EXIT_FAILURE);
296 }
297 }
298
299 SetupOutputFile(&SDDS_out, output, zdim);
300 }
301
302 rows = SDDS_CountRowsOfInterest(&SDDS_orig);
303 if (rows != xdim) {
304 fprintf(stderr, "Error: Row number does not equal xdim size.\n");
305 exit(EXIT_FAILURE);
306 }
307
308 for (j = 1; j <= ydim; j++) {
309 snprintf(tmpcol, sizeof(tmpcol), "Rho_%d", j);
310 Rho[page][j - 1] = NULL;
311 if (!(Rho[page][j - 1] = SDDS_GetColumnInDoubles(&SDDS_orig, tmpcol))) {
312 SDDS_PrintErrors(stderr, SDDS_VERBOSE_PrintErrors | SDDS_EXIT_PrintErrors);
313 }
314
315 snprintf(tmpcol, sizeof(tmpcol), "Jz_%d", j);
316 Jz[page][j - 1] = NULL;
317 if (!(Jz[page][j - 1] = SDDS_GetColumnInDoubles(&SDDS_orig, tmpcol))) {
318 SDDS_PrintErrors(stderr, SDDS_VERBOSE_PrintErrors | SDDS_EXIT_PrintErrors);
319 }
320 }
321
322 page++;
323 }
324
325 if (!SDDS_Terminate(&SDDS_orig)) {
326 SDDS_PrintErrors(stderr, SDDS_VERBOSE_PrintErrors);
327 exit(EXIT_FAILURE);
328 }
329
330 if (page != zdim) {
331 free_data_memory(Rho, zdim, ydim);
332 free_data_memory(Jz, zdim, ydim);
333 fprintf(stderr, "Error: The page number does not equal the zdim size.\n");
334 exit(EXIT_FAILURE);
335 }
336
337 if (!SDDS_StartPage(&SDDS_out, xdim) ||
338 !SDDS_SetParameters(&SDDS_out, SDDS_SET_BY_NAME | SDDS_PASS_BY_VALUE,
339 "origin1", xmin,
340 "origin2", ymin,
341 "origin3", zmin,
342 "max_ext1", xmax,
343 "max_ext2", ymax,
344 "delta1", xinterval,
345 "delta2", yinterval,
346 "numPhysCells1", xdim,
347 "numPhysCells2", ydim,
348 "xstart", x_min,
349 "xend", x_max,
350 "ystart", y_min,
351 "yend", y_max,
352 NULL)) {
353 SDDS_PrintErrors(stderr, SDDS_VERBOSE_PrintErrors | SDDS_EXIT_PrintErrors);
354 }
355
356 if (zdim > 1) {
357 if (!SDDS_SetParameters(&SDDS_out, SDDS_SET_BY_NAME | SDDS_PASS_BY_VALUE,
358 "origin3", zmin,
359 "max_ext3", zmax,
360 "delta3", zinterval,
361 "numPhysCells3", zdim,
362 "zstart", z_min,
363 "zend", z_max,
364 NULL)) {
365 SDDS_PrintErrors(stderr, SDDS_VERBOSE_PrintErrors | SDDS_EXIT_PrintErrors);
366 }
367 }
368
369 row = 0;
370 for (i = 0; i < xdim; i++) {
371 rhoSum = rhoSum1 = 0;
372 yRho = zRho = jzRho = 0;
373 x = i * xinterval + xmin;
374
375 if (xfilter_provided && (x < x_min || x > x_max)) {
376 continue;
377 }
378
379 for (j = 0; j < ydim; j++) {
380 y = j * yinterval + ymin;
381
382 if (yfilter_provided && (y < y_min || y > y_max)) {
383 continue;
384 }
385
386 for (k = 0; k < zdim; k++) {
387 z = k * zinterval + zmin;
388
389 if (zfilter_provided && zdim > 1 && (z < z_min || z > z_max)) {
390 continue;
391 }
392
393 if (power == 1) {
394 yRho += fabs(Rho[k][j][i]) * y;
395 zRho += fabs(Rho[k][j][i]) * z;
396 jzRho += Rho[k][j][i] * Jz[k][j][i];
397 rhoSum += fabs(Rho[k][j][i]);
398 rhoSum1 += Rho[k][j][i];
399 } else {
400 yRho += pow(fabs(Rho[k][j][i]), power) * y;
401 zRho += pow(fabs(Rho[k][j][i]), power) * z;
402 jzRho += pow(Rho[k][j][i] * Jz[k][j][i], power);
403 rhoSum += pow(fabs(Rho[k][j][i]), power);
404 rhoSum1 += pow(Rho[k][j][i], power);
405 }
406 }
407 }
408
409 /* Set row values */
410 if (!SDDS_SetRowValues(&SDDS_out, SDDS_SET_BY_NAME | SDDS_PASS_BY_VALUE, row,
411 "x", x,
412 "YAve", yRho / (rhoSum + 1.0e-20),
413 "JzAve", jzRho / (rhoSum1 + 1.0e-20),
414 NULL)) {
415 SDDS_PrintErrors(stderr, SDDS_VERBOSE_PrintErrors | SDDS_EXIT_PrintErrors);
416 }
417
418 if (zdim > 1) {
419 if (!SDDS_SetRowValues(&SDDS_out, SDDS_SET_BY_NAME | SDDS_PASS_BY_VALUE, row,
420 "ZAve", zRho / (rhoSum + 1.0e-20),
421 NULL)) {
422 SDDS_PrintErrors(stderr, SDDS_VERBOSE_PrintErrors | SDDS_EXIT_PrintErrors);
423 }
424 }
425
426 row++;
427 }
428
429 if (!SDDS_WritePage(&SDDS_out) || !SDDS_Terminate(&SDDS_out)) {
430 SDDS_PrintErrors(stderr, SDDS_VERBOSE_PrintErrors | SDDS_EXIT_PrintErrors);
431 }
432
433 free_data_memory(Rho, zdim, ydim);
434 free_data_memory(Jz, zdim, ydim);
435
436 return EXIT_SUCCESS;
437}
438
439void free_data_memory(double ***data, long zdim, long ydim) {
440 long i, j;
441 for (i = 0; i < zdim; i++) {
442 for (j = 0; j < ydim; j++) {
443 free(data[i][j]);
444 }
445 free(data[i]);
446 }
447 free(data);
448}
449
450void SetupOutputFile(SDDS_DATASET *SDDS_out, char *output, long zdim) {
451 if (!SDDS_InitializeOutput(SDDS_out, SDDS_BINARY, 0, NULL, NULL, output)) {
452 SDDS_PrintErrors(stderr, SDDS_VERBOSE_PrintErrors | SDDS_EXIT_PrintErrors);
453 }
454
455 if (!SDDS_DefineSimpleParameter(SDDS_out, "origin1", NULL, SDDS_DOUBLE) ||
456 !SDDS_DefineSimpleParameter(SDDS_out, "origin2", NULL, SDDS_DOUBLE) ||
457 !SDDS_DefineSimpleParameter(SDDS_out, "max_ext1", NULL, SDDS_DOUBLE) ||
458 !SDDS_DefineSimpleParameter(SDDS_out, "max_ext2", NULL, SDDS_DOUBLE) ||
459 !SDDS_DefineSimpleParameter(SDDS_out, "delta1", NULL, SDDS_DOUBLE) ||
460 !SDDS_DefineSimpleParameter(SDDS_out, "delta2", NULL, SDDS_DOUBLE) ||
461 !SDDS_DefineSimpleParameter(SDDS_out, "numPhysCells1", NULL, SDDS_LONG) ||
462 !SDDS_DefineSimpleParameter(SDDS_out, "numPhysCells2", NULL, SDDS_LONG) ||
463 !SDDS_DefineSimpleParameter(SDDS_out, "xstart", NULL, SDDS_DOUBLE) ||
464 !SDDS_DefineSimpleParameter(SDDS_out, "xend", NULL, SDDS_DOUBLE) ||
465 !SDDS_DefineSimpleParameter(SDDS_out, "ystart", NULL, SDDS_DOUBLE) ||
466 !SDDS_DefineSimpleParameter(SDDS_out, "yend", NULL, SDDS_DOUBLE) ||
467 !SDDS_DefineSimpleColumn(SDDS_out, "x", NULL, SDDS_DOUBLE) ||
468 !SDDS_DefineSimpleColumn(SDDS_out, "YAve", NULL, SDDS_DOUBLE) ||
469 !SDDS_DefineSimpleColumn(SDDS_out, "JzAve", NULL, SDDS_DOUBLE)) {
470 SDDS_PrintErrors(stderr, SDDS_VERBOSE_PrintErrors | SDDS_EXIT_PrintErrors);
471 }
472
473 if (zdim > 1) {
474 if (!SDDS_DefineSimpleParameter(SDDS_out, "origin3", NULL, SDDS_DOUBLE) ||
475 !SDDS_DefineSimpleParameter(SDDS_out, "max_ext3", NULL, SDDS_DOUBLE) ||
476 !SDDS_DefineSimpleParameter(SDDS_out, "delta3", NULL, SDDS_DOUBLE) ||
477 !SDDS_DefineSimpleParameter(SDDS_out, "numPhysCells3", NULL, SDDS_LONG) ||
478 !SDDS_DefineSimpleParameter(SDDS_out, "zstart", NULL, SDDS_DOUBLE) ||
479 !SDDS_DefineSimpleParameter(SDDS_out, "zend", NULL, SDDS_DOUBLE) ||
480 !SDDS_DefineSimpleColumn(SDDS_out, "ZAve", NULL, SDDS_DOUBLE)) {
481 SDDS_PrintErrors(stderr, SDDS_VERBOSE_PrintErrors | SDDS_EXIT_PrintErrors);
482 }
483 }
484
485 if (!SDDS_WriteLayout(SDDS_out)) {
486 SDDS_PrintErrors(stderr, SDDS_VERBOSE_PrintErrors | SDDS_EXIT_PrintErrors);
487 }
488}
SDDS (Self Describing Data Set) Data Types Definitions and Function Prototypes.
int32_t SDDS_SetRowValues(SDDS_DATASET *SDDS_dataset, int32_t mode, int64_t row,...)
int32_t SDDS_StartPage(SDDS_DATASET *SDDS_dataset, int64_t expected_n_rows)
int32_t SDDS_SetParameters(SDDS_DATASET *SDDS_dataset, int32_t mode,...)
int32_t * SDDS_GetParameterAsLong(SDDS_DATASET *SDDS_dataset, char *parameter_name, int32_t *memory)
Retrieves the value of a specified parameter as a 32-bit integer from the current data table of a dat...
double * SDDS_GetParameterAsDouble(SDDS_DATASET *SDDS_dataset, char *parameter_name, double *memory)
Retrieves the value of a specified parameter as a double from the current data table of an SDDS datas...
int64_t SDDS_CountRowsOfInterest(SDDS_DATASET *SDDS_dataset)
Counts the number of rows marked as "of interest" in the current data table.
double * SDDS_GetColumnInDoubles(SDDS_DATASET *SDDS_dataset, char *column_name)
Retrieves the data of a specified numerical column as an array of doubles, considering only rows mark...
int32_t SDDS_InitializeInput(SDDS_DATASET *SDDS_dataset, char *filename)
Definition SDDS_input.c:49
int32_t SDDS_Terminate(SDDS_DATASET *SDDS_dataset)
int32_t SDDS_ReadPage(SDDS_DATASET *SDDS_dataset)
int32_t SDDS_InitializeOutput(SDDS_DATASET *SDDS_dataset, int32_t data_mode, int32_t lines_per_row, const char *description, const char *contents, const char *filename)
Initializes the SDDS output dataset.
int32_t SDDS_DefineSimpleColumn(SDDS_DATASET *SDDS_dataset, const char *name, const char *unit, int32_t type)
Defines a simple data column within the SDDS dataset.
int32_t SDDS_DefineSimpleParameter(SDDS_DATASET *SDDS_dataset, const char *name, const char *unit, int32_t type)
Defines a simple data parameter within the SDDS dataset.
int32_t SDDS_WritePage(SDDS_DATASET *SDDS_dataset)
Writes the current data table to the output file.
int32_t SDDS_WriteLayout(SDDS_DATASET *SDDS_dataset)
Writes the SDDS layout header to the output file.
void SDDS_PrintErrors(FILE *fp, int32_t mode)
Prints recorded error messages to a specified file stream.
Definition SDDS_utils.c:432
void SDDS_RegisterProgramName(const char *name)
Registers the executable program name for use in error messages.
Definition SDDS_utils.c:288
void SDDS_Bomb(char *message)
Terminates the program after printing an error message and recorded errors.
Definition SDDS_utils.c:342
int32_t SDDS_CheckParameter(SDDS_DATASET *SDDS_dataset, char *name, char *units, int32_t type, FILE *fp_message)
Checks if a parameter exists in the SDDS dataset with the specified name, units, and type.
#define SDDS_LONG
Identifier for the signed 32-bit integer data type.
Definition SDDStypes.h:61
#define SDDS_ANY_NUMERIC_TYPE
Special identifier used by SDDS_Check*() routines to accept any numeric type.
Definition SDDStypes.h:157
#define SDDS_DOUBLE
Identifier for the double data type.
Definition SDDStypes.h:37
int get_long(long *iptr, char *s)
Parses a long integer value from the given string.
Definition data_scan.c:255
char * delete_chars(char *s, char *t)
Removes all occurrences of characters found in string t from string s.
long match_string(char *string, char **option, long n_options, long mode)
Matches a given string against an array of option strings based on specified modes.
int scanargs(SCANNED_ARG **scanned, int argc, char **argv)
Definition scanargs.c:36
long scanItemList(unsigned long *flags, char **item, long *items, unsigned long mode,...)
Scans a list of items and assigns values based on provided keywords and types.