--- trunk/src/io/Globals.cpp 2005/10/14 21:43:13 672 +++ trunk/src/io/Globals.cpp 2005/10/17 23:13:44 681 @@ -65,9 +65,8 @@ parameters_.insert(std::make_pair(std::string(KEYWORD), &NAME)); #define CheckParameter(NAME, CONSTRAINT) \ - if (!NAME.empty()) { if (!(CONSTRAINT)(NAME.getData())) std::cout <<"Error in parsing " << NAME.getKeyword() << " : "<< (CONSTRAINT).getConstraintDescription() << std::endl; } + if (!NAME.empty()) { if (!(CONSTRAINT)(NAME.getData())) { sprintf(painCave.errMsg,"Error in checking %s : should be %s\n",NAME.getKeyword().c_str(),(CONSTRAINT).getConstraintDescription().c_str()); painCave.isFatal = 1; painCave.severity = OOPSE_ERROR; simError();} } - Globals::Globals(){ DefineParameter(ForceField, "forceField") @@ -123,7 +122,6 @@ Globals::Globals(){ DefineOptionalParameter(PrintPressureTensor, "printPressureTensor"); DefineOptionalParameter(ElectrostaticSummationMethod, "electrostaticSummationMethod"); DefineOptionalParameter(CutoffPolicy, "cutoffPolicy"); - DefineOptionalParameter(StatFileFormat, "statFileFormat"); DefineOptionalParameterWithDefaultValue(MixingRule, "mixingRule", "standard"); DefineOptionalParameterWithDefaultValue(UsePeriodicBoundaryConditions, "usePeriodicBoundaryConditions", true); @@ -138,40 +136,48 @@ Globals::Globals(){ DefineOptionalParameterWithDefaultValue(DampingAlpha, "dampingAlpha", 1.5); DefineOptionalParameterWithDefaultValue(CompressDumpFile, "compressDumpFile", 0); DefineOptionalParameterWithDefaultValue(SkinThickness, "skinThickness", 1.0); + DefineOptionalParameterWithDefaultValue(StatFileFormat, "statFileFormat", "TIME|TOTAL_ENERGY|POTENTIAL_ENERGY|KINETIC_ENERGY|TEMPERATURE|PRESSURE|VOLUME|CONSERVED_QUANTITY"); + } int Globals::globalAssign( event* the_event ){ - + char errorMessage[65535]; int key; - int token; interface_assign_type the_type = the_event->evt.asmt.asmt_type; char* lhs = the_event->evt.asmt.lhs; std::string keyword(lhs); - bool result; + bool result = false; - + /**@todo fix memory leak */ ParamMap::iterator i =parameters_.find(keyword); if (i != parameters_.end()) { if( the_type == STRING ){ result = i->second->setData(std::string(the_event->evt.asmt.rhs.sval)); if (!result ) { - sprintf(the_event->err_msg, "Error in parsing meta-data file!\n\t%s must be a string.\n", keyword.c_str() ); + sprintf(errorMessage, "Error in parsing %s: expect %s, but get a string \"%s\".\n", keyword.c_str(), i->second->getParamType().c_str(), the_event->evt.asmt.rhs.sval); + the_event->err_msg = strdup(errorMessage); } } else if( the_type == DOUBLE ){ result = i->second->setData(the_event->evt.asmt.rhs.dval); if (!result ) - sprintf(the_event->err_msg, "Error in parsing meta-data file!\n\t%s must be a double.\n", keyword.c_str() ); + sprintf(errorMessage, "Error in parsing %s: expect %s, but get a double %f.\n", keyword.c_str(), i->second->getParamType().c_str(), the_event->evt.asmt.rhs.dval ); + the_event->err_msg = strdup(errorMessage); } else if (the_type == INT ){ result = i->second->setData(the_event->evt.asmt.rhs.ival); if (!result ) - sprintf(the_event->err_msg, "Error in parsing meta-data file!\n\t%s must be an int.\n", keyword.c_str() ); + sprintf(errorMessage, "Error in parsing %s: expect %s, but get an int %d.\n", keyword.c_str(), i->second->getParamType().c_str(), the_event->evt.asmt.rhs.ival ); + the_event->err_msg = strdup(errorMessage); } else { - + sprintf(errorMessage, "Internal error of parser\n"); + the_event->err_msg = strdup(errorMessage); } + } else { + sprintf(errorMessage, "%s is an unrecognized keyword\n", keyword.c_str() ); + the_event->err_msg = strdup(errorMessage); } if (keyword == "nComponents" && getNComponents() > 0) {