diff --git a/Plugin/Scal2Vec.cpp b/Plugin/Scal2Vec.cpp index da1b8a49ef0bf6b0fae431d52c0243009abe0182..a4ccd6bdf60d2bf76b78abdd1c4d0e5b682cd8da 100644 --- a/Plugin/Scal2Vec.cpp +++ b/Plugin/Scal2Vec.cpp @@ -8,13 +8,13 @@ #include "shapeFunctions.h" StringXNumber Scal2VecOptions_Number[] = { - {GMSH_FULLRC, "View X", NULL, -1.}, - {GMSH_FULLRC, "View Y", NULL, -1.}, - {GMSH_FULLRC, "View Z", NULL, -1.} + {GMSH_FULLRC, "ViewX", NULL, -1.}, + {GMSH_FULLRC, "ViewY", NULL, -1.}, + {GMSH_FULLRC, "ViewZ", NULL, -1.} }; StringXString Scal2VecOptions_String[] = { - {GMSH_FULLRC, "Name NewView", NULL, "NewView"} + {GMSH_FULLRC, "NameNewView", NULL, "NewView"} }; extern "C" @@ -27,10 +27,10 @@ extern "C" std::string GMSH_Scal2VecPlugin::getHelp() const { - return "Plugin(Scal2Vec) converts the scalar fields of 'View X', " - "'View Y' and/or 'View Z' into a vectorial field. " - "The new view 'Name NewView' contains it.\n\n" - "If the value of 'View X', 'View Y' or 'View Z' is -1, " + return "Plugin(Scal2Vec) converts the scalar fields of 'ViewX', " + "'ViewY' and/or 'ViewZ' into a vectorial field. " + "The new view 'NameNewView' contains it.\n\n" + "If the value of 'ViewX', 'ViewY' or 'ViewZ' is -1, " "the value of the vectorial field in the corresponding direction is 0."; } diff --git a/contrib/onelab/OnelabClients.cpp b/contrib/onelab/OnelabClients.cpp index 9a8658b50d07e8626ce018b7f31e1605c500f9fa..4b2ea7d77291d5d65ac39f7cd919ab6eb3bba4ef 100644 --- a/contrib/onelab/OnelabClients.cpp +++ b/contrib/onelab/OnelabClients.cpp @@ -122,7 +122,7 @@ std::string localNetworkSolverClient::appendArguments(){ command.append(" " + getSocketSwitch() + " " + getName() + " %s"); } else - OLMsg::Fatal("appendArguments: Unknown Action <%s>", action.c_str()); + OLMsg::Error("appendArguments: Unknown Action <%s>", action.c_str()); return command; } @@ -234,7 +234,7 @@ bool localNetworkSolverClient::run() onelab::function p; p.fromChar(message); set(p); } else - OLMsg::Fatal("FIXME query not done for this parameter type: <%s>", + OLMsg::Error("FIXME query not done for this parameter type: <%s>", message.c_str()); } break; @@ -328,7 +328,7 @@ bool localNetworkSolverClient::run() break; case GmshSocket::GMSH_ERROR: //OLMsg::Direct(1, "%-8.8s: %s", _name.c_str(), message.c_str()); - OLMsg::Fatal("%-8.8s: %s", _name.c_str(), message.c_str()); + OLMsg::Error("%-8.8s: %s", _name.c_str(), message.c_str()); break; case GmshSocket::GMSH_MERGE_FILE: break; @@ -539,7 +539,7 @@ bool remoteClient::checkIfPresentRemote(const std::string &fileName){ //std::cout << "check remote<" << cmd << ">" << std::endl; fp = POPEN(cmd.c_str(), "r"); if(fgets(cbuf, 1024, fp) == NULL){ - OLMsg::Fatal("The file <%s> is not present", fileName.c_str()); + OLMsg::Error("The file <%s> is not present", fileName.c_str()); PCLOSE(fp); return false; } @@ -567,7 +567,7 @@ bool remoteClient::syncInputFile(const std::string &wdir, const std::string &fil return mySystem(cmd); } else{ - OLMsg::Fatal("The input file <%s> is not present", fullName.c_str()); + OLMsg::Error("The input file <%s> is not present", fullName.c_str()); return false; } } @@ -581,13 +581,13 @@ bool remoteClient::syncInputFile(const std::string &wdir, const std::string &fil return mySystem(cmd); } else{ - OLMsg::Fatal("The input file <%s> is not present", fullName.c_str()); + OLMsg::Error("The input file <%s> is not present", fullName.c_str()); return false; } } else { //should be found remote if(!checkIfPresentRemote(fileName)){ - OLMsg::Fatal("The input file <%s> is not present", fileName.c_str()); + OLMsg::Error("The input file <%s> is not present", fileName.c_str()); return false; } else @@ -625,7 +625,7 @@ void MetaModel::saveCommandLines(const std::string fileName){ for(citer it = _clients.begin(); it != _clients.end(); it++) outfile << (*it)->toChar(); else - OLMsg::Fatal("The file <%s> cannot be opened",fileNameSave.c_str()); + OLMsg::Error("The file <%s> cannot be opened",fileNameSave.c_str()); outfile.close(); } @@ -677,7 +677,7 @@ void MetaModel::registerClient(const std::string &name, const std::string &type, else if(!type.compare(0,6,"encaps")) c= new EncapsulatedClient(name,cmdl,getWorkingDir()); else - OLMsg::Fatal("Unknown client type", type.c_str()); + OLMsg::Error("Unknown client type", type.c_str()); } else{ // remote client if(!type.compare(0,6,"interf")) @@ -687,7 +687,7 @@ void MetaModel::registerClient(const std::string &name, const std::string &type, else if(!type.compare(0,6,"encaps")) c= new RemoteEncapsulatedClient(name,cmdl,getWorkingDir(),host,rdir); else - OLMsg::Fatal("Unknown remote client type", type.c_str()); + OLMsg::Error("Unknown remote client type", type.c_str()); } _clients.push_back(c); } @@ -713,9 +713,10 @@ void InterfacedClient::analyze() { size_t pos; std::vector<std::string> choices; - setAction("check"); OLMsg::Info("Analyze <%s> changed=%d", getName().c_str(), onelab::server::instance()->getChanged(getName())); + setAction("check"); + getList("InputFiles", choices); for(unsigned int i = 0; i < choices.size(); i++){ if((pos=choices[i].find(onelabExtension)) != std::string::npos){ @@ -730,6 +731,7 @@ void InterfacedClient::analyze() { void InterfacedClient::convert() { size_t pos; std::vector<std::string> choices; + getList("InputFiles", choices); for(unsigned int i = 0; i < choices.size(); i++){ if((pos=choices[i].find(onelabExtension)) != std::string::npos){ @@ -740,7 +742,7 @@ void InterfacedClient::convert() { if (outfile.is_open()) convert_onefile(choices[i],outfile); else - OLMsg::Fatal("The file <%s> cannot be opened",ofileName.c_str()); + OLMsg::Error("The file <%s> cannot be opened",ofileName.c_str()); outfile.close(); } } @@ -750,9 +752,9 @@ void InterfacedClient::compute(){ std::string cmd; std::vector<std::string> choices; - OLMsg::Info("Computes <%s>", getName().c_str()); - analyze(); + if(OLMsg::GetErrorNum()) return; + OLMsg::Info("Computes <%s>", getName().c_str()); setAction("compute"); if(getList("InputFiles",choices)){ @@ -784,9 +786,9 @@ void InterfacedClient::compute(){ // NATIVE Client void NativeClient::analyze() { - setAction("check"); OLMsg::Info("Analyze <%s> changed=%d", getName().c_str(), onelab::server::instance()->getChanged(getName())); + setAction("check"); run(); } @@ -794,8 +796,9 @@ void NativeClient::compute() { std::string cmd; std::vector<std::string> choices; - OLMsg::Info("Computes <%s>", getName().c_str()); analyze(); + if(OLMsg::GetErrorNum()) return; + OLMsg::Info("Computes <%s>", getName().c_str()); setAction("compute"); if(buildRmCommand(cmd)) mySystem(cmd); @@ -823,9 +826,10 @@ void EncapsulatedClient::analyze() { size_t pos; std::vector<std::string> choices; - setAction("check"); OLMsg::Info("Analyze <%s> changed=%d", getName().c_str(), onelab::server::instance()->getChanged(getName())); + setAction("check"); + getList("InputFiles", choices); for(unsigned int i = 0; i < choices.size(); i++){ if((pos=choices[i].find(onelabExtension)) != std::string::npos){ @@ -840,6 +844,7 @@ void EncapsulatedClient::analyze() { void EncapsulatedClient::convert() { size_t pos; std::vector<std::string> choices; + getList("InputFiles", choices); for(unsigned int i = 0; i < choices.size(); i++){ if((pos=choices[i].find(onelabExtension)) != std::string::npos){ @@ -850,7 +855,7 @@ void EncapsulatedClient::convert() { if (outfile.is_open()) convert_onefile(choices[i],outfile); else - OLMsg::Fatal("The file <%s> cannot be opened",ofileName.c_str()); + OLMsg::Error("The file <%s> cannot be opened",ofileName.c_str()); outfile.close(); } } @@ -864,9 +869,9 @@ void EncapsulatedClient::compute(){ std::string cmd; std::vector<std::string> choices; - OLMsg::Info("Computes <%s>", getName().c_str()); - analyze(); + if(OLMsg::GetErrorNum()) return; + OLMsg::Info("Computes <%s>", getName().c_str()); setAction("compute"); if(getList("InputFiles",choices)){ @@ -908,9 +913,9 @@ void RemoteInterfacedClient::compute(){ std::string cmd,rmcmd; std::vector<std::string> choices; - OLMsg::Info("Computes <%s>", getName().c_str()); - analyze(); + if(OLMsg::GetErrorNum()) return; + OLMsg::Info("Computes <%s>", getName().c_str()); setAction("compute"); if(getList("InputFiles",choices)){ @@ -954,9 +959,9 @@ void RemoteNativeClient::analyze(){ std::string cmd,rmcmd; std::vector<std::string> choices; - setAction("check"); OLMsg::Info("Analyze <%s> changed=%d", getName().c_str(), onelab::server::instance()->getChanged(getName())); + setAction("check"); if(getList("InputFiles",choices)){ for(unsigned int i = 0; i < choices.size(); i++) @@ -970,8 +975,9 @@ void RemoteNativeClient::compute(){ std::string cmd,rmcmd; std::vector<std::string> choices; - OLMsg::Info("Analyze <%s> changed=%d", getName().c_str()); analyze(); + if(OLMsg::GetErrorNum()) return; + OLMsg::Info("Analyze <%s> changed=%d", getName().c_str()); setAction("compute"); if(getList("InputFiles",choices)){ @@ -1005,9 +1011,9 @@ void RemoteEncapsulatedClient::compute(){ std::string cmd,rmcmd; std::vector<std::string> choices; - OLMsg::Info("Computes <%s> changed=%d", getName().c_str()); - analyze(); + if(OLMsg::GetErrorNum()) return; + OLMsg::Info("Computes <%s> changed=%d", getName().c_str()); setAction("compute"); if(getList("InputFiles",choices)){ @@ -1115,7 +1121,7 @@ bool checkIfPresent(std::string fileName){ if (!stat(fileName.c_str(), &buf)) return true; else{ - OLMsg::Fatal("The file <%s> is not present.",fileName.c_str()); + OLMsg::Error("The file <%s> is not present.",fileName.c_str()); return false; } } @@ -1169,7 +1175,7 @@ bool isPath(const std::string &in) { size_t pos=in.find_last_not_of(" 0123456789"); if(in.compare(pos,1,"/")) - OLMsg::Fatal("The argument <%s> is not a valid path (must end with '/')",in.c_str()); + OLMsg::Error("The argument <%s> is not a valid path (must end with '/')",in.c_str()); return true; } @@ -1179,7 +1185,7 @@ bool isPath(const std::string &in) // if(col<=data[i].size()) // column.push_back(data[i][col-1]); // else -// OLMsg::Fatal("Column number (%d) out of range.",col); +// OLMsg::Error("Column number (%d) out of range.",col); // return column; // } @@ -1189,7 +1195,7 @@ double find_in_array(int lin, int col, const std::vector <std::vector <double> > if ( col>=0 && col<(int)data[lin].size() ) return data[lin][col]; } - OLMsg::Fatal("The value has not been calculated: (%d,%d) out of range",lin,col); + OLMsg::Error("The value has not been calculated: (%d,%d) out of range",lin,col); return(0); } diff --git a/contrib/onelab/OnelabMessage.cpp b/contrib/onelab/OnelabMessage.cpp index c997a1bc09c713f01095116a608cd6904784a527..8c78788b1eae2596d9ec78c1b0ecb2ac19df0392 100644 --- a/contrib/onelab/OnelabMessage.cpp +++ b/contrib/onelab/OnelabMessage.cpp @@ -51,6 +51,14 @@ static int vsnprintf(char *str, size_t size, const char *fmt, va_list ap) #define vsnprintf _vsnprintf #endif +int OLMsg::GetErrorNum(){ + return _errorCount; +} + +void OLMsg::ResetErrorNum(){ + _errorCount=0; +} + void OLMsg::Init(int argc, char **argv) { time_t now; @@ -92,12 +100,10 @@ void OLMsg::Fatal(const char *fmt, ...) fprintf(stderr, "Fatal : %s\n", str); fflush(stderr); } - - OLMsg::SetOnelabString("MetaModel/STATUS","STOP"); //FinalizeClient(); - //FinalizeOnelab(); + FinalizeOnelab(); //delete loader; - //Exit(1); + Exit(1); } void OLMsg::Error(const char *fmt, ...) @@ -145,8 +151,6 @@ void OLMsg::Warning(const char *fmt, ...) } } - - void OLMsg::Info(const char *fmt, ...) { if(_commRank || _verbosity < 3) return; diff --git a/contrib/onelab/OnelabMessage.h b/contrib/onelab/OnelabMessage.h index a933b22be8a6de48e9c749b2129672f3c1f3111e..1e7db7840d0b41d8cc83f1d546dc2564585a59b2 100644 --- a/contrib/onelab/OnelabMessage.h +++ b/contrib/onelab/OnelabMessage.h @@ -75,6 +75,8 @@ class OLMsg { /* static int GetVerbosity(){ return _verbosity; } */ /* static std::string GetLaunchDate(){ return _launchDate; } */ /* static std::string GetCommandLineArgs(){ return _commandLine; } */ + static int GetErrorNum(); + static void ResetErrorNum(); static void Fatal(const char *fmt, ...); static void Error(const char *fmt, ...); static void Warning(const char *fmt, ...); diff --git a/contrib/onelab/OnelabParser.cpp b/contrib/onelab/OnelabParser.cpp index 66c084ccb3d71bc9f7e81123c357751ca29d2feb..6b4a5cf296a9079df8d2eb14c3bc881cd1d6ae13 100644 --- a/contrib/onelab/OnelabParser.cpp +++ b/contrib/onelab/OnelabParser.cpp @@ -31,11 +31,11 @@ int enclosed(const std::string &in, std::vector<std::string> &arguments, arguments.resize(0); cursor=0; if ( (pos=in.find("(",cursor)) == std::string::npos ) - OLMsg::Fatal("Syntax error: <%s>",in.c_str()); + OLMsg::Error("Syntax error: <%s>",in.c_str()); if (pos>0){ std::cout << pos << in << std::endl; - OLMsg::Fatal("Syntax error: <%s>",in.c_str()); + OLMsg::Error("Syntax error: <%s>",in.c_str()); } unsigned int count=1; pos++; // skips '(' @@ -46,18 +46,18 @@ int enclosed(const std::string &in, std::vector<std::string> &arguments, else if(in[pos]==',' && (count==1)) { arguments.push_back(removeBlanks(in.substr(cursor,pos-cursor))); if(count!=1) - OLMsg::Fatal("Syntax error: mismatched parenthesis <%s>",in.c_str()); + OLMsg::Error("Syntax error: mismatched parenthesis <%s>",in.c_str()); cursor=pos+1; // skips ',' } else if(in[pos]==';') - OLMsg::Fatal("Syntax error: unterminated sentence <%s>",in.c_str()); + OLMsg::Error("Syntax error: unterminated sentence <%s>",in.c_str()); pos++; } while( count && (pos!=std::string::npos) ); // count is 0 when the closing brace is found. if(count) - OLMsg::Fatal("Syntax error: <%s>",in.c_str()); + OLMsg::Error("Syntax error: <%s>",in.c_str()); else arguments.push_back(removeBlanks(in.substr(cursor,pos-1-cursor))); end=pos; @@ -70,7 +70,7 @@ int extractLogic(const std::string &in, std::vector<std::string> &arguments){ arguments.resize(0); cursor=0; if ( (pos=in.find("(",cursor)) == std::string::npos ) - OLMsg::Fatal("Syntax error: <%s>",in.c_str()); + OLMsg::Error("Syntax error: <%s>",in.c_str()); unsigned int count=1; pos++; // skips '(' @@ -81,7 +81,7 @@ int extractLogic(const std::string &in, std::vector<std::string> &arguments){ if( (in[pos]=='<') || (in[pos]=='=') || (in[pos]=='>') || (in[pos]=='!') ){ arguments.push_back(removeBlanks(in.substr(cursor,pos-cursor))); if(count!=1) - OLMsg::Fatal("Syntax error: <%s>",in.c_str()); + OLMsg::Error("Syntax error: <%s>",in.c_str()); cursor=pos; if(in[pos+1]=='='){ arguments.push_back(in.substr(cursor,2)); @@ -97,12 +97,12 @@ int extractLogic(const std::string &in, std::vector<std::string> &arguments){ // count is 0 when the closing brace is found. if(count) - OLMsg::Fatal("Syntax error: mismatched parenthesis in <%s>",in.c_str()); + OLMsg::Error("Syntax error: mismatched parenthesis in <%s>",in.c_str()); else arguments.push_back(removeBlanks(in.substr(cursor,pos-1-cursor))); if((arguments.size()!=1) && (arguments.size()!=3)) - OLMsg::Fatal("Syntax error: <%s>",in.c_str()); + OLMsg::Error("Syntax error: <%s>",in.c_str()); return arguments.size(); } @@ -112,43 +112,18 @@ int extract(const std::string &in, std::string ¶mName, size_t pos, cursor; cursor=0; if ( (pos=in.find(".",cursor)) == std::string::npos ) - OLMsg::Fatal("Syntax error: <%s>",in.c_str()); + OLMsg::Error("Syntax error: <%s>",in.c_str()); else paramName.assign(sanitize(in.substr(cursor,pos-cursor))); cursor = pos+1; // skips '.' if ( (pos=in.find("(",cursor)) == std::string::npos ) - OLMsg::Fatal("Syntax error: <%s>",in.c_str()); + OLMsg::Error("Syntax error: <%s>",in.c_str()); else action.assign(sanitize(in.substr(cursor,pos-cursor))); cursor = pos; return enclosed(in.substr(cursor),arguments,pos); } -bool extractRange(const std::string &in, std::vector<double> &arguments){ - // syntax: a:b:c or a:b#n - size_t pos, cursor; - arguments.resize(0); - cursor=0; - if ( (pos=in.find(":",cursor)) == std::string::npos ) - OLMsg::Fatal("Syntax error in range <%s>",in.c_str()); - else{ - arguments.push_back(atof(in.substr(cursor,pos-cursor).c_str())); - } - 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())); - } - 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)); - } - else - OLMsg::Fatal("Syntax error in range <%s>",in.c_str()); - return (arguments.size()==3); -} - std::string extractExpandPattern(const std::string& str){ size_t posa, posb; posa=str.find_first_of("\"\'<"); @@ -158,7 +133,7 @@ std::string extractExpandPattern(const std::string& str){ if(posa!=std::string::npos) pattern.replace(posa,5,","); if(pattern.size()!=3) - OLMsg::Fatal("Incorrect expand pattern <%s>", + OLMsg::Error("Incorrect expand pattern <%s>", str.c_str()); return pattern; } @@ -186,7 +161,7 @@ std::string localSolverClient::resolveGetVal(std::string line) { cursor = pos+olkey::getValue.length(); int NumArg=enclosed(line.substr(cursor),arguments,pos); if(NumArg<1) - OLMsg::Fatal("Misformed %s statement: <%s>", + OLMsg::Error("Misformed %s statement: <%s>", olkey::getValue.c_str(),line.c_str()); std::string paramName=longName(arguments[0]); get(numbers,paramName); @@ -236,7 +211,7 @@ std::string localSolverClient::resolveGetVal(std::string line) { buff.assign(Num.str()); } else - OLMsg::Fatal("Unknown action <%s> in %s statement", + OLMsg::Error("Unknown action <%s> in %s statement", action.c_str(),olkey::getValue.c_str()); } else if(!name.compare("range")) { @@ -247,7 +222,7 @@ std::string localSolverClient::resolveGetVal(std::string line) { if( (stp == 0) || (min == -onelab::parameter::maxNumber()) || (max == onelab::parameter::maxNumber()) ) - OLMsg::Fatal("Invalid range description for parameter <%s>", + OLMsg::Error("Invalid range description for parameter <%s>", paramName.c_str()); if(!action.compare("size")) { buff.assign(ftoa(fabs((max-min)/stp))); @@ -262,7 +237,7 @@ std::string localSolverClient::resolveGetVal(std::string line) { else if(!action.compare("expand")) { } else - OLMsg::Fatal("Unknown action <%s> in %s statement", + OLMsg::Error("Unknown action <%s> in %s statement", action.c_str(),olkey::getValue.c_str()); } } @@ -272,7 +247,7 @@ std::string localSolverClient::resolveGetVal(std::string line) { if (strings.size()) buff.assign(strings[0].getValue()); else - OLMsg::Fatal("resolveGetVal: unknown variable: <%s>",paramName.c_str()); + OLMsg::Error("resolveGetVal: unknown variable: <%s>",paramName.c_str()); } line.replace(pos0,cursor+pos-pos0,buff); cursor=pos0+buff.length(); @@ -284,7 +259,7 @@ std::string localSolverClient::resolveGetVal(std::string line) { size_t pos0=pos; cursor=pos+olkey::mathex.length(); if(enclosed(line.substr(cursor),arguments,pos) != 1) - OLMsg::Fatal("Misformed %s statement: <%s>", + OLMsg::Error("Misformed %s statement: <%s>", olkey::mathex.c_str(),line.c_str()); //std::cout << "MathEx evaluates now <"<< arguments[0]<< "> " << std::endl; smlib::mathex* mathExp = new smlib::mathex(); @@ -296,7 +271,7 @@ std::string localSolverClient::resolveGetVal(std::string line) { // Check now wheter the line still contains OL. if ( (pos=line.find(olkey::label)) != std::string::npos) - OLMsg::Fatal("Unidentified onelab command in <%s>",line.c_str()); + OLMsg::Error("Unidentified onelab command in <%s>",line.c_str()); return line; } @@ -324,13 +299,38 @@ bool localSolverClient::resolveLogicExpr(std::vector<std::string> arguments) { else if (!arguments[1].compare("!=")) condition = (val1!=val2); else - OLMsg::Fatal("Unknown logical operator <%s>", arguments[1].c_str()); + OLMsg::Error("Unknown logical operator <%s>", arguments[1].c_str()); } else - OLMsg::Fatal("Invalid logical expression"); + OLMsg::Error("Invalid logical expression"); return condition; } +bool extractRange(const std::string &in, std::vector<double> &arguments){ + // syntax: a:b:c or a:b#n + 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())); + } + 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())); + } + else if ( (pos=in.find("X",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)); + } + else + OLMsg::Error("Syntax error in range <%s>",in.c_str()); + return (arguments.size()==3); +} + void localSolverClient::parse_sentence(std::string line) { size_t pos,cursor; std::string name,action,path; @@ -402,7 +402,7 @@ void localSolverClient::parse_sentence(std::string line) { else if(!action.compare("radioButton")) { // syntax: paramName.radioButton(val,path,label) if(arguments[0].empty()) - OLMsg::Fatal("No value given for param <%s>",name.c_str()); + OLMsg::Error("No value given for param <%s>",name.c_str()); double val=atof(arguments[0].c_str()); if((arguments.size()>1) && isPath(arguments[1])) name.assign(arguments[1] + name); @@ -429,7 +429,7 @@ void localSolverClient::parse_sentence(std::string line) { // set the range of an existing number // syntax: paramName.range({a:b:c|a:b#n|min,max,step}) if(arguments[0].empty()) - OLMsg::Fatal("No argument given for MinMax <%s>",name.c_str()); + OLMsg::Error("No argument given for MinMax <%s>",name.c_str()); name.assign(longName(name)); get(numbers,name); if(numbers.size()){ // parameter must exist @@ -447,7 +447,7 @@ void localSolverClient::parse_sentence(std::string line) { numbers[0].setStep(atof(arguments[2].c_str())); } else - OLMsg::Fatal("Wrong number of arguments for MinMax <%s>",name.c_str()); + OLMsg::Error("Wrong number of arguments for MinMax <%s>",name.c_str()); } set(numbers[0]); } @@ -470,7 +470,7 @@ void localSolverClient::parse_sentence(std::string line) { set(strings[0]); } else{ - OLMsg::Fatal("The parameter <%s> does not exist",name.c_str()); + OLMsg::Error("The parameter <%s> does not exist",name.c_str()); } } } @@ -499,7 +499,7 @@ void localSolverClient::parse_sentence(std::string line) { set(strings[0]); } else{ - OLMsg::Fatal("The parameter <%s> does not exist",name.c_str()); + OLMsg::Error("The parameter <%s> does not exist",name.c_str()); } } } @@ -508,7 +508,7 @@ void localSolverClient::parse_sentence(std::string line) { get(numbers,name); if(numbers.size()){ // parameter must exist if(arguments.size() % 2) - OLMsg::Fatal("Nb of labels does not match nb of choices for <%s>", + OLMsg::Error("Nb of labels does not match nb of choices for <%s>", name.c_str()); std::vector<double> choices=numbers[0].getChoices(); for(unsigned int i = 0; i < arguments.size(); i=i+2){ @@ -521,7 +521,7 @@ void localSolverClient::parse_sentence(std::string line) { set(numbers[0]); } else - OLMsg::Fatal("The number <%s> does not exist",name.c_str()); + OLMsg::Error("The number <%s> does not exist",name.c_str()); } else if(!action.compare("setValue")){ // force change on server name.assign(longName(name)); @@ -543,13 +543,13 @@ void localSolverClient::parse_sentence(std::string line) { set(strings[0]); } else{ - OLMsg::Fatal("The parameter <%s> does not exist",name.c_str()); + OLMsg::Error("The parameter <%s> does not exist",name.c_str()); } } } else if(!action.compare("setVisible")){ if(arguments[0].empty()) - OLMsg::Fatal("Missing argument SetVisible <%s>",name.c_str()); + OLMsg::Error("Missing argument SetVisible <%s>",name.c_str()); name.assign(longName(name)); get(numbers,name); if(numbers.size()){ @@ -563,13 +563,13 @@ void localSolverClient::parse_sentence(std::string line) { set(strings[0]); } else{ - OLMsg::Fatal("The parameter <%s> does not exist",name.c_str()); + OLMsg::Error("The parameter <%s> does not exist",name.c_str()); } } } else if(!action.compare("setReadOnly")){ if(arguments[0].empty()) - OLMsg::Fatal("Missing argument SetReadOnly <%s>",name.c_str()); + OLMsg::Error("Missing argument SetReadOnly <%s>",name.c_str()); name.assign(longName(name)); get(numbers,name); if(numbers.size()){ @@ -583,7 +583,7 @@ void localSolverClient::parse_sentence(std::string line) { set(strings[0]); } else{ - OLMsg::Fatal("The parameter <%s> does not exist",name.c_str()); + OLMsg::Error("The parameter <%s> does not exist",name.c_str()); } } } @@ -603,13 +603,13 @@ void localSolverClient::parse_sentence(std::string line) { set(strings[0]); } else{ - OLMsg::Fatal("The parameter <%s> does not exist",name.c_str()); + OLMsg::Error("The parameter <%s> does not exist",name.c_str()); } } } else if(!action.compare("setAttribute")){ if(arguments.size() !=2 ) - OLMsg::Fatal("SetAttribute <%s> needs two arguments %d", + OLMsg::Error("SetAttribute <%s> needs two arguments %d", name.c_str(), arguments.size()); name.assign(longName(name)); get(numbers,name); @@ -625,7 +625,7 @@ void localSolverClient::parse_sentence(std::string line) { set(strings[0]); } else{ - OLMsg::Fatal("The parameter <%s> does not exist",name.c_str()); + OLMsg::Error("The parameter <%s> does not exist",name.c_str()); } } } @@ -690,19 +690,19 @@ void localSolverClient::parse_oneline(std::string line, std::ifstream &infile) { else if(NumArg==2) modify_tags(arguments[0],arguments[1]); else - OLMsg::Fatal("Misformed <%s> statement", olkey::deflabel.c_str()); + OLMsg::Error("Misformed <%s> statement", olkey::deflabel.c_str()); } else if( (pos=line.find(olkey::begin)) != std::string::npos) { // onelab.begin if (!parse_block(infile)) - OLMsg::Fatal("Misformed <%s> block <%s>", + OLMsg::Error("Misformed <%s> block <%s>", olkey::begin.c_str(),olkey::end.c_str()); } else if ( (pos=line.find(olkey::iftrue)) != std::string::npos) { // onelab.iftrue cursor = pos+olkey::iftrue.length(); if(enclosed(line.substr(cursor),arguments,pos)<1) - OLMsg::Fatal("Misformed <%s> statement: (%s)", + OLMsg::Error("Misformed <%s> statement: (%s)", olkey::iftrue.c_str(),line.c_str()); bool condition = false; get(strings,longName(arguments[0])); @@ -713,18 +713,18 @@ void localSolverClient::parse_oneline(std::string line, std::ifstream &infile) { if (numbers.size()) condition = (bool) numbers[0].getValue(); else - OLMsg::Fatal("Unknown parameter <%s> in <%s> statement", + OLMsg::Error("Unknown parameter <%s> in <%s> statement", arguments[0].c_str(),olkey::iftrue.c_str()); } if (!parse_ifstatement(infile,condition)) - OLMsg::Fatal("Misformed <%s> statement: <%s>", + OLMsg::Error("Misformed <%s> statement: <%s>", olkey::iftrue.c_str(),arguments[0].c_str()); } else if ( (pos=line.find(olkey::ifntrue)) != std::string::npos) { // onelab.ifntrue cursor = pos+olkey::ifntrue.length(); if(enclosed(line.substr(cursor),arguments,pos)<1) - OLMsg::Fatal("Misformed <%s> statement: (%s)", + OLMsg::Error("Misformed <%s> statement: (%s)", olkey::ifntrue.c_str(),line.c_str()); bool condition = false; get(strings,longName(arguments[0])); @@ -735,12 +735,12 @@ void localSolverClient::parse_oneline(std::string line, std::ifstream &infile) { if (numbers.size()) condition = (bool) numbers[0].getValue(); else - OLMsg::Fatal("Unknown parameter <%s> in <%s> statement", + OLMsg::Error("Unknown parameter <%s> in <%s> statement", arguments[0].c_str(),olkey::ifntrue.c_str()); } std::cout << "cond=" << condition << std::endl; if (!parse_ifstatement(infile,!condition)) - OLMsg::Fatal("Misformed <%s> statement: <%s>", + OLMsg::Error("Misformed <%s> statement: <%s>", olkey::ifntrue.c_str(),arguments[0].c_str()); } else if ( (pos=line.find(olkey::ifcond)) != std::string::npos) { @@ -749,7 +749,7 @@ void localSolverClient::parse_oneline(std::string line, std::ifstream &infile) { extractLogic(line.substr(cursor),arguments); bool condition= resolveLogicExpr(arguments); if (!parse_ifstatement(infile,condition)){ - OLMsg::Fatal("Misformed %s statement: <%s>", + OLMsg::Error("Misformed %s statement: <%s>", olkey::ifcond.c_str(), line.c_str()); } } @@ -757,7 +757,7 @@ void localSolverClient::parse_oneline(std::string line, std::ifstream &infile) { // onelab.include cursor = pos+olkey::include.length(); if(enclosed(line.substr(cursor),arguments,pos)<1) - OLMsg::Fatal("Misformed <%s> statement: (%s)", + OLMsg::Error("Misformed <%s> statement: (%s)", olkey::include.c_str(),line.c_str()); parse_onefile(arguments[0]); } @@ -765,7 +765,7 @@ void localSolverClient::parse_oneline(std::string line, std::ifstream &infile) { // onelab.message cursor = pos+olkey::message.length(); if(enclosed(line.substr(cursor),arguments,pos)<1) - OLMsg::Fatal("Misformed <%s> statement: (%s)", + OLMsg::Error("Misformed <%s> statement: (%s)", olkey::message.c_str(),line.c_str()); std::string msg = resolveGetVal(arguments[0]); OLMsg::Info("%s",msg.c_str()); @@ -774,7 +774,7 @@ void localSolverClient::parse_oneline(std::string line, std::ifstream &infile) { // onelab.showParam cursor = pos+olkey::showParam.length(); if(enclosed(line.substr(cursor),arguments,pos)<1) - OLMsg::Fatal("Misformed <%s> statement: (%s)", + OLMsg::Error("Misformed <%s> statement: (%s)", olkey::showParam.c_str(),line.c_str()); for(unsigned int i = 0; i < arguments.size(); i++){ std::string lname=longName(arguments[i]); @@ -787,7 +787,7 @@ void localSolverClient::parse_oneline(std::string line, std::ifstream &infile) { if (strings.size()) msg.assign(strings[0].toChar()); else - OLMsg::Fatal("Unknown parameter <%s> in <%s> statement", + OLMsg::Error("Unknown parameter <%s> in <%s> statement", arguments[i].c_str(),olkey::showParam.c_str()); } for(unsigned int j = 0; j < msg.size(); j++) @@ -799,7 +799,7 @@ void localSolverClient::parse_oneline(std::string line, std::ifstream &infile) { // onelab.showGmsh cursor = pos+olkey::showGmsh.length(); if(enclosed(line.substr(cursor),arguments,pos)<1) - OLMsg::Fatal("Misformed <%s> statement: (%s)", + OLMsg::Error("Misformed <%s> statement: (%s)", olkey::showGmsh.c_str(),line.c_str()); std::string fileName=resolveGetVal(arguments[0]); OLMsg::MergeFile(fileName); @@ -808,7 +808,7 @@ void localSolverClient::parse_oneline(std::string line, std::ifstream &infile) { // onelab.dump cursor = pos+olkey::dump.length(); if(enclosed(line.substr(cursor),arguments,pos)<1) - OLMsg::Fatal("Misformed <%s> statement: (%s)", + OLMsg::Error("Misformed <%s> statement: (%s)", olkey::dump.c_str(),line.c_str()); onelab::server::instance()->toFile(resolveGetVal(arguments[0])); } @@ -842,11 +842,11 @@ void localSolverClient::parse_oneline(std::string line, std::ifstream &infile) { // append the next line getline (infile,line); if((pos=line.find_first_not_of(" \t"))==std::string::npos){ - OLMsg::Fatal("Empty line not allowed within a command <%s>", + OLMsg::Error("Empty line not allowed within a command <%s>", cmds.c_str()); } else if(!line.compare(pos,olkey::comment.size(),olkey::comment)){ - OLMsg::Fatal("Comment lines not allowed within a command <%s>", + OLMsg::Error("Comment lines not allowed within a command <%s>", cmds.c_str()); } NbLines++; // command should not span over more than 10 lines @@ -855,7 +855,7 @@ void localSolverClient::parse_oneline(std::string line, std::ifstream &infile) { break; } while (infile.good() && NbLines<=10); if(NbLines>=10) - OLMsg::Fatal("Command <%s> should not span over more than 10 lines", + OLMsg::Error("Command <%s> should not span over more than 10 lines", cmds.c_str()); parse_sentence(cmds); } @@ -869,7 +869,7 @@ void localSolverClient::parse_oneline(std::string line, std::ifstream &infile) { // onelab.getRegion: nothing to do } else if( (pos=line.find(olkey::label)) != std::string::npos) { - OLMsg::Fatal("Unknown ONELAB keyword in <%s>",line.c_str()); + OLMsg::Error("Unknown ONELAB keyword in <%s>",line.c_str()); } else{ // not a onelab line, skip @@ -933,7 +933,7 @@ void localSolverClient::parse_onefile(std::string fileName, bool mandatory) { } else if(mandatory) - OLMsg::Fatal("The file <%s> does not exist",fullName.c_str()); + OLMsg::Error("The file <%s> does not exist",fullName.c_str()); else OLMsg::Info("The file <%s> does not exist",fullName.c_str()); } @@ -988,7 +988,7 @@ void localSolverClient::convert_oneline(std::string line, std::ifstream &infile, else if(NumArg==2) modify_tags(arguments[0],arguments[1]); else - OLMsg::Fatal("Misformed <%s> statement", olkey::deflabel.c_str()); + OLMsg::Error("Misformed <%s> statement", olkey::deflabel.c_str()); } else if( (pos=line.find(olkey::begin)) != std::string::npos) { // onelab.begin @@ -996,7 +996,7 @@ void localSolverClient::convert_oneline(std::string line, std::ifstream &infile, getline (infile,line); if( (pos=line.find(olkey::end)) != std::string::npos) return; } - OLMsg::Fatal("Misformed <%s> block <%s>", + OLMsg::Error("Misformed <%s> block <%s>", olkey::begin.c_str(),olkey::end.c_str()); } else if ( (pos=line.find(olkey::iftrue)) != std::string::npos) { @@ -1005,7 +1005,7 @@ void localSolverClient::convert_oneline(std::string line, std::ifstream &infile, // pos=line.find_first_of(')',cursor)+1; // if(enclosed(line.substr(cursor,pos-cursor),arguments)<1) if(enclosed(line.substr(cursor),arguments,pos)<1) - OLMsg::Fatal("Misformed <%s> statement: (%s)", + OLMsg::Error("Misformed <%s> statement: (%s)", olkey::iftrue.c_str(),line.c_str()); bool condition = false; get(strings,longName(arguments[0])); @@ -1016,11 +1016,11 @@ void localSolverClient::convert_oneline(std::string line, std::ifstream &infile, if (numbers.size()) condition = (bool) numbers[0].getValue(); else - OLMsg::Fatal("Unknown parameter <%s> in <%s> statement", + OLMsg::Error("Unknown parameter <%s> in <%s> statement", arguments[0].c_str(),olkey::iftrue.c_str()); } if (!convert_ifstatement(infile,outfile,condition)) - OLMsg::Fatal("Misformed <%s> statement: %s", + OLMsg::Error("Misformed <%s> statement: %s", olkey::iftrue.c_str(),arguments[0].c_str()); } else if ( (pos=line.find(olkey::ifntrue)) != std::string::npos) { @@ -1029,7 +1029,7 @@ void localSolverClient::convert_oneline(std::string line, std::ifstream &infile, // pos=line.find_first_of(')',cursor)+1; // if(enclosed(line.substr(cursor,pos-cursor),arguments)<1) if(enclosed(line.substr(cursor),arguments,pos)<1) - OLMsg::Fatal("Misformed <%s> statement: (%s)", + OLMsg::Error("Misformed <%s> statement: (%s)", olkey::ifntrue.c_str(),line.c_str()); bool condition = false; get(strings,longName(arguments[0])); @@ -1040,11 +1040,11 @@ void localSolverClient::convert_oneline(std::string line, std::ifstream &infile, if (numbers.size()) condition = (bool) numbers[0].getValue(); else - OLMsg::Fatal("Unknown parameter <%s> in <%s> statement", + OLMsg::Error("Unknown parameter <%s> in <%s> statement", arguments[0].c_str(),olkey::ifntrue.c_str()); } if (!convert_ifstatement(infile,outfile,!condition)) - OLMsg::Fatal("Misformed <%s> statement: %s", + OLMsg::Error("Misformed <%s> statement: %s", olkey::ifntrue.c_str(),arguments[0].c_str()); } else if ( (pos=line.find(olkey::ifcond)) != std::string::npos) { @@ -1053,13 +1053,13 @@ void localSolverClient::convert_oneline(std::string line, std::ifstream &infile, extractLogic(line.substr(cursor),arguments); bool condition= resolveLogicExpr(arguments); if (!convert_ifstatement(infile,outfile,condition)) - OLMsg::Fatal("Misformed %s statement: <%s>", line.c_str()); + OLMsg::Error("Misformed %s statement: <%s>", line.c_str()); } else if ( (pos=line.find(olkey::include)) != std::string::npos) { // onelab.include cursor = pos+olkey::include.length(); if(enclosed(line.substr(cursor),arguments,pos)<1) - OLMsg::Fatal("Misformed <%s> statement: (%s)", + OLMsg::Error("Misformed <%s> statement: (%s)", olkey::include.c_str(),line.c_str()); convert_onefile(arguments[0],outfile); } @@ -1067,7 +1067,7 @@ void localSolverClient::convert_oneline(std::string line, std::ifstream &infile, // onelab.message cursor = pos+olkey::message.length(); if(enclosed(line.substr(cursor),arguments,pos)<1) - OLMsg::Fatal("Misformed <%s> statement: (%s)", + OLMsg::Error("Misformed <%s> statement: (%s)", olkey::message.c_str(),line.c_str()); std::string msg = resolveGetVal(arguments[0]); OLMsg::Info("%s",msg.c_str()); @@ -1116,14 +1116,14 @@ void localSolverClient::convert_oneline(std::string line, std::ifstream &infile, buff.append(1,pattern[2]); } else - OLMsg::Fatal("Unknown %s action: <%s>", + OLMsg::Error("Unknown %s action: <%s>", olkey::getRegion.c_str(), arguments[1].c_str()); } else - OLMsg::Fatal("Unknown region: <%s>",paramName.c_str()); + OLMsg::Error("Unknown region: <%s>",paramName.c_str()); } else - OLMsg::Fatal("Misformed <%s> statement: (%s)", + OLMsg::Error("Misformed <%s> statement: (%s)", olkey::getRegion.c_str(),line.c_str()); line.replace(pos0,cursor+pos-pos0,buff); cursor=pos0+buff.length(); @@ -1131,7 +1131,7 @@ void localSolverClient::convert_oneline(std::string line, std::ifstream &infile, outfile << line << std::endl; } else if ( (pos=line.find(olkey::label)) != std::string::npos){ - OLMsg::Fatal("Unidentified onelab command in <%s>",line.c_str()); + OLMsg::Error("Unidentified onelab command in <%s>",line.c_str()); } else{ outfile << line << std::endl; @@ -1151,13 +1151,13 @@ void localSolverClient::convert_onefile(std::string fileName, std::ofstream &out infile.close(); } else - OLMsg::Fatal("The file %s cannot be opened",fullName.c_str()); + OLMsg::Error("The file %s cannot be opened",fullName.c_str()); } void localSolverClient::client_sentence(const std::string &name, const std::string &action, const std::vector<std::string> &arguments) { - OLMsg::Fatal("The action <%s> is unknown in this context",action.c_str()); + OLMsg::Error("The action <%s> is unknown in this context",action.c_str()); } void MetaModel::client_sentence(const std::string &name, @@ -1212,7 +1212,7 @@ void MetaModel::client_sentence(const std::string &name, if((c=findClientByName(name))) c->setWorkingDir(c->getWorkingDir()+arguments[0]); else - OLMsg::Fatal("Unknown client <%s>", name.c_str()); + OLMsg::Error("Unknown client <%s>", name.c_str()); } else if(!action.compare("active")){ localSolverClient *c; @@ -1220,7 +1220,7 @@ void MetaModel::client_sentence(const std::string &name, if((c=findClientByName(name))) c->setActive(atof( resolveGetVal(arguments[0]).c_str() )); else - OLMsg::Fatal("Unknown client <%s>", name.c_str()); + OLMsg::Error("Unknown client <%s>", name.c_str()); } else OLMsg::Error("No argument for <%s.Active> statement", name.c_str()); @@ -1299,7 +1299,7 @@ void MetaModel::client_sentence(const std::string &name, bool changed = onelab::server::instance()->getChanged(c->getName()); bool started = isStarted(changed); - std::cout << c->getName() << " active=" << c->getActive() << " changed=" << changed << " started=" << started << std::endl; + std::cout << c->getName() << " active=" << c->getActive() << " changed=" << changed << " started=" << started << " errors=" << OLMsg::GetErrorNum() << std::endl; if(started) c->compute(); } } @@ -1336,7 +1336,7 @@ void MetaModel::client_sentence(const std::string &name, } } else - OLMsg::Fatal("Wrong number of arguments <%d> for <%s>", + OLMsg::Error("Wrong number of arguments <%d> for <%s>", arguments.size(), action.c_str()); } // else if(!action.compare("check")){ @@ -1346,7 +1346,7 @@ void MetaModel::client_sentence(const std::string &name, // c->analyze(); // } // else - // OLMsg::Fatal("Unknown client <%s>", name.c_str()); + // OLMsg::Error("Unknown client <%s>", name.c_str()); // } else if(!action.compare("alwaysCompute")){ if(isTodo(ANALYZE)){ @@ -1358,7 +1358,7 @@ void MetaModel::client_sentence(const std::string &name, } } else - OLMsg::Fatal("Unknown client <%s>", name.c_str()); + OLMsg::Error("Unknown client <%s>", name.c_str()); } else if(!action.compare("merge")){ if(isTodo(COMPUTE)){ @@ -1391,5 +1391,5 @@ void MetaModel::client_sentence(const std::string &name, } } else - OLMsg::Fatal("Unknown action <%s>",action.c_str()); + OLMsg::Error("Unknown action <%s>",action.c_str()); } diff --git a/contrib/onelab/metamodel.cpp b/contrib/onelab/metamodel.cpp index a70e0aba6b1ffdaacbe66185b79ba9babef76521..d8115671616c0849d995ad3047affae5bf3af9be 100644 --- a/contrib/onelab/metamodel.cpp +++ b/contrib/onelab/metamodel.cpp @@ -13,12 +13,12 @@ void initializeMetamodel(const std::string &loaderName, onelab::client *client, OLMsg::SetLoaderName(loaderName); OLMsg::SetOnelabClient(client); OLMsg::SetGuiWaitFunction(gui_wait_fct); - } int metamodel(const std::string &action){ OLMsg::Info("Start metamodel"); OLMsg::hasGmsh = OLMsg::GetOnelabNumber("IsMetamodel"); + OLMsg::ResetErrorNum(); parseMode todo; if(action == "initialize") @@ -30,7 +30,7 @@ int metamodel(const std::string &action){ } else{ todo = EXIT; - OLMsg::Fatal("Unknown action <%s>", action.c_str()); + OLMsg::Error("Unknown action <%s>", action.c_str()); } std::string modelName = OLMsg::GetOnelabString("Arguments/FileName"); @@ -60,13 +60,17 @@ int metamodel(const std::string &action){ myModel->compute(); } else - OLMsg::Fatal("Main: Unknown Action <%d>", todo); + OLMsg::Error("Main: Unknown Action <%d>", todo); delete myModel; int reload=OLMsg::GetOnelabNumber("Gmsh/NeedReloadGeom"); + int errors=OLMsg::GetErrorNum(); OLMsg::SetOnelabNumber("Gmsh/NeedReloadGeom",0,false); - OLMsg::Info("Leave metamodel - need reload=%d",reload); + if(errors) + OLMsg::Error("Leave metamodel - %d errors",errors); + else + OLMsg::Info("Leave metamodel - need reload=%d",reload); OLMsg::Info("=============================================="); return reload;