ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/mdtools/BASS_parse/interface.c
Revision: 138
Committed: Wed Oct 16 21:07:02 2002 UTC (21 years, 8 months ago) by chuckv
Content type: text/plain
File size: 5890 byte(s)
Log Message:

changed mpiInterface.c and .h -> mpiBASS.c and .h for clarity of purpose

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