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