mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
BUG: race condition when removing ABORT file
This commit is contained in:
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2009-2009 OpenCFD Ltd.
|
\\ / A nd | Copyright (C) 2009-2010 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -28,6 +28,7 @@ License
|
|||||||
#include "error.H"
|
#include "error.H"
|
||||||
#include "Time.H"
|
#include "Time.H"
|
||||||
#include "OSspecific.H"
|
#include "OSspecific.H"
|
||||||
|
#include "PstreamReduceOps.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
@ -52,8 +53,12 @@ const Foam::NamedEnum<Foam::abortCalculation::actionType, 3>
|
|||||||
|
|
||||||
void Foam::abortCalculation::removeFile() const
|
void Foam::abortCalculation::removeFile() const
|
||||||
{
|
{
|
||||||
if (isFile(abortFile_))
|
bool hasAbort = isFile(abortFile_);
|
||||||
|
reduce(hasAbort, orOp<bool>());
|
||||||
|
|
||||||
|
if (hasAbort && Pstream::master())
|
||||||
{
|
{
|
||||||
|
// cleanup ABORT file (on master only)
|
||||||
rm(abortFile_);
|
rm(abortFile_);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -92,14 +97,9 @@ Foam::abortCalculation::~abortCalculation()
|
|||||||
|
|
||||||
void Foam::abortCalculation::read(const dictionary& dict)
|
void Foam::abortCalculation::read(const dictionary& dict)
|
||||||
{
|
{
|
||||||
word actionName;
|
|
||||||
|
|
||||||
if (dict.found("action"))
|
if (dict.found("action"))
|
||||||
{
|
{
|
||||||
action_ = actionTypeNames_.read
|
action_ = actionTypeNames_.read(dict.lookup("action"));
|
||||||
(
|
|
||||||
dict.lookup("action")
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -115,26 +115,41 @@ void Foam::abortCalculation::read(const dictionary& dict)
|
|||||||
|
|
||||||
void Foam::abortCalculation::execute()
|
void Foam::abortCalculation::execute()
|
||||||
{
|
{
|
||||||
if (isFile(abortFile_))
|
bool hasAbort = isFile(abortFile_);
|
||||||
|
reduce(hasAbort, orOp<bool>());
|
||||||
|
|
||||||
|
if (hasAbort)
|
||||||
{
|
{
|
||||||
switch (action_)
|
switch (action_)
|
||||||
{
|
{
|
||||||
case noWriteNow :
|
case noWriteNow :
|
||||||
obr_.time().stopAt(Time::saNoWriteNow);
|
if (obr_.time().stopAt(Time::saNoWriteNow))
|
||||||
Info<< "user requested abort - "
|
{
|
||||||
"stop immediately without writing data" << endl;
|
Info<< "USER REQUESTED ABORT (timeIndex="
|
||||||
|
<< obr_.time().timeIndex()
|
||||||
|
<< "): stop without writing data"
|
||||||
|
<< endl;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case writeNow :
|
case writeNow :
|
||||||
obr_.time().stopAt(Time::saWriteNow);
|
if (obr_.time().stopAt(Time::saWriteNow))
|
||||||
Info<< "user requested abort - "
|
{
|
||||||
"stop immediately with writing data" << endl;
|
Info<< "USER REQUESTED ABORT (timeIndex="
|
||||||
|
<< obr_.time().timeIndex()
|
||||||
|
<< "): stop+write data"
|
||||||
|
<< endl;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case nextWrite :
|
case nextWrite :
|
||||||
obr_.time().stopAt(Time::saNextWrite);
|
if (obr_.time().stopAt(Time::saNextWrite))
|
||||||
Info<< "user requested abort - "
|
{
|
||||||
"stop after next data write" << endl;
|
Info<< "USER REQUESTED ABORT (timeIndex="
|
||||||
|
<< obr_.time().timeIndex()
|
||||||
|
<< "): stop after next data write"
|
||||||
|
<< endl;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -149,7 +164,7 @@ void Foam::abortCalculation::end()
|
|||||||
|
|
||||||
void Foam::abortCalculation::write()
|
void Foam::abortCalculation::write()
|
||||||
{
|
{
|
||||||
execute();
|
// Do nothing - only valid on execute
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user