| 26 | 
  | 
 | 
| 27 | 
  | 
#endif // is_mpi | 
| 28 | 
  | 
 | 
| 29 | 
< | 
InitializeFromFile :: InitializeFromFile( char *in_name ){ | 
| 29 | 
> | 
InitializeFromFile::InitializeFromFile( char *in_name ){ | 
| 30 | 
> | 
 | 
| 31 | 
  | 
#ifdef IS_MPI | 
| 32 | 
  | 
  if (worldRank == 0) { | 
| 33 | 
  | 
#endif | 
| 49 | 
  | 
  return;   | 
| 50 | 
  | 
} | 
| 51 | 
  | 
 | 
| 52 | 
< | 
InitializeFromFile :: ~InitializeFromFile( ){ | 
| 52 | 
> | 
InitializeFromFile::~InitializeFromFile( ){ | 
| 53 | 
  | 
#ifdef IS_MPI | 
| 54 | 
  | 
  if (worldRank == 0) { | 
| 55 | 
  | 
#endif | 
| 70 | 
  | 
} | 
| 71 | 
  | 
 | 
| 72 | 
  | 
 | 
| 73 | 
< | 
void InitializeFromFile :: read_xyz( SimInfo* the_simnfo ){ | 
| 73 | 
> | 
void InitializeFromFile :: readInit( SimInfo* the_simnfo ){ | 
| 74 | 
  | 
 | 
| 75 | 
  | 
  int i, j, done, which_node, which_atom; // loop counter | 
| 76 | 
  | 
 | 
| 84 | 
  | 
  char *eof_test; // ptr to see when we reach the end of the file  | 
| 85 | 
  | 
  char *parseErr; | 
| 86 | 
  | 
  int procIndex; | 
| 87 | 
+ | 
  double currTime; | 
| 88 | 
  | 
  double boxMat[9]; | 
| 89 | 
  | 
  double theBoxMat3[3][3]; | 
| 90 | 
  | 
 | 
| 125 | 
  | 
    simError(); | 
| 126 | 
  | 
  } | 
| 127 | 
  | 
 | 
| 128 | 
< | 
  parseErr = parseBoxLine( read_buffer, boxMat ); | 
| 128 | 
> | 
  parseErr = parseBoxLine( read_buffer, boxMat, currTime ); | 
| 129 | 
  | 
  if( parseErr != NULL ){ | 
| 130 | 
  | 
    strcpy( painCave.errMsg, parseErr ); | 
| 131 | 
  | 
    painCave.isFatal = 1; | 
| 136 | 
  | 
    for(j=0;j<3;j++) theBoxMat3[i][j] = boxMat[3*j+i]; | 
| 137 | 
  | 
 | 
| 138 | 
  | 
  simnfo->setBoxM( theBoxMat3 ); | 
| 139 | 
+ | 
  simnfo->setTime( currTime ); | 
| 140 | 
  | 
 | 
| 141 | 
  | 
 | 
| 142 | 
  | 
  for( i=0; i < n_atoms; i++){ | 
| 213 | 
  | 
      simError(); | 
| 214 | 
  | 
    } | 
| 215 | 
  | 
     | 
| 216 | 
< | 
    parseErr = parseBoxLine( read_buffer, boxMat ); | 
| 216 | 
> | 
    parseErr = parseBoxLine( read_buffer, boxMat, currTime ); | 
| 217 | 
  | 
    if( parseErr != NULL ){ | 
| 218 | 
  | 
      strcpy( painCave.errMsg, parseErr ); | 
| 219 | 
  | 
      haveError = 1; | 
| 221 | 
  | 
    } | 
| 222 | 
  | 
 | 
| 223 | 
  | 
    MPI_Bcast(boxMat, 9, MPI_DOUBLE, 0, MPI_COMM_WORLD ); | 
| 224 | 
+ | 
    MPI_Bcast(&currTime, 1, MPI_DOUBLE, 0, MPI_COMM_WORLD ); | 
| 225 | 
  | 
   | 
| 226 | 
  | 
    if(haveError) nodeZeroError(); | 
| 227 | 
  | 
 | 
| 276 | 
  | 
  } else { | 
| 277 | 
  | 
     | 
| 278 | 
  | 
    MPI_Bcast(boxMat, 9, MPI_DOUBLE, 0, MPI_COMM_WORLD); | 
| 279 | 
+ | 
    MPI_Bcast(&currTime, 1, MPI_DOUBLE, 0, MPI_COMM_WORLD); | 
| 280 | 
  | 
 | 
| 281 | 
  | 
    done = 0; | 
| 282 | 
  | 
    while (!done) { | 
| 314 | 
  | 
    for(j=0;j<3;j++) theBoxMat3[i][j] = boxMat[3*j+i]; | 
| 315 | 
  | 
 | 
| 316 | 
  | 
  simnfo->setBoxM( theBoxMat3 ); | 
| 317 | 
+ | 
  simnfo->setTime( currTime ); | 
| 318 | 
  | 
 | 
| 319 | 
  | 
    | 
| 320 | 
  | 
#endif | 
| 324 | 
  | 
 | 
| 325 | 
  | 
  char *foo; // the pointer to the current string token  | 
| 326 | 
  | 
   | 
| 327 | 
< | 
  double rx, ry, rz; // position place holders | 
| 328 | 
< | 
  double vx, vy, vz; // velocity placeholders | 
| 327 | 
> | 
  double pos[3]; // position place holders | 
| 328 | 
> | 
  double vel[3]; // velocity placeholders | 
| 329 | 
  | 
  double q[4]; // the quaternions | 
| 330 | 
  | 
  double jx, jy, jz; // angular velocity placeholders; | 
| 331 | 
  | 
  double qSqr, qLength; // needed to normalize the quaternion vector. | 
| 378 | 
  | 
             c_in_name, n_atoms, atomIndex ); | 
| 379 | 
  | 
    return strdup( painCave.errMsg ); | 
| 380 | 
  | 
  } | 
| 381 | 
< | 
  rx = atof( foo ); | 
| 381 | 
> | 
  pos[0] = atof( foo ); | 
| 382 | 
  | 
    | 
| 383 | 
  | 
  foo = strtok(NULL, " ,;\t"); | 
| 384 | 
  | 
  if(foo == NULL){ | 
| 388 | 
  | 
             c_in_name, n_atoms, atomIndex ); | 
| 389 | 
  | 
    return strdup( painCave.errMsg ); | 
| 390 | 
  | 
  } | 
| 391 | 
< | 
  ry = atof( foo ); | 
| 391 | 
> | 
  pos[1] = atof( foo ); | 
| 392 | 
  | 
      | 
| 393 | 
  | 
  foo = strtok(NULL, " ,;\t"); | 
| 394 | 
  | 
  if(foo == NULL){ | 
| 398 | 
  | 
             c_in_name, n_atoms, atomIndex ); | 
| 399 | 
  | 
    return strdup( painCave.errMsg ); | 
| 400 | 
  | 
  } | 
| 401 | 
< | 
  rz = atof( foo );     | 
| 401 | 
> | 
  pos[2] = atof( foo );     | 
| 402 | 
  | 
 | 
| 403 | 
  | 
 | 
| 404 | 
  | 
  // get the velocities | 
| 411 | 
  | 
             c_in_name, n_atoms, atomIndex ); | 
| 412 | 
  | 
    return strdup( painCave.errMsg ); | 
| 413 | 
  | 
  } | 
| 414 | 
< | 
  vx = atof( foo ); | 
| 414 | 
> | 
  vel[0] = atof( foo ); | 
| 415 | 
  | 
     | 
| 416 | 
  | 
  foo = strtok(NULL, " ,;\t"); | 
| 417 | 
  | 
  if(foo == NULL){ | 
| 421 | 
  | 
             c_in_name, n_atoms, atomIndex ); | 
| 422 | 
  | 
    return strdup( painCave.errMsg ); | 
| 423 | 
  | 
  } | 
| 424 | 
< | 
  vy = atof( foo ); | 
| 424 | 
> | 
  vel[1] = atof( foo ); | 
| 425 | 
  | 
     | 
| 426 | 
  | 
  foo = strtok(NULL, " ,;\t"); | 
| 427 | 
  | 
  if(foo == NULL){ | 
| 431 | 
  | 
             c_in_name, n_atoms, atomIndex ); | 
| 432 | 
  | 
    return strdup( painCave.errMsg ); | 
| 433 | 
  | 
  } | 
| 434 | 
< | 
  vz = atof( foo ); | 
| 434 | 
> | 
  vel[2] = atof( foo ); | 
| 435 | 
  | 
     | 
| 436 | 
  | 
     | 
| 437 | 
  | 
  // get the quaternions | 
| 533 | 
  | 
     | 
| 534 | 
  | 
  // add the positions and velocities to the atom | 
| 535 | 
  | 
     | 
| 536 | 
< | 
  atoms[atomIndex]->setX( rx ); | 
| 537 | 
< | 
  atoms[atomIndex]->setY( ry ); | 
| 532 | 
< | 
  atoms[atomIndex]->setZ( rz ); | 
| 533 | 
< | 
     | 
| 534 | 
< | 
  atoms[atomIndex]->set_vx( vx ); | 
| 535 | 
< | 
  atoms[atomIndex]->set_vy( vy ); | 
| 536 | 
< | 
  atoms[atomIndex]->set_vz( vz ); | 
| 536 | 
> | 
  atoms[atomIndex]->setPos( pos ); | 
| 537 | 
> | 
  atoms[atomIndex]->setVel( vel ); | 
| 538 | 
  | 
 | 
| 539 | 
  | 
  return NULL; | 
| 540 | 
  | 
} | 
| 541 | 
  | 
 | 
| 542 | 
  | 
 | 
| 543 | 
< | 
char* InitializeFromFile::parseBoxLine(char* readLine, double boxMat[9]){ | 
| 543 | 
> | 
char* InitializeFromFile::parseBoxLine(char* readLine, double boxMat[9], | 
| 544 | 
> | 
                                       double &time ){ | 
| 545 | 
  | 
 | 
| 546 | 
  | 
  char *foo; // the pointer to the current string token  | 
| 547 | 
  | 
  int j; | 
| 549 | 
  | 
  // set the string tokenizer | 
| 550 | 
  | 
   | 
| 551 | 
  | 
  foo = strtok(readLine, " ,;\t"); | 
| 552 | 
< | 
  // ignore the first token which is the time stamp. | 
| 552 | 
> | 
  // set the timeToken. | 
| 553 | 
  | 
 | 
| 554 | 
+ | 
  if(foo == NULL){ | 
| 555 | 
+ | 
    sprintf( painCave.errMsg, | 
| 556 | 
+ | 
             "error in reading Time from %s\n", | 
| 557 | 
+ | 
             c_in_name ); | 
| 558 | 
+ | 
    return strdup( painCave.errMsg ); | 
| 559 | 
+ | 
  } | 
| 560 | 
+ | 
  time = atof( foo ); | 
| 561 | 
  | 
 | 
| 562 | 
  | 
  // get the Hx vector | 
| 563 | 
  | 
 |