ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/tcProps/tcProps.c
Revision: 1072
Committed: Fri Feb 27 20:39:17 2004 UTC (20 years, 4 months ago) by mmeineke
Content type: text/plain
File size: 10231 byte(s)
Log Message:
started work on rmsd

File Contents

# Content
1 #define _FILE_OFFSET_BITS 64
2
3 #include <stdio.h>
4 #include <stdlib.h>
5 #include <string.h>
6
7
8 #include "params.h"
9 #include "tcProps.h"
10 #include "readWrite.h"
11 #include "scdCorr.h"
12 #include "directorHead.h"
13 #include "directorWhole.h"
14 #inlcude "rmsd.h"
15
16
17 #define VERSION_MAJOR 0
18 #define VERSION_MINOR 1
19
20 char *programName; /*the name of the program */
21 void usage(void);
22
23 int main( int argC, char *argV[] ){
24
25 // list of 'a priori' constants
26
27 const int nLipAtoms = NL_ATOMS;
28 const int nBonds = NBONDS;
29 const int nLipids = NLIPIDS;
30 const int nSSD = NSSD;
31 const int nAtoms = nLipAtoms * nLipids + nSSD;
32
33 // different needed variables
34
35 struct atomCoord atoms[nAtoms];
36 int i,j,k;
37
38 char* outPrefix; // the output prefix
39 char currentFlag; // used in parsing the flags
40 int done = 0; // multipurpose boolean
41 int havePrefix; // boolean for the output prefix
42 int haveMaxLength;
43 char* conversionCheck;
44 int conversionError;
45 int optionError;
46 char* pair1;
47 char* pair2;
48 int scdCorr;
49 double startTime;
50 double maxLength;
51 int directorHead, directorWhole;
52
53 // system initialization
54
55 isScanned = 0;
56 fileOpen = 0;
57 nFrames = 0;
58 frameTimes = NULL;
59
60 outPrefix = NULL;
61 inName = NULL;
62
63 haveMaxLength = 0;
64 conversionError = 0;
65 optionError = 0;
66 havePrefix = 0;
67 scdCorr = 0;
68 startTime = 0.0;
69 directorHead = 0;
70 directorWhole = 0;
71
72
73 // parse the command line
74
75 programName = argV[0]; /*save the program name in case we need it*/
76
77 for( i = 1; i < argC; i++){
78
79 if(argV[i][0] =='-'){
80
81 // parse the option
82
83 if(argV[i][1] == '-' ){
84
85 // parse long word options
86
87 if( !strcmp( argV[i], "--gofr" ) ){
88
89 i++;
90 if( i>=argC ){
91 fprintf( stderr,
92 "\n"
93 "not enough arguments for --gofr\n");
94 usage();
95 exit(0);
96 }
97 pair1 = argV[i];
98
99 i++;
100 if( i>=argC ){
101 fprintf( stderr,
102 "\n"
103 "not enough arguments for --gofr\n");
104 usage();
105 exit(0);
106 }
107 pair2 = argV[i];
108
109 }
110
111 else if( !strcmp( argV[i], "--gofrTheta" ) ){
112
113 i++;
114 if( i>=argC ){
115 fprintf( stderr,
116 "\n"
117 "not enough arguments for --gofrTheta\n");
118 usage();
119 exit(0);
120 }
121 pair1 = argV[i];
122
123 i++;
124 if( i>=argC ){
125 fprintf( stderr,
126 "\n"
127 "not enough arguments for --gofrTheta\n");
128 usage();
129 exit(0);
130 }
131 pair2 = argV[i];
132
133 }
134
135 else if( !strcmp( argV[i], "--gofrOmega" ) ){
136
137 i++;
138 if( i>=argC ){
139 fprintf( stderr,
140 "\n"
141 "not enough arguments for --gofrOmega\n");
142 usage();
143 exit(0);
144 }
145 pair1 = argV[i];
146
147 i++;
148 if( i>=argC ){
149 fprintf( stderr,
150 "\n"
151 "not enough arguments for --gofrOmega\n");
152 usage();
153 exit(0);
154 }
155 pair2 = argV[i];
156
157 }
158
159 else if( !strcmp( argV[i], "--version") ){
160
161 printf("\n"
162 "tcProps version %d.%d\n"
163 "\n",
164 VERSION_MAJOR, VERSION_MINOR );
165 exit(0);
166
167 }
168
169 else if( !strcmp( argV[i], "--help") ){
170
171 usage();
172 exit(0);
173 }
174
175 // anything else is an error
176
177 else{
178 fprintf( stderr,
179 "Invalid option \"%s\"\n", argV[i] );
180 usage();
181 exit(0);
182 }
183 }
184
185 else{
186
187 // parse single character options
188
189 done =0;
190 j = 1;
191 currentFlag = argV[i][j];
192 while( (currentFlag != '\0') && (!done) ){
193
194 switch(currentFlag){
195
196 case 'o':
197 // -o <prefix> => the output prefix.
198
199 j++;
200 currentFlag = argV[i][j];
201
202 if( currentFlag != '\0' ) optionError = 1;
203
204 if( optionError ){
205 fprintf( stderr,
206 "\n"
207 "The -o flag should end an option sequence.\n"
208 " example: -r <outname> *NOT* -or <outname>\n" );
209 usage();
210 exit(0);
211 }
212
213 i++;
214 if( i>=argC ){
215 fprintf( stderr,
216 "\n"
217 "not enough arguments for -o\n");
218 usage();
219 exit(0);
220 }
221
222 outPrefix = argV[i];
223 if( outPrefix[0] == '-' ) optionError = 1;
224
225 if( optionError ){
226 fprintf( stderr,
227 "\n"
228 "\"%s\" is not a valid out prefix/name.\n"
229 "Out prefix/name should not begin with a dash.\n",
230 outPrefix );
231 usage();
232 exit(0);
233 }
234
235 havePrefix = 1;
236 done = 1;
237 break;
238
239 case 'l':
240 // -l <double> set <double> to the maxLength
241
242 haveMaxLength = 1;
243 j++;
244 currentFlag = argV[i][j];
245
246 if( currentFlag != '\0' ) optionError = 1;
247
248 if( optionError ){
249 fprintf( stderr,
250 "\n"
251 "The -l flag should end an option sequence.\n"
252 " example: -sl <double> *NOT* -ls <double>\n" );
253 usage();
254 exit(0);
255 }
256
257 i++;
258 if( i>=argC ){
259 fprintf( stderr,
260 "\n"
261 "not enough arguments for -l\n");
262 usage();
263 exit(0);
264 }
265
266 maxLength = atof( argV[i] );
267
268 done = 1;
269
270 break;
271
272 case 't':
273 // -t <double> set <double> to the startTime
274
275 j++;
276 currentFlag = argV[i][j];
277
278 if( currentFlag != '\0' ) optionError = 1;
279
280 if( optionError ){
281 fprintf( stderr,
282 "\n"
283 "The -t flag should end an option sequence.\n"
284 " example: -st <double> *NOT* -ts <double>\n" );
285 usage();
286 exit(0);
287 }
288
289 i++;
290 if( i>=argC ){
291 fprintf( stderr,
292 "\n"
293 "not enough arguments for -t\n");
294 usage();
295 exit(0);
296 }
297
298 startTime = atof( argV[i] );
299 done = 1;
300 break;
301
302 case 's':
303 // -s turn on Scd corr
304
305 scdCorr = 1;
306 break;
307
308 case 'h':
309 // -h turn on director head
310
311 directorHead = 1;
312 break;
313
314 case 'w':
315 // -h turn on director head
316
317 directorWhole = 1;
318 break;
319
320
321 default:
322
323 fprintf( stderr,
324 "\n"
325 "Bad option \"-%c\"\n", currentFlag);
326 usage();
327 exit(0);
328 }
329 j++;
330 currentFlag = argV[i][j];
331 }
332 }
333 }
334
335 else{
336
337 if( inName != NULL ){
338 fprintf( stderr,
339 "Error at \"%s\", program does not currently support\n"
340 "more than one input dump file.\n"
341 "\n",
342 argV[i]);
343 usage();
344 exit(0);
345 }
346
347 inName = argV[i];
348
349 }
350 }
351
352 if( inName == NULL ){
353 fprintf( stderr,
354 "Error, dump file is needed to run.\n" );
355 usage();
356 exit(0);
357 }
358
359 if( outPrefix == NULL )
360 outPrefix = inName;
361
362
363 // initialize the arrays
364
365 for(i=0;i<nLipids;i++){
366
367 atoms[nLipAtoms*i+0].type = HEAD;
368 atoms[nLipAtoms*i+0].mass = 72;
369 atoms[nLipAtoms*i+0].u[0] = 0.0;
370 atoms[nLipAtoms*i+0].u[1] = 0.0;
371 atoms[nLipAtoms*i+0].u[2] = 1.0;
372
373
374
375 atoms[nLipAtoms*i+1].type = CH2;
376 atoms[nLipAtoms*i+1].mass = 14.03;
377
378 atoms[nLipAtoms*i+2].type = CH;
379 atoms[nLipAtoms*i+2].mass = 13.02;
380
381 atoms[nLipAtoms*i+3].type = CH2;
382 atoms[nLipAtoms*i+3].mass = 14.03;
383
384 atoms[nLipAtoms*i+4].type = CH2;
385 atoms[nLipAtoms*i+4].mass = 14.03;
386
387 atoms[nLipAtoms*i+5].type = CH2;
388 atoms[nLipAtoms*i+5].mass = 14.03;
389
390 atoms[nLipAtoms*i+6].type = CH2;
391 atoms[nLipAtoms*i+6].mass = 14.03;
392
393 atoms[nLipAtoms*i+7].type = CH2;
394 atoms[nLipAtoms*i+7].mass = 14.03;
395
396 atoms[nLipAtoms*i+8].type = CH2;
397 atoms[nLipAtoms*i+8].mass = 14.03;
398
399 atoms[nLipAtoms*i+9].type = CH2;
400 atoms[nLipAtoms*i+9].mass = 14.03;
401
402 atoms[nLipAtoms*i+10].type = CH3;
403 atoms[nLipAtoms*i+10].mass = 15.04;
404
405 atoms[nLipAtoms*i+11].type = CH2;
406 atoms[nLipAtoms*i+11].mass = 14.03;
407
408 atoms[nLipAtoms*i+12].type = CH2;
409 atoms[nLipAtoms*i+12].mass = 14.03;
410
411 atoms[nLipAtoms*i+13].type = CH2;
412 atoms[nLipAtoms*i+13].mass = 14.03;
413
414 atoms[nLipAtoms*i+14].type = CH2;
415 atoms[nLipAtoms*i+14].mass = 14.03;
416
417 atoms[nLipAtoms*i+15].type = CH2;
418 atoms[nLipAtoms*i+15].mass = 14.03;
419
420 atoms[nLipAtoms*i+16].type = CH2;
421 atoms[nLipAtoms*i+16].mass = 14.03;
422
423 atoms[nLipAtoms*i+17].type = CH2;
424 atoms[nLipAtoms*i+17].mass = 14.03;
425
426 atoms[nLipAtoms*i+18].type = CH3;
427 atoms[nLipAtoms*i+18].mass = 15.04;
428 }
429
430 for(i=(nLipAtoms*nLipids);i<nAtoms;i++){
431 atoms[i].type = SSD;
432 atoms[i].mass = 18.03;
433 atoms[i].u[0] = 0.0;
434 atoms[i].u[1] = 0.0;
435 atoms[i].u[2] = 1.0;
436 }
437
438 // read and set the frames
439
440 openFile();
441
442 fprintf( stdout,
443 "\n"
444 "Counting the number of frames in \"%s\"...",
445 inName );
446 fflush(stdout);
447
448 setFrames();
449
450 fprintf( stdout,
451 "done.\n"
452 "nFrames = %d.\n",
453 nFrames );
454 fflush(stdout);
455
456 if(scdCorr){
457
458 fprintf ( stdout,
459 "Calculating the Scd correlation\n" );
460 fflush( stdout );
461
462 calcScdCorr( startTime, atoms, outPrefix );
463 }
464
465 if(directorHead){
466
467 fprintf ( stdout,
468 "Calculating the Head director\n" );
469 fflush( stdout );
470
471 calcDirHeadCorr( startTime, atoms, outPrefix );
472 }
473
474 if(directorWhole){
475
476 fprintf ( stdout,
477 "Calculating the bilayer director\n" );
478 fflush( stdout );
479
480 calcDirWholeCorr( startTime, atoms, outPrefix );
481 }
482
483
484 closeFile();
485
486 }
487
488
489 /***************************************************************************
490 * prints out the usage for the command line arguments, then exits.
491 ***************************************************************************/
492
493 void usage(){
494 (void)fprintf(stdout,
495 "\n"
496 "The proper usage is: %s [options] <input_file>\n"
497 "\n"
498 "Options:\n"
499 "\n"
500 " short:\n"
501 " ------\n"
502 " -o <name> The output prefix\n"
503 " -t <time> Set the start time for correlations\n"
504 " -l <maxLength> set the maximum value of r\n"
505 " *Defaults to 1/2 smallest length of first frame.\n"
506 " -s Calculate the Scd chain correlation.\n"
507 " -h Calculate the directors for the head groups\n"
508 " -w Calculate the director fro the bilayers\n"
509 "\n"
510 " long:\n"
511 " -----\n"
512 " --gofr <atom1> <atom2> g(r) for atom1 and atom2\n"
513 " --gofrTheta <atom1> <atom2> g(r, theta) for atom1 and atom2\n"
514 " --gofrOmega <atom1> <atom2> g(r, omega) for atom1 and atom2\n"
515 " --version displays the version number\n"
516 " --help displays this help message.\n"
517
518 "\n"
519 "\n",
520 programName);
521 }