| 40 | 
  | 
      simError(); | 
| 41 | 
  | 
    } | 
| 42 | 
  | 
 | 
| 43 | 
< | 
    //outFile.setf( ios::scientific ); | 
| 43 | 
> | 
    finalOut.open( entry_plug->finalName, ios::out | ios::trunc ); | 
| 44 | 
> | 
    if( !finalOut ){ | 
| 45 | 
> | 
      sprintf( painCave.errMsg, | 
| 46 | 
> | 
               "Could not open \"%s\" for final dump output.\n", | 
| 47 | 
> | 
               entry_plug->finalName ); | 
| 48 | 
> | 
      painCave.isFatal = 1; | 
| 49 | 
> | 
      simError(); | 
| 50 | 
> | 
    } | 
| 51 | 
  | 
 | 
| 52 | 
  | 
#ifdef IS_MPI | 
| 53 | 
  | 
  } | 
| 68 | 
  | 
#endif // is_mpi | 
| 69 | 
  | 
 | 
| 70 | 
  | 
    dumpFile.close(); | 
| 71 | 
+ | 
    finalOut.close(); | 
| 72 | 
  | 
 | 
| 73 | 
  | 
#ifdef IS_MPI | 
| 74 | 
  | 
  } | 
| 110 | 
  | 
#endif | 
| 111 | 
  | 
 | 
| 112 | 
  | 
void DumpWriter::writeDump(double currentTime){ | 
| 105 | 
– | 
   | 
| 106 | 
– | 
// write to eor file | 
| 107 | 
– | 
  writeFinal(currentTime); | 
| 113 | 
  | 
 | 
| 114 | 
< | 
//write to dump file | 
| 115 | 
< | 
  writeFrame(dumpFile, currentTime); | 
| 114 | 
> | 
  vector<ofstream*> fileStreams; | 
| 115 | 
> | 
 | 
| 116 | 
> | 
#ifdef IS_MPI | 
| 117 | 
> | 
  if(worldRank == 0 ){ | 
| 118 | 
> | 
    finalOut.seekp(0); | 
| 119 | 
> | 
  } | 
| 120 | 
> | 
#endif // is_mpi | 
| 121 | 
> | 
 | 
| 122 | 
> | 
  fileStreams.push_back(&finalOut);  | 
| 123 | 
> | 
  fileStreams.push_back(&dumpFile); | 
| 124 | 
> | 
 | 
| 125 | 
> | 
  writeFrame(fileStreams, currentTime); | 
| 126 | 
  | 
         | 
| 127 | 
  | 
} | 
| 128 | 
  | 
 | 
| 129 | 
  | 
void DumpWriter::writeFinal(double currentTime){ | 
| 130 | 
  | 
 | 
| 131 | 
< | 
  ofstream finalOut;     | 
| 117 | 
< | 
   | 
| 118 | 
< | 
  //Open eor file | 
| 119 | 
< | 
#ifdef IS_MPI | 
| 120 | 
< | 
  if(worldRank == 0 ){ | 
| 121 | 
< | 
#endif // is_mpi | 
| 131 | 
> | 
  vector<ofstream*> fileStreams; | 
| 132 | 
  | 
 | 
| 123 | 
– | 
    finalOut.open( entry_plug->finalName, ios::out | ios::trunc ); | 
| 124 | 
– | 
    if( !finalOut ){ | 
| 125 | 
– | 
      sprintf( painCave.errMsg, | 
| 126 | 
– | 
               "Could not open \"%s\" for final dump output.\n", | 
| 127 | 
– | 
               entry_plug->finalName ); | 
| 128 | 
– | 
      painCave.isFatal = 1; | 
| 129 | 
– | 
      simError(); | 
| 130 | 
– | 
    } | 
| 131 | 
– | 
     | 
| 133 | 
  | 
#ifdef IS_MPI | 
| 133 | 
– | 
  } | 
| 134 | 
– | 
#endif | 
| 135 | 
– | 
   | 
| 136 | 
– | 
  //write to eor file   | 
| 137 | 
– | 
  writeFrame(finalOut, currentTime);  | 
| 138 | 
– | 
   | 
| 139 | 
– | 
  //close eor file       | 
| 140 | 
– | 
#ifdef IS_MPI | 
| 134 | 
  | 
  if(worldRank == 0 ){ | 
| 135 | 
< | 
    finalOut.close(); | 
| 135 | 
> | 
    finalOut.seekp(0); | 
| 136 | 
  | 
  } | 
| 137 | 
  | 
#endif // is_mpi | 
| 138 | 
< | 
 | 
| 138 | 
> | 
   | 
| 139 | 
> | 
  fileStreams.push_back(&finalOut);   | 
| 140 | 
> | 
  writeFrame(fileStreams, currentTime); | 
| 141 | 
> | 
   | 
| 142 | 
  | 
} | 
| 143 | 
  | 
 | 
| 144 | 
< | 
void DumpWriter::writeFrame( ofstream& outFile, double currentTime ){ | 
| 144 | 
> | 
void DumpWriter::writeFrame( vector<ofstream*>& outFile, double currentTime ){ | 
| 145 | 
  | 
 | 
| 146 | 
  | 
  const int BUFFERSIZE = 2000; | 
| 147 | 
  | 
  const int MINIBUFFERSIZE = 100; | 
| 149 | 
  | 
  char tempBuffer[BUFFERSIZE]; | 
| 150 | 
  | 
  char writeLine[BUFFERSIZE]; | 
| 151 | 
  | 
 | 
| 152 | 
< | 
  int i; | 
| 152 | 
> | 
  int i, k; | 
| 153 | 
  | 
 | 
| 154 | 
  | 
#ifdef IS_MPI | 
| 155 | 
  | 
   | 
| 174 | 
  | 
  double pos[3], vel[3]; | 
| 175 | 
  | 
 | 
| 176 | 
  | 
#ifndef IS_MPI | 
| 177 | 
+ | 
   | 
| 178 | 
+ | 
  for(k = 0; k < outFile.size(); k++){ | 
| 179 | 
+ | 
    *outFile[k] << nAtoms << "\n"; | 
| 180 | 
  | 
 | 
| 181 | 
< | 
  outFile << nAtoms << "\n"; | 
| 181 | 
> | 
    *outFile[k] << currentTime << ";\t" | 
| 182 | 
> | 
               << entry_plug->Hmat[0][0] << "\t" | 
| 183 | 
> | 
                     << entry_plug->Hmat[1][0] << "\t" | 
| 184 | 
> | 
                     << entry_plug->Hmat[2][0] << ";\t" | 
| 185 | 
> | 
                | 
| 186 | 
> | 
               << entry_plug->Hmat[0][1] << "\t" | 
| 187 | 
> | 
                     << entry_plug->Hmat[1][1] << "\t" | 
| 188 | 
> | 
                     << entry_plug->Hmat[2][1] << ";\t" | 
| 189 | 
  | 
 | 
| 190 | 
< | 
  outFile << currentTime << ";\t" | 
| 191 | 
< | 
          << entry_plug->Hmat[0][0] << "\t" | 
| 192 | 
< | 
          << entry_plug->Hmat[1][0] << "\t" | 
| 187 | 
< | 
          << entry_plug->Hmat[2][0] << ";\t" | 
| 190 | 
> | 
                     << entry_plug->Hmat[0][2] << "\t" | 
| 191 | 
> | 
                     << entry_plug->Hmat[1][2] << "\t" | 
| 192 | 
> | 
                     << entry_plug->Hmat[2][2] << ";"; | 
| 193 | 
  | 
 | 
| 194 | 
< | 
          << entry_plug->Hmat[0][1] << "\t" | 
| 195 | 
< | 
          << entry_plug->Hmat[1][1] << "\t" | 
| 196 | 
< | 
          << entry_plug->Hmat[2][1] << ";\t" | 
| 197 | 
< | 
 | 
| 193 | 
< | 
          << entry_plug->Hmat[0][2] << "\t" | 
| 194 | 
< | 
          << entry_plug->Hmat[1][2] << "\t" | 
| 195 | 
< | 
          << entry_plug->Hmat[2][2] << ";"; | 
| 196 | 
< | 
  //write out additional parameters, such as chi and eta | 
| 197 | 
< | 
  outFile << entry_plug->the_integrator->getAdditionalParameters(); | 
| 198 | 
< | 
  outFile << endl; | 
| 199 | 
< | 
 | 
| 194 | 
> | 
    //write out additional parameters, such as chi and eta | 
| 195 | 
> | 
    *outFile[k] << entry_plug->the_integrator->getAdditionalParameters() << endl; | 
| 196 | 
> | 
  } | 
| 197 | 
> | 
   | 
| 198 | 
  | 
  for( i=0; i<nAtoms; i++ ){ | 
| 199 | 
  | 
 | 
| 200 | 
  | 
    atoms[i]->getPos(pos); | 
| 230 | 
  | 
    else | 
| 231 | 
  | 
      strcat( writeLine, "0.0\t0.0\t0.0\t0.0\t0.0\t0.0\t0.0\n" ); | 
| 232 | 
  | 
 | 
| 233 | 
< | 
    outFile << writeLine; | 
| 233 | 
> | 
    for(k = 0; k < outFile.size(); k++) | 
| 234 | 
> | 
      *outFile[k] << writeLine; | 
| 235 | 
  | 
  } | 
| 236 | 
  | 
 | 
| 237 | 
  | 
#else // is_mpi | 
| 260 | 
  | 
    nProc = mpiSim->getNumberProcessors(); | 
| 261 | 
  | 
    potatoes = new int[nProc]; | 
| 262 | 
  | 
 | 
| 263 | 
+ | 
    //write out the comment lines | 
| 264 | 
  | 
    for (i = 0; i < nProc; i++)  | 
| 265 | 
  | 
      potatoes[i] = 0; | 
| 266 | 
  | 
     | 
| 267 | 
< | 
    outFile << mpiSim->getTotAtoms() << "\n"; | 
| 267 | 
> | 
      for(k = 0; k < outFile.size(); k++){ | 
| 268 | 
> | 
        *outFile[k] << mpiSim->getTotAtoms() << "\n"; | 
| 269 | 
  | 
 | 
| 270 | 
< | 
    outFile << currentTime << ";\t" | 
| 271 | 
< | 
            << entry_plug->Hmat[0][0] << "\t" | 
| 272 | 
< | 
            << entry_plug->Hmat[1][0] << "\t" | 
| 273 | 
< | 
            << entry_plug->Hmat[2][0] << ";\t" | 
| 270 | 
> | 
        *outFile[k] << currentTime << ";\t" | 
| 271 | 
> | 
                         << entry_plug->Hmat[0][0] << "\t" | 
| 272 | 
> | 
                         << entry_plug->Hmat[1][0] << "\t" | 
| 273 | 
> | 
                         << entry_plug->Hmat[2][0] << ";\t" | 
| 274 | 
  | 
 | 
| 275 | 
< | 
            << entry_plug->Hmat[0][1] << "\t" | 
| 276 | 
< | 
            << entry_plug->Hmat[1][1] << "\t" | 
| 277 | 
< | 
            << entry_plug->Hmat[2][1] << ";\t" | 
| 275 | 
> | 
                         << entry_plug->Hmat[0][1] << "\t" | 
| 276 | 
> | 
                         << entry_plug->Hmat[1][1] << "\t" | 
| 277 | 
> | 
                         << entry_plug->Hmat[2][1] << ";\t" | 
| 278 | 
  | 
 | 
| 279 | 
< | 
            << entry_plug->Hmat[0][2] << "\t" | 
| 280 | 
< | 
            << entry_plug->Hmat[1][2] << "\t" | 
| 281 | 
< | 
            << entry_plug->Hmat[2][2] << ";"; | 
| 279 | 
> | 
                         << entry_plug->Hmat[0][2] << "\t" | 
| 280 | 
> | 
                         << entry_plug->Hmat[1][2] << "\t" | 
| 281 | 
> | 
                         << entry_plug->Hmat[2][2] << ";"; | 
| 282 | 
> | 
   | 
| 283 | 
> | 
        *outFile[k] << entry_plug->the_integrator->getAdditionalParameters() << endl; | 
| 284 | 
> | 
    } | 
| 285 | 
  | 
 | 
| 282 | 
– | 
    outFile << entry_plug->the_integrator->getAdditionalParameters(); | 
| 283 | 
– | 
    outFile << endl; | 
| 284 | 
– | 
    outFile.flush(); | 
| 285 | 
– | 
     | 
| 286 | 
  | 
    currentIndex = 0; | 
| 287 | 
+ | 
 | 
| 288 | 
  | 
    for (i = 0 ; i < mpiSim->getTotAtoms(); i++ ) { | 
| 289 | 
  | 
       | 
| 290 | 
  | 
      // Get the Node number which has this atom; | 
| 329 | 
  | 
 | 
| 330 | 
  | 
      } else { | 
| 331 | 
  | 
         | 
| 332 | 
< | 
        haveError = 0; | 
| 333 | 
< | 
        which_atom = i; | 
| 332 | 
> | 
        haveError = 0; | 
| 333 | 
> | 
              which_atom = i; | 
| 334 | 
  | 
         | 
| 335 | 
  | 
        local_index = indexArray[currentIndex].first;         | 
| 336 | 
  | 
                 | 
| 338 | 
  | 
           | 
| 339 | 
  | 
          atomTypeString = atoms[local_index]->getType(); | 
| 340 | 
  | 
 | 
| 341 | 
< | 
          atoms[local_index]->getPos(pos); | 
| 342 | 
< | 
          atoms[local_index]->getVel(vel);           | 
| 341 | 
> | 
                atoms[local_index]->getPos(pos); | 
| 342 | 
> | 
                atoms[local_index]->getVel(vel);           | 
| 343 | 
  | 
 | 
| 344 | 
  | 
          atomData6[0] = pos[0]; | 
| 345 | 
  | 
          atomData6[1] = pos[1]; | 
| 372 | 
  | 
          } | 
| 373 | 
  | 
           | 
| 374 | 
  | 
        } else { | 
| 375 | 
< | 
          sprintf(painCave.errMsg, | 
| 376 | 
< | 
                  "Atom %d not found on processor %d\n", | 
| 377 | 
< | 
                  i, worldRank ); | 
| 378 | 
< | 
          haveError= 1; | 
| 379 | 
< | 
          simError(); | 
| 380 | 
< | 
        } | 
| 375 | 
> | 
          sprintf(painCave.errMsg, | 
| 376 | 
> | 
                              "Atom %d not found on processor %d\n", | 
| 377 | 
> | 
                              i, worldRank ); | 
| 378 | 
> | 
                haveError= 1; | 
| 379 | 
> | 
                simError(); | 
| 380 | 
> | 
              } | 
| 381 | 
  | 
         | 
| 382 | 
< | 
        if(haveError) DieDieDie(); | 
| 382 | 
> | 
        if(haveError) DieDieDie(); | 
| 383 | 
  | 
         | 
| 384 | 
  | 
        currentIndex ++; | 
| 385 | 
  | 
      } | 
| 387 | 
  | 
       | 
| 388 | 
  | 
      if (!isDirectional) { | 
| 389 | 
  | 
         | 
| 390 | 
< | 
        sprintf( writeLine, | 
| 391 | 
< | 
                 "%s\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t", | 
| 392 | 
< | 
                 atomTypeString, | 
| 393 | 
< | 
                 atomData6[0], | 
| 394 | 
< | 
                 atomData6[1], | 
| 395 | 
< | 
                 atomData6[2], | 
| 396 | 
< | 
                 atomData6[3], | 
| 397 | 
< | 
                 atomData6[4], | 
| 398 | 
< | 
                 atomData6[5]); | 
| 390 | 
> | 
        sprintf( writeLine, | 
| 391 | 
> | 
                             "%s\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t", | 
| 392 | 
> | 
                             atomTypeString, | 
| 393 | 
> | 
                             atomData6[0], | 
| 394 | 
> | 
                             atomData6[1], | 
| 395 | 
> | 
                             atomData6[2], | 
| 396 | 
> | 
                             atomData6[3], | 
| 397 | 
> | 
                             atomData6[4], | 
| 398 | 
> | 
                             atomData6[5]); | 
| 399 | 
  | 
 | 
| 400 | 
< | 
        strcat( writeLine, "0.0\t0.0\t0.0\t0.0\t0.0\t0.0\t0.0\n" ); | 
| 400 | 
> | 
              strcat( writeLine, "0.0\t0.0\t0.0\t0.0\t0.0\t0.0\t0.0\n" ); | 
| 401 | 
  | 
         | 
| 402 | 
  | 
      } else { | 
| 403 | 
  | 
         | 
| 404 | 
< | 
        sprintf( writeLine, | 
| 405 | 
< | 
                 "%s\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\n", | 
| 406 | 
< | 
                 atomTypeString, | 
| 407 | 
< | 
                 atomData13[0], | 
| 408 | 
< | 
                 atomData13[1], | 
| 409 | 
< | 
                 atomData13[2], | 
| 410 | 
< | 
                 atomData13[3], | 
| 411 | 
< | 
                 atomData13[4], | 
| 412 | 
< | 
                 atomData13[5], | 
| 413 | 
< | 
                 atomData13[6], | 
| 414 | 
< | 
                 atomData13[7], | 
| 415 | 
< | 
                 atomData13[8], | 
| 416 | 
< | 
                 atomData13[9], | 
| 417 | 
< | 
                 atomData13[10], | 
| 418 | 
< | 
                 atomData13[11], | 
| 419 | 
< | 
                 atomData13[12]); | 
| 404 | 
> | 
              sprintf( writeLine, | 
| 405 | 
> | 
                             "%s\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\n", | 
| 406 | 
> | 
                             atomTypeString, | 
| 407 | 
> | 
                             atomData13[0], | 
| 408 | 
> | 
                             atomData13[1], | 
| 409 | 
> | 
                             atomData13[2], | 
| 410 | 
> | 
                             atomData13[3], | 
| 411 | 
> | 
                             atomData13[4], | 
| 412 | 
> | 
                             atomData13[5], | 
| 413 | 
> | 
                             atomData13[6], | 
| 414 | 
> | 
                             atomData13[7], | 
| 415 | 
> | 
                             atomData13[8], | 
| 416 | 
> | 
                             atomData13[9], | 
| 417 | 
> | 
                             atomData13[10], | 
| 418 | 
> | 
                             atomData13[11], | 
| 419 | 
> | 
                             atomData13[12]); | 
| 420 | 
  | 
         | 
| 421 | 
  | 
      } | 
| 422 | 
  | 
       | 
| 423 | 
< | 
      outFile << writeLine; | 
| 423 | 
> | 
      for(k = 0; k < outFile.size(); k++) | 
| 424 | 
> | 
        *outFile[k] << writeLine; | 
| 425 | 
  | 
    } | 
| 426 | 
  | 
     | 
| 427 | 
< | 
 | 
| 428 | 
< | 
    outFile.flush(); | 
| 427 | 
> | 
    for(k = 0; k < outFile.size(); k++) | 
| 428 | 
> | 
      outFile[k]->flush(); | 
| 429 | 
> | 
     | 
| 430 | 
  | 
    sprintf( checkPointMsg, | 
| 431 | 
  | 
             "Sucessfully took a dump.\n"); | 
| 432 | 
+ | 
 | 
| 433 | 
  | 
    MPIcheckPoint();         | 
| 434 | 
+ | 
 | 
| 435 | 
  | 
    delete[] potatoes; | 
| 436 | 
+ | 
 | 
| 437 | 
  | 
  } else { | 
| 438 | 
  | 
 | 
| 439 | 
  | 
    // worldRank != 0, so I'm a remote node.   | 
| 465 | 
  | 
          | 
| 466 | 
  | 
          atomTypeString = atoms[local_index]->getType(); | 
| 467 | 
  | 
 | 
| 468 | 
< | 
          atoms[local_index]->getPos(pos); | 
| 469 | 
< | 
          atoms[local_index]->getVel(vel); | 
| 468 | 
> | 
                atoms[local_index]->getPos(pos); | 
| 469 | 
> | 
                atoms[local_index]->getVel(vel); | 
| 470 | 
  | 
 | 
| 471 | 
  | 
          atomData6[0] = pos[0]; | 
| 472 | 
  | 
          atomData6[1] = pos[1]; | 
| 492 | 
  | 
            atomData13[7] = q[1]; | 
| 493 | 
  | 
            atomData13[8] = q[2]; | 
| 494 | 
  | 
            atomData13[9] = q[3]; | 
| 495 | 
< | 
 | 
| 495 | 
> | 
   | 
| 496 | 
  | 
            atomData13[10] = dAtom->getJx(); | 
| 497 | 
  | 
            atomData13[11] = dAtom->getJy(); | 
| 498 | 
  | 
            atomData13[12] = dAtom->getJz(); | 
| 499 | 
  | 
          } | 
| 500 | 
  | 
 | 
| 501 | 
  | 
        } else { | 
| 502 | 
< | 
          sprintf(painCave.errMsg, | 
| 503 | 
< | 
                  "Atom %d not found on processor %d\n", | 
| 504 | 
< | 
                  i, worldRank ); | 
| 505 | 
< | 
          haveError= 1; | 
| 506 | 
< | 
          simError(); | 
| 507 | 
< | 
        } | 
| 502 | 
> | 
                sprintf(painCave.errMsg, | 
| 503 | 
> | 
                              "Atom %d not found on processor %d\n", | 
| 504 | 
> | 
                              i, worldRank ); | 
| 505 | 
> | 
                haveError= 1; | 
| 506 | 
> | 
                simError(); | 
| 507 | 
> | 
              } | 
| 508 | 
  | 
 | 
| 509 | 
  | 
        strncpy(MPIatomTypeString, atomTypeString, MINIBUFFERSIZE); | 
| 510 | 
  | 
 | 
| 512 | 
  | 
        MPIatomTypeString[MINIBUFFERSIZE-1] = '\0'; | 
| 513 | 
  | 
 | 
| 514 | 
  | 
        MPI_Send(MPIatomTypeString, MINIBUFFERSIZE, MPI_CHAR, 0, | 
| 515 | 
< | 
                 myPotato, MPI_COMM_WORLD); | 
| 515 | 
> | 
                             myPotato, MPI_COMM_WORLD); | 
| 516 | 
  | 
         | 
| 517 | 
  | 
        myPotato++; | 
| 518 | 
  | 
 | 
| 519 | 
  | 
        MPI_Send(&isDirectional, 1, MPI_INT, 0, | 
| 520 | 
< | 
                 myPotato, MPI_COMM_WORLD); | 
| 520 | 
> | 
                             myPotato, MPI_COMM_WORLD); | 
| 521 | 
  | 
         | 
| 522 | 
  | 
        myPotato++; | 
| 523 | 
  | 
         |