| 4 | 
  | 
 | 
| 5 | 
  | 
#ifdef IS_MPI | 
| 6 | 
  | 
#include <mpi.h> | 
| 7 | 
– | 
#include <mpi++.h> | 
| 7 | 
  | 
#include "mpiSimulation.hpp" | 
| 8 | 
  | 
#define TAKE_THIS_TAG_CHAR 1 | 
| 9 | 
  | 
#define TAKE_THIS_TAG_INT 2 | 
| 27 | 
  | 
  if(worldRank == 0 ){ | 
| 28 | 
  | 
#endif // is_mpi | 
| 29 | 
  | 
     | 
| 31 | 
– | 
  | 
| 32 | 
– | 
     | 
| 30 | 
  | 
    strcpy( outName, entry_plug->sampleName ); | 
| 31 | 
  | 
     | 
| 32 | 
  | 
    outFile.open(outName, ios::out | ios::trunc ); | 
| 39 | 
  | 
      painCave.isFatal = 1; | 
| 40 | 
  | 
      simError(); | 
| 41 | 
  | 
    } | 
| 42 | 
< | 
   | 
| 42 | 
> | 
 | 
| 43 | 
  | 
    //outFile.setf( ios::scientific ); | 
| 44 | 
  | 
 | 
| 45 | 
  | 
#ifdef IS_MPI | 
| 70 | 
  | 
  char tempBuffer[BUFFERSIZE]; | 
| 71 | 
  | 
  char writeLine[BUFFERSIZE]; | 
| 72 | 
  | 
 | 
| 73 | 
< | 
  int i, j, which_node, done, game_over, which_atom, local_index; | 
| 73 | 
> | 
  int i, j, which_node, done, which_atom, local_index; | 
| 74 | 
  | 
  double q[4]; | 
| 75 | 
  | 
  DirectionalAtom* dAtom; | 
| 76 | 
  | 
  int nAtoms = entry_plug->n_atoms; | 
| 77 | 
  | 
  Atom** atoms = entry_plug->atoms; | 
| 78 | 
+ | 
 | 
| 79 | 
+ | 
  double pos[3], vel[3]; | 
| 80 | 
  | 
     | 
| 81 | 
  | 
 | 
| 82 | 
  | 
#ifndef IS_MPI | 
| 83 | 
  | 
     | 
| 84 | 
  | 
  outFile << nAtoms << "\n"; | 
| 85 | 
  | 
     | 
| 86 | 
< | 
  outFile << currentTime << "\t"  | 
| 87 | 
< | 
          << entry_plug->box_x << "\t" | 
| 88 | 
< | 
          << entry_plug->box_y << "\t" | 
| 89 | 
< | 
          << entry_plug->box_z << "\n"; | 
| 86 | 
> | 
  outFile << currentTime << ";\t"  | 
| 87 | 
> | 
          << entry_plug->Hmat[0][0] << "\t" | 
| 88 | 
> | 
          << entry_plug->Hmat[1][0] << "\t" | 
| 89 | 
> | 
          << entry_plug->Hmat[2][0] << ";\t" | 
| 90 | 
> | 
 | 
| 91 | 
> | 
          << entry_plug->Hmat[0][1] << "\t" | 
| 92 | 
> | 
          << entry_plug->Hmat[1][1] << "\t" | 
| 93 | 
> | 
          << entry_plug->Hmat[2][1] << ";\t" | 
| 94 | 
> | 
 | 
| 95 | 
> | 
          << entry_plug->Hmat[0][2] << "\t" | 
| 96 | 
> | 
          << entry_plug->Hmat[1][2] << "\t" | 
| 97 | 
> | 
          << entry_plug->Hmat[2][2] << ";\n"; | 
| 98 | 
  | 
     | 
| 99 | 
  | 
  for( i=0; i<nAtoms; i++ ){ | 
| 100 | 
  | 
       | 
| 101 | 
+ | 
    atoms[i]->getPos(pos); | 
| 102 | 
+ | 
    atoms[i]->getVel(vel); | 
| 103 | 
  | 
 | 
| 104 | 
  | 
    sprintf( tempBuffer, | 
| 105 | 
  | 
             "%s\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t", | 
| 106 | 
  | 
             atoms[i]->getType(), | 
| 107 | 
< | 
             atoms[i]->getX(), | 
| 108 | 
< | 
             atoms[i]->getY(), | 
| 109 | 
< | 
             atoms[i]->getZ(), | 
| 110 | 
< | 
             atoms[i]->get_vx(), | 
| 111 | 
< | 
             atoms[i]->get_vy(), | 
| 112 | 
< | 
             atoms[i]->get_vz()); | 
| 107 | 
> | 
             pos[0], | 
| 108 | 
> | 
             pos[1], | 
| 109 | 
> | 
             pos[2], | 
| 110 | 
> | 
             vel[0], | 
| 111 | 
> | 
             vel[1], | 
| 112 | 
> | 
             vel[2]); | 
| 113 | 
  | 
    strcpy( writeLine, tempBuffer ); | 
| 114 | 
  | 
 | 
| 115 | 
  | 
    if( atoms[i]->isDirectional() ){ | 
| 143 | 
  | 
  int myStatus; // 1 = wakeup & success; 0 = error; -1 = AllDone | 
| 144 | 
  | 
  int haveError; | 
| 145 | 
  | 
 | 
| 146 | 
< | 
  MPI::Status istatus; | 
| 146 | 
> | 
  MPI_Status istatus; | 
| 147 | 
  | 
  int *AtomToProcMap = mpiSim->getAtomToProcMap(); | 
| 148 | 
  | 
   | 
| 149 | 
  | 
  // write out header and node 0's coordinates | 
| 150 | 
  | 
   | 
| 151 | 
  | 
  if( worldRank == 0 ){ | 
| 152 | 
  | 
    outFile << mpiSim->getTotAtoms() << "\n"; | 
| 153 | 
+ | 
   | 
| 154 | 
+ | 
    outFile << currentTime << ";\t"  | 
| 155 | 
+ | 
            << entry_plug->Hmat[0][0] << "\t" | 
| 156 | 
+ | 
            << entry_plug->Hmat[1][0] << "\t" | 
| 157 | 
+ | 
            << entry_plug->Hmat[2][0] << ";\t" | 
| 158 | 
+ | 
       | 
| 159 | 
+ | 
            << entry_plug->Hmat[0][1] << "\t" | 
| 160 | 
+ | 
            << entry_plug->Hmat[1][1] << "\t" | 
| 161 | 
+ | 
            << entry_plug->Hmat[2][1] << ";\t" | 
| 162 | 
+ | 
       | 
| 163 | 
+ | 
            << entry_plug->Hmat[0][2] << "\t" | 
| 164 | 
+ | 
            << entry_plug->Hmat[1][2] << "\t" | 
| 165 | 
+ | 
            << entry_plug->Hmat[2][2] << ";\n"; | 
| 166 | 
  | 
     | 
| 145 | 
– | 
    outFile << currentTime << "\t"  | 
| 146 | 
– | 
            << entry_plug->box_x << "\t" | 
| 147 | 
– | 
            << entry_plug->box_y << "\t" | 
| 148 | 
– | 
            << entry_plug->box_z << "\n"; | 
| 167 | 
  | 
    outFile.flush(); | 
| 168 | 
  | 
    for (i = 0 ; i < mpiSim->getTotAtoms(); i++ ) { | 
| 169 | 
  | 
      // Get the Node number which has this atom; | 
| 180 | 
  | 
        } | 
| 181 | 
  | 
        if (local_index != -1) { | 
| 182 | 
  | 
          //format the line | 
| 183 | 
+ | 
           | 
| 184 | 
+ | 
          atoms[local_index]->getPos(pos); | 
| 185 | 
+ | 
          atoms[local_index]->getVel(vel); | 
| 186 | 
+ | 
 | 
| 187 | 
  | 
          sprintf( tempBuffer, | 
| 188 | 
  | 
                   "%s\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t", | 
| 189 | 
  | 
                   atoms[local_index]->getType(), | 
| 190 | 
< | 
                   atoms[local_index]->getX(), | 
| 191 | 
< | 
                   atoms[local_index]->getY(), | 
| 192 | 
< | 
                   atoms[local_index]->getZ(), | 
| 193 | 
< | 
                   atoms[local_index]->get_vx(), | 
| 194 | 
< | 
                   atoms[local_index]->get_vy(), | 
| 195 | 
< | 
                   atoms[local_index]->get_vz()); // check here. | 
| 190 | 
> | 
                   pos[0], | 
| 191 | 
> | 
                   pos[1], | 
| 192 | 
> | 
                   pos[2], | 
| 193 | 
> | 
                   vel[0], | 
| 194 | 
> | 
                   vel[1], | 
| 195 | 
> | 
                   vel[2]); // check here. | 
| 196 | 
  | 
          strcpy( writeLine, tempBuffer ); | 
| 197 | 
  | 
           | 
| 198 | 
  | 
          if( atoms[local_index]->isDirectional() ){ | 
| 228 | 
  | 
      } | 
| 229 | 
  | 
      else { | 
| 230 | 
  | 
        myStatus = 1; | 
| 231 | 
< | 
        MPI::COMM_WORLD.Send(&myStatus, 1, MPI_INT, which_node,  | 
| 232 | 
< | 
                             TAKE_THIS_TAG_INT); | 
| 233 | 
< | 
        MPI::COMM_WORLD.Send(&i, 1, MPI_INT, which_node, TAKE_THIS_TAG_INT); | 
| 234 | 
< | 
        MPI::COMM_WORLD.Recv(writeLine, BUFFERSIZE, MPI_CHAR, which_node, | 
| 235 | 
< | 
                             TAKE_THIS_TAG_CHAR, istatus); | 
| 236 | 
< | 
        MPI::COMM_WORLD.Recv(&myStatus, 1, MPI_INT, which_node,  | 
| 237 | 
< | 
                             TAKE_THIS_TAG_INT, istatus); | 
| 231 | 
> | 
        MPI_Send(&myStatus, 1, MPI_INT, which_node,  | 
| 232 | 
> | 
                 TAKE_THIS_TAG_INT, MPI_COMM_WORLD); | 
| 233 | 
> | 
        MPI_Send(&i, 1, MPI_INT, which_node, TAKE_THIS_TAG_INT,  | 
| 234 | 
> | 
                 MPI_COMM_WORLD); | 
| 235 | 
> | 
        MPI_Recv(writeLine, BUFFERSIZE, MPI_CHAR, which_node, | 
| 236 | 
> | 
                 TAKE_THIS_TAG_CHAR, MPI_COMM_WORLD, &istatus); | 
| 237 | 
> | 
        MPI_Recv(&myStatus, 1, MPI_INT, which_node,  | 
| 238 | 
> | 
                 TAKE_THIS_TAG_INT, MPI_COMM_WORLD, &istatus); | 
| 239 | 
  | 
         | 
| 240 | 
  | 
        if(!myStatus) nodeZeroError(); | 
| 241 | 
  | 
 | 
| 248 | 
  | 
    // kill everyone off: | 
| 249 | 
  | 
    myStatus = -1; | 
| 250 | 
  | 
    for (j = 0; j < mpiSim->getNumberProcessors(); j++) {       | 
| 251 | 
< | 
      MPI::COMM_WORLD.Send(&myStatus, 1, MPI_INT, j,  | 
| 252 | 
< | 
                           TAKE_THIS_TAG_INT); | 
| 251 | 
> | 
      MPI_Send(&myStatus, 1, MPI_INT, j,  | 
| 252 | 
> | 
               TAKE_THIS_TAG_INT, MPI_COMM_WORLD); | 
| 253 | 
  | 
    } | 
| 254 | 
  | 
 | 
| 255 | 
  | 
  } else { | 
| 257 | 
  | 
    done = 0; | 
| 258 | 
  | 
    while (!done) { | 
| 259 | 
  | 
       | 
| 260 | 
< | 
      MPI::COMM_WORLD.Recv(&myStatus, 1, MPI_INT, 0,  | 
| 261 | 
< | 
                           TAKE_THIS_TAG_INT, istatus); | 
| 260 | 
> | 
      MPI_Recv(&myStatus, 1, MPI_INT, 0,  | 
| 261 | 
> | 
               TAKE_THIS_TAG_INT, MPI_COMM_WORLD, &istatus); | 
| 262 | 
  | 
 | 
| 263 | 
  | 
      if(!myStatus) anonymousNodeDie(); | 
| 264 | 
  | 
       | 
| 265 | 
  | 
      if(myStatus < 0) break; | 
| 266 | 
  | 
 | 
| 267 | 
< | 
      MPI::COMM_WORLD.Recv(&which_atom, 1, MPI_INT, 0,  | 
| 268 | 
< | 
                           TAKE_THIS_TAG_INT, istatus); | 
| 267 | 
> | 
      MPI_Recv(&which_atom, 1, MPI_INT, 0,  | 
| 268 | 
> | 
               TAKE_THIS_TAG_INT, MPI_COMM_WORLD, &istatus); | 
| 269 | 
  | 
       | 
| 270 | 
  | 
      myStatus = 1; | 
| 271 | 
  | 
      local_index=-1;         | 
| 274 | 
  | 
      } | 
| 275 | 
  | 
      if (local_index != -1) { | 
| 276 | 
  | 
        //format the line | 
| 277 | 
+ | 
 | 
| 278 | 
+ | 
        atoms[local_index]->getPos(pos); | 
| 279 | 
+ | 
        atoms[local_index]->getVel(vel); | 
| 280 | 
+ | 
 | 
| 281 | 
  | 
        sprintf( tempBuffer, | 
| 282 | 
  | 
                 "%s\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t", | 
| 283 | 
  | 
                 atoms[local_index]->getType(), | 
| 284 | 
< | 
                 atoms[local_index]->getX(), | 
| 285 | 
< | 
                 atoms[local_index]->getY(), | 
| 286 | 
< | 
                 atoms[local_index]->getZ(), | 
| 287 | 
< | 
                 atoms[local_index]->get_vx(), | 
| 288 | 
< | 
                 atoms[local_index]->get_vy(), | 
| 289 | 
< | 
                 atoms[local_index]->get_vz()); // check here. | 
| 284 | 
> | 
                 pos[0], | 
| 285 | 
> | 
                 pos[1], | 
| 286 | 
> | 
                 pos[2], | 
| 287 | 
> | 
                 vel[0], | 
| 288 | 
> | 
                 vel[1], | 
| 289 | 
> | 
                 vel[2]); // check here. | 
| 290 | 
  | 
        strcpy( writeLine, tempBuffer ); | 
| 291 | 
  | 
         | 
| 292 | 
  | 
        if( atoms[local_index]->isDirectional() ){ | 
| 319 | 
  | 
        strcpy( writeLine, "Hello, I'm an error.\n"); | 
| 320 | 
  | 
      } | 
| 321 | 
  | 
 | 
| 322 | 
< | 
      MPI::COMM_WORLD.Send(writeLine, BUFFERSIZE, MPI_CHAR, 0,  | 
| 323 | 
< | 
                           TAKE_THIS_TAG_CHAR); | 
| 324 | 
< | 
      MPI::COMM_WORLD.Send( &myStatus, 1, MPI_INT, 0,  | 
| 325 | 
< | 
                            TAKE_THIS_TAG_INT); | 
| 322 | 
> | 
      MPI_Send(writeLine, BUFFERSIZE, MPI_CHAR, 0,  | 
| 323 | 
> | 
               TAKE_THIS_TAG_CHAR, MPI_COMM_WORLD); | 
| 324 | 
> | 
      MPI_Send( &myStatus, 1, MPI_INT, 0,  | 
| 325 | 
> | 
                TAKE_THIS_TAG_INT, MPI_COMM_WORLD); | 
| 326 | 
  | 
    } | 
| 327 | 
  | 
  }   | 
| 328 | 
  | 
  outFile.flush(); | 
| 336 | 
  | 
#endif // is_mpi | 
| 337 | 
  | 
} | 
| 338 | 
  | 
 | 
| 339 | 
< | 
void DumpWriter::writeFinal(){ | 
| 339 | 
> | 
void DumpWriter::writeFinal(double finalTime){ | 
| 340 | 
  | 
 | 
| 341 | 
  | 
  char finalName[500]; | 
| 342 | 
  | 
  ofstream finalOut; | 
| 351 | 
  | 
  Atom** atoms = entry_plug->atoms; | 
| 352 | 
  | 
  int i, j, which_node, done, game_over, which_atom, local_index; | 
| 353 | 
  | 
   | 
| 354 | 
+ | 
  double pos[3], vel[3]; | 
| 355 | 
  | 
   | 
| 356 | 
  | 
#ifdef IS_MPI | 
| 357 | 
  | 
  if(worldRank == 0 ){ | 
| 383 | 
  | 
     | 
| 384 | 
  | 
  finalOut << nAtoms << "\n"; | 
| 385 | 
  | 
     | 
| 386 | 
< | 
  finalOut << entry_plug->box_x << "\t" | 
| 387 | 
< | 
           << entry_plug->box_y << "\t" | 
| 388 | 
< | 
           << entry_plug->box_z << "\n"; | 
| 386 | 
> | 
  finalOut << finalTime << ";\t" | 
| 387 | 
> | 
           << entry_plug->Hmat[0][0] << "\t" | 
| 388 | 
> | 
           << entry_plug->Hmat[1][0] << "\t" | 
| 389 | 
> | 
           << entry_plug->Hmat[2][0] << ";\t" | 
| 390 | 
> | 
     | 
| 391 | 
> | 
           << entry_plug->Hmat[0][1] << "\t" | 
| 392 | 
> | 
           << entry_plug->Hmat[1][1] << "\t" | 
| 393 | 
> | 
           << entry_plug->Hmat[2][1] << ";\t" | 
| 394 | 
> | 
     | 
| 395 | 
> | 
           << entry_plug->Hmat[0][2] << "\t" | 
| 396 | 
> | 
           << entry_plug->Hmat[1][2] << "\t" | 
| 397 | 
> | 
           << entry_plug->Hmat[2][2] << ";\n"; | 
| 398 | 
  | 
   | 
| 399 | 
  | 
  for( i=0; i<nAtoms; i++ ){ | 
| 400 | 
  | 
       | 
| 401 | 
+ | 
    atoms[i]->getPos(pos); | 
| 402 | 
+ | 
    atoms[i]->getVel(vel); | 
| 403 | 
+ | 
     | 
| 404 | 
  | 
    sprintf( tempBuffer, | 
| 405 | 
  | 
             "%s\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t", | 
| 406 | 
  | 
             atoms[i]->getType(), | 
| 407 | 
< | 
             atoms[i]->getX(), | 
| 408 | 
< | 
             atoms[i]->getY(), | 
| 409 | 
< | 
             atoms[i]->getZ(), | 
| 410 | 
< | 
             atoms[i]->get_vx(), | 
| 411 | 
< | 
             atoms[i]->get_vy(), | 
| 412 | 
< | 
             atoms[i]->get_vz()); | 
| 407 | 
> | 
             pos[0], | 
| 408 | 
> | 
             pos[1], | 
| 409 | 
> | 
             pos[2], | 
| 410 | 
> | 
             vel[0], | 
| 411 | 
> | 
             vel[1], | 
| 412 | 
> | 
             vel[2]); | 
| 413 | 
  | 
    strcpy( writeLine, tempBuffer ); | 
| 414 | 
  | 
 | 
| 415 | 
  | 
    if( atoms[i]->isDirectional() ){ | 
| 444 | 
  | 
  int myStatus; // 1 = wakeup & success; 0 = error; -1 = AllDone | 
| 445 | 
  | 
  int haveError; | 
| 446 | 
  | 
 | 
| 447 | 
< | 
  MPI::Status istatus; | 
| 447 | 
> | 
  MPI_Status istatus; | 
| 448 | 
  | 
  int *AtomToProcMap = mpiSim->getAtomToProcMap(); | 
| 449 | 
  | 
 | 
| 450 | 
  | 
  // write out header and node 0's coordinates | 
| 453 | 
  | 
  if( worldRank == 0 ){ | 
| 454 | 
  | 
    finalOut << mpiSim->getTotAtoms() << "\n"; | 
| 455 | 
  | 
     | 
| 456 | 
< | 
    finalOut << entry_plug->box_x << "\t" | 
| 457 | 
< | 
            << entry_plug->box_y << "\t" | 
| 458 | 
< | 
            << entry_plug->box_z << "\n"; | 
| 456 | 
> | 
    finalOut << finalTime << ";\t" | 
| 457 | 
> | 
             << entry_plug->Hmat[0][0] << "\t" | 
| 458 | 
> | 
             << entry_plug->Hmat[1][0] << "\t" | 
| 459 | 
> | 
             << entry_plug->Hmat[2][0] << ";\t" | 
| 460 | 
> | 
       | 
| 461 | 
> | 
             << entry_plug->Hmat[0][1] << "\t" | 
| 462 | 
> | 
             << entry_plug->Hmat[1][1] << "\t" | 
| 463 | 
> | 
             << entry_plug->Hmat[2][1] << ";\t" | 
| 464 | 
> | 
       | 
| 465 | 
> | 
             << entry_plug->Hmat[0][2] << "\t" | 
| 466 | 
> | 
             << entry_plug->Hmat[1][2] << "\t" | 
| 467 | 
> | 
             << entry_plug->Hmat[2][2] << ";\n"; | 
| 468 | 
  | 
     | 
| 469 | 
  | 
    for (i = 0 ; i < mpiSim->getTotAtoms(); i++ ) { | 
| 470 | 
  | 
      // Get the Node number which has this molecule: | 
| 478 | 
  | 
        for (j=0; (j<mpiSim->getMyNlocal()) && (local_index < 0); j++) { | 
| 479 | 
  | 
          if (atoms[j]->getGlobalIndex() == which_atom) local_index = j; | 
| 480 | 
  | 
        } | 
| 481 | 
< | 
        if (local_index != -1) {         | 
| 481 | 
> | 
        if (local_index != -1) {     | 
| 482 | 
> | 
 | 
| 483 | 
> | 
          atoms[local_index]->getPos(pos); | 
| 484 | 
> | 
          atoms[local_index]->getVel(vel); | 
| 485 | 
> | 
           | 
| 486 | 
  | 
          sprintf( tempBuffer, | 
| 487 | 
  | 
                   "%s\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t", | 
| 488 | 
  | 
                   atoms[local_index]->getType(), | 
| 489 | 
< | 
                   atoms[local_index]->getX(), | 
| 490 | 
< | 
                   atoms[local_index]->getY(), | 
| 491 | 
< | 
                   atoms[local_index]->getZ(), | 
| 492 | 
< | 
                   atoms[local_index]->get_vx(), | 
| 493 | 
< | 
                   atoms[local_index]->get_vy(), | 
| 494 | 
< | 
                   atoms[local_index]->get_vz()); | 
| 489 | 
> | 
                   pos[0], | 
| 490 | 
> | 
                   pos[1], | 
| 491 | 
> | 
                   pos[2], | 
| 492 | 
> | 
                   vel[0], | 
| 493 | 
> | 
                   vel[1], | 
| 494 | 
> | 
                   vel[2]); | 
| 495 | 
  | 
          strcpy( writeLine, tempBuffer ); | 
| 496 | 
  | 
           | 
| 497 | 
  | 
          if( atoms[local_index]->isDirectional() ){ | 
| 527 | 
  | 
      else { | 
| 528 | 
  | 
         | 
| 529 | 
  | 
        myStatus = 1; | 
| 530 | 
< | 
        MPI::COMM_WORLD.Send(&myStatus, 1, MPI_INT, which_node,  | 
| 531 | 
< | 
                             TAKE_THIS_TAG_INT); | 
| 532 | 
< | 
        MPI::COMM_WORLD.Send(&i, 1, MPI_INT, which_node, TAKE_THIS_TAG_INT); | 
| 533 | 
< | 
        MPI::COMM_WORLD.Recv(writeLine, BUFFERSIZE, MPI_CHAR, which_node, | 
| 534 | 
< | 
                             TAKE_THIS_TAG_CHAR, istatus); | 
| 535 | 
< | 
        MPI::COMM_WORLD.Recv(&myStatus, 1, MPI_INT, which_node,  | 
| 536 | 
< | 
                             TAKE_THIS_TAG_INT, istatus); | 
| 530 | 
> | 
        MPI_Send(&myStatus, 1, MPI_INT, which_node,  | 
| 531 | 
> | 
                 TAKE_THIS_TAG_INT, MPI_COMM_WORLD); | 
| 532 | 
> | 
        MPI_Send(&i, 1, MPI_INT, which_node, TAKE_THIS_TAG_INT, | 
| 533 | 
> | 
                 MPI_COMM_WORLD); | 
| 534 | 
> | 
        MPI_Recv(writeLine, BUFFERSIZE, MPI_CHAR, which_node, | 
| 535 | 
> | 
                 TAKE_THIS_TAG_CHAR, MPI_COMM_WORLD, &istatus); | 
| 536 | 
> | 
        MPI_Recv(&myStatus, 1, MPI_INT, which_node,  | 
| 537 | 
> | 
                 TAKE_THIS_TAG_INT, MPI_COMM_WORLD, &istatus); | 
| 538 | 
  | 
         | 
| 539 | 
  | 
        if(!myStatus) nodeZeroError(); | 
| 540 | 
  | 
      } | 
| 545 | 
  | 
    // kill everyone off: | 
| 546 | 
  | 
    myStatus = -1; | 
| 547 | 
  | 
    for (j = 0; j < mpiSim->getNumberProcessors(); j++) {       | 
| 548 | 
< | 
      MPI::COMM_WORLD.Send(&myStatus, 1, MPI_INT, j,  | 
| 549 | 
< | 
                           TAKE_THIS_TAG_INT); | 
| 548 | 
> | 
      MPI_Send(&myStatus, 1, MPI_INT, j,  | 
| 549 | 
> | 
               TAKE_THIS_TAG_INT, MPI_COMM_WORLD); | 
| 550 | 
  | 
    } | 
| 551 | 
  | 
 | 
| 552 | 
  | 
  } else { | 
| 554 | 
  | 
    done = 0; | 
| 555 | 
  | 
    while (!done) { | 
| 556 | 
  | 
 | 
| 557 | 
< | 
      MPI::COMM_WORLD.Recv(&myStatus, 1, MPI_INT, 0,  | 
| 558 | 
< | 
                           TAKE_THIS_TAG_INT, istatus); | 
| 557 | 
> | 
      MPI_Recv(&myStatus, 1, MPI_INT, 0,  | 
| 558 | 
> | 
               TAKE_THIS_TAG_INT, MPI_COMM_WORLD, &istatus); | 
| 559 | 
  | 
       | 
| 560 | 
  | 
      if(!myStatus) anonymousNodeDie(); | 
| 561 | 
  | 
       | 
| 562 | 
  | 
      if(myStatus < 0) break; | 
| 563 | 
  | 
       | 
| 564 | 
< | 
      MPI::COMM_WORLD.Recv(&which_atom, 1, MPI_INT, 0,  | 
| 565 | 
< | 
                           TAKE_THIS_TAG_INT, istatus); | 
| 564 | 
> | 
      MPI_Recv(&which_atom, 1, MPI_INT, 0,  | 
| 565 | 
> | 
               TAKE_THIS_TAG_INT, MPI_COMM_WORLD, &istatus); | 
| 566 | 
  | 
       | 
| 567 | 
  | 
      myStatus = 1; | 
| 568 | 
  | 
      local_index=-1;         | 
| 571 | 
  | 
      } | 
| 572 | 
  | 
      if (local_index != -1) { | 
| 573 | 
  | 
 | 
| 574 | 
+ | 
        atoms[local_index]->getPos(pos); | 
| 575 | 
+ | 
        atoms[local_index]->getVel(vel); | 
| 576 | 
+ | 
 | 
| 577 | 
  | 
        //format the line | 
| 578 | 
  | 
        sprintf( tempBuffer, | 
| 579 | 
  | 
                 "%s\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t", | 
| 580 | 
  | 
                 atoms[local_index]->getType(), | 
| 581 | 
< | 
                 atoms[local_index]->getX(), | 
| 582 | 
< | 
                 atoms[local_index]->getY(), | 
| 583 | 
< | 
                 atoms[local_index]->getZ(), | 
| 584 | 
< | 
                 atoms[local_index]->get_vx(), | 
| 585 | 
< | 
                 atoms[local_index]->get_vy(), | 
| 586 | 
< | 
                 atoms[local_index]->get_vz()); // check here. | 
| 581 | 
> | 
                 pos[0], | 
| 582 | 
> | 
                 pos[1], | 
| 583 | 
> | 
                 pos[2], | 
| 584 | 
> | 
                 vel[0], | 
| 585 | 
> | 
                 vel[1], | 
| 586 | 
> | 
                 vel[2]); // check here. | 
| 587 | 
  | 
        strcpy( writeLine, tempBuffer ); | 
| 588 | 
  | 
         | 
| 589 | 
  | 
        if( atoms[local_index]->isDirectional() ){ | 
| 616 | 
  | 
        strcpy( writeLine, "Hello, I'm an error.\n"); | 
| 617 | 
  | 
      } | 
| 618 | 
  | 
 | 
| 619 | 
< | 
      MPI::COMM_WORLD.Send(writeLine, BUFFERSIZE, MPI_CHAR, 0,  | 
| 620 | 
< | 
                           TAKE_THIS_TAG_CHAR); | 
| 621 | 
< | 
      MPI::COMM_WORLD.Send( &myStatus, 1, MPI_INT, 0,  | 
| 622 | 
< | 
                            TAKE_THIS_TAG_INT); | 
| 619 | 
> | 
      MPI_Send(writeLine, BUFFERSIZE, MPI_CHAR, 0,  | 
| 620 | 
> | 
               TAKE_THIS_TAG_CHAR, MPI_COMM_WORLD); | 
| 621 | 
> | 
      MPI_Send( &myStatus, 1, MPI_INT, 0,  | 
| 622 | 
> | 
                TAKE_THIS_TAG_INT, MPI_COMM_WORLD); | 
| 623 | 
  | 
    } | 
| 624 | 
  | 
  } | 
| 625 | 
  | 
  finalOut.flush(); | 
| 642 | 
  | 
   | 
| 643 | 
  | 
  myStatus = 0; | 
| 644 | 
  | 
  for (j = 0; j < mpiSim->getNumberProcessors(); j++) {       | 
| 645 | 
< | 
    MPI::COMM_WORLD.Send( &myStatus, 1, MPI_INT, j,  | 
| 646 | 
< | 
                          TAKE_THIS_TAG_INT); | 
| 645 | 
> | 
    MPI_Send( &myStatus, 1, MPI_INT, j,  | 
| 646 | 
> | 
              TAKE_THIS_TAG_INT, MPI_COMM_WORLD); | 
| 647 | 
  | 
  }   | 
| 648 | 
  | 
   | 
| 649 | 
  | 
 |