1 |
+ |
#define _LARGEFILE_SOURCE64 |
2 |
|
#define _FILE_OFFSET_BITS 64 |
3 |
|
|
4 |
+ |
#include <sys/types.h> |
5 |
+ |
#include <sys/stat.h> |
6 |
+ |
|
7 |
|
#include <iostream> |
8 |
< |
#include <cmath> |
8 |
> |
#include <math.h> |
9 |
|
|
10 |
|
#include <stdio.h> |
11 |
|
#include <stdlib.h> |
12 |
|
#include <string.h> |
9 |
– |
#include <unistd.h> |
10 |
– |
#include <sys/types.h> |
11 |
– |
#include <sys/stat.h> |
13 |
|
|
14 |
+ |
|
15 |
|
#include "ReadWrite.hpp" |
16 |
|
#include "simError.h" |
17 |
|
|
20 |
|
#include "mpiSimulation.hpp" |
21 |
|
#define TAKE_THIS_TAG_CHAR 0 |
22 |
|
#define TAKE_THIS_TAG_INT 1 |
23 |
+ |
#endif // is_mpi |
24 |
|
|
25 |
|
namespace dumpRead{ |
26 |
+ |
|
27 |
+ |
#ifdef IS_MPI |
28 |
|
void nodeZeroError( void ); |
29 |
|
void anonymousNodeDie( void ); |
30 |
+ |
#endif // is_mpi |
31 |
+ |
|
32 |
|
} |
33 |
|
|
34 |
|
using namespace dumpRead; |
35 |
|
|
29 |
– |
#endif // is_mpi |
36 |
|
|
37 |
< |
DumpReader :: DumpReader( char *in_name ){ |
37 |
> |
DumpReader :: DumpReader(const char *in_name ){ |
38 |
> |
|
39 |
> |
isScanned = false; |
40 |
> |
headFP = new FilePos; |
41 |
> |
|
42 |
|
#ifdef IS_MPI |
43 |
|
if (worldRank == 0) { |
44 |
|
#endif |
45 |
|
|
46 |
< |
c_in_file = fopen(in_name, "r"); |
47 |
< |
if(c_in_file == NULL){ |
46 |
> |
inFile = fopen(in_name, "r"); |
47 |
> |
if(inFile == NULL){ |
48 |
|
sprintf(painCave.errMsg, |
49 |
|
"Cannot open file: %s\n", in_name); |
50 |
|
painCave.isFatal = 1; |
51 |
|
simError(); |
52 |
|
} |
53 |
|
|
54 |
< |
strcpy( c_in_name, in_name); |
54 |
> |
strcpy( inName, in_name); |
55 |
|
#ifdef IS_MPI |
56 |
|
} |
57 |
|
strcpy( checkPointMsg, "Dump file opened for reading successfully." ); |
65 |
|
if (worldRank == 0) { |
66 |
|
#endif |
67 |
|
int error; |
68 |
< |
error = fclose( c_in_file ); |
68 |
> |
error = fclose( inFile ); |
69 |
|
if( error ){ |
70 |
|
sprintf( painCave.errMsg, |
71 |
< |
"Error closing %s\n", c_in_name ); |
71 |
> |
"Error closing %s\n", inName ); |
72 |
|
simError(); |
73 |
|
} |
74 |
|
#ifdef IS_MPI |
80 |
|
return; |
81 |
|
} |
82 |
|
|
83 |
+ |
int DumpReader::getNframes( void ){ |
84 |
|
|
85 |
+ |
if( !isScanned ) scanFile(); |
86 |
+ |
return nFrames; |
87 |
+ |
} |
88 |
|
|
89 |
< |
void DumpReader :: getFrame( SimInfo* the_simnfo, int whichFrame){ |
89 |
> |
void DumpReader::scanFile( void ){ |
90 |
|
|
91 |
+ |
int vectorSize; |
92 |
+ |
int i, j, k; |
93 |
+ |
int lineNum = 0; |
94 |
+ |
char readBuffer[2000]; |
95 |
+ |
char* foo; |
96 |
+ |
fpos_t *currPos; |
97 |
+ |
double time; |
98 |
+ |
|
99 |
+ |
FilePos *currFP; |
100 |
+ |
|
101 |
+ |
|
102 |
+ |
#ifdef IS_MPI |
103 |
+ |
if( worldRank == 0 ){ |
104 |
+ |
#endif // is_mpi |
105 |
+ |
|
106 |
+ |
rewind( inFile ); |
107 |
+ |
|
108 |
+ |
currPos = new fpos_t; |
109 |
+ |
fgetpos( inFile, currPos ); |
110 |
+ |
fgets( readBuffer, sizeof( readBuffer ), inFile ); |
111 |
+ |
lineNum++; |
112 |
+ |
if( feof( inFile ) ){ |
113 |
+ |
sprintf( painCave.errMsg, |
114 |
+ |
"File \"%s\" ended unexpectedly at line %d\n", |
115 |
+ |
inName, |
116 |
+ |
lineNum ); |
117 |
+ |
painCave.isFatal = 1; |
118 |
+ |
simError(); |
119 |
+ |
} |
120 |
+ |
|
121 |
+ |
nFrames = 0; |
122 |
+ |
while( !feof( inFile ) ){ |
123 |
+ |
|
124 |
+ |
headFP->add( currPos ); |
125 |
+ |
nFrames++; |
126 |
+ |
|
127 |
+ |
i = atoi(readBuffer); |
128 |
+ |
|
129 |
+ |
fgets( readBuffer, sizeof( readBuffer ), inFile ); |
130 |
+ |
lineNum++; |
131 |
+ |
if( feof( inFile ) ){ |
132 |
+ |
sprintf( painCave.errMsg, |
133 |
+ |
"File \"%s\" ended unexpectedly at line %d\n", |
134 |
+ |
inName, |
135 |
+ |
lineNum ); |
136 |
+ |
painCave.isFatal = 1; |
137 |
+ |
simError(); |
138 |
+ |
} |
139 |
+ |
|
140 |
+ |
// if(outTime){ |
141 |
+ |
// foo = strtok( readBuffer, " ,;\t" ); |
142 |
+ |
// time = atof( foo ); |
143 |
+ |
// } |
144 |
+ |
|
145 |
+ |
for(j=0; j<i; j++){ |
146 |
+ |
|
147 |
+ |
fgets( readBuffer, sizeof( readBuffer ), inFile ); |
148 |
+ |
lineNum++; |
149 |
+ |
if( feof( inFile ) ){ |
150 |
+ |
sprintf( painCave.errMsg, |
151 |
+ |
"File \"%s\" ended unexpectedly at line %d," |
152 |
+ |
" with atom %d\n", |
153 |
+ |
inName, |
154 |
+ |
lineNum, |
155 |
+ |
j ); |
156 |
+ |
painCave.isFatal = 1; |
157 |
+ |
simError(); |
158 |
+ |
} |
159 |
+ |
|
160 |
+ |
} |
161 |
+ |
|
162 |
+ |
currPos = new fpos_t; |
163 |
+ |
fgetpos( inFile, currPos ); |
164 |
+ |
fgets( readBuffer, sizeof( readBuffer ), inFile ); |
165 |
+ |
lineNum++; |
166 |
+ |
} |
167 |
+ |
|
168 |
+ |
delete currPos; |
169 |
+ |
rewind( inFile ); |
170 |
+ |
|
171 |
+ |
frameStart = new FilePos*[nFrames]; |
172 |
+ |
currFP = headFP; |
173 |
+ |
for(i=0; i<nFrames; i++){ |
174 |
+ |
|
175 |
+ |
currFP = currFP->getNext(); |
176 |
+ |
if( currFP == NULL ){ |
177 |
+ |
sprintf( painCave.errMsg, |
178 |
+ |
"DumpReader error: scanFile FilePos mismatch at " |
179 |
+ |
"nFrames = %d\n", |
180 |
+ |
i ); |
181 |
+ |
painCave.isFatal = 1; |
182 |
+ |
simError(); |
183 |
+ |
} |
184 |
+ |
|
185 |
+ |
frameStart[i] = currFP; |
186 |
+ |
} |
187 |
+ |
|
188 |
+ |
isScanned = true; |
189 |
+ |
|
190 |
+ |
#ifdef IS_MPI |
191 |
+ |
} |
192 |
+ |
strcpy( checkPointMsg, "Successfully scanned DumpFile\n" ); |
193 |
+ |
MPIcheckPoint(); |
194 |
+ |
#endif // is_mpi |
195 |
+ |
} |
196 |
+ |
|
197 |
+ |
void DumpReader :: readFrame( SimInfo* the_simnfo, int whichFrame){ |
198 |
+ |
|
199 |
+ |
simnfo = the_simnfo; |
200 |
+ |
|
201 |
+ |
this->readSet( whichFrame ); |
202 |
+ |
} |
203 |
+ |
|
204 |
+ |
|
205 |
+ |
|
206 |
+ |
void DumpReader :: readSet( int whichFrame ){ |
207 |
+ |
|
208 |
|
int i, j, done, which_node, which_atom; // loop counter |
209 |
|
|
210 |
|
const int BUFFERSIZE = 2000; // size of the read buffer |
219 |
|
int procIndex; |
220 |
|
double boxMat[9]; |
221 |
|
double theBoxMat3[3][3]; |
222 |
+ |
double time; |
223 |
|
|
224 |
< |
simnfo = the_simnfo; |
225 |
< |
|
224 |
> |
fpos_t *framePos; |
225 |
> |
|
226 |
|
#ifndef IS_MPI |
227 |
< |
eof_test = fgets(read_buffer, sizeof(read_buffer), c_in_file); |
227 |
> |
|
228 |
> |
framePos = frameStart[whichFrame]->getPos(); |
229 |
> |
|
230 |
> |
fsetpos(inFile, framePos); |
231 |
> |
|
232 |
> |
|
233 |
> |
eof_test = fgets(read_buffer, sizeof(read_buffer), inFile); |
234 |
|
if( eof_test == NULL ){ |
235 |
|
sprintf( painCave.errMsg, |
236 |
|
"DumpReader error: error reading 1st line of \"%s\"\n", |
237 |
< |
c_in_name ); |
237 |
> |
inName ); |
238 |
|
painCave.isFatal = 1; |
239 |
|
simError(); |
240 |
|
} |
248 |
|
sprintf( painCave.errMsg, |
249 |
|
"DumpReader error. %s n_atoms, %d, " |
250 |
|
"does not match the BASS file's n_atoms, %d.\n", |
251 |
< |
c_in_name, n_atoms, simnfo->n_atoms ); |
251 |
> |
inName, n_atoms, simnfo->n_atoms ); |
252 |
|
painCave.isFatal = 1; |
253 |
|
simError(); |
254 |
|
} |
255 |
|
|
256 |
|
//read the box mat from the comment line |
257 |
|
|
258 |
< |
eof_test = fgets(read_buffer, sizeof(read_buffer), c_in_file); |
258 |
> |
eof_test = fgets(read_buffer, sizeof(read_buffer), inFile); |
259 |
|
if(eof_test == NULL){ |
260 |
|
sprintf( painCave.errMsg, |
261 |
< |
"error in reading commment in %s\n", c_in_name); |
261 |
> |
"error in reading commment in %s\n", inName); |
262 |
|
painCave.isFatal = 1; |
263 |
|
simError(); |
264 |
|
} |
281 |
|
|
282 |
|
for( i=0; i < n_atoms; i++){ |
283 |
|
|
284 |
< |
eof_test = fgets(read_buffer, sizeof(read_buffer), c_in_file); |
284 |
> |
eof_test = fgets(read_buffer, sizeof(read_buffer), inFile); |
285 |
|
if(eof_test == NULL){ |
286 |
|
sprintf(painCave.errMsg, |
287 |
|
"error in reading file %s\n" |
288 |
|
"natoms = %d; index = %d\n" |
289 |
|
"error reading the line from the file.\n", |
290 |
< |
c_in_name, n_atoms, i ); |
290 |
> |
inName, n_atoms, i ); |
291 |
|
painCave.isFatal = 1; |
292 |
|
simError(); |
293 |
|
} |
317 |
|
|
318 |
|
haveError = 0; |
319 |
|
if (worldRank == 0) { |
320 |
< |
|
321 |
< |
eof_test = fgets(read_buffer, sizeof(read_buffer), c_in_file); |
320 |
> |
fsetpos(inFile, framePos); |
321 |
> |
eof_test = fgets(read_buffer, sizeof(read_buffer), inFile); |
322 |
|
if( eof_test == NULL ){ |
323 |
|
sprintf( painCave.errMsg, |
324 |
< |
"Error reading 1st line of %d \n ",c_in_name); |
324 |
> |
"Error reading 1st line of %d \n ",inName); |
325 |
|
haveError = 1; |
326 |
|
simError(); |
327 |
|
} |
338 |
|
sprintf( painCave.errMsg, |
339 |
|
"Initialize from File error. %s n_atoms, %d, " |
340 |
|
"does not match the BASS file's n_atoms, %d.\n", |
341 |
< |
c_in_name, n_atoms, simnfo->n_atoms ); |
341 |
> |
inName, n_atoms, simnfo->n_atoms ); |
342 |
|
haveError= 1; |
343 |
|
simError(); |
344 |
|
} |
345 |
|
|
346 |
|
//read the time and boxMat from the comment line |
347 |
|
|
348 |
< |
eof_test = fgets(read_buffer, sizeof(read_buffer), c_in_file); |
348 |
> |
eof_test = fgets(read_buffer, sizeof(read_buffer), inFile); |
349 |
|
if(eof_test == NULL){ |
350 |
|
sprintf( painCave.errMsg, |
351 |
< |
"error in reading commment in %s\n", c_in_name); |
351 |
> |
"error in reading commment in %s\n", inName); |
352 |
|
haveError = 1; |
353 |
|
simError(); |
354 |
|
} |
360 |
|
simError(); |
361 |
|
} |
362 |
|
|
363 |
< |
MPI_Bcast(time, 1, MPI_DOUBLE, 0, MPI_COMM_WORLD ); |
363 |
> |
MPI_Bcast(&time, 1, MPI_DOUBLE, 0, MPI_COMM_WORLD ); |
364 |
|
|
365 |
|
MPI_Bcast(boxMat, 9, MPI_DOUBLE, 0, MPI_COMM_WORLD ); |
366 |
|
|
368 |
|
|
369 |
|
for (i=0 ; i < mpiSim->getTotAtoms(); i++) { |
370 |
|
|
371 |
< |
eof_test = fgets(read_buffer, sizeof(read_buffer), c_in_file); |
371 |
> |
eof_test = fgets(read_buffer, sizeof(read_buffer), inFile); |
372 |
|
if(eof_test == NULL){ |
373 |
|
sprintf(painCave.errMsg, |
374 |
|
"error in reading file %s\n" |
375 |
|
"natoms = %d; index = %d\n" |
376 |
|
"error reading the line from the file.\n", |
377 |
< |
c_in_name, n_atoms, i ); |
377 |
> |
inName, n_atoms, i ); |
378 |
|
haveError= 1; |
379 |
|
simError(); |
380 |
|
} |
416 |
|
|
417 |
|
} else { |
418 |
|
|
419 |
< |
MPI_Bcast(time, 1, MPI_DOUBLE, 0, MPI_COMM_WORLD); |
419 |
> |
MPI_Bcast(&time, 1, MPI_DOUBLE, 0, MPI_COMM_WORLD); |
420 |
|
MPI_Bcast(boxMat, 9, MPI_DOUBLE, 0, MPI_COMM_WORLD); |
421 |
|
|
422 |
|
done = 0; |
466 |
|
|
467 |
|
char *foo; // the pointer to the current string token |
468 |
|
|
469 |
< |
double rx, ry, rz; // position place holders |
470 |
< |
double vx, vy, vz; // velocity placeholders |
469 |
> |
double pos[3]; // position place holders |
470 |
> |
double vel[3]; // velocity placeholders |
471 |
|
double q[4]; // the quaternions |
472 |
|
double jx, jy, jz; // angular velocity placeholders; |
473 |
|
double qSqr, qLength; // needed to normalize the quaternion vector. |
487 |
|
sprintf( painCave.errMsg, |
488 |
|
"Initialize from file error. Atom at index %d " |
489 |
|
"in file %s does not exist on processor %d .\n", |
490 |
< |
globalIndex, c_in_name, mpiSim->getMyNode() ); |
490 |
> |
globalIndex, inName, mpiSim->getMyNode() ); |
491 |
|
return strdup( painCave.errMsg ); |
492 |
|
} |
493 |
|
#else |
498 |
|
// set the string tokenizer |
499 |
|
|
500 |
|
foo = strtok(readLine, " ,;\t"); |
501 |
< |
|
501 |
> |
atoms[atomIndex]->setType(foo); |
502 |
|
// check the atom name to the current atom |
503 |
|
|
504 |
< |
if( strcmp( foo, atoms[atomIndex]->getType() ) ){ |
505 |
< |
sprintf( painCave.errMsg, |
506 |
< |
"Initialize from file error. Atom %s at index %d " |
507 |
< |
"in file %s does not" |
508 |
< |
" match the BASS atom %s.\n", |
509 |
< |
foo, atomIndex, c_in_name, atoms[atomIndex]->getType() ); |
510 |
< |
return strdup( painCave.errMsg ); |
511 |
< |
} |
504 |
> |
//if( strcmp( foo, atoms[atomIndex]->getType() ) ){ |
505 |
> |
// sprintf( painCave.errMsg, |
506 |
> |
// "Initialize from file error. Atom %s at index %d " |
507 |
> |
// "in file %s does not" |
508 |
> |
// " match the BASS atom %s.\n", |
509 |
> |
// foo, atomIndex, inName, atoms[atomIndex]->getType() ); |
510 |
> |
// return strdup( painCave.errMsg ); |
511 |
> |
//} |
512 |
|
|
513 |
|
// get the positions |
514 |
|
|
517 |
|
sprintf( painCave.errMsg, |
518 |
|
"error in reading postition x from %s\n" |
519 |
|
"natoms = %d, index = %d\n", |
520 |
< |
c_in_name, n_atoms, atomIndex ); |
520 |
> |
inName, n_atoms, atomIndex ); |
521 |
|
return strdup( painCave.errMsg ); |
522 |
|
} |
523 |
< |
rx = atof( foo ); |
523 |
> |
pos[0] = atof( foo ); |
524 |
|
|
525 |
|
foo = strtok(NULL, " ,;\t"); |
526 |
|
if(foo == NULL){ |
527 |
|
sprintf( painCave.errMsg, |
528 |
|
"error in reading postition y from %s\n" |
529 |
|
"natoms = %d, index = %d\n", |
530 |
< |
c_in_name, n_atoms, atomIndex ); |
530 |
> |
inName, n_atoms, atomIndex ); |
531 |
|
return strdup( painCave.errMsg ); |
532 |
|
} |
533 |
< |
ry = atof( foo ); |
533 |
> |
pos[1] = atof( foo ); |
534 |
|
|
535 |
|
foo = strtok(NULL, " ,;\t"); |
536 |
|
if(foo == NULL){ |
537 |
|
sprintf( painCave.errMsg, |
538 |
|
"error in reading postition z from %s\n" |
539 |
|
"natoms = %d, index = %d\n", |
540 |
< |
c_in_name, n_atoms, atomIndex ); |
540 |
> |
inName, n_atoms, atomIndex ); |
541 |
|
return strdup( painCave.errMsg ); |
542 |
|
} |
543 |
< |
rz = atof( foo ); |
543 |
> |
pos[2] = atof( foo ); |
544 |
|
|
545 |
|
|
546 |
|
// get the velocities |
550 |
|
sprintf( painCave.errMsg, |
551 |
|
"error in reading velocity x from %s\n" |
552 |
|
"natoms = %d, index = %d\n", |
553 |
< |
c_in_name, n_atoms, atomIndex ); |
553 |
> |
inName, n_atoms, atomIndex ); |
554 |
|
return strdup( painCave.errMsg ); |
555 |
|
} |
556 |
< |
vx = atof( foo ); |
556 |
> |
vel[0] = atof( foo ); |
557 |
|
|
558 |
|
foo = strtok(NULL, " ,;\t"); |
559 |
|
if(foo == NULL){ |
560 |
|
sprintf( painCave.errMsg, |
561 |
|
"error in reading velocity y from %s\n" |
562 |
|
"natoms = %d, index = %d\n", |
563 |
< |
c_in_name, n_atoms, atomIndex ); |
563 |
> |
inName, n_atoms, atomIndex ); |
564 |
|
return strdup( painCave.errMsg ); |
565 |
|
} |
566 |
< |
vy = atof( foo ); |
566 |
> |
vel[1] = atof( foo ); |
567 |
|
|
568 |
|
foo = strtok(NULL, " ,;\t"); |
569 |
|
if(foo == NULL){ |
570 |
|
sprintf( painCave.errMsg, |
571 |
|
"error in reading velocity z from %s\n" |
572 |
|
"natoms = %d, index = %d\n", |
573 |
< |
c_in_name, n_atoms, atomIndex ); |
573 |
> |
inName, n_atoms, atomIndex ); |
574 |
|
return strdup( painCave.errMsg ); |
575 |
|
} |
576 |
< |
vz = atof( foo ); |
576 |
> |
vel[2] = atof( foo ); |
577 |
|
|
578 |
|
|
579 |
|
// get the quaternions |
585 |
|
sprintf(painCave.errMsg, |
586 |
|
"error in reading quaternion 0 from %s\n" |
587 |
|
"natoms = %d, index = %d\n", |
588 |
< |
c_in_name, n_atoms, atomIndex ); |
588 |
> |
inName, n_atoms, atomIndex ); |
589 |
|
return strdup( painCave.errMsg ); |
590 |
|
} |
591 |
|
q[0] = atof( foo ); |
595 |
|
sprintf( painCave.errMsg, |
596 |
|
"error in reading quaternion 1 from %s\n" |
597 |
|
"natoms = %d, index = %d\n", |
598 |
< |
c_in_name, n_atoms, atomIndex ); |
598 |
> |
inName, n_atoms, atomIndex ); |
599 |
|
return strdup( painCave.errMsg ); |
600 |
|
} |
601 |
|
q[1] = atof( foo ); |
605 |
|
sprintf( painCave.errMsg, |
606 |
|
"error in reading quaternion 2 from %s\n" |
607 |
|
"natoms = %d, index = %d\n", |
608 |
< |
c_in_name, n_atoms, atomIndex ); |
608 |
> |
inName, n_atoms, atomIndex ); |
609 |
|
return strdup( painCave.errMsg ); |
610 |
|
} |
611 |
|
q[2] = atof( foo ); |
615 |
|
sprintf( painCave.errMsg, |
616 |
|
"error in reading quaternion 3 from %s\n" |
617 |
|
"natoms = %d, index = %d\n", |
618 |
< |
c_in_name, n_atoms, atomIndex ); |
618 |
> |
inName, n_atoms, atomIndex ); |
619 |
|
return strdup( painCave.errMsg ); |
620 |
|
} |
621 |
|
q[3] = atof( foo ); |
627 |
|
sprintf( painCave.errMsg, |
628 |
|
"error in reading angular momentum jx from %s\n" |
629 |
|
"natoms = %d, index = %d\n", |
630 |
< |
c_in_name, n_atoms, atomIndex ); |
630 |
> |
inName, n_atoms, atomIndex ); |
631 |
|
return strdup( painCave.errMsg ); |
632 |
|
} |
633 |
|
jx = atof( foo ); |
637 |
|
sprintf( painCave.errMsg, |
638 |
|
"error in reading angular momentum jy from %s\n" |
639 |
|
"natoms = %d, index = %d\n", |
640 |
< |
c_in_name, n_atoms, atomIndex ); |
640 |
> |
inName, n_atoms, atomIndex ); |
641 |
|
return strdup( painCave.errMsg ); |
642 |
|
} |
643 |
|
jy = atof(foo ); |
647 |
|
sprintf( painCave.errMsg, |
648 |
|
"error in reading angular momentum jz from %s\n" |
649 |
|
"natoms = %d, index = %d\n", |
650 |
< |
c_in_name, n_atoms, atomIndex ); |
650 |
> |
inName, n_atoms, atomIndex ); |
651 |
|
return strdup( painCave.errMsg ); |
652 |
|
} |
653 |
|
jz = atof( foo ); |
674 |
|
} |
675 |
|
|
676 |
|
// add the positions and velocities to the atom |
539 |
– |
|
540 |
– |
atoms[atomIndex]->setX( rx ); |
541 |
– |
atoms[atomIndex]->setY( ry ); |
542 |
– |
atoms[atomIndex]->setZ( rz ); |
543 |
– |
|
544 |
– |
atoms[atomIndex]->set_vx( vx ); |
545 |
– |
atoms[atomIndex]->set_vy( vy ); |
546 |
– |
atoms[atomIndex]->set_vz( vz ); |
677 |
|
|
678 |
+ |
atoms[atomIndex]->setPos( pos ); |
679 |
+ |
atoms[atomIndex]->setVel( vel ); |
680 |
+ |
|
681 |
|
return NULL; |
682 |
|
} |
683 |
|
|
684 |
|
|
685 |
< |
char* DumpReader::parseCommentLine(char* readLine, double time, |
685 |
> |
char* DumpReader::parseCommentLine(char* readLine, double &time, |
686 |
|
double boxMat[9]){ |
687 |
|
|
688 |
|
char *foo; // the pointer to the current string token |
689 |
|
int j; |
690 |
+ |
double chi, integralOfChidt; |
691 |
+ |
double eta[9]; |
692 |
|
|
693 |
|
// set the string tokenizer |
694 |
|
|
696 |
|
if(foo == NULL){ |
697 |
|
sprintf( painCave.errMsg, |
698 |
|
"error in reading time from %s\n", |
699 |
< |
c_in_name ); |
699 |
> |
inName ); |
700 |
|
return strdup( painCave.errMsg ); |
701 |
|
} |
702 |
|
time = atof( foo ); |
707 |
|
if(foo == NULL){ |
708 |
|
sprintf( painCave.errMsg, |
709 |
|
"error in reading Hx[0] from %s\n", |
710 |
< |
c_in_name ); |
710 |
> |
inName ); |
711 |
|
return strdup( painCave.errMsg ); |
712 |
|
} |
713 |
|
boxMat[0] = atof( foo ); |
716 |
|
if(foo == NULL){ |
717 |
|
sprintf( painCave.errMsg, |
718 |
|
"error in reading Hx[1] from %s\n", |
719 |
< |
c_in_name ); |
719 |
> |
inName ); |
720 |
|
return strdup( painCave.errMsg ); |
721 |
|
} |
722 |
|
boxMat[1] = atof( foo ); |
725 |
|
if(foo == NULL){ |
726 |
|
sprintf( painCave.errMsg, |
727 |
|
"error in reading Hx[2] from %s\n", |
728 |
< |
c_in_name ); |
728 |
> |
inName ); |
729 |
|
return strdup( painCave.errMsg ); |
730 |
|
} |
731 |
|
boxMat[2] = atof( foo ); |
736 |
|
if(foo == NULL){ |
737 |
|
sprintf( painCave.errMsg, |
738 |
|
"error in reading Hy[0] from %s\n", |
739 |
< |
c_in_name ); |
739 |
> |
inName ); |
740 |
|
return strdup( painCave.errMsg ); |
741 |
|
} |
742 |
|
boxMat[3] = atof( foo ); |
745 |
|
if(foo == NULL){ |
746 |
|
sprintf( painCave.errMsg, |
747 |
|
"error in reading Hy[1] from %s\n", |
748 |
< |
c_in_name ); |
748 |
> |
inName ); |
749 |
|
return strdup( painCave.errMsg ); |
750 |
|
} |
751 |
|
boxMat[4] = atof( foo ); |
754 |
|
if(foo == NULL){ |
755 |
|
sprintf( painCave.errMsg, |
756 |
|
"error in reading Hy[2] from %s\n", |
757 |
< |
c_in_name ); |
757 |
> |
inName ); |
758 |
|
return strdup( painCave.errMsg ); |
759 |
|
} |
760 |
|
boxMat[5] = atof( foo ); |
765 |
|
if(foo == NULL){ |
766 |
|
sprintf( painCave.errMsg, |
767 |
|
"error in reading Hz[0] from %s\n", |
768 |
< |
c_in_name ); |
768 |
> |
inName ); |
769 |
|
return strdup( painCave.errMsg ); |
770 |
|
} |
771 |
|
boxMat[6] = atof( foo ); |
774 |
|
if(foo == NULL){ |
775 |
|
sprintf( painCave.errMsg, |
776 |
|
"error in reading Hz[1] from %s\n", |
777 |
< |
c_in_name ); |
777 |
> |
inName ); |
778 |
|
return strdup( painCave.errMsg ); |
779 |
|
} |
780 |
|
boxMat[7] = atof( foo ); |
783 |
|
if(foo == NULL){ |
784 |
|
sprintf( painCave.errMsg, |
785 |
|
"error in reading Hz[2] from %s\n", |
786 |
< |
c_in_name ); |
786 |
> |
inName ); |
787 |
|
return strdup( painCave.errMsg ); |
788 |
|
} |
789 |
|
boxMat[8] = atof( foo ); |
790 |
|
|
791 |
|
return NULL; |
792 |
+ |
|
793 |
+ |
//get chi and integralOfChidt, they should appear by pair |
794 |
+ |
foo = strtok(NULL, " ,;\t\n"); |
795 |
+ |
if(foo != NULL){ |
796 |
+ |
chi = atof(foo); |
797 |
+ |
|
798 |
+ |
foo = strtok(NULL, " ,;\t\n"); |
799 |
+ |
if(foo == NULL){ |
800 |
+ |
sprintf( painCave.errMsg, |
801 |
+ |
"chi and integralOfChidt should appear by pair in %s\n", inName ); |
802 |
+ |
return strdup( painCave.errMsg ); |
803 |
+ |
} |
804 |
+ |
integralOfChidt = atof( foo ); |
805 |
+ |
|
806 |
+ |
//push chi and integralOfChidt into SimInfo::properties which can be |
807 |
+ |
//retrieved by integrator later |
808 |
+ |
DoubleData* chiValue = new DoubleData(); |
809 |
+ |
chiValue->setID(CHIVALUE_ID); |
810 |
+ |
chiValue->setData(chi); |
811 |
+ |
simnfo->addProperty(chiValue); |
812 |
+ |
|
813 |
+ |
DoubleData* integralOfChidtValue = new DoubleData(); |
814 |
+ |
integralOfChidtValue->setID(INTEGRALOFCHIDT_ID); |
815 |
+ |
integralOfChidtValue->setData(integralOfChidt); |
816 |
+ |
simnfo->addProperty(integralOfChidtValue); |
817 |
+ |
|
818 |
+ |
} |
819 |
+ |
else |
820 |
+ |
return NULL; |
821 |
+ |
|
822 |
+ |
//get eta |
823 |
+ |
for(int i = 0 ; i < 9; i++){ |
824 |
+ |
foo = strtok(NULL, " ,;\t"); |
825 |
+ |
if(foo == NULL){ |
826 |
+ |
sprintf( painCave.errMsg, |
827 |
+ |
"error in reading eta[%d] from %s\n", i, inName ); |
828 |
+ |
return strdup( painCave.errMsg ); |
829 |
+ |
} |
830 |
+ |
eta[i] = atof( foo ); |
831 |
+ |
} |
832 |
+ |
|
833 |
+ |
//push eta into SimInfo::properties which can be |
834 |
+ |
//retrieved by integrator later |
835 |
+ |
//simnfo->setBoxM( theBoxMat3 ); |
836 |
+ |
DoubleArrayData* etaValue = new DoubleArrayData(); |
837 |
+ |
etaValue->setID(ETAVALUE_ID); |
838 |
+ |
etaValue->setData(eta, 9); |
839 |
+ |
simnfo->addProperty(etaValue); |
840 |
+ |
|
841 |
+ |
|
842 |
+ |
return NULL; |
843 |
+ |
|
844 |
+ |
|
845 |
+ |
|
846 |
|
} |
847 |
|
|
848 |
|
|
850 |
|
|
851 |
|
// a couple of functions to let us escape the read loop |
852 |
|
|
853 |
< |
void initFile::nodeZeroError( void ){ |
853 |
> |
void dumpRead::nodeZeroError( void ){ |
854 |
|
int j, myStatus; |
855 |
|
|
856 |
|
myStatus = 0; |
865 |
|
|
866 |
|
} |
867 |
|
|
868 |
< |
void initFile::anonymousNodeDie( void ){ |
868 |
> |
void dumpRead::anonymousNodeDie( void ){ |
869 |
|
|
870 |
|
MPI_Finalize(); |
871 |
|
exit (0); |