| 79 |
|
} |
| 80 |
|
|
| 81 |
|
/* |
| 82 |
< |
The next three functions deal with creating and initializing of the |
| 83 |
< |
members statements used by the bonds, bends, and torsions. |
| 82 |
> |
The next function deals with creating and initializing of the |
| 83 |
> |
members statements used by the bonds, bends, torsions, rigid bodies, |
| 84 |
> |
and cutoff groups. |
| 85 |
|
*/ |
| 86 |
|
|
| 87 |
< |
struct node_tag* members_2( int a, int b ){ |
| 87 |
> |
struct node_tag* members( char* list_str ){ |
| 88 |
|
|
| 89 |
|
struct node_tag* the_node; |
| 90 |
|
the_node = ( struct node_tag* )malloc( sizeof( node ) ); |
| 91 |
|
|
| 92 |
< |
the_node->type = MEMBER_STMT; |
| 92 |
> |
the_node->type = MEMBERS_STMT; |
| 93 |
|
the_node->index = 0; |
| 94 |
|
the_node->next_stmt = NULL; |
| 95 |
|
the_node->prev_stmt = NULL; |
| 96 |
|
the_node->stmt_list = NULL; |
| 97 |
|
|
| 98 |
< |
the_node->the_data.mbr.a = a; |
| 99 |
< |
the_node->the_data.mbr.b = b; |
| 99 |
< |
the_node->the_data.mbr.c = 0; |
| 100 |
< |
the_node->the_data.mbr.d = 0; |
| 98 |
> |
int nTokens, i; |
| 99 |
> |
char *foo; |
| 100 |
|
|
| 101 |
< |
return the_node; |
| 103 |
< |
} |
| 101 |
> |
nTokens = count_tokens(list_str, " ,;\t"); |
| 102 |
|
|
| 103 |
< |
struct node_tag* members_3( int a, int b, int c ){ |
| 103 |
> |
if (nTokens < 1) { |
| 104 |
> |
yyerror("can't find any members in this members statement"); |
| 105 |
> |
} |
| 106 |
|
|
| 107 |
< |
struct node_tag* the_node; |
| 108 |
< |
the_node = ( struct node_tag* )malloc( sizeof( node ) ); |
| 109 |
< |
|
| 110 |
< |
the_node->type = MEMBER_STMT; |
| 111 |
< |
the_node->index = 0; |
| 112 |
< |
the_node->next_stmt = NULL; |
| 113 |
< |
the_node->prev_stmt = NULL; |
| 114 |
< |
the_node->stmt_list = NULL; |
| 115 |
< |
|
| 116 |
< |
the_node->the_data.mbr.a = a; |
| 117 |
< |
the_node->the_data.mbr.b = b; |
| 118 |
< |
the_node->the_data.mbr.c = c; |
| 119 |
< |
the_node->the_data.mbr.d = 0; |
| 107 |
> |
the_node->the_data.mbrs.nMembers = nTokens; |
| 108 |
|
|
| 109 |
< |
return the_node; |
| 122 |
< |
} |
| 109 |
> |
the_node->the_data.mbrs.memberList = (int *) calloc(nTokens, sizeof(int)); |
| 110 |
|
|
| 111 |
< |
struct node_tag* members_4( int a, int b, int c, int d ){ |
| 111 |
> |
foo = strtok(list_str, " ,;\t"); |
| 112 |
> |
the_node->the_data.mbrs.memberList[0] = atoi( foo ); |
| 113 |
|
|
| 114 |
< |
struct node_tag* the_node; |
| 115 |
< |
the_node = ( struct node_tag* )malloc( sizeof( node ) ); |
| 116 |
< |
|
| 117 |
< |
the_node->type = MEMBER_STMT; |
| 130 |
< |
the_node->index = 0; |
| 131 |
< |
the_node->next_stmt = NULL; |
| 132 |
< |
the_node->prev_stmt = NULL; |
| 133 |
< |
the_node->stmt_list = NULL; |
| 134 |
< |
|
| 135 |
< |
the_node->the_data.mbr.a = a; |
| 136 |
< |
the_node->the_data.mbr.b = b; |
| 137 |
< |
the_node->the_data.mbr.c = c; |
| 138 |
< |
the_node->the_data.mbr.d = d; |
| 114 |
> |
for (i = 1; i < nTokens; i++) { |
| 115 |
> |
foo = strtok(NULL, " ,;\t"); |
| 116 |
> |
the_node->the_data.mbrs.memberList[i] = atoi( foo ); |
| 117 |
> |
} |
| 118 |
|
|
| 119 |
|
return the_node; |
| 120 |
|
} |
| 123 |
|
This function does the C & I of the constraint statements |
| 124 |
|
*/ |
| 125 |
|
|
| 126 |
< |
struct node_tag* constraint( double constraint_val ){ |
| 126 |
> |
struct node_tag* constraint( char* list_str ){ |
| 127 |
|
|
| 128 |
|
struct node_tag* the_node; |
| 129 |
|
the_node = ( struct node_tag* )malloc( sizeof( node ) ); |
| 134 |
|
the_node->prev_stmt = NULL; |
| 135 |
|
the_node->stmt_list = NULL; |
| 136 |
|
|
| 137 |
< |
the_node->the_data.cnstr.constraint_val = constraint_val; |
| 137 |
> |
int nTokens; |
| 138 |
> |
char *foo; |
| 139 |
|
|
| 140 |
+ |
nTokens = count_tokens(list_str, " ,;\t"); |
| 141 |
+ |
if (nTokens != 1) { |
| 142 |
+ |
yyerror("wrong number of arguments given in constraint statement"); |
| 143 |
+ |
} |
| 144 |
+ |
|
| 145 |
+ |
foo = strtok(list_str, " ,;\t"); |
| 146 |
+ |
the_node->the_data.cnstr.constraint_val = atof( foo ); |
| 147 |
+ |
|
| 148 |
|
return the_node; |
| 149 |
|
} |
| 150 |
|
|
| 152 |
|
This function does the C & I for the orientation statements |
| 153 |
|
*/ |
| 154 |
|
|
| 155 |
< |
struct node_tag* orientation( double x, double y, double z ){ |
| 155 |
> |
struct node_tag* orientation( char* list_str ){ |
| 156 |
|
|
| 157 |
|
struct node_tag* the_node; |
| 158 |
|
the_node = ( struct node_tag* )malloc( sizeof( node ) ); |
| 162 |
|
the_node->next_stmt = NULL; |
| 163 |
|
the_node->prev_stmt = NULL; |
| 164 |
|
the_node->stmt_list = NULL; |
| 165 |
< |
|
| 166 |
< |
the_node->the_data.pos.x = x; |
| 167 |
< |
the_node->the_data.pos.y = y; |
| 168 |
< |
the_node->the_data.pos.z = z; |
| 169 |
< |
|
| 165 |
> |
|
| 166 |
> |
int nTokens; |
| 167 |
> |
char *foo; |
| 168 |
> |
|
| 169 |
> |
nTokens = count_tokens(list_str, " ,;\t"); |
| 170 |
> |
if (nTokens != 3) { |
| 171 |
> |
yyerror("wrong number of arguments given in orientation"); |
| 172 |
> |
} |
| 173 |
> |
|
| 174 |
> |
foo = strtok(list_str, " ,;\t"); |
| 175 |
> |
the_node->the_data.ort.phi = atof( foo ); |
| 176 |
> |
|
| 177 |
> |
foo = strtok(NULL, " ,;\t"); |
| 178 |
> |
the_node->the_data.ort.theta = atof( foo ); |
| 179 |
> |
|
| 180 |
> |
foo = strtok(NULL, " ,;\t"); |
| 181 |
> |
the_node->the_data.ort.psi = atof( foo ); |
| 182 |
> |
|
| 183 |
|
return the_node; |
| 184 |
|
} |
| 185 |
|
|
| 187 |
|
This function does the C & I for the position statements |
| 188 |
|
*/ |
| 189 |
|
|
| 190 |
< |
struct node_tag* position( double x, double y, double z ){ |
| 190 |
> |
struct node_tag* position( char* list_str ){ |
| 191 |
|
|
| 192 |
|
struct node_tag* the_node; |
| 193 |
|
the_node = ( struct node_tag* )malloc( sizeof( node ) ); |
| 197 |
|
the_node->next_stmt = NULL; |
| 198 |
|
the_node->prev_stmt = NULL; |
| 199 |
|
the_node->stmt_list = NULL; |
| 200 |
+ |
|
| 201 |
+ |
int nTokens; |
| 202 |
+ |
char *foo; |
| 203 |
+ |
|
| 204 |
+ |
nTokens = count_tokens(list_str, " ,;\t"); |
| 205 |
+ |
if (nTokens != 3) { |
| 206 |
+ |
yyerror("wrong number of arguments given in position"); |
| 207 |
+ |
} |
| 208 |
+ |
|
| 209 |
+ |
foo = strtok(list_str, " ,;\t"); |
| 210 |
+ |
the_node->the_data.pos.x = atof( foo ); |
| 211 |
+ |
|
| 212 |
+ |
foo = strtok(NULL, " ,;\t"); |
| 213 |
+ |
the_node->the_data.pos.y = atof( foo ); |
| 214 |
+ |
|
| 215 |
+ |
foo = strtok(NULL, " ,;\t"); |
| 216 |
+ |
the_node->the_data.pos.z = atof( foo ); |
| 217 |
+ |
|
| 218 |
|
|
| 200 |
– |
the_node->the_data.pos.x = x; |
| 201 |
– |
the_node->the_data.pos.y = y; |
| 202 |
– |
the_node->the_data.pos.z = z; |
| 203 |
– |
|
| 219 |
|
return the_node; |
| 220 |
|
} |
| 221 |
|
|
| 244 |
|
the_node = ( struct node_tag* )malloc( sizeof( node ) ); |
| 245 |
|
|
| 246 |
|
the_node->type = RIGIDBODY_HEAD; |
| 247 |
< |
the_node->index = 0; |
| 247 |
> |
the_node->index = index; |
| 248 |
|
the_node->next_stmt = NULL; |
| 249 |
|
the_node->prev_stmt = NULL; |
| 250 |
|
the_node->stmt_list = walk_to_top( stmt_list ); |
| 252 |
|
return the_node; |
| 253 |
|
} |
| 254 |
|
|
| 255 |
+ |
struct node_tag* cutoffgroup_blk( int index, struct node_tag* stmt_list ){ |
| 256 |
+ |
|
| 257 |
+ |
struct node_tag* the_node; |
| 258 |
+ |
the_node = ( struct node_tag* )malloc( sizeof( node ) ); |
| 259 |
+ |
|
| 260 |
+ |
// The guillotine statement: |
| 261 |
+ |
the_node->type = CUTOFFGROUP_HEAD; |
| 262 |
+ |
the_node->index = index; |
| 263 |
+ |
the_node->next_stmt = NULL; |
| 264 |
+ |
the_node->prev_stmt = NULL; |
| 265 |
+ |
the_node->stmt_list = walk_to_top( stmt_list ); |
| 266 |
+ |
|
| 267 |
+ |
return the_node; |
| 268 |
+ |
} |
| 269 |
+ |
|
| 270 |
|
struct node_tag* atom_blk( int index, struct node_tag* stmt_list ){ |
| 271 |
|
|
| 272 |
|
struct node_tag* the_node; |
| 350 |
|
|
| 351 |
|
return the_node; |
| 352 |
|
} |
| 353 |
+ |
|
| 354 |
+ |
|
| 355 |
+ |
int count_tokens(char *line, char *delimiters) { |
| 356 |
+ |
/* PURPOSE: RETURN A COUNT OF THE NUMBER OF TOKENS ON THE LINE. */ |
| 357 |
+ |
|
| 358 |
+ |
char *working_line; /* WORKING COPY OF LINE. */ |
| 359 |
+ |
int ntokens; /* NUMBER OF TOKENS FOUND IN LINE. */ |
| 360 |
+ |
char *strtok_ptr; /* POINTER FOR STRTOK. */ |
| 361 |
+ |
|
| 362 |
+ |
strtok_ptr= working_line= strdup(line); |
| 363 |
+ |
|
| 364 |
+ |
ntokens=0; |
| 365 |
+ |
while (strtok(strtok_ptr,delimiters)!=NULL) |
| 366 |
+ |
{ |
| 367 |
+ |
ntokens++; |
| 368 |
+ |
strtok_ptr=NULL; |
| 369 |
+ |
} |
| 370 |
+ |
|
| 371 |
+ |
free(working_line); |
| 372 |
+ |
return(ntokens); |
| 373 |
+ |
} |