1 |
#include <stdio.h> |
2 |
#include <stdlib.h> |
3 |
#include <string.h> |
4 |
|
5 |
#include "parse_interface.h" |
6 |
#include "BASS_interface.h" |
7 |
#include "simError.h" |
8 |
#ifdef IS_MPI |
9 |
#include "mpiBASS.h" |
10 |
#endif |
11 |
|
12 |
void interface_error( event* the_event ); |
13 |
|
14 |
void init_component( int comp_index ){ |
15 |
event* the_event; |
16 |
|
17 |
the_event = (event* )malloc( sizeof( event ) ); |
18 |
|
19 |
the_event->event_type = COMPONENT; |
20 |
the_event->err_msg = NULL; |
21 |
the_event->evt.blk_index = comp_index; |
22 |
|
23 |
if( !event_handler( the_event ) ) interface_error( the_event ); |
24 |
#ifdef IS_MPI |
25 |
throwMPIEvent(the_event); |
26 |
#endif |
27 |
|
28 |
free( the_event ); |
29 |
} |
30 |
|
31 |
void init_molecule( int mol_index ){ |
32 |
event* the_event; |
33 |
|
34 |
the_event = (event* )malloc( sizeof( event ) ); |
35 |
|
36 |
the_event->event_type = MOLECULE; |
37 |
the_event->err_msg = NULL; |
38 |
the_event->evt.blk_index = mol_index; |
39 |
|
40 |
if( !event_handler( the_event ) ) interface_error( the_event ); |
41 |
#ifdef IS_MPI |
42 |
throwMPIEvent(the_event); |
43 |
#endif |
44 |
|
45 |
free( the_event ); |
46 |
} |
47 |
|
48 |
void init_atom( int atom_index ){ |
49 |
event* the_event; |
50 |
|
51 |
the_event = (event* )malloc( sizeof( event ) ); |
52 |
|
53 |
the_event->event_type = ATOM; |
54 |
the_event->err_msg = NULL; |
55 |
the_event->evt.blk_index = atom_index; |
56 |
|
57 |
if( !event_handler( the_event ) ) interface_error( the_event ); |
58 |
#ifdef IS_MPI |
59 |
throwMPIEvent(the_event); |
60 |
#endif |
61 |
|
62 |
free( the_event ); |
63 |
} |
64 |
|
65 |
void init_bond( int bond_index ){ |
66 |
event* the_event; |
67 |
|
68 |
the_event = (event* )malloc( sizeof( event ) ); |
69 |
|
70 |
the_event->event_type = BOND; |
71 |
the_event->err_msg = NULL; |
72 |
the_event->evt.blk_index = bond_index; |
73 |
|
74 |
if( !event_handler( the_event ) ) interface_error( the_event ); |
75 |
#ifdef IS_MPI |
76 |
throwMPIEvent(the_event); |
77 |
#endif |
78 |
|
79 |
free( the_event ); |
80 |
} |
81 |
|
82 |
void init_bend( int bend_index ){ |
83 |
event* the_event; |
84 |
|
85 |
the_event = (event* )malloc( sizeof( event ) ); |
86 |
|
87 |
the_event->event_type = BEND; |
88 |
the_event->err_msg = NULL; |
89 |
the_event->evt.blk_index = bend_index; |
90 |
|
91 |
if( !event_handler( the_event ) ) interface_error( the_event ); |
92 |
#ifdef IS_MPI |
93 |
throwMPIEvent(the_event); |
94 |
#endif |
95 |
|
96 |
free( the_event ); |
97 |
} |
98 |
|
99 |
void init_torsion( int torsion_index ){ |
100 |
event* the_event; |
101 |
|
102 |
the_event = (event* )malloc( sizeof( event ) ); |
103 |
|
104 |
the_event->event_type = TORSION; |
105 |
the_event->err_msg = NULL; |
106 |
the_event->evt.blk_index = torsion_index; |
107 |
|
108 |
if( !event_handler( the_event ) ) interface_error( the_event ); |
109 |
#ifdef IS_MPI |
110 |
throwMPIEvent(the_event); |
111 |
#endif |
112 |
|
113 |
free( the_event ); |
114 |
} |
115 |
|
116 |
void init_zconstraint( int zconstraint_index ){ |
117 |
event* the_event; |
118 |
|
119 |
the_event = (event* )malloc( sizeof( event ) ); |
120 |
|
121 |
the_event->event_type = ZCONSTRAINT; |
122 |
the_event->err_msg = NULL; |
123 |
the_event->evt.blk_index = zconstraint_index; |
124 |
|
125 |
if( !event_handler( the_event ) ) interface_error( the_event ); |
126 |
#ifdef IS_MPI |
127 |
throwMPIEvent(the_event); |
128 |
#endif |
129 |
|
130 |
free( the_event ); |
131 |
} |
132 |
|
133 |
|
134 |
/* |
135 |
* the next few deal with the statement initializations |
136 |
*/ |
137 |
|
138 |
void init_members( struct node_tag* the_node, |
139 |
struct namespc the_namespc ){ |
140 |
event* the_event; |
141 |
|
142 |
the_event = (event* )malloc( sizeof( event ) ); |
143 |
|
144 |
the_event->event_type = MEMBER; |
145 |
the_event->err_msg = NULL; |
146 |
the_event->evt.mbr.a = the_node->the_data.mbr.a; |
147 |
the_event->evt.mbr.b = the_node->the_data.mbr.b; |
148 |
the_event->evt.mbr.c = the_node->the_data.mbr.c; |
149 |
the_event->evt.mbr.d = the_node->the_data.mbr.d; |
150 |
|
151 |
if( !event_handler( the_event ) ) interface_error( the_event ); |
152 |
#ifdef IS_MPI |
153 |
throwMPIEvent(the_event); |
154 |
#endif |
155 |
|
156 |
free( the_event ); |
157 |
} |
158 |
|
159 |
void init_constraint( struct node_tag* the_node, |
160 |
struct namespc the_namespc ){ |
161 |
event* the_event; |
162 |
|
163 |
the_event = (event* )malloc( sizeof( event ) ); |
164 |
|
165 |
the_event->event_type = CONSTRAINT; |
166 |
the_event->err_msg = NULL; |
167 |
the_event->evt.cnstr = the_node->the_data.cnstr.constraint_val; |
168 |
|
169 |
if( !event_handler( the_event ) ) interface_error( the_event ); |
170 |
#ifdef IS_MPI |
171 |
throwMPIEvent(the_event); |
172 |
#endif |
173 |
|
174 |
free( the_event ); |
175 |
} |
176 |
|
177 |
void init_assignment( struct node_tag* the_node, |
178 |
struct namespc the_namespc ){ |
179 |
event* the_event; |
180 |
|
181 |
the_event = (event* )malloc( sizeof( event ) ); |
182 |
|
183 |
the_event->event_type = ASSIGNMENT; |
184 |
the_event->err_msg = NULL; |
185 |
|
186 |
strcpy( the_event->evt.asmt.lhs, the_node->the_data.asmt.identifier ); |
187 |
switch( the_node->the_data.asmt.type ){ |
188 |
|
189 |
case STR_ASSN: |
190 |
the_event->evt.asmt.asmt_type = STRING; |
191 |
strcpy( the_event->evt.asmt.rhs.sval, |
192 |
the_node->the_data.asmt.rhs.str_ptr ); |
193 |
break; |
194 |
|
195 |
case INT_ASSN: |
196 |
the_event->evt.asmt.asmt_type = INT; |
197 |
the_event->evt.asmt.rhs.ival = the_node->the_data.asmt.rhs.i_val; |
198 |
break; |
199 |
|
200 |
case DOUBLE_ASSN: |
201 |
the_event->evt.asmt.asmt_type = DOUBLE; |
202 |
the_event->evt.asmt.rhs.dval = the_node->the_data.asmt.rhs.d_val; |
203 |
break; |
204 |
} |
205 |
|
206 |
if( !event_handler( the_event ) ) interface_error( the_event ); |
207 |
#ifdef IS_MPI |
208 |
throwMPIEvent(the_event); |
209 |
#endif |
210 |
|
211 |
free( the_event ); |
212 |
} |
213 |
|
214 |
void init_position( struct node_tag* the_node, |
215 |
struct namespc the_namespc ){ |
216 |
event* the_event; |
217 |
|
218 |
the_event = (event* )malloc( sizeof( event ) ); |
219 |
|
220 |
the_event->event_type = POSITION; |
221 |
the_event->err_msg = NULL; |
222 |
the_event->evt.pos.x = the_node->the_data.pos.x; |
223 |
the_event->evt.pos.y = the_node->the_data.pos.y; |
224 |
the_event->evt.pos.z = the_node->the_data.pos.z; |
225 |
|
226 |
if( !event_handler( the_event ) ) interface_error( the_event ); |
227 |
#ifdef IS_MPI |
228 |
throwMPIEvent(the_event); |
229 |
#endif |
230 |
|
231 |
free( the_event ); |
232 |
} |
233 |
|
234 |
void init_orientation( struct node_tag* the_node, |
235 |
struct namespc the_namespc ){ |
236 |
event* the_event; |
237 |
|
238 |
the_event = (event* )malloc( sizeof( event ) ); |
239 |
|
240 |
the_event->event_type = ORIENTATION; |
241 |
the_event->err_msg = NULL; |
242 |
the_event->evt.ornt.x = the_node->the_data.ort.x; |
243 |
the_event->evt.ornt.y = the_node->the_data.ort.y; |
244 |
the_event->evt.ornt.z = the_node->the_data.ort.z; |
245 |
|
246 |
if( !event_handler( the_event ) ) interface_error( the_event ); |
247 |
#ifdef IS_MPI |
248 |
throwMPIEvent(the_event); |
249 |
#endif |
250 |
|
251 |
free( the_event ); |
252 |
} |
253 |
|
254 |
|
255 |
void end_of_block( void ){ |
256 |
event* the_event; |
257 |
|
258 |
the_event = (event* )malloc( sizeof( event ) ); |
259 |
|
260 |
the_event->event_type = BLOCK_END; |
261 |
the_event->err_msg = NULL; |
262 |
|
263 |
if( !event_handler( the_event ) ) interface_error( the_event ); |
264 |
#ifdef IS_MPI |
265 |
throwMPIEvent(the_event); |
266 |
#endif |
267 |
|
268 |
free( the_event ); |
269 |
} |
270 |
|
271 |
void interface_error( event* the_event ){ |
272 |
|
273 |
sprintf( painCave.errMsg, |
274 |
"**Interface event error**\n" |
275 |
"%s\n", |
276 |
the_event->err_msg ); |
277 |
painCave.isFatal = 1; |
278 |
simError(); |
279 |
#ifdef IS_MPI |
280 |
mpiInterfaceExit(); |
281 |
#endif //IS_MPI |
282 |
} |