mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
- add additional control via a Foam::infoDetailLevel flag, which is
supported by a 'DetailLevel' macro. Eg,
DetailLevel << "some information" << nl
- When infoDetailLevel is zero, the stdout for all Foam::system() calls
are also redirected to stderr to prevent child output from
appearing on the parent.
- close stdin before exec in system call.
This commit is contained in:
@ -124,7 +124,7 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
if (nProcs)
|
if (nProcs)
|
||||||
{
|
{
|
||||||
// Info<< "Remove " << timeDirs.size()
|
// Serr<< "Remove " << timeDirs.size()
|
||||||
// << " processor time directories" << nl;
|
// << " processor time directories" << nl;
|
||||||
|
|
||||||
forAllReverse(timeDirs, timei)
|
forAllReverse(timeDirs, timei)
|
||||||
@ -153,7 +153,7 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Info<< "Remove " << timeDirs.size()
|
// Serr<< "Remove " << timeDirs.size()
|
||||||
// << " time directories" << nl;
|
// << " time directories" << nl;
|
||||||
|
|
||||||
forAllReverse(timeDirs, timei)
|
forAllReverse(timeDirs, timei)
|
||||||
|
|||||||
@ -122,7 +122,7 @@ int main(int argc, char *argv[])
|
|||||||
const scalar scaling = args.lookupOrDefault<scalar>("scale", -1);
|
const scalar scaling = args.lookupOrDefault<scalar>("scale", -1);
|
||||||
if (scaling > 0)
|
if (scaling > 0)
|
||||||
{
|
{
|
||||||
Info<< " -scale " << scaling << nl;
|
DetailInfo << " -scale " << scaling << nl;
|
||||||
surf.scalePoints(scaling);
|
surf.scalePoints(scaling);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -56,9 +56,6 @@ notTest()
|
|||||||
# Extract 'numberOfSubdomains' from system/decomposeParDict
|
# Extract 'numberOfSubdomains' from system/decomposeParDict
|
||||||
# (or alternative location).
|
# (or alternative location).
|
||||||
#
|
#
|
||||||
# Note that '#include' and other directives are disabled - only entries that
|
|
||||||
# are in the dictionary are considered.
|
|
||||||
#
|
|
||||||
# On failure:
|
# On failure:
|
||||||
# return '1'
|
# return '1'
|
||||||
# exit status 1
|
# exit status 1
|
||||||
@ -68,14 +65,14 @@ getNumberOfProcessors()
|
|||||||
local dict="${1:-system/decomposeParDict}"
|
local dict="${1:-system/decomposeParDict}"
|
||||||
|
|
||||||
# Re-use positional parameters for automatic whitespace elimination
|
# Re-use positional parameters for automatic whitespace elimination
|
||||||
set -- $(foamDictionary -disableFunctionEntries -entry numberOfSubdomains -value "$dict" 2>/dev/null)
|
set -- $(foamDictionary -entry numberOfSubdomains -value "$dict" 2>/dev/null)
|
||||||
|
|
||||||
if [ "$#" -eq 1 ]
|
if [ "$#" -eq 1 ]
|
||||||
then
|
then
|
||||||
echo "$1"
|
echo "$1"
|
||||||
else
|
else
|
||||||
echo "Error getting 'numberOfSubdomains' from '$dict'" 1>&2
|
echo "Error getting 'numberOfSubdomains' from '$dict'" 1>&2
|
||||||
echo 1 # serial as fallback
|
echo 1 # Fallback is 1 proc (serial)
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@ -84,9 +81,6 @@ getNumberOfProcessors()
|
|||||||
#
|
#
|
||||||
# Extract 'application' from system/controlDict
|
# Extract 'application' from system/controlDict
|
||||||
#
|
#
|
||||||
# Note that '#include' and other directives are disabled - only entries that
|
|
||||||
# are in the dictionary are considered.
|
|
||||||
#
|
|
||||||
# On failure:
|
# On failure:
|
||||||
# return 'false' which is also a command (ie, shell builtin or /bin/false)
|
# return 'false' which is also a command (ie, shell builtin or /bin/false)
|
||||||
# exit status 1
|
# exit status 1
|
||||||
@ -94,14 +88,14 @@ getNumberOfProcessors()
|
|||||||
getApplication()
|
getApplication()
|
||||||
{
|
{
|
||||||
# Re-use positional parameters for automatic whitespace elimination
|
# Re-use positional parameters for automatic whitespace elimination
|
||||||
set -- $(foamDictionary -disableFunctionEntries -entry application -value system/controlDict 2>/dev/null)
|
set -- $(foamDictionary -entry application -value system/controlDict 2>/dev/null)
|
||||||
|
|
||||||
if [ "$#" -eq 1 ]
|
if [ "$#" -eq 1 ]
|
||||||
then
|
then
|
||||||
echo "$1"
|
echo "$1"
|
||||||
else
|
else
|
||||||
echo "Error getting 'application' from system/controlDict" 1>&2
|
echo "Error getting 'application' from system/controlDict" 1>&2
|
||||||
echo false
|
echo false # Fallback
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|||||||
@ -66,6 +66,7 @@ Description
|
|||||||
#include <link.h>
|
#include <link.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
namespace Foam
|
namespace Foam
|
||||||
@ -74,9 +75,7 @@ namespace Foam
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * Static Functions * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
//! \cond fileScope
|
|
||||||
|
|
||||||
// Like fileName "/" global operator, but retain any invalid characters
|
// Like fileName "/" global operator, but retain any invalid characters
|
||||||
static inline Foam::fileName fileNameConcat
|
static inline Foam::fileName fileNameConcat
|
||||||
@ -106,7 +105,23 @@ static inline Foam::fileName fileNameConcat
|
|||||||
// Both strings are empty
|
// Both strings are empty
|
||||||
return Foam::fileName();
|
return Foam::fileName();
|
||||||
}
|
}
|
||||||
//! \endcond
|
|
||||||
|
|
||||||
|
// After a fork in system(), before the exec() do the following
|
||||||
|
// 1. close stdin
|
||||||
|
// 2. redirect stdout to stderr when infoDetailLevel == 0
|
||||||
|
static inline void redirects()
|
||||||
|
{
|
||||||
|
// Close stdin(0) - unchecked return value
|
||||||
|
(void) ::close(STDIN_FILENO);
|
||||||
|
|
||||||
|
// Redirect stdout(1) to stderr(2) '1>&2'
|
||||||
|
if (Foam::infoDetailLevel == 0)
|
||||||
|
{
|
||||||
|
// This is correct. 1>&2 means dup2(2, 1);
|
||||||
|
(void) ::dup2(STDERR_FILENO, STDOUT_FILENO);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
@ -1312,6 +1327,7 @@ static int waitpid(const pid_t pid)
|
|||||||
// in parent - blocking wait
|
// in parent - blocking wait
|
||||||
// modest treatment of signals (in child)
|
// modest treatment of signals (in child)
|
||||||
// treat 'stopped' like exit (suspend/continue)
|
// treat 'stopped' like exit (suspend/continue)
|
||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
pid_t wpid = ::waitpid(pid, &status, WUNTRACED);
|
pid_t wpid = ::waitpid(pid, &status, WUNTRACED);
|
||||||
@ -1354,11 +1370,7 @@ static int waitpid(const pid_t pid)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int Foam::system
|
int Foam::system(const std::string& command, const bool bg)
|
||||||
(
|
|
||||||
const std::string& command,
|
|
||||||
const bool background
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
if (command.empty())
|
if (command.empty())
|
||||||
{
|
{
|
||||||
@ -1369,17 +1381,22 @@ int Foam::system
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
pid_t child_pid = ::vfork(); // NB: vfork, not fork!
|
const pid_t child_pid = ::vfork(); // NB: vfork, not fork!
|
||||||
|
|
||||||
if (child_pid == -1)
|
if (child_pid == -1)
|
||||||
{
|
{
|
||||||
FatalErrorInFunction
|
FatalErrorInFunction
|
||||||
<< "vfork() failed for system command " << command
|
<< "vfork() failed for system command " << command
|
||||||
<< exit(FatalError);
|
<< exit(FatalError);
|
||||||
}
|
|
||||||
|
|
||||||
if (child_pid == 0)
|
return -1; // fallback error value
|
||||||
|
}
|
||||||
|
else if (child_pid == 0)
|
||||||
{
|
{
|
||||||
// in child
|
// In child
|
||||||
|
|
||||||
|
// Close or redirect file descriptors
|
||||||
|
redirects();
|
||||||
|
|
||||||
// execl uses the current environ
|
// execl uses the current environ
|
||||||
(void) ::execl
|
(void) ::execl
|
||||||
@ -1395,27 +1412,19 @@ int Foam::system
|
|||||||
FatalErrorInFunction
|
FatalErrorInFunction
|
||||||
<< "exec failed: " << command
|
<< "exec failed: " << command
|
||||||
<< exit(FatalError);
|
<< exit(FatalError);
|
||||||
|
|
||||||
|
return -1; // fallback error value
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// In parent:
|
// In parent
|
||||||
|
// - started as background process, or blocking wait for the child
|
||||||
|
|
||||||
if (background)
|
return (bg ? 0 : waitpid(child_pid));
|
||||||
{
|
|
||||||
// Started as background process
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// blocking wait for the child
|
|
||||||
return waitpid(child_pid);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int Foam::system
|
int Foam::system(const CStringList& command, const bool bg)
|
||||||
(
|
|
||||||
const CStringList& command,
|
|
||||||
const bool background
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
const int argc = command.size();
|
const int argc = command.size();
|
||||||
|
|
||||||
@ -1432,17 +1441,25 @@ int Foam::system
|
|||||||
// triggered by fork.
|
// triggered by fork.
|
||||||
// The normal system() command has a fork buried in it that causes
|
// The normal system() command has a fork buried in it that causes
|
||||||
// issues with infiniband and openmpi etc.
|
// issues with infiniband and openmpi etc.
|
||||||
pid_t child_pid = ::vfork();
|
|
||||||
|
const pid_t child_pid = ::vfork();
|
||||||
|
|
||||||
if (child_pid == -1)
|
if (child_pid == -1)
|
||||||
{
|
{
|
||||||
FatalErrorInFunction
|
FatalErrorInFunction
|
||||||
<< "vfork() failed for system command " << command[0]
|
<< "vfork() failed for system command " << command[0]
|
||||||
<< exit(FatalError);
|
<< exit(FatalError);
|
||||||
}
|
|
||||||
|
|
||||||
if (child_pid == 0)
|
return -1; // fallback error value
|
||||||
|
}
|
||||||
|
else if (child_pid == 0)
|
||||||
{
|
{
|
||||||
// In child:
|
// In child
|
||||||
|
|
||||||
|
// Close or redirect file descriptors
|
||||||
|
redirects();
|
||||||
|
|
||||||
|
|
||||||
// Need command and arguments separately.
|
// Need command and arguments separately.
|
||||||
// args is a nullptr-terminated list of c-strings
|
// args is a nullptr-terminated list of c-strings
|
||||||
|
|
||||||
@ -1453,32 +1470,24 @@ int Foam::system
|
|||||||
FatalErrorInFunction
|
FatalErrorInFunction
|
||||||
<< "exec(" << command[0] << ", ...) failed"
|
<< "exec(" << command[0] << ", ...) failed"
|
||||||
<< exit(FatalError);
|
<< exit(FatalError);
|
||||||
|
|
||||||
|
return -1; // fallback error value
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// In parent:
|
// In parent
|
||||||
|
// - started as background process, or blocking wait for the child
|
||||||
|
|
||||||
if (background)
|
return (bg ? 0 : waitpid(child_pid));
|
||||||
{
|
|
||||||
// Started as background process
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// blocking wait for the child
|
|
||||||
return waitpid(child_pid);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int Foam::system
|
int Foam::system(const Foam::UList<Foam::string>& command, const bool bg)
|
||||||
(
|
|
||||||
const Foam::UList<Foam::string>& command,
|
|
||||||
const bool background
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
// In the future simply call the CStringList version:
|
// In the future simply call the CStringList version:
|
||||||
//
|
//
|
||||||
// const CStringList cmd(command);
|
// const CStringList cmd(command);
|
||||||
// return Foam::system(cmd, background);
|
// return Foam::system(cmd, bg);
|
||||||
|
|
||||||
const int argc = command.size();
|
const int argc = command.size();
|
||||||
|
|
||||||
@ -1495,17 +1504,25 @@ int Foam::system
|
|||||||
// triggered by fork.
|
// triggered by fork.
|
||||||
// The normal system() command has a fork buried in it that causes
|
// The normal system() command has a fork buried in it that causes
|
||||||
// issues with infiniband and openmpi etc.
|
// issues with infiniband and openmpi etc.
|
||||||
pid_t child_pid = ::vfork();
|
|
||||||
|
const pid_t child_pid = ::vfork();
|
||||||
|
|
||||||
if (child_pid == -1)
|
if (child_pid == -1)
|
||||||
{
|
{
|
||||||
FatalErrorInFunction
|
FatalErrorInFunction
|
||||||
<< "vfork() failed for system command " << command[0]
|
<< "vfork() failed for system command " << command[0]
|
||||||
<< exit(FatalError);
|
<< exit(FatalError);
|
||||||
}
|
|
||||||
|
|
||||||
if (child_pid == 0)
|
return -1; // fallback error value
|
||||||
|
}
|
||||||
|
else if (child_pid == 0)
|
||||||
{
|
{
|
||||||
// In child:
|
// In child
|
||||||
|
|
||||||
|
// Close or redirect file descriptors
|
||||||
|
redirects();
|
||||||
|
|
||||||
|
|
||||||
// Need command and arguments separately.
|
// Need command and arguments separately.
|
||||||
// args is a nullptr-terminated list of c-strings
|
// args is a nullptr-terminated list of c-strings
|
||||||
|
|
||||||
@ -1522,19 +1539,15 @@ int Foam::system
|
|||||||
FatalErrorInFunction
|
FatalErrorInFunction
|
||||||
<< "exec(" << command[0] << ", ...) failed"
|
<< "exec(" << command[0] << ", ...) failed"
|
||||||
<< exit(FatalError);
|
<< exit(FatalError);
|
||||||
|
|
||||||
|
return -1; // fallback error value
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// In parent:
|
// In parent
|
||||||
|
// - started as background process, or blocking wait for the child
|
||||||
|
|
||||||
if (background)
|
return (bg ? 0 : waitpid(child_pid));
|
||||||
{
|
|
||||||
// Started as background process
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// blocking wait for the child
|
|
||||||
return waitpid(child_pid);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -47,10 +47,19 @@ Description
|
|||||||
|
|
||||||
namespace Foam
|
namespace Foam
|
||||||
{
|
{
|
||||||
|
//- An Istream wrapper for std::cin
|
||||||
extern ISstream Sin;
|
extern ISstream Sin;
|
||||||
|
|
||||||
|
//- An Ostream wrapper for std::cout
|
||||||
extern OSstream Sout;
|
extern OSstream Sout;
|
||||||
|
|
||||||
|
//- An Ostream wrapper for std::cerr
|
||||||
extern OSstream Serr;
|
extern OSstream Serr;
|
||||||
|
|
||||||
|
//- An Ostream wrapper for parallel output to std::cout
|
||||||
extern prefixOSstream Pout;
|
extern prefixOSstream Pout;
|
||||||
|
|
||||||
|
//- An Ostream wrapper for parallel output to std::cerr
|
||||||
extern prefixOSstream Perr;
|
extern prefixOSstream Perr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -93,8 +93,6 @@ void Foam::Time::readDict()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check for local switches and settings
|
// Check for local switches and settings
|
||||||
// - echo values, unless the application was invoked with noBanner
|
|
||||||
const bool echo = argList::bannerEnabled();
|
|
||||||
|
|
||||||
const dictionary* localDict = nullptr;
|
const dictionary* localDict = nullptr;
|
||||||
|
|
||||||
@ -105,11 +103,9 @@ void Foam::Time::readDict()
|
|||||||
&& localDict->size()
|
&& localDict->size()
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (echo)
|
DetailInfo
|
||||||
{
|
<< "Overriding DebugSwitches according to "
|
||||||
Info<< "Overriding DebugSwitches according to "
|
|
||||||
<< controlDict_.name() << nl;
|
<< controlDict_.name() << nl;
|
||||||
}
|
|
||||||
|
|
||||||
simpleObjectRegistry& objs = debug::debugObjects();
|
simpleObjectRegistry& objs = debug::debugObjects();
|
||||||
|
|
||||||
@ -123,10 +119,7 @@ void Foam::Time::readDict()
|
|||||||
{
|
{
|
||||||
const List<simpleRegIOobject*>& objects = *objPtr;
|
const List<simpleRegIOobject*>& objects = *objPtr;
|
||||||
|
|
||||||
if (echo)
|
DetailInfo << " " << iter() << nl;
|
||||||
{
|
|
||||||
Info<< " " << iter() << nl;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (iter().isDict())
|
if (iter().isDict())
|
||||||
{
|
{
|
||||||
@ -157,11 +150,9 @@ void Foam::Time::readDict()
|
|||||||
&& localDict->size()
|
&& localDict->size()
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (echo)
|
DetailInfo
|
||||||
{
|
<< "Overriding InfoSwitches according to "
|
||||||
Info<< "Overriding InfoSwitches according to "
|
|
||||||
<< controlDict_.name() << nl;
|
<< controlDict_.name() << nl;
|
||||||
}
|
|
||||||
|
|
||||||
simpleObjectRegistry& objs = debug::infoObjects();
|
simpleObjectRegistry& objs = debug::infoObjects();
|
||||||
|
|
||||||
@ -175,10 +166,7 @@ void Foam::Time::readDict()
|
|||||||
{
|
{
|
||||||
const List<simpleRegIOobject*>& objects = *objPtr;
|
const List<simpleRegIOobject*>& objects = *objPtr;
|
||||||
|
|
||||||
if (echo)
|
DetailInfo << " " << iter() << nl;
|
||||||
{
|
|
||||||
Info<< " " << iter() << nl;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (iter().isDict())
|
if (iter().isDict())
|
||||||
{
|
{
|
||||||
@ -208,11 +196,9 @@ void Foam::Time::readDict()
|
|||||||
&& localDict->size()
|
&& localDict->size()
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (echo)
|
DetailInfo
|
||||||
{
|
<< "Overriding OptimisationSwitches according to "
|
||||||
Info<< "Overriding OptimisationSwitches according to "
|
|
||||||
<< controlDict_.name() << nl;
|
<< controlDict_.name() << nl;
|
||||||
}
|
|
||||||
|
|
||||||
simpleObjectRegistry& objs = debug::optimisationObjects();
|
simpleObjectRegistry& objs = debug::optimisationObjects();
|
||||||
|
|
||||||
@ -224,10 +210,7 @@ void Foam::Time::readDict()
|
|||||||
|
|
||||||
if (objPtr)
|
if (objPtr)
|
||||||
{
|
{
|
||||||
if (echo)
|
DetailInfo << " " << iter() << nl;
|
||||||
{
|
|
||||||
Info<< " " << iter() << nl;
|
|
||||||
}
|
|
||||||
|
|
||||||
const List<simpleRegIOobject*>& objects = *objPtr;
|
const List<simpleRegIOobject*>& objects = *objPtr;
|
||||||
|
|
||||||
@ -263,10 +246,7 @@ void Foam::Time::readDict()
|
|||||||
&& fileHandler().type() != fileHandlerName
|
&& fileHandler().type() != fileHandlerName
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (echo)
|
DetailInfo << "Overriding fileHandler to " << fileHandlerName << nl;
|
||||||
{
|
|
||||||
Info<< "Overriding fileHandler to " << fileHandlerName << nl;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Remove old watches since destroying the file
|
// Remove old watches since destroying the file
|
||||||
fileNameList oldWatched(controlDict_.watchIndices().size());
|
fileNameList oldWatched(controlDict_.watchIndices().size());
|
||||||
@ -304,11 +284,9 @@ void Foam::Time::readDict()
|
|||||||
&& localDict->size()
|
&& localDict->size()
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (echo)
|
DetailInfo
|
||||||
{
|
<< "Overriding DimensionedConstants according to "
|
||||||
Info<< "Overriding DimensionedConstants according to "
|
|
||||||
<< controlDict_.name() << nl;
|
<< controlDict_.name() << nl;
|
||||||
}
|
|
||||||
|
|
||||||
simpleObjectRegistry& objs = debug::dimensionedConstantObjects();
|
simpleObjectRegistry& objs = debug::dimensionedConstantObjects();
|
||||||
|
|
||||||
@ -325,7 +303,7 @@ void Foam::Time::readDict()
|
|||||||
{
|
{
|
||||||
obj->readData(dummyIs);
|
obj->readData(dummyIs);
|
||||||
|
|
||||||
if (echo)
|
if (Foam::infoDetailLevel > 0)
|
||||||
{
|
{
|
||||||
Info<< " ";
|
Info<< " ";
|
||||||
obj->writeData(Info);
|
obj->writeData(Info);
|
||||||
@ -343,11 +321,9 @@ void Foam::Time::readDict()
|
|||||||
&& localDict->size()
|
&& localDict->size()
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (echo)
|
DetailInfo
|
||||||
{
|
<< "Overriding DimensionSets according to "
|
||||||
Info<< "Overriding DimensionSets according to "
|
|
||||||
<< controlDict_.name() << nl;
|
<< controlDict_.name() << nl;
|
||||||
}
|
|
||||||
|
|
||||||
simpleObjectRegistry& objs = debug::dimensionSetObjects();
|
simpleObjectRegistry& objs = debug::dimensionSetObjects();
|
||||||
|
|
||||||
@ -358,10 +334,7 @@ void Foam::Time::readDict()
|
|||||||
|
|
||||||
if (objPtr)
|
if (objPtr)
|
||||||
{
|
{
|
||||||
if (echo)
|
DetailInfo << *localDict << nl;
|
||||||
{
|
|
||||||
Info<< *localDict << nl;
|
|
||||||
}
|
|
||||||
|
|
||||||
const List<simpleRegIOobject*>& objects = *objPtr;
|
const List<simpleRegIOobject*>& objects = *objPtr;
|
||||||
|
|
||||||
|
|||||||
@ -3,7 +3,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) 2011-2013 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -66,7 +66,8 @@ bool Foam::functionEntries::calcEntry::execute
|
|||||||
Istream& is
|
Istream& is
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
Info<< "Using #calc at line " << is.lineNumber()
|
DetailInfo
|
||||||
|
<< "Using #calc at line " << is.lineNumber()
|
||||||
<< " in file " << parentDict.name() << endl;
|
<< " in file " << parentDict.name() << endl;
|
||||||
|
|
||||||
dynamicCode::checkSecurity
|
dynamicCode::checkSecurity
|
||||||
@ -110,7 +111,8 @@ bool Foam::functionEntries::calcEntry::execute
|
|||||||
Istream& is
|
Istream& is
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
Info<< "Using #calc at line " << is.lineNumber()
|
DetailInfo
|
||||||
|
<< "Using #calc at line " << is.lineNumber()
|
||||||
<< " in file " << parentDict.name() << endl;
|
<< " in file " << parentDict.name() << endl;
|
||||||
|
|
||||||
dynamicCode::checkSecurity
|
dynamicCode::checkSecurity
|
||||||
|
|||||||
@ -3,7 +3,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) 2011-2017 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -147,7 +147,8 @@ Foam::functionEntries::codeStream::getFunction
|
|||||||
|
|
||||||
if (!lib)
|
if (!lib)
|
||||||
{
|
{
|
||||||
Info<< "Using #codeStream with " << libPath << endl;
|
DetailInfo
|
||||||
|
<< "Using #codeStream with " << libPath << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -372,7 +373,8 @@ bool Foam::functionEntries::codeStream::execute
|
|||||||
Istream& is
|
Istream& is
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
Info<< "Using #codeStream at line " << is.lineNumber()
|
DetailInfo
|
||||||
|
<< "Using #codeStream at line " << is.lineNumber()
|
||||||
<< " in file " << parentDict.name() << endl;
|
<< " in file " << parentDict.name() << endl;
|
||||||
|
|
||||||
dynamicCode::checkSecurity
|
dynamicCode::checkSecurity
|
||||||
@ -405,7 +407,8 @@ bool Foam::functionEntries::codeStream::execute
|
|||||||
Istream& is
|
Istream& is
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
Info<< "Using #codeStream at line " << is.lineNumber()
|
DetailInfo
|
||||||
|
<< "Using #codeStream at line " << is.lineNumber()
|
||||||
<< " in file " << parentDict.name() << endl;
|
<< " in file " << parentDict.name() << endl;
|
||||||
|
|
||||||
dynamicCode::checkSecurity
|
dynamicCode::checkSecurity
|
||||||
|
|||||||
@ -141,7 +141,7 @@ bool Foam::functionEntries::includeEntry::execute
|
|||||||
{
|
{
|
||||||
if (Foam::functionEntries::includeEntry::log)
|
if (Foam::functionEntries::includeEntry::log)
|
||||||
{
|
{
|
||||||
Info<< fName << endl;
|
DetailInfo << fName << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add watch on included file
|
// Add watch on included file
|
||||||
@ -188,7 +188,7 @@ bool Foam::functionEntries::includeEntry::execute
|
|||||||
{
|
{
|
||||||
if (Foam::functionEntries::includeEntry::log)
|
if (Foam::functionEntries::includeEntry::log)
|
||||||
{
|
{
|
||||||
Info<< fName << endl;
|
DetailInfo << fName << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add watch on included file
|
// Add watch on included file
|
||||||
@ -234,7 +234,7 @@ bool Foam::functionEntries::sincludeEntry::execute
|
|||||||
{
|
{
|
||||||
if (Foam::functionEntries::includeEntry::log)
|
if (Foam::functionEntries::includeEntry::log)
|
||||||
{
|
{
|
||||||
Info<< fName << endl;
|
DetailInfo << fName << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add watch on included file
|
// Add watch on included file
|
||||||
@ -272,7 +272,7 @@ bool Foam::functionEntries::sincludeEntry::execute
|
|||||||
{
|
{
|
||||||
if (Foam::functionEntries::includeEntry::log)
|
if (Foam::functionEntries::includeEntry::log)
|
||||||
{
|
{
|
||||||
Info<< fName << endl;
|
DetailInfo << fName << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add watch on included file
|
// Add watch on included file
|
||||||
|
|||||||
@ -102,7 +102,7 @@ bool Foam::functionEntries::includeEtcEntry::execute
|
|||||||
{
|
{
|
||||||
if (Foam::functionEntries::includeEtcEntry::log)
|
if (Foam::functionEntries::includeEtcEntry::log)
|
||||||
{
|
{
|
||||||
Info<< fName << endl;
|
DetailInfo << fName << endl;
|
||||||
}
|
}
|
||||||
parentDict.read(ifs);
|
parentDict.read(ifs);
|
||||||
return true;
|
return true;
|
||||||
@ -137,7 +137,7 @@ bool Foam::functionEntries::includeEtcEntry::execute
|
|||||||
{
|
{
|
||||||
if (Foam::functionEntries::includeEtcEntry::log)
|
if (Foam::functionEntries::includeEtcEntry::log)
|
||||||
{
|
{
|
||||||
Info<< fName << endl;
|
DetailInfo << fName << endl;
|
||||||
}
|
}
|
||||||
entry.read(parentDict, ifs);
|
entry.read(parentDict, ifs);
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@ -3,7 +3,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) 2011-2016 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
\\/ M anipulation | Copyright (C) 2016-2018 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -350,7 +350,8 @@ void Foam::codedBase::updateLibrary
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Info<< "Using dynamicCode for " << this->description().c_str()
|
DetailInfo
|
||||||
|
<< "Using dynamicCode for " << this->description().c_str()
|
||||||
<< " at line " << dict.startLineNumber()
|
<< " at line " << dict.startLineNumber()
|
||||||
<< " in " << dict.name() << endl;
|
<< " in " << dict.name() << endl;
|
||||||
|
|
||||||
|
|||||||
@ -3,7 +3,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) 2011-2016 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
\\/ M anipulation | Copyright (C) 2016-2018 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -27,6 +27,7 @@ License
|
|||||||
#include "dynamicCodeContext.H"
|
#include "dynamicCodeContext.H"
|
||||||
#include "stringOps.H"
|
#include "stringOps.H"
|
||||||
#include "Fstream.H"
|
#include "Fstream.H"
|
||||||
|
#include "IOstreams.H"
|
||||||
#include "OSspecific.H"
|
#include "OSspecific.H"
|
||||||
#include "etcFiles.H"
|
#include "etcFiles.H"
|
||||||
#include "dictionary.H"
|
#include "dictionary.H"
|
||||||
@ -210,7 +211,7 @@ bool Foam::dynamicCode::createMakeFiles() const
|
|||||||
mkDir(dstFile.path());
|
mkDir(dstFile.path());
|
||||||
|
|
||||||
OFstream os(dstFile);
|
OFstream os(dstFile);
|
||||||
//Info<< "Writing to " << dstFile << endl;
|
//Debug: Info << "Writing to " << dstFile << endl;
|
||||||
if (!os.good())
|
if (!os.good())
|
||||||
{
|
{
|
||||||
FatalErrorInFunction
|
FatalErrorInFunction
|
||||||
@ -247,7 +248,7 @@ bool Foam::dynamicCode::createMakeOptions() const
|
|||||||
mkDir(dstFile.path());
|
mkDir(dstFile.path());
|
||||||
|
|
||||||
OFstream os(dstFile);
|
OFstream os(dstFile);
|
||||||
//Info<< "Writing to " << dstFile << endl;
|
//Debug: Info<< "Writing to " << dstFile << endl;
|
||||||
if (!os.good())
|
if (!os.good())
|
||||||
{
|
{
|
||||||
FatalErrorInFunction
|
FatalErrorInFunction
|
||||||
@ -403,7 +404,8 @@ bool Foam::dynamicCode::copyOrCreateFiles(const bool verbose) const
|
|||||||
{
|
{
|
||||||
if (verbose)
|
if (verbose)
|
||||||
{
|
{
|
||||||
Info<< "Creating new library in " << this->libRelPath() << endl;
|
DetailInfo
|
||||||
|
<< "Creating new library in " << this->libRelPath() << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
const label nFiles = compileFiles_.size() + copyFiles_.size();
|
const label nFiles = compileFiles_.size() + copyFiles_.size();
|
||||||
@ -441,7 +443,7 @@ bool Foam::dynamicCode::copyOrCreateFiles(const bool verbose) const
|
|||||||
const fileName dstFile(outputDir/srcFile.name());
|
const fileName dstFile(outputDir/srcFile.name());
|
||||||
|
|
||||||
IFstream is(srcFile);
|
IFstream is(srcFile);
|
||||||
//Info<< "Reading from " << is.name() << endl;
|
//Debug: Info<< "Reading from " << is.name() << endl;
|
||||||
if (!is.good())
|
if (!is.good())
|
||||||
{
|
{
|
||||||
FatalErrorInFunction
|
FatalErrorInFunction
|
||||||
@ -450,7 +452,7 @@ bool Foam::dynamicCode::copyOrCreateFiles(const bool verbose) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
OFstream os(dstFile);
|
OFstream os(dstFile);
|
||||||
//Info<< "Writing to " << dstFile.name() << endl;
|
//Debug: Info<< "Writing to " << dstFile.name() << endl;
|
||||||
if (!os.good())
|
if (!os.good())
|
||||||
{
|
{
|
||||||
FatalErrorInFunction
|
FatalErrorInFunction
|
||||||
@ -473,7 +475,7 @@ bool Foam::dynamicCode::copyOrCreateFiles(const bool verbose) const
|
|||||||
|
|
||||||
mkDir(dstFile.path());
|
mkDir(dstFile.path());
|
||||||
OFstream os(dstFile);
|
OFstream os(dstFile);
|
||||||
//Info<< "Writing to " << createFiles_[fileI].first() << endl;
|
//Debug: Info<< "Writing to " << createFiles_[fileI].first() << endl;
|
||||||
if (!os.good())
|
if (!os.good())
|
||||||
{
|
{
|
||||||
FatalErrorInFunction
|
FatalErrorInFunction
|
||||||
@ -501,15 +503,25 @@ bool Foam::dynamicCode::wmakeLibso() const
|
|||||||
// NOTE: could also resolve wmake command explicitly
|
// NOTE: could also resolve wmake command explicitly
|
||||||
// cmd[0] = stringOps::expand("$WM_PROJECT_DIR/wmake/wmake");
|
// cmd[0] = stringOps::expand("$WM_PROJECT_DIR/wmake/wmake");
|
||||||
|
|
||||||
Info<< "Invoking wmake libso " << this->codePath().c_str() << endl;
|
// This can take a bit longer, so report that we are starting wmake
|
||||||
if (Foam::system(cmd))
|
|
||||||
|
if (Foam::infoDetailLevel > 0)
|
||||||
{
|
{
|
||||||
return false;
|
Info<< "Invoking wmake libso " << this->codePath().c_str() << endl;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
// Even with details turned off, we want some feedback
|
||||||
|
Serr
|
||||||
|
<< "Invoking wmake libso " << this->codePath().c_str() << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Foam::system(cmd) == 0)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -55,7 +55,7 @@ SourceFiles
|
|||||||
namespace Foam
|
namespace Foam
|
||||||
{
|
{
|
||||||
|
|
||||||
// Forward declaration of friend functions and operators
|
// Forward declarations
|
||||||
class error;
|
class error;
|
||||||
Ostream& operator<<(Ostream& os, const error& err);
|
Ostream& operator<<(Ostream& os, const error& err);
|
||||||
|
|
||||||
@ -215,7 +215,7 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// Forward declaration of friend functions and operators
|
// Forward declarations
|
||||||
class IOerror;
|
class IOerror;
|
||||||
Ostream& operator<<(Ostream& os, const IOerror& err);
|
Ostream& operator<<(Ostream& os, const IOerror& err);
|
||||||
|
|
||||||
@ -334,9 +334,15 @@ public:
|
|||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
// Global error declarations: defined in error.C
|
// Global error declarations: defined in error.C
|
||||||
|
|
||||||
|
//- Error stream (uses stdout - output on all processes),
|
||||||
|
//- with additional 'FOAM FATAL ERROR' header text and stack trace.
|
||||||
extern error FatalError;
|
extern error FatalError;
|
||||||
|
|
||||||
|
//- Error stream (uses stdout - output on all processes),
|
||||||
|
//- with additional 'FOAM FATAL IO ERROR' header text and stack trace.
|
||||||
extern IOerror FatalIOError;
|
extern IOerror FatalIOError;
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
} // End namespace Foam
|
} // End namespace Foam
|
||||||
|
|||||||
@ -31,10 +31,16 @@ Description
|
|||||||
|
|
||||||
Usage
|
Usage
|
||||||
\code
|
\code
|
||||||
error << "message1" << "message2" << FoamDataType << exit(error, errNo);
|
error << "message " << someType << abort(error);
|
||||||
error << "message1" << "message2" << FoamDataType << abort(error);
|
error << "message " << someType << exit(error, errNo);
|
||||||
\endcode
|
\endcode
|
||||||
|
|
||||||
|
Class
|
||||||
|
Foam::errorManipArg
|
||||||
|
|
||||||
|
Description
|
||||||
|
Error stream manipulators for functions with an argument.
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#ifndef errorManip_H
|
#ifndef errorManip_H
|
||||||
@ -47,7 +53,7 @@ Usage
|
|||||||
namespace Foam
|
namespace Foam
|
||||||
{
|
{
|
||||||
|
|
||||||
// Forward declaration of friend functions and operators
|
// Forward declarations
|
||||||
template<class Err> class errorManip;
|
template<class Err> class errorManip;
|
||||||
template<class Err> Ostream& operator<<(Ostream&, errorManip<Err>);
|
template<class Err> Ostream& operator<<(Ostream&, errorManip<Err>);
|
||||||
|
|
||||||
@ -90,7 +96,6 @@ inline Ostream& operator<<(Ostream& os, errorManip<Err> m)
|
|||||||
Class errorManipArg Declaration
|
Class errorManipArg Declaration
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
//- errorManipArg
|
|
||||||
template<class Err, class T>
|
template<class Err, class T>
|
||||||
class errorManipArg
|
class errorManipArg
|
||||||
{
|
{
|
||||||
|
|||||||
@ -29,8 +29,12 @@ License
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
// Default is 2 : report source file name and line number if available
|
||||||
int Foam::messageStream::level(Foam::debug::debugSwitch("level", 2));
|
int Foam::messageStream::level(Foam::debug::debugSwitch("level", 2));
|
||||||
|
|
||||||
|
// Default is 1 : report to Info
|
||||||
|
int Foam::infoDetailLevel(1);
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
@ -72,11 +76,9 @@ Foam::OSstream& Foam::messageStream::masterStream(const label communicator)
|
|||||||
{
|
{
|
||||||
return operator()();
|
return operator()();
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
return Snull;
|
return Snull;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||||
@ -217,7 +219,7 @@ Foam::messageStream::operator Foam::OSstream&()
|
|||||||
|
|
||||||
if (maxErrors_)
|
if (maxErrors_)
|
||||||
{
|
{
|
||||||
errorCount_++;
|
++errorCount_;
|
||||||
|
|
||||||
if (errorCount_ >= maxErrors_)
|
if (errorCount_ >= maxErrors_)
|
||||||
{
|
{
|
||||||
@ -244,12 +246,7 @@ Foam::messageStream::operator Foam::OSstream&()
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * Global Variables * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Global Variables * * * * * * * * * * * * * //
|
||||||
|
|
||||||
Foam::messageStream Foam::SeriousError
|
Foam::messageStream Foam::Info("", messageStream::INFO);
|
||||||
(
|
|
||||||
"--> FOAM Serious Error : ",
|
|
||||||
messageStream::SERIOUS,
|
|
||||||
100
|
|
||||||
);
|
|
||||||
|
|
||||||
Foam::messageStream Foam::Warning
|
Foam::messageStream Foam::Warning
|
||||||
(
|
(
|
||||||
@ -257,7 +254,12 @@ Foam::messageStream Foam::Warning
|
|||||||
messageStream::WARNING
|
messageStream::WARNING
|
||||||
);
|
);
|
||||||
|
|
||||||
Foam::messageStream Foam::Info("", messageStream::INFO);
|
Foam::messageStream Foam::SeriousError
|
||||||
|
(
|
||||||
|
"--> FOAM Serious Error : ",
|
||||||
|
messageStream::SERIOUS,
|
||||||
|
100
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|||||||
@ -3,7 +3,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) 2011-2016 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
\\/ M anipulation | Copyright (C) 2016-2018 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -28,9 +28,9 @@ Description
|
|||||||
Class to handle messaging in a simple, consistent stream-based
|
Class to handle messaging in a simple, consistent stream-based
|
||||||
manner.
|
manner.
|
||||||
|
|
||||||
The messageStream class is globaly instantiated with a title string and
|
The messageStream class is globally instantiated with a title string and
|
||||||
a severity (which controls the program termination) and a number of
|
a severity (which controls the program termination) and a number of
|
||||||
errors before termination. Errors, messages and other data are piped to
|
errors before termination. Errors, messages and other data are sent to
|
||||||
the messageStream class in the standard manner.
|
the messageStream class in the standard manner.
|
||||||
|
|
||||||
Usage
|
Usage
|
||||||
@ -55,7 +55,7 @@ SourceFiles
|
|||||||
namespace Foam
|
namespace Foam
|
||||||
{
|
{
|
||||||
|
|
||||||
// Forward declaration of classes
|
// Forward declarations
|
||||||
class IOstream;
|
class IOstream;
|
||||||
class Ostream;
|
class Ostream;
|
||||||
class OSstream;
|
class OSstream;
|
||||||
@ -71,13 +71,13 @@ class messageStream
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
//- Severity flags
|
//- Message type, or error severity flags
|
||||||
enum errorSeverity
|
enum errorSeverity
|
||||||
{
|
{
|
||||||
INFO, // Debugging information in event of error
|
INFO, //!< General information output, not necessarily an error.
|
||||||
WARNING, // Warning of possible problem
|
WARNING, //!< Warning of possible problem.
|
||||||
SERIOUS, // A serious problem (data corruption?)
|
SERIOUS, //!< A serious problem - eg, data corruption.
|
||||||
FATAL // Oh bugger!
|
FATAL //!< A fatal error.
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -93,8 +93,15 @@ protected:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// Debug switches
|
// Static data
|
||||||
|
|
||||||
|
//- Controls the output verbosity of messageStream
|
||||||
|
//
|
||||||
|
// - level == 0 : suppress all output
|
||||||
|
// - level == 1 : normal output
|
||||||
|
// - level >= 2 : report source file name and line number if available
|
||||||
|
//
|
||||||
|
// \note The default level is normally 2.
|
||||||
static int level;
|
static int level;
|
||||||
|
|
||||||
|
|
||||||
@ -203,10 +210,31 @@ public:
|
|||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
// Global error declarations: defined in messageStream.C
|
// Global error declarations: defined in messageStream.C
|
||||||
|
|
||||||
extern messageStream SeriousError;
|
//- Global for selective suppression of Info output.
|
||||||
extern messageStream Warning;
|
// This is normally accessed implicitly via the DetailInfo macro and is often
|
||||||
|
// associated applications with suppressed banners. For example,
|
||||||
|
//
|
||||||
|
// \code
|
||||||
|
// DetailInfo << "Hello, I'm running from program xyz" << nl;
|
||||||
|
// Info<< "Found ... invalid items" << nl;
|
||||||
|
// \endcode
|
||||||
|
//
|
||||||
|
// The values are normally 0 or a positive value.
|
||||||
|
// \note This flag is initialized to 1 by default.
|
||||||
|
extern int infoDetailLevel;
|
||||||
|
|
||||||
|
//- Information stream (uses stdout - output is on the master only)
|
||||||
extern messageStream Info;
|
extern messageStream Info;
|
||||||
|
|
||||||
|
//- Warning stream (uses stdout - output is on the master only),
|
||||||
|
//- with additional 'FOAM Warning' header text.
|
||||||
|
extern messageStream Warning;
|
||||||
|
|
||||||
|
//- Error stream (uses stdout - output on all processes),
|
||||||
|
//- with additional 'FOAM Serious Error' header text.
|
||||||
|
extern messageStream SeriousError;
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
} // End namespace Foam
|
} // End namespace Foam
|
||||||
@ -290,6 +318,10 @@ extern messageStream Info;
|
|||||||
// for FUNCTION_NAME in file __FILE__ at line __LINE__
|
// for FUNCTION_NAME in file __FILE__ at line __LINE__
|
||||||
#define PoutInFunction PoutIn(FUNCTION_NAME)
|
#define PoutInFunction PoutIn(FUNCTION_NAME)
|
||||||
|
|
||||||
|
//- Write to Foam::Info if the Foam::infoDetailLevel is +ve non-zero (default)
|
||||||
|
#define DetailInfo \
|
||||||
|
if (::Foam::infoDetailLevel > 0) Info
|
||||||
|
|
||||||
//- Report write to Foam::Info if the local log switch is true
|
//- Report write to Foam::Info if the local log switch is true
|
||||||
#define Log \
|
#define Log \
|
||||||
if (log) Info
|
if (log) Info
|
||||||
|
|||||||
@ -50,7 +50,6 @@ License
|
|||||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
bool Foam::argList::argsMandatory_ = true;
|
bool Foam::argList::argsMandatory_ = true;
|
||||||
bool Foam::argList::bannerEnabled_ = true;
|
|
||||||
bool Foam::argList::checkProcessorDirectories_ = true;
|
bool Foam::argList::checkProcessorDirectories_ = true;
|
||||||
Foam::SLList<Foam::string> Foam::argList::validArgs;
|
Foam::SLList<Foam::string> Foam::argList::validArgs;
|
||||||
Foam::HashTable<Foam::string> Foam::argList::validOptions;
|
Foam::HashTable<Foam::string> Foam::argList::validOptions;
|
||||||
@ -295,13 +294,13 @@ void Foam::argList::nonMandatoryArgs()
|
|||||||
|
|
||||||
void Foam::argList::noBanner()
|
void Foam::argList::noBanner()
|
||||||
{
|
{
|
||||||
bannerEnabled_ = false;
|
::Foam::infoDetailLevel = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Foam::argList::bannerEnabled()
|
bool Foam::argList::bannerEnabled()
|
||||||
{
|
{
|
||||||
return bannerEnabled_;
|
return (::Foam::infoDetailLevel > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -914,7 +913,7 @@ void Foam::argList::parse
|
|||||||
const string timeString = clock::clockTime();
|
const string timeString = clock::clockTime();
|
||||||
|
|
||||||
// Print the banner once only for parallel runs
|
// Print the banner once only for parallel runs
|
||||||
if (Pstream::master() && bannerEnabled_)
|
if (Pstream::master() && bannerEnabled())
|
||||||
{
|
{
|
||||||
IOobject::writeBanner(Info, true)
|
IOobject::writeBanner(Info, true)
|
||||||
<< "Build : " << Foam::FOAMbuild << nl
|
<< "Build : " << Foam::FOAMbuild << nl
|
||||||
@ -972,7 +971,7 @@ void Foam::argList::parse
|
|||||||
fileOperation::New
|
fileOperation::New
|
||||||
(
|
(
|
||||||
handlerType,
|
handlerType,
|
||||||
bannerEnabled_
|
bannerEnabled()
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
Foam::fileHandler(handler);
|
Foam::fileHandler(handler);
|
||||||
@ -1320,7 +1319,7 @@ void Foam::argList::parse
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Pstream::master() && bannerEnabled_)
|
if (Pstream::master() && bannerEnabled())
|
||||||
{
|
{
|
||||||
Info<< "Case : " << (rootPath_/globalCase_).c_str() << nl
|
Info<< "Case : " << (rootPath_/globalCase_).c_str() << nl
|
||||||
<< "nProcs : " << nProcs << endl;
|
<< "nProcs : " << nProcs << endl;
|
||||||
@ -1371,12 +1370,12 @@ void Foam::argList::parse
|
|||||||
|
|
||||||
// Switch on signal trapping. We have to wait until after Pstream::init
|
// Switch on signal trapping. We have to wait until after Pstream::init
|
||||||
// since this sets up its own ones.
|
// since this sets up its own ones.
|
||||||
sigFpe::set(bannerEnabled_);
|
sigFpe::set(bannerEnabled());
|
||||||
sigInt::set(bannerEnabled_);
|
sigInt::set(bannerEnabled());
|
||||||
sigQuit::set(bannerEnabled_);
|
sigQuit::set(bannerEnabled());
|
||||||
sigSegv::set(bannerEnabled_);
|
sigSegv::set(bannerEnabled());
|
||||||
|
|
||||||
if (Pstream::master() && bannerEnabled_)
|
if (Pstream::master() && bannerEnabled())
|
||||||
{
|
{
|
||||||
Info<< "fileModificationChecking : "
|
Info<< "fileModificationChecking : "
|
||||||
<< "Monitoring run-time modified files using "
|
<< "Monitoring run-time modified files using "
|
||||||
|
|||||||
@ -121,9 +121,6 @@ class argList
|
|||||||
//- Track enabled/disabled mandatory arguments
|
//- Track enabled/disabled mandatory arguments
|
||||||
static bool argsMandatory_;
|
static bool argsMandatory_;
|
||||||
|
|
||||||
//- Track enabled/disabled banner state
|
|
||||||
static bool bannerEnabled_;
|
|
||||||
|
|
||||||
//- Track enabled/disabled checking of processor directories state
|
//- Track enabled/disabled checking of processor directories state
|
||||||
static bool checkProcessorDirectories_;
|
static bool checkProcessorDirectories_;
|
||||||
|
|
||||||
@ -494,10 +491,12 @@ public:
|
|||||||
//- Flag command arguments as being non-mandatory
|
//- Flag command arguments as being non-mandatory
|
||||||
static void nonMandatoryArgs();
|
static void nonMandatoryArgs();
|
||||||
|
|
||||||
//- Disable emitting the banner information
|
//- Disable emitting the banner information.
|
||||||
|
// Adjusts the Foam::infoDetailLevel flag.
|
||||||
static void noBanner();
|
static void noBanner();
|
||||||
|
|
||||||
//- Banner status (enabled/disabled)
|
//- Banner status (enabled/disabled).
|
||||||
|
// Queries the Foam::infoDetailLevel flag.
|
||||||
static bool bannerEnabled();
|
static bool bannerEnabled();
|
||||||
|
|
||||||
//- Remove the 'noFunctionObjects' option,
|
//- Remove the 'noFunctionObjects' option,
|
||||||
|
|||||||
@ -244,10 +244,7 @@ Foam::profiling::profiling
|
|||||||
Information *info = this->create(Zero);
|
Information *info = this->create(Zero);
|
||||||
this->beginTimer(info);
|
this->beginTimer(info);
|
||||||
|
|
||||||
if (argList::bannerEnabled())
|
DetailInfo << "profiling initialized" << nl;
|
||||||
{
|
|
||||||
Info<< "profiling initialized" << nl;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -283,10 +280,7 @@ Foam::profiling::profiling
|
|||||||
Information *info = this->create(Zero);
|
Information *info = this->create(Zero);
|
||||||
this->beginTimer(info);
|
this->beginTimer(info);
|
||||||
|
|
||||||
if (argList::bannerEnabled())
|
DetailInfo << "profiling initialized" << nl;
|
||||||
{
|
|
||||||
Info<< "profiling initialized" << nl;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -3,7 +3,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) 2011-2017 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||||
\\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd.
|
\\/ M anipulation | Copyright (C) 2016-2018 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -83,7 +83,7 @@ string domainName();
|
|||||||
//- Return the user's login name
|
//- Return the user's login name
|
||||||
string userName();
|
string userName();
|
||||||
|
|
||||||
//- Is user administrator
|
//- Is the current user the administrator (root)
|
||||||
bool isAdministrator();
|
bool isAdministrator();
|
||||||
|
|
||||||
//- Return home directory path name for the current user
|
//- Return home directory path name for the current user
|
||||||
@ -208,34 +208,39 @@ bool ping(const std::string& host, const label timeOut=10);
|
|||||||
|
|
||||||
//- Execute the specified command via the shell.
|
//- Execute the specified command via the shell.
|
||||||
// Uses vfork/execl internally.
|
// Uses vfork/execl internally.
|
||||||
|
// When Foam::infoDetailLevel is zero, redirects stdout to stderr.
|
||||||
|
//
|
||||||
// Where possible, use the list version instead.
|
// Where possible, use the list version instead.
|
||||||
//
|
//
|
||||||
// \param background return immediately to parent process instead of waiting
|
// \param bg return immediately to parent process instead of waiting
|
||||||
// for the child. Can be used (with moderation) to create background
|
// for the child. Can be used (with moderation) to create background
|
||||||
// processes.
|
// processes.
|
||||||
//
|
//
|
||||||
// \note treats an empty command as a successful no-op.
|
// \note treats an empty command as a successful no-op.
|
||||||
int system(const std::string& command, const bool background=false);
|
// When Foam::infoDetailLevel is zero, redirects stdout to stderr.
|
||||||
|
int system(const std::string& command, const bool bg = false);
|
||||||
|
|
||||||
//- Execute the specified command with arguments.
|
//- Execute the specified command with arguments.
|
||||||
// Uses vfork/execvp internally
|
// Uses vfork/execvp internally
|
||||||
|
// When Foam::infoDetailLevel is zero, redirects stdout to stderr.
|
||||||
//
|
//
|
||||||
// \param background return immediately to parent process instead of waiting
|
// \param bg return immediately to parent process instead of waiting
|
||||||
// for the child. Can be used (with moderation) to create background
|
// for the child. Can be used (with moderation) to create background
|
||||||
// processes.
|
// processes.
|
||||||
//
|
//
|
||||||
// \note treats an empty command as a successful no-op.
|
// \note treats an empty command as a successful no-op.
|
||||||
int system(const UList<string>& command, const bool background=false);
|
int system(const UList<string>& command, const bool bg = false);
|
||||||
|
|
||||||
//- Execute the specified command with arguments.
|
//- Execute the specified command with arguments.
|
||||||
// Uses vfork/execvp internally
|
// Uses vfork/execvp internally
|
||||||
|
// When Foam::infoDetailLevel is zero, redirects stdout to stderr.
|
||||||
//
|
//
|
||||||
// \param background return immediately to parent process instead of waiting
|
// \param bg return immediately to parent process instead of waiting
|
||||||
// for the child. Can be used (with moderation) to create background
|
// for the child. Can be used (with moderation) to create background
|
||||||
// processes.
|
// processes.
|
||||||
//
|
//
|
||||||
// \note treats an empty command as a successful no-op.
|
// \note treats an empty command as a successful no-op.
|
||||||
int system(const CStringList& command, const bool background=false);
|
int system(const CStringList& command, const bool bg = false);
|
||||||
|
|
||||||
//- Open a shared library and return handle to library.
|
//- Open a shared library and return handle to library.
|
||||||
// Print error message if library cannot be loaded (suppress with check=true)
|
// Print error message if library cannot be loaded (suppress with check=true)
|
||||||
|
|||||||
Reference in New Issue
Block a user