18#include "compiler_flags.h"
31#include "hdf5io/hdf5_dist.h"
74 print_err(
"Error: No options in input file.");
82 print_err(
"Error: Active QID not declared.");
88 print_err(
"Error: Failed to initialize options.\n");
96 print_err(
"Error: No magnetic field in input file.");
104 print_err(
"Error: Active QID not declared.");
110 print_err(
"Error: Failed to initialize magnetic field.\n");
118 print_err(
"Error: No electric field in input file.");
126 print_err(
"Error: Active QID not declared.");
132 print_err(
"Error: Failed to initialize electric field.\n");
140 print_err(
"Error: No plasma data in input file.");
148 print_err(
"Error: Active QID not declared.");
154 print_err(
"Error: Failed to initialize plasma data.\n");
162 print_err(
"Error: No neutral data in input file.");
170 print_err(
"Error: Active QID not declared.");
176 print_err(
"Error: Failed to initialize neutral data.\n");
184 print_err(
"Error: No wall data in input file.");
192 print_err(
"Error: Active QID not declared.");
198 print_err(
"Error: Failed to initialize wall.\n");
206 print_err(
"Error: No boozer data in input file.");
214 print_err(
"Error: Active QID not declared.");
220 print_err(
"Error: Failed to read boozer input.\n");
228 print_err(
"Error: No MHD data in input file.");
236 print_err(
"Error: Active QID not declared.");
242 print_err(
"Error: Failed to read MHD input.\n");
250 print_err(
"Error: No atomic reaction data in input file.");
258 print_err(
"Error: Active QID not declared.");
264 print_err(
"Error: Failed to initialize atomic reaction data.\n");
272 print_err(
"Error: No NBI data in input file.");
280 print_err(
"Error: Active QID not declared.");
286 print_err(
"Error: Failed to initialize NBI data.\n");
294 print_err(
"Error: No marker data in input file.");
302 print_err(
"Error: Active QID not declared.");
308 print_err(
"Error: Failed to read markers.\n");
316 print_err(
"Error: Could not close the file.\n");
363 char runpath[200], path[256];
364 sprintf(runpath,
"/results/%s_XXXXXXXXXX", run);
371 print_err(
"Error: A run with qid %s already exists.\n", qid);
414 fout, path,
"qid_wall", sim->
qid_wall);
429 fout, path,
"qid_mhd", sim->
qid_mhd);
439 fout, path,
"qid_nbi", sim->
qid_nbi);
452 sprintf(git,
"Tag %s Branch %s", GIT_VERSION, GIT_BRANCH);
456 "Not under version control");
459 time_t t = time(NULL);
460 struct tm tm = *localtime(&t);
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);
495 print_err(
"Error: Active QID was not written to results group.\n");
503 sprintf(run,
"/results/run_%s/", qid);
510 sprintf(run,
"/results/bbnbi_%s/", qid);
517 sprintf(run,
"/results/afsi_%s/", qid);
523 print_err(
"Error: Run group not found.\n");
527 print_err(
"Error: State could not be written.\n");
556 print_err(
"Error: Active QID was not written to results group.\n");
564 sprintf(run,
"/results/run_%s/", qid);
571 sprintf(run,
"/results/bbnbi_%s/", qid);
578 sprintf(run,
"/results/afsi_%s/", qid);
584 print_err(
"Error: Run group not found.\n");
589 sprintf(path,
"%sdist5d", run);
591 print_err(
"Warning: 5D distribution could not be written.\n");
597 sprintf(path,
"%sdist6d", run);
599 print_err(
"Warning: 6D distribution could not be written.\n");
604 sprintf(path,
"%sdistrho5d", run);
606 print_err(
"Warning: rho 5D distribution could not be written.\n");
612 sprintf(path,
"%sdistrho6d", run);
614 print_err(
"Warning: rho 6D distribution could not be written.\n");
620 sprintf(path,
"%sdistcom", run);
622 print_err(
"Warning: COM distribution could not be written.\n");
628 sprintf(path,
"%sorbit", run);
630 print_err(
"Warning: Orbit diagnostics could not be written.\n");
636 sprintf(path,
"%stranscoef", run);
638 print_err(
"Warning: Coefficients could not be written.\n");
665 if( H5LTget_attribute_string(f, group,
"active", qid) ) {
687 clock_gettime(CLOCK_MONOTONIC, &ts);
689 clock_gettime(CLOCK_REALTIME, &ts);
691 srand48( ts.tv_nsec );
701 sprintf(qid,
"%010lu", (
long unsigned int)qint);
Main header file for ASCOT5.
int hdf5_asigma_init(hid_t f, asigma_data *data, char *qid)
Read atomic data from HDF5 file.
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.
Header file for hdf5_bfield.c.
int hdf5_boozer_init(hid_t f, boozer_data *data, char *qid)
Initialize Boozer data from HDF5 file.
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.
int hdf5_dist_write_COM(hid_t f, char *path, dist_COM_data *dist)
Write constants-of-motion distribution to an existing result group.
int hdf5_dist_write_5D(hid_t f, char *path, dist_5D_data *dist)
Write 5D distribution to an existing result group.
int hdf5_dist_write_rho5D(hid_t f, char *path, dist_rho5D_data *dist)
Write rho 5D distribution to an existing result group.
int hdf5_dist_write_6D(hid_t f, char *path, dist_6D_data *dist)
Write 6D distribution to an existing result group.
int hdf5_efield_init(hid_t f, E_field_data *data, 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_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.
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(hid_t f, mhd_data *data, char *qid)
Initialize MHD data from HDF5 file.
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.
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.
Header file for hdf5_orbit.c.
int hdf5_plasma_init(hid_t f, plasma_data *data, 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_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.
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.
diag_transcoef_data diagtrcof
dist_rho6D_data distrho6D
dist_rho5D_data distrho5D
Wrapper for marker structs.
General representation of a marker.
neutral_data neutral_data