69 |
|
} |
70 |
|
|
71 |
|
|
72 |
< |
void InitializeFromFile :: read_xyz( SimInfo* the_simnfo ){ |
72 |
> |
void InitializeFromFile :: readInit( SimInfo* the_simnfo ){ |
73 |
|
|
74 |
|
int i, j, done, which_node, which_atom; // loop counter |
75 |
|
|
83 |
|
char *eof_test; // ptr to see when we reach the end of the file |
84 |
|
char *parseErr; |
85 |
|
int procIndex; |
86 |
+ |
double currTime; |
87 |
|
double boxMat[9]; |
88 |
< |
|
88 |
> |
double theBoxMat3[3][3]; |
89 |
|
|
90 |
|
simnfo = the_simnfo; |
91 |
|
|
124 |
|
simError(); |
125 |
|
} |
126 |
|
|
127 |
< |
parseErr = parseBoxLine( read_buffer, boxMat ); |
127 |
> |
parseErr = parseBoxLine( read_buffer, boxMat, currTime ); |
128 |
|
if( parseErr != NULL ){ |
129 |
|
strcpy( painCave.errMsg, parseErr ); |
130 |
|
painCave.isFatal = 1; |
131 |
|
simError(); |
132 |
|
} |
133 |
|
|
134 |
< |
simnfo->setBoxM( boxMat ); |
134 |
> |
for(i=0;i<3;i++) |
135 |
> |
for(j=0;j<3;j++) theBoxMat3[i][j] = boxMat[3*j+i]; |
136 |
|
|
137 |
+ |
simnfo->setBoxM( theBoxMat3 ); |
138 |
+ |
simnfo->setTime( currTime ); |
139 |
|
|
140 |
+ |
|
141 |
|
for( i=0; i < n_atoms; i++){ |
142 |
|
|
143 |
|
eof_test = fgets(read_buffer, sizeof(read_buffer), c_in_file); |
212 |
|
simError(); |
213 |
|
} |
214 |
|
|
215 |
< |
parseErr = parseBoxLine( read_buffer, boxMat ); |
215 |
> |
parseErr = parseBoxLine( read_buffer, boxMat, currTime ); |
216 |
|
if( parseErr != NULL ){ |
217 |
|
strcpy( painCave.errMsg, parseErr ); |
218 |
|
haveError = 1; |
220 |
|
} |
221 |
|
|
222 |
|
MPI_Bcast(boxMat, 9, MPI_DOUBLE, 0, MPI_COMM_WORLD ); |
223 |
+ |
MPI_Bcast(&currTime, 1, MPI_DOUBLE, 0, MPI_COMM_WORLD ); |
224 |
|
|
225 |
|
if(haveError) nodeZeroError(); |
226 |
|
|
275 |
|
} else { |
276 |
|
|
277 |
|
MPI_Bcast(boxMat, 9, MPI_DOUBLE, 0, MPI_COMM_WORLD); |
278 |
+ |
MPI_Bcast(&currTime, 1, MPI_DOUBLE, 0, MPI_COMM_WORLD); |
279 |
|
|
280 |
|
done = 0; |
281 |
|
while (!done) { |
308 |
|
|
309 |
|
// last thing last, enable fatalities. |
310 |
|
painCave.isEventLoop = 0; |
311 |
< |
simnfo->setBoxM( boxMat ); |
311 |
> |
|
312 |
> |
for(i=0;i<3;i++) |
313 |
> |
for(j=0;j<3;j++) theBoxMat3[i][j] = boxMat[3*j+i]; |
314 |
|
|
315 |
+ |
simnfo->setBoxM( theBoxMat3 ); |
316 |
+ |
simnfo->setTime( currTime ); |
317 |
+ |
|
318 |
|
|
319 |
|
#endif |
320 |
|
} |
544 |
|
} |
545 |
|
|
546 |
|
|
547 |
< |
char* InitializeFromFile::parseBoxLine(char* readLine, double boxMat[9]){ |
547 |
> |
char* InitializeFromFile::parseBoxLine(char* readLine, double boxMat[9], |
548 |
> |
double &time ){ |
549 |
|
|
550 |
|
char *foo; // the pointer to the current string token |
551 |
|
int j; |
553 |
|
// set the string tokenizer |
554 |
|
|
555 |
|
foo = strtok(readLine, " ,;\t"); |
556 |
< |
// ignore the first token which is the time stamp. |
556 |
> |
// set the timeToken. |
557 |
|
|
558 |
+ |
if(foo == NULL){ |
559 |
+ |
sprintf( painCave.errMsg, |
560 |
+ |
"error in reading Time from %s\n", |
561 |
+ |
c_in_name ); |
562 |
+ |
return strdup( painCave.errMsg ); |
563 |
+ |
} |
564 |
+ |
time = atof( foo ); |
565 |
|
|
566 |
|
// get the Hx vector |
567 |
|
|