MCPcopy Create free account
hub / github.com/AMReX-Codes/amrex / TryFileOutput

Method TryFileOutput

Src/Base/AMReX_Utility.cpp:647–692  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

645
646
647bool amrex::StreamRetry::TryFileOutput()
648{
649 bool bTryOutput(false);
650
651 if(tries == 0) {
652 bTryOutput = true;
653 } else {
654
655 int nWriteErrors(nStreamErrors);
656 ParallelDescriptor::ReduceIntSum(nWriteErrors);
657
658 if(nWriteErrors == 0) { // wrote a good file
659 bTryOutput = false;
660 } else { // wrote a bad file, rename it
661 if(ParallelDescriptor::IOProcessor()) {
662 const std::string& badFileName = amrex::Concatenate(fileName + ".bad",
663 tries - 1, 2);
664 if (amrex::Verbose() > 1) {
665 amrex::Print() << nWriteErrors << " STREAMERRORS : Renaming file from "
666 << fileName << " to " << badFileName << '\n';
667 }
668 if (amrex::FileExists(badFileName)) {
669 FileSystem::RemoveAll(badFileName);
670 }
671 if (std::rename(fileName.c_str(), badFileName.c_str())) {
672 amrex::Abort("StreamRetry::TryFileOutput: std::rename failed");
673 }
674 }
675 ParallelDescriptor::Barrier("StreamRetry::TryFileOutput"); // wait for file rename
676
677 // check for maxtries and abort pref
678 if(tries < maxTries) {
679 bTryOutput = true;
680 } else {
681 if(abortOnRetryFailure) {
682 amrex::Abort("STREAMERROR : StreamRetry::maxTries exceeded.");
683 }
684 bTryOutput = false;
685 }
686 }
687 }
688
689 ++tries;
690 nStreamErrors = 0;
691 return bTryOutput;
692}
693
694
695void amrex::SyncStrings(const Vector<std::string> &localStrings,

Callers 2

writePlotFileDoitMethod · 0.80
checkPointMethod · 0.80

Calls 7

ReduceIntSumFunction · 0.85
IOProcessorFunction · 0.85
ConcatenateFunction · 0.85
PrintClass · 0.85
RemoveAllFunction · 0.85
AbortFunction · 0.85
BarrierFunction · 0.85

Tested by

no test coverage detected