ASCOT5
Loading...
Searching...
No Matches
hdf5_boozer.c
Go to the documentation of this file.
1
6#include <stdlib.h>
7#include <stdio.h>
8#include <hdf5.h>
9#include <hdf5_hl.h>
10#include "../ascot5.h"
11#include "../boozer.h"
12#include "../consts.h"
13#include "hdf5_helpers.h"
14#include "hdf5_boozer.h"
15
29 real** offload_array, char* qid) {
30
32 #undef BOOZERPATH
33 #define BOOZERPATH "/boozer/Boozer_XXXXXXXXXX/"
35
36 /* Read data the QID corresponds to */
37 char path[256];
38 hdf5_gen_path(BOOZERPATH, qid, path);
39 if( hdf5_find_group(f, path) ) {
40 return 1;
41 }
42
43 /* Read parameters. */
44 if( hdf5_read_int(BOOZERPATH "ntheta", &(offload_data->ntheta),
45 f, qid, __FILE__, __LINE__) ) {return 1;}
46 if( hdf5_read_int(BOOZERPATH "nthetag", &(offload_data->nthetag),
47 f, qid, __FILE__, __LINE__) ) {return 1;}
48 if( hdf5_read_int(BOOZERPATH "nrzs", &(offload_data->nrzs),
49 f, qid, __FILE__, __LINE__) ) {return 1;}
50 if( hdf5_read_int(BOOZERPATH "npsi", &(offload_data->npsi),
51 f, qid, __FILE__, __LINE__) ) {return 1;}
52 if( hdf5_read_double(BOOZERPATH "psimin", &(offload_data->psi_min),
53 f, qid, __FILE__, __LINE__) ) {return 1;}
54 if( hdf5_read_double(BOOZERPATH "psimax", &(offload_data->psi_max),
55 f, qid, __FILE__, __LINE__) ) {return 1;}
56
57 /* Size of 1D and 2D input data arrays */
58 int nusize = offload_data->npsi * offload_data->ntheta;
59 int thetasize = offload_data->npsi * offload_data->nthetag;
60 int contoursize = offload_data->nrzs;
61
62 /* Allocate offload array */
63 *offload_array = (real*) malloc(
64 (nusize + thetasize + 2 * contoursize) * sizeof(real) );
65
66 /* Read data to offload array */
67 if( hdf5_read_double(BOOZERPATH "nu_psitheta",
68 &(*offload_array)[0],
69 f, qid, __FILE__, __LINE__) ) {return 1;}
70 if( hdf5_read_double(BOOZERPATH "theta_psithetageom",
71 &(*offload_array)[nusize],
72 f, qid, __FILE__, __LINE__) ) {return 1;}
73 if( hdf5_read_double(BOOZERPATH "rs",
74 &(*offload_array)[nusize + thetasize],
75 f, qid, __FILE__, __LINE__) ) {return 1;}
76 if( hdf5_read_double(BOOZERPATH "zs",
77 &(*offload_array)[nusize + thetasize
78 + contoursize],
79 f, qid, __FILE__, __LINE__) ) {return 1;}
80
81 /* Initialize the data */
82 if( boozer_init_offload(offload_data, offload_array) ) {
83 return 1;
84 }
85
86 return 0;
87}
Main header file for ASCOT5.
double real
Definition ascot5.h:85
int boozer_init_offload(boozer_offload_data *offload_data, real **offload_array)
Load Boozer data and prepare parameters for offload.
Definition boozer.c:37
Header file for boozer.c.
Header file containing physical and mathematical constants.
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.
Definition hdf5_boozer.c:28
Header file for hdf5_boozer.c.
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 ...
int hdf5_read_double(const char *var, real *ptr, hid_t file, char *qid, const char *errfile, int errline)
Read double-valued data from ASCOT5 HDF5 file.
char * hdf5_gen_path(const char *original, char *qid, char *path)
Generate a valid path from a given template and qid.
int hdf5_read_int(const char *var, int *ptr, hid_t file, char *qid, const char *errfile, int errline)
Read int-valued data from ASCOT5 HDF5 file.
Header file for hdf5_helpers.h.
offload data for maps between boozer and cylindrical coordinates
Definition boozer.h:16