Skip to content
Snippets Groups Projects
Commit beee067c authored by Christophe Geuzaine's avatar Christophe Geuzaine
Browse files

New command line option "-run", which acts like the "Run" button in the GUI:...

New command line option "-run", which acts like the "Run" button in the GUI: it runs the ONELAB solvers (even the local Gmsh client: this is not the case if one uses simply "-").

"-run" should be used in all your scripts instead of "-" from now on.

parent c458c7f2
No related branches found
No related tags found
No related merge requests found
...@@ -117,6 +117,7 @@ std::vector<std::pair<std::string, std::string> > GetUsage() ...@@ -117,6 +117,7 @@ std::vector<std::pair<std::string, std::string> > GetUsage()
s.push_back(mp("-listen", "Always listen to incoming connection requests")); s.push_back(mp("-listen", "Always listen to incoming connection requests"));
s.push_back(mp("-minterpreter string", "Name of Octave interpreter")); s.push_back(mp("-minterpreter string", "Name of Octave interpreter"));
s.push_back(mp("-pyinterpreter string", "Name of Python interpreter")); s.push_back(mp("-pyinterpreter string", "Name of Python interpreter"));
s.push_back(mp("-run", "Run ONELAB solver(s)"));
s.push_back(mp("Display options:", "")); s.push_back(mp("Display options:", ""));
s.push_back(mp("-n", "Hide all meshes and post-processing views on startup")); s.push_back(mp("-n", "Hide all meshes and post-processing views on startup"));
s.push_back(mp("-nodb", "Disable double buffering")); s.push_back(mp("-nodb", "Disable double buffering"));
...@@ -308,6 +309,13 @@ void GetOptions(int argc, char *argv[]) ...@@ -308,6 +309,13 @@ void GetOptions(int argc, char *argv[])
CTX::instance()->batch = -99; CTX::instance()->batch = -99;
i++; i++;
} }
else if(!strcmp(argv[i] + 1, "run")) {
// same as '-', but will run local Gmsh client (if no other clients are
// requested, e.g. by opening a '.pro' or '.py' file)
CTX::instance()->batch = -99;
CTX::instance()->launchSolverAtStartup = -2;
i++;
}
else if(!strcmp(argv[i] + 1, "onelab")) { else if(!strcmp(argv[i] + 1, "onelab")) {
i++; i++;
if(argv[i] && argv[i + 1] && argv[i + 1][0] != '-'){ if(argv[i] && argv[i + 1] && argv[i + 1][0] != '-'){
......
...@@ -798,12 +798,27 @@ void resetDb(bool runGmshClient) ...@@ -798,12 +798,27 @@ void resetDb(bool runGmshClient)
void solver_batch_cb(void *data) void solver_batch_cb(void *data)
{ {
int num = (intptr_t)data; int num = (intptr_t)data;
if(num < 0) return; std::string name, exe, host;
std::string name = opt_solver_name(num, GMSH_GET, "");
std::string exe = opt_solver_executable(num, GMSH_GET, ""); if(num == -1){
std::string host = opt_solver_remote_login(num, GMSH_GET, ""); // no solver to run
if(exe.empty()){ return;
Msg::Error("Solver executable name not provided"); }
else if(num == -2){
// just run local Gmsh client
}
else if(num >= 0){
// run local Gmsh client + solver num
name = opt_solver_name(num, GMSH_GET, "");
exe = opt_solver_executable(num, GMSH_GET, "");
host = opt_solver_remote_login(num, GMSH_GET, "");
if(exe.empty()){
Msg::Error("Solver executable name not provided");
return;
}
}
else{
Msg::Error("Unknown client to run in batch mode (%d)", num);
return; return;
} }
...@@ -812,15 +827,21 @@ void solver_batch_cb(void *data) ...@@ -812,15 +827,21 @@ void solver_batch_cb(void *data)
onelab::server::instance()->set(n); onelab::server::instance()->set(n);
// create client // create client
onelab::localNetworkClient *c = new gmshLocalNetworkClient(name, exe, host); onelab::localNetworkClient *c = 0;
c->setIndex(num); onelab::string o;
onelab::string o(c->getName() + "/Action"); if(name.size()){
c = new gmshLocalNetworkClient(name, exe, host);
c->setIndex(num);
o = c->getName() + "/Action";
}
// initialize // initialize
onelabUtils::runGmshClient("initialize", CTX::instance()->solver.autoMesh); onelabUtils::runGmshClient("initialize", CTX::instance()->solver.autoMesh);
o.setValue("initialize"); if(c){
onelab::server::instance()->set(o); o.setValue("initialize");
c->run(); onelab::server::instance()->set(o);
c->run();
}
// load db // load db
if(CTX::instance()->solver.autoSaveDatabase){ if(CTX::instance()->solver.autoSaveDatabase){
...@@ -830,20 +851,24 @@ void solver_batch_cb(void *data) ...@@ -830,20 +851,24 @@ void solver_batch_cb(void *data)
// check // check
onelabUtils::runGmshClient("check", CTX::instance()->solver.autoMesh); onelabUtils::runGmshClient("check", CTX::instance()->solver.autoMesh);
onelabUtils::guessModelName(c); if(c){
o.setValue("check"); onelabUtils::guessModelName(c);
onelab::server::instance()->set(o); o.setValue("check");
c->run(); onelab::server::instance()->set(o);
c->run();
}
// compute // compute
initializeLoops(); initializeLoops();
do{ do{
onelabUtils::runGmshClient("compute", CTX::instance()->solver.autoMesh); onelabUtils::runGmshClient("compute", CTX::instance()->solver.autoMesh);
onelabUtils::guessModelName(c); if(c){
o.setValue("compute"); onelabUtils::guessModelName(c);
onelab::server::instance()->set(o); o.setValue("compute");
c->run(); onelab::server::instance()->set(o);
onelab::server::instance()->setChanged(false, c->getName()); c->run();
onelab::server::instance()->setChanged(false, c->getName());
}
} while(incrementLoops()); } while(incrementLoops());
if(CTX::instance()->solver.autoSaveDatabase || if(CTX::instance()->solver.autoSaveDatabase ||
......
...@@ -88,6 +88,8 @@ Always listen to incoming connection requests ...@@ -88,6 +88,8 @@ Always listen to incoming connection requests
Name of Octave interpreter Name of Octave interpreter
@item -pyinterpreter string @item -pyinterpreter string
Name of Python interpreter Name of Python interpreter
@item -run
Run ONELAB solver(s)
@end ftable @end ftable
Display options: Display options:
@ftable @code @ftable @code
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment