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
44void 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
62void 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
70 sprintf(msg, "Input evaluation failed "
71 "(marker could be outside input data grid)");
72 break;
73
75 sprintf(msg, "Input was not regonized "
76 "(offload or target data could be uninitialized)");
77 break;
78
80 sprintf(msg, "Input evaluation yields unphysical results "
81 "(something could be wrong with the input)");
82 break;
83
85 sprintf(msg, "One or more of marker's fields are unphysical or "
86 "inconsistent (marker input could be corrupted)");
87 break;
88
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
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
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
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}
void error_parse(a5err err, int *msg, int *line, int *file)
Retrieve stored data from the error flag.
Definition error.c:44
void error_parse2str(a5err err, char *msg, char *line, char *file)
Convert error flag in string format.
Definition error.c:62
Error module for ASCOT5.
unsigned long int a5err
Simulation error flag.
Definition error.h:17
@ EF_N0_1D
Definition error.h:33
@ EF_N0_3D
Definition error.h:34
@ EF_MCCC
Definition error.h:29
@ EF_ASIGMA_LOC
Definition error.h:52
@ EF_ASIGMA
Definition error.h:51
@ EF_N0_ST
Definition error.h:35
@ EF_PLASMA
Definition error.h:42
@ EF_B_2DS
Definition error.h:37
@ EF_MCCC_WIENER
Definition error.h:26
@ EF_BOOZER
Definition error.h:48
@ EF_B_GS
Definition error.h:39
@ EF_E_FIELD
Definition error.h:43
@ EF_STEP_GC_CASHKARP
Definition error.h:31
@ EF_B_3DS
Definition error.h:36
@ EF_MCCC_COEFS
Definition error.h:28
@ EF_PLASMA_1DS
Definition error.h:41
@ EF_ATOMIC
Definition error.h:50
@ EF_B_FIELD
Definition error.h:46
@ EF_STEP_FO_VPA
Definition error.h:30
@ EF_STEP_GC_RK4
Definition error.h:32
@ EF_MCCC_PUSH
Definition error.h:27
@ EF_MHD
Definition error.h:49
@ EF_B_STS
Definition error.h:38
@ EF_E_1DS
Definition error.h:45
@ EF_NEUTRAL
Definition error.h:44
@ EF_PARTICLE
Definition error.h:47
@ EF_PLASMA_1D
Definition error.h:40
@ ERR_MARKER_UNPHYSICAL
Definition error.h:66
@ ERR_INVALID_TIMESTEP
Definition error.h:67
@ ERR_ATOMIC_EVALUATION
Definition error.h:71
@ ERR_INPUT_EVALUATION
Definition error.h:63
@ ERR_UNKNOWN_INPUT
Definition error.h:64
@ ERR_WIENER_ARRAY
Definition error.h:68
@ ERR_INPUT_UNPHYSICAL
Definition error.h:65
Header file for math.c.