# | Line 65 | Line 65 | |
---|---|---|
65 | parameters_.insert(std::make_pair(std::string(KEYWORD), &NAME)); | |
66 | ||
67 | #define CheckParameter(NAME, CONSTRAINT) \ | |
68 | < | if (!NAME.empty()) { if (!(CONSTRAINT)(NAME.getData())) std::cout <<"Error in parsing " << NAME.getKeyword() << " : "<< (CONSTRAINT).getConstraintDescription() << std::endl; } |
68 | > | 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();} } |
69 | ||
70 | – | |
70 | Globals::Globals(){ | |
71 | ||
72 | DefineParameter(ForceField, "forceField") | |
# | Line 122 | Line 121 | Globals::Globals(){ | |
121 | DefineOptionalParameter(SurfaceTension, "surfaceTension"); | |
122 | DefineOptionalParameter(PrintPressureTensor, "printPressureTensor"); | |
123 | DefineOptionalParameter(ElectrostaticSummationMethod, "electrostaticSummationMethod"); | |
124 | + | DefineOptionalParameter(ScreeningMethod, "screeningMethod"); |
125 | DefineOptionalParameter(CutoffPolicy, "cutoffPolicy"); | |
126 | – | DefineOptionalParameter(StatFileFormat, "statFileFormat"); |
126 | ||
127 | DefineOptionalParameterWithDefaultValue(MixingRule, "mixingRule", "standard"); | |
128 | DefineOptionalParameterWithDefaultValue(UsePeriodicBoundaryConditions, "usePeriodicBoundaryConditions", true); | |
# | Line 138 | Line 137 | Globals::Globals(){ | |
137 | DefineOptionalParameterWithDefaultValue(DampingAlpha, "dampingAlpha", 1.5); | |
138 | DefineOptionalParameterWithDefaultValue(CompressDumpFile, "compressDumpFile", 0); | |
139 | DefineOptionalParameterWithDefaultValue(SkinThickness, "skinThickness", 1.0); | |
140 | + | DefineOptionalParameterWithDefaultValue(StatFileFormat, "statFileFormat", "TIME|TOTAL_ENERGY|POTENTIAL_ENERGY|KINETIC_ENERGY|TEMPERATURE|PRESSURE|VOLUME|CONSERVED_QUANTITY"); |
141 | + | |
142 | ||
143 | } | |
144 | ||
145 | int Globals::globalAssign( event* the_event ){ | |
146 | < | |
146 | > | char errorMessage[65535]; |
147 | int key; | |
147 | – | int token; |
148 | interface_assign_type the_type = the_event->evt.asmt.asmt_type; | |
149 | char* lhs = the_event->evt.asmt.lhs; | |
150 | std::string keyword(lhs); | |
151 | ||
152 | < | bool result; |
152 | > | bool result = false; |
153 | ||
154 | < | |
154 | > | /**@todo fix memory leak */ |
155 | ParamMap::iterator i =parameters_.find(keyword); | |
156 | if (i != parameters_.end()) { | |
157 | if( the_type == STRING ){ | |
158 | result = i->second->setData(std::string(the_event->evt.asmt.rhs.sval)); | |
159 | if (!result ) { | |
160 | < | sprintf(the_event->err_msg, "Error in parsing meta-data file!\n\t%s must be a string.\n", keyword.c_str() ); |
160 | > | 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); |
161 | > | the_event->err_msg = strdup(errorMessage); |
162 | } | |
163 | } else if( the_type == DOUBLE ){ | |
164 | result = i->second->setData(the_event->evt.asmt.rhs.dval); | |
165 | if (!result ) | |
166 | < | sprintf(the_event->err_msg, "Error in parsing meta-data file!\n\t%s must be a double.\n", keyword.c_str() ); |
166 | > | 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 ); |
167 | > | the_event->err_msg = strdup(errorMessage); |
168 | } | |
169 | else if (the_type == INT ){ | |
170 | result = i->second->setData(the_event->evt.asmt.rhs.ival); | |
171 | if (!result ) | |
172 | < | sprintf(the_event->err_msg, "Error in parsing meta-data file!\n\t%s must be an int.\n", keyword.c_str() ); |
172 | > | 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 ); |
173 | > | the_event->err_msg = strdup(errorMessage); |
174 | ||
175 | } else { | |
176 | < | |
176 | > | sprintf(errorMessage, "Internal error of parser\n"); |
177 | > | the_event->err_msg = strdup(errorMessage); |
178 | } | |
179 | + | } else { |
180 | + | sprintf(errorMessage, "%s is an unrecognized keyword\n", keyword.c_str() ); |
181 | + | the_event->err_msg = strdup(errorMessage); |
182 | } | |
183 | ||
184 | if (keyword == "nComponents" && getNComponents() > 0) { | |
# | Line 336 | Line 343 | char* Globals::checkMe( void ){ | |
343 | CheckParameter(Ensemble, isEqualIgnoreCase(std::string("NVE")) || isEqualIgnoreCase(std::string("NVT")) || | |
344 | isEqualIgnoreCase(std::string("NPTi")) || isEqualIgnoreCase(std::string("NPTf"))|| | |
345 | isEqualIgnoreCase(std::string("NPTxyz")) ); | |
339 | – | |
346 | CheckParameter(Dt, isPositive()); | |
347 | CheckParameter(RunTime, isPositive()); | |
348 | CheckParameter(InitialConfig, isNotEmpty()); | |
# | Line 380 | Line 386 | char* Globals::checkMe( void ){ | |
386 | CheckParameter(ThermIntThetaSpringConst, isPositive()); | |
387 | CheckParameter(ThermIntOmegaSpringConst, isPositive()); | |
388 | CheckParameter(SurfaceTension, isPositive()); | |
389 | < | CheckParameter(ElectrostaticSummationMethod, isEqualIgnoreCase(std::string("NONE")) || isEqualIgnoreCase(std::string("UNDAMPED_WOLF")) || isEqualIgnoreCase(std::string("DAMPED_WOLF")) || isEqualIgnoreCase(std::string("REACTION_FIELD")) ); |
389 | > | CheckParameter(ElectrostaticSummationMethod, isEqualIgnoreCase(std::string("NONE")) || isEqualIgnoreCase(std::string("SHIFTED_POTENTIAL")) || isEqualIgnoreCase(std::string("SHIFTED_FORCE")) || isEqualIgnoreCase(std::string("REACTION_FIELD"))); |
390 | > | CheckParameter(ScreeningMethod, isEqualIgnoreCase(std::string("UNDAMPED")) || isEqualIgnoreCase(std::string("DAMPED"))); |
391 | CheckParameter(CutoffPolicy, isEqualIgnoreCase(std::string("MIX")) || isEqualIgnoreCase(std::string("MAX")) || isEqualIgnoreCase(std::string("TRADITIONAL"))); | |
392 | //CheckParameter(StatFileFormat,); | |
393 | //CheckParameter(MixingRule,); |
– | Removed lines |
+ | Added lines |
< | Changed lines |
> | Changed lines |