22 |
|
int lineNum = 0; // keeps track of the line number |
23 |
|
int n_atoms; // the number of atoms |
24 |
|
int i,j; // loop counters |
25 |
+ |
int isFirst; |
26 |
|
|
27 |
|
char read_buffer[2000]; /*the line buffer for reading */ |
28 |
|
char *foo; /*the pointer to the current string token */ |
48 |
|
char cosCorr1[30]; |
49 |
|
char cosCorr2[30]; |
50 |
|
|
51 |
+ |
int startFrame = 0; |
52 |
+ |
int haveStartFrame = 0; |
53 |
+ |
int endFrame = 0; |
54 |
+ |
int haveEndFrame = 0; |
55 |
|
|
51 |
– |
|
56 |
|
program_name = argv[0]; /*save the program name in case we need it*/ |
57 |
|
|
58 |
|
for( i = 1; i < argc; i++){ |
79 |
|
strcpy( muCorr, argv[i] ); |
80 |
|
} |
81 |
|
|
82 |
< |
else if( !strcmp( argv[i], "--CosCorr" ) ){ |
83 |
< |
calcCosCorr = 1; |
82 |
> |
else if( !strcmp( argv[i], "--startFrame" ) ){ |
83 |
> |
haveStartFrame = 1; |
84 |
|
i++; |
85 |
< |
strcpy( cosCorr1, argv[i] ); |
85 |
> |
startFrame = atoi(argv[i]); |
86 |
> |
} |
87 |
> |
|
88 |
> |
else if( !strcmp( argv[i], "--endFrame" ) ){ |
89 |
> |
haveEndFrame = 1; |
90 |
|
i++; |
91 |
< |
strcpy( cosCorr2, argv[i] ); |
91 |
> |
endFrame = atoi(argv[i]); |
92 |
|
} |
93 |
|
|
94 |
|
else{ |
176 |
|
fflush( stdout ); |
177 |
|
|
178 |
|
nFrames = frameCount( in_name ); |
179 |
+ |
if( !haveEndFrame ) endFrame = nFrames; |
180 |
|
|
181 |
|
printf( "done.\n" |
182 |
|
"nframes = %d\n" |
190 |
|
exit(8); |
191 |
|
} |
192 |
|
|
193 |
< |
// create the array of frames |
193 |
> |
// create and initialize the array of frames |
194 |
|
|
195 |
|
dumpArray = (struct xyz_frame*)calloc( nFrames, |
196 |
|
sizeof( struct xyz_frame ) ); |
197 |
+ |
for( i=0; i<nFrames; i++ ){ |
198 |
+ |
dumpArray[i].nAtoms = 0; |
199 |
+ |
dumpArray[i].time = 0.0; |
200 |
+ |
dumpArray[i].boxX = 0.0; |
201 |
+ |
dumpArray[i].boxY = 0.0; |
202 |
+ |
dumpArray[i].boxZ = 0.0; |
203 |
+ |
dumpArray[i].r = NULL; |
204 |
+ |
dumpArray[i].v = NULL; |
205 |
+ |
dumpArray[i].names = NULL; |
206 |
+ |
} |
207 |
|
|
208 |
|
// read the frames |
209 |
|
|
210 |
|
printf( "Reading the frames into the coordinate arrays..." ); |
211 |
|
fflush( stdout ); |
212 |
|
|
213 |
+ |
isFirst = 1; |
214 |
|
for(j =0; j<nFrames; j++ ){ |
215 |
|
|
216 |
|
// read the number of atoms |
223 |
|
|
224 |
|
dumpArray[j].r = |
225 |
|
(struct coords *)calloc(n_atoms, sizeof(struct coords)); |
226 |
+ |
|
227 |
+ |
if( isFirst ) { |
228 |
+ |
dumpArray[0].names = |
229 |
+ |
(atomID *)calloc( n_atoms, sizeof(atomID) ); |
230 |
+ |
isFirst = 0; |
231 |
+ |
} |
232 |
|
|
233 |
|
if( calcMuCorr || calcCosCorr ){ |
234 |
|
dumpArray[j].v = |
286 |
|
exit(8); |
287 |
|
} |
288 |
|
|
289 |
< |
strcpy(dumpArray[j].r[i].name, foo); /*copy the atom name */ |
289 |
> |
strcpy(dumpArray[0].names[i], foo); /*copy the atom name */ |
290 |
|
|
291 |
|
foo = strtok(NULL, " ,;\t"); |
292 |
|
if(foo == NULL){ |
364 |
|
fflush( stdout ); |
365 |
|
|
366 |
|
// gofr call |
367 |
< |
GofR( out_prefix, gofR1, gofR2, dumpArray, nFrames ); |
367 |
> |
GofR( out_prefix, gofR1, gofR2, dumpArray, nFrames, startFrame, endFrame ); |
368 |
|
|
369 |
|
fprintf( stdout, |
370 |
|
" done.\n" |
410 |
|
cosCorr1, cosCorr2 ); |
411 |
|
fflush( stdout ); |
412 |
|
|
413 |
< |
// cosCorr call |
414 |
< |
|
413 |
> |
cosCorr( out_prefix, cosCorr1, cosCorr2, dumpArray, nFrames, startFrame, |
414 |
> |
endFrame ); |
415 |
|
|
416 |
|
fprintf( stdout, |
417 |
|
" done.\n" |
419 |
|
fflush(stdout); |
420 |
|
} |
421 |
|
|
396 |
– |
|
422 |
|
return 0; |
423 |
|
|
424 |
|
} |
425 |
|
|
426 |
|
|
427 |
+ |
void map( double *x, double *y, double *z, |
428 |
+ |
double boxX, double boxY, double boxZ ){ |
429 |
+ |
|
430 |
+ |
*x -= boxX * copysign(1.0,*x) * floor( fabs( *x/boxX ) + 0.5 ); |
431 |
+ |
*y -= boxY * copysign(1.0,*y) * floor( fabs( *y/boxY ) + 0.5 ); |
432 |
+ |
*z -= boxZ * copysign(1.0,*z) * floor( fabs( *z/boxZ ) + 0.5 ); |
433 |
|
|
434 |
+ |
} |
435 |
+ |
|
436 |
+ |
|
437 |
|
/*************************************************************************** |
438 |
|
* prints out the usage for the command line arguments, then exits. |
439 |
|
***************************************************************************/ |
458 |
|
" -note: \"all\" will do all atoms\n" |
459 |
|
" --MuCorr <atom> Calculate mu correlation of atom\n" |
460 |
|
" --CosCorr <atom1> <atom2> Calculate the cos correlation between atom1 and atom2\n" |
461 |
+ |
" --startFrame <frame#> Specifies a frame to start correlating\n" |
462 |
+ |
" --endFrame <frame#> Specifies a frame to stop correlating.\n" |
463 |
|
|
428 |
– |
|
464 |
|
"\n" |
465 |
|
"\n", |
466 |
|
program_name); |