From 907bb58e9f788016d5f0ac2107e3065e0ff5908b Mon Sep 17 00:00:00 2001 From: Henry Weller Date: Sun, 21 Jan 2018 12:22:30 +0000 Subject: [PATCH] jobInfo: Write jobInfo files into the case/jobInfo directory With the writeJobInfo option in OpenFOAM-dev/etc/controlDict::InfoSwitches set to 1 each OpenFOAM executable writes a . file containing the job summary into the /jobInfo directory, e.g. after running the tutorials/incompressible/pisoFoam/RAS/cavity tutorials tutorials/incompressible/pisoFoam/RAS/cavity/jobInfo contains blockMesh.20169 pisoFoam.20170 --- bin/tools/CleanFunctions | 3 ++- src/OpenFOAM/global/argList/argList.C | 2 +- src/OpenFOAM/global/jobInfo/jobInfo.C | 28 +++++++++++++++++---------- src/OpenFOAM/global/jobInfo/jobInfo.H | 2 +- 4 files changed, 22 insertions(+), 13 deletions(-) diff --git a/bin/tools/CleanFunctions b/bin/tools/CleanFunctions index 7390c36403..7be55f0593 100644 --- a/bin/tools/CleanFunctions +++ b/bin/tools/CleanFunctions @@ -2,7 +2,7 @@ # ========= | # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox # \\ / O peration | -# \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation +# \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation # \\/ M anipulation | #------------------------------------------------------------------------------ # License @@ -56,6 +56,7 @@ cleanCase() cleanDynamicCode rm -rf processor* > /dev/null 2>&1 + rm -rf jobInfo > /dev/null 2>&1 rm -rf postProcessing > /dev/null 2>&1 rm -rf TDAC > /dev/null 2>&1 rm -rf probes* > /dev/null 2>&1 diff --git a/src/OpenFOAM/global/argList/argList.C b/src/OpenFOAM/global/argList/argList.C index 22d09ec229..ce45118c42 100644 --- a/src/OpenFOAM/global/argList/argList.C +++ b/src/OpenFOAM/global/argList/argList.C @@ -895,7 +895,7 @@ void Foam::argList::parse { jobInfo_.add("roots", roots); } - jobInfo_.write(rootPath_/globalCase_); + jobInfo_.write(executable_, rootPath_/globalCase_); // Switch on signal trapping. We have to wait until after Pstream::init // since this sets up its own ones. diff --git a/src/OpenFOAM/global/jobInfo/jobInfo.C b/src/OpenFOAM/global/jobInfo/jobInfo.C index 3838c12f0c..353c384b32 100644 --- a/src/OpenFOAM/global/jobInfo/jobInfo.C +++ b/src/OpenFOAM/global/jobInfo/jobInfo.C @@ -90,13 +90,6 @@ Foam::jobInfo::jobInfo() writeJobInfo = true; } - else if (writeJobInfo) - { - string jobFile = name() + '.' + Foam::name(pid()); - - runningJobPath_ = jobFile; - finishedJobPath_ = jobFile; - } } constructed = true; @@ -139,14 +132,29 @@ bool Foam::jobInfo::write(Ostream& os) const } -void Foam::jobInfo::write(const fileName& casePath) const +void Foam::jobInfo::write +( + const word& executable, + const fileName& casePath +) const { if (writeJobInfo && Pstream::master()) { if (!writeJobControl) { - runningJobPath_ = casePath/runningJobPath_; - finishedJobPath_ = casePath/finishedJobPath_; + const fileName jobInfoPath(casePath/"jobInfo"); + + if (!isDir(jobInfoPath) && !mkDir(jobInfoPath)) + { + FatalErrorInFunction + << "Cannot make jobInfo directory " << jobInfoPath + << Foam::exit(FatalError); + } + + const word jobFile = executable + '.' + Foam::name(pid()); + + runningJobPath_ = jobInfoPath/jobFile; + finishedJobPath_ = jobInfoPath/jobFile; } if (!write(OFstream(runningJobPath_)())) diff --git a/src/OpenFOAM/global/jobInfo/jobInfo.H b/src/OpenFOAM/global/jobInfo/jobInfo.H index be1f56e954..e6819aad5a 100644 --- a/src/OpenFOAM/global/jobInfo/jobInfo.H +++ b/src/OpenFOAM/global/jobInfo/jobInfo.H @@ -86,7 +86,7 @@ public: // Member Functions - void write(const fileName& casePath) const; + void write(const word& executable, const fileName& casePath) const; void end();