ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/mdtools/BASS_parse/interface.c
Revision: 163
Committed: Tue Nov 5 22:04:42 2002 UTC (21 years, 8 months ago) by mmeineke
Content type: text/plain
File size: 5957 byte(s)
Log Message:
adding simError into the mpiBASS Event loop

File Contents

# User Rev Content
1 mmeineke 10 #include <stdio.h>
2     #include <stdlib.h>
3 mmeineke 117 #include <string.h>
4 mmeineke 10
5     #include "interface.h"
6     #include "../headers/BASS_interface.h"
7 mmeineke 157 #include "../headers/simError.h"
8 chuckv 131 #ifdef IS_MPI
9 chuckv 138 #include "../headers/mpiBASS.h"
10 chuckv 131 #endif
11 mmeineke 10
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 chuckv 131 #ifdef IS_MPI
25 chuckv 118 throwMPIEvent(the_event);
26     #endif
27    
28 mmeineke 10 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 chuckv 131 #ifdef IS_MPI
42 chuckv 118 throwMPIEvent(the_event);
43     #endif
44 mmeineke 10
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 chuckv 131 #ifdef IS_MPI
59 chuckv 118 throwMPIEvent(the_event);
60     #endif
61 mmeineke 10
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 chuckv 131 #ifdef IS_MPI
76 chuckv 118 throwMPIEvent(the_event);
77     #endif
78 mmeineke 10
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 chuckv 131 #ifdef IS_MPI
93 chuckv 118 throwMPIEvent(the_event);
94     #endif
95 mmeineke 10
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 chuckv 131 #ifdef IS_MPI
110 chuckv 118 throwMPIEvent(the_event);
111     #endif
112 mmeineke 10
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 chuckv 131 #ifdef IS_MPI
136 chuckv 118 throwMPIEvent(the_event);
137     #endif
138 mmeineke 10
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 chuckv 131 #ifdef IS_MPI
154 chuckv 118 throwMPIEvent(the_event);
155     #endif
156 mmeineke 10
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 chuckv 131 #ifdef IS_MPI
191 chuckv 118 throwMPIEvent(the_event);
192     #endif
193 mmeineke 10
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 chuckv 131 #ifdef IS_MPI
211 chuckv 118 throwMPIEvent(the_event);
212     #endif
213 mmeineke 10
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 chuckv 131 #ifdef IS_MPI
231 chuckv 118 throwMPIEvent(the_event);
232     #endif
233 mmeineke 10
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 chuckv 131 #ifdef IS_MPI
248 chuckv 118 throwMPIEvent(the_event);
249     #endif
250 mmeineke 10
251     free( the_event );
252     }
253    
254     void interface_error( event* the_event ){
255    
256 mmeineke 157 sprintf( painCave.errMsg,
257 mmeineke 10 "**Interface event error**\n"
258     "%s\n",
259     the_event->err_msg );
260 mmeineke 160 simError();
261 mmeineke 163 mpiInterfaceExit();
262 mmeineke 10 }