ASCOT5
Loading...
Searching...
No Matches
hdf5_interface.c
Go to the documentation of this file.
1
8#include <stdio.h>
9#include <stdlib.h>
10#include <string.h>
11#include <time.h>
12#include <hdf5.h>
13#include <hdf5_hl.h>
14#include "ascot5.h"
15#include "simulate.h"
16#include "print.h"
17#include "gitver.h"
18#include "compiler_flags.h"
19#include "hdf5_interface.h"
20#include "hdf5io/hdf5_helpers.h"
21#include "hdf5io/hdf5_options.h"
22#include "hdf5io/hdf5_bfield.h"
23#include "hdf5io/hdf5_plasma.h"
24#include "hdf5io/hdf5_neutral.h"
25#include "hdf5io/hdf5_efield.h"
26#include "hdf5io/hdf5_wall.h"
27#include "hdf5io/hdf5_boozer.h"
28#include "hdf5io/hdf5_mhd.h"
29#include "hdf5io/hdf5_marker.h"
30#include "hdf5io/hdf5_state.h"
31#include "hdf5io/hdf5_dist.h"
32#include "hdf5io/hdf5_orbit.h"
34#include "hdf5io/hdf5_asigma.h"
35#include "hdf5io/hdf5_nbi.h"
36
37int hdf5_get_active_qid(hid_t f, const char* group, char qid[11]);
38
52int hdf5_interface_read_input(sim_data* sim, int input_active,
53 input_particle** p, int* n_markers){
54
55 print_out(VERBOSE_IO, "\nReading and initializing input.\n");
56
57 /* This init disables automatic error messages.
58 * We want to generate our own that are more informative.*/
59 hdf5_init();
60
61 /* Check if requested HDF5 file exists and open it */
62 print_out(VERBOSE_IO, "\nInput file is %s.\n", sim->hdf5_in);
63 hid_t f = hdf5_open_ro(sim->hdf5_in);
64 if(f < 0) {
65 print_err("Error: File not found.");
66 return 1;
67 }
68
69 /* Read active input from hdf5 and initialize */
70 char qid[11];
71
72 if(input_active & hdf5_input_options) {
73 if(hdf5_find_group(f, "/options/")) {
74 print_err("Error: No options in input file.");
75 return 1;
76 }
77 print_out(VERBOSE_IO, "\nReading options input.\n");
78 if(sim->qid_options[0] != '\0') {
79 strcpy(qid, sim->qid_options);
80 }
81 else if( hdf5_get_active_qid(f, "/options/", qid) ) {
82 print_err("Error: Active QID not declared.");
83 return 1;
84 }
85 strcpy(sim->qid_options, qid);
86 print_out(VERBOSE_IO, "Active QID is %s\n", qid);
87 if( hdf5_options_read(f, sim, qid) ) {
88 print_err("Error: Failed to initialize options.\n");
89 return 1;
90 }
91 print_out(VERBOSE_IO, "Options read and initialized.\n");
92 }
93
94 if(input_active & hdf5_input_bfield) {
95 if(hdf5_find_group(f, "/bfield/")) {
96 print_err("Error: No magnetic field in input file.");
97 return 1;
98 }
99 print_out(VERBOSE_IO, "\nReading magnetic field input.\n");
100 if(sim->qid_bfield[0] != '\0') {
101 strcpy(qid, sim->qid_bfield);
102 }
103 else if( hdf5_get_active_qid(f, "/bfield/", qid) ) {
104 print_err("Error: Active QID not declared.");
105 return 1;
106 }
107 strcpy(sim->qid_bfield, qid);
108 print_out(VERBOSE_IO, "Active QID is %s\n", qid);
109 if( hdf5_bfield_init(f, &sim->B_data, qid) ) {
110 print_err("Error: Failed to initialize magnetic field.\n");
111 return 1;
112 }
113 print_out(VERBOSE_IO, "Magnetic field read and initialized.\n");
114 }
115
116 if(input_active & hdf5_input_efield) {
117 if(hdf5_find_group(f, "/efield/")) {
118 print_err("Error: No electric field in input file.");
119 return 1;
120 }
121 print_out(VERBOSE_IO, "\nReading electric field input.\n");
122 if(sim->qid_efield[0] != '\0') {
123 strcpy(qid, sim->qid_efield);
124 }
125 else if( hdf5_get_active_qid(f, "/efield/", qid) ) {
126 print_err("Error: Active QID not declared.");
127 return 1;
128 }
129 strcpy(sim->qid_efield, qid);
130 print_out(VERBOSE_IO, "Active QID is %s\n", qid);
131 if( hdf5_efield_init(f, &sim->E_data, qid) ) {
132 print_err("Error: Failed to initialize electric field.\n");
133 return 1;
134 }
135 print_out(VERBOSE_IO, "Electric field read and initialized.\n");
136 }
137
138 if(input_active & hdf5_input_plasma) {
139 if(hdf5_find_group(f, "/plasma/")) {
140 print_err("Error: No plasma data in input file.");
141 return 1;
142 }
143 print_out(VERBOSE_IO, "\nReading plasma input.\n");
144 if(sim->qid_plasma[0] != '\0') {
145 strcpy(qid, sim->qid_plasma);
146 }
147 else if( hdf5_get_active_qid(f, "/plasma/", qid) ) {
148 print_err("Error: Active QID not declared.");
149 return 1;
150 }
151 strcpy(sim->qid_plasma, qid);
152 print_out(VERBOSE_IO, "Active QID is %s\n", qid);
153 if( hdf5_plasma_init(f, &(sim->plasma_data), qid) ) {
154 print_err("Error: Failed to initialize plasma data.\n");
155 return 1;
156 }
157 print_out(VERBOSE_IO, "Plasma data read and initialized.\n");
158 }
159
160 if(input_active & hdf5_input_neutral) {
161 if(hdf5_find_group(f, "/neutral/")) {
162 print_err("Error: No neutral data in input file.");
163 return 1;
164 }
165 print_out(VERBOSE_IO, "\nReading neutral input.\n");
166 if(sim->qid_neutral[0] != '\0') {
167 strcpy(qid, sim->qid_neutral);
168 }
169 else if( hdf5_get_active_qid(f, "/neutral/", qid) ) {
170 print_err("Error: Active QID not declared.");
171 return 1;
172 }
173 strcpy(sim->qid_neutral, qid);
174 print_out(VERBOSE_IO, "Active QID is %s\n", qid);
175 if( hdf5_neutral_init(f, &sim->neutral_data, qid) ) {
176 print_err("Error: Failed to initialize neutral data.\n");
177 return 1;
178 }
179 print_out(VERBOSE_IO, "Neutral data read and initialized.\n");
180 }
181
182 if(input_active & hdf5_input_wall) {
183 if(hdf5_find_group(f, "/wall/")) {
184 print_err("Error: No wall data in input file.");
185 return 1;
186 }
187 print_out(VERBOSE_IO, "\nReading wall input.\n");
188 if(sim->qid_wall[0] != '\0') {
189 strcpy(qid, sim->qid_wall);
190 }
191 else if( hdf5_get_active_qid(f, "/wall/", qid) ) {
192 print_err("Error: Active QID not declared.");
193 return 1;
194 }
195 strcpy(sim->qid_wall, qid);
196 print_out(VERBOSE_IO, "Active QID is %s\n", qid);
197 if( hdf5_wall_init(f, &sim->wall_data, qid) ) {
198 print_err("Error: Failed to initialize wall.\n");
199 return 1;
200 }
201 print_out(VERBOSE_IO, "Wall data read and initialized.\n");
202 }
203
204 if(input_active & hdf5_input_boozer) {
205 if(hdf5_find_group(f, "/boozer/")) {
206 print_err("Error: No boozer data in input file.");
207 return 1;
208 }
209 print_out(VERBOSE_IO, "\nReading boozer input.\n");
210 if(sim->qid_boozer[0] != '\0') {
211 strcpy(qid, sim->qid_boozer);
212 }
213 else if( hdf5_get_active_qid(f, "/boozer/", qid) ) {
214 print_err("Error: Active QID not declared.");
215 return 1;
216 }
217 strcpy(sim->qid_boozer, qid);
218 print_out(VERBOSE_IO, "Active QID is %s\n", qid);
219 if( hdf5_boozer_init(f, &sim->boozer_data, qid) ) {
220 print_err("Error: Failed to read boozer input.\n");
221 return 1;
222 }
223 print_out(VERBOSE_IO, "Boozer data read and initialized.\n");
224 }
225
226 if(input_active & hdf5_input_mhd) {
227 if(hdf5_find_group(f, "/mhd/")) {
228 print_err("Error: No MHD data in input file.");
229 return 1;
230 }
231 print_out(VERBOSE_IO, "\nReading MHD input.\n");
232 if(sim->qid_mhd[0] != '\0') {
233 strcpy(qid, sim->qid_mhd);
234 }
235 else if( hdf5_get_active_qid(f, "/mhd/", qid) ) {
236 print_err("Error: Active QID not declared.");
237 return 1;
238 }
239 strcpy(sim->qid_mhd, qid);
240 print_out(VERBOSE_IO, "Active QID is %s\n", qid);
241 if( hdf5_mhd_init(f, &sim->mhd_data, qid) ) {
242 print_err("Error: Failed to read MHD input.\n");
243 return 1;
244 }
245 print_out(VERBOSE_IO, "MHD data read and initialized.\n");
246 }
247
248 if(input_active & hdf5_input_asigma) {
249 if(hdf5_find_group(f, "/asigma/")) {
250 print_err("Error: No atomic reaction data in input file.");
251 return 1;
252 }
253 print_out(VERBOSE_IO, "\nReading atomic reaction input.\n");
254 if(sim->qid_asigma[0] != '\0') {
255 strcpy(qid, sim->qid_asigma);
256 }
257 else if( hdf5_get_active_qid(f, "/asigma/", qid) ) {
258 print_err("Error: Active QID not declared.");
259 return 1;
260 }
261 strcpy(sim->qid_asigma, qid);
262 print_out(VERBOSE_IO, "Active QID is %s\n", qid);
263 if( hdf5_asigma_init(f, &sim->asigma_data, qid) ) {
264 print_err("Error: Failed to initialize atomic reaction data.\n");
265 return 1;
266 }
267 print_out(VERBOSE_IO, "Atomic reaction data read and initialized.\n");
268 }
269
270 if(input_active & hdf5_input_nbi) {
271 if(hdf5_find_group(f, "/nbi/")) {
272 print_err("Error: No NBI data in input file.");
273 return 1;
274 }
275 print_out(VERBOSE_IO, "\nReading NBI input.\n");
276 if(sim->qid_nbi[0] != '\0') {
277 strcpy(qid, sim->qid_nbi);
278 }
279 else if( hdf5_get_active_qid(f, "/nbi/", qid) ) {
280 print_err("Error: Active QID not declared.");
281 return 1;
282 }
283 strcpy(sim->qid_nbi, qid);
284 print_out(VERBOSE_IO, "Active QID is %s\n", qid);
285 if( hdf5_nbi_init(f, &sim->nbi_data, qid) ) {
286 print_err("Error: Failed to initialize NBI data.\n");
287 return 1;
288 }
289 print_out(VERBOSE_IO, "NBI data read and initialized.\n");
290 }
291
292 if(input_active & hdf5_input_marker) {
293 if(hdf5_find_group(f, "/marker/")) {
294 print_err("Error: No marker data in input file.");
295 return 1;
296 }
297 print_out(VERBOSE_IO, "\nReading marker input.\n");
298 if(sim->qid_marker[0] != '\0') {
299 strcpy(qid, sim->qid_marker);
300 }
301 else if( hdf5_get_active_qid(f, "/marker/", qid) ) {
302 print_err("Error: Active QID not declared.");
303 return 1;
304 }
305 strcpy(sim->qid_marker, qid);
306 print_out(VERBOSE_IO, "Active QID is %s\n", qid);
307 if( hdf5_marker_read(f, n_markers, p, qid) ) {
308 print_err("Error: Failed to read markers.\n");
309 return 1;
310 }
311 print_out(VERBOSE_IO, "Marker data read and initialized.\n");
312 }
313
314 /* Close the hdf5 file */
315 if( hdf5_close(f) ) {
316 print_err("Error: Could not close the file.\n");
317 return 1;
318 }
319
320 print_out(VERBOSE_IO, "\nAll input read and initialized.\n");
321 return 0;
322}
323
342int hdf5_interface_init_results(sim_data* sim, char* qid, char* run) {
343
344 /* Create new file for the output if one does not yet exist. */
345 hid_t fout = hdf5_create(sim->hdf5_out);
346 if(fout < 0) {
347 print_out(VERBOSE_IO, "Note: Output file %s is already present.\n",
348 sim->hdf5_out);
349 }
350 else {
351 hdf5_close(fout);
352 }
353
354 /* Open output file. */
355 fout = hdf5_open(sim->hdf5_out);
356 if(fout < 0) {
357 print_err("Error: Output file %s doesn't exists.\n", sim->hdf5_out);
358 return 1;
359 }
360
361 /* Create a run group for this specific run (and results group if one */
362 /* doesn't exist already. */
363 char runpath[200], path[256];
364 sprintf(runpath, "/results/%s_XXXXXXXXXX", run);
365 hdf5_gen_path(runpath, qid, path);
366 hid_t newgroup = hdf5_create_group(fout, path);
367
368 /* If a run with identical qid exists, abort. */
369 print_out(VERBOSE_IO, "\nThe qid of this run is %s\n", qid);
370 if(newgroup < 0) {
371 print_err("Error: A run with qid %s already exists.\n", qid);
372 hdf5_close(fout);
373 return 1;
374 }
375 H5Gclose(newgroup);
376
377 /* Set this run as the active run. */
378 hdf5_write_string_attribute(fout, "/results", "active", qid);
379
380 /* Open input file (if different file than the output) */
381 hid_t fin = fout;
382 if( strcmp(sim->hdf5_in, sim->hdf5_out) != 0 ) {
383 fin = hdf5_open(sim->hdf5_in);
384 }
385
386 /* Record input QIDs from sim struct to output group. */
387 if(sim->qid_options[0] != '\0') {
389 fout, path, "qid_options", sim->qid_options);
390 }
391
392 if(sim->qid_bfield[0] != '\0') {
394 fout, path, "qid_bfield", sim->qid_bfield);
395 }
396
397 if(sim->qid_efield[0] != '\0') {
399 fout, path, "qid_efield", sim->qid_efield);
400 }
401
402 if(sim->qid_plasma[0] != '\0') {
404 fout, path, "qid_plasma", sim->qid_plasma);
405 }
406
407 if(sim->qid_neutral[0] != '\0') {
409 fout, path, "qid_neutral", sim->qid_neutral);
410 }
411
412 if(sim->qid_wall[0] != '\0') {
414 fout, path, "qid_wall", sim->qid_wall);
415 }
416
417 if(sim->qid_marker[0] != '\0') {
419 fout, path, "qid_marker", sim->qid_marker);
420 }
421
422 if(sim->qid_boozer[0] != '\0') {
424 fout, path, "qid_boozer", sim->qid_boozer);
425 }
426
427 if(sim->qid_mhd[0] != '\0') {
429 fout, path, "qid_mhd", sim->qid_mhd);
430 }
431
432 if(sim->qid_asigma[0] != '\0') {
434 fout, path, "qid_asigma", sim->qid_asigma);
435 }
436
437 if(sim->qid_nbi[0] != '\0') {
439 fout, path, "qid_nbi", sim->qid_nbi);
440 }
441
442 /* If input and output are different files, close input */
443 if( strcmp(sim->hdf5_in, sim->hdf5_out) != 0 ) {
444 hdf5_close(fin);
445 }
446
447 /* Set a description, repository status, and date; close the file. */
448 hdf5_write_string_attribute(fout, path, "description", sim->description);
449
450#ifdef GIT_VERSION
451 char git[256];
452 sprintf(git, "Tag %s Branch %s", GIT_VERSION, GIT_BRANCH);
453 hdf5_write_string_attribute(fout, path, "repository", git);
454#else
455 hdf5_write_string_attribute(fout, path, "repository",
456 "Not under version control");
457#endif
458
459 time_t t = time(NULL);
460 struct tm tm = *localtime(&t);
461 char date[21];
462 sprintf(date, "%04hu-%02hu-%02hu %02hu:%02hu:%02hu.", tm.tm_year + 1900,
463 tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec);
464 hdf5_write_string_attribute(fout, path, "date", date);
465
466 /* Write compiler flags from stringified macros */
467 hdf5_write_string_attribute(fout, path, "CFLAGS", str_macro(CFLAGS));
468 hdf5_write_string_attribute(fout, path, "CC", str_macro(CC));
469
470 hdf5_close(fout);
471
472 return 0;
473}
474
485int hdf5_interface_write_state(char* fn, char* state, integer n,
486 particle_state* p) {
487 hid_t f = hdf5_open(fn);
488 if(f < 0) {
489 print_err("Error: File not found.\n");
490 return 1;
491 }
492
493 char qid[11];
494 if( hdf5_get_active_qid(f, "/results/", qid) ) {
495 print_err("Error: Active QID was not written to results group.\n");
496 hdf5_close(f);
497 return 1;
498 }
499 char run[256];
500 run[0] = '\0';
501 if(run[0] == '\0') {
502 /* Check if this an ascot5_main run */
503 sprintf(run, "/results/run_%s/", qid);
504 if( hdf5_find_group(f, run) < 0 ) {
505 run[0] = '\0';
506 }
507 }
508 if(run[0] == '\0') {
509 /* Check if this an bbnbi5 run */
510 sprintf(run, "/results/bbnbi_%s/", qid);
511 if( hdf5_find_group(f, run) < 0 ) {
512 run[0] = '\0';
513 }
514 }
515 if(run[0] == '\0') {
516 /* Check if this an afsi5 run */
517 sprintf(run, "/results/afsi_%s/", qid);
518 if( hdf5_find_group(f, run) < 0 ) {
519 run[0] = '\0';
520 }
521 }
522 if(run[0] == '\0') {
523 print_err("Error: Run group not found.\n");
524 }
525
526 if( hdf5_state_write(f, run, state, n, p) ) {
527 print_err("Error: State could not be written.\n");
528 hdf5_close(f);
529 return 1;
530 }
531
532 hdf5_close(f);
533 return 0;
534}
535
545 char path[256]; /* For storing dataset names */
546 print_out(VERBOSE_IO, "\nWriting diagnostics output.\n");
547
548 hid_t f = hdf5_open(sim->hdf5_out);
549 if(f < 0) {
550 print_err("Error: File not found.\n");
551 return 1;
552 }
553
554 char qid[11];
555 if( hdf5_get_active_qid(f, "/results/", qid) ) {
556 print_err("Error: Active QID was not written to results group.\n");
557 hdf5_close(f);
558 return 1;
559 }
560 char run[256];
561 run[0] = '\0';
562 if(run[0] == '\0') {
563 /* Check if this an ascot5_main run */
564 sprintf(run, "/results/run_%s/", qid);
565 if( hdf5_find_group(f, run) < 0 ) {
566 run[0] = '\0';
567 }
568 }
569 if(run[0] == '\0') {
570 /* Check if this an bbnbi5 run */
571 sprintf(run, "/results/bbnbi_%s/", qid);
572 if( hdf5_find_group(f, run) < 0 ) {
573 run[0] = '\0';
574 }
575 }
576 if(run[0] == '\0') {
577 /* Check if this an afsi5 run */
578 sprintf(run, "/results/afsi_%s/", qid);
579 if( hdf5_find_group(f, run) < 0 ) {
580 run[0] = '\0';
581 }
582 }
583 if(run[0] == '\0') {
584 print_err("Error: Run group not found.\n");
585 }
586
587 if(sim->diag_data.dist5D_collect) {
588 print_out(VERBOSE_IO, "\nWriting 5D distribution.\n");
589 sprintf(path, "%sdist5d", run);
590 if( hdf5_dist_write_5D(f, path, &sim->diag_data.dist5D) ) {
591 print_err("Warning: 5D distribution could not be written.\n");
592 }
593 }
594
595 if(sim->diag_data.dist6D_collect) {
596 print_out(VERBOSE_IO, "\nWriting 6D distribution.\n");
597 sprintf(path, "%sdist6d", run);
598 if( hdf5_dist_write_6D(f, path, &sim->diag_data.dist6D) ) {
599 print_err("Warning: 6D distribution could not be written.\n");
600 }
601 }
603 print_out(VERBOSE_IO, "\nWriting rho 5D distribution.\n");
604 sprintf(path, "%sdistrho5d", run);
605 if( hdf5_dist_write_rho5D(f, path, &sim->diag_data.distrho5D) ) {
606 print_err("Warning: rho 5D distribution could not be written.\n");
607 }
608 }
609
611 print_out(VERBOSE_IO, "\nWriting rho 6D distribution.\n");
612 sprintf(path, "%sdistrho6d", run);
613 if( hdf5_dist_write_rho6D(f, path, &sim->diag_data.distrho6D) ) {
614 print_err("Warning: rho 6D distribution could not be written.\n");
615 }
616 }
617
618 if(sim->diag_data.distCOM_collect) {
619 print_out(VERBOSE_IO, "\nWriting COM distribution.\n");
620 sprintf(path, "%sdistcom", run);
621 if( hdf5_dist_write_COM( f, path, &sim->diag_data.distCOM) ) {
622 print_err("Warning: COM distribution could not be written.\n");
623 }
624 }
625
626 if(sim->diag_data.diagorb_collect) {
627 print_out(VERBOSE_IO, "Writing orbit diagnostics.\n");
628 sprintf(path, "%sorbit", run);
629 if( hdf5_orbit_write(f, path, &sim->diag_data.diagorb) ) {
630 print_err("Warning: Orbit diagnostics could not be written.\n");
631 }
632 }
633
635 print_out(VERBOSE_IO, "Writing transport coefficient diagnostics.\n");
636 sprintf(path, "%stranscoef", run);
637 if( hdf5_transcoef_write(f, path, &sim->diag_data.diagtrcof) ) {
638 print_err("Warning: Coefficients could not be written.\n");
639 }
640 }
641
642 hdf5_close(f);
643
644 print_out(VERBOSE_IO, "\nDiagnostics output written.\n");
645
646 return 0;
647}
648
664int hdf5_get_active_qid(hid_t f, const char* group, char qid[11]) {
665 if( H5LTget_attribute_string(f, group, "active", qid) ) {
666 return 1;
667 }
668 qid[10] = '\0';
669
670 return 0;
671}
672
682void hdf5_generate_qid(char* qid) {
683
684 /* Seed random number generator with current time */
685 struct timespec ts;
686#ifdef __MACH__
687 clock_gettime(CLOCK_MONOTONIC, &ts);
688#else
689 clock_gettime(CLOCK_REALTIME, &ts);
690#endif
691 srand48( ts.tv_nsec );
692
693 /* Generate a 32 bit random integer by generating signed 32 bit random
694 * integers with mrand48() and choosing the first one that is positive */
695 long int qint = -1;
696 while(qint < 0) {
697 qint = mrand48();
698 }
699
700 /* Convert the random number to a string format */
701 sprintf(qid, "%010lu", (long unsigned int)qint);
702}
Main header file for ASCOT5.
#define str_macro(c)
Definition ascot5.h:69
long integer
Definition ascot5.h:84
int hdf5_asigma_init(hid_t f, asigma_data *data, char *qid)
Read atomic data from HDF5 file.
Definition hdf5_asigma.c:30
Header file for hdf5_asigma.c.
int hdf5_bfield_init(hid_t f, B_field_data *data, char *qid)
Initialize magnetic field data from HDF5 file.
Definition hdf5_bfield.c:62
Header file for hdf5_bfield.c.
int hdf5_boozer_init(hid_t f, boozer_data *data, char *qid)
Initialize Boozer data from HDF5 file.
Definition hdf5_boozer.c:26
Header file for hdf5_boozer.c.
int hdf5_dist_write_rho6D(hid_t f, char *path, dist_rho6D_data *dist)
Write rho 6D distribution to an existing result group.
Definition hdf5_dist.c:191
int hdf5_dist_write_COM(hid_t f, char *path, dist_COM_data *dist)
Write constants-of-motion distribution to an existing result group.
Definition hdf5_dist.c:248
int hdf5_dist_write_5D(hid_t f, char *path, dist_5D_data *dist)
Write 5D distribution to an existing result group.
Definition hdf5_dist.c:26
int hdf5_dist_write_rho5D(hid_t f, char *path, dist_rho5D_data *dist)
Write rho 5D distribution to an existing result group.
Definition hdf5_dist.c:137
int hdf5_dist_write_6D(hid_t f, char *path, dist_6D_data *dist)
Write 6D distribution to an existing result group.
Definition hdf5_dist.c:80
int hdf5_efield_init(hid_t f, E_field_data *data, char *qid)
Read electric field data from HDF5 file.
Definition hdf5_efield.c:53
Header file for hdf5_efielc.c.
hid_t hdf5_create_group(hid_t loc, const char *path)
Create a group (with parent groups if necessary). Returns a handle to the group. Negative on failure.
herr_t hdf5_write_string_attribute(hid_t loc, const char *path, const char *attrname, const char *string)
Write string attribute with null-padding.
herr_t hdf5_find_group(hid_t loc, const char *path)
Checks if given group exists within given hdf5 file. Negative value is returned if the group doesn't ...
hid_t hdf5_create(const char *filename)
Create an hdf5 file, fail if file exists. A negative value is returned on failure.
herr_t hdf5_close(hid_t file_id)
Close access to given hdf5 file identifier. A negative value is returned on failure.
char * hdf5_gen_path(const char *original, char *qid, char *path)
Generate a valid path from a given template and qid.
void hdf5_init(void)
Initialize hdf5, right now just disables automatic error messages.
hid_t hdf5_open_ro(const char *filename)
Open a hdf5 file for read only. A negative value is returned on failure.
hid_t hdf5_open(const char *filename)
Open a hdf5 file for reading and writing. A negative value is returned on failure.
Header file for hdf5_helpers.h.
int hdf5_interface_write_diagnostics(sim_data *sim)
Write diagnostics to HDF5 output.
int hdf5_interface_write_state(char *fn, char *state, integer n, particle_state *p)
Write marker state to HDF5 output.
int hdf5_get_active_qid(hid_t f, const char *group, char qid[11])
Fetch active qid within the given group.
int hdf5_interface_init_results(sim_data *sim, char *qid, char *run)
Initialize run group.
int hdf5_interface_read_input(sim_data *sim, int input_active, input_particle **p, int *n_markers)
Read and initialize input data.
void hdf5_generate_qid(char *qid)
Generate an identification number for a run.
Header file for hdf5_interface.c.
@ hdf5_input_marker
@ hdf5_input_plasma
@ hdf5_input_options
@ hdf5_input_wall
@ hdf5_input_neutral
@ hdf5_input_bfield
@ hdf5_input_efield
@ hdf5_input_boozer
@ hdf5_input_mhd
@ hdf5_input_nbi
@ hdf5_input_asigma
int hdf5_marker_read(hid_t f, int *n, input_particle **p, char *qid)
Read marker input.
Definition hdf5_marker.c:41
Header file for hdf5_marker.c.
int hdf5_mhd_init(hid_t f, mhd_data *data, char *qid)
Initialize MHD data from HDF5 file.
Definition hdf5_mhd.c:31
Header file for hdf5_mhd.c.
int hdf5_nbi_init(hid_t f, nbi_data *data, char *qid)
Initialize NBI offload data from HDF5 file.
Definition hdf5_nbi.c:25
Header file for hdf5_nbi.c.
int hdf5_neutral_init(hid_t f, neutral_data *data, char *qid)
Initialize neutral data from HDF5 file.
Header file for hdf5_neutral.c.
int hdf5_options_read(hid_t file, sim_data *sim, char *qid)
Read options and diagnostics settings from HDF5 file.
Header file for hdf5_options.c.
int hdf5_orbit_write(hid_t f, char *path, diag_orb_data *data)
Write orbit diagnostics data to a HDF5 file.
Definition hdf5_orbit.c:32
Header file for hdf5_orbit.c.
int hdf5_plasma_init(hid_t f, plasma_data *data, char *qid)
Read plasma data from HDF5 file.
Definition hdf5_plasma.c:36
Header file for hdf5_plasma.c.
int hdf5_state_write(hid_t f, char *run, char *state, integer n, particle_state *p)
Writes marker state to an ASCOT5 HDF5 file.
Definition hdf5_state.c:36
Header file for hdf5_state.c.
int hdf5_transcoef_write(hid_t f, char *path, diag_transcoef_data *data)
Write transport coefficients to a HDF5 file.
Header file for hdf5_transcoef.c.
int hdf5_wall_init(hid_t f, wall_data *data, char *qid)
Read wall data from HDF5 file.
Definition hdf5_wall.c:40
Header file for hdf5_wall.c.
Macros for printing console output.
#define print_out(v,...)
Print to standard output.
Definition print.h:31
@ VERBOSE_IO
Definition print.h:20
#define print_err(...)
Print to standard error.
Definition print.h:42
Header file for simulate.c.
dist_COM_data distCOM
Definition diag.h:35
int distrho5D_collect
Definition diag.h:25
int diagtrcof_collect
Definition diag.h:28
diag_transcoef_data diagtrcof
Definition diag.h:36
int distrho6D_collect
Definition diag.h:26
diag_orb_data diagorb
Definition diag.h:30
dist_rho6D_data distrho6D
Definition diag.h:34
dist_5D_data dist5D
Definition diag.h:31
int dist5D_collect
Definition diag.h:23
int dist6D_collect
Definition diag.h:24
int distCOM_collect
Definition diag.h:27
dist_6D_data dist6D
Definition diag.h:32
dist_rho5D_data distrho5D
Definition diag.h:33
int diagorb_collect
Definition diag.h:22
Wrapper for marker structs.
Definition particle.h:186
General representation of a marker.
Definition particle.h:40
Simulation data struct.
Definition simulate.h:57
char qid_wall[256]
Definition simulate.h:140
char qid_asigma[256]
Definition simulate.h:145
plasma_data plasma_data
Definition simulate.h:61
mhd_data mhd_data
Definition simulate.h:65
char hdf5_in[256]
Definition simulate.h:126
char qid_plasma[256]
Definition simulate.h:141
char qid_marker[256]
Definition simulate.h:139
char qid_nbi[256]
Definition simulate.h:146
E_field_data E_data
Definition simulate.h:60
char qid_bfield[256]
Definition simulate.h:137
char qid_options[256]
Definition simulate.h:136
char qid_boozer[256]
Definition simulate.h:143
neutral_data neutral_data
Definition simulate.h:62
boozer_data boozer_data
Definition simulate.h:64
char description[256]
Definition simulate.h:129
B_field_data B_data
Definition simulate.h:59
char qid_mhd[256]
Definition simulate.h:144
char hdf5_out[256]
Definition simulate.h:127
char qid_efield[256]
Definition simulate.h:138
wall_data wall_data
Definition simulate.h:63
asigma_data asigma_data
Definition simulate.h:66
char qid_neutral[256]
Definition simulate.h:142
diag_data diag_data
Definition simulate.h:68
nbi_data nbi_data
Definition simulate.h:67