diff --git a/applications/test/dictionary/dictionaryTest.C b/applications/test/dictionary/dictionaryTest.C index d958d81a1a..2c2395e9fb 100644 --- a/applications/test/dictionary/dictionaryTest.C +++ b/applications/test/dictionary/dictionaryTest.C @@ -29,6 +29,7 @@ Description \*---------------------------------------------------------------------------*/ +#include "argList.H" #include "IOstreams.H" #include "IOobject.H" #include "IFstream.H" @@ -41,6 +42,15 @@ using namespace Foam; int main(int argc, char *argv[]) { + argList::noParallel(); + argList args(argc, argv); + + Info<< nl + << "FOAM_CASE=" << getEnv("FOAM_CASE") << nl + << "FOAM_CASENAME=" << getEnv("FOAM_CASENAME") << nl + << endl; + + { dictionary dict1(IFstream("testDict")()); Info<< "dict1: " << dict1 << nl diff --git a/applications/test/dictionary/testDict b/applications/test/dictionary/testDict index 6a0863a454..42a473a52b 100644 --- a/applications/test/dictionary/testDict +++ b/applications/test/dictionary/testDict @@ -14,6 +14,9 @@ FoamFile } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // #inputMode merge +#includeIfPresent "someUnknownFile" +#includeIfPresent "$FOAM_CASE/someUnknownFile" +#includeIfPresent "$FOAM_CASE/someUnknownFile-$FOAM_CASENAME" internalField uniform 1; @@ -78,7 +81,6 @@ boundaryField // NB: the inputMode has a global scope #inputMode merge #include "testDict2" -#includeIfPresent "SomeUnknownFile" foo { diff --git a/src/OpenFOAM/global/argList/argList.C b/src/OpenFOAM/global/argList/argList.C index 365bff3cfa..01feb13dfc 100644 --- a/src/OpenFOAM/global/argList/argList.C +++ b/src/OpenFOAM/global/argList/argList.C @@ -129,14 +129,18 @@ void Foam::argList::getRootCase() casePath = iter(); casePath.removeRepeated('/'); casePath.removeTrailing('/'); + + // handle degenerate form and '-case .' like no -case specified + if (casePath.empty() || casePath == ".") + { + casePath = cwd(); + options_.erase("case"); + } } else { // nothing specified, use the current dir casePath = cwd(); - - // we could add this back in as '-case'? - // options_.set("case", casePath); } rootPath_ = casePath.path(); @@ -522,10 +526,26 @@ Foam::argList::argList } jobInfo.write(); + // Set the case and case-name as an environment variable - setEnv("FOAM_CASE", rootPath_/globalCase_, true); + if (rootPath_[0] == '/') + { + // absolute path + setEnv("FOAM_CASE", rootPath_/globalCase_, true); + } + else if (rootPath_ == ".") + { + // relative to the current working directory + setEnv("FOAM_CASE", cwd()/globalCase_, true); + } + else + { + // qualify relative path + setEnv("FOAM_CASE", cwd()/rootPath_/globalCase_, true); + } setEnv("FOAM_CASENAME", globalCase_, true); + // Switch on signal trapping. We have to wait until after Pstream::init // since this sets up its own ones. sigFpe_.set(bannerEnabled);