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