43 bool Foam::argList::bannerEnabled(
true);
46 Foam::argList::initValidTables::initValidTables()
48 validOptions.set(
"case",
"dir");
49 validOptions.set(
"parallel",
"");
50 validParOptions.set(
"parallel",
"");
52 Pstream::addValidParOptions(validParOptions);
61 bool Foam::argList::regroupArgv(
int& argc,
char**& argv)
69 for (
int argI = 0; argI < argc; argI++)
71 if (strcmp(argv[argI],
"(") == 0)
76 else if (strcmp(argv[argI],
")") == 0)
84 args_[nArgs++] = tmpString;
90 args_[nArgs++] = argv[argI];
97 tmpString += argv[argI];
102 args_[nArgs++] = argv[argI];
106 if (tmpString.size())
108 args_[nArgs++] = tmpString;
124 void Foam::argList::getRootCase()
131 if (iter != options_.end())
136 if (casePath.empty() || casePath ==
".")
140 options_.erase(
"case");
142 else if (casePath[0] !=
'/' && casePath.name() ==
"..")
155 rootPath_ = casePath.path();
156 globalCase_ = casePath.name();
161 if (rootPath_[0] ==
'/')
164 setEnv(
"FOAM_CASE", rootPath_/globalCase_,
true);
165 setEnv(
"FOAM_CASENAME", globalCase_,
true);
170 fileName casePath =
cwd()/rootPath_/globalCase_;
173 setEnv(
"FOAM_CASE", casePath,
true);
174 setEnv(
"FOAM_CASENAME", casePath.name(),
true);
202 for (
int argI = 0; argI < argc; argI++)
204 if (argv[argI][0] ==
'-')
206 const char *optionName = &argv[argI][1];
208 if (validParOptions.found(optionName))
210 parRunControl_.runPar(argc, argv);
218 regroupArgv(argc, argv);
226 string argListString = args_[0];
228 for (
int argI = 1; argI < args_.size(); argI++)
230 argListString +=
' ';
231 argListString += args_[argI];
233 if (args_[argI][0] ==
'-')
235 const char *optionName = &args_[argI][1];
240 validOptions.found(optionName)
241 && validOptions[optionName] !=
""
244 validParOptions.found(optionName)
245 && validParOptions[optionName] !=
""
250 if (argI >= args_.size())
253 <<
"option " <<
"'-" << optionName <<
'\''
254 <<
" requires an argument"
258 argListString +=
' ';
259 argListString += args_[argI];
260 options_.insert(optionName, args_[argI]);
264 options_.insert(optionName,
"");
271 args_[nArgs] = args_[argI];
277 args_.setSize(nArgs);
285 options_.found(
"help")
286 || options_.found(
"doc")
287 || options_.found(
"srcDoc")
290 if (options_.found(
"help"))
296 if (options_.found(
"srcDoc"))
300 else if (options_.found(
"doc"))
309 if (!check(checkArgs, checkOpts))
323 <<
"Exec : " << argListString.c_str() <<
nl
324 <<
"Date : " << dateString.c_str() <<
nl
325 <<
"Time : " << timeString.c_str() <<
nl
347 if (parRunControl_.parRun())
357 rootPath_/globalCase_/
"system/decomposeParDict"
360 if (!decompDictStream.
good())
364 << decompDictStream.
name()
374 decompDict.
lookup(
"numberOfSubdomains")
390 << decompDictStream.
name()
391 <<
" specifies " << dictNProcs
392 <<
" processors but job was started with "
401 decompDict.
lookup(
"roots") >> roots;
406 <<
"number of entries in decompositionDict::roots"
407 <<
" is not equal to the number of slaves "
413 bool hadCaseOpt = options_.found(
"case");
424 fileName(roots[slave-1])/globalCase_
428 toSlave << args_ << options_;
430 options_.erase(
"case");
435 options_.set(
"case", rootPath_/globalCase_);
449 rootPath_/globalCase_/
"processor"
458 <<
"number of processor directories = "
460 <<
" is not equal to the number of processors = "
475 toSlave << args_ << options_;
483 fromMaster >> args_ >> options_;
503 if (parRunControl_.parRun())
520 fromSlave >> slaveMachine >> slavePid;
522 slaveProcs[procI++] = slaveMachine +
"." +
name(slavePid);
535 Info<<
"Case : " << (rootPath_/globalCase_).c_str() <<
nl
536 <<
"nProcs : " << nProcs <<
endl;
538 if (parRunControl_.parRun())
540 Info<<
"Slaves : " << slaveProcs <<
nl
541 <<
"Pstream initialized with:" <<
nl
553 if (slaveProcs.
size())
561 sigFpe_.set(bannerEnabled);
562 sigInt_.set(bannerEnabled);
563 sigQuit_.set(bannerEnabled);
564 sigSegv_.set(bannerEnabled);
586 bannerEnabled =
false;
592 validOptions.erase(
"parallel");
599 <<
"Usage: " << executable_;
604 iter != validArgs.end();
608 Info<<
" <" << iter().c_str() <<
'>';
614 iter != validOptions.end();
618 Info<<
" [-" << iter.key();
622 Info<<
' ' << iter().c_str();
630 Info<<
" [-help] [-doc] [-srcDoc]\n" <<
endl;
643 forAll(docIndexFiles,idxI)
645 IFstream indexFile(docIndexFiles[idxI]);
647 if (!indexFile.
good())
649 WarningIn(
"Foam::argList::displayDoc(bool)")
650 <<
"Cannot open documentation index file " << docIndexFiles[idxI]
657 if (indexDict.
found(
"docDir") && indexDict.
found(
"docFiles"))
662 indexDict.
lookup(
"docDir") >> docDir;
664 docFiles = indexDict.
subDict(
"docFiles");
666 if (docFiles.
found(executable_))
674 WarningIn(
"Foam::argList::displayDoc(bool)")
675 <<
"The file " << docIndexFiles[idxI]
676 <<
"does not contain one or both of the entries"
677 <<
"\"docDir\" and \"docFiles\"."
685 string docBrowser(docDict.
lookup(
"docBrowser"));
686 if (docBrowser !=
"ECHO")
688 docBrowser.replaceAll(
"%f", docFile);
690 Info<<
"Show documentation: " << docBrowser.c_str() <<
endl;
696 Info<<
"Documentation available at: " << docFile <<
endl;
702 <<
"No documentation found for " << executable_
703 <<
", but you can use -help to display the usage\n" <<
endl;
714 if (checkArgs && args_.size() - 1 != validArgs.size())
717 <<
"Wrong number of arguments, expected " << validArgs.size()
718 <<
" found " << args_.size() - 1 <<
endl;
728 !validOptions.found(iter.key())
729 && !validParOptions.found(iter.key())
733 <<
"Invalid option: -" << iter.key() <<
endl;
751 if (!
isDir(rootPath()))
755 <<
": cannot open root directory " << rootPath()
766 <<
": cannot open case directory " << path()