ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/mdtools/BASS_parse/interface.c
Revision: 118
Committed: Wed Sep 25 22:51:14 2002 UTC (21 years, 9 months ago) by chuckv
Content type: text/plain
File size: 5801 byte(s)
Log Message:
begin the pain that is MPI.

abandon all hope ye who check out this branch..

P.S. we've added consistent BASS error checking

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