ASCOT5
Loading...
Searching...
No Matches
hdf5_options.c
Go to the documentation of this file.
1
5#include <stdlib.h>
6#include <hdf5.h>
7#include <hdf5_hl.h>
8#include "../ascot5.h"
9#include "../consts.h"
10#include "../diag.h"
11#include "../diag/diag_orb.h"
12#include "../diag/dist_5D.h"
13#include "../diag/dist_6D.h"
14#include "../diag/dist_rho5D.h"
15#include "../diag/dist_rho6D.h"
16#include "../diag/dist_com.h"
17#include "../endcond.h"
18#include "../math.h"
19#include "../simulate.h"
20#include "hdf5_helpers.h"
21#include "hdf5_options.h"
22#define OPTPATH
25 char* qid);
27 char* qid);
29 char* qid);
31 char* qid);
33 char* qid);
35 char* qid);
36int hdf5_options_read_diagtrcof(hid_t file,
38 char* qid);
39
54int hdf5_options_read(hid_t file, sim_offload_data* sim, char* qid){
55
56 #undef OPTPATH
57 #define OPTPATH "/options/opt_XXXXXXXXXX/"
58
59 real tempfloat; // For reading float data that is converted to int.
60
61 if( hdf5_read_double(OPTPATH "SIM_MODE", &tempfloat,
62 file, qid, __FILE__, __LINE__) ) {return 1;}
63 sim->sim_mode = (int)tempfloat;
64 if( hdf5_read_double(OPTPATH "ENABLE_ADAPTIVE", &tempfloat,
65 file, qid, __FILE__, __LINE__) ) {return 1;}
66 sim->enable_ada = (int)tempfloat;
67 if( hdf5_read_double(OPTPATH "RECORD_MODE", &tempfloat,
68 file, qid, __FILE__, __LINE__) ) {return 1;}
69 sim->record_mode = (int)tempfloat;
70
71
72 if( hdf5_read_double(OPTPATH "FIXEDSTEP_USE_USERDEFINED", &tempfloat,
73 file, qid, __FILE__, __LINE__) ) {return 1;}
74 sim->fix_usrdef_use = (int)tempfloat;
75 if( hdf5_read_double(OPTPATH "FIXEDSTEP_USERDEFINED", &sim->fix_usrdef_val,
76 file, qid, __FILE__, __LINE__) ) {return 1;}
77 if( hdf5_read_double(OPTPATH "FIXEDSTEP_GYRODEFINED", &tempfloat,
78 file, qid, __FILE__, __LINE__) ) {return 1;}
79 sim->fix_gyrodef_nstep = (int)tempfloat;
80
81
82 if( hdf5_read_double(OPTPATH "ADAPTIVE_TOL_ORBIT", &sim->ada_tol_orbfol,
83 file, qid, __FILE__, __LINE__) ) {return 1;}
84 if( hdf5_read_double(OPTPATH "ADAPTIVE_TOL_CCOL", &sim->ada_tol_clmbcol,
85 file, qid, __FILE__, __LINE__) ) {return 1;}
86 if( hdf5_read_double(OPTPATH "ADAPTIVE_MAX_DRHO", &sim->ada_max_drho,
87 file, qid, __FILE__, __LINE__) ) {return 1;}
88 if( hdf5_read_double(OPTPATH "ADAPTIVE_MAX_DPHI", &sim->ada_max_dphi,
89 file, qid, __FILE__, __LINE__) ) {return 1;}
90
91
92 if( hdf5_read_double(OPTPATH "ENABLE_ORBIT_FOLLOWING", &tempfloat,
93 file, qid, __FILE__, __LINE__) ) {return 1;}
94 sim->enable_orbfol = (int)tempfloat;
95 if( hdf5_read_double(OPTPATH "ENABLE_COULOMB_COLLISIONS", &tempfloat,
96 file, qid, __FILE__, __LINE__) ) {return 1;}
97 sim->enable_clmbcol = (int)tempfloat;
98 if( hdf5_read_double(OPTPATH "ENABLE_MHD", &tempfloat,
99 file, qid, __FILE__, __LINE__) ) {return 1;}
100 sim->enable_mhd = (int)tempfloat;
101 if( hdf5_read_double(OPTPATH "ENABLE_ATOMIC", &tempfloat,
102 file, qid, __FILE__, __LINE__) ) {return 1;}
103 sim->enable_atomic = (int)tempfloat;
104 if( hdf5_read_double(OPTPATH "DISABLE_FIRSTORDER_GCTRANS", &tempfloat,
105 file, qid, __FILE__, __LINE__) ) {return 1;}
106 sim->disable_gctransform = (int)tempfloat;
107 if( hdf5_read_double(OPTPATH "DISABLE_ENERGY_CCOLL", &tempfloat,
108 file, qid, __FILE__, __LINE__) ) {return 1;}
109 sim->disable_energyccoll = (int)tempfloat;
110 if( hdf5_read_double(OPTPATH "DISABLE_PITCH_CCOLL", &tempfloat,
111 file, qid, __FILE__, __LINE__) ) {return 1;}
112 sim->disable_pitchccoll = (int)tempfloat;
113 if( hdf5_read_double(OPTPATH "DISABLE_GCDIFF_CCOLL", &tempfloat,
114 file, qid, __FILE__, __LINE__) ) {return 1;}
115 sim->disable_gcdiffccoll = (int)tempfloat;
116 if( hdf5_read_double(OPTPATH "REVERSE_TIME", &tempfloat,
117 file, qid, __FILE__, __LINE__) ) {return 1;}
118 sim->reverse_time = (int)tempfloat;
119
120 int ec;
121 sim->endcond_active = 0;
122
123 if( hdf5_read_double(OPTPATH "ENDCOND_SIMTIMELIM", &tempfloat,
124 file, qid, __FILE__, __LINE__) ) {return 1;}
125 ec = (int)tempfloat;
126 sim->endcond_active = sim->endcond_active | endcond_tlim * (ec > 0);
127 if( hdf5_read_double(OPTPATH "ENDCOND_CPUTIMELIM", &tempfloat,
128 file, qid, __FILE__, __LINE__) ) {return 1;}
129 ec = (int)tempfloat;
130 sim->endcond_active = sim->endcond_active | endcond_cpumax * (ec > 0);
131 if( hdf5_read_double(OPTPATH "ENDCOND_RHOLIM", &tempfloat,
132 file, qid, __FILE__, __LINE__) ) {return 1;}
133 ec = (int)tempfloat;
134 sim->endcond_active = sim->endcond_active | endcond_rhomin * (ec > 0);
135 sim->endcond_active = sim->endcond_active | endcond_rhomax * (ec > 0);
136 if( hdf5_read_double(OPTPATH "ENDCOND_ENERGYLIM", &tempfloat,
137 file, qid, __FILE__, __LINE__) ) {return 1;}
138 ec = (int)tempfloat;
139 sim->endcond_active = sim->endcond_active | endcond_emin * (ec > 0);
140 sim->endcond_active = sim->endcond_active | endcond_therm * (ec > 0);
141 if( hdf5_read_double(OPTPATH "ENDCOND_WALLHIT", &tempfloat,
142 file, qid, __FILE__, __LINE__) ) {return 1;}
143 ec = (int)tempfloat;
144 sim->endcond_active = sim->endcond_active | endcond_wall * (ec > 0);
145 if( hdf5_read_double(OPTPATH "ENDCOND_MAXORBS", &tempfloat,
146 file, qid, __FILE__, __LINE__) ) {return 1;}
147 ec = (int)tempfloat;
148 sim->endcond_active = sim->endcond_active | endcond_polmax * (ec > 0);
149 sim->endcond_active = sim->endcond_active | endcond_tormax * (ec > 0);
150 if( hdf5_read_double(OPTPATH "ENDCOND_NEUTRALIZED", &tempfloat,
151 file, qid, __FILE__, __LINE__) ) {return 1;}
152 ec = (int)tempfloat;
153 sim->endcond_active = sim->endcond_active | endcond_neutr * (ec > 0);
154 if( hdf5_read_double(OPTPATH "ENDCOND_IONIZED", &tempfloat,
155 file, qid, __FILE__, __LINE__) ) {return 1;}
156 ec = (int)tempfloat;
157 sim->endcond_active = sim->endcond_active | endcond_ioniz * (ec > 0);
158
159 sim->endcond_torandpol = 0;
160 if( ec == 2) {
161 sim->endcond_torandpol = 1;
162 }
163
164
165 if( hdf5_read_double(OPTPATH "ENDCOND_LIM_SIMTIME",
167 file, qid, __FILE__, __LINE__) ) {return 1;}
168 if( hdf5_read_double(OPTPATH "ENDCOND_MAX_MILEAGE",
170 file, qid, __FILE__, __LINE__) ) {return 1;}
171 if( hdf5_read_double(OPTPATH "ENDCOND_MAX_CPUTIME",
173 file, qid, __FILE__, __LINE__) ) {return 1;}
174 if( hdf5_read_double(OPTPATH "ENDCOND_MAX_RHO",
175 &sim->endcond_max_rho,
176 file, qid, __FILE__, __LINE__) ) {return 1;}
177 if( hdf5_read_double(OPTPATH "ENDCOND_MIN_RHO",
178 &sim->endcond_min_rho,
179 file, qid, __FILE__, __LINE__) ) {return 1;}
180 if( hdf5_read_double(OPTPATH "ENDCOND_MIN_ENERGY",
181 &sim->endcond_min_ekin,
182 file, qid, __FILE__, __LINE__) ) {return 1;}
183 if( hdf5_read_double(OPTPATH "ENDCOND_MIN_THERMAL",
185 file, qid, __FILE__, __LINE__) ) {return 1;}
186 sim->endcond_min_ekin *= CONST_E; // eV -> J
187
188 int temp;
189 if( hdf5_read_double(OPTPATH "ENDCOND_MAX_POLOIDALORBS", &tempfloat,
190 file, qid, __FILE__, __LINE__) ) {return 1;}
191 temp = (int)tempfloat;
192 sim->endcond_max_polorb = temp * 2 *CONST_PI;
193
194 if( hdf5_read_double(OPTPATH "ENDCOND_MAX_TOROIDALORBS", &tempfloat,
195 file, qid, __FILE__, __LINE__) ) {return 1;}
196 temp = (int)tempfloat;
197 sim->endcond_max_tororb = temp * 2 *CONST_PI;
198
199
200 /* See which diagnostics are active */
202
203 if( hdf5_read_double(OPTPATH "ENABLE_DIST_5D", &tempfloat,
204 file, qid, __FILE__, __LINE__) ) {return 1;}
205 diag->dist5D_collect = (int)tempfloat;
206 if( hdf5_read_double(OPTPATH "ENABLE_DIST_6D", &tempfloat,
207 file, qid, __FILE__, __LINE__) ) {return 1;}
208 diag->dist6D_collect = (int)tempfloat;
209 if( hdf5_read_double(OPTPATH "ENABLE_DIST_RHO5D", &tempfloat,
210 file, qid, __FILE__, __LINE__) ) {return 1;}
211 diag->distrho5D_collect = (int)tempfloat;
212 if( hdf5_read_double(OPTPATH "ENABLE_DIST_RHO6D", &tempfloat,
213 file, qid, __FILE__, __LINE__) ) {return 1;}
214 diag->distrho6D_collect = (int)tempfloat;
215 if( hdf5_read_double(OPTPATH "ENABLE_DIST_COM", &tempfloat,
216 file, qid, __FILE__, __LINE__) ) {return 1;}
217 diag->distCOM_collect = (int)tempfloat;
218 if( hdf5_read_double(OPTPATH "ENABLE_ORBITWRITE", &tempfloat,
219 file, qid, __FILE__, __LINE__) ) {return 1;}
220 diag->diagorb_collect = (int)tempfloat;
221 if( hdf5_read_double(OPTPATH "ENABLE_TRANSCOEF", &tempfloat,
222 file, qid, __FILE__, __LINE__) ) {return 1;}
223 diag->diagtrcof_collect = (int)tempfloat;
224
225 /* Read individual diagnostics data */
226 if(diag->dist5D_collect) {
227 if( hdf5_options_read_dist5D(file, &diag->dist5D, qid) ) {
228 return 1;
229 }
230 }
231 if(diag->dist6D_collect) {
232 if( hdf5_options_read_dist6D(file, &diag->dist6D, qid) ) {
233 return 1;
234 }
235 }
236 if(diag->distrho5D_collect) {
237 if( hdf5_options_read_distrho5D(file, &diag->distrho5D, qid) ) {
238 return 1;
239 }
240 }
241 if(diag->distrho6D_collect) {
242 if( hdf5_options_read_distrho6D(file, &diag->distrho6D, qid) ) {
243 return 1;
244 }
245 }
246 if(diag->distCOM_collect) {
247 if( hdf5_options_read_distCOM(file, &diag->distCOM, qid) ) {
248 return 1;
249 }
250 }
251 if(diag->diagorb_collect) {
252 diag->diagorb.record_mode = sim->sim_mode;
253 if(sim->record_mode && (sim->sim_mode == simulate_mode_fo ||
254 sim->sim_mode == simulate_mode_hybrid) ) {
256 }
257
258 if( hdf5_options_read_diagorb(file, &diag->diagorb, qid) ) {
259 return 1;
260 }
261 }
262
263 if(diag->diagtrcof_collect) {
264 if( hdf5_options_read_diagtrcof(file, &diag->diagtrcof, qid) ) {
265 return 1;
266 }
267 }
268
269 return 0;
270}
271
282 char* qid) {
283 #undef OPTPATH
284 #define OPTPATH "/options/opt_XXXXXXXXXX/"
285
286 real tempfloat;
287
288 if( hdf5_read_double(OPTPATH "DIST_MIN_R", &dist->min_r,
289 file, qid, __FILE__, __LINE__) ) {return 1;}
290 if( hdf5_read_double(OPTPATH "DIST_MAX_R", &dist->max_r,
291 file, qid, __FILE__, __LINE__) ) {return 1;}
292 if( hdf5_read_double(OPTPATH "DIST_NBIN_R", &tempfloat,
293 file, qid, __FILE__, __LINE__) ) {return 1;}
294 dist->n_r = (int)tempfloat;
295
296 if( hdf5_read_double(OPTPATH "DIST_MIN_PHI", &dist->min_phi,
297 file, qid, __FILE__, __LINE__) ) {return 1;}
298 if( hdf5_read_double(OPTPATH "DIST_MAX_PHI", &dist->max_phi,
299 file, qid, __FILE__, __LINE__) ) {return 1;}
300 if( hdf5_read_double(OPTPATH "DIST_NBIN_PHI", &tempfloat,
301 file, qid, __FILE__, __LINE__) ) {return 1;}
302 dist->n_phi = (int)tempfloat;
303 dist->min_phi = math_deg2rad(dist->min_phi);
304 dist->max_phi = math_deg2rad(dist->max_phi);
305
306 if( hdf5_read_double(OPTPATH "DIST_MIN_Z", &dist->min_z,
307 file, qid, __FILE__, __LINE__) ) {return 1;}
308 if( hdf5_read_double(OPTPATH "DIST_MAX_Z", &dist->max_z,
309 file, qid, __FILE__, __LINE__) ) {return 1;}
310 if( hdf5_read_double(OPTPATH "DIST_NBIN_Z", &tempfloat,
311 file, qid, __FILE__, __LINE__) ) {return 1;}
312 dist->n_z = (int)tempfloat;
313
314 if( hdf5_read_double(OPTPATH "DIST_MIN_PPA", &dist->min_ppara,
315 file, qid, __FILE__, __LINE__) ) {return 1;}
316 if( hdf5_read_double(OPTPATH "DIST_MAX_PPA", &dist->max_ppara,
317 file, qid, __FILE__, __LINE__) ) {return 1;}
318 if( hdf5_read_double(OPTPATH "DIST_NBIN_PPA", &tempfloat,
319 file, qid, __FILE__, __LINE__) ) {return 1;}
320 dist->n_ppara = (int)tempfloat;
321
322 if( hdf5_read_double(OPTPATH "DIST_MIN_PPE", &dist->min_pperp,
323 file, qid, __FILE__, __LINE__) ) {return 1;}
324 if( hdf5_read_double(OPTPATH "DIST_MAX_PPE", &dist->max_pperp,
325 file, qid, __FILE__, __LINE__) ) {return 1;}
326 if( hdf5_read_double(OPTPATH "DIST_NBIN_PPE", &tempfloat,
327 file, qid, __FILE__, __LINE__) ) {return 1;}
328 dist->n_pperp = (int)tempfloat;
329
330 if( hdf5_read_double(OPTPATH "DIST_MIN_TIME", &dist->min_time,
331 file, qid, __FILE__, __LINE__) ) {return 1;}
332 if( hdf5_read_double(OPTPATH "DIST_MAX_TIME", &dist->max_time,
333 file, qid, __FILE__, __LINE__) ) {return 1;}
334 if( hdf5_read_double(OPTPATH "DIST_NBIN_TIME", &tempfloat,
335 file, qid, __FILE__, __LINE__) ) {return 1;}
336 dist->n_time = (int)tempfloat;
337
338 if( hdf5_read_double(OPTPATH "DIST_MIN_CHARGE", &dist->min_q,
339 file, qid, __FILE__, __LINE__) ) {return 1;}
340 if( hdf5_read_double(OPTPATH "DIST_MAX_CHARGE", &dist->max_q,
341 file, qid, __FILE__, __LINE__) ) {return 1;}
342 if( hdf5_read_double(OPTPATH "DIST_NBIN_CHARGE", &tempfloat,
343 file, qid, __FILE__, __LINE__) ) {return 1;}
344 dist->n_q = (int)tempfloat;
345
346 return 0;
347}
348
359 char* qid) {
360 #undef OPTPATH
361 #define OPTPATH "/options/opt_XXXXXXXXXX/"
362
363 real tempfloat;
364
365 if( hdf5_read_double(OPTPATH "DIST_MIN_R", &dist->min_r,
366 file, qid, __FILE__, __LINE__) ) {return 1;}
367 if( hdf5_read_double(OPTPATH "DIST_MAX_R", &dist->max_r,
368 file, qid, __FILE__, __LINE__) ) {return 1;}
369 if( hdf5_read_double(OPTPATH "DIST_NBIN_R", &tempfloat,
370 file, qid, __FILE__, __LINE__) ) {return 1;}
371 dist->n_r = (int)tempfloat;
372
373 if( hdf5_read_double(OPTPATH "DIST_MIN_PHI", &dist->min_phi,
374 file, qid, __FILE__, __LINE__) ) {return 1;}
375 if( hdf5_read_double(OPTPATH "DIST_MAX_PHI", &dist->max_phi,
376 file, qid, __FILE__, __LINE__) ) {return 1;}
377 if( hdf5_read_double(OPTPATH "DIST_NBIN_PHI", &tempfloat,
378 file, qid, __FILE__, __LINE__) ) {return 1;}
379 dist->n_phi = (int)tempfloat;
380 dist->min_phi = math_deg2rad(dist->min_phi);
381 dist->max_phi = math_deg2rad(dist->max_phi);
382
383 if( hdf5_read_double(OPTPATH "DIST_MIN_Z", &dist->min_z,
384 file, qid, __FILE__, __LINE__) ) {return 1;}
385 if( hdf5_read_double(OPTPATH "DIST_MAX_Z", &dist->max_z,
386 file, qid, __FILE__, __LINE__) ) {return 1;}
387 if( hdf5_read_double(OPTPATH "DIST_NBIN_Z", &tempfloat,
388 file, qid, __FILE__, __LINE__) ) {return 1;}
389 dist->n_z = (int)tempfloat;
390
391 if( hdf5_read_double(OPTPATH "DIST_MIN_PR", &dist->min_pr,
392 file, qid, __FILE__, __LINE__) ) {return 1;}
393 if( hdf5_read_double(OPTPATH "DIST_MAX_PR", &dist->max_pr,
394 file, qid, __FILE__, __LINE__) ) {return 1;}
395 if( hdf5_read_double(OPTPATH "DIST_NBIN_PR", &tempfloat,
396 file, qid, __FILE__, __LINE__) ) {return 1;}
397 dist->n_pr = (int)tempfloat;
398
399 if( hdf5_read_double(OPTPATH "DIST_MIN_PPHI", &dist->min_pphi,
400 file, qid, __FILE__, __LINE__) ) {return 1;}
401 if( hdf5_read_double(OPTPATH "DIST_MAX_PPHI", &dist->max_pphi,
402 file, qid, __FILE__, __LINE__) ) {return 1;}
403 if( hdf5_read_double(OPTPATH "DIST_NBIN_PPHI", &tempfloat,
404 file, qid, __FILE__, __LINE__) ) {return 1;}
405 dist->n_pphi = (int)tempfloat;
406
407 if( hdf5_read_double(OPTPATH "DIST_MIN_PZ", &dist->min_pz,
408 file, qid, __FILE__, __LINE__) ) {return 1;}
409 if( hdf5_read_double(OPTPATH "DIST_MAX_PZ", &dist->max_pz,
410 file, qid, __FILE__, __LINE__) ) {return 1;}
411 if( hdf5_read_double(OPTPATH "DIST_NBIN_PZ", &tempfloat,
412 file, qid, __FILE__, __LINE__) ) {return 1;}
413 dist->n_pz = (int)tempfloat;
414
415 if( hdf5_read_double(OPTPATH "DIST_MIN_TIME", &dist->min_time,
416 file, qid, __FILE__, __LINE__) ) {return 1;}
417 if( hdf5_read_double(OPTPATH "DIST_MAX_TIME", &dist->max_time,
418 file, qid, __FILE__, __LINE__) ) {return 1;}
419 if( hdf5_read_double(OPTPATH "DIST_NBIN_TIME", &tempfloat,
420 file, qid, __FILE__, __LINE__) ) {return 1;}
421 dist->n_time = (int)tempfloat;
422
423 if( hdf5_read_double(OPTPATH "DIST_MIN_CHARGE", &dist->min_q,
424 file, qid, __FILE__, __LINE__) ) {return 1;}
425 if( hdf5_read_double(OPTPATH "DIST_MAX_CHARGE", &dist->max_q,
426 file, qid, __FILE__, __LINE__) ) {return 1;}
427 if( hdf5_read_double(OPTPATH "DIST_NBIN_CHARGE", &tempfloat,
428 file, qid, __FILE__, __LINE__) ) {return 1;}
429 dist->n_q = (int)tempfloat;
430
431 return 0;
432}
433
444 char* qid) {
445 #undef OPTPATH
446 #define OPTPATH "/options/opt_XXXXXXXXXX/"
447
448 real tempfloat;
449
450 if( hdf5_read_double(OPTPATH "DIST_MIN_RHO", &dist->min_rho,
451 file, qid, __FILE__, __LINE__) ) {return 1;}
452 if( hdf5_read_double(OPTPATH "DIST_MAX_RHO", &dist->max_rho,
453 file, qid, __FILE__, __LINE__) ) {return 1;}
454 if( hdf5_read_double(OPTPATH "DIST_NBIN_RHO", &tempfloat,
455 file, qid, __FILE__, __LINE__) ) {return 1;}
456 dist->n_rho = (int)tempfloat;
457
458 if( hdf5_read_double(OPTPATH "DIST_MIN_PHI", &dist->min_phi,
459 file, qid, __FILE__, __LINE__) ) {return 1;}
460 if( hdf5_read_double(OPTPATH "DIST_MAX_PHI", &dist->max_phi,
461 file, qid, __FILE__, __LINE__) ) {return 1;}
462 if( hdf5_read_double(OPTPATH "DIST_NBIN_PHI", &tempfloat,
463 file, qid, __FILE__, __LINE__) ) {return 1;}
464 dist->n_phi = (int)tempfloat;
465 dist->min_phi = math_deg2rad(dist->min_phi);
466 dist->max_phi = math_deg2rad(dist->max_phi);
467
468 if( hdf5_read_double(OPTPATH "DIST_MIN_THETA", &dist->min_theta,
469 file, qid, __FILE__, __LINE__) ) {return 1;}
470 if( hdf5_read_double(OPTPATH "DIST_MAX_THETA", &dist->max_theta,
471 file, qid, __FILE__, __LINE__) ) {return 1;}
472 if( hdf5_read_double(OPTPATH "DIST_NBIN_THETA", &tempfloat,
473 file, qid, __FILE__, __LINE__) ) {return 1;}
474 dist->n_theta = (int)tempfloat;
475 dist->min_theta = math_deg2rad(dist->min_theta);
476 dist->max_theta = math_deg2rad(dist->max_theta);
477
478 if( hdf5_read_double(OPTPATH "DIST_MIN_PPA", &dist->min_ppara,
479 file, qid, __FILE__, __LINE__) ) {return 1;}
480 if( hdf5_read_double(OPTPATH "DIST_MAX_PPA", &dist->max_ppara,
481 file, qid, __FILE__, __LINE__) ) {return 1;}
482 if( hdf5_read_double(OPTPATH "DIST_NBIN_PPA", &tempfloat,
483 file, qid, __FILE__, __LINE__) ) {return 1;}
484 dist->n_ppara = (int)tempfloat;
485
486 if( hdf5_read_double(OPTPATH "DIST_MIN_PPE", &dist->min_pperp,
487 file, qid, __FILE__, __LINE__) ) {return 1;}
488 if( hdf5_read_double(OPTPATH "DIST_MAX_PPE", &dist->max_pperp,
489 file, qid, __FILE__, __LINE__) ) {return 1;}
490 if( hdf5_read_double(OPTPATH "DIST_NBIN_PPE", &tempfloat,
491 file, qid, __FILE__, __LINE__) ) {return 1;}
492 dist->n_pperp = (int)tempfloat;
493
494 if( hdf5_read_double(OPTPATH "DIST_MIN_TIME", &dist->min_time,
495 file, qid, __FILE__, __LINE__) ) {return 1;}
496 if( hdf5_read_double(OPTPATH "DIST_MAX_TIME", &dist->max_time,
497 file, qid, __FILE__, __LINE__) ) {return 1;}
498 if( hdf5_read_double(OPTPATH "DIST_NBIN_TIME", &tempfloat,
499 file, qid, __FILE__, __LINE__) ) {return 1;}
500 dist->n_time = (int)tempfloat;
501
502 if( hdf5_read_double(OPTPATH "DIST_MIN_CHARGE", &dist->min_q,
503 file, qid, __FILE__, __LINE__) ) {return 1;}
504 if( hdf5_read_double(OPTPATH "DIST_MAX_CHARGE", &dist->max_q,
505 file, qid, __FILE__, __LINE__) ) {return 1;}
506 if( hdf5_read_double(OPTPATH "DIST_NBIN_CHARGE", &tempfloat,
507 file, qid, __FILE__, __LINE__) ) {return 1;}
508 dist->n_q = (int)tempfloat;
509
510 return 0;
511}
512
523 char* qid) {
524 #undef OPTPATH
525 #define OPTPATH "/options/opt_XXXXXXXXXX/"
526
527 real tempfloat;
528
529 if( hdf5_read_double(OPTPATH "DIST_MIN_RHO", &dist->min_rho,
530 file, qid, __FILE__, __LINE__) ) {return 1;}
531 if( hdf5_read_double(OPTPATH "DIST_MAX_RHO", &dist->max_rho,
532 file, qid, __FILE__, __LINE__) ) {return 1;}
533 if( hdf5_read_double(OPTPATH "DIST_NBIN_RHO", &tempfloat,
534 file, qid, __FILE__, __LINE__) ) {return 1;}
535 dist->n_rho = (int)tempfloat;
536
537 if( hdf5_read_double(OPTPATH "DIST_MIN_PHI", &dist->min_phi,
538 file, qid, __FILE__, __LINE__) ) {return 1;}
539 if( hdf5_read_double(OPTPATH "DIST_MAX_PHI", &dist->max_phi,
540 file, qid, __FILE__, __LINE__) ) {return 1;}
541 if( hdf5_read_double(OPTPATH "DIST_NBIN_PHI", &tempfloat,
542 file, qid, __FILE__, __LINE__) ) {return 1;}
543 dist->n_phi = (int)tempfloat;
544 dist->min_phi = math_deg2rad(dist->min_phi);
545 dist->max_phi = math_deg2rad(dist->max_phi);
546
547 if( hdf5_read_double(OPTPATH "DIST_MIN_THETA", &dist->min_theta,
548 file, qid, __FILE__, __LINE__) ) {return 1;}
549 if( hdf5_read_double(OPTPATH "DIST_MAX_THETA", &dist->max_theta,
550 file, qid, __FILE__, __LINE__) ) {return 1;}
551 if( hdf5_read_double(OPTPATH "DIST_NBIN_THETA", &tempfloat,
552 file, qid, __FILE__, __LINE__) ) {return 1;}
553 dist->n_theta = (int)tempfloat;
554 dist->min_theta = math_deg2rad(dist->min_theta);
555 dist->max_theta = math_deg2rad(dist->max_theta);
556
557 if( hdf5_read_double(OPTPATH "DIST_MIN_PR", &dist->min_pr,
558 file, qid, __FILE__, __LINE__) ) {return 1;}
559 if( hdf5_read_double(OPTPATH "DIST_MAX_PR", &dist->max_pr,
560 file, qid, __FILE__, __LINE__) ) {return 1;}
561 if( hdf5_read_double(OPTPATH "DIST_NBIN_PR", &tempfloat,
562 file, qid, __FILE__, __LINE__) ) {return 1;}
563 dist->n_pr = (int)tempfloat;
564
565 if( hdf5_read_double(OPTPATH "DIST_MIN_PPHI", &dist->min_pphi,
566 file, qid, __FILE__, __LINE__) ) {return 1;}
567 if( hdf5_read_double(OPTPATH "DIST_MAX_PPHI", &dist->max_pphi,
568 file, qid, __FILE__, __LINE__) ) {return 1;}
569 if( hdf5_read_double(OPTPATH "DIST_NBIN_PPHI", &tempfloat,
570 file, qid, __FILE__, __LINE__) ) {return 1;}
571 dist->n_pphi = (int)tempfloat;
572
573 if( hdf5_read_double(OPTPATH "DIST_MIN_PZ", &dist->min_pz,
574 file, qid, __FILE__, __LINE__) ) {return 1;}
575 if( hdf5_read_double(OPTPATH "DIST_MAX_PZ", &dist->max_pz,
576 file, qid, __FILE__, __LINE__) ) {return 1;}
577 if( hdf5_read_double(OPTPATH "DIST_NBIN_PZ", &tempfloat,
578 file, qid, __FILE__, __LINE__) ) {return 1;}
579 dist->n_pz = (int)tempfloat;
580
581 if( hdf5_read_double(OPTPATH "DIST_MIN_TIME", &dist->min_time,
582 file, qid, __FILE__, __LINE__) ) {return 1;}
583 if( hdf5_read_double(OPTPATH "DIST_MAX_TIME", &dist->max_time,
584 file, qid, __FILE__, __LINE__) ) {return 1;}
585 if( hdf5_read_double(OPTPATH "DIST_NBIN_TIME", &tempfloat,
586 file, qid, __FILE__, __LINE__) ) {return 1;}
587 dist->n_time = (int)tempfloat;
588
589 if( hdf5_read_double(OPTPATH "DIST_MIN_CHARGE", &dist->min_q,
590 file, qid, __FILE__, __LINE__) ) {return 1;}
591 if( hdf5_read_double(OPTPATH "DIST_MAX_CHARGE", &dist->max_q,
592 file, qid, __FILE__, __LINE__) ) {return 1;}
593 if( hdf5_read_double(OPTPATH "DIST_NBIN_CHARGE", &tempfloat,
594 file, qid, __FILE__, __LINE__) ) {return 1;}
595 dist->n_q = (int)tempfloat;
596
597 return 0;
598}
599
610 char* qid) {
611 #undef OPTPATH
612 #define OPTPATH "/options/opt_XXXXXXXXXX/"
613
614 real tempfloat;
615 if( hdf5_read_double(OPTPATH "DIST_MIN_MU", &dist->min_mu,
616 file, qid, __FILE__, __LINE__) ) {return 1;}
617 if( hdf5_read_double(OPTPATH "DIST_MAX_MU", &dist->max_mu,
618 file, qid, __FILE__, __LINE__) ) {return 1;}
619 if( hdf5_read_double(OPTPATH "DIST_NBIN_MU", &tempfloat,
620 file, qid, __FILE__, __LINE__) ) {return 1;}
621 dist->n_mu = (int)tempfloat;
622
623 if( hdf5_read_double(OPTPATH "DIST_MIN_EKIN", &dist->min_Ekin,
624 file, qid, __FILE__, __LINE__) ) {return 1;}
625 if( hdf5_read_double(OPTPATH "DIST_MAX_EKIN", &dist->max_Ekin,
626 file, qid, __FILE__, __LINE__) ) {return 1;}
627 if( hdf5_read_double(OPTPATH "DIST_NBIN_EKIN", &tempfloat,
628 file, qid, __FILE__, __LINE__) ) {return 1;}
629 dist->n_Ekin = (int)tempfloat;
630
631 if( hdf5_read_double(OPTPATH "DIST_MIN_PTOR", &dist->min_Ptor,
632 file, qid, __FILE__, __LINE__) ) {return 1;}
633 if( hdf5_read_double(OPTPATH "DIST_MAX_PTOR", &dist->max_Ptor,
634 file, qid, __FILE__, __LINE__) ) {return 1;}
635 if( hdf5_read_double(OPTPATH "DIST_NBIN_PTOR", &tempfloat,
636 file, qid, __FILE__, __LINE__) ) {return 1;}
637 dist->n_Ptor = (int)tempfloat;
638
639 return 0;
640}
641
652 char* qid) {
653 #undef OPTPATH
654 #define OPTPATH "/options/opt_XXXXXXXXXX/"
655
656 real tempfloat;
657
658 if( hdf5_read_double(OPTPATH "ORBITWRITE_MODE", &tempfloat,
659 file, qid, __FILE__, __LINE__) ) {return 1;}
660 diagorb->mode = (int)tempfloat;
661
662 if( hdf5_read_double(OPTPATH "ORBITWRITE_NPOINT", &tempfloat,
663 file, qid, __FILE__, __LINE__) ) {return 1;}
664 diagorb->Npnt = (int)tempfloat;
665 if( hdf5_read_double(OPTPATH "ORBITWRITE_INTERVAL",
666 &(diagorb->writeInterval),
667 file, qid, __FILE__, __LINE__) ) {return 1;}
668
669
670
671 for(int i=0; i < DIAG_ORB_MAXPOINCARES; i++) {
675 }
676
677 if( hdf5_read_double(OPTPATH "ORBITWRITE_TOROIDALANGLES",
678 (diagorb->toroidalangles),
679 file, qid, __FILE__, __LINE__) ) {return 1;}
680 if( hdf5_read_double(OPTPATH "ORBITWRITE_POLOIDALANGLES",
681 (diagorb->poloidalangles),
682 file, qid, __FILE__, __LINE__) ) {return 1;}
683 if( hdf5_read_double(OPTPATH "ORBITWRITE_RADIALDISTANCES",
684 (diagorb->radialdistances),
685 file, qid, __FILE__, __LINE__) ) {return 1;}
686
687
688 for(int i=0; i < DIAG_ORB_MAXPOINCARES; i++) {
689 if(diagorb->toroidalangles[0] < 0) {
690 /* Negative angle means plane is disabled */
691 diagorb->ntoroidalplots = 0;
692 break;
693 }
695 diagorb->ntoroidalplots = i;
696 break;
697 }
698 }
699
700 for(int i=0; i < DIAG_ORB_MAXPOINCARES; i++) {
701 if(diagorb->poloidalangles[0] < 0) {
702 /* Negative angle means plane is disabled */
703 diagorb->npoloidalplots = 0;
704 break;
705 }
707 diagorb->npoloidalplots = i;
708 break;
709 }
710 }
711
712 for(int i=0; i < DIAG_ORB_MAXPOINCARES; i++) {
713 if(diagorb->radialdistances[0] < 0) {
714 /* Negative angle means plane is disabled */
715 diagorb->nradialplots = 0;
716 break;
717 }
718 if(diagorb->radialdistances[i] == RADIAL_FILLER_VALUE) {
719 diagorb->nradialplots = i;
720 break;
721 }
722 }
723
724 for(int i=0; i < diagorb->ntoroidalplots; i++) {
725 diagorb->toroidalangles[i] = diagorb->toroidalangles[i]*CONST_PI/180;
726 }
727 for(int i=0; i < diagorb->npoloidalplots; i++) {
728 diagorb->poloidalangles[i] = diagorb->poloidalangles[i]*CONST_PI/180;
729 }
730 return 0;
731}
732
743 hid_t file, diag_transcoef_offload_data* diagtrcof, char* qid) {
744 #undef OPTPATH
745 #define OPTPATH "/options/opt_XXXXXXXXXX/"
746
747 if( hdf5_read_double(OPTPATH "TRANSCOEF_INTERVAL", &diagtrcof->interval,
748 file, qid, __FILE__, __LINE__) ) {return 1;}
749
750 real tempfloat;
751 if( hdf5_read_double(OPTPATH "TRANSCOEF_NAVG", &tempfloat,
752 file, qid, __FILE__, __LINE__) ) {return 1;}
753 diagtrcof->Navg = (int)tempfloat;
754
755 if( hdf5_read_double(OPTPATH "TRANSCOEF_RECORDRHO", &tempfloat,
756 file, qid, __FILE__, __LINE__) ) {return 1;}
757 diagtrcof->recordrho = (int)tempfloat;
758
759 return 0;
760}
Main header file for ASCOT5.
double real
Definition ascot5.h:85
Header file containing physical and mathematical constants.
#define CONST_PI
pi
Definition consts.h:11
#define CONST_E
Elementary charge [C]
Definition consts.h:32
Header file for diag.c.
Header file for diag_orb.c.
#define DIAG_ORB_MAXPOINCARES
Definition diag_orb.h:15
Header file for dist_5D.c.
Header file for dist_6D.c.
Header file for dist_com.c.
Header file for dist_rho5D.c.
Header file for dist_rho6D.c.
Header file for endcond.c.
@ endcond_therm
Definition endcond.h:21
@ endcond_tormax
Definition endcond.h:26
@ endcond_emin
Definition endcond.h:20
@ endcond_rhomin
Definition endcond.h:23
@ endcond_tlim
Definition endcond.h:19
@ endcond_neutr
Definition endcond.h:29
@ endcond_cpumax
Definition endcond.h:27
@ endcond_polmax
Definition endcond.h:25
@ endcond_rhomax
Definition endcond.h:24
@ endcond_wall
Definition endcond.h:22
@ endcond_ioniz
Definition endcond.h:30
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.
Header file for hdf5_helpers.h.
int hdf5_options_read_diagtrcof(hid_t file, diag_transcoef_offload_data *diagtrcof, char *qid)
Helper function to read transport coefficient settings from HDF5 file.
int hdf5_options_read_distrho5D(hid_t file, dist_rho5D_offload_data *dist, char *qid)
Helper function to read distrho5D settings from HDF5 file.
int hdf5_options_read_distrho6D(hid_t file, dist_rho6D_offload_data *dist, char *qid)
Helper function to read distrho6D settings from HDF5 file.
int hdf5_options_read(hid_t file, sim_offload_data *sim, char *qid)
Read options and diagnostics settings from HDF5 file.
int hdf5_options_read_dist6D(hid_t file, dist_6D_offload_data *dist, char *qid)
Helper function to read dist6D settings from HDF5 file.
int hdf5_options_read_diagorb(hid_t file, diag_orb_offload_data *diagorb, char *qid)
Helper function to read orbit diagnostics settings from HDF5 file.
#define OPTPATH
int hdf5_options_read_dist5D(hid_t file, dist_5D_offload_data *dist, char *qid)
Helper function to read dist5D settings from HDF5 file.
int hdf5_options_read_distCOM(hid_t file, dist_COM_offload_data *dist, char *qid)
Helper function to read COM dist settings from HDF5 file.
Header file for hdf5_options.c.
#define RADIAL_FILLER_VALUE
#define TOROIDAL_ANGLE_FILLER_VALUE
#define POLOIDAL_ANGLE_FILLER_VALUE
Header file for math.c.
#define math_deg2rad(a)
Convert degrees to radians.
Definition math.h:107
Header file for simulate.c.
@ simulate_mode_fo
Definition simulate.h:34
@ simulate_mode_gc
Definition simulate.h:37
@ simulate_mode_hybrid
Definition simulate.h:42
Diagnostics offload data struct.
Definition diag.h:21
dist_rho5D_offload_data distrho5D
Definition diag.h:33
int distrho6D_collect
Definition diag.h:26
int diagtrcof_collect
Definition diag.h:28
diag_transcoef_offload_data diagtrcof
Definition diag.h:36
int distCOM_collect
Definition diag.h:27
dist_5D_offload_data dist5D
Definition diag.h:31
int distrho5D_collect
Definition diag.h:25
dist_6D_offload_data dist6D
Definition diag.h:32
int dist5D_collect
Definition diag.h:23
dist_rho6D_offload_data distrho6D
Definition diag.h:34
int diagorb_collect
Definition diag.h:22
int dist6D_collect
Definition diag.h:24
dist_COM_offload_data distCOM
Definition diag.h:35
diag_orb_offload_data diagorb
Definition diag.h:30
Orbit diagnostics offload data struct.
Definition diag_orb.h:35
real toroidalangles[DIAG_ORB_MAXPOINCARES]
Definition diag_orb.h:45
real radialdistances[DIAG_ORB_MAXPOINCARES]
Definition diag_orb.h:47
real poloidalangles[DIAG_ORB_MAXPOINCARES]
Definition diag_orb.h:46
Transport coefficient diagnostics offload data struct.
Histogram parameters that will be offloaded to target.
Definition dist_5D.h:15
Histogram parameters that will be offloaded to target.
Definition dist_6D.h:15
Histogram parameters that will be offloaded to target.
Definition dist_com.h:16
Histogram parameters that will be offloaded to target.
Definition dist_rho5D.h:15
Histogram parameters that will be offloaded to target.
Definition dist_rho6D.h:15
Simulation offload struct.
Definition simulate.h:55
int disable_gcdiffccoll
Definition simulate.h:101
int fix_gyrodef_nstep
Definition simulate.h:76
real endcond_min_ekin
Definition simulate.h:112
real endcond_max_mileage
Definition simulate.h:108
int disable_pitchccoll
Definition simulate.h:99
real ada_tol_clmbcol
Definition simulate.h:82
int disable_gctransform
Definition simulate.h:95
real endcond_max_tororb
Definition simulate.h:115
real endcond_max_polorb
Definition simulate.h:116
real endcond_min_thermal
Definition simulate.h:113
real endcond_lim_simtime
Definition simulate.h:107
real ada_tol_orbfol
Definition simulate.h:80
real fix_usrdef_val
Definition simulate.h:75
int disable_energyccoll
Definition simulate.h:97
real endcond_max_cputime
Definition simulate.h:109
diag_offload_data diag_offload_data
Definition simulate.h:66