diff --git a/src/OSspecific/POSIX/POSIX.C b/src/OSspecific/POSIX/POSIX.C index da4bf887c9..d90fb84397 100644 --- a/src/OSspecific/POSIX/POSIX.C +++ b/src/OSspecific/POSIX/POSIX.C @@ -523,6 +523,22 @@ time_t Foam::lastModified(const fileName& name) } +double Foam::highResLastModified(const fileName& name) +{ + fileStat fileStatus(name); + if (fileStatus.isValid()) + { + return + fileStatus.status().st_mtime + + 1e-9d*fileStatus.status().st_atim.tv_nsec; + } + else + { + return 0.0; + } +} + + Foam::fileNameList Foam::readDir ( const fileName& directory, diff --git a/src/OSspecific/POSIX/fileMonitor.C b/src/OSspecific/POSIX/fileMonitor.C index d3f010f093..ff7deb7538 100644 --- a/src/OSspecific/POSIX/fileMonitor.C +++ b/src/OSspecific/POSIX/fileMonitor.C @@ -126,7 +126,7 @@ namespace Foam // For stat //- From watch descriptor to modified time - DynamicList lastMod_; + DynamicList lastMod_; @@ -261,7 +261,7 @@ namespace Foam << abort(FatalError); } - lastMod_(watchFd) = lastModified(fName); + lastMod_(watchFd) = highResLastModified(fName); } return true; @@ -395,12 +395,12 @@ void Foam::fileMonitor::checkFiles() const { forAll(watcher_->lastMod_, watchFd) { - time_t oldTime = watcher_->lastMod_[watchFd]; + double oldTime = watcher_->lastMod_[watchFd]; if (oldTime != 0) { const fileName& fName = watchFile_[watchFd]; - time_t newTime = lastModified(fName); + double newTime = highResLastModified(fName); if (newTime == 0) { @@ -615,7 +615,7 @@ void Foam::fileMonitor::setUnmodified(const label watchFd) if (!useInotify_) { - watcher_->lastMod_[watchFd] = lastModified(watchFile_[watchFd]); + watcher_->lastMod_[watchFd] = highResLastModified(watchFile_[watchFd]); } } diff --git a/src/OpenFOAM/db/regIOobject/regIOobject.C b/src/OpenFOAM/db/regIOobject/regIOobject.C index fbd5f64eef..675e611182 100644 --- a/src/OpenFOAM/db/regIOobject/regIOobject.C +++ b/src/OpenFOAM/db/regIOobject/regIOobject.C @@ -48,14 +48,14 @@ namespace Foam }; } -int Foam::regIOobject::fileModificationSkew +float Foam::regIOobject::fileModificationSkew ( - Foam::debug::optimisationSwitch("fileModificationSkew", 30) + Foam::debug::floatOptimisationSwitch("fileModificationSkew", 30) ); registerOptSwitch ( "fileModificationSkew", - int, + float, Foam::regIOobject::fileModificationSkew ); diff --git a/src/OpenFOAM/db/regIOobject/regIOobject.H b/src/OpenFOAM/db/regIOobject/regIOobject.H index 56078ce15d..aea17b9a64 100644 --- a/src/OpenFOAM/db/regIOobject/regIOobject.H +++ b/src/OpenFOAM/db/regIOobject/regIOobject.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -124,7 +124,7 @@ public: //- Runtime type information TypeName("regIOobject"); - static int fileModificationSkew; + static float fileModificationSkew; static fileCheckTypes fileModificationChecking; diff --git a/src/OpenFOAM/global/argList/argList.C b/src/OpenFOAM/global/argList/argList.C index d9cf7f2065..9e223df6ba 100644 --- a/src/OpenFOAM/global/argList/argList.C +++ b/src/OpenFOAM/global/argList/argList.C @@ -872,8 +872,23 @@ void Foam::argList::parse << regIOobject::fileCheckTypesNames [ regIOobject::fileModificationChecking - ] - << endl; + ]; + if + ( + ( + regIOobject::fileModificationChecking + == regIOobject::timeStamp + ) + || ( + regIOobject::fileModificationChecking + == regIOobject::timeStampMaster + ) + ) + { + Info<< " (fileModificationSkew " + << regIOobject::fileModificationSkew << ")"; + } + Info<< endl; Info<< "allowSystemOperations : "; if (dynamicCode::allowSystemOperations) diff --git a/src/OpenFOAM/global/debug/debug.C b/src/OpenFOAM/global/debug/debug.C index 279be74090..bdf1698d07 100644 --- a/src/OpenFOAM/global/debug/debug.C +++ b/src/OpenFOAM/global/debug/debug.C @@ -190,6 +190,19 @@ int Foam::debug::optimisationSwitch(const char* name, const int defaultValue) } +float Foam::debug::floatOptimisationSwitch +( + const char* name, + const float defaultValue +) +{ + return optimisationSwitches().lookupOrAddDefault + ( + name, defaultValue, false, false + ); +} + + void Foam::debug::addDebugObject(const char* name, simpleRegIOobject* obj) { simpleObjectRegistryEntry* ptr = debugObjects().lookupPtr(name); diff --git a/src/OpenFOAM/global/debug/debug.H b/src/OpenFOAM/global/debug/debug.H index 4eeb8cbb53..190f73be30 100644 --- a/src/OpenFOAM/global/debug/debug.H +++ b/src/OpenFOAM/global/debug/debug.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -74,6 +74,13 @@ namespace debug //- Lookup optimisation switch or add default value. int optimisationSwitch(const char* name, const int defaultValue=0); + //- Lookup optimisation switch or add default value. + float floatOptimisationSwitch + ( + const char* name, + const float defaultValue=0 + ); + //- Internal function to lookup a sub-dictionary from controlDict. dictionary& switchSet(const char* subDictName, dictionary*& subDictPtr); diff --git a/src/OpenFOAM/include/OSspecific.H b/src/OpenFOAM/include/OSspecific.H index c40aebb598..66a4ecc44a 100644 --- a/src/OpenFOAM/include/OSspecific.H +++ b/src/OpenFOAM/include/OSspecific.H @@ -122,6 +122,9 @@ off_t fileSize(const fileName&); //- Return time of last file modification time_t lastModified(const fileName&); +//- Return time of last file modification +double highResLastModified(const fileName&); + //- Read a directory and return the entries as a string list fileNameList readDir (