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 |
|
|
50 |
– |
|
51 |
– |
|
51 |
|
program_name = argv[0]; /*save the program name in case we need it*/ |
52 |
|
|
53 |
|
for( i = 1; i < argc; i++){ |
180 |
|
exit(8); |
181 |
|
} |
182 |
|
|
183 |
< |
// create the array of frames |
183 |
> |
// create and initialize the array of frames |
184 |
|
|
185 |
|
dumpArray = (struct xyz_frame*)calloc( nFrames, |
186 |
|
sizeof( struct xyz_frame ) ); |
187 |
+ |
for( i=0; i<nFrames; i++ ){ |
188 |
+ |
dumpArray[i].nAtoms = 0; |
189 |
+ |
dumpArray[i].time = 0.0; |
190 |
+ |
dumpArray[i].boxX = 0.0; |
191 |
+ |
dumpArray[i].boxY = 0.0; |
192 |
+ |
dumpArray[i].boxZ = 0.0; |
193 |
+ |
dumpArray[i].r = NULL; |
194 |
+ |
dumpArray[i].v = NULL; |
195 |
+ |
dumpArray[i].names = NULL; |
196 |
+ |
} |
197 |
|
|
198 |
|
// read the frames |
199 |
|
|
200 |
|
printf( "Reading the frames into the coordinate arrays..." ); |
201 |
|
fflush( stdout ); |
202 |
|
|
203 |
+ |
isFirst = 1; |
204 |
|
for(j =0; j<nFrames; j++ ){ |
205 |
|
|
206 |
|
// read the number of atoms |
213 |
|
|
214 |
|
dumpArray[j].r = |
215 |
|
(struct coords *)calloc(n_atoms, sizeof(struct coords)); |
216 |
+ |
|
217 |
+ |
if( isFirst ) { |
218 |
+ |
dumpArray[0].names = |
219 |
+ |
(atomID *)calloc( n_atoms, sizeof(atomID) ); |
220 |
+ |
isFirst = 0; |
221 |
+ |
} |
222 |
|
|
223 |
|
if( calcMuCorr || calcCosCorr ){ |
224 |
|
dumpArray[j].v = |
276 |
|
exit(8); |
277 |
|
} |
278 |
|
|
279 |
< |
strcpy(dumpArray[j].r[i].name, foo); /*copy the atom name */ |
279 |
> |
strcpy(dumpArray[0].names[i], foo); /*copy the atom name */ |
280 |
|
|
281 |
|
foo = strtok(NULL, " ,;\t"); |
282 |
|
if(foo == NULL){ |
400 |
|
cosCorr1, cosCorr2 ); |
401 |
|
fflush( stdout ); |
402 |
|
|
403 |
< |
// cosCorr call |
388 |
< |
|
403 |
> |
cosCorr( out_prefix, cosCorr1, cosCorr2, dumpArray, nFrames ); |
404 |
|
|
405 |
|
fprintf( stdout, |
406 |
|
" done.\n" |
408 |
|
fflush(stdout); |
409 |
|
} |
410 |
|
|
396 |
– |
|
411 |
|
return 0; |
412 |
|
|
413 |
|
} |
414 |
|
|
415 |
|
|
416 |
+ |
void map( double *x, double *y, double *z, |
417 |
+ |
double boxX, double boxY, double boxZ ){ |
418 |
+ |
|
419 |
+ |
*x -= boxX * copysign(1.0,*x) * floor( fabs( *x/boxX ) + 0.5 ); |
420 |
+ |
*y -= boxY * copysign(1.0,*y) * floor( fabs( *y/boxY ) + 0.5 ); |
421 |
+ |
*z -= boxZ * copysign(1.0,*z) * floor( fabs( *z/boxZ ) + 0.5 ); |
422 |
|
|
423 |
+ |
} |
424 |
+ |
|
425 |
+ |
|
426 |
|
/*************************************************************************** |
427 |
|
* prints out the usage for the command line arguments, then exits. |
428 |
|
***************************************************************************/ |