| 69 |
|
} |
| 70 |
|
|
| 71 |
|
|
| 72 |
< |
void InitializeFromFile :: read_xyz( SimInfo* the_entry_plug ){ |
| 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 boxMat[9]; |
| 87 |
+ |
double theBoxMat3[3][3]; |
| 88 |
|
|
| 89 |
< |
entry_plug = the_entry_plug; |
| 89 |
> |
simnfo = the_simnfo; |
| 90 |
|
|
| 91 |
|
|
| 92 |
|
#ifndef IS_MPI |
| 101 |
|
|
| 102 |
|
n_atoms = atoi( read_buffer ); |
| 103 |
|
|
| 104 |
< |
Atom **atoms = entry_plug->atoms; |
| 104 |
> |
Atom **atoms = simnfo->atoms; |
| 105 |
|
DirectionalAtom* dAtom; |
| 106 |
|
|
| 107 |
< |
if( n_atoms != entry_plug->n_atoms ){ |
| 107 |
> |
if( n_atoms != simnfo->n_atoms ){ |
| 108 |
|
sprintf( painCave.errMsg, |
| 109 |
|
"Initialize from File error. %s n_atoms, %d, " |
| 110 |
|
"does not match the BASS file's n_atoms, %d.\n", |
| 111 |
< |
c_in_name, n_atoms, entry_plug->n_atoms ); |
| 111 |
> |
c_in_name, n_atoms, simnfo->n_atoms ); |
| 112 |
|
painCave.isFatal = 1; |
| 113 |
|
simError(); |
| 114 |
|
} |
| 115 |
|
|
| 116 |
< |
//read and toss the comment line |
| 116 |
> |
//read the box mat from the comment line |
| 117 |
|
|
| 118 |
|
eof_test = fgets(read_buffer, sizeof(read_buffer), c_in_file); |
| 119 |
|
if(eof_test == NULL){ |
| 123 |
|
simError(); |
| 124 |
|
} |
| 125 |
|
|
| 126 |
+ |
parseErr = parseBoxLine( read_buffer, boxMat ); |
| 127 |
+ |
if( parseErr != NULL ){ |
| 128 |
+ |
strcpy( painCave.errMsg, parseErr ); |
| 129 |
+ |
painCave.isFatal = 1; |
| 130 |
+ |
simError(); |
| 131 |
+ |
} |
| 132 |
+ |
|
| 133 |
+ |
for(i=0;i<3;i++) |
| 134 |
+ |
for(j=0;j<3;j++) theBoxMat3[i][j] = boxMat[3*j+i]; |
| 135 |
+ |
|
| 136 |
+ |
simnfo->setBoxM( theBoxMat3 ); |
| 137 |
+ |
|
| 138 |
+ |
|
| 139 |
|
for( i=0; i < n_atoms; i++){ |
| 140 |
|
|
| 141 |
|
eof_test = fgets(read_buffer, sizeof(read_buffer), c_in_file); |
| 155 |
|
strcpy( painCave.errMsg, parseErr ); |
| 156 |
|
painCave.isFatal = 1; |
| 157 |
|
simError(); |
| 158 |
< |
} |
| 158 |
> |
} |
| 159 |
|
} |
| 160 |
|
|
| 161 |
|
|
| 185 |
|
|
| 186 |
|
n_atoms = atoi( read_buffer ); |
| 187 |
|
|
| 188 |
< |
Atom **atoms = entry_plug->atoms; |
| 188 |
> |
Atom **atoms = simnfo->atoms; |
| 189 |
|
DirectionalAtom* dAtom; |
| 190 |
|
|
| 191 |
|
// Check to see that the number of atoms in the intial configuration file is the |
| 195 |
|
sprintf( painCave.errMsg, |
| 196 |
|
"Initialize from File error. %s n_atoms, %d, " |
| 197 |
|
"does not match the BASS file's n_atoms, %d.\n", |
| 198 |
< |
c_in_name, n_atoms, entry_plug->n_atoms ); |
| 198 |
> |
c_in_name, n_atoms, simnfo->n_atoms ); |
| 199 |
|
haveError= 1; |
| 200 |
|
simError(); |
| 201 |
|
} |
| 202 |
|
|
| 203 |
< |
//read and toss the comment line |
| 203 |
> |
//read the boxMat from the comment line |
| 204 |
|
|
| 205 |
|
eof_test = fgets(read_buffer, sizeof(read_buffer), c_in_file); |
| 206 |
|
if(eof_test == NULL){ |
| 207 |
|
sprintf( painCave.errMsg, |
| 208 |
|
"error in reading commment in %s\n", c_in_name); |
| 209 |
< |
haveError= 1; |
| 209 |
> |
haveError = 1; |
| 210 |
|
simError(); |
| 211 |
|
} |
| 212 |
+ |
|
| 213 |
+ |
parseErr = parseBoxLine( read_buffer, boxMat ); |
| 214 |
+ |
if( parseErr != NULL ){ |
| 215 |
+ |
strcpy( painCave.errMsg, parseErr ); |
| 216 |
+ |
haveError = 1; |
| 217 |
+ |
simError(); |
| 218 |
+ |
} |
| 219 |
+ |
|
| 220 |
+ |
MPI_Bcast(boxMat, 9, MPI_DOUBLE, 0, MPI_COMM_WORLD ); |
| 221 |
|
|
| 222 |
|
if(haveError) nodeZeroError(); |
| 223 |
|
|
| 271 |
|
|
| 272 |
|
} else { |
| 273 |
|
|
| 274 |
+ |
MPI_Bcast(boxMat, 9, MPI_DOUBLE, 0, MPI_COMM_WORLD); |
| 275 |
+ |
|
| 276 |
|
done = 0; |
| 277 |
|
while (!done) { |
| 278 |
|
|
| 304 |
|
|
| 305 |
|
// last thing last, enable fatalities. |
| 306 |
|
painCave.isEventLoop = 0; |
| 307 |
+ |
|
| 308 |
+ |
for(i=0;i<3;i++) |
| 309 |
+ |
for(j=0;j<3;j++) theBoxMat3[i][j] = boxMat[3*j+i]; |
| 310 |
+ |
|
| 311 |
+ |
simnfo->setBoxM( theBoxMat3 ); |
| 312 |
+ |
|
| 313 |
|
|
| 314 |
|
#endif |
| 315 |
|
} |
| 324 |
|
double jx, jy, jz; // angular velocity placeholders; |
| 325 |
|
double qSqr, qLength; // needed to normalize the quaternion vector. |
| 326 |
|
|
| 327 |
< |
Atom **atoms = entry_plug->atoms; |
| 327 |
> |
Atom **atoms = simnfo->atoms; |
| 328 |
|
DirectionalAtom* dAtom; |
| 329 |
|
|
| 330 |
|
int j, n_atoms, atomIndex; |
| 343 |
|
return strdup( painCave.errMsg ); |
| 344 |
|
} |
| 345 |
|
#else |
| 346 |
< |
n_atoms = entry_plug->n_atoms; |
| 346 |
> |
n_atoms = simnfo->n_atoms; |
| 347 |
|
atomIndex = globalIndex; |
| 348 |
|
#endif // is_mpi |
| 349 |
|
|
| 539 |
|
} |
| 540 |
|
|
| 541 |
|
|
| 542 |
+ |
char* InitializeFromFile::parseBoxLine(char* readLine, double boxMat[9]){ |
| 543 |
+ |
|
| 544 |
+ |
char *foo; // the pointer to the current string token |
| 545 |
+ |
int j; |
| 546 |
+ |
|
| 547 |
+ |
// set the string tokenizer |
| 548 |
+ |
|
| 549 |
+ |
foo = strtok(readLine, " ,;\t"); |
| 550 |
+ |
// set the timeToken. |
| 551 |
+ |
|
| 552 |
+ |
if(foo == NULL){ |
| 553 |
+ |
sprintf( painCave.errMsg, |
| 554 |
+ |
"error in reading Time from %s\n", |
| 555 |
+ |
c_in_name ); |
| 556 |
+ |
return strdup( painCave.errMsg ); |
| 557 |
+ |
} |
| 558 |
+ |
simnfo->currentTime = atof( foo ); |
| 559 |
+ |
|
| 560 |
+ |
// get the Hx vector |
| 561 |
+ |
|
| 562 |
+ |
foo = strtok(NULL, " ,;\t"); |
| 563 |
+ |
if(foo == NULL){ |
| 564 |
+ |
sprintf( painCave.errMsg, |
| 565 |
+ |
"error in reading Hx[0] from %s\n", |
| 566 |
+ |
c_in_name ); |
| 567 |
+ |
return strdup( painCave.errMsg ); |
| 568 |
+ |
} |
| 569 |
+ |
boxMat[0] = atof( foo ); |
| 570 |
+ |
|
| 571 |
+ |
foo = strtok(NULL, " ,;\t"); |
| 572 |
+ |
if(foo == NULL){ |
| 573 |
+ |
sprintf( painCave.errMsg, |
| 574 |
+ |
"error in reading Hx[1] from %s\n", |
| 575 |
+ |
c_in_name ); |
| 576 |
+ |
return strdup( painCave.errMsg ); |
| 577 |
+ |
} |
| 578 |
+ |
boxMat[1] = atof( foo ); |
| 579 |
+ |
|
| 580 |
+ |
foo = strtok(NULL, " ,;\t"); |
| 581 |
+ |
if(foo == NULL){ |
| 582 |
+ |
sprintf( painCave.errMsg, |
| 583 |
+ |
"error in reading Hx[2] from %s\n", |
| 584 |
+ |
c_in_name ); |
| 585 |
+ |
return strdup( painCave.errMsg ); |
| 586 |
+ |
} |
| 587 |
+ |
boxMat[2] = atof( foo ); |
| 588 |
+ |
|
| 589 |
+ |
// get the Hy vector |
| 590 |
+ |
|
| 591 |
+ |
foo = strtok(NULL, " ,;\t"); |
| 592 |
+ |
if(foo == NULL){ |
| 593 |
+ |
sprintf( painCave.errMsg, |
| 594 |
+ |
"error in reading Hy[0] from %s\n", |
| 595 |
+ |
c_in_name ); |
| 596 |
+ |
return strdup( painCave.errMsg ); |
| 597 |
+ |
} |
| 598 |
+ |
boxMat[3] = atof( foo ); |
| 599 |
+ |
|
| 600 |
+ |
foo = strtok(NULL, " ,;\t"); |
| 601 |
+ |
if(foo == NULL){ |
| 602 |
+ |
sprintf( painCave.errMsg, |
| 603 |
+ |
"error in reading Hy[1] from %s\n", |
| 604 |
+ |
c_in_name ); |
| 605 |
+ |
return strdup( painCave.errMsg ); |
| 606 |
+ |
} |
| 607 |
+ |
boxMat[4] = atof( foo ); |
| 608 |
+ |
|
| 609 |
+ |
foo = strtok(NULL, " ,;\t"); |
| 610 |
+ |
if(foo == NULL){ |
| 611 |
+ |
sprintf( painCave.errMsg, |
| 612 |
+ |
"error in reading Hy[2] from %s\n", |
| 613 |
+ |
c_in_name ); |
| 614 |
+ |
return strdup( painCave.errMsg ); |
| 615 |
+ |
} |
| 616 |
+ |
boxMat[5] = atof( foo ); |
| 617 |
+ |
|
| 618 |
+ |
// get the Hz vector |
| 619 |
+ |
|
| 620 |
+ |
foo = strtok(NULL, " ,;\t"); |
| 621 |
+ |
if(foo == NULL){ |
| 622 |
+ |
sprintf( painCave.errMsg, |
| 623 |
+ |
"error in reading Hz[0] from %s\n", |
| 624 |
+ |
c_in_name ); |
| 625 |
+ |
return strdup( painCave.errMsg ); |
| 626 |
+ |
} |
| 627 |
+ |
boxMat[6] = atof( foo ); |
| 628 |
+ |
|
| 629 |
+ |
foo = strtok(NULL, " ,;\t"); |
| 630 |
+ |
if(foo == NULL){ |
| 631 |
+ |
sprintf( painCave.errMsg, |
| 632 |
+ |
"error in reading Hz[1] from %s\n", |
| 633 |
+ |
c_in_name ); |
| 634 |
+ |
return strdup( painCave.errMsg ); |
| 635 |
+ |
} |
| 636 |
+ |
boxMat[7] = atof( foo ); |
| 637 |
+ |
|
| 638 |
+ |
foo = strtok(NULL, " ,;\t"); |
| 639 |
+ |
if(foo == NULL){ |
| 640 |
+ |
sprintf( painCave.errMsg, |
| 641 |
+ |
"error in reading Hz[2] from %s\n", |
| 642 |
+ |
c_in_name ); |
| 643 |
+ |
return strdup( painCave.errMsg ); |
| 644 |
+ |
} |
| 645 |
+ |
boxMat[8] = atof( foo ); |
| 646 |
+ |
|
| 647 |
+ |
return NULL; |
| 648 |
+ |
} |
| 649 |
+ |
|
| 650 |
+ |
|
| 651 |
|
#ifdef IS_MPI |
| 652 |
|
|
| 653 |
|
// a couple of functions to let us escape the read loop |