# | Line 1 | Line 1 | |
---|---|---|
1 | #include <stdio.h> | |
2 | #include <stdlib.h> | |
3 | #include <string.h> | |
4 | – | #include <math.h> |
4 | ||
5 | + | #define STR_BUFFER_SIZE 500 |
6 | ||
7 | < | #include "madProps.h" |
8 | < | #include "frameCount.h" |
7 | > | // ******************************************************* |
8 | > | // Uncomment the following two tyedefs to support multiple |
9 | > | // input files |
10 | > | // ******************************************************* |
11 | ||
12 | < | char *program_name; /*the name of the program */ |
12 | > | typedef struct{ |
13 | > | char fileName[STR_BUFFER_SIZE]; |
14 | > | FILE* filePtr; |
15 | > | } fileStruct; |
16 | ||
17 | + | typedef struct linkedNameTag { |
18 | + | char name[STR_BUFFER_SIZE]; |
19 | + | struct linkedNameTag* next; |
20 | + | } linkedName; |
21 | + | |
22 | + | // ******************************************************* |
23 | + | // end multiple file support |
24 | + | // ******************************************************* |
25 | + | |
26 | + | |
27 | + | char *programName; /*the name of the program */ |
28 | void usage(void); | |
29 | ||
30 | < | int main(argc, argv) |
31 | < | int argc; |
32 | < | char *argv[]; |
30 | > | int main(argC, argV) |
31 | > | int argC; |
32 | > | char *argV[]; |
33 | { | |
34 | + | int i,j; // loop counters |
35 | ||
36 | + | char* outPrefix; // the output prefix |
37 | ||
38 | < | struct xyz_frame *dumpArray; |
39 | < | int nFrames; // the nu8mvber of frames |
40 | < | 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; |
38 | > | char* conversionCheck; |
39 | > | int conversionError; |
40 | > | int optionError; |
41 | ||
42 | < | char read_buffer[2000]; /*the line buffer for reading */ |
43 | < | char *foo; /*the pointer to the current string token */ |
44 | < | FILE *in_file; /* the input file */ |
30 | < | char *in_name = NULL; /*the name of the input file */ |
31 | < | char *out_prefix; // the output prefix |
32 | < | char current_flag; // used in parseing the flags |
42 | > | char currentFlag; // used in parsing the flags |
43 | > | int done = 0; // multipurpose boolean |
44 | > | int havePrefix; // boolean for the output prefix |
45 | ||
46 | + | int flag1; |
47 | + | char flag1Arg1[STR_BUFFER_SIZE]; |
48 | + | char flag1Arg2[STR_BUFFER_SIZE]; |
49 | + | int flag2; |
50 | + | double flag2Val; |
51 | + | int flag3; |
52 | + | int rFlag; |
53 | + | int iFlag, iVal; |
54 | + | |
55 | + | // ********************************************************** |
56 | + | // to support single or multiple input files, uncomment the |
57 | + | // appropriate declarations |
58 | + | // ********************************************************** |
59 | + | // single: |
60 | ||
61 | + | // char* inName; |
62 | + | // FILE* inFile; |
63 | ||
64 | < | int done = 0; // multipurpose boolean |
65 | < | int have_prefix = 0; // prefix boolean |
66 | < | int calcRMSD = 0; |
64 | > | // *********************************************************** |
65 | > | // multiple: |
66 | > | |
67 | > | fileStruct* inputArray; |
68 | > | linkedName* headName; |
69 | > | linkedName* currentName; |
70 | > | int nInputs; |
71 | > | |
72 | > | // end input file declarations |
73 | > | // *********************************************************** |
74 | > | |
75 | > | |
76 | ||
77 | < | int calcGofR = 0; |
78 | < | char gofR1[30]; |
79 | < | char gofR2[30]; |
77 | > | // intialize default values |
78 | > | |
79 | > | |
80 | > | // ******************************************** |
81 | > | // single input: |
82 | > | |
83 | > | // inName = NULL; |
84 | > | // inFile = NULL; |
85 | > | |
86 | > | // ********************************************* |
87 | > | // multiple input: |
88 | > | |
89 | > | nInputs = 0; |
90 | > | inputArray = NULL; |
91 | > | headName = NULL; |
92 | > | currentName = NULL; |
93 | ||
94 | < | int calcMuCorr = 0; |
95 | < | char muCorr[30]; |
94 | > | // end file initialization |
95 | > | // ********************************************** |
96 | ||
47 | – | int calcCosCorr = 0; |
48 | – | char cosCorr1[30]; |
49 | – | char cosCorr2[30]; |
97 | ||
51 | – | int startFrame = 0; |
52 | – | int haveStartFrame = 0; |
53 | – | int endFrame = 0; |
54 | – | int haveEndFrame = 0; |
98 | ||
99 | < | program_name = argv[0]; /*save the program name in case we need it*/ |
99 | > | outPrefix = NULL; |
100 | > | |
101 | > | conversionError = 0; |
102 | > | optionError = 0; |
103 | > | |
104 | > | havePrefix = 0; |
105 | > | flag1 = 0; |
106 | > | flag2 = 0; |
107 | > | flag3 = 0; |
108 | > | rFlag = 0; |
109 | > | iFlag = 0; |
110 | > | |
111 | > | flag2Val = 0.0; |
112 | > | iVal = 0; |
113 | ||
114 | < | for( i = 1; i < argc; i++){ |
114 | > | |
115 | > | |
116 | > | // here we set the name of the program need by the usage message |
117 | > | programName = argV[0]; |
118 | > | |
119 | > | |
120 | > | for( i = 1; i < argC; i++){ |
121 | ||
122 | < | if(argv[i][0] =='-'){ |
122 | > | if(argV[i][0] =='-'){ |
123 | ||
124 | // parse the option | |
125 | ||
126 | < | if(argv[i][1] == '-' ){ |
126 | > | if(argV[i][1] == '-' ){ |
127 | ||
128 | // parse long word options | |
129 | ||
130 | < | if( !strcmp( argv[i], "--GofR" ) ){ |
131 | < | calcGofR = 1; |
130 | > | if( !strcmp( argV[i], "--flag1" ) ){ |
131 | > | flag1 = 1; // set flag1 to true |
132 | > | |
133 | i++; | |
134 | < | strcpy( gofR1, argv[i] ); |
134 | > | if( i>=argC ){ |
135 | > | fprintf( stderr, |
136 | > | "\n" |
137 | > | "not enough arguments for flag1\n"); |
138 | > | usage(); |
139 | > | exit(0); |
140 | > | } |
141 | > | strcpy( flag1Arg1, argV[i] ); |
142 | > | |
143 | i++; | |
144 | < | strcpy( gofR2, argv[i] ); |
144 | > | if( i>=argC ){ |
145 | > | fprintf( stderr, |
146 | > | "\n" |
147 | > | "not enough arguments for flag1\n"); |
148 | > | usage(); |
149 | > | exit(0); |
150 | > | } |
151 | > | strcpy( flag1Arg2, argV[i] ); |
152 | } | |
153 | ||
154 | < | else if( !strcmp( argv[i], "--CosCorr" ) ){ |
155 | < | calcCosCorr = 1; |
154 | > | else if( !strcmp( argV[i], "--flag2" ) ){ |
155 | > | flag2 = 1; // set the flag2 to true; |
156 | > | |
157 | i++; | |
158 | < | strcpy( cosCorr1, argv[i] ); |
159 | < | i++; |
160 | < | strcpy( cosCorr2, argv[i] ); |
158 | > | if( i>=argC ){ |
159 | > | fprintf( stderr, |
160 | > | "\n" |
161 | > | "not enough arguments for flag2\n"); |
162 | > | usage(); |
163 | > | exit(0); |
164 | > | } |
165 | > | |
166 | > | flag2Val = strtod( argV[i], &conversionCheck ); |
167 | > | if( conversionCheck == argV[i] ) conversionError = 1; |
168 | > | if( *conversionCheck != '\0' ) conversionError = 1; |
169 | > | |
170 | > | if( conversionError ){ |
171 | > | |
172 | > | fprintf( stderr, |
173 | > | "Error converting \"%s\" to a double\n", argV[i] ); |
174 | > | usage(); |
175 | > | exit(0); |
176 | > | } |
177 | > | |
178 | } | |
179 | ||
180 | < | else if( !strcmp( argv[i], "--MuCorr") ){ |
181 | < | calcMuCorr = 1; |
182 | < | i++; |
87 | < | strcpy( muCorr, argv[i] ); |
180 | > | else if( !strcmp( argV[i], "--flag3") ){ |
181 | > | flag3 = 1; // set flag3 to be true |
182 | > | |
183 | } | |
184 | ||
185 | < | else if( !strcmp( argv[i], "--startFrame" ) ){ |
91 | < | haveStartFrame = 1; |
92 | < | i++; |
93 | < | startFrame = atoi(argv[i]); |
94 | < | startFrame--; |
95 | < | } |
185 | > | // anything else is an error |
186 | ||
97 | – | else if( !strcmp( argv[i], "--endFrame" ) ){ |
98 | – | haveEndFrame = 1; |
99 | – | i++; |
100 | – | endFrame = atoi(argv[i]); |
101 | – | } |
102 | – | |
187 | else{ | |
188 | fprintf( stderr, | |
189 | < | "Invalid option \"%s\"\n", argv[i] ); |
189 | > | "Invalid option \"%s\"\n", argV[i] ); |
190 | usage(); | |
191 | + | exit(0); |
192 | } | |
193 | } | |
194 | ||
# | Line 113 | Line 198 | int main(argc, argv) | |
198 | ||
199 | done =0; | |
200 | j = 1; | |
201 | < | current_flag = argv[i][j]; |
202 | < | while( (current_flag != '\0') && (!done) ){ |
201 | > | currentFlag = argV[i][j]; |
202 | > | while( (currentFlag != '\0') && (!done) ){ |
203 | ||
204 | < | switch(current_flag){ |
204 | > | switch(currentFlag){ |
205 | ||
206 | + | case 'h': |
207 | + | // -h => give the usage help message |
208 | + | |
209 | + | usage(); |
210 | + | exit(0); |
211 | + | break; |
212 | + | |
213 | case 'o': | |
214 | // -o <prefix> => the output prefix. | |
215 | ||
216 | + | j++; |
217 | + | currentFlag = argV[i][j]; |
218 | + | |
219 | + | if( currentFlag != '\0' ) optionError = 1; |
220 | + | |
221 | + | if( optionError ){ |
222 | + | fprintf( stderr, |
223 | + | "\n" |
224 | + | "The -o flag should end an option sequence.\n" |
225 | + | " example: -ro <outname> *NOT* -or <outname>\n" ); |
226 | + | usage(); |
227 | + | exit(0); |
228 | + | } |
229 | + | |
230 | i++; | |
231 | < | out_prefix = argv[i]; |
232 | < | have_prefix = 1; |
233 | < | done = 1; |
234 | < | break; |
231 | > | if( i>=argC ){ |
232 | > | fprintf( stderr, |
233 | > | "\n" |
234 | > | "not enough arguments for -o\n"); |
235 | > | usage(); |
236 | > | exit(0); |
237 | > | } |
238 | ||
239 | < | case 'h': |
240 | < | // -h => give the usage |
239 | > | outPrefix = argV[i]; |
240 | > | if( outPrefix[0] == '-' ) optionError = 1; |
241 | > | |
242 | > | if( optionError ){ |
243 | > | fprintf( stderr, |
244 | > | "\n" |
245 | > | "\"%s\" is not a valid out prefix/name.\n" |
246 | > | "Out prefix/name should not begin with a dash.\n", |
247 | > | outPrefix ); |
248 | > | usage(); |
249 | > | exit(0); |
250 | > | } |
251 | ||
252 | < | usage(); |
252 | > | havePrefix = 1; |
253 | > | done = 1; |
254 | break; | |
255 | + | |
256 | + | |
257 | ||
258 | case 'r': | |
259 | < | // calculates the rmsd |
259 | > | // the r flag |
260 | ||
261 | < | calcRMSD = 1; |
261 | > | rFlag = 1; // set rflag to true |
262 | break; | |
263 | ||
264 | < | case 'g': |
265 | < | // calculate all to all g(r) |
264 | > | case 'i': |
265 | > | // -i <int> set <int> to the iVal |
266 | ||
267 | < | calcGofR = 1; |
268 | < | strcpy( gofR1, "all" ); |
269 | < | strcpy( gofR2, "all" ); |
267 | > | iFlag = 1; // set iFlag to true |
268 | > | j++; |
269 | > | currentFlag = argV[i][j]; |
270 | > | |
271 | > | if( currentFlag != '\0' ) optionError = 1; |
272 | > | |
273 | > | if( optionError ){ |
274 | > | fprintf( stderr, |
275 | > | "\n" |
276 | > | "The -i flag should end an option sequence.\n" |
277 | > | " example: -ri <int> *NOT* -ir <int>\n" ); |
278 | > | usage(); |
279 | > | exit(0); |
280 | > | } |
281 | > | |
282 | > | i++; |
283 | > | if( i>=argC ){ |
284 | > | fprintf( stderr, |
285 | > | "\n" |
286 | > | "not enough arguments for -i\n"); |
287 | > | usage(); |
288 | > | exit(0); |
289 | > | } |
290 | > | |
291 | > | iVal = (int)strtol( argV[i], &conversionCheck, 10 ); |
292 | > | if( conversionCheck == argV[i] ) conversionError = 1; |
293 | > | if( *conversionCheck != '\0' ) conversionError = 1; |
294 | > | |
295 | > | if( conversionError ){ |
296 | > | |
297 | > | fprintf( stderr, |
298 | > | "Error converting \"%s\" to a int\n", argV[i] ); |
299 | > | usage(); |
300 | > | exit(0); |
301 | > | } |
302 | > | |
303 | > | done = 1; |
304 | > | |
305 | break; | |
306 | ||
307 | default: | |
308 | ||
309 | < | (void)fprintf(stderr, "Bad option \"-%c\"\n", current_flag); |
309 | > | (void)fprintf(stderr, |
310 | > | "\n" |
311 | > | "Bad option \"-%c\"\n", currentFlag); |
312 | usage(); | |
313 | } | |
314 | j++; | |
315 | < | current_flag = argv[i][j]; |
315 | > | currentFlag = argV[i][j]; |
316 | } | |
317 | } | |
318 | } | |
319 | ||
320 | else{ | |
321 | ||
322 | < | if( in_name != NULL ){ |
322 | > | |
323 | > | // ******************************************************** |
324 | > | // for only a single input file, leave this as it is. |
325 | > | // ******************************************************** |
326 | > | |
327 | > | // if( inName != NULL ){ |
328 | > | // fprintf( stderr, |
329 | > | // "\n" |
330 | > | // "Error at \"%s\", program does not currently support\n" |
331 | > | // "more than one input file.\n" |
332 | > | // "\n", |
333 | > | // argV[i]); |
334 | > | // usage(); |
335 | > | // exit(0); |
336 | > | // } |
337 | > | |
338 | > | // inName = argV[i]; |
339 | > | |
340 | > | // ************************************************************* |
341 | > | |
342 | > | |
343 | > | // ************************************************************ |
344 | > | // To support more than one input file, uncomment the following |
345 | > | // section. |
346 | > | // ************************************************************ |
347 | > | |
348 | > | |
349 | > | nInputs++; |
350 | > | currentName = (linkedName *) malloc( sizeof( linkedName ) ); |
351 | > | if( currentName == NULL ){ |
352 | fprintf( stderr, | |
353 | < | "Error at \"%s\", program does not currently support\n" |
354 | < | "more than one input file.\n" |
355 | < | "\n", |
168 | < | argv[i]); |
169 | < | usage(); |
353 | > | "\n" |
354 | > | "Ran out of memory\n" ); |
355 | > | exit(0); |
356 | } | |
357 | < | |
358 | < | in_name = argv[i]; |
357 | > | |
358 | > | strcpy( currentName->name, argV[i] ); |
359 | > | |
360 | > | currentName->next = headName; |
361 | > | headName = currentName; |
362 | > | |
363 | > | // ********************************************************** |
364 | > | // end multiple input files |
365 | > | // ********************************************************** |
366 | } | |
367 | } | |
368 | ||
369 | < | if(in_name == NULL){ |
370 | < | usage(); |
371 | < | } |
369 | > | |
370 | > | |
371 | > | |
372 | > | // initialize the input file(s) |
373 | ||
374 | < | if( !have_prefix ) out_prefix = in_name; |
374 | > | // *********************************************************** |
375 | > | // single file: |
376 | ||
377 | < | printf( "Counting number of frames..." ); |
378 | < | fflush( stdout ); |
379 | < | |
380 | < | nFrames = frameCount( in_name ); |
381 | < | if( !haveEndFrame ) endFrame = nFrames; |
377 | > | // if(inName == NULL){ |
378 | > | |
379 | > | // fprintf( stderr, |
380 | > | // "\n" |
381 | > | // "Error, no input file was given\n"); |
382 | > | // usage(); |
383 | > | // exit(0); |
384 | > | // } |
385 | ||
386 | < | printf( "done.\n" |
387 | < | "nframes = %d\n" |
388 | < | "\n", |
389 | < | nFrames ); |
390 | < | fflush( stdout ); |
386 | > | // inFile = fopen( inName, "r" ); |
387 | > | // if( inFile == NULL ){ |
388 | > | |
389 | > | // fprintf( stderr, |
390 | > | // "\n" |
391 | > | // "Error trying to open \"%s\" for reading\n", |
392 | > | // inName ); |
393 | > | // exit(0); |
394 | > | // } |
395 | ||
396 | < | in_file = fopen(in_name, "r"); |
397 | < | if(in_file == NULL){ |
398 | < | printf("Cannot open file: %s\n", in_name); |
399 | < | exit(8); |
396 | > | // ************************************************************** |
397 | > | // multiple files: |
398 | > | |
399 | > | if( !nInputs ){ |
400 | > | |
401 | > | fprintf( stderr, |
402 | > | "\n" |
403 | > | "Error, no input files were given\n"); |
404 | > | usage(); |
405 | > | exit(0); |
406 | } | |
407 | ||
408 | < | // create and initialize the array of frames |
408 | > | // create the input array |
409 | ||
410 | < | dumpArray = (struct xyz_frame*)calloc( nFrames, |
411 | < | sizeof( struct xyz_frame ) ); |
412 | < | for( i=0; i<nFrames; i++ ){ |
413 | < | dumpArray[i].nAtoms = 0; |
414 | < | dumpArray[i].time = 0.0; |
415 | < | dumpArray[i].boxX = 0.0; |
208 | < | dumpArray[i].boxY = 0.0; |
209 | < | dumpArray[i].boxZ = 0.0; |
210 | < | dumpArray[i].r = NULL; |
211 | < | dumpArray[i].v = NULL; |
212 | < | dumpArray[i].names = NULL; |
410 | > | inputArray = (fileStruct *) calloc( nInputs, sizeof( fileStruct ) ); |
411 | > | if( inputArray == NULL ){ |
412 | > | fprintf(stderr, |
413 | > | "\n" |
414 | > | "Ran out of memory\n" ); |
415 | > | exit(0); |
416 | } | |
214 | – | |
215 | – | // read the frames |
417 | ||
418 | < | printf( "Reading the frames into the coordinate arrays..." ); |
419 | < | fflush( stdout ); |
420 | < | |
220 | < | isFirst = 1; |
221 | < | for(j =0; j<nFrames; j++ ){ |
418 | > | j = nInputs - 1; |
419 | > | currentName = headName; |
420 | > | while( currentName != NULL ){ |
421 | ||
422 | < | // read the number of atoms |
422 | > | strcpy( inputArray[j].fileName, currentName->name ); |
423 | > | inputArray[j].filePtr = NULL; |
424 | > | j--; |
425 | > | currentName = currentName->next; |
426 | > | } |
427 | ||
428 | < | fgets(read_buffer, sizeof(read_buffer), in_file); |
429 | < | lineNum++; |
430 | < | |
228 | < | n_atoms = atoi( read_buffer ); |
229 | < | dumpArray[j].nAtoms = n_atoms; |
230 | < | |
231 | < | dumpArray[j].r = |
232 | < | (struct coords *)calloc(n_atoms, sizeof(struct coords)); |
428 | > | // delete linked list |
429 | > | |
430 | > | while( headName != NULL ){ |
431 | ||
432 | < | if( isFirst ) { |
433 | < | dumpArray[0].names = |
236 | < | (atomID *)calloc( n_atoms, sizeof(atomID) ); |
237 | < | isFirst = 0; |
238 | < | } |
432 | > | currentName = headName; |
433 | > | headName = currentName->next; |
434 | ||
435 | < | if( calcMuCorr || calcCosCorr ){ |
436 | < | dumpArray[j].v = |
437 | < | (struct vect *)calloc(n_atoms, sizeof(struct vect)); |
243 | < | } |
435 | > | free( currentName ); |
436 | > | } |
437 | > | |
438 | ||
439 | < | //read the time and the box sizes |
439 | > | // open the files for reading |
440 | > | |
441 | > | for(i=0; i<nInputs; i++){ |
442 | ||
443 | < | fgets(read_buffer, sizeof(read_buffer), in_file); |
444 | < | lineNum++; |
445 | < | |
446 | < | foo = strtok(read_buffer, " ,;\t"); |
447 | < | if(foo == NULL){ |
448 | < | printf("error in reading time at line %d\n", lineNum); |
449 | < | exit(8); |
443 | > | inputArray[i].filePtr = fopen( inputArray[i].fileName, "r" ); |
444 | > | if( inputArray[i].filePtr == NULL ){ |
445 | > | |
446 | > | fprintf( stderr, |
447 | > | "\n" |
448 | > | "Error trying to open \"%s\" for reading\n", |
449 | > | inputArray[i].fileName ); |
450 | > | exit(0); |
451 | } | |
255 | – | |
256 | – | dumpArray[j].time = atof( foo ); |
257 | – | |
258 | – | foo = strtok(NULL, " ,;\t"); |
259 | – | if(foo == NULL){ |
260 | – | printf("error in reading boxX at line %d\n", lineNum); |
261 | – | exit(8); |
262 | – | } |
263 | – | |
264 | – | dumpArray[j].boxX = atof( foo ); |
452 | ||
453 | < | foo = strtok(NULL, " ,;\t"); |
267 | < | if(foo == NULL){ |
268 | < | printf("error in reading boxY at line %d\n", lineNum); |
269 | < | exit(8); |
270 | < | } |
271 | < | |
272 | < | dumpArray[j].boxY = atof( foo ); |
273 | < | |
274 | < | foo = strtok(NULL, " ,;\t"); |
275 | < | if(foo == NULL){ |
276 | < | printf("error in reading boxZ at line %d\n", lineNum); |
277 | < | exit(8); |
278 | < | } |
279 | < | |
280 | < | dumpArray[j].boxZ = atof( foo ); |
453 | > | //read and do stuff here |
454 | ||
455 | + | } |
456 | + | |
457 | + | // ************************************************************* |
458 | + | // end file opening |
459 | + | // ************************************************************* |
460 | + | |
461 | ||
283 | – | for( i=0; i < n_atoms; i++){ |
284 | – | |
285 | – | fgets(read_buffer, sizeof(read_buffer), in_file); |
286 | – | lineNum++; |
287 | – | |
288 | – | // get the name and positions |
462 | ||
463 | < | foo = strtok(read_buffer, " ,;\t"); |
291 | < | if(foo == NULL){ |
292 | < | printf("error in reading atom name at line %d\n", lineNum ); |
293 | < | exit(8); |
294 | < | } |
295 | < | |
296 | < | strcpy(dumpArray[0].names[i], foo); /*copy the atom name */ |
463 | > | // or read and do stuff here. |
464 | ||
298 | – | foo = strtok(NULL, " ,;\t"); |
299 | – | if(foo == NULL){ |
300 | – | printf("error in reading position x at line %d\n", lineNum); |
301 | – | exit(8); |
302 | – | } |
303 | – | |
304 | – | dumpArray[j].r[i].x = atof( foo ); |
465 | ||
306 | – | foo = strtok(NULL, " ,;\t"); |
307 | – | if(foo == NULL){ |
308 | – | printf("error in reading position y at line %d\n", lineNum); |
309 | – | exit(8); |
310 | – | } |
311 | – | |
312 | – | dumpArray[j].r[i].y = atof( foo ); |
466 | ||
314 | – | foo = strtok(NULL, " ,;\t"); |
315 | – | if(foo == NULL){ |
316 | – | printf("error in reading position z at line %d\n", lineNum); |
317 | – | exit(8); |
318 | – | } |
319 | – | |
320 | – | dumpArray[j].r[i].z = atof( foo ); |
467 | ||
322 | – | if( calcCosCorr || calcMuCorr ){ |
323 | – | |
324 | – | foo = strtok(NULL, " ,;\t"); |
325 | – | if(foo == NULL){ |
326 | – | |
327 | – | dumpArray[j].v[i].x = 0.0; |
328 | – | dumpArray[j].v[i].y = 0.0; |
329 | – | dumpArray[j].v[i].z = 0.0; |
330 | – | } |
331 | – | else{ |
468 | ||
469 | < | dumpArray[j].v[i].x = atof( foo ); |
470 | < | |
471 | < | foo = strtok(NULL, " ,;\t"); |
472 | < | if(foo == NULL){ |
337 | < | printf("error in reading vector y at line %d\n", lineNum); |
338 | < | exit(8); |
339 | < | } |
340 | < | |
341 | < | dumpArray[j].v[i].y = atof( foo ); |
342 | < | |
343 | < | foo = strtok(NULL, " ,;\t"); |
344 | < | if(foo == NULL){ |
345 | < | printf("error in reading vector z at line %d\n", lineNum); |
346 | < | exit(8); |
347 | < | } |
348 | < | |
349 | < | dumpArray[j].v[i].z = atof( foo ); |
350 | < | } |
351 | < | } |
352 | < | |
353 | < | } |
354 | < | } |
469 | > | // close files when we are done. |
470 | > | |
471 | > | // *********************************************************** |
472 | > | // single: |
473 | ||
474 | < | (void)fclose(in_file); |
474 | > | // fclose( inFile ); |
475 | ||
476 | < | printf( "done\n" |
477 | < | "\n" ); |
360 | < | fflush( stdout ); |
361 | < | |
362 | < | |
476 | > | // ************************************************************* |
477 | > | // multiple: |
478 | ||
479 | < | // do calculations here. |
365 | < | |
366 | < | if( calcGofR ){ |
479 | > | for( i=0; i<nInputs; i++){ |
480 | ||
481 | < | fprintf( stdout, |
369 | < | "Calculating the g(r) between atoms \"%s\" and \"%s\"...", |
370 | < | gofR1, gofR2 ); |
371 | < | fflush( stdout ); |
372 | < | |
373 | < | // gofr call |
374 | < | GofR( out_prefix, gofR1, gofR2, dumpArray, nFrames, startFrame, endFrame ); |
375 | < | |
376 | < | fprintf( stdout, |
377 | < | " done.\n" |
378 | < | "\n"); |
379 | < | fflush(stdout); |
481 | > | fclose( inputArray[i].filePtr ); |
482 | } | |
483 | ||
484 | < | if( calcRMSD ){ |
485 | < | |
384 | < | fprintf( stdout, |
385 | < | "Calculating the RMSD..." ); |
386 | < | fflush( stdout ); |
387 | < | |
388 | < | // RMSD call |
484 | > | free( inputArray ); // free the input Array if we are done; |
485 | > | inputArray = NULL; |
486 | ||
487 | < | |
488 | < | fprintf( stdout, |
489 | < | " done.\n" |
393 | < | "\n"); |
394 | < | fflush(stdout); |
395 | < | } |
487 | > | // ************************************************************ |
488 | > | // end file closing |
489 | > | // ************************************************************ |
490 | ||
397 | – | if( calcMuCorr ){ |
398 | – | |
399 | – | fprintf( stdout, |
400 | – | "Calculating the mu correlation for \"%s\"...", |
401 | – | muCorr); |
402 | – | fflush( stdout ); |
403 | – | |
404 | – | // muCorr call |
405 | – | |
406 | – | |
407 | – | fprintf( stdout, |
408 | – | " done.\n" |
409 | – | "\n"); |
410 | – | fflush(stdout); |
411 | – | } |
412 | – | |
413 | – | if( calcCosCorr ){ |
414 | – | |
415 | – | fprintf( stdout, |
416 | – | "Calculating the cos correlation between \"%s\" and \"%s\"...", |
417 | – | cosCorr1, cosCorr2 ); |
418 | – | fflush( stdout ); |
419 | – | |
420 | – | cosCorr( out_prefix, cosCorr1, cosCorr2, dumpArray, nFrames, startFrame, |
421 | – | endFrame ); |
422 | – | |
423 | – | fprintf( stdout, |
424 | – | " done.\n" |
425 | – | "\n"); |
426 | – | fflush(stdout); |
427 | – | } |
428 | – | |
429 | – | return 0; |
430 | – | |
491 | } | |
492 | ||
493 | ||
434 | – | void map( double *x, double *y, double *z, |
435 | – | double boxX, double boxY, double boxZ ){ |
436 | – | |
437 | – | *x -= boxX * copysign(1.0,*x) * floor( fabs( *x/boxX ) + 0.5 ); |
438 | – | *y -= boxY * copysign(1.0,*y) * floor( fabs( *y/boxY ) + 0.5 ); |
439 | – | *z -= boxZ * copysign(1.0,*z) * floor( fabs( *z/boxZ ) + 0.5 ); |
440 | – | |
441 | – | } |
442 | – | |
443 | – | |
494 | /*************************************************************************** | |
495 | * prints out the usage for the command line arguments, then exits. | |
496 | ***************************************************************************/ | |
497 | ||
498 | void usage(){ | |
499 | (void)fprintf(stdout, | |
450 | – | "The proper usage is: %s [options] <xyz_file>\n" |
500 | "\n" | |
501 | + | "The proper usage is: %s [options] <input_file>\n" |
502 | + | "\n" |
503 | "Options:\n" | |
504 | "\n" | |
505 | " short:\n" | |
506 | " ------\n" | |
507 | " -h Display this message\n" | |
508 | < | " -o <prefix> The output prefix\n" |
509 | < | " -r Calculate the RMSD\n" |
510 | < | " -g Calculate all to all g(r)\n" |
508 | > | " -o <name> The output name/prefix\n" |
509 | > | " -r the r flag\n" |
510 | > | " -i <int> set number to <#>\n" |
511 | ||
512 | "\n" | |
513 | " long:\n" | |
514 | " -----\n" | |
515 | < | " --GofR <atom1> <atom2> Calculates g(r) between atom1 and atom 2\n" |
516 | < | " -note: \"all\" will do all atoms\n" |
517 | < | " --MuCorr <atom> Calculate mu correlation of atom\n" |
467 | < | " --CosCorr <atom1> <atom2> Calculate the cos correlation between atom1 and atom2\n" |
468 | < | " --startFrame <frame#> Specifies a frame to start correlating\n" |
469 | < | " --endFrame <frame#> Specifies a frame to stop correlating.\n" |
515 | > | " --flag1 <arg1> <arg2> does flag 1 for arg1 and 2\n" |
516 | > | " --flag2 <double> does flag 2 for double\n" |
517 | > | " --flag3 does flag 3\n" |
518 | ||
519 | "\n" | |
520 | "\n", | |
521 | < | program_name); |
522 | < | exit(8); |
521 | > | programName); |
522 | > | exit(0); |
523 | } |
– | Removed lines |
+ | Added lines |
< | Changed lines |
> | Changed lines |