| 1 | 
mmeineke | 
377 | 
#include <stdio.h> | 
| 2 | 
  | 
  | 
#include <stdlib.h> | 
| 3 | 
  | 
  | 
#include <string.h> | 
| 4 | 
  | 
  | 
 | 
| 5 | 
mmeineke | 
854 | 
#include "parse_interface.h" | 
| 6 | 
  | 
  | 
#include "BASS_interface.h" | 
| 7 | 
  | 
  | 
#include "simError.h" | 
| 8 | 
mmeineke | 
377 | 
#ifdef IS_MPI | 
| 9 | 
mmeineke | 
854 | 
#include "mpiBASS.h" | 
| 10 | 
mmeineke | 
377 | 
#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 | 
gezelter | 
957 | 
void init_rigidbody( int rigidbody_index ){ | 
| 49 | 
  | 
  | 
  event* the_event; | 
| 50 | 
  | 
  | 
 | 
| 51 | 
  | 
  | 
  the_event = (event* )malloc( sizeof( event ) ); | 
| 52 | 
  | 
  | 
   | 
| 53 | 
  | 
  | 
  the_event->event_type = RIGIDBODY; | 
| 54 | 
  | 
  | 
  the_event->err_msg = NULL; | 
| 55 | 
  | 
  | 
  the_event->evt.blk_index = rigidbody_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 | 
gezelter | 
1153 | 
void init_cutoffgroup( int cutoffgroup_index ){ | 
| 66 | 
  | 
  | 
  event* the_event; | 
| 67 | 
  | 
  | 
 | 
| 68 | 
  | 
  | 
  the_event = (event* )malloc( sizeof( event ) ); | 
| 69 | 
  | 
  | 
   | 
| 70 | 
  | 
  | 
  the_event->event_type = CUTOFFGROUP; | 
| 71 | 
  | 
  | 
  the_event->err_msg = NULL; | 
| 72 | 
  | 
  | 
  the_event->evt.blk_index = cutoffgroup_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 | 
mmeineke | 
377 | 
void init_atom( int atom_index ){ | 
| 83 | 
  | 
  | 
  event* the_event; | 
| 84 | 
  | 
  | 
   | 
| 85 | 
  | 
  | 
  the_event = (event* )malloc( sizeof( event ) ); | 
| 86 | 
  | 
  | 
   | 
| 87 | 
  | 
  | 
  the_event->event_type = ATOM; | 
| 88 | 
  | 
  | 
  the_event->err_msg = NULL; | 
| 89 | 
  | 
  | 
  the_event->evt.blk_index = atom_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_bond( int bond_index ){ | 
| 100 | 
  | 
  | 
  event* the_event; | 
| 101 | 
  | 
  | 
 | 
| 102 | 
  | 
  | 
  the_event = (event* )malloc( sizeof( event ) ); | 
| 103 | 
  | 
  | 
   | 
| 104 | 
  | 
  | 
  the_event->event_type = BOND; | 
| 105 | 
  | 
  | 
  the_event->err_msg = NULL; | 
| 106 | 
  | 
  | 
  the_event->evt.blk_index = bond_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_bend( int bend_index ){ | 
| 117 | 
  | 
  | 
  event* the_event; | 
| 118 | 
  | 
  | 
 | 
| 119 | 
  | 
  | 
  the_event = (event* )malloc( sizeof( event ) ); | 
| 120 | 
  | 
  | 
   | 
| 121 | 
  | 
  | 
  the_event->event_type = BEND; | 
| 122 | 
  | 
  | 
  the_event->err_msg = NULL; | 
| 123 | 
  | 
  | 
  the_event->evt.blk_index = bend_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 | 
  | 
  | 
void init_torsion( int torsion_index ){ | 
| 134 | 
  | 
  | 
  event* the_event; | 
| 135 | 
  | 
  | 
 | 
| 136 | 
  | 
  | 
  the_event = (event* )malloc( sizeof( event ) ); | 
| 137 | 
  | 
  | 
   | 
| 138 | 
  | 
  | 
  the_event->event_type = TORSION; | 
| 139 | 
  | 
  | 
  the_event->err_msg = NULL; | 
| 140 | 
  | 
  | 
  the_event->evt.blk_index = torsion_index; | 
| 141 | 
  | 
  | 
 | 
| 142 | 
  | 
  | 
  if( !event_handler( the_event ) ) interface_error( the_event ); | 
| 143 | 
  | 
  | 
#ifdef IS_MPI | 
| 144 | 
  | 
  | 
  throwMPIEvent(the_event); | 
| 145 | 
  | 
  | 
#endif | 
| 146 | 
  | 
  | 
   | 
| 147 | 
  | 
  | 
  free( the_event ); | 
| 148 | 
  | 
  | 
} | 
| 149 | 
  | 
  | 
 | 
| 150 | 
mmeineke | 
675 | 
void init_zconstraint( int zconstraint_index ){ | 
| 151 | 
  | 
  | 
  event* the_event; | 
| 152 | 
mmeineke | 
377 | 
 | 
| 153 | 
mmeineke | 
675 | 
  the_event = (event* )malloc( sizeof( event ) ); | 
| 154 | 
  | 
  | 
   | 
| 155 | 
  | 
  | 
  the_event->event_type = ZCONSTRAINT; | 
| 156 | 
  | 
  | 
  the_event->err_msg = NULL; | 
| 157 | 
  | 
  | 
  the_event->evt.blk_index = zconstraint_index; | 
| 158 | 
  | 
  | 
 | 
| 159 | 
  | 
  | 
  if( !event_handler( the_event ) ) interface_error( the_event ); | 
| 160 | 
  | 
  | 
#ifdef IS_MPI | 
| 161 | 
  | 
  | 
  throwMPIEvent(the_event); | 
| 162 | 
  | 
  | 
#endif | 
| 163 | 
  | 
  | 
   | 
| 164 | 
  | 
  | 
  free( the_event ); | 
| 165 | 
  | 
  | 
} | 
| 166 | 
  | 
  | 
 | 
| 167 | 
  | 
  | 
 | 
| 168 | 
mmeineke | 
377 | 
/* | 
| 169 | 
  | 
  | 
 * the next few deal with the statement initializations  | 
| 170 | 
  | 
  | 
 */ | 
| 171 | 
  | 
  | 
 | 
| 172 | 
  | 
  | 
void init_members( struct node_tag* the_node,  | 
| 173 | 
  | 
  | 
                   struct namespc the_namespc ){ | 
| 174 | 
  | 
  | 
  event* the_event; | 
| 175 | 
gezelter | 
998 | 
  int i; | 
| 176 | 
mmeineke | 
377 | 
 | 
| 177 | 
  | 
  | 
  the_event = (event* )malloc( sizeof( event ) ); | 
| 178 | 
  | 
  | 
   | 
| 179 | 
gezelter | 
988 | 
  the_event->event_type = MEMBERS; | 
| 180 | 
mmeineke | 
377 | 
  the_event->err_msg = NULL; | 
| 181 | 
  | 
  | 
 | 
| 182 | 
gezelter | 
998 | 
  the_event->evt.mbrs.nMembers = the_node->the_data.mbrs.nMembers; | 
| 183 | 
  | 
  | 
 | 
| 184 | 
  | 
  | 
  the_event->evt.mbrs.memberList = (int *) calloc(the_node->the_data.mbrs.nMembers,  | 
| 185 | 
  | 
  | 
                                                  sizeof(int)); | 
| 186 | 
  | 
  | 
 | 
| 187 | 
  | 
  | 
  for (i = 0; i < the_node->the_data.mbrs.nMembers; i++) { | 
| 188 | 
  | 
  | 
    the_event->evt.mbrs.memberList[i] = the_node->the_data.mbrs.memberList[i]; | 
| 189 | 
  | 
  | 
  } | 
| 190 | 
  | 
  | 
   | 
| 191 | 
mmeineke | 
377 | 
  if( !event_handler( the_event ) ) interface_error( the_event ); | 
| 192 | 
  | 
  | 
#ifdef IS_MPI | 
| 193 | 
  | 
  | 
  throwMPIEvent(the_event); | 
| 194 | 
  | 
  | 
#endif | 
| 195 | 
  | 
  | 
   | 
| 196 | 
gezelter | 
998 | 
  free( the_event->evt.mbrs.memberList ); | 
| 197 | 
mmeineke | 
377 | 
  free( the_event ); | 
| 198 | 
  | 
  | 
} | 
| 199 | 
  | 
  | 
 | 
| 200 | 
  | 
  | 
void init_constraint( struct node_tag* the_node,  | 
| 201 | 
  | 
  | 
                      struct namespc the_namespc ){ | 
| 202 | 
  | 
  | 
  event* the_event; | 
| 203 | 
  | 
  | 
 | 
| 204 | 
  | 
  | 
  the_event = (event* )malloc( sizeof( event ) ); | 
| 205 | 
  | 
  | 
   | 
| 206 | 
  | 
  | 
  the_event->event_type = CONSTRAINT; | 
| 207 | 
  | 
  | 
  the_event->err_msg = NULL; | 
| 208 | 
  | 
  | 
  the_event->evt.cnstr = the_node->the_data.cnstr.constraint_val; | 
| 209 | 
  | 
  | 
 | 
| 210 | 
  | 
  | 
  if( !event_handler( the_event ) ) interface_error( the_event ); | 
| 211 | 
  | 
  | 
#ifdef IS_MPI | 
| 212 | 
  | 
  | 
  throwMPIEvent(the_event); | 
| 213 | 
  | 
  | 
#endif | 
| 214 | 
  | 
  | 
   | 
| 215 | 
  | 
  | 
  free( the_event ); | 
| 216 | 
  | 
  | 
} | 
| 217 | 
  | 
  | 
 | 
| 218 | 
  | 
  | 
void init_assignment( struct node_tag* the_node,  | 
| 219 | 
  | 
  | 
                      struct namespc the_namespc ){ | 
| 220 | 
  | 
  | 
  event* the_event; | 
| 221 | 
  | 
  | 
 | 
| 222 | 
  | 
  | 
  the_event = (event* )malloc( sizeof( event ) ); | 
| 223 | 
  | 
  | 
   | 
| 224 | 
  | 
  | 
  the_event->event_type = ASSIGNMENT; | 
| 225 | 
  | 
  | 
  the_event->err_msg = NULL; | 
| 226 | 
  | 
  | 
 | 
| 227 | 
  | 
  | 
  strcpy( the_event->evt.asmt.lhs, the_node->the_data.asmt.identifier ); | 
| 228 | 
  | 
  | 
  switch( the_node->the_data.asmt.type ){ | 
| 229 | 
  | 
  | 
     | 
| 230 | 
  | 
  | 
  case STR_ASSN: | 
| 231 | 
  | 
  | 
    the_event->evt.asmt.asmt_type = STRING; | 
| 232 | 
  | 
  | 
    strcpy( the_event->evt.asmt.rhs.sval, | 
| 233 | 
  | 
  | 
            the_node->the_data.asmt.rhs.str_ptr ); | 
| 234 | 
  | 
  | 
    break; | 
| 235 | 
  | 
  | 
 | 
| 236 | 
  | 
  | 
  case INT_ASSN: | 
| 237 | 
  | 
  | 
    the_event->evt.asmt.asmt_type = INT; | 
| 238 | 
  | 
  | 
    the_event->evt.asmt.rhs.ival = the_node->the_data.asmt.rhs.i_val; | 
| 239 | 
  | 
  | 
    break; | 
| 240 | 
  | 
  | 
 | 
| 241 | 
  | 
  | 
  case DOUBLE_ASSN: | 
| 242 | 
  | 
  | 
    the_event->evt.asmt.asmt_type = DOUBLE; | 
| 243 | 
  | 
  | 
    the_event->evt.asmt.rhs.dval = the_node->the_data.asmt.rhs.d_val; | 
| 244 | 
  | 
  | 
    break; | 
| 245 | 
  | 
  | 
  } | 
| 246 | 
  | 
  | 
 | 
| 247 | 
  | 
  | 
  if( !event_handler( the_event ) ) interface_error( the_event ); | 
| 248 | 
  | 
  | 
#ifdef IS_MPI | 
| 249 | 
  | 
  | 
  throwMPIEvent(the_event); | 
| 250 | 
  | 
  | 
#endif | 
| 251 | 
  | 
  | 
   | 
| 252 | 
  | 
  | 
  free( the_event ); | 
| 253 | 
  | 
  | 
} | 
| 254 | 
  | 
  | 
 | 
| 255 | 
  | 
  | 
void init_position( struct node_tag* the_node,  | 
| 256 | 
  | 
  | 
                    struct namespc the_namespc ){ | 
| 257 | 
  | 
  | 
  event* the_event; | 
| 258 | 
  | 
  | 
 | 
| 259 | 
  | 
  | 
  the_event = (event* )malloc( sizeof( event ) ); | 
| 260 | 
  | 
  | 
   | 
| 261 | 
  | 
  | 
  the_event->event_type = POSITION; | 
| 262 | 
  | 
  | 
  the_event->err_msg = NULL; | 
| 263 | 
  | 
  | 
  the_event->evt.pos.x = the_node->the_data.pos.x; | 
| 264 | 
  | 
  | 
  the_event->evt.pos.y = the_node->the_data.pos.y; | 
| 265 | 
  | 
  | 
  the_event->evt.pos.z = the_node->the_data.pos.z; | 
| 266 | 
  | 
  | 
 | 
| 267 | 
  | 
  | 
  if( !event_handler( the_event ) ) interface_error( the_event ); | 
| 268 | 
  | 
  | 
#ifdef IS_MPI | 
| 269 | 
  | 
  | 
  throwMPIEvent(the_event); | 
| 270 | 
  | 
  | 
#endif | 
| 271 | 
  | 
  | 
   | 
| 272 | 
  | 
  | 
  free( the_event ); | 
| 273 | 
  | 
  | 
} | 
| 274 | 
  | 
  | 
 | 
| 275 | 
  | 
  | 
void init_orientation( struct node_tag* the_node,  | 
| 276 | 
  | 
  | 
                       struct namespc the_namespc ){ | 
| 277 | 
  | 
  | 
  event* the_event; | 
| 278 | 
  | 
  | 
 | 
| 279 | 
  | 
  | 
  the_event = (event* )malloc( sizeof( event ) ); | 
| 280 | 
  | 
  | 
   | 
| 281 | 
  | 
  | 
  the_event->event_type = ORIENTATION; | 
| 282 | 
  | 
  | 
  the_event->err_msg = NULL; | 
| 283 | 
gezelter | 
998 | 
  the_event->evt.ornt.phi   = the_node->the_data.ort.phi; | 
| 284 | 
  | 
  | 
  the_event->evt.ornt.theta = the_node->the_data.ort.theta; | 
| 285 | 
  | 
  | 
  the_event->evt.ornt.psi   = the_node->the_data.ort.psi; | 
| 286 | 
mmeineke | 
377 | 
 | 
| 287 | 
  | 
  | 
  if( !event_handler( the_event ) ) interface_error( the_event ); | 
| 288 | 
  | 
  | 
#ifdef IS_MPI | 
| 289 | 
  | 
  | 
  throwMPIEvent(the_event); | 
| 290 | 
  | 
  | 
#endif | 
| 291 | 
  | 
  | 
   | 
| 292 | 
  | 
  | 
  free( the_event ); | 
| 293 | 
  | 
  | 
} | 
| 294 | 
  | 
  | 
 | 
| 295 | 
  | 
  | 
 | 
| 296 | 
  | 
  | 
void end_of_block( void ){ | 
| 297 | 
  | 
  | 
  event* the_event; | 
| 298 | 
  | 
  | 
   | 
| 299 | 
  | 
  | 
  the_event = (event* )malloc( sizeof( event ) ); | 
| 300 | 
  | 
  | 
   | 
| 301 | 
  | 
  | 
  the_event->event_type = BLOCK_END; | 
| 302 | 
  | 
  | 
  the_event->err_msg = NULL; | 
| 303 | 
  | 
  | 
 | 
| 304 | 
  | 
  | 
  if( !event_handler( the_event ) ) interface_error( the_event ); | 
| 305 | 
  | 
  | 
#ifdef IS_MPI | 
| 306 | 
  | 
  | 
  throwMPIEvent(the_event); | 
| 307 | 
  | 
  | 
#endif | 
| 308 | 
  | 
  | 
   | 
| 309 | 
  | 
  | 
  free( the_event ); | 
| 310 | 
  | 
  | 
} | 
| 311 | 
  | 
  | 
 | 
| 312 | 
  | 
  | 
void interface_error( event* the_event ){ | 
| 313 | 
  | 
  | 
 | 
| 314 | 
  | 
  | 
  sprintf( painCave.errMsg, | 
| 315 | 
  | 
  | 
           "**Interface event error**\n" | 
| 316 | 
  | 
  | 
           "%s\n", | 
| 317 | 
  | 
  | 
           the_event->err_msg ); | 
| 318 | 
  | 
  | 
  painCave.isFatal = 1; | 
| 319 | 
  | 
  | 
  simError(); | 
| 320 | 
  | 
  | 
#ifdef IS_MPI | 
| 321 | 
  | 
  | 
  mpiInterfaceExit(); | 
| 322 | 
  | 
  | 
#endif //IS_MPI | 
| 323 | 
  | 
  | 
} |