BUG: mismatch in watch file indices (see !605)
This commit is contained in:
parent
56a0f80863
commit
c647e68e1f
@ -277,6 +277,23 @@ Foam::label Foam::regIOobject::addWatch(const fileName& f)
|
||||
|
||||
void Foam::regIOobject::addWatch()
|
||||
{
|
||||
// Everyone or just master
|
||||
const bool masterOnly
|
||||
(
|
||||
global()
|
||||
&& (
|
||||
IOobject::fileModificationChecking == IOobject::timeStampMaster
|
||||
|| IOobject::fileModificationChecking == IOobject::inotifyMaster
|
||||
)
|
||||
);
|
||||
|
||||
// if (debug)
|
||||
// {
|
||||
// Pout<< "regIOobject::addWatch " << watchIndices_.size()
|
||||
// << " indices master-only:" << masterOnly
|
||||
// << " watchFiles: " << watchFiles_ << endl;
|
||||
// }
|
||||
|
||||
if
|
||||
(
|
||||
registered_
|
||||
@ -285,7 +302,7 @@ void Foam::regIOobject::addWatch()
|
||||
)
|
||||
{
|
||||
fileName f = filePath();
|
||||
if (!f.size())
|
||||
if (f.empty())
|
||||
{
|
||||
// We don't have this file but would like to re-read it.
|
||||
// Possibly if master-only reading mode.
|
||||
@ -303,14 +320,6 @@ void Foam::regIOobject::addWatch()
|
||||
|
||||
// If master-only reading only the master will have all dependencies
|
||||
// so broadcast these to other ranks
|
||||
const bool masterOnly
|
||||
(
|
||||
global()
|
||||
&& (
|
||||
IOobject::fileModificationChecking == IOobject::timeStampMaster
|
||||
|| IOobject::fileModificationChecking == IOobject::inotifyMaster
|
||||
)
|
||||
);
|
||||
|
||||
if (masterOnly && UPstream::parRun())
|
||||
{
|
||||
@ -328,8 +337,13 @@ void Foam::regIOobject::addWatch()
|
||||
|
||||
UPstream::parRun(oldParRun);
|
||||
}
|
||||
Pstream::broadcast(filesToWatch);
|
||||
|
||||
Pstream::broadcasts
|
||||
(
|
||||
UPstream::worldComm,
|
||||
filesToWatch,
|
||||
watchFiles_
|
||||
);
|
||||
|
||||
// Add master files in same order
|
||||
if (!UPstream::master())
|
||||
|
@ -100,7 +100,7 @@ void Foam::regIOobject::readStream(const bool readOnProc)
|
||||
if (watchIndices_.size())
|
||||
{
|
||||
// File is being watched. Read exact file that is being watched.
|
||||
objPath = fileHandler().getFile(watchIndices_.last());
|
||||
objPath = fileHandler().getFile(watchIndices_.back());
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -190,26 +190,7 @@ bool Foam::regIOobject::read()
|
||||
// Note: cannot do anything in readStream itself since this is used by
|
||||
// e.g. GeometricField.
|
||||
|
||||
|
||||
// Save old watchIndices and clear (so the list of included files can
|
||||
// change)
|
||||
fileNameList oldWatchFiles;
|
||||
if (watchIndices_.size())
|
||||
{
|
||||
oldWatchFiles.setSize(watchIndices_.size());
|
||||
forAll(watchIndices_, i)
|
||||
{
|
||||
oldWatchFiles[i] = fileHandler().getFile(watchIndices_[i]);
|
||||
}
|
||||
forAllReverse(watchIndices_, i)
|
||||
{
|
||||
fileHandler().removeWatch(watchIndices_[i]);
|
||||
}
|
||||
watchIndices_.clear();
|
||||
}
|
||||
|
||||
|
||||
// Read
|
||||
// Everyone or just master
|
||||
const bool masterOnly
|
||||
(
|
||||
global()
|
||||
@ -219,12 +200,26 @@ bool Foam::regIOobject::read()
|
||||
)
|
||||
);
|
||||
|
||||
// Remove old watches (indices) and clear:
|
||||
// so the list of included files can change
|
||||
|
||||
const bool needWatch(!watchIndices_.empty());
|
||||
|
||||
if (!watchIndices_.empty())
|
||||
{
|
||||
forAllReverse(watchIndices_, i)
|
||||
{
|
||||
fileHandler().removeWatch(watchIndices_[i]);
|
||||
}
|
||||
watchIndices_.clear();
|
||||
}
|
||||
|
||||
// Note: IOstream::binary flag is for all the processor comms. (Only for
|
||||
// dictionaries should it be ascii)
|
||||
bool ok =
|
||||
fileHandler().read(*this, masterOnly, IOstreamOption::BINARY, type());
|
||||
|
||||
if (oldWatchFiles.size())
|
||||
if (needWatch)
|
||||
{
|
||||
// Re-watch master file
|
||||
addWatch();
|
||||
@ -264,9 +259,9 @@ bool Foam::regIOobject::readIfModified()
|
||||
|
||||
if (modified != -1)
|
||||
{
|
||||
const fileName fName = fileHandler().getFile(watchIndices_.last());
|
||||
const fileName fName = fileHandler().getFile(watchIndices_.back());
|
||||
|
||||
if (modified == watchIndices_.last())
|
||||
if (modified == watchIndices_.back())
|
||||
{
|
||||
InfoInFunction
|
||||
<< " Re-reading object " << name()
|
||||
|
@ -94,7 +94,7 @@ bool Foam::regIOobject::writeObject
|
||||
}
|
||||
|
||||
|
||||
// Everyone check or just master
|
||||
// Everyone or just master
|
||||
const bool masterOnly
|
||||
(
|
||||
isGlobal
|
||||
@ -122,9 +122,9 @@ bool Foam::regIOobject::writeObject
|
||||
|
||||
// Only update the lastModified_ time if this object is re-readable,
|
||||
// i.e. lastModified_ is already set
|
||||
if (watchIndices_.size())
|
||||
if (!watchIndices_.empty())
|
||||
{
|
||||
fileHandler().setUnmodified(watchIndices_.last());
|
||||
fileHandler().setUnmodified(watchIndices_.back());
|
||||
}
|
||||
|
||||
return osGood;
|
||||
|
Loading…
Reference in New Issue
Block a user