diff --git a/Common/onelabUtils.cpp b/Common/onelabUtils.cpp index c46c1e8020d83dd4a968ebdfcac1e909546ea891..7004a893e4be1f7144c897867ddb2e45052a2b3f 100644 --- a/Common/onelabUtils.cpp +++ b/Common/onelabUtils.cpp @@ -120,12 +120,18 @@ namespace onelabUtils { else if(numbers[i].getStep() > 0){ if(numbers[i].getMin() != -onelab::parameter::maxNumber()){ numbers[i].setValue(numbers[i].getMin()); + numbers[i].setIndex(0); // indicates we are in a loop + std::vector<double> choices; + numbers[0].setChoices(choices); onelab::server::instance()->set(numbers[i]); changed = true; } } else if(numbers[i].getStep() < 0){ if(numbers[i].getMax() != onelab::parameter::maxNumber()){ + numbers[i].setIndex(0); // indicates we are in a loop + std::vector<double> choices; + numbers[0].setChoices(choices); numbers[i].setValue(numbers[i].getMax()); onelab::server::instance()->set(numbers[i]); changed = true; @@ -161,24 +167,34 @@ namespace onelabUtils { } } else if(numbers[i].getStep() > 0){ + int j = numbers[i].getIndex() + 1; + double val = numbers[i].getValue() + numbers[i].getStep(); if(numbers[i].getMax() != onelab::parameter::maxNumber() && - numbers[i].getValue() < numbers[i].getMax()){ - numbers[i].setValue(numbers[i].getValue() + numbers[i].getStep()); + val < numbers[i].getMax()){ + numbers[i].setValue(val); + numbers[i].setIndex(j); onelab::server::instance()->set(numbers[i]); Msg::Info("Recomputing with new step %s=%g", numbers[i].getName().c_str(), numbers[i].getValue()); recompute = true; } + else + numbers[i].setIndex(numbers[i].getMax()); } else if(numbers[i].getStep() < 0){ + int j = numbers[i].getIndex() + 1; + double val = numbers[i].getValue() + numbers[i].getStep(); if(numbers[i].getMin() != -onelab::parameter::maxNumber() && - numbers[i].getValue() > numbers[i].getMin()){ - numbers[i].setValue(numbers[i].getValue() + numbers[i].getStep()); + val > numbers[i].getMin()){ + numbers[i].setValue(val); + numbers[i].setIndex(j); onelab::server::instance()->set(numbers[i]); Msg::Info("Recomputing with new step %s=%g", numbers[i].getName().c_str(), numbers[i].getValue()); recompute = true; } + else + numbers[i].setIndex(numbers[i].getMin()); } } } diff --git a/contrib/onelab/OnelabClients.cpp b/contrib/onelab/OnelabClients.cpp index d134824ccc9ae15580f22e41d525044a897621f5..72a9220b3f8899c87b24f086773d6fb4d036f633 100644 --- a/contrib/onelab/OnelabClients.cpp +++ b/contrib/onelab/OnelabClients.cpp @@ -99,7 +99,7 @@ std::string localNetworkSolverClient::buildCommandLine(){ command.assign(""); if(!getWorkingDir().empty()) command.append("cd " + getWorkingDir() + cmdSep); - command.append(FixWindowsPath(getCommandLine())); + command.append(FixExecPath(getCommandLine())); return command; } @@ -406,12 +406,39 @@ const bool localSolverClient::getList(const std::string type, std::vector<std::s } bool localSolverClient::checkCommandLine(){ - OLMsg::Info("Check command line for <%s>",getName().c_str()); + OLMsg::Info("Check command line <%s> for client <%s>", + getCommandLine().c_str(), getName().c_str()); if(!isActive()) return true; + //if(*getCommandLine().rbegin() != '=') return false; + if(!getCommandLine().empty()){ - setAction("initialize"); - run(); // does nothing for Interfaced clients, initializes native clients + if(isNative()){ + setAction("initialize"); + if(!run()){ // initializes native clients + OLMsg::Error("Invalid commandline <%s> for client <%s>", + FixExecPath(getCommandLine()).c_str(), getName().c_str()); + //setCommandLine(""); + return false; + } + } + else{ + std::string cmd,commandLine; + char cbuf [1024]; + FILE *fp; + commandLine.assign(FixExecPath(getCommandLine())); + cmd.assign("which "+commandLine); + fp = POPEN(cmd.c_str(), "r"); + if(fgets(cbuf, 1024, fp) == NULL){ + OLMsg::Error("The executable <%s> does not exist", + commandLine.c_str()); + PCLOSE(fp); + return false; + } + OLMsg::Info("The executable <%s> exists", commandLine.c_str()); + PCLOSE(fp); + return true; + } } else{ OLMsg::Error("No commandline for client <%s>", getName().c_str()); @@ -608,18 +635,6 @@ bool remoteClient::syncOutputFile(const std::string &wdir, const std::string &fi // client METAMODEL -void MetaModel::saveCommandLines(const std::string fileName){ - //save client command lines - std::string fileNameSave = getWorkingDir()+fileName+onelabExtension+".save"; - std::ofstream outfile(fileNameSave.c_str()); - - if (outfile.is_open()) - for(citer it = _clients.begin(); it != _clients.end(); it++) - outfile << (*it)->toChar(); - else - OLMsg::Error("The file <%s> cannot be opened",fileNameSave.c_str()); - outfile.close(); -} bool MetaModel::checkCommandLines(){ bool allDefined=true; @@ -660,6 +675,7 @@ void MetaModel::compute() { void MetaModel::registerClient(const std::string &name, const std::string &type, const std::string &cmdl, const std::string &host, const std::string &rdir) { localSolverClient *c; + // Clients are assigned by default the same working dir as the MetaModel // i.e. the working dir from args if(host.empty() || rdir.empty()){ //local client @@ -763,7 +779,7 @@ void InterfacedClient::compute(){ cmd.assign(""); if(!getWorkingDir().empty()) cmd.append("cd " + getWorkingDir() + cmdSep); - cmd.append(FixWindowsPath(getCommandLine())); + cmd.append(FixExecPath(getCommandLine())); cmd.append(" " + getString("Arguments")); if(cmd.size()) mySystem(cmd.c_str()); @@ -782,7 +798,9 @@ void NativeClient::analyze() { OLMsg::Info("Analyze <%s> changed=%d", getName().c_str(), onelab::server::instance()->getChanged(getName())); setAction("check"); - run(); + if(!run()) + OLMsg::Error("Invalid commandline <%s> for client <%s>", + FixExecPath(getCommandLine()).c_str(), getName().c_str()); } void NativeClient::compute() { @@ -801,7 +819,10 @@ void NativeClient::compute() { checkIfPresentLocal(choices[i]); } } - run(); + + if(!run()) + OLMsg::Error("Invalid commandline <%s> for client <%s>", + FixExecPath(getCommandLine()).c_str(), getName().c_str()); if(getList("OutputFiles",choices)){ for(unsigned int i = 0; i < choices.size(); i++){ @@ -855,7 +876,9 @@ void EncapsulatedClient::convert() { } std::string EncapsulatedClient::buildCommandLine(){ - return FixWindowsQuotes(OLMsg::GetLoaderName()); + std::string cmd= FixExecPath(OLMsg::GetOnelabString("LoaderPathName")); + OLMsg::Info("command line=<%s>",cmd.c_str()); + return cmd; } void EncapsulatedClient::compute(){ @@ -881,13 +904,16 @@ void EncapsulatedClient::compute(){ cmd.assign(""); if(!getWorkingDir().empty()) cmd.append("cd " + getWorkingDir() + cmdSep); - cmd.append(FixWindowsPath(getCommandLine())); + cmd.append(FixExecPath(getCommandLine())); cmd.append(" " + getString("Arguments")); OLMsg::SetOnelabString(getName()+"/FullCmdLine",cmd,false); // the encapsulating localNetworkClient is called OLMsg::Info("Command line=<%s>",cmd.c_str()); - run(); + + if(!run()) + OLMsg::Error("Invalid commandline <%s> for client <%s>", + FixExecPath(getCommandLine()).c_str(), getName().c_str()); if(getList("OutputFiles",choices)){ for(unsigned int i = 0; i < choices.size(); i++){ @@ -941,7 +967,7 @@ std::string RemoteNativeClient::buildCommandLine(){ std::string command; command.assign("incomp_ssh -f "+getRemoteHost()); command.append(" 'cd "+getRemoteDir()+"; "); - command.append(FixWindowsPath(getCommandLine())+" "); + command.append(FixExecPath(getCommandLine())+" "); return command; } @@ -961,7 +987,10 @@ void RemoteNativeClient::analyze(){ for(unsigned int i = 0; i < choices.size(); i++) syncInputFile(getWorkingDir(),choices[i]); } - run(); + + if(!run()) + OLMsg::Error("Invalid commandline <%s> for client <%s>", + FixExecPath(getCommandLine()).c_str(), getName().c_str()); } @@ -984,7 +1013,9 @@ void RemoteNativeClient::compute(){ mySystem(cmd); } - run(); + if(!run()) + OLMsg::Error("Invalid commandline <%s> for client <%s>", + FixExecPath(getCommandLine()).c_str(), getName().c_str()); if(getList("OutputFiles",choices)){ for(unsigned int i = 0; i < choices.size(); i++) @@ -1024,13 +1055,16 @@ void RemoteEncapsulatedClient::compute(){ cmd.assign("ssh "+getRemoteHost()); if(!getRemoteDir().empty()) cmd.append(" 'cd " + getRemoteDir() + ";"); - cmd.append(" "+FixWindowsPath(getCommandLine())); + cmd.append(" "+FixExecPath(getCommandLine())); cmd.append(" " + getString("Arguments") + " '"); OLMsg::SetOnelabString(getName()+"/FullCmdLine",cmd,false); // the encapsulating localNetworkClient is called OLMsg::Info("Command line=<%s>",cmd.c_str()); - run(); + + if(!run()) + OLMsg::Error("Invalid commandline <%s> for client <%s>", + FixExecPath(getCommandLine()).c_str(), getName().c_str()); if(getList("OutputFiles",choices)){ for(unsigned int i = 0; i < choices.size(); i++) @@ -1159,15 +1193,9 @@ std::string sanitize(const std::string &in) return out; } -std::string FixWindowsQuotes(const std::string &in) -{ -#if defined(WIN32) +std::string quote(const std::string &in){ return "\"" + in + "\""; -#else - return in; -#endif } - std::string unquote(const std::string &in) { size_t pos0=in.find_first_not_of(" "); @@ -1178,6 +1206,49 @@ std::string unquote(const std::string &in) return in.substr(pos0,pos-pos0+1); } +std::string FixWindowsQuotes(const std::string &in) +{ +#if defined(WIN32) + return "\"" + in + "\""; +#else + return in; +#endif +} + +std::string FixExecPath(const std::string &in) +{ + std::string cmd,split0,split1,split2; + std::cout << "in=<" << in << ">" << std::endl; + + cmd.assign(removeBlanks(in)); + cmd.assign(FixWindowsPath(cmd)); + + split0.assign(SplitFileName(cmd)[0]); + split1.assign(SplitFileName(cmd)[1]); + split2.assign(SplitFileName(cmd)[2]); + std::cout << "0=<" << split0 << ">" << std::endl; + std::cout << "1=<" << split1 << ">" << std::endl; + std::cout << "2=<" << split2 << ">" << std::endl; + + if(split2==".app") + cmd.assign(cmd + "/Contents/MacOS/" + split1); + + if(split1.find("elmerfem") != std::string::npos){ +#if not defined(WIN32) + cmd.assign("ELMER_HOME=" + quote(split0.substr(0,split0.size()-4)) ); + cmd.append(cmdSep); + cmd.append( quote("$ELMER_HOME/bin/"+split1) ); +#endif + } + else + if(cmd[0] != '\"') cmd.assign(quote(cmd)); + + std::cout << "cmd=<" << cmd << ">" << std::endl; + + //exit(1); + return cmd; +} + std::string removeBlanks(const std::string &in) { size_t pos0=in.find_first_not_of(" "); @@ -1190,9 +1261,13 @@ std::string removeBlanks(const std::string &in) bool isPath(const std::string &in) { size_t pos=in.find_last_not_of(" 0123456789"); - if(in.compare(pos,1,"/")) + if(pos==std::string::npos) return true; + if(in.compare(pos,1,"/")){ OLMsg::Error("The argument <%s> is not a valid parameter path (must end with '/')",in.c_str()); - return true; + return false; + } + else + return true; } // std::vector <double> extract_column(const unsigned int col, const array data){ diff --git a/contrib/onelab/OnelabClients.h b/contrib/onelab/OnelabClients.h index 6e63e28a8452e204f34c179f0b9677a427ace636..d3edf7495f294a51ef1e8b9b72fc3359b205c17b 100644 --- a/contrib/onelab/OnelabClients.h +++ b/contrib/onelab/OnelabClients.h @@ -40,12 +40,13 @@ std::string sanitize(const std::string &in); std::string removeBlanks(const std::string &in); bool isPath(const std::string &in); std::string FixWindowsQuotes(const std::string &in); +std::string FixExecPath(const std::string &in); std::string unquote(const std::string &in); // Parser TOOLS int enclosed(const std::string &in, std::vector<std::string> &arguments, size_t &end); int extract(const std::string &in, std::string ¶mName, std::string &action, std::vector<std::string> &arguments); -bool extractRange(const std::string &in, std::vector<double> &arguments); +//bool extractRange(const std::string &in, std::vector<double> &arguments); std::string extractExpandPattern(const std::string& str); @@ -141,6 +142,7 @@ class localSolverClient : public onelab::localClient{ const void closeOnelabBlock() { _onelabBlock=false; } std::string resolveGetVal(std::string line); bool resolveLogicExpr(std::vector<std::string> arguments); + bool resolveRange(const std::string &in, std::vector<double> &arguments); void parse_sentence(std::string line) ; void parse_oneline(std::string line, std::ifstream &infile) ; bool parse_block(std::ifstream &infile) ; diff --git a/contrib/onelab/OnelabMessage.cpp b/contrib/onelab/OnelabMessage.cpp index a7b08a9c35a1cb93a8e799d616fc2e379d459179..6d028085b5021a6e82d4c70a1d8e41334d042d02 100644 --- a/contrib/onelab/OnelabMessage.cpp +++ b/contrib/onelab/OnelabMessage.cpp @@ -29,7 +29,6 @@ std::string OLMsg::_commandLine; std::string OLMsg::_launchDate; GmshClient *OLMsg::_client = 0; onelab::client *OLMsg::_onelabClient = 0; -std::string OLMsg::_loaderName; bool OLMsg::hasGmsh=false; std::set<std::string, fullNameLessThan> OLMsg::_fullNameDict; void (*OLMsg::gui_wait_fct)(double time) = 0; @@ -90,8 +89,11 @@ void OLMsg::Fatal(const char *fmt, ...) vsnprintf(str, sizeof(str), fmt, args); va_end(args); - if(_callback) (*_callback)("Fatal", str); - if(_client) _client->Error(str); + //if(_callback) (*_callback)("Fatal", str); + //if(_client) _client->Error(str); + + if(_onelabClient && OLMsg::hasGmsh) + _onelabClient->sendError(str); if(ALWAYS_TRUE){ if(_commSize > 1) @@ -120,7 +122,8 @@ void OLMsg::Error(const char *fmt, ...) //if(_callback) (*_callback)("Error", str); //if(_client) _client->Error(str); - if(_onelabClient) _onelabClient->sendError(str); + if(_onelabClient && OLMsg::hasGmsh) + _onelabClient->sendError(str); if(ALWAYS_TRUE){ if(_commSize > 1) @@ -145,7 +148,8 @@ void OLMsg::Warning(const char *fmt, ...) //if(_callback) (*_callback)("Warning", str); //if(_client) _client->Warning(str); - if(_onelabClient) _onelabClient->sendWarning(str); + if(_onelabClient && OLMsg::hasGmsh) + _onelabClient->sendWarning(str); if(ALWAYS_TRUE){ fprintf(stderr, "Warning : %s\n", str); @@ -165,7 +169,8 @@ void OLMsg::Info(const char *fmt, ...) //if(_callback) (*_callback)("Info", str); //if(_client) _client->Info(str); - if(_onelabClient) _onelabClient->sendInfo(str); + if(_onelabClient && OLMsg::hasGmsh) + _onelabClient->sendInfo(str); if(ALWAYS_TRUE){ fprintf(stdout, "Onelab : %s\n", str); @@ -196,8 +201,10 @@ void OLMsg::Direct(int level, const char *fmt, ...) vsnprintf(str, sizeof(str), fmt, args); va_end(args); - if(_callback) (*_callback)("Direct", str); - if(_client) _client->Info(str); + //if(_callback) (*_callback)("Direct", str); + //if(_client) _client->Info(str); + if(_onelabClient && OLMsg::hasGmsh) + _onelabClient->sendInfo(str); if(ALWAYS_TRUE){ fprintf(stdout, "%s\n", str); @@ -216,8 +223,11 @@ void OLMsg::StatusBar(int num, bool log, const char *fmt, ...) vsnprintf(str, sizeof(str), fmt, args); va_end(args); - if(_callback && log) (*_callback)("Info", str); - if(_client && log) _client->Info(str); + //if(_callback && log) (*_callback)("Info", str); + //if(_client && log) _client->Info(str); + + if(_onelabClient && OLMsg::hasGmsh) + _onelabClient->sendInfo(str); if(log && ALWAYS_TRUE){ fprintf(stdout, "Info : %s\n", str); @@ -239,13 +249,6 @@ void (*OLMsg::GetGuiWaitFunction())(double){ return gui_wait_fct; } -// void OLMsg::SetLoaderName(const std::string &name) { -// _loaderName = name; -// } -// std::string OLMsg::GetLoaderName() { -// return _loaderName; -// } - double OLMsg::GetOnelabNumber(std::string name) { if(_onelabClient){ diff --git a/contrib/onelab/OnelabMessage.h b/contrib/onelab/OnelabMessage.h index 426ee93d880cb526695fc7f8df8226772fb6c82b..ffd187a8b16c6ab3b493b06b75ca4c1f0aca3559 100644 --- a/contrib/onelab/OnelabMessage.h +++ b/contrib/onelab/OnelabMessage.h @@ -54,8 +54,6 @@ class OLMsg { static onelab::client *_onelabClient; // dictionnary for parameter names static std::set<std::string, fullNameLessThan> _fullNameDict; - // Loader executable name - static std::string _loaderName; // Gmsh wait function static void (*gui_wait_fct)(double time); public: @@ -101,8 +99,8 @@ class OLMsg { //static void FinalizeClient(); static GmshClient *GetClient(){ return _client; } - static void SetLoaderName(const std::string &name){ _loaderName = name; } - static std::string GetLoaderName(){ return _loaderName; } + //static void SetLoaderName(const std::string &name){ _loaderName = name; } + //static std::string GetLoaderName(){ return _loaderName; } static void SetGuiWaitFunction(void (*fct)(double time)); static void (*GetGuiWaitFunction())(double); static void SetOnelabClient(onelab::client *client){ _onelabClient = client;} diff --git a/contrib/onelab/OnelabParser.cpp b/contrib/onelab/OnelabParser.cpp index b63bf8e632a3e87b72596d833ca731a4eb26c44d..1d9352d1c7503b31c8f3c2887b1b9225154b4227 100644 --- a/contrib/onelab/OnelabParser.cpp +++ b/contrib/onelab/OnelabParser.cpp @@ -11,6 +11,7 @@ namespace olkey{ static std::string begin(label+"block"); static std::string end(label+"endblock"); static std::string include(label+"include"); + static std::string loader(label+"loaderName"); static std::string message(label+"msg"); static std::string showParam(label+"show"); static std::string showGmsh(label+"merge"); @@ -23,6 +24,25 @@ namespace olkey{ static std::string getRegion(label+"region"); } +// Client member function moved here because it uses parser commands +void MetaModel::saveCommandLines(const std::string fileName){ + //save client command lines + std::string fileNameSave = getWorkingDir()+fileName+onelabExtension+".save"; + std::ofstream outfile(fileNameSave.c_str()); + if (outfile.is_open()){ + outfile << olkey::ifcond << "(" << olkey::getValue ; + outfile << "(LoaderPathName) == "; + outfile << OLMsg::GetOnelabString("LoaderPathName") << ")" << std::endl; + for(citer it = _clients.begin(); it != _clients.end(); it++) + if((*it)->checkCommandLine()) + outfile << (*it)->toChar(); + outfile << olkey::olendif << std::endl; + } + else + OLMsg::Error("The file <%s> cannot be opened",fileNameSave.c_str()); + outfile.close(); +} + int enclosed(const std::string &in, std::vector<std::string> &arguments, size_t &end){ // syntax: (arguments[Ø], arguments[1], ... , arguments[n]) @@ -312,23 +332,33 @@ bool localSolverClient::resolveLogicExpr(std::vector<std::string> arguments) { return condition; } -bool extractRange(const std::string &in, std::vector<double> &arguments){ - // syntax: a:b:c or a:b#n +bool localSolverClient::resolveRange(const std::string &in, std::vector<double> &arguments){ + // syntax: a:b:c or a:b|n with a,b,c numbers and n integer + double val; size_t pos, cursor; arguments.resize(0); cursor=0; if ( (pos=in.find(":",cursor)) == std::string::npos ) OLMsg::Error("Syntax error in range <%s>",in.c_str()); else{ - arguments.push_back(atof(in.substr(cursor,pos-cursor).c_str())); + val=atof(resolveGetVal(in.substr(cursor,pos-cursor)).c_str()); + arguments.push_back(val); } cursor = pos+1; // skips ':' if ( (pos=in.find(":",cursor)) != std::string::npos ){ - arguments.push_back(atof(in.substr(cursor,pos-cursor).c_str())); - arguments.push_back(atof(in.substr(pos+1).c_str())); + //arguments.push_back(atof(in.substr(cursor,pos-cursor).c_str())); + //arguments.push_back(atof(in.substr(pos+1).c_str())); + val=atof(resolveGetVal(in.substr(cursor,pos-cursor)).c_str()); + arguments.push_back(val); + val=atof(resolveGetVal(in.substr(pos+1)).c_str()); + arguments.push_back(val); } - else if ( (pos=in.find("X",cursor)) != std::string::npos ){ - arguments.push_back(atof(in.substr(cursor,pos-cursor).c_str())); + else if ( (pos=in.find("|",cursor)) != std::string::npos ){ + // arguments.push_back(atof(in.substr(cursor,pos-cursor).c_str())); + // double NumStep = atof(in.substr(pos+1).c_str()); + //arguments.push_back((arguments[1]-arguments[0])/((NumStep==0)?1:NumStep)); + val=atof(resolveGetVal(in.substr(cursor,pos-cursor)).c_str()); + arguments.push_back(val); double NumStep = atof(in.substr(pos+1).c_str()); arguments.push_back((arguments[1]-arguments[0])/((NumStep==0)?1:NumStep)); } @@ -373,7 +403,7 @@ void localSolverClient::parse_sentence(std::string line) { numbers[0].setLabel(arguments[2]); if(arguments.size()>3){ std::vector<double> bounds; - if (extractRange(arguments[3],bounds)){ + if (resolveRange(arguments[3],bounds)){ numbers[0].setMin(bounds[0]); numbers[0].setMax(bounds[1]); numbers[0].setStep(bounds[2]); @@ -444,7 +474,7 @@ void localSolverClient::parse_sentence(std::string line) { if(numbers.size()){ // parameter must exist if(arguments.size()==1){ std::vector<double> bounds; - if (extractRange(arguments[0],bounds)){ + if (resolveRange(arguments[0],bounds)){ numbers[0].setMin(bounds[0]); numbers[0].setMax(bounds[1]); numbers[0].setStep(bounds[2]); @@ -661,6 +691,7 @@ void localSolverClient::modify_tags(const std::string lab, const std::string com olkey::begin.assign(olkey::label+"block"); olkey::end.assign(olkey::label+"endblock"); olkey::include.assign(olkey::label+"include"); + olkey::loader.assign(olkey::label+"loaderName"); olkey::message.assign(olkey::label+"msg"); olkey::showParam.assign(olkey::label+"show"); olkey::showGmsh.assign(olkey::label+"merge"); @@ -793,6 +824,17 @@ void localSolverClient::parse_oneline(std::string line, std::ifstream &infile) { OLMsg::Info("%s",msg.c_str()); } } + else if ( (pos=line.find(olkey::loader)) != std::string::npos) { + // onelab.loaderName + cursor = pos+olkey::loader.length(); + if(enclosed(line.substr(cursor),arguments,pos)<1) + OLMsg::Error("Misformed <%s> statement: (%s)", + olkey::loader.c_str(),line.c_str()); + else{ + std::string msg = resolveGetVal(arguments[0]); + OLMsg::Info("%s",msg.c_str()); + } + } else if ( (pos=line.find(olkey::showParam)) != std::string::npos) { // onelab.showParam cursor = pos+olkey::showParam.length(); @@ -870,10 +912,12 @@ void localSolverClient::parse_oneline(std::string line, std::ifstream &infile) { if((pos=line.find_first_not_of(" \t"))==std::string::npos){ OLMsg::Error("Empty line not allowed within a command <%s>", cmds.c_str()); + break; } else if(!line.compare(pos,olkey::comment.size(),olkey::comment)){ OLMsg::Error("Comment lines not allowed within a command <%s>", cmds.c_str()); + break; } NbLines++; // command should not span over more than 10 lines } @@ -1199,7 +1243,8 @@ void MetaModel::client_sentence(const std::string &name, // syntax name.register([interf...|native]{,cmdl{host{,rdir}}}}) ; if(!findClientByName(name)){ OLMsg::Info("Define client <%s>", name.c_str()); - std::string cmdl="",host="",rdir=""; + std::string type="",cmdl="",host="",rdir=""; + if(arguments.size()>=1) type.assign(resolveGetVal(arguments[0])); if(arguments.size()>=2) cmdl.assign(resolveGetVal(arguments[1])); if(arguments.size()>=3) host.assign(resolveGetVal(arguments[2])); if(arguments.size()>=4) rdir.assign(resolveGetVal(arguments[3])); @@ -1221,7 +1266,10 @@ void MetaModel::client_sentence(const std::string &name, set(str); } } - registerClient(name,resolveGetVal(arguments[0]),cmdl,host,rdir); + + if((!type.compare(0,6,"encaps")) && (!OLMsg::hasGmsh)) + type.assign("interf"); + registerClient(name,type,cmdl,host,rdir); } else OLMsg::Error("Redefinition of client <%s>", name.c_str()); @@ -1410,7 +1458,7 @@ void MetaModel::client_sentence(const std::string &name, } localSolverClient *c; if((c=findClientByName(name))) { - if(isTodo(REGISTER)) + if(isTodo(REGISTER) && !OLMsg::GetErrorNum()) if(onelab::server::instance()->getChanged(c->getName())){ c->compute(); c->GmshMerge(choices); diff --git a/contrib/onelab/metamodel.cpp b/contrib/onelab/metamodel.cpp index 0313b96bdc8a1034e01a1dae2f08e4beeef8b801..4588bab57d9f320e8ebd211c57a05853408f51d0 100644 --- a/contrib/onelab/metamodel.cpp +++ b/contrib/onelab/metamodel.cpp @@ -10,8 +10,8 @@ void initializeMetamodel(const std::string &loaderName, onelab::client *olclient //which is a onelab::client with sone Gmsh features (merge and messages). //Initilizes also the wait function the Gmsh Gui //so that Gmsh windows may remain active during client computations. - OLMsg::SetLoaderName(loaderName); OLMsg::SetOnelabClient(olclient); + OLMsg::SetOnelabString("LoaderPathName",loaderName,false); OLMsg::SetGuiWaitFunction(gui_wait_fct); }