1 |
#include <stdio.h> |
2 |
#include <stdlib.h> |
3 |
#include <string.h> |
4 |
|
5 |
#include <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 |
|
117 |
/* |
118 |
* the next few deal with the statement initializations |
119 |
*/ |
120 |
|
121 |
void init_members( struct node_tag* the_node, |
122 |
struct namespc the_namespc ){ |
123 |
event* the_event; |
124 |
|
125 |
the_event = (event* )malloc( sizeof( event ) ); |
126 |
|
127 |
the_event->event_type = MEMBER; |
128 |
the_event->err_msg = NULL; |
129 |
the_event->evt.mbr.a = the_node->the_data.mbr.a; |
130 |
the_event->evt.mbr.b = the_node->the_data.mbr.b; |
131 |
the_event->evt.mbr.c = the_node->the_data.mbr.c; |
132 |
the_event->evt.mbr.d = the_node->the_data.mbr.d; |
133 |
|
134 |
if( !event_handler( the_event ) ) interface_error( the_event ); |
135 |
#ifdef IS_MPI |
136 |
throwMPIEvent(the_event); |
137 |
#endif |
138 |
|
139 |
free( the_event ); |
140 |
} |
141 |
|
142 |
void init_constraint( struct node_tag* the_node, |
143 |
struct namespc the_namespc ){ |
144 |
event* the_event; |
145 |
|
146 |
the_event = (event* )malloc( sizeof( event ) ); |
147 |
|
148 |
the_event->event_type = CONSTRAINT; |
149 |
the_event->err_msg = NULL; |
150 |
the_event->evt.cnstr = the_node->the_data.cnstr.constraint_val; |
151 |
|
152 |
if( !event_handler( the_event ) ) interface_error( the_event ); |
153 |
#ifdef IS_MPI |
154 |
throwMPIEvent(the_event); |
155 |
#endif |
156 |
|
157 |
free( the_event ); |
158 |
} |
159 |
|
160 |
void init_assignment( struct node_tag* the_node, |
161 |
struct namespc the_namespc ){ |
162 |
event* the_event; |
163 |
|
164 |
the_event = (event* )malloc( sizeof( event ) ); |
165 |
|
166 |
the_event->event_type = ASSIGNMENT; |
167 |
the_event->err_msg = NULL; |
168 |
|
169 |
strcpy( the_event->evt.asmt.lhs, the_node->the_data.asmt.identifier ); |
170 |
switch( the_node->the_data.asmt.type ){ |
171 |
|
172 |
case STR_ASSN: |
173 |
the_event->evt.asmt.asmt_type = STRING; |
174 |
strcpy( the_event->evt.asmt.rhs.sval, |
175 |
the_node->the_data.asmt.rhs.str_ptr ); |
176 |
break; |
177 |
|
178 |
case INT_ASSN: |
179 |
the_event->evt.asmt.asmt_type = INT; |
180 |
the_event->evt.asmt.rhs.ival = the_node->the_data.asmt.rhs.i_val; |
181 |
break; |
182 |
|
183 |
case DOUBLE_ASSN: |
184 |
the_event->evt.asmt.asmt_type = DOUBLE; |
185 |
the_event->evt.asmt.rhs.dval = the_node->the_data.asmt.rhs.d_val; |
186 |
break; |
187 |
} |
188 |
|
189 |
if( !event_handler( the_event ) ) interface_error( the_event ); |
190 |
#ifdef IS_MPI |
191 |
throwMPIEvent(the_event); |
192 |
#endif |
193 |
|
194 |
free( the_event ); |
195 |
} |
196 |
|
197 |
void init_position( struct node_tag* the_node, |
198 |
struct namespc the_namespc ){ |
199 |
event* the_event; |
200 |
|
201 |
the_event = (event* )malloc( sizeof( event ) ); |
202 |
|
203 |
the_event->event_type = POSITION; |
204 |
the_event->err_msg = NULL; |
205 |
the_event->evt.pos.x = the_node->the_data.pos.x; |
206 |
the_event->evt.pos.y = the_node->the_data.pos.y; |
207 |
the_event->evt.pos.z = the_node->the_data.pos.z; |
208 |
|
209 |
if( !event_handler( the_event ) ) interface_error( the_event ); |
210 |
#ifdef IS_MPI |
211 |
throwMPIEvent(the_event); |
212 |
#endif |
213 |
|
214 |
free( the_event ); |
215 |
} |
216 |
|
217 |
void init_orientation( struct node_tag* the_node, |
218 |
struct namespc the_namespc ){ |
219 |
event* the_event; |
220 |
|
221 |
the_event = (event* )malloc( sizeof( event ) ); |
222 |
|
223 |
the_event->event_type = ORIENTATION; |
224 |
the_event->err_msg = NULL; |
225 |
the_event->evt.ornt.x = the_node->the_data.ort.x; |
226 |
the_event->evt.ornt.y = the_node->the_data.ort.y; |
227 |
the_event->evt.ornt.z = the_node->the_data.ort.z; |
228 |
|
229 |
if( !event_handler( the_event ) ) interface_error( the_event ); |
230 |
#ifdef IS_MPI |
231 |
throwMPIEvent(the_event); |
232 |
#endif |
233 |
|
234 |
free( the_event ); |
235 |
} |
236 |
|
237 |
|
238 |
void end_of_block( void ){ |
239 |
event* the_event; |
240 |
|
241 |
the_event = (event* )malloc( sizeof( event ) ); |
242 |
|
243 |
the_event->event_type = BLOCK_END; |
244 |
the_event->err_msg = NULL; |
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 |
void interface_error( event* the_event ){ |
255 |
|
256 |
sprintf( painCave.errMsg, |
257 |
"**Interface event error**\n" |
258 |
"%s\n", |
259 |
the_event->err_msg ); |
260 |
painCave.isFatal = 1; |
261 |
simError(); |
262 |
#ifdef IS_MPI |
263 |
mpiInterfaceExit(); |
264 |
#endif //IS_MPI |
265 |
} |