Go to the documentation of this file.
40 namespace functionEntries
58 primitiveEntryIstream,
82 bool masterOnly = regIOobject::masterOnlyReading;
84 const auto* iodictPtr = isA<baseIOdictionary>(
dict.topDict());
88 masterOnly = iodictPtr->globalObject();
91 <<
"codeStream : baseIOdictionary:" <<
dict.name()
92 <<
" master-only-reading:" << masterOnly <<
endl;
97 <<
"codeStream : not a baseIOdictionary:" <<
dict.name()
98 <<
" master-only-reading:" << masterOnly <<
endl;
117 std::string sha1Str(context.
sha1().
str(
true));
118 dynamicCode dynCode(
"codeStream" + sha1Str, sha1Str);
122 const fileName libPath = dynCode.libPath();
129 if (isA<baseIOdictionary>(topDict))
131 lib = libs(parentDict).findLibrary(libPath);
139 <<
"Using #codeStream with " << libPath <<
endl;
141 if (isA<baseIOdictionary>(topDict))
144 lib = libs(parentDict).open(libPath,
false);
159 || (IOobject::fileModificationSkew <= 0);
163 if (!dynCode.upToDate(context))
166 dynCode.
reset(context);
169 dynCode.addCompileFile(codeTemplateC);
172 dynCode.setMakeOptions
176 +
"\n\nLIB_LIBS = \\\n"
181 if (!dynCode.copyOrCreateFiles(
true))
184 <<
"Failed writing files for" <<
nl
185 << dynCode.libRelPath() <<
nl
190 if (!dynCode.wmakeLibso())
193 <<
"Failed wmake " << dynCode.libRelPath() <<
nl
202 !doingMasterOnlyReading(topDict)
203 && IOobject::fileModificationSkew > 0
212 off_t masterSize = mySize;
213 Pstream::scatter(masterSize);
218 iter < IOobject::maxFileModificationPolls;
223 <<
"on processor " << Pstream::myProcNo()
224 <<
"masterSize:" << masterSize
225 <<
" and localSize:" << mySize
228 if (mySize == masterSize)
232 else if (mySize > masterSize)
235 <<
"Excessive size when reading (NFS mounted) library "
236 <<
nl << libPath <<
nl
237 <<
"on processor " << Pstream::myProcNo()
238 <<
" detected size " << mySize
239 <<
" whereas master size is " << masterSize
241 <<
"If your case is NFS mounted increase"
242 <<
" fileModificationSkew or maxFileModificationPolls;"
243 <<
nl <<
"If your case is not NFS mounted"
244 <<
" (so distributed) set fileModificationSkew"
251 <<
"Local file " << libPath
252 <<
" not of same size (" << mySize
254 << masterSize <<
"). Waiting for "
255 << IOobject::fileModificationSkew
256 <<
" seconds." <<
endl;
267 if (mySize != masterSize)
270 <<
"Cannot read (NFS mounted) library " <<
nl
272 <<
"on processor " << Pstream::myProcNo()
273 <<
" detected size " << mySize
274 <<
" whereas master size is " << masterSize
276 <<
"If your case is NFS mounted increase"
277 <<
" fileModificationSkew or maxFileModificationPolls;"
278 <<
nl <<
"If your case is not NFS mounted"
279 <<
" (so distributed) set fileModificationSkew"
285 <<
"on processor " << Pstream::myProcNo()
286 <<
" after waiting: have masterSize:" << masterSize
287 <<
" and localSize:" << mySize <<
endl;
290 if (isA<baseIOdictionary>(topDict))
294 <<
"Opening cached dictionary:" << libPath <<
endl;
296 lib = libs(parentDict).open(libPath,
false);
301 <<
"Failed loading library " << libPath <<
nl
302 <<
"Did you add all libraries to the 'libs' entry"
303 <<
" in system/controlDict?"
311 <<
"Opening uncached dictionary:" << libPath <<
endl;
318 if (!doingMasterOnlyReading(topDict))
326 <<
"Failed loading library " << libPath
327 <<
" on some processors."
333 streamingFunctionType
function =
334 reinterpret_cast<streamingFunctionType
>
343 <<
"Failed looking up symbol " << dynCode.codeName()
358 <<
"Using #codeStream at line " << is.
lineNumber()
361 dynamicCode::checkSecurity
363 "functionEntries::codeStream::evaluate(..)",
368 dictionary codeDict(
"#codeStream", parentDict, is);
373 streamingFunctionType
function = getFunction(parentDict, codeDict);
374 (*function)(
os, parentDict);
391 entry.read(parentDict, result);
404 parentDict.
read(result);
A keyword and a list of tokens is an 'entry'.
void reset()
Clear all bits but do not adjust the addressable size.
bitSet create(const label n, const labelHashSet &locations, const bool on=true)
Create a bitSet with length n with the specified on locations.
A table of dynamically loaded libraries.
A keyword and a list of tokens comprise a primitiveEntry. A primitiveEntry can be read,...
A class for handling file names.
std::string str(const bool prefixed=false) const
The digest (40-byte) text representation, optionally with '_' prefix.
Tools for handling dynamic code compilation.
static string evaluate(const dictionary &parentDict, Istream &is)
Evaluate dynamically compiled code, returning result as string.
Encapsulation of dynamic code dictionaries.
defineTypeNameAndDebug(codeStream, 0)
streamFormat format() const noexcept
Get the current stream format.
label lineNumber() const noexcept
Const access to the current stream line number.
Input/output from string buffers.
static bool execute(const dictionary &parentDict, primitiveEntry &entry, Istream &is)
Execute in a primitiveEntry context.
Ostream & endl(Ostream &os)
Add newline and flush stream.
A class for handling character strings derived from std::string.
const dictionary & dict() const noexcept
Return the parent dictionary context.
static streamingFunctionType getFunction(const dictionary &parentDict, const dictionary &codeDict)
Construct, compile, load and return streaming function.
const SHA1 & sha1() const noexcept
The SHA1 calculated from options, libs, include, code, etc.
void(* streamingFunctionType)(Ostream &, const dictionary &)
Interpreter function type.
off_t fileSize(const fileName &name, const bool followLink=true)
Return size of file or -1 on failure (normally follows symbolic links).
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
fileName relativeName(const bool caseTag=false) const
The dictionary name relative to the case.
void * dlSym(void *handle, const std::string &symbol)
Lookup a symbol in a dlopened library using handle to library.
static dlLibraryTable & libs(const dictionary &dict)
Helper function: access to dlLibraryTable of Time.
baseIOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO function...
Macros for easy insertion into member function selection tables.
const string & libs() const noexcept
The code libs (LIB_LIBS)
const dictionary & topDict() const
Return the top of the tree.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
reduce(hasMovingMesh, orOp< bool >())
OBJstream os(runTime.globalPath()/outputName)
addNamedToMemberFunctionSelectionTable(functionEntry, calcEntry, execute, dictionaryIstream, calc)
Input from string buffer, using a ISstream. Always UNCOMPRESSED.
#define DebugPout
Report an information message using Foam::Pout.
bool read(Istream &is)
Read dictionary from Istream. Discards the header.
errorManipArg< error, int > exit(error &err, const int errNo=1)
static bool doingMasterOnlyReading(const dictionary &dict)
Helper: access IOobject for master-only-reading functionality.
Output to string buffer, using a OSstream. Always UNCOMPRESSED.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
unsigned int sleep(const unsigned int sec)
Sleep for the specified number of seconds.
const string & options() const noexcept
The code options (Make/options)
void * dlOpen(const fileName &libName, const bool check=true)
Open a shared library and return handle to library.
string evaluate(label fieldWidth, const std::string &s, size_t pos=0, size_t len=std::string::npos)
String evaluation with specified (positive, non-zero) field width.