ASCOT5
Loading...
Searching...
No Matches
error.c
Go to the documentation of this file.
1
27
#include <stdlib.h>
28
#include <
math.h
>
29
#include "
error.h
"
30
44
void
error_parse
(
a5err
err,
int
* msg,
int
* line,
int
* file) {
45
*file = (int)( floor( err / ( 256 * 1024 ) ) );
46
err -= *file * ( 256 * 1024 );
47
*line = (int)( floor( err / 256 ) );
48
err -= *line * ( 256 );
49
*msg = err;
50
}
51
62
void
error_parse2str
(
a5err
err,
char
* msg,
char
* line,
char
* file) {
63
int
msg_i, line_i, file_i;
64
error_parse
(err, &msg_i, &line_i, &file_i);
65
66
/* Find the error message */
67
switch
(msg_i) {
68
69
case
ERR_INPUT_EVALUATION
:
70
sprintf(msg,
"Input evaluation failed "
71
"(marker could be outside input data grid)"
);
72
break
;
73
74
case
ERR_UNKNOWN_INPUT
:
75
sprintf(msg,
"Input was not regonized "
76
"(offload or target data could be uninitialized)"
);
77
break
;
78
79
case
ERR_INPUT_UNPHYSICAL
:
80
sprintf(msg,
"Input evaluation yields unphysical results "
81
"(something could be wrong with the input)"
);
82
break
;
83
84
case
ERR_MARKER_UNPHYSICAL
:
85
sprintf(msg,
"One or more of marker's fields are unphysical or "
86
"inconsistent (marker input could be corrupted)"
);
87
break
;
88
89
case
ERR_INVALID_TIMESTEP
:
90
sprintf(msg,
"Time step is zero, NaN, or smaller than MIN_ALLOWED"
91
"_TIME_STEP in ascot5.h (time step limits could be too "
92
"conservative)"
);
93
break
;
94
95
case
ERR_WIENER_ARRAY
:
96
sprintf(msg,
"Wiener array is full of rejected steps or "
97
"limits could be too conservative or initial step too "
98
"large)"
);
99
break
;
100
101
case
ERR_ATOMIC_EVALUATION
:
102
sprintf(msg,
"Atomic reaction evaluation failed "
103
"(atomic reactions for the current charge state might"
104
"not have been implemented)"
);
105
break
;
106
107
default
:
108
sprintf(msg,
"Unknown error"
);
109
break
;
110
}
111
112
/* Line number to string */
113
sprintf(line,
"%4d"
, line_i);
114
115
/* Find the file where error originated from */
116
switch
(file_i) {
117
118
case
EF_MCCC_WIENER
:
119
sprintf(file,
"mccc_wiener.c"
);
120
break
;
121
122
case
EF_MCCC_PUSH
:
123
sprintf(file,
"mccc_push.c"
);
124
break
;
125
126
case
EF_MCCC_COEFS
:
127
sprintf(file,
"mccc_coefs.c"
);
128
break
;
129
130
case
EF_MCCC
:
131
sprintf(file,
"mccc.c"
);
132
break
;
133
134
case
EF_STEP_FO_VPA
:
135
sprintf(file,
"step_fo_vpa.c"
);
136
break
;
137
138
case
EF_STEP_GC_RK4
:
139
sprintf(file,
"step_gc_rk4.c"
);
140
break
;
141
142
case
EF_STEP_GC_CASHKARP
:
143
sprintf(file,
"step_gc_cashkarp.c"
);
144
break
;
145
146
case
EF_PLASMA
:
147
sprintf(file,
"plasma.c"
);
148
break
;
149
150
case
EF_PLASMA_1D
:
151
sprintf(file,
"plasma_1D.c"
);
152
break
;
153
154
case
EF_PLASMA_1DS
:
155
sprintf(file,
"plasma_1DS.c"
);
156
break
;
157
158
case
EF_E_FIELD
:
159
sprintf(file,
"E_field.c"
);
160
break
;
161
162
case
EF_E_1DS
:
163
sprintf(file,
"E_1DS.c"
);
164
break
;
165
166
case
EF_NEUTRAL
:
167
sprintf(file,
"neutral.c"
);
168
break
;
169
170
case
EF_N0_1D
:
171
sprintf(file,
"N0_1D.c"
);
172
break
;
173
174
case
EF_N0_3D
:
175
sprintf(file,
"N0_3D.c"
);
176
break
;
177
178
case
EF_N0_ST
:
179
sprintf(file,
"N0_ST.c"
);
180
break
;
181
182
case
EF_B_FIELD
:
183
sprintf(file,
"B_field.c"
);
184
break
;
185
186
case
EF_B_GS
:
187
sprintf(file,
"B_GS.c"
);
188
break
;
189
190
case
EF_B_STS
:
191
sprintf(file,
"B_STS.c"
);
192
break
;
193
194
case
EF_B_2DS
:
195
sprintf(file,
"B_2DS.c"
);
196
break
;
197
198
case
EF_B_3DS
:
199
sprintf(file,
"B_3DS.c"
);
200
break
;
201
202
case
EF_PARTICLE
:
203
sprintf(file,
"particle.c"
);
204
break
;
205
206
case
EF_BOOZER
:
207
sprintf(file,
"boozer.c"
);
208
break
;
209
210
case
EF_MHD
:
211
sprintf(file,
"mhd.c"
);
212
break
;
213
214
case
EF_ATOMIC
:
215
sprintf(file,
"atomic.c"
);
216
break
;
217
218
case
EF_ASIGMA
:
219
sprintf(file,
"asigma.c"
);
220
break
;
221
222
case
EF_ASIGMA_LOC
:
223
sprintf(file,
"asigma_loc.c"
);
224
break
;
225
226
default
:
227
sprintf(file,
"unknown file"
);
228
break
;
229
}
230
}
error_parse
void error_parse(a5err err, int *msg, int *line, int *file)
Retrieve stored data from the error flag.
Definition
error.c:44
error_parse2str
void error_parse2str(a5err err, char *msg, char *line, char *file)
Convert error flag in string format.
Definition
error.c:62
error.h
Error module for ASCOT5.
a5err
unsigned long int a5err
Simulation error flag.
Definition
error.h:17
EF_N0_1D
@ EF_N0_1D
Definition
error.h:33
EF_N0_3D
@ EF_N0_3D
Definition
error.h:34
EF_MCCC
@ EF_MCCC
Definition
error.h:29
EF_ASIGMA_LOC
@ EF_ASIGMA_LOC
Definition
error.h:52
EF_ASIGMA
@ EF_ASIGMA
Definition
error.h:51
EF_N0_ST
@ EF_N0_ST
Definition
error.h:35
EF_PLASMA
@ EF_PLASMA
Definition
error.h:42
EF_B_2DS
@ EF_B_2DS
Definition
error.h:37
EF_MCCC_WIENER
@ EF_MCCC_WIENER
Definition
error.h:26
EF_BOOZER
@ EF_BOOZER
Definition
error.h:48
EF_B_GS
@ EF_B_GS
Definition
error.h:39
EF_E_FIELD
@ EF_E_FIELD
Definition
error.h:43
EF_STEP_GC_CASHKARP
@ EF_STEP_GC_CASHKARP
Definition
error.h:31
EF_B_3DS
@ EF_B_3DS
Definition
error.h:36
EF_MCCC_COEFS
@ EF_MCCC_COEFS
Definition
error.h:28
EF_PLASMA_1DS
@ EF_PLASMA_1DS
Definition
error.h:41
EF_ATOMIC
@ EF_ATOMIC
Definition
error.h:50
EF_B_FIELD
@ EF_B_FIELD
Definition
error.h:46
EF_STEP_FO_VPA
@ EF_STEP_FO_VPA
Definition
error.h:30
EF_STEP_GC_RK4
@ EF_STEP_GC_RK4
Definition
error.h:32
EF_MCCC_PUSH
@ EF_MCCC_PUSH
Definition
error.h:27
EF_MHD
@ EF_MHD
Definition
error.h:49
EF_B_STS
@ EF_B_STS
Definition
error.h:38
EF_E_1DS
@ EF_E_1DS
Definition
error.h:45
EF_NEUTRAL
@ EF_NEUTRAL
Definition
error.h:44
EF_PARTICLE
@ EF_PARTICLE
Definition
error.h:47
EF_PLASMA_1D
@ EF_PLASMA_1D
Definition
error.h:40
ERR_MARKER_UNPHYSICAL
@ ERR_MARKER_UNPHYSICAL
Definition
error.h:66
ERR_INVALID_TIMESTEP
@ ERR_INVALID_TIMESTEP
Definition
error.h:67
ERR_ATOMIC_EVALUATION
@ ERR_ATOMIC_EVALUATION
Definition
error.h:71
ERR_INPUT_EVALUATION
@ ERR_INPUT_EVALUATION
Definition
error.h:63
ERR_UNKNOWN_INPUT
@ ERR_UNKNOWN_INPUT
Definition
error.h:64
ERR_WIENER_ARRAY
@ ERR_WIENER_ARRAY
Definition
error.h:68
ERR_INPUT_UNPHYSICAL
@ ERR_INPUT_UNPHYSICAL
Definition
error.h:65
math.h
Header file for math.c.
Generated on Wed Oct 9 2024 17:13:57 for ASCOT5 by
1.10.0