ASCOT5
|
Functions to execute main program externally. More...
Go to the source code of this file.
Functions | |
int | pack_offload_array (sim_offload_data *sim, offload_package *offload_data, 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 **offload_array, int **int_offload_array) |
Prepare offload array to be offloaded. | |
int | prepare_markers (sim_offload_data *sim, int n_tot, input_particle *pin, particle_state **pout, int *nprts, real *B_offload_array) |
Prepare markers for offload. | |
int | write_rungroup (sim_offload_data *sim, particle_state *ps, int n_tot, char *qid) |
Create and store run group and marker inistate. | |
int | offload_and_simulate (sim_offload_data *sim, int n_tot, int n_proc, particle_state *pin, offload_package *offload_data, real *offload_array, int *int_offload_array, int *n_gather, particle_state **pout, real *diag_offload_array) |
Offload data to target, carry out the simulation, and return to host. | |
int | write_output (sim_offload_data *sim, particle_state *ps_gathered, int n_tot, real *diag_offload_array) |
Store simulation output data. | |
void | print_marker_summary (particle_state *ps, int n_tot) |
Writes a summary of what happened to the markers during simulation. | |
Functions to execute main program externally.
The main progam for ascot5 is in ascot5_main.c. This header file declares the functions needed to carry out the simulation, so that hey can be used by an external program (i.e. via the python interface).
Definition in file ascot5_main.h.
int pack_offload_array | ( | sim_offload_data * | sim, |
offload_package * | offload_data, | ||
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 ** | offload_array, | ||
int ** | int_offload_array ) |
Prepare offload array to be offloaded.
When data is read, it is stored to input specific offload arrays which are packed as a single array here (two actually as one array contains integers and the other floats). The initial individual arrays are deallocated.
sim | simulation offload data struct |
offload_data | empty offload package |
B_offload_array | magnetic field offload array |
E_offload_array | electric field offload array |
plasma_offload_array | plasma offload array |
neutral_offload_array | neutrals offload array |
wall_offload_array | wall offload array |
wall_int_offload_array | wall integer offload array |
boozer_offload_array | boozer offload array |
mhd_offload_array | MHD data offload array |
asigma_offload_array | atomic data offload array |
offload_array | pointer to common offload array created here |
int_offload_array | pointer to common offload integer array created here |
Definition at line 341 of file ascot5_main.c.
int prepare_markers | ( | sim_offload_data * | sim, |
int | n_tot, | ||
input_particle * | pin, | ||
particle_state ** | pout, | ||
int * | n_proc, | ||
real * | B_offload_array ) |
Prepare markers for offload.
This function initializes the marker states and allocates memory for the particle states. The input markers are read from the HDF5 file and stored in the input_particle_states array. The initial marker states are then calculated and stored in the particle_states array.
When MPI is used, the marker states are initialized only for those markers that are used in this MPI process.
sim | simulation offload data struct |
n_tot | total number of markers |
pin | pointer to marker input array which is deallocated here |
pout | pointer to marker state array created here |
n_proc | pointer to variable for number of markers for this process |
B_offload_array | pointer to magnetic field data needed for marker init |
Definition at line 278 of file ascot5_main.c.
int write_rungroup | ( | sim_offload_data * | sim, |
particle_state * | ps, | ||
int | n_tot, | ||
char * | qid ) |
Create and store run group and marker inistate.
sim | simulation offload data struct |
ps | marker state array for this process |
n_tot | total number of markers in this simulation |
qid | unique identifier for this run group |
Definition at line 408 of file ascot5_main.c.
int offload_and_simulate | ( | sim_offload_data * | sim, |
int | n_tot, | ||
int | n_proc, | ||
particle_state * | pin, | ||
offload_package * | offload_data, | ||
real * | offload_array, | ||
int * | int_offload_array, | ||
int * | n_gather, | ||
particle_state ** | pout, | ||
real * | diag_offload_array ) |
Offload data to target, carry out the simulation, and return to host.
sim | simulation offload data struct |
n_tot | total number of markers |
n_proc | number of markers in this process |
pin | marker state array for this process (deallocated here) |
offload_data | packed offload data struct |
offload_array | packed offload array containing the input data |
int_offload_array | packed offload integer array containg the input data |
n_gather | pointer for storing the number of markers in pout (either n_tot or n_proc) |
pout | pointer to array containing all endstates in the simulation |
diag_offload_array | array to store output data |
Definition at line 469 of file ascot5_main.c.
int write_output | ( | sim_offload_data * | sim, |
particle_state * | ps, | ||
int | n_tot, | ||
real * | diag_offload_array ) |
Store simulation output data.
sim | simulation offload data |
ps | marker endstate array to be written |
n_tot | number of markers |
diag_offload_array | diagnostics offload data array |
Definition at line 508 of file ascot5_main.c.
void print_marker_summary | ( | particle_state * | ps, |
int | n_tot ) |
Writes a summary of what happened to the markers during simulation.
This function writes a summary of marker end conditions and possible simulation-time errors. Since simulation can have billions and billions of markers, we only show how many markers had specific error or end condition.
End conditions and errors are printed in human-readable format.
This function is called by the root MPI process only.
ps | array of marker states after simulation has finished |
n_tot | number of markers in the array |
Definition at line 736 of file ascot5_main.c.