18#include "compiler_flags.h"
31#include "hdf5io/hdf5_dist.h"
64 real** B_offload_array,
65 real** E_offload_array,
66 real** plasma_offload_array,
67 real** neutral_offload_array,
68 real** wall_offload_array,
69 int** wall_int_offload_array,
70 real** boozer_offload_array,
71 real** mhd_offload_array,
72 real** asigma_offload_array,
73 real** nbi_offload_array,
96 print_err(
"Error: No options in input file.");
104 print_err(
"Error: Active QID not declared.");
110 print_err(
"Error: Failed to initialize options.\n");
118 print_err(
"Error: No magnetic field in input file.");
126 print_err(
"Error: Active QID not declared.");
132 B_offload_array, qid) ) {
133 print_err(
"Error: Failed to initialize magnetic field.\n");
141 print_err(
"Error: No electric field in input file.");
149 print_err(
"Error: Active QID not declared.");
155 E_offload_array, qid) ) {
156 print_err(
"Error: Failed to initialize electric field.\n");
164 print_err(
"Error: No plasma data in input file.");
172 print_err(
"Error: Active QID not declared.");
178 plasma_offload_array, qid) ) {
179 print_err(
"Error: Failed to initialize plasma data.\n");
187 print_err(
"Error: No neutral data in input file.");
195 print_err(
"Error: Active QID not declared.");
201 neutral_offload_array, qid) ) {
202 print_err(
"Error: Failed to initialize neutral data.\n");
210 print_err(
"Error: No wall data in input file.");
218 print_err(
"Error: Active QID not declared.");
224 wall_offload_array, wall_int_offload_array,
226 print_err(
"Error: Failed to initialize wall.\n");
234 print_err(
"Error: No boozer data in input file.");
242 print_err(
"Error: Active QID not declared.");
248 boozer_offload_array, qid) ) {
249 print_err(
"Error: Failed to read boozer input.\n");
257 print_err(
"Error: No MHD data in input file.");
265 print_err(
"Error: Active QID not declared.");
271 mhd_offload_array, qid) ) {
272 print_err(
"Error: Failed to read MHD input.\n");
280 print_err(
"Error: No atomic reaction data in input file.");
288 print_err(
"Error: Active QID not declared.");
294 asigma_offload_array, qid) ) {
295 print_err(
"Error: Failed to initialize atomic reaction data.\n");
303 print_err(
"Error: No NBI data in input file.");
311 print_err(
"Error: Active QID not declared.");
317 nbi_offload_array, qid) ) {
318 print_err(
"Error: Failed to initialize NBI data.\n");
326 print_err(
"Error: No marker data in input file.");
334 print_err(
"Error: Active QID not declared.");
340 print_err(
"Error: Failed to read markers.\n");
348 print_err(
"Error: Could not close the file.\n");
395 char runpath[200], path[256];
396 sprintf(runpath,
"/results/%s_XXXXXXXXXX", run);
403 print_err(
"Error: A run with qid %s already exists.\n", qid);
446 fout, path,
"qid_wall", sim->
qid_wall);
461 fout, path,
"qid_mhd", sim->
qid_mhd);
471 fout, path,
"qid_nbi", sim->
qid_nbi);
484 sprintf(git,
"Tag %s Branch %s", GIT_VERSION, GIT_BRANCH);
488 "Not under version control");
491 time_t t = time(NULL);
492 struct tm tm = *localtime(&t);
494 sprintf(date,
"%04hu-%02hu-%02hu %02hu:%02hu:%02hu.", tm.tm_year + 1900,
495 tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec);
527 print_err(
"Error: Active QID was not written to results group.\n");
535 sprintf(run,
"/results/run_%s/", qid);
542 sprintf(run,
"/results/bbnbi_%s/", qid);
549 sprintf(run,
"/results/afsi_%s/", qid);
555 print_err(
"Error: Run group not found.\n");
559 print_err(
"Error: State could not be written.\n");
578 real* diag_offload_array,
char* out) {
590 print_err(
"Error: Active QID was not written to results group.\n");
598 sprintf(run,
"/results/run_%s/", qid);
605 sprintf(run,
"/results/bbnbi_%s/", qid);
612 sprintf(run,
"/results/afsi_%s/", qid);
618 print_err(
"Error: Run group not found.\n");
624 sprintf(path,
"%sdist5d", run);
626 &diag_offload_array[idx]) ) {
627 print_err(
"Warning: 5D distribution could not be written.\n");
634 sprintf(path,
"%sdist6d", run);
636 &diag_offload_array[idx]) ) {
637 print_err(
"Warning: 6D distribution could not be written.\n");
643 sprintf(path,
"%sdistrho5d", run);
645 &diag_offload_array[idx]) ) {
646 print_err(
"Warning: rho 5D distribution could not be written.\n");
653 sprintf(path,
"%sdistrho6d", run);
655 &diag_offload_array[idx]) ) {
656 print_err(
"Warning: rho 6D distribution could not be written.\n");
663 sprintf(path,
"%sdistcom", run);
665 &diag_offload_array[idx]) ) {
666 print_err(
"Warning: COM distribution could not be written.\n");
673 sprintf(path,
"%sorbit", run);
675 &diag_offload_array[idx]) ) {
676 print_err(
"Warning: Orbit diagnostics could not be written.\n");
683 sprintf(path,
"%stranscoef", run);
685 &diag_offload_array[idx]) ) {
686 print_err(
"Warning: Coefficients could not be written.\n");
713 if( H5LTget_attribute_string(f, group,
"active", qid) ) {
735 clock_gettime(CLOCK_MONOTONIC_RAW, &ts);
737 clock_gettime(CLOCK_REALTIME, &ts);
739 srand48( ts.tv_nsec );
749 sprintf(qid,
"%010lu", (
long unsigned int)qint);
Main header file for ASCOT5.
int hdf5_asigma_init_offload(hid_t f, asigma_offload_data *offload_data, real **offload_array, char *qid)
Read atomic data from HDF5 file.
Header file for hdf5_asigma.c.
int hdf5_bfield_init_offload(hid_t f, B_field_offload_data *offload_data, real **offload_array, char *qid)
Initialize magnetic field offload data from HDF5 file.
Header file for hdf5_bfield.c.
int hdf5_boozer_init_offload(hid_t f, boozer_offload_data *offload_data, real **offload_array, char *qid)
Initialize Boozer offload data from HDF5 file.
Header file for hdf5_boozer.c.
int hdf5_dist_write_6D(hid_t f, char *path, dist_6D_offload_data *dist, real *hist)
Write 6D distribution to an existing result group.
int hdf5_dist_write_rho5D(hid_t f, char *path, dist_rho5D_offload_data *dist, real *hist)
Write rho 5D distribution to an existing result group.
int hdf5_dist_write_COM(hid_t f, char *path, dist_COM_offload_data *dist, real *hist)
Write constants-of-motion distribution to an existing result group.
int hdf5_dist_write_rho6D(hid_t f, char *path, dist_rho6D_offload_data *dist, real *hist)
Write rho 6D distribution to an existing result group.
int hdf5_dist_write_5D(hid_t f, char *path, dist_5D_offload_data *dist, real *hist)
Write 5D distribution to an existing result group.
int hdf5_efield_init_offload(hid_t f, E_field_offload_data *offload_data, real **offload_array, char *qid)
Read electric field data from HDF5 file.
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_init_results(sim_offload_data *sim, char *qid, char *run)
Initialize run group.
int hdf5_interface_read_input(sim_offload_data *sim, int input_active, real **B_offload_array, real **E_offload_array, real **plasma_offload_array, real **neutral_offload_array, real **wall_offload_array, int **wall_int_offload_array, real **boozer_offload_array, real **mhd_offload_array, real **asigma_offload_array, real **nbi_offload_array, input_particle **p, int *n_markers)
Read and initialize input data.
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_write_diagnostics(sim_offload_data *sim, real *diag_offload_array, char *out)
Write diagnostics to HDF5 output.
void hdf5_generate_qid(char *qid)
Generate an identification number for a run.
Header file for hdf5_interface.c.
int hdf5_marker_read(hid_t f, int *n, input_particle **p, char *qid)
Read marker input.
Header file for hdf5_marker.c.
int hdf5_mhd_init_offload(hid_t f, mhd_offload_data *offload_data, real **offload_array, char *qid)
Initialize MHD offload data from HDF5 file.
Header file for hdf5_mhd.c.
int hdf5_nbi_init_offload(hid_t f, nbi_offload_data *offload_data, real **offload_array, char *qid)
Initialize NBI offload data from HDF5 file.
Header file for hdf5_nbi.c.
int hdf5_neutral_init_offload(hid_t f, neutral_offload_data *offload_data, real **offload_array, char *qid)
Initialize neutral data from HDF5 file.
Header file for hdf5_neutral.c.
int hdf5_options_read(hid_t file, sim_offload_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_offload_data *data, real *orbits)
Write orbit diagnostics data to a HDF5 file.
Header file for hdf5_orbit.c.
int hdf5_plasma_init_offload(hid_t f, plasma_offload_data *offload_data, real **offload_array, char *qid)
Read plasma data from HDF5 file.
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.
Header file for hdf5_state.c.
int hdf5_transcoef_write(hid_t f, char *path, diag_transcoef_offload_data *data, real *coefarr)
Write transport coefficients to a HDF5 file.
Header file for hdf5_transcoef.c.
int hdf5_wall_init_offload(hid_t f, wall_offload_data *offload_data, real **offload_array, int **int_offload_array, char *qid)
Read wall data from HDF5 file.
Header file for hdf5_wall.c.
Macros for printing console output.
#define print_out(v,...)
Print to standard output.
#define print_err(...)
Print to standard error.
Header file for simulate.c.
dist_rho5D_offload_data distrho5D
size_t offload_distCOM_index
diag_transcoef_offload_data diagtrcof
dist_5D_offload_data dist5D
size_t offload_distrho6D_index
size_t offload_distrho5D_index
size_t offload_dist6D_index
size_t offload_diagtrcof_index
dist_6D_offload_data dist6D
dist_rho6D_offload_data distrho6D
size_t offload_dist5D_index
dist_COM_offload_data distCOM
size_t offload_diagorb_index
diag_orb_offload_data diagorb
Wrapper for marker structs.
General representation of a marker.
Simulation offload struct.
B_field_offload_data B_offload_data
plasma_offload_data plasma_offload_data
neutral_offload_data neutral_offload_data
mhd_offload_data mhd_offload_data
asigma_offload_data asigma_offload_data
boozer_offload_data boozer_offload_data
wall_offload_data wall_offload_data
nbi_offload_data nbi_offload_data
E_field_offload_data E_offload_data
diag_offload_data diag_offload_data