ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/tcProps/tcProps.c
Revision: 1062
Committed: Fri Feb 20 21:20:37 2004 UTC (20 years, 4 months ago) by mmeineke
Content type: text/plain
File size: 10186 byte(s)
Log Message:
debugging the director code

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