---------------------------------------------------------------
| 474 | |
| 475 | // --------------------------------------------------------------- |
| 476 | static void WriteCheckpointFile(const std::string& inFileName, const std::string &outFileName) { |
| 477 | VisMF::SetNOutFiles(nFiles); |
| 478 | // In checkpoint files always write out FABs in NATIVE format. |
| 479 | FABio::Format thePrevFormat = FArrayBox::getFormat(); |
| 480 | FArrayBox::setFormat(FABio::FAB_NATIVE); |
| 481 | |
| 482 | const std::string ckfile = outFileName; |
| 483 | |
| 484 | // Only the I/O processor makes the directory if it doesn't already exist. |
| 485 | if(ParallelDescriptor::IOProcessor()) { |
| 486 | if( ! amrex::UtilCreateDirectory(ckfile, 0755)) { |
| 487 | amrex::CreateDirectoryFailed(ckfile); |
| 488 | } |
| 489 | } |
| 490 | // Force other processors to wait till directory is built. |
| 491 | ParallelDescriptor::Barrier(); |
| 492 | |
| 493 | // Copy some standard auxiliary files to the new checkpoint. |
| 494 | // Only one processor (the I/O processor) needs to do this. |
| 495 | |
| 496 | if (ParallelDescriptor::IOProcessor()) { |
| 497 | |
| 498 | std::ifstream oldCastroHeaderFile; |
| 499 | |
| 500 | std::string oldCastroHeaderName = inFileName + "/CastroHeader"; |
| 501 | oldCastroHeaderFile.open(oldCastroHeaderName.c_str(), std::ios::binary); |
| 502 | |
| 503 | if (oldCastroHeaderFile.good()) { |
| 504 | |
| 505 | std::ofstream newCastroHeaderFile; |
| 506 | |
| 507 | std::string newCastroHeaderName = outFileName + "/CastroHeader"; |
| 508 | newCastroHeaderFile.open(newCastroHeaderName.c_str(), std::ios::binary); |
| 509 | |
| 510 | if (newCastroHeaderFile.good()) { |
| 511 | newCastroHeaderFile << oldCastroHeaderFile.rdbuf(); |
| 512 | newCastroHeaderFile.close(); |
| 513 | } |
| 514 | |
| 515 | oldCastroHeaderFile.close(); |
| 516 | |
| 517 | } |
| 518 | |
| 519 | } |
| 520 | |
| 521 | // Write the main header file. |
| 522 | |
| 523 | std::string HeaderFileName = ckfile + "/Header"; |
| 524 | |
| 525 | VisMF::IO_Buffer io_buffer(VisMF::IO_Buffer_Size); |
| 526 | |
| 527 | std::ofstream HeaderFile; |
| 528 | |
| 529 | HeaderFile.rdbuf()->pubsetbuf(io_buffer.dataPtr(), io_buffer.size()); |
| 530 | |
| 531 | int old_prec(0), i; |
| 532 | |
| 533 | if(ParallelDescriptor::IOProcessor()) { |