ASCOT5
Loading...
Searching...
No Matches
hdf5_interface.c File Reference

HDF5 operations are accessed through here. More...

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <hdf5.h>
#include <hdf5_hl.h>
#include "ascot5.h"
#include "simulate.h"
#include "print.h"
#include "gitver.h"
#include "compiler_flags.h"
#include "hdf5_interface.h"
#include "hdf5io/hdf5_helpers.h"
#include "hdf5io/hdf5_options.h"
#include "hdf5io/hdf5_bfield.h"
#include "hdf5io/hdf5_plasma.h"
#include "hdf5io/hdf5_neutral.h"
#include "hdf5io/hdf5_efield.h"
#include "hdf5io/hdf5_wall.h"
#include "hdf5io/hdf5_boozer.h"
#include "hdf5io/hdf5_mhd.h"
#include "hdf5io/hdf5_marker.h"
#include "hdf5io/hdf5_state.h"
#include "hdf5io/hdf5_dist.h"
#include "hdf5io/hdf5_orbit.h"
#include "hdf5io/hdf5_transcoef.h"
#include "hdf5io/hdf5_asigma.h"
#include "hdf5io/hdf5_nbi.h"

Go to the source code of this file.

Functions

int hdf5_get_active_qid (hid_t f, const char *group, char qid[11])
 Fetch active qid within the given group.
 
int hdf5_interface_read_input (sim_data *sim, int input_active, input_particle **p, int *n_markers)
 Read and initialize input data.
 
int hdf5_interface_init_results (sim_data *sim, char *qid, char *run)
 Initialize run group.
 
int hdf5_interface_write_state (char *fn, char *state, integer n, particle_state *p)
 Write marker state to HDF5 output.
 
int hdf5_interface_write_diagnostics (sim_data *sim)
 Write diagnostics to HDF5 output.
 
void hdf5_generate_qid (char *qid)
 Generate an identification number for a run.
 

Detailed Description

HDF5 operations are accessed through here.

This module handles IO operations to HDF5 file. Accessing HDF5 files from the main program should be done using this module.

Definition in file hdf5_interface.c.

Function Documentation

◆ hdf5_get_active_qid()

int hdf5_get_active_qid ( hid_t f,
const char * group,
char qid[11] )

Fetch active qid within the given group.

Each input group (/bfield/, /options/, etc.) has qid string indicating which of the subgroups is active, i.e., meant to be used within this simulation.

This function fetches the active qid assuming the file is opened and closed outside of this function.

Parameters
fHDF5 file identifier
groupgroup string including the "/"s on both sides e.g. /bfield/
qidarray where qid will be stored
Returns
Zero on success

Definition at line 664 of file hdf5_interface.c.

◆ hdf5_interface_read_input()

int hdf5_interface_read_input ( sim_data * sim,
int input_active,
input_particle ** p,
int * n_markers )

Read and initialize input data.

This function reads input from HDF5 file, initializes it, and allocates offload arrays and returns the pointers to them.

Parameters
simpointer to simulation offload struct
input_activebitflags for input types to read
ppointer to marker offload data
n_markerspointer to integer notating how many markers were read
Returns
zero if reading and initialization succeeded

Definition at line 52 of file hdf5_interface.c.

◆ hdf5_interface_init_results()

int hdf5_interface_init_results ( sim_data * sim,
char * qid,
char * run )

Initialize run group.

This functions creates results group (if one does not already exist) and creates run group corresponding to this run. Run group is named as /results/<run>_XXXXXXXXXX/ where X's are the qid of current run and <run> is the type of the run: "run" for ascot5_main and "bbnbi" for bbnbi5.

The group is initialized by writing qids of all used inputs as string attributes in the run group. Also the date and empty "details" fields are written.

Parameters
simpointer to simulation struct
qidqid of this run
runtype of this run
Returns
Zero if initialization succeeded

Definition at line 342 of file hdf5_interface.c.

◆ hdf5_interface_write_state()

int hdf5_interface_write_state ( char * fn,
char * state,
integer n,
particle_state * p )

Write marker state to HDF5 output.

Parameters
fnHDF5 output filename
statename of the state to be written
nnumber of markers in marker array
parray of markers to be written
Returns
Zero if state was written succesfully

Definition at line 485 of file hdf5_interface.c.

◆ hdf5_interface_write_diagnostics()

int hdf5_interface_write_diagnostics ( sim_data * sim)

Write diagnostics to HDF5 output.

Parameters
simpointer to simulation data
outHDF5 output filename
Returns
Zero if diagnostics were written succesfully

Definition at line 544 of file hdf5_interface.c.

◆ hdf5_generate_qid()

void hdf5_generate_qid ( char * qid)

Generate an identification number for a run.

The identification number (QID) is a 32 bit unsigned integer represented in a string format, i.e., by ten characters. QID is a random integer between 0 and 4 294 967 295, and it is padded with leading zeroes in string representation.

Parameters
qida pointer to 11 chars wide array where generated QID is stored

Definition at line 682 of file hdf5_interface.c.