gas_phase and irrev removed.

get_line moved to PHRQ_io.

Still debugging some.

git-svn-id: svn://136.177.114.72/svn_GW/phreeqcpp/branches/ErrorHandling@5967 1feff8c3-07ed-0310-ac33-dd36852eb9cd
This commit is contained in:
David L Parkhurst 2012-01-04 16:07:40 +00:00
parent ddafdd170f
commit acf62c7881
44 changed files with 1969 additions and 1020 deletions

View File

@ -125,7 +125,7 @@ ChartHandler::End_timer()
// size_t i; // size_t i;
// for (i = 0; i < it->second->Get_Curves().size(); i ++) // for (i = 0; i < it->second->Get_Curves().size(); i ++)
// { // {
// std::cerr << "Curve " << i << ", number of points " << it->second->Get_Curves()[i]->Get_x().size() << std::endl; // std::cerr << "Curve " << i << ", number of points " << it->second->Get_Curves()[i]->Get_x().size() << "\n";
// } // }
//} //}
size_t i = 0; size_t i = 0;

View File

@ -142,7 +142,7 @@ ChartObject::Set_axis_scale(CParser & parser)
} }
if (string_vector.size() == 0) if (string_vector.size() == 0)
{ {
error_msg("No axis defined for scales", CParser::OT_CONTINUE); error_msg("No axis defined for scales", PHRQ_io::OT_CONTINUE);
return false; return false;
} }
std::string str = string_vector[0]; std::string str = string_vector[0];
@ -168,8 +168,8 @@ ChartObject::Set_axis_scale(CParser & parser)
std::ostringstream estream; std::ostringstream estream;
estream << "Found " << str; estream << "Found " << str;
estream << ", but expect axis type \'x\', \'y\', \'y2\'or \'sy\'."; estream << ", but expect axis type \'x\', \'y\', \'y2\'or \'sy\'.";
estream << std::endl; estream << "\n";
error_msg(estream.str().c_str(), CParser::OT_CONTINUE); error_msg(estream.str().c_str(), PHRQ_io::OT_CONTINUE);
return false; return false;
} }
@ -189,7 +189,7 @@ ChartObject::Set_axis_scale(CParser & parser)
std::ostringstream estream; std::ostringstream estream;
estream << "Found " << s; estream << "Found " << s;
estream << ", but expect number or 'a(uto)'."; estream << ", but expect number or 'a(uto)'.";
estream << std::endl; estream << "\n";
error_msg(estream.str().c_str(), CONTINUE); error_msg(estream.str().c_str(), CONTINUE);
return false; return false;
} }
@ -205,7 +205,7 @@ ChartObject::Set_axis_scale(CParser & parser)
{ {
std::ostringstream estream; std::ostringstream estream;
estream << "MIN and MAX must be > 0 for log " << type << "-scale."; estream << "MIN and MAX must be > 0 for log " << type << "-scale.";
estream << std::endl; estream << "\n";
error_msg(estream.str().c_str(), CONTINUE); error_msg(estream.str().c_str(), CONTINUE);
return false; return false;
} }
@ -217,8 +217,8 @@ ChartObject::Set_axis_scale(CParser & parser)
if (scale_ptr[0] > scale_ptr[1]) if (scale_ptr[0] > scale_ptr[1])
{ {
std::ostringstream estream; std::ostringstream estream;
estream << "Maximum must be larger than minimum of axis_scale " << type << "-scale." << std::endl; estream << "Maximum must be larger than minimum of axis_scale " << type << "-scale." << "\n";
estream << "Switching values for MIN and MAX. " << std::endl; estream << "Switching values for MIN and MAX. " << "\n";
warning_msg(estream.str().c_str()); warning_msg(estream.str().c_str());
double t; double t;
t = scale_ptr[0]; t = scale_ptr[0];
@ -468,9 +468,10 @@ ChartObject::OpenCSVFile(std::string file_name)
return false; return false;
} }
std::ostringstream oss_out; //std::ostringstream oss_out;
std::ostringstream oss_err; //std::ostringstream oss_err;
CParser parser(f_csv, oss_out, oss_err, this->Get_io()); //CParser parser(f_csv, oss_out, oss_err, this->Get_io());
CParser parser(f_csv, this->Get_io());
parser.set_echo_file(CParser::EO_NONE); parser.set_echo_file(CParser::EO_NONE);
/* Get lines */ /* Get lines */
@ -481,7 +482,7 @@ ChartObject::OpenCSVFile(std::string file_name)
std::vector<CurveObject *> csv_curves; std::vector<CurveObject *> csv_curves;
// Read file line by line into temporary curves // Read file line by line into temporary curves
while (parser.check_line("cvs file", false, true, true, false) != CParser::LT_EOF) while (parser.check_line("cvs file", false, true, true, false) != PHRQ_io::LT_EOF)
{ {
// Headings line // Headings line
if (linenr == 0) if (linenr == 0)
@ -743,7 +744,7 @@ ChartObject::ExtractCurveInfo(std::string & cmd_line)
// Add to list of new plotxy curves // Add to list of new plotxy curves
this->new_plotxy_curves.push_back(new_curve); this->new_plotxy_curves.push_back(new_curve);
//std::cerr << revised_line << std::endl; //std::cerr << revised_line << "\n";
cmd_line = revised_line; cmd_line = revised_line;
} }
void void
@ -755,7 +756,7 @@ ChartObject::Set_rate_struct(void)
std::ostringstream oss; std::ostringstream oss;
for (; it != rate_command_list.end(); it++) for (; it != rate_command_list.end(); it++)
{ {
oss << *it << std::endl; oss << *it << "\n";
} }
this->Rate_free(); this->Rate_free();
this->user_graph->commands = (char *) P_INSTANCE_POINTER PHRQ_malloc((oss.str().size()) + 100 * sizeof(char)); this->user_graph->commands = (char *) P_INSTANCE_POINTER PHRQ_malloc((oss.str().size()) + 100 * sizeof(char));
@ -930,7 +931,7 @@ ChartObject::SaveCurvesToFile(std::string &file_name)
if ((*it)->Get_x().size() > max_points) if ((*it)->Get_x().size() > max_points)
max_points = (*it)->Get_x().size(); max_points = (*it)->Get_x().size();
} }
f_out << std::endl; f_out << "\n";
// write data // write data
size_t i2 = 0; size_t i2 = 0;
@ -955,7 +956,7 @@ ChartObject::SaveCurvesToFile(std::string &file_name)
f_out << "\t"; f_out << "\t";
} }
} }
f_out << std::endl; f_out << "\n";
i2++; i2++;
} }
f_out.close(); f_out.close();
@ -1101,10 +1102,10 @@ ChartObject::dump(std::ostream & oss, unsigned int indent)
indent0.append(Utilities::INDENT); indent0.append(Utilities::INDENT);
for (i = 0; i < indent + 1; ++i) for (i = 0; i < indent + 1; ++i)
indent1.append(Utilities::INDENT); indent1.append(Utilities::INDENT);
oss << indent0 << "USER_GRAPH " << this->n_user << " " << this->description << std::endl; oss << indent0 << "USER_GRAPH " << this->n_user << " " << this->description << "\n";
// chart title // chart title
oss << indent1 << "-chart_title \"" << this->chart_title << "\"" << std::endl; oss << indent1 << "-chart_title \"" << this->chart_title << "\"" << "\n";
// axis titles // axis titles
if (this->axis_titles.size() > 0) if (this->axis_titles.size() > 0)
@ -1115,7 +1116,7 @@ ChartObject::dump(std::ostream & oss, unsigned int indent)
{ {
oss << "\"" << axis_titles[i] << "\" "; oss << "\"" << axis_titles[i] << "\" ";
} }
oss << std::endl; oss << "\n";
} }
// axis_scale_x // axis_scale_x
@ -1137,7 +1138,7 @@ ChartObject::dump(std::ostream & oss, unsigned int indent)
{ {
oss << " log"; oss << " log";
} }
oss << std::endl; oss << "\n";
} }
// axis_scale_y // axis_scale_y
scale_ptr = this->axis_scale_y; scale_ptr = this->axis_scale_y;
@ -1158,7 +1159,7 @@ ChartObject::dump(std::ostream & oss, unsigned int indent)
{ {
oss << " log"; oss << " log";
} }
oss << std::endl; oss << "\n";
} }
// axis_scale_sy // axis_scale_sy
scale_ptr = this->axis_scale_y2; scale_ptr = this->axis_scale_y2;
@ -1179,39 +1180,39 @@ ChartObject::dump(std::ostream & oss, unsigned int indent)
{ {
oss << " log"; oss << " log";
} }
oss << std::endl; oss << "\n";
} }
// chart type // chart type
if (this->chart_type == 0) if (this->chart_type == 0)
{ {
oss << indent1 << "-plot_concentration_vs x" << std::endl; oss << indent1 << "-plot_concentration_vs x" << "\n";
} }
else else
{ {
oss << indent1 << "-plot_concentration_vs t" << std::endl; oss << indent1 << "-plot_concentration_vs t" << "\n";
} }
// graph_initial_solutions // graph_initial_solutions
if (this->graph_initial_solutions) if (this->graph_initial_solutions)
{ {
oss << indent1 << "-initial_solutions true" << std::endl; oss << indent1 << "-initial_solutions true" << "\n";
} }
else else
{ {
oss << indent1 << "-initial_solutions false" << std::endl; oss << indent1 << "-initial_solutions false" << "\n";
} }
// connect_simulations // connect_simulations
if (this->connect_simulations) if (this->connect_simulations)
{ {
oss << indent1 << "-connect_simulations true" << std::endl; oss << indent1 << "-connect_simulations true" << "\n";
} }
else else
{ {
oss << indent1 << "-connect_simulations false" << std::endl; oss << indent1 << "-connect_simulations false" << "\n";
} }
// csv files // csv files
for (i = 0; i < this->csv_file_names.size(); i++) for (i = 0; i < this->csv_file_names.size(); i++)
{ {
oss << indent1 << "-plot_csv_file " << this->csv_file_names[i] << std::endl; oss << indent1 << "-plot_csv_file " << this->csv_file_names[i] << "\n";
} }
// headings // headings
@ -1222,17 +1223,17 @@ ChartObject::dump(std::ostream & oss, unsigned int indent)
{ {
oss << this->headings_original[i] << " "; oss << this->headings_original[i] << " ";
} }
oss << std::endl; oss << "\n";
} }
// commands // commands
oss << indent1 << "-start" << std::endl; oss << indent1 << "-start" << "\n";
std::list<std::string>::iterator it = rate_command_list_original.begin(); std::list<std::string>::iterator it = rate_command_list_original.begin();
for (; it != rate_command_list_original.end(); it++) for (; it != rate_command_list_original.end(); it++)
{ {
oss << *it << std::endl; oss << *it << "\n";
} }
oss << indent1 << "-end" << std::endl; oss << indent1 << "-end" << "\n";
/* /*
struct rate *user_graph; struct rate *user_graph;

View File

@ -140,33 +140,33 @@ cxxExchComp::dump_xml(std::ostream & s_oss, unsigned int indent) const
// Exch_Comp element and attributes // Exch_Comp element and attributes
s_oss << indent0 << "formula=\"" << this->formula << "\"" << std::endl; s_oss << indent0 << "formula=\"" << this->formula << "\"" << "\n";
s_oss << indent0 << "formula_z=\"" << this-> s_oss << indent0 << "formula_z=\"" << this->
formula_z << "\"" << std::endl; formula_z << "\"" << "\n";
s_oss << indent0 << "moles=\"" << this->moles << "\"" << std::endl; s_oss << indent0 << "moles=\"" << this->moles << "\"" << "\n";
s_oss << indent0 << "la=\"" << this->la << "\"" << std::endl; s_oss << indent0 << "la=\"" << this->la << "\"" << "\n";
s_oss << indent0 << "charge_balance=\"" << this-> s_oss << indent0 << "charge_balance=\"" << this->
charge_balance << "\"" << std::endl; charge_balance << "\"" << "\n";
if (this->phase_name.size() != 0) if (this->phase_name.size() != 0)
{ {
s_oss << indent0 << "phase_name=\"" << this->phase_name << "\"" << std::endl; s_oss << indent0 << "phase_name=\"" << this->phase_name << "\"" << "\n";
} }
if (this->rate_name.size() != 0) if (this->rate_name.size() != 0)
{ {
s_oss << indent0 << "rate_name=\"" << this-> s_oss << indent0 << "rate_name=\"" << this->
rate_name << "\"" << std::endl; rate_name << "\"" << "\n";
} }
s_oss << indent0 << "phase_proportion=\"" << this-> s_oss << indent0 << "phase_proportion=\"" << this->
phase_proportion << "\"" << std::endl; phase_proportion << "\"" << "\n";
// totals // totals
s_oss << indent0; s_oss << indent0;
s_oss << "<totals " << std::endl; s_oss << "<totals " << "\n";
this->totals.dump_xml(s_oss, indent + 1); this->totals.dump_xml(s_oss, indent + 1);
// formula_totals // formula_totals
s_oss << indent0; s_oss << indent0;
s_oss << "<formula_totals " << std::endl; s_oss << "<formula_totals " << "\n";
this->formula_totals.dump_xml(s_oss, indent + 1); this->formula_totals.dump_xml(s_oss, indent + 1);
} }
@ -186,35 +186,35 @@ cxxExchComp::dump_raw(std::ostream & s_oss, unsigned int indent) const
// Exch_Comp element and attributes // Exch_Comp element and attributes
s_oss << indent0 << "-formula " << this->formula << std::endl; s_oss << indent0 << "-formula " << this->formula << "\n";
//s_oss << indent1 << "# critical values" << std::endl; //s_oss << indent1 << "# critical values" << "\n";
// totals // totals
s_oss << indent1; s_oss << indent1;
s_oss << "-totals" << std::endl; s_oss << "-totals" << "\n";
this->totals.dump_raw(s_oss, indent + 2); this->totals.dump_raw(s_oss, indent + 2);
s_oss << indent1 << "-charge_balance " << this->charge_balance << std::endl; s_oss << indent1 << "-charge_balance " << this->charge_balance << "\n";
//s_oss << indent1 << "# Noncritical values" << std::endl; //s_oss << indent1 << "# Noncritical values" << "\n";
s_oss << indent1 << "-moles " << this->moles << std::endl; s_oss << indent1 << "-moles " << this->moles << "\n";
s_oss << indent1 << "-la " << this->la << std::endl; s_oss << indent1 << "-la " << this->la << "\n";
if (this->phase_name.size() != 0) if (this->phase_name.size() != 0)
{ {
s_oss << indent1 << "-phase_name " << this->phase_name << std::endl; s_oss << indent1 << "-phase_name " << this->phase_name << "\n";
} }
if (this->rate_name.size() != 0) if (this->rate_name.size() != 0)
{ {
s_oss << indent1 << "-rate_name " << this->rate_name << std::endl; s_oss << indent1 << "-rate_name " << this->rate_name << "\n";
} }
s_oss << indent1 << "-phase_proportion " << this->phase_proportion << std::endl; s_oss << indent1 << "-phase_proportion " << this->phase_proportion << "\n";
s_oss << indent1 << "-formula_z " << this->formula_z << std::endl; s_oss << indent1 << "-formula_z " << this->formula_z << "\n";
// formula_totals // formula_totals
s_oss << indent1; s_oss << indent1;
s_oss << "-formula_totals" << std::endl; s_oss << "-formula_totals" << "\n";
this->formula_totals.dump_raw(s_oss, indent + 2); this->formula_totals.dump_raw(s_oss, indent + 2);
} }
@ -270,8 +270,8 @@ cxxExchComp::read_raw(CParser & parser, bool check)
case CParser::OPT_ERROR: case CParser::OPT_ERROR:
opt = CParser::OPT_KEYWORD; opt = CParser::OPT_KEYWORD;
// Allow return to Exchange for more processing // Allow return to Exchange for more processing
//parser.error_msg("Unknown input in EXCH_COMP read.", CParser::OT_CONTINUE); //parser.error_msg("Unknown input in EXCH_COMP read.", PHRQ_io::OT_CONTINUE);
//parser.error_msg(parser.line().c_str(), CParser::OT_CONTINUE); //parser.error_msg(parser.line().c_str(), PHRQ_io::OT_CONTINUE);
break; break;
case 0: // formula case 0: // formula
@ -280,7 +280,7 @@ cxxExchComp::read_raw(CParser & parser, bool check)
this->formula.clear(); this->formula.clear();
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Expected string value for formula.", parser.error_msg("Expected string value for formula.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
else else
{ {
@ -295,7 +295,7 @@ cxxExchComp::read_raw(CParser & parser, bool check)
this->moles = 0; this->moles = 0;
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Expected numeric value for moles.", parser.error_msg("Expected numeric value for moles.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
moles_defined = true; moles_defined = true;
break; break;
@ -306,7 +306,7 @@ cxxExchComp::read_raw(CParser & parser, bool check)
this->la = 0; this->la = 0;
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Expected numeric value for la.", parser.error_msg("Expected numeric value for la.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
la_defined = true; la_defined = true;
break; break;
@ -317,7 +317,7 @@ cxxExchComp::read_raw(CParser & parser, bool check)
this->charge_balance = 0; this->charge_balance = 0;
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Expected numeric value for charge_balance.", parser.error_msg("Expected numeric value for charge_balance.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
charge_balance_defined = true; charge_balance_defined = true;
break; break;
@ -328,7 +328,7 @@ cxxExchComp::read_raw(CParser & parser, bool check)
this->phase_name.clear(); this->phase_name.clear();
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Expected string value for phase_name.", parser.error_msg("Expected string value for phase_name.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
else else
{ {
@ -342,7 +342,7 @@ cxxExchComp::read_raw(CParser & parser, bool check)
this->rate_name.clear(); this->rate_name.clear();
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Expected string value for rate_name.", parser.error_msg("Expected string value for rate_name.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
else else
{ {
@ -356,7 +356,7 @@ cxxExchComp::read_raw(CParser & parser, bool check)
this->formula_z = 0; this->formula_z = 0;
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Expected numeric value for formula_z.", parser.error_msg("Expected numeric value for formula_z.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
formula_z_defined = true; formula_z_defined = true;
break; break;
@ -368,7 +368,7 @@ cxxExchComp::read_raw(CParser & parser, bool check)
parser.incr_input_error(); parser.incr_input_error();
parser. parser.
error_msg("Expected numeric value for phase_proportion.", error_msg("Expected numeric value for phase_proportion.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
break; break;
@ -380,7 +380,7 @@ cxxExchComp::read_raw(CParser & parser, bool check)
parser. parser.
error_msg error_msg
("Expected element name and molality for ExchComp totals.", ("Expected element name and molality for ExchComp totals.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
opt_save = 8; opt_save = 8;
break; break;
@ -393,7 +393,7 @@ cxxExchComp::read_raw(CParser & parser, bool check)
parser. parser.
error_msg error_msg
("Expected element name and molality for ExchComp formula totals.", ("Expected element name and molality for ExchComp formula totals.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
opt_save = 9; opt_save = 9;
break; break;
@ -408,31 +408,31 @@ cxxExchComp::read_raw(CParser & parser, bool check)
{ {
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Formula not defined for ExchComp input.", parser.error_msg("Formula not defined for ExchComp input.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
if (moles_defined == false) if (moles_defined == false)
{ {
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Moles not defined for ExchComp input.", parser.error_msg("Moles not defined for ExchComp input.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
if (la_defined == false) if (la_defined == false)
{ {
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("La not defined for ExchComp input.", parser.error_msg("La not defined for ExchComp input.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
if (charge_balance_defined == false) if (charge_balance_defined == false)
{ {
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Charge_balance not defined for ExchComp input.", parser.error_msg("Charge_balance not defined for ExchComp input.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
if (formula_z_defined == false) if (formula_z_defined == false)
{ {
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Formula_z not defined for ExchComp input.", parser.error_msg("Formula_z not defined for ExchComp input.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
} }
} }

View File

@ -121,8 +121,8 @@ class cxxExchComp: public PHRQ_base
this->formula_totals = nd; this->formula_totals = nd;
} }
cxxNameDouble & Get_totals() {return (this->totals);}; cxxNameDouble & Get_totals() {return (this->totals);}
cxxNameDouble & Get_formula_totals(void) {return this->formula_totals;}; cxxNameDouble & Get_formula_totals(void) {return this->formula_totals;}
void add(const cxxExchComp & comp, double extensive); void add(const cxxExchComp & comp, double extensive);

View File

@ -127,15 +127,15 @@ cxxExchange::dump_xml(std::ostream & s_oss, unsigned int indent) const
// Exchange element and attributes // Exchange element and attributes
s_oss << indent0; s_oss << indent0;
s_oss << "<exchange " << std::endl; s_oss << "<exchange " << "\n";
s_oss << indent1; s_oss << indent1;
s_oss << "pitzer_exchange_gammas=\"" << this-> s_oss << "pitzer_exchange_gammas=\"" << this->
pitzer_exchange_gammas << "\"" << std::endl; pitzer_exchange_gammas << "\"" << "\n";
// components // components
s_oss << indent1; s_oss << indent1;
s_oss << "<component " << std::endl; s_oss << "<component " << "\n";
for (std::map < std::string, cxxExchComp >::const_iterator it = exchComps.begin(); for (std::map < std::string, cxxExchComp >::const_iterator it = exchComps.begin();
it != exchComps.end(); ++it) it != exchComps.end(); ++it)
{ {
@ -162,26 +162,26 @@ cxxExchange::dump_raw(std::ostream & s_oss, unsigned int indent, int *n_out) con
// Exchange element and attributes // Exchange element and attributes
s_oss << indent0; s_oss << indent0;
int n_user_local = (n_out != NULL) ? *n_out : this->n_user; int n_user_local = (n_out != NULL) ? *n_out : this->n_user;
s_oss << "EXCHANGE_RAW " << n_user_local << " " << this->description << std::endl; s_oss << "EXCHANGE_RAW " << n_user_local << " " << this->description << "\n";
s_oss << indent1; s_oss << indent1;
s_oss << "-new_def " << this->new_def << std::endl; s_oss << "-new_def " << this->new_def << "\n";
s_oss << indent1; s_oss << indent1;
s_oss << "-exchange_gammas " << this->pitzer_exchange_gammas << std::endl; s_oss << "-exchange_gammas " << this->pitzer_exchange_gammas << "\n";
s_oss << indent1; s_oss << indent1;
s_oss << "-solution_equilibria " << this->solution_equilibria << std::endl; s_oss << "-solution_equilibria " << this->solution_equilibria << "\n";
s_oss << indent1; s_oss << indent1;
s_oss << "-n_solution " << this->n_solution << std::endl; s_oss << "-n_solution " << this->n_solution << "\n";
// exchComps structures // exchComps structures
for (std::map < std::string, cxxExchComp >::const_iterator it = exchComps.begin(); for (std::map < std::string, cxxExchComp >::const_iterator it = exchComps.begin();
it != exchComps.end(); ++it) it != exchComps.end(); ++it)
{ {
s_oss << indent1; s_oss << indent1;
s_oss << "-component" << std::endl; s_oss << "-component" << "\n";
(*it).second.dump_raw(s_oss, indent + 2); (*it).second.dump_raw(s_oss, indent + 2);
} }
@ -236,8 +236,8 @@ cxxExchange::read_raw(CParser & parser, bool check)
case CParser::OPT_ERROR: case CParser::OPT_ERROR:
opt = CParser::OPT_EOF; opt = CParser::OPT_EOF;
parser.error_msg("Unknown input in EXCH_COMP_RAW keyword.", parser.error_msg("Unknown input in EXCH_COMP_RAW keyword.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
parser.error_msg(parser.line().c_str(), CParser::OT_CONTINUE); parser.error_msg(parser.line().c_str(), PHRQ_io::OT_CONTINUE);
useLastLine = false; useLastLine = false;
break; break;
@ -250,7 +250,7 @@ cxxExchange::read_raw(CParser & parser, bool check)
parser. parser.
error_msg error_msg
("Expected boolean value for pitzer_exchange_gammas.", ("Expected boolean value for pitzer_exchange_gammas.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
pitzer_exchange_gammas_defined = true; pitzer_exchange_gammas_defined = true;
useLastLine = false; useLastLine = false;
@ -290,7 +290,7 @@ cxxExchange::read_raw(CParser & parser, bool check)
parser. parser.
error_msg error_msg
("Expected boolean value for new_def.", ("Expected boolean value for new_def.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
useLastLine = false; useLastLine = false;
break; break;
@ -302,7 +302,7 @@ cxxExchange::read_raw(CParser & parser, bool check)
parser. parser.
error_msg error_msg
("Expected boolean value for solution_equilibria.", ("Expected boolean value for solution_equilibria.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
useLastLine = false; useLastLine = false;
break; break;
@ -314,7 +314,7 @@ cxxExchange::read_raw(CParser & parser, bool check)
parser. parser.
error_msg error_msg
("Expected integer value for n_solution.", ("Expected integer value for n_solution.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
useLastLine = false; useLastLine = false;
break; break;
@ -331,7 +331,7 @@ cxxExchange::read_raw(CParser & parser, bool check)
parser. parser.
error_msg error_msg
("Pitzer_exchange_gammsa not defined for EXCHANGE_RAW input.", ("Pitzer_exchange_gammsa not defined for EXCHANGE_RAW input.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
} }
} }

View File

@ -32,15 +32,16 @@ public:
bool Get_pitzer_exchange_gammas() const; bool Get_pitzer_exchange_gammas() const;
void Set_pitzer_exchange_gammas(bool b); void Set_pitzer_exchange_gammas(bool b);
bool Get_new_def(void) const {return this->new_def;}; bool Get_new_def(void) const {return this->new_def;}
void Set_new_def(bool tf) {this->new_def = tf;}; void Set_new_def(bool tf) {this->new_def = tf;}
bool Get_solution_equilibria(void) const {return this->solution_equilibria;}; bool Get_solution_equilibria(void) const {return this->solution_equilibria;}
void Set_solution_equilibria(bool tf) {this->solution_equilibria = tf;}; void Set_solution_equilibria(bool tf) {this->solution_equilibria = tf;}
int Get_n_solution(void) const {return this->n_solution;}; int Get_n_solution(void) const {return this->n_solution;}
void Set_n_solution(int i) {this->n_solution = i;}; void Set_n_solution(int i) {this->n_solution = i;}
cxxExchComp *ExchComp_find(std::string s); cxxExchComp *ExchComp_find(std::string s);
std::map < std::string, cxxExchComp > &Get_exchComps(void) ; std::map < std::string, cxxExchComp > &Get_exchComps(void);
void totalize(); void totalize();
const cxxNameDouble & Get_totals() const; const cxxNameDouble & Get_totals() const;

View File

@ -25,47 +25,98 @@ cxxGasPhase::cxxGasPhase(PHRQ_io * io)
// //
: cxxNumKeyword(io) : cxxNumKeyword(io)
{ {
new_def = true;
solution_equilibria = false;
n_solution = -999;
type = cxxGasPhase::GP_PRESSURE;
total_p = 1.0;
volume = 1.0;
v_m = 0;
pr_in = false;
temperature = 298.15;
}
cxxGasPhase::cxxGasPhase(std::map < int, cxxGasPhase > &entity_map,
cxxMix & mx, int l_n_user, PHRQ_io * io)
: cxxNumKeyword(io)
{
this->n_user = this->n_user_end = l_n_user;
total_p = 0; total_p = 0;
volume = 0; volume = 0;
v_m = 0; v_m = 0;
pr_in = false; pr_in = false;
gasPhaseComps.type = cxxNameDouble::ND_NAME_COEF; bool first = true;
} //
// Mix
//
// accumulate in map
std::map<std::string, cxxGasComp> comp_map;
std::map<std::string, cxxGasComp>::iterator comp_it;
cxxGasPhase::cxxGasPhase(struct gas_phase *gas_phase_ptr, PHRQ_io * io) const std::map < int, double > & mixcomps = mx.Get_mixComps();
// std::map < int, double >::const_iterator it;
// constructor for cxxGasPhase from struct gas_phase for (it = mixcomps.begin(); it != mixcomps.end(); it++)
//
:
cxxNumKeyword(io)
{
int i;
this->Set_description(gas_phase_ptr->description);
n_user = gas_phase_ptr->n_user;
n_user_end = gas_phase_ptr->n_user_end;
if (gas_phase_ptr->type == PRESSURE)
{ {
type = cxxGasPhase::GP_PRESSURE; const cxxGasPhase *entity_ptr = &(entity_map.find(it->first)->second);
if (first)
{
this->new_def = entity_ptr->new_def;
this->solution_equilibria = entity_ptr->solution_equilibria;
this->n_solution = entity_ptr->n_solution;
this->type = entity_ptr->type;
this->total_p = entity_ptr->total_p * it->second;
this->total_moles = entity_ptr->total_moles * it->second;
this->volume = entity_ptr->volume * it->second;
this->v_m = entity_ptr->v_m * it->second;
this->pr_in = entity_ptr->pr_in;
this->temperature = entity_ptr->temperature;
first = false;
}
else
{
if (this->type != entity_ptr->type)
{
std::ostringstream oss;
oss << "Can not mix two gas_phases with differing types.";
error_msg(oss.str().c_str(), CONTINUE);
return;
}
this->total_p += entity_ptr->total_p * it->second;
this->volume += entity_ptr->volume * it->second;
this->v_m += entity_ptr->v_m * it->second;
}
cxxGasPhase *gas_phase_ptr = Utilities::Rxn_find(entity_map, it->first);
if (gas_phase_ptr)
{
std::vector<cxxGasComp> add_comps = gas_phase_ptr->Get_gas_comps();
for (size_t i = 0; i < add_comps.size(); i++)
{
comp_it = comp_map.find(add_comps[i].Get_phase_name());
if (comp_it != comp_map.end())
{
comp_it->second.add(add_comps[i], it->second);
}
else
{
cxxGasComp gc(add_comps[i]);
gc.multiply(it->second);
comp_map[add_comps[i].Get_phase_name()] = gc;
}
}
}
} }
else
{
type = cxxGasPhase::GP_VOLUME;
}
total_p = gas_phase_ptr->total_p;
volume = gas_phase_ptr->volume;
v_m = gas_phase_ptr->v_m;
pr_in = gas_phase_ptr->pr_in;
// gas_phase components // put map into vector
for (i = 0; i < gas_phase_ptr->count_comps; i++) this->gas_comps.clear();
std::vector<cxxGasComp> gc;
for (comp_it = comp_map.begin(); comp_it != comp_map.end(); comp_it++)
{ {
if (gas_phase_ptr->comps[i].name == NULL) this->gas_comps.push_back(comp_it->second);
continue;
gasPhaseComps[gas_phase_ptr->comps[i].name] =
gas_phase_ptr->comps[i].moles;
} }
} }
#ifdef SKIP
cxxGasPhase::cxxGasPhase(const std::map < int, cxxGasPhase > &entities, cxxGasPhase::cxxGasPhase(const std::map < int, cxxGasPhase > &entities,
cxxMix & mix, int l_n_user, PHRQ_io * io): cxxMix & mix, int l_n_user, PHRQ_io * io):
cxxNumKeyword(io) cxxNumKeyword(io)
@ -121,7 +172,7 @@ cxxNumKeyword(io)
} }
} }
} }
#endif
cxxGasPhase::~cxxGasPhase() cxxGasPhase::~cxxGasPhase()
{ {
} }
@ -143,15 +194,15 @@ cxxGasPhase::dump_xml(std::ostream & s_oss, unsigned int indent) const const
// GasPhase element and attributes // GasPhase element and attributes
s_oss << indent0; s_oss << indent0;
s_oss << "<gas_phase " << std::endl; s_oss << "<gas_phase " << "\n";
s_oss << indent1; s_oss << indent1;
s_oss << "pitzer_gas_phase_gammas=\"" << this-> s_oss << "pitzer_gas_phase_gammas=\"" << this->
pitzer_gas_phase_gammas << "\"" << std::endl; pitzer_gas_phase_gammas << "\"" << "\n";
// components // components
s_oss << indent1; s_oss << indent1;
s_oss << "<component " << std::endl; s_oss << "<component " << "\n";
for (std::list < cxxGasPhaseComp >::const_iterator it = for (std::list < cxxGasPhaseComp >::const_iterator it =
gas_phaseComps.begin(); it != gas_phaseComps.end(); ++it) gas_phaseComps.begin(); it != gas_phaseComps.end(); ++it)
{ {
@ -179,27 +230,36 @@ cxxGasPhase::dump_raw(std::ostream & s_oss, unsigned int indent, int *n_out) con
// GasPhase element and attributes // GasPhase element and attributes
s_oss << indent0; s_oss << indent0;
int n_user_local = (n_out != NULL) ? *n_out : this->n_user; int n_user_local = (n_out != NULL) ? *n_out : this->n_user;
s_oss << "GAS_PHASE_RAW " << n_user_local << " " << this->description << std::endl; s_oss << "GAS_PHASE_RAW " << n_user_local << " " << this->description << "\n";
s_oss << indent1; s_oss << indent1;
s_oss << "-type " << this->type << std::endl; s_oss << "-new_def " << this->new_def << "\n";
s_oss << indent1; s_oss << indent1;
s_oss << "-total_p " << this->total_p << std::endl; s_oss << "-solution_equilibria " << this->solution_equilibria << "\n";
s_oss << indent1; s_oss << indent1;
s_oss << "-volume " << this->volume << std::endl; s_oss << "-n_solution " << this->n_solution << "\n";
s_oss << indent1; s_oss << indent1;
s_oss << "-v_m " << this->v_m << std::endl; s_oss << "-type " << this->type << "\n";
s_oss << indent1; s_oss << indent1;
s_oss << "-pr_in " << (this->pr_in ? 1 : 0) << std::endl; s_oss << "-total_p " << this->total_p << "\n";
s_oss << indent1;
s_oss << "-total_moles " << this->total_moles << "\n";
s_oss << indent1;
s_oss << "-volume " << this->volume << "\n";
s_oss << indent1;
s_oss << "-v_m " << this->v_m << "\n";
s_oss << indent1;
s_oss << "-pr_in " << (this->pr_in ? 1 : 0) << "\n";
s_oss << indent1;
s_oss << "-temperature " << this->temperature << "\n";
// gasPhaseComps // gasPhaseComps
s_oss << indent1; for (size_t i = 0 ; i < this->gas_comps.size(); i++)
s_oss << "-component" << std::endl; {
this->gasPhaseComps.dump_raw(s_oss, indent + 2); s_oss << indent1;
s_oss << "-component" << "\n";
this->gas_comps[i].dump_raw(s_oss, indent + 2);
}
} }
void void
@ -211,13 +271,18 @@ cxxGasPhase::read_raw(CParser & parser, bool check)
if (vopts.empty()) if (vopts.empty())
{ {
vopts.reserve(15); vopts.reserve(15);
vopts.push_back("type"); //0 vopts.push_back("type"); //0
vopts.push_back("total_p"); //1 vopts.push_back("total_p"); //1
vopts.push_back("volume"); //2 vopts.push_back("volume"); //2
vopts.push_back("v_m"); //3 vopts.push_back("v_m"); //3
vopts.push_back("component"); //4 vopts.push_back("component"); //4
vopts.push_back("pressure"); //5 vopts.push_back("pressure"); //5
vopts.push_back("pr_in"); //6 vopts.push_back("pr_in"); //6
vopts.push_back("new_def"); //7
vopts.push_back("solution_equilibria"); //8
vopts.push_back("n_solution"); //9
vopts.push_back("total_moles"); //10
vopts.push_back("temperature"); //11
} }
std::istream::pos_type ptr; std::istream::pos_type ptr;
@ -261,8 +326,8 @@ cxxGasPhase::read_raw(CParser & parser, bool check)
case CParser::OPT_ERROR: case CParser::OPT_ERROR:
opt = CParser::OPT_EOF; opt = CParser::OPT_EOF;
parser.error_msg("Unknown input in GAS_PHASE_COMP_RAW keyword.", parser.error_msg("Unknown input in GAS_PHASE_COMP_RAW keyword.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
parser.error_msg(parser.line().c_str(), CParser::OT_CONTINUE); parser.error_msg(parser.line().c_str(), PHRQ_io::OT_CONTINUE);
useLastLine = false; useLastLine = false;
break; break;
@ -273,7 +338,7 @@ cxxGasPhase::read_raw(CParser & parser, bool check)
this->type = cxxGasPhase::GP_PRESSURE; this->type = cxxGasPhase::GP_PRESSURE;
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Expected enum for type.", parser.error_msg("Expected enum for type.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
else else
{ {
@ -290,7 +355,7 @@ cxxGasPhase::read_raw(CParser & parser, bool check)
this->total_p = 0; this->total_p = 0;
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Expected numeric value for total_p.", parser.error_msg("Expected numeric value for total_p.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
total_p_defined = true; total_p_defined = true;
useLastLine = false; useLastLine = false;
@ -302,7 +367,7 @@ cxxGasPhase::read_raw(CParser & parser, bool check)
this->volume = 0; this->volume = 0;
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Expected numeric value for volume.", parser.error_msg("Expected numeric value for volume.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
volume_defined = true; volume_defined = true;
useLastLine = false; useLastLine = false;
@ -314,30 +379,37 @@ cxxGasPhase::read_raw(CParser & parser, bool check)
this->v_m = 0; this->v_m = 0;
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Expected numeric value for v_m.", parser.error_msg("Expected numeric value for v_m.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
v_m_defined = true; v_m_defined = true;
useLastLine = false; useLastLine = false;
break; break;
case 4: // component case 4: // component
if (this->gasPhaseComps.read_raw(parser, next_char) !=
CParser::PARSER_OK)
{ {
parser.incr_input_error(); cxxGasComp gc;
parser. //bool tf = gc.read_raw(parser, next_char);
error_msg //if (!tf
("Expected gas component name and moles for gasPhaseComps.", if (!gc.read_raw(parser, next_char))
CParser::OT_CONTINUE); {
parser.incr_input_error();
parser.error_msg
("Expected gas component information.",
PHRQ_io::OT_CONTINUE);
}
else
{
this->gas_comps.push_back(gc);
}
//opt_save = 4;
useLastLine = true;
} }
opt_save = 4;
useLastLine = false;
break; break;
case 6: // pr_in case 6: // pr_in
if (!(parser.get_iss() >> i)) if (!(parser.get_iss() >> i))
{ {
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Expected 0/1 for pr_in.", CParser::OT_CONTINUE); parser.error_msg("Expected 0/1 for pr_in.", PHRQ_io::OT_CONTINUE);
} }
else else
{ {
@ -346,6 +418,58 @@ cxxGasPhase::read_raw(CParser & parser, bool check)
pr_in_defined = true; pr_in_defined = true;
useLastLine = false; useLastLine = false;
break; break;
case 7: // new_def
if (!(parser.get_iss() >> i))
{
parser.incr_input_error();
parser.error_msg("Expected 0/1 for new_def.", PHRQ_io::OT_CONTINUE);
}
else
{
this->new_def = (i == 0) ? false : true;
}
useLastLine = false;
break;
case 8: // solution_equilibria
if (!(parser.get_iss() >> i))
{
parser.incr_input_error();
parser.error_msg("Expected 0/1 for solution_equilibria.", PHRQ_io::OT_CONTINUE);
}
else
{
this->solution_equilibria = (i == 0) ? false : true;
}
useLastLine = false;
break;
case 9: // n_solution
if (!(parser.get_iss() >> this->n_solution))
{
parser.incr_input_error();
parser.error_msg("Expected integer for n_solution.", PHRQ_io::OT_CONTINUE);
}
useLastLine = false;
break;
case 10: // total_moles
if (!(parser.get_iss() >> this->total_moles))
{
this->total_moles = 0;
parser.incr_input_error();
parser.error_msg("Expected numeric value for total_moles.",
PHRQ_io::OT_CONTINUE);
}
useLastLine = false;
break;
case 11: // temperature
if (!(parser.get_iss() >> this->temperature))
{
this->temperature = 0;
parser.incr_input_error();
parser.error_msg("Expected numeric value for temperature.",
PHRQ_io::OT_CONTINUE);
}
useLastLine = false;
break;
} }
if (opt == CParser::OPT_EOF || opt == CParser::OPT_KEYWORD) if (opt == CParser::OPT_EOF || opt == CParser::OPT_KEYWORD)
break; break;
@ -357,31 +481,31 @@ cxxGasPhase::read_raw(CParser & parser, bool check)
{ {
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Type not defined for GAS_PHASE_RAW input.", parser.error_msg("Type not defined for GAS_PHASE_RAW input.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
if (total_p_defined == false) if (total_p_defined == false)
{ {
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Total_p not defined for GAS_PHASE_RAW input.", parser.error_msg("Total_p not defined for GAS_PHASE_RAW input.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
if (volume_defined == false) if (volume_defined == false)
{ {
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Volume not defined for GAS_PHASE_RAW input.", parser.error_msg("Volume not defined for GAS_PHASE_RAW input.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
if (v_m_defined == false) if (v_m_defined == false)
{ {
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("V_m not defined for GAS_PHASE_RAW input.", parser.error_msg("V_m not defined for GAS_PHASE_RAW input.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
if (pr_in_defined == false) if (pr_in_defined == false)
{ {
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Pr_in not defined for GAS_PHASE_RAW input.", parser.error_msg("Pr_in not defined for GAS_PHASE_RAW input.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
} }
} }
@ -436,6 +560,29 @@ cxxGasPhase::mpi_unpack(int *ints, int *ii, double *doubles, int *dd)
#endif #endif
void void
cxxGasPhase::totalize(PHREEQC_PTR_ARG) cxxGasPhase::totalize(PHREEQC_PTR_ARG)
{
this->totals.clear();
// component structures
for (size_t i = 0; i < this->gas_comps.size(); i++)
{
struct phase *phase_ptr;
int l;
phase_ptr = P_INSTANCE_POINTER phase_bsearch(this->gas_comps[i].Get_phase_name().c_str(), &l, FALSE);
if (phase_ptr != NULL)
{
cxxNameDouble phase_formula(phase_ptr->next_elt);
this->totals.add_extensive(phase_formula, this->gas_comps[i].Get_moles());
}
else
{
assert(false);
}
}
return;
}
#ifdef SKIP
void
cxxGasPhase::totalize(PHREEQC_PTR_ARG)
{ {
this->totals.clear(); this->totals.clear();
// component structures // component structures
@ -457,3 +604,13 @@ cxxGasPhase::totalize(PHREEQC_PTR_ARG)
} }
return; return;
} }
#endif
LDBLE cxxGasPhase::Calc_total_moles(void)
{
LDBLE tot = 0.0;
for (size_t i = 0; i < this->gas_comps.size(); i++)
{
tot += gas_comps[i].Get_moles();
}
return tot;
}

View File

@ -6,10 +6,11 @@
#include <string> // std::string #include <string> // std::string
#include <list> // std::list #include <list> // std::list
#include <vector> // std::vector #include <vector> // std::vector
#include "phrqtype.h"
#include "NumKeyword.h" #include "NumKeyword.h"
#include "NameDouble.h" #include "NameDouble.h"
#include "Phreeqc_class.h" #include "Phreeqc_class.h"
#include "GasComp.h"
class cxxMix; class cxxMix;
class cxxGasPhase:public cxxNumKeyword class cxxGasPhase:public cxxNumKeyword
@ -17,9 +18,8 @@ class cxxGasPhase:public cxxNumKeyword
public: public:
cxxGasPhase(PHRQ_io * io=NULL); cxxGasPhase(PHRQ_io * io=NULL);
cxxGasPhase(struct gas_phase *, PHRQ_io * io=NULL); cxxGasPhase(std::map < int, cxxGasPhase > &entity_map,
cxxGasPhase(const std::map < int, cxxGasPhase > &entity_map, cxxMix & mx, int n_user, PHRQ_io * io=NULL);
cxxMix & mx, int n_user, PHRQ_io * io=NULL);
~cxxGasPhase(); ~cxxGasPhase();
enum GP_TYPE enum GP_TYPE
@ -45,26 +45,50 @@ class cxxGasPhase:public cxxNumKeyword
{ {
return this->totals; return this->totals;
}; };
const cxxNameDouble & Get_gasPhaseComps(void) const {return gasPhaseComps;}; std::vector<cxxGasComp> & Get_gas_comps(void) {return gas_comps;};
void Set_gas_comps(const std::vector<cxxGasComp> v) {gas_comps = v;};
GP_TYPE Get_type(void) const {return type;}; GP_TYPE Get_type(void) const {return type;};
void Set_type(GP_TYPE t) {type = t;};
double Get_total_p(void) const {return total_p;}; double Get_total_p(void) const {return total_p;};
double Get_volume(void) const {return volume;}; double Get_volume(void) const {return volume;};
void Set_volume(LDBLE v) {volume = v;};
double Get_v_m(void) const {return v_m;}; double Get_v_m(void) const {return v_m;};
void Set_v_m(LDBLE v) {v_m = v;};
bool Get_pr_in(void) const {return pr_in;}; bool Get_pr_in(void) const {return pr_in;};
void Set_pr_in(bool tf) {pr_in = tf;};
cxxNameDouble & Get_totals(void) {return totals;}; cxxNameDouble & Get_totals(void) {return totals;};
bool Get_new_def(void) const {return this->new_def;};
void Set_new_def(bool tf) {this->new_def = tf;};
bool Get_solution_equilibria(void) const {return this->solution_equilibria;};
void Set_solution_equilibria(bool tf) {this->solution_equilibria = tf;};
int Get_n_solution(void) const {return this->n_solution;};
void Set_n_solution(int i) {this->n_solution = i;};
LDBLE Get_total_moles(void) {return (LDBLE) total_moles;};
void Set_total_moles(LDBLE t) {total_moles = t;};
LDBLE Get_total_p(void) {return (LDBLE) total_p;};
void Set_total_p(LDBLE t) {total_p = t;};
LDBLE Get_temperature(void) {return (LDBLE) temperature;};
void Set_temperature(LDBLE t) {temperature = t;};
LDBLE Calc_total_moles(void);
protected: protected:
void add(const cxxGasPhase & addee, double extensive); void add(const cxxGasPhase & addee, double extensive);
protected: protected:
cxxNameDouble gasPhaseComps; bool new_def;
bool solution_equilibria;
int n_solution;
GP_TYPE type; GP_TYPE type;
double total_p; LDBLE total_p;
double volume; LDBLE total_moles;
double v_m; LDBLE volume;
LDBLE v_m;
bool pr_in; bool pr_in;
LDBLE temperature;
std::vector<cxxGasComp> gas_comps;
cxxNameDouble totals; cxxNameDouble totals;
}; };
#endif // !defined(GASPHASE_H_INCLUDED) #endif // !defined(GASPHASE_H_INCLUDED)

View File

@ -193,8 +193,8 @@ cxxISolution & cxxISolution::read(CParser & parser)
case CParser::OPTION_ERROR: case CParser::OPTION_ERROR:
opt = CParser::OPTION_EOF; opt = CParser::OPTION_EOF;
CParser::error_msg("Unknown input in SOLUTION keyword.", CParser::error_msg("Unknown input in SOLUTION keyword.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
CParser::error_msg(parser.line().c_str(), CParser::OT_CONTINUE); CParser::error_msg(parser.line().c_str(), PHRQ_io::OT_CONTINUE);
break; break;
case 0: // temp case 0: // temp
@ -299,7 +299,7 @@ cxxISolution & cxxISolution::read(CParser & parser)
parser. parser.
error_msg error_msg
("Expected numeric value for mass of water in solution.", ("Expected numeric value for mass of water in solution.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
else else
{ {

View File

@ -169,7 +169,7 @@ cxxISolutionComp::STATUS_TYPE cxxISolutionComp::read(CParser & parser,
parser. parser.
error_msg error_msg
("No element or master species given for concentration input.", ("No element or master species given for concentration input.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
return cxxISolutionComp::ERROR; return cxxISolutionComp::ERROR;
} }
description = token1; description = token1;
@ -189,7 +189,7 @@ cxxISolutionComp::STATUS_TYPE cxxISolutionComp::read(CParser & parser,
std::ostringstream err; std::ostringstream err;
err << "Concentration data error for " << token1 << err << "Concentration data error for " << token1 <<
" in solution input."; " in solution input.";
parser.error_msg(err, CParser::OT_CONTINUE); parser.error_msg(err, PHRQ_io::OT_CONTINUE);
return cxxISolutionComp::ERROR; return cxxISolutionComp::ERROR;
} }
if ((j = parser.copy_token(token, ptr)) == CParser::TT_EMPTY) if ((j = parser.copy_token(token, ptr)) == CParser::TT_EMPTY)
@ -232,7 +232,7 @@ cxxISolutionComp::STATUS_TYPE cxxISolutionComp::read(CParser & parser,
if (parser.copy_token(token, ptr) != CParser::TT_DIGIT) if (parser.copy_token(token, ptr) != CParser::TT_DIGIT)
{ {
parser.error_msg("Expecting gram formula weight.", parser.error_msg("Expecting gram formula weight.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
return cxxISolutionComp::ERROR; return cxxISolutionComp::ERROR;
} }
else else
@ -272,7 +272,7 @@ cxxISolutionComp::STATUS_TYPE cxxISolutionComp::read(CParser & parser,
// Check for saturation index // Check for saturation index
if (!(std::istringstream(token) >> this->phase_si)) if (!(std::istringstream(token) >> this->phase_si))
{ {
parser.error_msg("Expected saturation index.", CParser::OT_CONTINUE); parser.error_msg("Expected saturation index.", PHRQ_io::OT_CONTINUE);
return cxxISolutionComp::ERROR; return cxxISolutionComp::ERROR;
} }
return cxxISolutionComp::OK; return cxxISolutionComp::OK;
@ -295,6 +295,6 @@ cxxISolutionComp::dump_xml(std::ostream & s_oss, unsigned int indent) const cons
s_oss << " conc_moles=\"" << this->moles << "\""; s_oss << " conc_moles=\"" << this->moles << "\"";
s_oss << "\">" << std::endl; s_oss << "\">" << "\n";
} }
#endif #endif

View File

@ -73,32 +73,32 @@ cxxKineticsComp::dump_xml(std::ostream & s_oss, unsigned int indent) const const
// Kinetics_Comp element and attributes // Kinetics_Comp element and attributes
s_oss << indent0 << "formula=\"" << this->formula << "\"" << std::endl; s_oss << indent0 << "formula=\"" << this->formula << "\"" << "\n";
s_oss << indent0 << "moles=\"" << this->moles << "\"" << std::endl; s_oss << indent0 << "moles=\"" << this->moles << "\"" << "\n";
s_oss << indent0 << "la=\"" << this->la << "\"" << std::endl; s_oss << indent0 << "la=\"" << this->la << "\"" << "\n";
s_oss << indent0 << "charge_balance=\"" << this-> s_oss << indent0 << "charge_balance=\"" << this->
charge_balance << "\"" << std::endl; charge_balance << "\"" << "\n";
if (this->phase_name != NULL) if (this->phase_name != NULL)
{ {
s_oss << indent0 << "phase_name=\"" << this-> s_oss << indent0 << "phase_name=\"" << this->
phase_name << "\"" << std::endl; phase_name << "\"" << "\n";
} }
if (this->rate_name != NULL) if (this->rate_name != NULL)
{ {
s_oss << indent0 << "rate_name=\"" << this-> s_oss << indent0 << "rate_name=\"" << this->
rate_name << "\"" << std::endl; rate_name << "\"" << "\n";
} }
s_oss << indent0 << "phase_proportion=\"" << this-> s_oss << indent0 << "phase_proportion=\"" << this->
phase_proportion << "\"" << std::endl; phase_proportion << "\"" << "\n";
// totals // totals
s_oss << indent0; s_oss << indent0;
s_oss << "<totals " << std::endl; s_oss << "<totals " << "\n";
this->totals.dump_xml(s_oss, indent + 1); this->totals.dump_xml(s_oss, indent + 1);
// formula_totals // formula_totals
s_oss << indent0; s_oss << indent0;
s_oss << "<formula_totals " << std::endl; s_oss << "<formula_totals " << "\n";
this->formula_totals.dump_xml(s_oss, indent + 1); this->formula_totals.dump_xml(s_oss, indent + 1);
} }
#endif #endif
@ -119,20 +119,20 @@ cxxKineticsComp::dump_raw(std::ostream & s_oss, unsigned int indent) const
// Kinetics_Comp element and attributes // Kinetics_Comp element and attributes
s_oss << indent0 << "-rate_name " << this-> s_oss << indent0 << "-rate_name " << this->
rate_name << std::endl; rate_name << "\n";
s_oss << indent1 << "-tol " << this->tol << std::endl; s_oss << indent1 << "-tol " << this->tol << "\n";
s_oss << indent1 << "-m " << this->m << std::endl; s_oss << indent1 << "-m " << this->m << "\n";
s_oss << indent1 << "-m0 " << this->m0 << std::endl; s_oss << indent1 << "-m0 " << this->m0 << "\n";
s_oss << indent1 << "-moles " << this->moles << std::endl; s_oss << indent1 << "-moles " << this->moles << "\n";
// namecoef // namecoef
s_oss << indent1; s_oss << indent1;
s_oss << "-namecoef" << std::endl; s_oss << "-namecoef" << "\n";
this->namecoef.dump_raw(s_oss, indent + 2); this->namecoef.dump_raw(s_oss, indent + 2);
// d_params // d_params
s_oss << indent1; s_oss << indent1;
s_oss << "-d_params" << std::endl; s_oss << "-d_params" << "\n";
{ {
int i = 0; int i = 0;
s_oss << indent2; s_oss << indent2;
@ -141,13 +141,13 @@ cxxKineticsComp::dump_raw(std::ostream & s_oss, unsigned int indent) const
{ {
if (i++ == 5) if (i++ == 5)
{ {
s_oss << std::endl; s_oss << "\n";
s_oss << indent2; s_oss << indent2;
i = 0; i = 0;
} }
s_oss << *it << " "; s_oss << *it << " ";
} }
s_oss << std::endl; s_oss << "\n";
} }
} }
@ -202,8 +202,8 @@ cxxKineticsComp::read_raw(CParser & parser, bool check)
case CParser::OPT_ERROR: case CParser::OPT_ERROR:
opt = CParser::OPT_KEYWORD; opt = CParser::OPT_KEYWORD;
// Allow return to Kinetics for more processing // Allow return to Kinetics for more processing
//parser.error_msg("Unknown input in KINETICS_COMP read.", CParser::OT_CONTINUE); //parser.error_msg("Unknown input in KINETICS_COMP read.", PHRQ_io::OT_CONTINUE);
//parser.error_msg(parser.line().c_str(), CParser::OT_CONTINUE); //parser.error_msg(parser.line().c_str(), PHRQ_io::OT_CONTINUE);
break; break;
case 0: // rate_name case 0: // rate_name
@ -212,7 +212,7 @@ cxxKineticsComp::read_raw(CParser & parser, bool check)
this->rate_name.clear(); this->rate_name.clear();
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Expected string value for rate_name.", parser.error_msg("Expected string value for rate_name.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
else else
{ {
@ -227,7 +227,7 @@ cxxKineticsComp::read_raw(CParser & parser, bool check)
this->tol = 0; this->tol = 0;
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Expected numeric value for tol.", parser.error_msg("Expected numeric value for tol.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
tol_defined = true; tol_defined = true;
break; break;
@ -238,7 +238,7 @@ cxxKineticsComp::read_raw(CParser & parser, bool check)
this->m = 0; this->m = 0;
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Expected numeric value for m.", parser.error_msg("Expected numeric value for m.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
m_defined = true; m_defined = true;
break; break;
@ -249,7 +249,7 @@ cxxKineticsComp::read_raw(CParser & parser, bool check)
this->m0 = 0; this->m0 = 0;
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Expected numeric value for m0.", parser.error_msg("Expected numeric value for m0.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
m0_defined = true; m0_defined = true;
break; break;
@ -261,7 +261,7 @@ cxxKineticsComp::read_raw(CParser & parser, bool check)
this->moles = 0; this->moles = 0;
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Expected numeric value for moles.", parser.error_msg("Expected numeric value for moles.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
moles_defined = true; moles_defined = true;
break; break;
@ -275,7 +275,7 @@ cxxKineticsComp::read_raw(CParser & parser, bool check)
parser. parser.
error_msg error_msg
("Expected element name and molality for namecoef.", ("Expected element name and molality for namecoef.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
opt_save = 5; opt_save = 5;
break; break;
@ -304,31 +304,31 @@ cxxKineticsComp::read_raw(CParser & parser, bool check)
{ {
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Rate_name not defined for KineticsComp input.", parser.error_msg("Rate_name not defined for KineticsComp input.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
if (tol_defined == false) if (tol_defined == false)
{ {
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Tol not defined for KineticsComp input.", parser.error_msg("Tol not defined for KineticsComp input.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
if (m_defined == false) if (m_defined == false)
{ {
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("M not defined for KineticsComp input.", parser.error_msg("M not defined for KineticsComp input.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
if (m0_defined == false) if (m0_defined == false)
{ {
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("M0 not defined for KineticsComp input.", parser.error_msg("M0 not defined for KineticsComp input.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
if (moles_defined == false) if (moles_defined == false)
{ {
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Moles not defined for KineticsComp input.", parser.error_msg("Moles not defined for KineticsComp input.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
} }
} }

View File

@ -193,7 +193,7 @@ cxxNameDouble::dump_xml(std::ostream & s_oss, unsigned int indent) const
{ {
s_oss << indent0; s_oss << indent0;
s_oss << xmlElement << xmlAtt1 << it->first << xmlAtt2 << it-> s_oss << xmlElement << xmlAtt1 << it->first << xmlAtt2 << it->
second << "/>" << std::endl; second << "/>" << "\n";
} }
} }
@ -210,7 +210,7 @@ cxxNameDouble::dump_raw(std::ostream & s_oss, unsigned int indent) const
for (const_iterator it = (*this).begin(); it != (*this).end(); it++) for (const_iterator it = (*this).begin(); it != (*this).end(); it++)
{ {
s_oss << indent0; s_oss << indent0;
s_oss << it->first << " " << it->second << std::endl; s_oss << it->first << " " << it->second << "\n";
} }
} }
@ -448,7 +448,7 @@ cxxNameDouble::mpi_pack(int *ints, int *ii, LDBLE *doubles, int *dd)
int n = dictionary.string2int(it->first); int n = dictionary.string2int(it->first);
if (n < 0) if (n < 0)
{ {
std::cerr << it->first << std::endl; std::cerr << it->first << "\n";
error_msg("Name in NameDouble was not defined in dictionary?\n", error_msg("Name in NameDouble was not defined in dictionary?\n",
STOP); STOP);
} }

View File

@ -25,7 +25,7 @@ error_msg(const std::string & stdstr, int stop)
{ {
this->base_error_count++; this->base_error_count++;
std::ostringstream msg; std::ostringstream msg;
msg << "ERROR: " << stdstr << std::endl; msg << "ERROR: " << stdstr << "\n";
if (this->io) if (this->io)
{ {
this->io->output_msg(msg.str().c_str()); this->io->output_msg(msg.str().c_str());
@ -53,8 +53,8 @@ warning_msg(const std::string & stdstr)
} }
else else
{ {
std::cerr << stdstr << std::endl; std::cerr << stdstr << "\n";
std::cout << stdstr << std::endl; std::cout << stdstr << "\n";
} }
} }
@ -67,7 +67,7 @@ output_msg(const std::string & stdstr)
} }
else else
{ {
std::cout << stdstr << std::endl; std::cout << stdstr << "\n";
} }
} }
@ -80,7 +80,7 @@ screen_msg(const std::string & stdstr)
} }
else else
{ {
std::cerr << stdstr << std::endl; std::cerr << stdstr << "\n";
} }
} }
@ -93,6 +93,6 @@ echo_msg(const std::string & stdstr)
} }
else else
{ {
std::cout << stdstr << std::endl; std::cout << stdstr << "\n";
} }
} }

View File

@ -1,5 +1,7 @@
#include <assert.h> #include <assert.h>
#include "Utils.h"
#include "PHRQ_io.h" #include "PHRQ_io.h"
#include "Parser.h"
#include <algorithm> #include <algorithm>
#include <cctype> #include <cctype>
@ -358,11 +360,11 @@ warning_msg(const char *err_str)
{ {
if (error_ostream != NULL && error_on) if (error_ostream != NULL && error_on)
{ {
(*error_ostream) << err_str << std::endl; (*error_ostream) << err_str << "\n";
error_ostream->flush(); error_ostream->flush();
} }
std::ostringstream warn_str; std::ostringstream warn_str;
warn_str << err_str << std::endl; warn_str << err_str << "\n";
log_msg(warn_str.str().c_str()); log_msg(warn_str.str().c_str());
log_flush(); log_flush();
output_msg(warn_str.str().c_str()); output_msg(warn_str.str().c_str());
@ -516,4 +518,267 @@ pop_istream()
istream_list.pop_front(); istream_list.pop_front();
delete_istream_list.pop_front(); delete_istream_list.pop_front();
} }
} }
/* ---------------------------------------------------------------------- */
PHRQ_io::LINE_TYPE PHRQ_io::
get_line(void)
/* ---------------------------------------------------------------------- */
{
/*
* Read a line from input file put in "line".
* Copy of input line is stored in "line_save".
* Characters after # are discarded in line but retained in "line_save"
*
* Arguments:
* fp is file name
* Returns:
* EMPTY,
* EOF,
* KEYWORD,
* OK,
* OPTION
*/
int i;
bool empty;
std::string stdtoken;
void *cookie;
bool continue_loop = true;;
PHRQ_io::LINE_TYPE return_value;
// loop for include files
for (;;)
{
cookie = this->get_istream();
if (cookie == NULL)
{
break;
}
return_value = LT_EMPTY;
while (return_value == LT_EMPTY)
{
/*
* Eliminate all characters after # sign as a comment
*/
i = -1;
empty = true;
/*
* Get line, check for eof
*/
continue_loop = false;
//if (!m_input_stream.eof())
////{
//// error_msg("Reading input file.", OT_CONTINUE);
//// error_msg("istream::get() returned an error.", OT_STOP);
////}
////else
//{
// //{{MOD
// m_line.erase(m_line.begin(), m_line.end()); // m_line.clear();
// //}}MOD
// m_next_keyword = Keywords::KEY_END;
// return LT_EOF;
//}
if (get_logical_line(cookie) == LT_EOF)
{
//if (!m_input_stream.eof())
//{
// error_msg("Reading input file.", OT_CONTINUE);
// error_msg("istream::get() returned an error.", OT_STOP);
//}
//pop next file
this->pop_istream();
continue_loop = true;
break;
}
/*
* Get long lines
*/
bool empty = true;
m_line = m_line_save.substr(0, m_line_save.find_first_of('#'));
for (unsigned int i = 0; i < m_line.size(); ++i)
{
if (!::isspace(m_line[i]))
{
empty = false;
break;
}
}
if (this->accumulate)
{
this->accumulated.append(m_line_save);
this->accumulated.append("\n");
}
//
// New line character encountered
//
return_value = (empty ? LT_EMPTY : LT_OK);
}
if (continue_loop) continue;
//
// Determine return_value
//
if (return_value == LT_OK)
{
if (check_key(m_line.begin(), m_line.end()))
{
return_value = LT_KEYWORD;
}
else
{
std::string::iterator beg = m_line.begin();
std::string::iterator end = m_line.end();
std::string token;
CParser::copy_token(token, beg, end);
if (token.size() > 1 && token[0] == '-' &&::isalpha(token[1]))
{
return_value = LT_OPTION;
}
}
}
// add new include file to stack
//ptr = line;
//copy_token(stdtoken, &ptr);
std::string::iterator beg = m_line.begin();
std::string::iterator end = m_line.end();
CParser::copy_token(stdtoken, beg, end);
Utilities::str_tolower(stdtoken);
if ((strstr(stdtoken.c_str(),"include$") == stdtoken.c_str()) ||
(strstr(stdtoken.c_str(),"include_file") == stdtoken.c_str()))
{
std::string file_name;
file_name.assign(beg, end);
file_name = trim(file_name);
if (file_name.size() > 0)
{
std::ifstream *next_stream = new std::ifstream(file_name.c_str(), std::ios_base::in);
if (!next_stream->is_open())
{
// error opening file
// error_string = sformatf( "Could not open include file %s", file_name);
std::ostringstream errstr;
errstr << "Could not open include file " << file_name;
error_msg(errstr.str().c_str(), OT_STOP);
}
this->push_istream(next_stream);
continue;
}
}
return return_value;
}
m_next_keyword = Keywords::KEY_END;
return LT_EOF;
}
/**
Reads input stream until end of line, ";", or eof
stores characters in line_save
returns:
EOF on empty line on end of file or
OK otherwise
*/
PHRQ_io::LINE_TYPE PHRQ_io::
get_logical_line(void * cookie)
{
int
j;
unsigned int
pos;
char
c;
if (!cookie)
return LT_EOF;
m_line_save.erase(m_line_save.begin(), m_line_save.end()); // m_line_save.clear();
//while ((j = m_input_stream.get()) != std::char_traits < char >::eof())
while ((j = istream_getc(cookie)) != EOF)
{
c = (char) j;
if (c == '#')
{
// ignore all chars after # until newline
do
{
c = (char) j;
if (c == '\n')
{
break;
}
m_line_save += c;
}
while ((j = istream_getc(cookie)) != EOF);
//while ((j =
// m_input_stream.get()) != std::char_traits <
// char >::eof());
}
if (c == ';')
break;
if (c == '\n')
{
break;
}
if (c == '\\')
{
pos = (int) m_line_save.size();
m_line_save += c;
//while ((j = m_input_stream.get()) != std::char_traits < char >::eof())
while ((j = PHRQ_io::istream_getc(cookie)) != EOF)
{
c = (char) j;
if (c == '\\')
{
pos = (int) m_line_save.size();
m_line_save += c;
continue;
}
if (c == '\n')
{
// remove '\\'
for (; pos < m_line_save.size(); pos++)
{
m_line_save[pos] = m_line_save[pos + 1];
}
m_line_save.erase(m_line_save.size() - 1, 1);
break;
}
m_line_save += c;
if (!::isspace(j))
break;
}
}
else
{
m_line_save += c;
}
}
if (j == std::char_traits < char >::eof() && m_line_save.size() == 0)
{
return (LT_EOF);
}
return (LT_OK);
}
bool PHRQ_io::
check_key(std::string::iterator begin, std::string::iterator end)
{
std::string lowercase;
CParser::copy_token(lowercase, begin, end);
std::transform(lowercase.begin(), lowercase.end(), lowercase.begin(),
tolower);
m_next_keyword = Keywords::Keyword_search(lowercase);
if (m_next_keyword == Keywords::KEY_NONE)
{
return false;
}
return true;
}

View File

@ -10,6 +10,7 @@
#include <iostream> #include <iostream>
#include <exception> #include <exception>
#include <list> #include <list>
#include "Keywords.h"
class PhreeqcStop : std::exception class PhreeqcStop : std::exception
{ {
@ -18,6 +19,20 @@ class PhreeqcStop : std::exception
class IPQ_DLL_EXPORT PHRQ_io class IPQ_DLL_EXPORT PHRQ_io
{ {
public: public:
enum LINE_TYPE
{
LT_EOF = -1,
LT_OK = 1,
LT_EMPTY = 2,
LT_KEYWORD = 3,
LT_OPTION = 8
};
enum ONERROR_TYPE
{
OT_CONTINUE = 0,
OT_STOP = 1
};
// constructor/destructor // constructor/destructor
PHRQ_io(void); PHRQ_io(void);
virtual ~ PHRQ_io(); virtual ~ PHRQ_io();
@ -103,6 +118,24 @@ public:
void Set_screen_on(bool tf) {this->screen_on = tf;}; void Set_screen_on(bool tf) {this->screen_on = tf;};
bool Get_screen_on(void) {return this->screen_on;}; bool Get_screen_on(void) {return this->screen_on;};
// input methods
LINE_TYPE get_line(void);
LINE_TYPE get_logical_line(void * cookie);
bool check_key(std::string::iterator begin, std::string::iterator end);
std::string & Get_m_line() {return m_line;}
std::string & Get_m_line_save() {return m_line_save;}
std::string & Get_accumulated() {return accumulated;}
LINE_TYPE Get_m_line_type() {return m_line_type;};
void Set_accumulate(bool tf)
{
if (tf)
{
accumulated.clear();
}
this->accumulate = tf;
}
Keywords::KEYWORDS Get_m_next_keyword() const {return m_next_keyword;}
// echo // echo
enum ECHO_OPTION enum ECHO_OPTION
{ {
@ -136,5 +169,14 @@ protected:
std::list <std::istream *> istream_list; std::list <std::istream *> istream_list;
std::list <bool> delete_istream_list; std::list <bool> delete_istream_list;
// input data members
Keywords::KEYWORDS m_next_keyword;
std::string m_line;
std::string m_line_save;
std::string accumulated;
bool accumulate;
LINE_TYPE m_line_type;
}; };
#endif /* _PHRQIO_H */ #endif /* _PHRQIO_H */

View File

@ -92,14 +92,14 @@ cxxPPassemblage::dump_xml(std::ostream & s_oss, unsigned int indent) const
// PPassemblage element and attributes // PPassemblage element and attributes
s_oss << indent0; s_oss << indent0;
s_oss << "<EQUILIBRIUM_PHASES " << std::endl; s_oss << "<EQUILIBRIUM_PHASES " << "\n";
// eltList // eltList
this->eltList.dump_xml(s_oss, indent + 1); this->eltList.dump_xml(s_oss, indent + 1);
// ppAssemblageComps // ppAssemblageComps
s_oss << indent1; s_oss << indent1;
s_oss << "<pure_phases " << std::endl; s_oss << "<pure_phases " << "\n";
for (std::map < std::string, cxxPPassemblageComp >::const_iterator it = for (std::map < std::string, cxxPPassemblageComp >::const_iterator it =
ppAssemblageComps.begin(); it != ppAssemblageComps.end(); ++it) ppAssemblageComps.begin(); it != ppAssemblageComps.end(); ++it)
{ {
@ -125,12 +125,12 @@ cxxPPassemblage::dump_raw(std::ostream & s_oss, unsigned int indent, int *n_out)
s_oss << indent0; s_oss << indent0;
int n_user_local = (n_out != NULL) ? *n_out : this->n_user; int n_user_local = (n_out != NULL) ? *n_out : this->n_user;
s_oss << "EQUILIBRIUM_PHASES_RAW " << n_user_local << " " << this-> s_oss << "EQUILIBRIUM_PHASES_RAW " << n_user_local << " " << this->
description << std::endl; description << "\n";
// eltList // eltList
s_oss << indent1; s_oss << indent1;
s_oss << "-eltList " << std::endl; s_oss << "-eltList " << "\n";
this->eltList.dump_raw(s_oss, indent + 2); this->eltList.dump_raw(s_oss, indent + 2);
// ppAssemblagComps // ppAssemblagComps
@ -138,7 +138,7 @@ cxxPPassemblage::dump_raw(std::ostream & s_oss, unsigned int indent, int *n_out)
ppAssemblageComps.begin(); it != ppAssemblageComps.end(); ++it) ppAssemblageComps.begin(); it != ppAssemblageComps.end(); ++it)
{ {
s_oss << indent1; s_oss << indent1;
s_oss << "-component" << std::endl; s_oss << "-component" << "\n";
(*it).second.dump_raw(s_oss, indent + 2); (*it).second.dump_raw(s_oss, indent + 2);
} }
} }
@ -191,8 +191,8 @@ cxxPPassemblage::read_raw(CParser & parser, bool check)
opt = CParser::OPT_EOF; opt = CParser::OPT_EOF;
parser. parser.
error_msg("Unknown input in EQUILIBRIUM_PHASES_RAW keyword.", error_msg("Unknown input in EQUILIBRIUM_PHASES_RAW keyword.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
parser.error_msg(parser.line().c_str(), CParser::OT_CONTINUE); parser.error_msg(parser.line().c_str(), PHRQ_io::OT_CONTINUE);
useLastLine = false; useLastLine = false;
break; break;
@ -203,7 +203,7 @@ cxxPPassemblage::read_raw(CParser & parser, bool check)
parser.incr_input_error(); parser.incr_input_error();
parser. parser.
error_msg("Expected element name and moles for totals.", error_msg("Expected element name and moles for totals.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
opt_save = 0; opt_save = 0;
break; break;

View File

@ -73,21 +73,21 @@ cxxPPassemblageComp::dump_xml(std::ostream & s_oss, unsigned int indent) const
// Pure_Phase element and attributes // Pure_Phase element and attributes
s_oss << indent0 << "name=\"" << this->name << "\"" << std::endl; s_oss << indent0 << "name=\"" << this->name << "\"" << "\n";
s_oss << indent0 << "add_formula=\"" << this-> s_oss << indent0 << "add_formula=\"" << this->
add_formula << "\"" << std::endl; add_formula << "\"" << "\n";
s_oss << indent0 << "si=\"" << this->si << "\"" << std::endl; s_oss << indent0 << "si=\"" << this->si << "\"" << "\n";
s_oss << indent0 << "si_org=\"" << this->si_org << "\"" << std::endl; s_oss << indent0 << "si_org=\"" << this->si_org << "\"" << "\n";
s_oss << indent0 << "moles=\"" << this->moles << "\"" << std::endl; s_oss << indent0 << "moles=\"" << this->moles << "\"" << "\n";
s_oss << indent0 << "delta=\"" << this->delta << "\"" << std::endl; s_oss << indent0 << "delta=\"" << this->delta << "\"" << "\n";
s_oss << indent0 << "initial_moles=\"" << this-> s_oss << indent0 << "initial_moles=\"" << this->
initial_moles << "\"" << std::endl; initial_moles << "\"" << "\n";
s_oss << indent0 << "force_equality=\"" << this-> s_oss << indent0 << "force_equality=\"" << this->
force_equality << "\"" << std::endl; force_equality << "\"" << "\n";
s_oss << indent0 << "dissolve_only=\"" << this-> s_oss << indent0 << "dissolve_only=\"" << this->
dissolve_only << "\"" << std::endl; dissolve_only << "\"" << "\n";
s_oss << indent0 << "precipitate_only=\"" << this-> s_oss << indent0 << "precipitate_only=\"" << this->
precipitate_only << "\"" << std::endl; precipitate_only << "\"" << "\n";
} }
@ -108,17 +108,17 @@ cxxPPassemblageComp::dump_raw(std::ostream & s_oss, unsigned int indent) const
// Pure_Phase element and attributes // Pure_Phase element and attributes
if (this->name.size() != 0) if (this->name.size() != 0)
s_oss << indent0 << "-name " << this->name << std::endl; s_oss << indent0 << "-name " << this->name << "\n";
if (this->add_formula.size() != 0) if (this->add_formula.size() != 0)
s_oss << indent1 << "-add_formula " << this->add_formula << std::endl; s_oss << indent1 << "-add_formula " << this->add_formula << "\n";
s_oss << indent1 << "-si " << this->si << std::endl; s_oss << indent1 << "-si " << this->si << "\n";
s_oss << indent1 << "-si_org " << this->si_org << std::endl; s_oss << indent1 << "-si_org " << this->si_org << "\n";
s_oss << indent1 << "-moles " << this->moles << std::endl; s_oss << indent1 << "-moles " << this->moles << "\n";
s_oss << indent1 << "-delta " << this->delta << std::endl; s_oss << indent1 << "-delta " << this->delta << "\n";
s_oss << indent1 << "-initial_moles " << this->initial_moles << std::endl; s_oss << indent1 << "-initial_moles " << this->initial_moles << "\n";
s_oss << indent1 << "-force_equality " << this->force_equality << std::endl; s_oss << indent1 << "-force_equality " << this->force_equality << "\n";
s_oss << indent1 << "-dissolve_only " << this->dissolve_only << std::endl; s_oss << indent1 << "-dissolve_only " << this->dissolve_only << "\n";
s_oss << indent1 << "-precipitate_only " << this->precipitate_only << std::endl; s_oss << indent1 << "-precipitate_only " << this->precipitate_only << "\n";
} }
void void
@ -176,8 +176,8 @@ cxxPPassemblageComp::read_raw(CParser & parser, bool check)
case CParser::OPT_ERROR: case CParser::OPT_ERROR:
opt = CParser::OPT_KEYWORD; opt = CParser::OPT_KEYWORD;
// Allow return to Exchange for more processing // Allow return to Exchange for more processing
//parser.error_msg("Unknown input in PURE_PHASE read.", CParser::OT_CONTINUE); //parser.error_msg("Unknown input in PURE_PHASE read.", PHRQ_io::OT_CONTINUE);
//parser.error_msg(parser.line().c_str(), CParser::OT_CONTINUE); //parser.error_msg(parser.line().c_str(), PHRQ_io::OT_CONTINUE);
break; break;
case 0: // name case 0: // name
@ -186,7 +186,7 @@ cxxPPassemblageComp::read_raw(CParser & parser, bool check)
this->name.clear(); this->name.clear();
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Expected string value for name.", parser.error_msg("Expected string value for name.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
else else
{ {
@ -201,7 +201,7 @@ cxxPPassemblageComp::read_raw(CParser & parser, bool check)
this->add_formula.clear(); this->add_formula.clear();
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Expected string value for add_formula.", parser.error_msg("Expected string value for add_formula.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
else else
{ {
@ -215,7 +215,7 @@ cxxPPassemblageComp::read_raw(CParser & parser, bool check)
this->si = 0; this->si = 0;
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Expected numeric value for si.", parser.error_msg("Expected numeric value for si.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
si_defined = true; si_defined = true;
break; break;
@ -226,7 +226,7 @@ cxxPPassemblageComp::read_raw(CParser & parser, bool check)
this->moles = 0; this->moles = 0;
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Expected numeric value for moles.", parser.error_msg("Expected numeric value for moles.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
moles_defined = true; moles_defined = true;
break; break;
@ -237,7 +237,7 @@ cxxPPassemblageComp::read_raw(CParser & parser, bool check)
this->delta = 0; this->delta = 0;
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Expected numeric value for delta.", parser.error_msg("Expected numeric value for delta.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
delta_defined = true; delta_defined = true;
break; break;
@ -248,7 +248,7 @@ cxxPPassemblageComp::read_raw(CParser & parser, bool check)
this->initial_moles = 0; this->initial_moles = 0;
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Expected numeric value for initial_moles.", parser.error_msg("Expected numeric value for initial_moles.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
initial_moles_defined = true; initial_moles_defined = true;
break; break;
@ -260,7 +260,7 @@ cxxPPassemblageComp::read_raw(CParser & parser, bool check)
this->dissolve_only = false; this->dissolve_only = false;
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Expected boolean value for dissolve_only.", parser.error_msg("Expected boolean value for dissolve_only.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
dissolve_only_defined = true; dissolve_only_defined = true;
if (this->dissolve_only) if (this->dissolve_only)
@ -275,7 +275,7 @@ cxxPPassemblageComp::read_raw(CParser & parser, bool check)
this->force_equality = false; this->force_equality = false;
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Expected boolean value for force_equality.", parser.error_msg("Expected boolean value for force_equality.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
force_equality_defined = true; force_equality_defined = true;
break; break;
@ -286,7 +286,7 @@ cxxPPassemblageComp::read_raw(CParser & parser, bool check)
this->precipitate_only = false; this->precipitate_only = false;
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Expected boolean value for precipitate_only.", parser.error_msg("Expected boolean value for precipitate_only.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
precipitate_only_defined = true; precipitate_only_defined = true;
if (this->precipitate_only) if (this->precipitate_only)
@ -300,7 +300,7 @@ cxxPPassemblageComp::read_raw(CParser & parser, bool check)
this->si_org = 0; this->si_org = 0;
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Expected numeric value for si_org.", parser.error_msg("Expected numeric value for si_org.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
si_org_defined = true; si_org_defined = true;
break; break;
@ -315,37 +315,37 @@ cxxPPassemblageComp::read_raw(CParser & parser, bool check)
{ {
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Name not defined for PPassemblageComp input.", parser.error_msg("Name not defined for PPassemblageComp input.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
if (si_defined == false) if (si_defined == false)
{ {
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Si not defined for PPassemblageComp input.", parser.error_msg("Si not defined for PPassemblageComp input.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
if (moles_defined == false) if (moles_defined == false)
{ {
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Moles not defined for PPassemblageComp input.", parser.error_msg("Moles not defined for PPassemblageComp input.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
if (delta_defined == false) if (delta_defined == false)
{ {
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Delta not defined for PPassemblageComp input.", parser.error_msg("Delta not defined for PPassemblageComp input.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
if (initial_moles_defined == false) if (initial_moles_defined == false)
{ {
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Initial_moles not defined for PPassemblageComp input.", parser.error_msg("Initial_moles not defined for PPassemblageComp input.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
if (dissolve_only_defined == false) if (dissolve_only_defined == false)
{ {
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Dissolve_only not defined for PPassemblageComp input.", parser.error_msg("Dissolve_only not defined for PPassemblageComp input.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
/* don't check to maintain backward compatibility /* don't check to maintain backward compatibility
if (precipitate_only_defined == false) if (precipitate_only_defined == false)
@ -353,7 +353,7 @@ cxxPPassemblageComp::read_raw(CParser & parser, bool check)
parser.incr_input_error(); parser.incr_input_error();
parser. parser.
error_msg("Precipitate_only not defined for PPassemblageComp input.", error_msg("Precipitate_only not defined for PPassemblageComp input.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
*/ */
if (force_equality_defined == false) if (force_equality_defined == false)
@ -361,13 +361,13 @@ cxxPPassemblageComp::read_raw(CParser & parser, bool check)
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg parser.error_msg
("Force_equality not defined for PPassemblageComp input.", ("Force_equality not defined for PPassemblageComp input.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
if (si_org_defined == false) if (si_org_defined == false)
{ {
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Si_org not defined for PPassemblageComp input.", parser.error_msg("Si_org not defined for PPassemblageComp input.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
} }
} }

View File

@ -19,12 +19,36 @@
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
// Construction/Destruction // Construction/Destruction
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
CParser::CParser(PHRQ_io *io):
PHRQ_base(io),
m_input_stream(std::cin),
//m_output_stream(std::cout),
//m_error_stream(std::cerr),
m_input_error(0),
m_next_keyword(Keywords::KEY_NONE)
{
if (!io)
{
error_msg("This parser constructor requires non-null phrq_io", PHRQ_io::OT_STOP);
}
m_line_save = io->Get_m_line();
m_line = io->Get_m_line();
m_line_type = io->Get_m_line_type();
m_line_iss.str(m_line);
m_line_iss.seekg(0, std::ios_base::beg);
m_line_iss.clear();
echo_file = EO_ALL;
echo_stream = EO_NONE;
accumulate = false;
phrq_io_only = true;
}
CParser::CParser(std::istream & input, PHRQ_io *io): CParser::CParser(std::istream & input, PHRQ_io *io):
PHRQ_base(io), PHRQ_base(io),
m_input_stream(input), m_input_stream(input),
m_output_stream(std::cout), //m_output_stream(std::cout),
m_error_stream(std::cerr), //m_error_stream(std::cerr),
m_input_error(0), m_input_error(0),
m_next_keyword(Keywords::KEY_NONE) m_next_keyword(Keywords::KEY_NONE)
{ {
@ -33,8 +57,10 @@ m_next_keyword(Keywords::KEY_NONE)
echo_file = EO_ALL; echo_file = EO_ALL;
echo_stream = EO_NONE; echo_stream = EO_NONE;
accumulate = false; accumulate = false;
phrq_io_only = false;
} }
#ifdef SKIP
CParser::CParser(std::istream & input, std::ostream & output, PHRQ_io *io) CParser::CParser(std::istream & input, std::ostream & output, PHRQ_io *io)
: :
PHRQ_base(io), PHRQ_base(io),
@ -66,16 +92,16 @@ m_next_keyword(Keywords::KEY_NONE)
echo_stream = EO_NONE; echo_stream = EO_NONE;
accumulate = false; accumulate = false;
} }
#endif
CParser::~CParser() CParser::~CParser()
{ {
} }
CParser::LINE_TYPE CParser::check_line(const std::string & str, PHRQ_io::LINE_TYPE CParser::check_line(const std::string & str,
bool allow_empty, bool allow_eof, bool allow_empty, bool allow_eof,
bool allow_keyword, bool print) bool allow_keyword, bool print)
{ {
LINE_TYPE PHRQ_io::LINE_TYPE
i; i;
// Get line // Get line
@ -93,27 +119,30 @@ CParser::LINE_TYPE CParser::check_line(const std::string & str,
case EO_NONE: case EO_NONE:
break; break;
case EO_ALL: case EO_ALL:
if (i != LT_EOF) if (i != PHRQ_io::LT_EOF)
{ {
std::ostringstream msg; std::ostringstream msg;
msg << "\t" << m_line_save << "\n"; msg << "\t" << m_line_save << "\n";
get_output() << msg; //get_output() << msg;
io->output_msg(msg.str().c_str());
} }
break; break;
case EO_KEYWORDS: case EO_KEYWORDS:
if (i == LT_KEYWORD) if (i == PHRQ_io::LT_KEYWORD)
{ {
std::ostringstream msg; std::ostringstream msg;
msg << "\t" << m_line_save << "\n"; msg << "\t" << m_line_save << "\n";
get_output() << msg; //get_output() << msg;
io->output_msg(msg.str().c_str());
} }
break; break;
case EO_NOKEYWORDS: case EO_NOKEYWORDS:
if (i != LT_KEYWORD && i != LT_EOF) if (i != PHRQ_io::LT_KEYWORD && i != PHRQ_io::LT_EOF)
{ {
std::ostringstream msg; std::ostringstream msg;
msg << "\t" << m_line_save << "\n"; msg << "\t" << m_line_save << "\n";
get_output() << msg; //get_output() << msg;
io->output_msg(msg.str().c_str());
} }
break; break;
} }
@ -123,7 +152,7 @@ CParser::LINE_TYPE CParser::check_line(const std::string & str,
case EO_NONE: case EO_NONE:
break; break;
case EO_ALL: case EO_ALL:
if (i != LT_EOF) if (i != PHRQ_io::LT_EOF)
{ {
std::ostringstream msg; std::ostringstream msg;
msg << "\t" << m_line_save << "\n"; msg << "\t" << m_line_save << "\n";
@ -131,7 +160,7 @@ CParser::LINE_TYPE CParser::check_line(const std::string & str,
} }
break; break;
case EO_KEYWORDS: case EO_KEYWORDS:
if (i == LT_KEYWORD) if (i == PHRQ_io::LT_KEYWORD)
{ {
std::ostringstream msg; std::ostringstream msg;
msg << "\t" << m_line_save << "\n"; msg << "\t" << m_line_save << "\n";
@ -140,7 +169,7 @@ CParser::LINE_TYPE CParser::check_line(const std::string & str,
break; break;
case EO_NOKEYWORDS: case EO_NOKEYWORDS:
if (i != LT_KEYWORD && i != LT_EOF) if (i != PHRQ_io::LT_KEYWORD && i != PHRQ_io::LT_EOF)
{ {
std::ostringstream msg; std::ostringstream msg;
msg << "\t" << m_line_save << "\n"; msg << "\t" << m_line_save << "\n";
@ -149,34 +178,51 @@ CParser::LINE_TYPE CParser::check_line(const std::string & str,
break; break;
} }
} }
while (i == LT_EMPTY && allow_empty == false); while (i == PHRQ_io::LT_EMPTY && allow_empty == false);
// Check eof // Check eof
if (i == LT_EOF && allow_eof == false) if (i == PHRQ_io::LT_EOF && allow_eof == false)
{ {
std::ostringstream msg; std::ostringstream msg;
msg << "Unexpected eof while reading " << str << msg << "Unexpected eof while reading " << str <<
"\nExecution terminated.\n"; "\nExecution terminated.\n";
error_msg(msg.str().c_str(), OT_STOP); error_msg(msg.str().c_str(), PHRQ_io::OT_STOP);
} }
// Check keyword // Check keyword
if (i == LT_KEYWORD && allow_keyword == false) if (i == PHRQ_io::LT_KEYWORD && allow_keyword == false)
{ {
std::ostringstream msg; std::ostringstream msg;
msg << "Expected data for " << str << msg << "Expected data for " << str <<
", but got a keyword ending data block."; ", but got a keyword ending data block.";
error_msg(msg.str().c_str(), OT_CONTINUE); error_msg(msg.str().c_str(), PHRQ_io::OT_CONTINUE);
incr_input_error(); incr_input_error();
} }
m_line_type = i; m_line_type = i;
return i; return i;
} }
PHRQ_io::LINE_TYPE CParser::get_line_phrq_io()
CParser::LINE_TYPE CParser::get_line()
{ {
CParser::LINE_TYPE return_value = LT_EMPTY; m_line_type = io->get_line();
while (return_value == LT_EMPTY) m_line_save = io->Get_m_line_save();
m_line = io->Get_m_line();
m_next_keyword = io->Get_m_next_keyword();
if (accumulate)
{
this->accumulated.append(m_line_save);
this->accumulated.append("\n");
}
return m_line_type;
}
PHRQ_io::LINE_TYPE CParser::get_line()
{
if (this->phrq_io_only)
{
return get_line_phrq_io();
}
PHRQ_io::LINE_TYPE return_value = PHRQ_io::LT_EMPTY;
while (return_value == PHRQ_io::LT_EMPTY)
{ {
// //
// Eliminate all characters after # sign as a comment // Eliminate all characters after # sign as a comment
@ -185,12 +231,12 @@ CParser::LINE_TYPE CParser::get_line()
// //
// Get line, check for eof // Get line, check for eof
// //
if (get_logical_line() == LT_EOF) if (get_logical_line() == PHRQ_io::LT_EOF)
{ {
if (!m_input_stream.eof()) if (!m_input_stream.eof())
{ {
error_msg("Reading input file.", OT_CONTINUE); error_msg("Reading input file.", PHRQ_io::OT_CONTINUE);
error_msg("istream::get() returned an error.", OT_STOP); error_msg("istream::get() returned an error.", PHRQ_io::OT_STOP);
} }
else else
{ {
@ -198,7 +244,7 @@ CParser::LINE_TYPE CParser::get_line()
m_line.erase(m_line.begin(), m_line.end()); // m_line.clear(); m_line.erase(m_line.begin(), m_line.end()); // m_line.clear();
//}}MOD //}}MOD
m_next_keyword = Keywords::KEY_END; m_next_keyword = Keywords::KEY_END;
return LT_EOF; return PHRQ_io::LT_EOF;
} }
} }
@ -225,17 +271,17 @@ CParser::LINE_TYPE CParser::get_line()
// //
// New line character encountered // New line character encountered
// //
return_value = (empty ? LT_EMPTY : LT_OK); return_value = (empty ? PHRQ_io::LT_EMPTY : PHRQ_io::LT_OK);
} }
// //
// Determine return_value // Determine return_value
// //
if (return_value == LT_OK) if (return_value == PHRQ_io::LT_OK)
{ {
if (check_key(m_line.begin(), m_line.end())) if (check_key(m_line.begin(), m_line.end()))
{ {
return_value = LT_KEYWORD; return_value = PHRQ_io::LT_KEYWORD;
} }
else else
{ {
@ -246,7 +292,7 @@ CParser::LINE_TYPE CParser::get_line()
if (token.size() > 1 && token[0] == '-' &&::isalpha(token[1])) if (token.size() > 1 && token[0] == '-' &&::isalpha(token[1]))
{ {
return_value = LT_OPTION; return_value = PHRQ_io::LT_OPTION;
} }
} }
} }
@ -261,7 +307,7 @@ CParser::LINE_TYPE CParser::get_line()
EOF on empty line on end of file or EOF on empty line on end of file or
OK otherwise OK otherwise
*/ */
CParser::LINE_TYPE CParser::get_logical_line() PHRQ_io::LINE_TYPE CParser::get_logical_line()
{ {
int int
j; j;
@ -333,9 +379,9 @@ CParser::LINE_TYPE CParser::get_logical_line()
} }
if (j == std::char_traits < char >::eof() && m_line_save.size() == 0) if (j == std::char_traits < char >::eof() && m_line_save.size() == 0)
{ {
return (LT_EOF); return (PHRQ_io::LT_EOF);
} }
return (LT_OK); return (PHRQ_io::LT_OK);
} }
bool bool
@ -396,7 +442,7 @@ CParser::check_key(std::string::iterator begin, std::string::iterator end)
} }
return true; return true;
} }
#ifdef SKIP
CParser::STATUS_TYPE CParser::check_units(std::string & tot_units, CParser::STATUS_TYPE CParser::check_units(std::string & tot_units,
bool alkalinity, bool alkalinity,
bool check_compatibility, bool check_compatibility,
@ -503,7 +549,7 @@ CParser::STATUS_TYPE CParser::check_units(std::string & tot_units,
{ {
std::ostringstream err; std::ostringstream err;
err << "Unknown unit, " << tot_units; err << "Unknown unit, " << tot_units;
error_msg(err.str().c_str(), OT_CONTINUE); error_msg(err.str().c_str(), PHRQ_io::OT_CONTINUE);
} }
return PARSER_ERROR; return PARSER_ERROR;
} }
@ -531,7 +577,7 @@ CParser::STATUS_TYPE CParser::check_units(std::string & tot_units,
if (print) if (print)
{ {
error_msg("Only alkalinity can be entered in equivalents.", error_msg("Only alkalinity can be entered in equivalents.",
OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
return PARSER_ERROR; return PARSER_ERROR;
} }
@ -564,11 +610,11 @@ CParser::STATUS_TYPE CParser::check_units(std::string & tot_units,
std::ostringstream err; std::ostringstream err;
err << "Units for master species, " << tot_units << err << "Units for master species, " << tot_units <<
", are not compatible with default units, " << str << "."; ", are not compatible with default units, " << str << ".";
error_msg(err.str().c_str(), OT_CONTINUE); error_msg(err.str().c_str(), PHRQ_io::OT_CONTINUE);
} }
return PARSER_ERROR; return PARSER_ERROR;
} }
#endif
CParser::TOKEN_TYPE CParser::token_type(const std::string & token) CParser::TOKEN_TYPE CParser::token_type(const std::string & token)
{ {
if (!token.empty()) if (!token.empty())
@ -696,16 +742,16 @@ CParser::get_option(const std::vector < std::string > &opt_list,
// //
// Read line // Read line
// //
LINE_TYPE lt = check_line("get_option", false, true, true, true); PHRQ_io::LINE_TYPE lt = check_line("get_option", false, true, true, true);
if (lt == LT_EOF) if (lt == PHRQ_io::LT_EOF)
{ {
j = OPT_EOF; j = OPT_EOF;
} }
else if (lt == LT_KEYWORD) else if (lt == PHRQ_io::LT_KEYWORD)
{ {
j = OPT_KEYWORD; j = OPT_KEYWORD;
} }
else if (lt == LT_OPTION) else if (lt == PHRQ_io::LT_OPTION)
{ {
opt_ptr = m_line.begin(); opt_ptr = m_line.begin();
std::string::iterator end = m_line.end(); std::string::iterator end = m_line.end();
@ -724,7 +770,10 @@ CParser::get_option(const std::vector < std::string > &opt_list,
{ {
if (true) // database_file == NULL if (true) // database_file == NULL
{ {
get_output() << "\t" << m_line_save << "\n"; //get_output() << "\t" << m_line_save << "\n";
std::ostringstream msg;
msg << "\t" << m_line_save << "\n";
io->output_msg(msg.str().c_str());
} }
} }
} }
@ -732,7 +781,10 @@ CParser::get_option(const std::vector < std::string > &opt_list,
{ {
if (true) // (database_file == NULL) if (true) // (database_file == NULL)
{ {
get_output() << "\t" << m_line_save << "\n"; //get_output() << "\t" << m_line_save << "\n";
std::ostringstream msg;
msg << "\t" << m_line_save << "\n";
io->output_msg(msg.str().c_str());
} }
std::ostringstream err; std::ostringstream err;
@ -785,16 +837,16 @@ CParser::get_option(const std::vector < std::string > &opt_list,
// //
// Read line // Read line
// //
LINE_TYPE lt = check_line("get_option", false, true, true, true); PHRQ_io::LINE_TYPE lt = check_line("get_option", false, true, true, true);
if (lt == LT_EOF) if (lt == PHRQ_io::LT_EOF)
{ {
j = OPT_EOF; j = OPT_EOF;
} }
else if (lt == LT_KEYWORD) else if (lt == PHRQ_io::LT_KEYWORD)
{ {
j = OPT_KEYWORD; j = OPT_KEYWORD;
} }
else if (lt == LT_OPTION) else if (lt == PHRQ_io::LT_OPTION)
{ {
std::string::iterator opt_ptr = m_line.begin(); std::string::iterator opt_ptr = m_line.begin();
std::string::iterator end = m_line.end(); std::string::iterator end = m_line.end();
@ -850,7 +902,7 @@ CParser::STATUS_TYPE CParser::get_elt(std::string::iterator & begin,
if (begin == end) if (begin == end)
{ {
error_msg("Empty string in get_elt. Expected an element name.", error_msg("Empty string in get_elt. Expected an element name.",
OT_CONTINUE); PHRQ_io::OT_CONTINUE);
return PARSER_ERROR; return PARSER_ERROR;
} }
@ -876,7 +928,7 @@ CParser::STATUS_TYPE CParser::get_elt(std::string::iterator & begin,
else if (begin == end) else if (begin == end)
{ {
error_msg("No ending bracket (]) for element name", error_msg("No ending bracket (]) for element name",
OT_CONTINUE); PHRQ_io::OT_CONTINUE);
incr_input_error(); incr_input_error();
return PARSER_ERROR; return PARSER_ERROR;
} }
@ -925,7 +977,7 @@ CParser::STATUS_TYPE CParser::parse_couple(std::string & token)
std::ostringstream err_msg; std::ostringstream err_msg;
err_msg << "Element name must be followed by " << err_msg << "Element name must be followed by " <<
"parentheses in redox couple, " << token << "."; "parentheses in redox couple, " << token << ".";
error_msg(err_msg.str().c_str(), OT_CONTINUE); error_msg(err_msg.str().c_str(), PHRQ_io::OT_CONTINUE);
incr_input_error(); incr_input_error();
return PARSER_ERROR; return PARSER_ERROR;
} }
@ -941,7 +993,7 @@ CParser::STATUS_TYPE CParser::parse_couple(std::string & token)
std::ostringstream err_msg; std::ostringstream err_msg;
err_msg << "End of line or " "/" err_msg << "End of line or " "/"
" encountered before end of parentheses, " << token << "."; " encountered before end of parentheses, " << token << ".";
error_msg(err_msg.str().c_str(), OT_CONTINUE); error_msg(err_msg.str().c_str(), PHRQ_io::OT_CONTINUE);
return PARSER_ERROR; return PARSER_ERROR;
} }
paren1.insert(paren1.end(), *ptr); // element.push_back(c); paren1.insert(paren1.end(), *ptr); // element.push_back(c);
@ -959,7 +1011,7 @@ CParser::STATUS_TYPE CParser::parse_couple(std::string & token)
std::ostringstream err_msg; std::ostringstream err_msg;
err_msg << " " "/" " must follow parentheses " << err_msg << " " "/" " must follow parentheses " <<
"ending first half of redox couple, " << token << "."; "ending first half of redox couple, " << token << ".";
error_msg(err_msg.str().c_str(), OT_CONTINUE); error_msg(err_msg.str().c_str(), PHRQ_io::OT_CONTINUE);
return PARSER_ERROR; return PARSER_ERROR;
} }
++ptr; ++ptr;
@ -970,7 +1022,7 @@ CParser::STATUS_TYPE CParser::parse_couple(std::string & token)
std::ostringstream err_msg; std::ostringstream err_msg;
err_msg << "Redox couple must be two redox states " << err_msg << "Redox couple must be two redox states " <<
"of the same element, " << token << "."; "of the same element, " << token << ".";
error_msg(err_msg.str().c_str(), OT_CONTINUE); error_msg(err_msg.str().c_str(), PHRQ_io::OT_CONTINUE);
return PARSER_ERROR; return PARSER_ERROR;
} }
if (*ptr != '(') if (*ptr != '(')
@ -978,7 +1030,7 @@ CParser::STATUS_TYPE CParser::parse_couple(std::string & token)
std::ostringstream err_msg; std::ostringstream err_msg;
err_msg << "Element name must be followed by " err_msg << "Element name must be followed by "
"parentheses in redox couple, " << token << "."; "parentheses in redox couple, " << token << ".";
error_msg(err_msg.str().c_str(), OT_CONTINUE); error_msg(err_msg.str().c_str(), PHRQ_io::OT_CONTINUE);
incr_input_error(); incr_input_error();
return PARSER_ERROR; return PARSER_ERROR;
} }
@ -993,7 +1045,7 @@ CParser::STATUS_TYPE CParser::parse_couple(std::string & token)
std::ostringstream err_msg; std::ostringstream err_msg;
err_msg << "End of line or " "/" err_msg << "End of line or " "/"
" encountered before end of parentheses, " << token << "."; " encountered before end of parentheses, " << token << ".";
error_msg(err_msg.str().c_str(), OT_CONTINUE); error_msg(err_msg.str().c_str(), PHRQ_io::OT_CONTINUE);
return PARSER_ERROR; return PARSER_ERROR;
} }
paren2.insert(paren2.end(), *ptr); // element.push_back(c); paren2.insert(paren2.end(), *ptr); // element.push_back(c);
@ -1017,7 +1069,7 @@ CParser::STATUS_TYPE CParser::parse_couple(std::string & token)
std::ostringstream err_msg; std::ostringstream err_msg;
err_msg << "Both parts of redox couple are the same, " << err_msg << "Both parts of redox couple are the same, " <<
token << "."; token << ".";
error_msg(err_msg.str().c_str(), OT_CONTINUE); error_msg(err_msg.str().c_str(), PHRQ_io::OT_CONTINUE);
return PARSER_ERROR; return PARSER_ERROR;
} }
return PARSER_OK; return PARSER_OK;
@ -1036,7 +1088,7 @@ CParser::STATUS_TYPE CParser::addPair(std::map < std::string, double >&totals,
j = copy_token(token, pos); j = copy_token(token, pos);
if (j == TT_EMPTY) if (j == CParser::TT_EMPTY)
return PARSER_OK; return PARSER_OK;
if (!(m_line_iss >> d)) if (!(m_line_iss >> d))
@ -1067,16 +1119,16 @@ CParser::getOptionFromLastLine(const std::vector < std::string > &opt_list,
// //
// Read line // Read line
// //
LINE_TYPE lt = m_line_type; PHRQ_io::LINE_TYPE lt = m_line_type;
if (lt == LT_EOF) if (lt == PHRQ_io::LT_EOF)
{ {
j = OPT_EOF; j = OPT_EOF;
} }
else if (lt == LT_KEYWORD) else if (lt == PHRQ_io::LT_KEYWORD)
{ {
j = OPT_KEYWORD; j = OPT_KEYWORD;
} }
else if (lt == LT_OPTION) else if (lt == PHRQ_io::LT_OPTION)
{ {
opt_ptr = m_line.begin(); opt_ptr = m_line.begin();
std::string::iterator end = m_line.end(); std::string::iterator end = m_line.end();
@ -1095,7 +1147,10 @@ CParser::getOptionFromLastLine(const std::vector < std::string > &opt_list,
{ {
if (true) // database_file == NULL if (true) // database_file == NULL
{ {
get_output() << "\t" << m_line_save << "\n"; //get_output() << "\t" << m_line_save << "\n";
std::ostringstream msg;
msg << "\t" << m_line_save << "\n";
io->output_msg(msg.str().c_str());
} }
} }
} }
@ -1103,7 +1158,10 @@ CParser::getOptionFromLastLine(const std::vector < std::string > &opt_list,
{ {
if (true) // (database_file == NULL) if (true) // (database_file == NULL)
{ {
get_output() << "\t" << m_line_save << "\n"; //get_output() << "\t" << m_line_save << "\n";
std::ostringstream msg;
msg << "\t" << m_line_save << "\n";
io->output_msg(msg.str().c_str());
} }
//std::cerr << "Unknown option." << "\n"; //std::cerr << "Unknown option." << "\n";
//std::cerr << m_line_save << "\n"; //std::cerr << m_line_save << "\n";
@ -1157,16 +1215,16 @@ CParser::getOptionFromLastLine(const std::vector < std::string > &opt_list,
// //
// Read line // Read line
// //
LINE_TYPE lt = m_line_type; PHRQ_io::LINE_TYPE lt = m_line_type;
if (lt == LT_EOF) if (lt == PHRQ_io::LT_EOF)
{ {
j = OPT_EOF; j = OPT_EOF;
} }
else if (lt == LT_KEYWORD) else if (lt == PHRQ_io::LT_KEYWORD)
{ {
j = OPT_KEYWORD; j = OPT_KEYWORD;
} }
else if (lt == LT_OPTION) else if (lt == PHRQ_io::LT_OPTION)
{ {
std::string::iterator opt_ptr = m_line.begin(); std::string::iterator opt_ptr = m_line.begin();
std::string::iterator end = m_line.end(); std::string::iterator end = m_line.end();
@ -1191,7 +1249,10 @@ CParser::getOptionFromLastLine(const std::vector < std::string > &opt_list,
{ {
if (true) // database_file == NULL if (true) // database_file == NULL
{ {
get_output() << "\t" << m_line_save << "\n"; //get_output() << "\t" << m_line_save << "\n";
std::ostringstream msg;
msg << "\t" << m_line_save << "\n";
io->output_msg(msg.str().c_str());
} }
} }
} }
@ -1199,10 +1260,13 @@ CParser::getOptionFromLastLine(const std::vector < std::string > &opt_list,
{ {
if (true) // (database_file == NULL) if (true) // (database_file == NULL)
{ {
get_output() << "\t" << m_line_save << "\n"; //get_output() << "\t" << m_line_save << "\n";
std::ostringstream msg;
msg << "\t" << m_line_save << "\n";
io->output_msg(msg.str().c_str());
} }
error_msg("Unknown option.", OT_CONTINUE); error_msg("Unknown option.", PHRQ_io::OT_CONTINUE);
error_msg(m_line_save.c_str(), OT_CONTINUE); error_msg(m_line_save.c_str(), PHRQ_io::OT_CONTINUE);
incr_input_error(); incr_input_error();
j = OPT_ERROR; j = OPT_ERROR;
next_pos = pos_ptr; next_pos = pos_ptr;
@ -1226,7 +1290,10 @@ CParser::getOptionFromLastLine(const std::vector < std::string > &opt_list,
{ {
if (true) // database_file == NULL if (true) // database_file == NULL
{ {
get_output() << "\t" << m_line_save << "\n"; //get_output() << "\t" << m_line_save << "\n";
std::ostringstream msg;
msg << "\t" << m_line_save << "\n";
io->output_msg(msg.str().c_str());
} }
} }
} }
@ -1304,7 +1371,7 @@ bool CParser::get_true_false(std::istream::pos_type & pos, bool def)
CParser::TOKEN_TYPE CParser::get_rest_of_line(std::string &token) CParser::TOKEN_TYPE CParser::get_rest_of_line(std::string &token)
{ {
token.clear(); token.clear();
std::istringstream::pos_type pos = m_line_iss.tellg(); //std::istringstream::pos_type pos = m_line_iss.tellg();
int j; int j;
while ((j = m_line_iss.get()) != std::char_traits < char >::eof()) while ((j = m_line_iss.get()) != std::char_traits < char >::eof())
{ {

View File

@ -12,18 +12,21 @@
#include <istream> // std::istream #include <istream> // std::istream
#include "PHRQ_base.h" #include "PHRQ_base.h"
#include "Keywords.h" #include "Keywords.h"
#include "PHRQ_io.h"
class CParser: public PHRQ_base class CParser: public PHRQ_base
{ {
public: public:
CParser(PHRQ_io *io=NULL);
CParser(std::istream & input, PHRQ_io *io=NULL); CParser(std::istream & input, PHRQ_io *io=NULL);
CParser(std::istream & input, std::ostream & output, PHRQ_io *io=NULL); //CParser(std::istream & input, std::ostream & output, PHRQ_io *io=NULL);
CParser(std::istream & input, std::ostream & output, //CParser(std::istream & input, std::ostream & output,
std::ostream & error, PHRQ_io *io=NULL); // std::ostream & error, PHRQ_io *io=NULL);
virtual ~ CParser(); virtual ~ CParser();
#ifdef SKIP
enum LINE_TYPE enum LINE_TYPE
{ {
LT_EOF = -1, LT_EOF = -1,
@ -32,7 +35,7 @@ class CParser: public PHRQ_base
LT_KEYWORD = 3, LT_KEYWORD = 3,
LT_OPTION = 8 LT_OPTION = 8
}; };
#endif
enum TOKEN_TYPE enum TOKEN_TYPE
{ {
TT_EMPTY = 2, TT_EMPTY = 2,
@ -48,26 +51,6 @@ class CParser: public PHRQ_base
FT_ERROR = 1 FT_ERROR = 1
}; };
// enum KEY_TYPE
// {
// KT_NONE = -1,
// KT_END = 0,
// KT_EOF = 1,
// KT_SOLUTION_RAW = 5,
// KT_EXCHANGE_RAW = 6,
// KT_GASPHASE_RAW = 7,
// KT_KINETICS_RAW = 8,
// KT_PPASSEMBLAGE_RAW = 9,
// KT_SSASSEMBLAGE_RAW = 10,
// KT_SURFACE_RAW = 11,
// KT_TEMPERATURE_RAW = 12,
// KT_REACTION_RAW = 13,
// KT_MIX_RAW = 14
//#if defined MULTICHART
// , KT_USER_GRAPH = 15
//#endif
// };
enum OPT_TYPE enum OPT_TYPE
{ {
OPT_DEFAULT = -4, OPT_DEFAULT = -4,
@ -75,13 +58,13 @@ class CParser: public PHRQ_base
OPT_KEYWORD = -2, OPT_KEYWORD = -2,
OPT_EOF = -1 OPT_EOF = -1
}; };
#ifdef SKIP
enum ONERROR_TYPE enum ONERROR_TYPE
{ {
OT_CONTINUE = 0, OT_CONTINUE = 0,
OT_STOP = 1 OT_STOP = 1
}; };
#endif
enum ECHO_OPTION enum ECHO_OPTION
{ {
EO_NONE = 0, EO_NONE = 0,
@ -116,7 +99,7 @@ class CParser: public PHRQ_base
Terminates if EOF and allow_eof == false. Terminates if EOF and allow_eof == false.
*/ */
LINE_TYPE check_line(const std::string & str, bool allow_empty, PHRQ_io::LINE_TYPE check_line(const std::string & str, bool allow_empty,
bool allow_eof, bool allow_keyword, bool print); bool allow_eof, bool allow_keyword, bool print);
/** /**
@ -133,14 +116,15 @@ class CParser: public PHRQ_base
LT_OK, LT_OK,
LT_OPTION LT_OPTION
*/ */
LINE_TYPE get_line(); PHRQ_io::LINE_TYPE get_line();
PHRQ_io::LINE_TYPE get_line_phrq_io();
// bool check_key(const std::string::iterator ptr); // bool check_key(const std::string::iterator ptr);
bool check_key(std::string::iterator begin, std::string::iterator end); bool check_key(std::string::iterator begin, std::string::iterator end);
STATUS_TYPE check_units(std::string & tot_units, bool alkalinity, //STATUS_TYPE check_units(std::string & tot_units, bool alkalinity,
bool check_compatibility, // bool check_compatibility,
const std::string & default_units, bool print); // const std::string & default_units, bool print);
//KEY_TYPE next_keyword() const //KEY_TYPE next_keyword() const
@ -183,15 +167,15 @@ class CParser: public PHRQ_base
return m_line_iss; return m_line_iss;
} }
int incr_input_error(); int incr_input_error();
std::ostream & get_output() //std::ostream & get_output()
{ //{
return m_output_stream; // return m_output_stream;
} //}
int get_input_error() int get_input_error()
{ {
return m_input_error; return m_input_error;
} }
#ifdef SKIP
std::istream::pos_type tellg() std::istream::pos_type tellg()
{ {
return m_input_stream.tellg(); return m_input_stream.tellg();
@ -200,6 +184,7 @@ class CParser: public PHRQ_base
{ {
return m_input_stream.seekg(p); return m_input_stream.seekg(p);
} }
#endif
@ -219,18 +204,18 @@ class CParser: public PHRQ_base
TT_DIGIT TT_DIGIT
TT_UNKNOWN TT_UNKNOWN
*/ */
static TOKEN_TYPE copy_token(std::string & token, static CParser::TOKEN_TYPE copy_token(std::string & token,
std::string::iterator & begin, std::string::iterator & begin,
std::string::iterator & end); std::string::iterator & end);
static CParser::TOKEN_TYPE copy_title(std::string & token, static CParser::TOKEN_TYPE copy_title(std::string & token,
std::string::iterator & begin, std::string::iterator & begin,
std::string::iterator & end); std::string::iterator & end);
static TOKEN_TYPE token_type(const std::string & token); static CParser::TOKEN_TYPE token_type(const std::string & token);
static TOKEN_TYPE copy_token(std::string & token, std::istream & is); static CParser::TOKEN_TYPE copy_token(std::string & token, std::istream & is);
TOKEN_TYPE copy_token(std::string & token, std::istream::pos_type & pos); CParser::TOKEN_TYPE copy_token(std::string & token, std::istream::pos_type & pos);
bool get_true_false(std::istream::pos_type & pos, bool def); bool get_true_false(std::istream::pos_type & pos, bool def);
TOKEN_TYPE get_rest_of_line(std::string &token); CParser::TOKEN_TYPE get_rest_of_line(std::string &token);
static TOKEN_TYPE parse_delimited(std::string & source, std::string & result, const std::string& t); static CParser::TOKEN_TYPE parse_delimited(std::string & source, std::string & result, const std::string& t);
CParser::TOKEN_TYPE peek_token(); CParser::TOKEN_TYPE peek_token();
/** /**
@ -294,23 +279,24 @@ class CParser: public PHRQ_base
std::istream::pos_type & pos); std::istream::pos_type & pos);
protected: protected:
LINE_TYPE get_logical_line(); PHRQ_io::LINE_TYPE get_logical_line();
protected: protected:
std::istream & m_input_stream; std::istream & m_input_stream;
std::ostream & m_output_stream; //std::ostream & m_output_stream;
std::ostream & m_error_stream; //std::ostream & m_error_stream;
int m_input_error; int m_input_error;
//KEY_TYPE m_next_keyword; //KEY_TYPE m_next_keyword;
Keywords::KEYWORDS m_next_keyword; Keywords::KEYWORDS m_next_keyword;
std::string m_line; std::string m_line;
std::string m_line_save; std::string m_line_save;
std::istringstream m_line_iss; std::istringstream m_line_iss;
LINE_TYPE m_line_type; PHRQ_io::LINE_TYPE m_line_type;
ECHO_OPTION echo_stream; ECHO_OPTION echo_stream;
ECHO_OPTION echo_file; ECHO_OPTION echo_file;
std::string accumulated; std::string accumulated;
bool accumulate; bool accumulate;
bool phrq_io_only;
}; };

View File

@ -186,13 +186,25 @@ size_t Phreeqc::list_components(std::list<std::string> &list_c)
} }
// irreversible reactions // irreversible reactions
for (i = 0; i < count_irrev; i++)
{ {
reaction_calc(&irrev[i]); std::map<int, cxxReaction>::const_iterator cit = Rxn_reaction_map.begin();
cxxReaction entity(&irrev[i]); for (; cit != Rxn_reaction_map.end(); cit++)
accumulator.add_extensive(entity.Get_elementList(), 1.0); {
cxxReaction r_ptr(cit->second);
reaction_calc(&r_ptr);
accumulator.add_extensive(r_ptr.Get_elementList(), 1.0);
}
} }
#ifdef SKIP
{
for (i = 0; i < count_irrev; i++)
{
reaction_calc(&irrev[i]);
cxxReaction entity(&irrev[i]);
accumulator.add_extensive(entity.Get_elementList(), 1.0);
}
}
#endif
// pure phases // pure phases
for (i = 0; i < count_pp_assemblage; i++) for (i = 0; i < count_pp_assemblage; i++)
{ {
@ -202,19 +214,23 @@ size_t Phreeqc::list_components(std::list<std::string> &list_c)
} }
// exchangers // exchangers
//for (i = 0; i < count_exchange; i++) #ifdef SKIP
//{ for (i = 0; i < count_exchange; i++)
// cxxExchange entity(&exchange[i], phrq_io);
// entity.totalize();
// accumulator.add_extensive(entity.Get_totals(), 1.0);
//}
std::map<int, cxxExchange>::const_iterator cit = Rxn_exchange_map.begin();
for (; cit != Rxn_exchange_map.end(); cit++)
{ {
cxxExchange entity = cit->second; cxxExchange entity(&exchange[i], phrq_io);
entity.totalize(); entity.totalize();
accumulator.add_extensive(entity.Get_totals(), 1.0); accumulator.add_extensive(entity.Get_totals(), 1.0);
} }
#endif
{
std::map<int, cxxExchange>::const_iterator cit = Rxn_exchange_map.begin();
for (; cit != Rxn_exchange_map.end(); cit++)
{
cxxExchange entity = cit->second;
entity.totalize();
accumulator.add_extensive(entity.Get_totals(), 1.0);
}
}
// surfaces // surfaces
for (i = 0; i < count_surface; i++) for (i = 0; i < count_surface; i++)
@ -225,13 +241,23 @@ size_t Phreeqc::list_components(std::list<std::string> &list_c)
} }
// gas phases // gas phases
{
std::map<int, cxxGasPhase>::const_iterator cit = Rxn_gas_phase_map.begin();
for (; cit != Rxn_gas_phase_map.end(); cit++)
{
cxxGasPhase entity = cit->second;
entity.totalize(this);
accumulator.add_extensive(entity.Get_totals(), 1.0);
}
}
#ifdef SKIP
for (i = 0; i < count_gas_phase; i++) for (i = 0; i < count_gas_phase; i++)
{ {
cxxGasPhase entity(&gas_phase[i], phrq_io); cxxGasPhase entity(&gas_phase[i], phrq_io);
entity.totalize(this); entity.totalize(this);
accumulator.add_extensive(entity.Get_totals(), 1.0); accumulator.add_extensive(entity.Get_totals(), 1.0);
} }
#endif
// solid-solutions // solid-solutions
for (i = 0; i < count_s_s_assemblage; i++) for (i = 0; i < count_s_s_assemblage; i++)
{ {
@ -320,7 +346,7 @@ void Phreeqc::init(void)
max_pp_assemblage = MAX_PP_ASSEMBLAGE; max_pp_assemblage = MAX_PP_ASSEMBLAGE;
//max_exchange = MAX_PP_ASSEMBLAGE; //max_exchange = MAX_PP_ASSEMBLAGE;
max_surface = MAX_PP_ASSEMBLAGE; max_surface = MAX_PP_ASSEMBLAGE;
max_gas_phase = MAX_PP_ASSEMBLAGE; //max_gas_phase = MAX_PP_ASSEMBLAGE;
max_kinetics = MAX_PP_ASSEMBLAGE; max_kinetics = MAX_PP_ASSEMBLAGE;
max_s_s_assemblage = MAX_PP_ASSEMBLAGE; max_s_s_assemblage = MAX_PP_ASSEMBLAGE;
@ -340,12 +366,12 @@ void Phreeqc::init(void)
count_pp_assemblage = 0; count_pp_assemblage = 0;
//count_exchange = 0; //count_exchange = 0;
count_surface = 0; count_surface = 0;
count_gas_phase = 0; //count_gas_phase = 0;
count_kinetics = 0; count_kinetics = 0;
count_s_s_assemblage = 0; count_s_s_assemblage = 0;
count_elements = 0; count_elements = 0;
count_irrev = 0; //count_irrev = 0;
count_master = 0; count_master = 0;
//count_mix = 0; //count_mix = 0;
count_phases = 0; count_phases = 0;
@ -392,7 +418,7 @@ void Phreeqc::init(void)
pp_assemblage = 0; pp_assemblage = 0;
//exchange = 0; //exchange = 0;
surface = 0; surface = 0;
gas_phase = 0; //gas_phase = 0;
kinetics = 0; kinetics = 0;
s_s_assemblage = 0; s_s_assemblage = 0;
cell_data = 0; cell_data = 0;
@ -403,7 +429,7 @@ void Phreeqc::init(void)
inverse = 0; inverse = 0;
count_inverse = 0; count_inverse = 0;
irrev = 0; //irrev = 0;
line = 0; line = 0;
line_save = 0; line_save = 0;
@ -470,7 +496,7 @@ void Phreeqc::init(void)
use.solution_in = FALSE; use.solution_in = FALSE;
use.pp_assemblage_in = FALSE; use.pp_assemblage_in = FALSE;
use.mix_in = FALSE; use.mix_in = FALSE;
use.irrev_in = FALSE; use.reaction_in = FALSE;
/* /*
* Initialize punch * Initialize punch
*/ */
@ -661,7 +687,7 @@ void Phreeqc::init(void)
copy_gas_phase.n_user = copy_gas_phase.start = copy_gas_phase.end = 0; copy_gas_phase.n_user = copy_gas_phase.start = copy_gas_phase.end = 0;
copy_kinetics.n_user = copy_kinetics.start = copy_kinetics.end = 0; copy_kinetics.n_user = copy_kinetics.start = copy_kinetics.end = 0;
copy_mix.n_user = copy_mix.start = copy_mix.end = 0; copy_mix.n_user = copy_mix.start = copy_mix.end = 0;
copy_irrev.n_user = copy_irrev.start = copy_irrev.end = 0; copy_reaction.n_user = copy_reaction.start = copy_reaction.end = 0;
copy_temperature.n_user = copy_temperature.start = copy_temperature.end = 0; copy_temperature.n_user = copy_temperature.start = copy_temperature.end = 0;
copy_pressure.n_user = copy_pressure.start = copy_pressure.end = 0; copy_pressure.n_user = copy_pressure.start = copy_pressure.end = 0;
@ -712,7 +738,7 @@ void Phreeqc::init(void)
dbg_surface = surface; dbg_surface = surface;
dbg_pp_assemblage = pp_assemblage; dbg_pp_assemblage = pp_assemblage;
dbg_kinetics = kinetics; dbg_kinetics = kinetics;
dbg_irrev = irrev; //dbg_irrev = irrev;
//dbg_mix = mix; //dbg_mix = mix;
dbg_master = master; dbg_master = master;
calculating_deriv = FALSE; calculating_deriv = FALSE;

View File

@ -131,7 +131,7 @@ public:
//int system_total_solids(struct exchange *exchange_ptr, //int system_total_solids(struct exchange *exchange_ptr,
int system_total_solids(cxxExchange *exchange_ptr, int system_total_solids(cxxExchange *exchange_ptr,
struct pp_assemblage *pp_assemblage_ptr, struct pp_assemblage *pp_assemblage_ptr,
struct gas_phase *gas_phase_ptr, cxxGasPhase *gas_phase_ptr,
struct s_s_assemblage *s_s_assemblage_ptr, struct s_s_assemblage *s_s_assemblage_ptr,
struct surface *surface_ptr); struct surface *surface_ptr);
@ -570,7 +570,8 @@ public:
int setup_slack(void); int setup_slack(void);
int setup_master_rxn(struct master **master_ptr_list, int setup_master_rxn(struct master **master_ptr_list,
struct reaction **pe_rxn); struct reaction **pe_rxn);
LDBLE calc_PR(struct phase **phase_ptrs, int n_g, LDBLE P, LDBLE TK, LDBLE V_m); //LDBLE calc_PR(struct phase **phase_ptrs, int n_g, LDBLE P, LDBLE TK, LDBLE V_m);
LDBLE calc_PR(std::vector<struct phase *> phase_ptrs, LDBLE P, LDBLE TK, LDBLE V_m);
LDBLE calc_PR(); LDBLE calc_PR();
int setup_pure_phases(void); int setup_pure_phases(void);
int adjust_setup_pure_phases(void); int adjust_setup_pure_phases(void);
@ -620,7 +621,7 @@ public:
int print_alkalinity(void); int print_alkalinity(void);
int print_diffuse_layer(struct surface_charge *surface_charge_ptr); int print_diffuse_layer(struct surface_charge *surface_charge_ptr);
int print_eh(void); int print_eh(void);
int print_irrev(void); int print_reaction(void);
int print_kinetics(void); int print_kinetics(void);
int print_mix(void); int print_mix(void);
int print_pp_assemblage(void); int print_pp_assemblage(void);
@ -653,11 +654,10 @@ public:
int read_t_c_only(char *ptr, LDBLE *t_c); int read_t_c_only(char *ptr, LDBLE *t_c);
int read_p_c_only(char *ptr, LDBLE * p_c); int read_p_c_only(char *ptr, LDBLE * p_c);
int read_omega_only(char *ptr, LDBLE *omega); int read_omega_only(char *ptr, LDBLE *omega);
//int read_delta_v_only(char *ptr, LDBLE * delta_v);
int read_number_description(char *ptr, int *n_user, int *n_user_end, int read_number_description(char *ptr, int *n_user, int *n_user_end,
char **description, int allow_negative=FALSE); char **description, int allow_negative=FALSE);
int check_key(const char *str); int check_key(const char *str);
int check_units(char *tot_units, int alkalinity, int check_compatibility, int check_units(char * tot_units, int alkalinity, int check_compatibility,
const char *default_units, int print); const char *default_units, int print);
int find_option(const char *item, int *n, const char **list, int count_list, int find_option(const char *item, int *n, const char **list, int count_list,
int exact); int exact);
@ -703,8 +703,10 @@ public:
int read_pure_phases(void); int read_pure_phases(void);
int read_rates(void); int read_rates(void);
int read_reaction(void); int read_reaction(void);
int read_reaction_reactants(struct irrev *irrev_ptr); //int read_reaction_reactants(struct irrev *irrev_ptr);
int read_reaction_steps(struct irrev *irrev_ptr); int read_reaction_reactants(cxxReaction *reaction_ptr);
//int read_reaction_steps(struct irrev *irrev_ptr);
int read_reaction_steps(cxxReaction *reaction_ptr);
int read_solid_solutions(void); int read_solid_solutions(void);
int read_temperature(void); int read_temperature(void);
int read_reaction_temps(struct temperature *temperature_ptr); int read_reaction_temps(struct temperature *temperature_ptr);
@ -731,26 +733,26 @@ public:
int cleanup_after_parser(CParser &parser); int cleanup_after_parser(CParser &parser);
// ReadClass.cxx // ReadClass.cxx
int read_generic(Keywords::KEYWORDS key);
int read_solution_raw(void); int read_solution_raw(void);
int read_exchange_raw(void); //int read_exchange_raw(void);
int read_surface_raw(void); int read_surface_raw(void);
int read_equilibrium_phases_raw(void); int read_equilibrium_phases_raw(void);
int read_kinetics_raw(void); int read_kinetics_raw(void);
int read_solid_solutions_raw(void); int read_solid_solutions_raw(void);
int read_gas_phase_raw(void); //int read_gas_phase_raw(void);
int read_reaction_raw(void); //int read_reaction_raw(void);
int read_mix_raw(void); //int read_mix_raw(void);
int read_temperature_raw(void); //int read_temperature_raw(void);
int read_dump(void); int read_dump(void);
int read_solution_modify(void); int read_solution_modify(void);
int read_equilibrium_phases_modify(void); int read_equilibrium_phases_modify(void);
int read_exchange_modify(void); //int read_exchange_modify(void);
int read_surface_modify(void); int read_surface_modify(void);
int read_solid_solutions_modify(void); int read_solid_solutions_modify(void);
int read_gas_phase_modify(void); //int read_gas_phase_modify(void);
int read_kinetics_modify(void); int read_kinetics_modify(void);
int read_reaction_modify(void); //int read_reaction_modify(void);
//int read_reaction_temperature_modify(void); //int read_reaction_temperature_modify(void);
int read_delete(void); int read_delete(void);
int read_run_cells(void); int read_run_cells(void);
@ -818,21 +820,24 @@ public:
int xsolution_zero(void); int xsolution_zero(void);
//int add_exchange(struct exchange *exchange_ptr); //int add_exchange(struct exchange *exchange_ptr);
int add_exchange(cxxExchange *exchange_ptr); int add_exchange(cxxExchange *exchange_ptr);
int add_gas_phase(struct gas_phase *gas_phase_ptr); int add_gas_phase(cxxGasPhase *gas_phase_ptr);
int add_kinetics(struct kinetics *kinetics_ptr); int add_kinetics(struct kinetics *kinetics_ptr);
//int add_mix(struct mix *mix_ptr); //int add_mix(struct mix *mix_ptr);
int add_mix(cxxMix * mix_ptr); int add_mix(cxxMix * mix_ptr);
int add_pp_assemblage(struct pp_assemblage *pp_assemblage_ptr); int add_pp_assemblage(struct pp_assemblage *pp_assemblage_ptr);
int add_reaction(struct irrev *irrev_ptr, int step_number, //int add_reaction(struct irrev *irrev_ptr, int step_number,
// LDBLE step_fraction);
int add_reaction(cxxReaction *reaction_ptr, int step_number,
LDBLE step_fraction); LDBLE step_fraction);
int add_s_s_assemblage(struct s_s_assemblage *s_s_assemblage_ptr); int add_s_s_assemblage(struct s_s_assemblage *s_s_assemblage_ptr);
int add_solution(struct solution *solution_ptr, LDBLE extensive, int add_solution(struct solution *solution_ptr, LDBLE extensive,
LDBLE intensive); LDBLE intensive);
int add_surface(struct surface *surface_ptr); int add_surface(struct surface *surface_ptr);
int check_pp_assemblage(struct pp_assemblage *pp_assemblage_ptr); int check_pp_assemblage(struct pp_assemblage *pp_assemblage_ptr);
int gas_phase_check(struct gas_phase *gas_phase_ptr); int gas_phase_check(cxxGasPhase *gas_phase_ptr);
int pp_assemblage_check(struct pp_assemblage *pp_assemblage_ptr); int pp_assemblage_check(struct pp_assemblage *pp_assemblage_ptr);
int reaction_calc(struct irrev *irrev_ptr); //int reaction_calc(struct irrev *irrev_ptr);
int reaction_calc(cxxReaction *reaction_ptr);
int solution_check(void); int solution_check(void);
int s_s_assemblage_check(struct s_s_assemblage *s_s_assemblage_ptr); int s_s_assemblage_check(struct s_s_assemblage *s_s_assemblage_ptr);
@ -878,8 +883,9 @@ protected:
struct exchange *exchange_search(int n_user, int *n, int print); struct exchange *exchange_search(int n_user, int *n, int print);
int exchange_sort(void); int exchange_sort(void);
#endif #endif
static int gas_comp_compare(const void *ptr1, const void *ptr2); //static int gas_comp_compare(const void *ptr1, const void *ptr2);
public: public:
#ifdef SKIP
struct gas_phase *gas_phase_alloc(void); struct gas_phase *gas_phase_alloc(void);
struct gas_phase *gas_phase_bsearch(int k, int *n); struct gas_phase *gas_phase_bsearch(int k, int *n);
protected: protected:
@ -901,12 +907,14 @@ public:
int n_user_new); int n_user_new);
struct gas_phase *gas_phase_search(int n_user, int *n); struct gas_phase *gas_phase_search(int n_user, int *n);
int gas_phase_sort(void); int gas_phase_sort(void);
#endif
enum entity_type get_entity_enum(char *name); enum entity_type get_entity_enum(char *name);
struct inverse *inverse_alloc(void); struct inverse *inverse_alloc(void);
int inverse_delete(int i); int inverse_delete(int i);
static int inverse_isotope_compare(const void *ptr1, const void *ptr2); static int inverse_isotope_compare(const void *ptr1, const void *ptr2);
struct inverse *inverse_search(int n_user, int *n); struct inverse *inverse_search(int n_user, int *n);
int inverse_sort(void); int inverse_sort(void);
#ifdef SKIP
struct irrev *irrev_bsearch(int k, int *n); struct irrev *irrev_bsearch(int k, int *n);
int irrev_copy(struct irrev *irrev_old_ptr, struct irrev *irrev_new_ptr, int irrev_copy(struct irrev *irrev_old_ptr, struct irrev *irrev_new_ptr,
int n_user_new); int n_user_new);
@ -916,6 +924,7 @@ public:
struct irrev *irrev_search(int n_user, int *n); struct irrev *irrev_search(int n_user, int *n);
int irrev_ptr_to_user(struct irrev *irrev_ptr_old, int n_user_new); int irrev_ptr_to_user(struct irrev *irrev_ptr_old, int n_user_new);
int irrev_sort(void); int irrev_sort(void);
#endif
public: public:
struct kinetics *kinetics_alloc(void); struct kinetics *kinetics_alloc(void);
struct kinetics *kinetics_bsearch(int k, int *n); struct kinetics *kinetics_bsearch(int k, int *n);
@ -1105,18 +1114,18 @@ public:
int unknown_free(struct unknown *unknown_ptr); int unknown_free(struct unknown *unknown_ptr);
int entity_exists(char *name, int n_user); int entity_exists(char *name, int n_user);
static int exchange_compare_int(const void *ptr1, const void *ptr2); //static int exchange_compare_int(const void *ptr1, const void *ptr2);
static int gas_phase_compare_int(const void *ptr1, const void *ptr2); //static int gas_phase_compare_int(const void *ptr1, const void *ptr2);
static int inverse_compare(const void *ptr1, const void *ptr2); static int inverse_compare(const void *ptr1, const void *ptr2);
int inverse_free(struct inverse *inverse_ptr); int inverse_free(struct inverse *inverse_ptr);
static int irrev_compare(const void *ptr1, const void *ptr2); //static int irrev_compare(const void *ptr1, const void *ptr2);
static int irrev_compare_int(const void *ptr1, const void *ptr2); //static int irrev_compare_int(const void *ptr1, const void *ptr2);
static int kinetics_compare_int(const void *ptr1, const void *ptr2); static int kinetics_compare_int(const void *ptr1, const void *ptr2);
int logk_init(struct logk *logk_ptr); int logk_init(struct logk *logk_ptr);
static int master_compare_string(const void *ptr1, const void *ptr2); static int master_compare_string(const void *ptr1, const void *ptr2);
int master_free(struct master *master_ptr); int master_free(struct master *master_ptr);
static int mix_compare(const void *ptr1, const void *ptr2); //static int mix_compare(const void *ptr1, const void *ptr2);
static int mix_compare_int(const void *ptr1, const void *ptr2); //static int mix_compare_int(const void *ptr1, const void *ptr2);
struct phase *phase_alloc(void); struct phase *phase_alloc(void);
static int phase_compare_string(const void *ptr1, const void *ptr2); static int phase_compare_string(const void *ptr1, const void *ptr2);
int phase_free(struct phase *phase_ptr); int phase_free(struct phase *phase_ptr);
@ -1132,8 +1141,8 @@ public:
static int solution_compare_int(const void *ptr1, const void *ptr2); static int solution_compare_int(const void *ptr1, const void *ptr2);
static int species_list_compare(const void *ptr1, const void *ptr2); static int species_list_compare(const void *ptr1, const void *ptr2);
static int surface_compare_int(const void *ptr1, const void *ptr2); static int surface_compare_int(const void *ptr1, const void *ptr2);
static int temperature_compare(const void *ptr1, const void *ptr2); //static int temperature_compare(const void *ptr1, const void *ptr2);
static int temperature_compare_int(const void *ptr1, const void *ptr2); //static int temperature_compare_int(const void *ptr1, const void *ptr2);
static int rxn_token_temp_compare(const void *ptr1, const void *ptr2); static int rxn_token_temp_compare(const void *ptr1, const void *ptr2);
int trxn_multiply(LDBLE coef); int trxn_multiply(LDBLE coef);
#ifdef PHREEQCI_GUI #ifdef PHREEQCI_GUI
@ -1144,18 +1153,18 @@ public:
#endif #endif
// convert class to struct (structures.cpp) // convert class to struct (structures.cpp)
struct mix * cxxMix2mix(const cxxMix *mx); //struct mix * cxxMix2mix(const cxxMix *mx);
struct kinetics *cxxKinetics2kinetics(const cxxKinetics * kin); struct kinetics *cxxKinetics2kinetics(const cxxKinetics * kin);
struct kinetics_comp * cxxKineticsComp2kinetics_comp(const std::list < cxxKineticsComp > * el); struct kinetics_comp * cxxKineticsComp2kinetics_comp(const std::list < cxxKineticsComp > * el);
//struct exchange * cxxExchange2exchange(const cxxExchange * ex); //struct exchange * cxxExchange2exchange(const cxxExchange * ex);
//struct exch_comp * cxxExchComp2exch_comp(const std::map < std::string, cxxExchComp > * el); //struct exch_comp * cxxExchComp2exch_comp(const std::map < std::string, cxxExchComp > * el);
struct master * Get_exch_master(const cxxExchComp * ec); //struct master * Get_exch_master(const cxxExchComp * ec);
struct gas_phase * cxxGasPhase2gas_phase(const cxxGasPhase * gp); //struct gas_phase * cxxGasPhase2gas_phase(const cxxGasPhase * gp);
struct gas_comp * cxxGasPhaseComp2gas_comp(const cxxGasPhase * gp); //struct gas_comp * cxxGasPhaseComp2gas_comp(const cxxGasPhase * gp);
struct temperature * cxxTemperature2temperature(const cxxTemperature *temp); //struct temperature * cxxTemperature2temperature(const cxxTemperature *temp);
struct pp_assemblage * cxxPPassemblage2pp_assemblage(const cxxPPassemblage * pp); struct pp_assemblage * cxxPPassemblage2pp_assemblage(const cxxPPassemblage * pp);
struct pure_phase * cxxPPassemblageComp2pure_phase(const std::map < std::string, cxxPPassemblageComp > * ppc); struct pure_phase * cxxPPassemblageComp2pure_phase(const std::map < std::string, cxxPPassemblageComp > * ppc);
struct irrev * cxxReaction2irrev(const cxxReaction * rxn); //struct irrev * cxxReaction2irrev(const cxxReaction * rxn);
struct solution * cxxSolution2solution(const cxxSolution * sol); struct solution * cxxSolution2solution(const cxxSolution * sol);
struct isotope * cxxSolutionIsotopeList2isotope(const cxxSolutionIsotopeList * il); struct isotope * cxxSolutionIsotopeList2isotope(const cxxSolutionIsotopeList * il);
struct s_s_assemblage * cxxSSassemblage2s_s_assemblage(const cxxSSassemblage * ss); struct s_s_assemblage * cxxSSassemblage2s_s_assemblage(const cxxSSassemblage * ss);
@ -1331,10 +1340,10 @@ protected:
Address Hash_multi(HashTable * Table, const char *Key); Address Hash_multi(HashTable * Table, const char *Key);
void ExpandTable_multi(HashTable * Table); void ExpandTable_multi(HashTable * Table);
public: public:
//bool recursive_include(std::ifstream & input_stream, std::iostream & accumulated_stream);
int main_method(int argc, char *argv[]); int main_method(int argc, char *argv[]);
void set_phast(int); void set_phast(int);
size_t list_components(std::list<std::string> &list_c); size_t list_components(std::list<std::string> &list_c);
PHRQ_io * Get_phrq_io(void) {return this->phrq_io;}
protected: protected:
void init(void); void init(void);
@ -1426,7 +1435,7 @@ protected:
struct copier copy_gas_phase; struct copier copy_gas_phase;
struct copier copy_kinetics; struct copier copy_kinetics;
struct copier copy_mix; struct copier copy_mix;
struct copier copy_irrev; struct copier copy_reaction;
struct copier copy_temperature; struct copier copy_temperature;
struct copier copy_pressure; struct copier copy_pressure;
@ -1450,17 +1459,21 @@ protected:
/*---------------------------------------------------------------------- /*----------------------------------------------------------------------
* Irreversible reaction * Irreversible reaction
*---------------------------------------------------------------------- */ *---------------------------------------------------------------------- */
std::map<int, cxxReaction> Rxn_reaction_map;
#ifdef SKIP
struct irrev *irrev; struct irrev *irrev;
struct irrev *dbg_irrev; struct irrev *dbg_irrev;
int count_irrev; int count_irrev;
#endif
/*---------------------------------------------------------------------- /*----------------------------------------------------------------------
* Gas phase * Gas phase
*---------------------------------------------------------------------- */ *---------------------------------------------------------------------- */
std::map<int, cxxGasPhase> Rxn_gas_phase_map;
#ifdef SKIP
int count_gas_phase; int count_gas_phase;
int max_gas_phase; int max_gas_phase;
struct gas_phase *gas_phase; struct gas_phase *gas_phase;
#endif
/*---------------------------------------------------------------------- /*----------------------------------------------------------------------
* Solid solution * Solid solution
*---------------------------------------------------------------------- */ *---------------------------------------------------------------------- */
@ -2102,7 +2115,8 @@ public:
std::vector<int> keycount; // used to mark keywords that have been read std::vector<int> keycount; // used to mark keywords that have been read
#endif /* _INC_PHREEQC_H */ #endif /* _INC_PHREEQC_H */
#ifndef _INC_ISFINITE_H
#define _INC_ISFINITE_H
/********************************* /*********************************
isfinite handling isfinite handling
(Note: Should NOT be guarded) (Note: Should NOT be guarded)
@ -2128,3 +2142,4 @@ public:
#endif #endif
}; };
#endif

View File

@ -48,7 +48,7 @@ cxxPressure::read(CParser & parser)
*/ */
// Number and description set in read_reaction_pressure // Number and description set in read_reaction_pressure
CParser::LINE_TYPE lt; PHRQ_io::LINE_TYPE lt;
bool done = false; bool done = false;
for (;;) for (;;)
{ {
@ -60,21 +60,21 @@ cxxPressure::read(CParser & parser)
std::string token, str; std::string token, str;
lt = parser.check_line(str, false, true, true, true); lt = parser.check_line(str, false, true, true, true);
if (lt == CParser::LT_EMPTY || if (lt == PHRQ_io::LT_EMPTY ||
lt == CParser::LT_KEYWORD || lt == PHRQ_io::LT_KEYWORD ||
lt == CParser::LT_EOF) lt == PHRQ_io::LT_EOF)
{ {
break; break;
} }
if (lt == CParser::LT_OPTION) if (lt == PHRQ_io::LT_OPTION)
{ {
this->error_msg("Expected numeric value for pressures.", CParser::OT_CONTINUE); this->error_msg("Expected numeric value for pressures.", PHRQ_io::OT_CONTINUE);
break; break;
} }
if (done) if (done)
{ {
this->error_msg("Unknown input following equal increment definition.", CParser::OT_CONTINUE); this->error_msg("Unknown input following equal increment definition.", PHRQ_io::OT_CONTINUE);
continue; continue;
} }
@ -101,7 +101,7 @@ cxxPressure::read(CParser & parser)
if (!(iss >> d)) if (!(iss >> d))
{ {
this->error_msg("Expected numeric value for pressures.", this->error_msg("Expected numeric value for pressures.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
else else
{ {
@ -165,18 +165,18 @@ cxxPressure::dump_raw(std::ostream & s_oss, unsigned int indent, int *n_out) con
s_oss << indent0; s_oss << indent0;
int n_user_local = (n_out != NULL) ? *n_out : this->n_user; int n_user_local = (n_out != NULL) ? *n_out : this->n_user;
s_oss << "REACTION_PRESSURE_RAW " << n_user_local << " " << this->description << std::endl; s_oss << "REACTION_PRESSURE_RAW " << n_user_local << " " << this->description << "\n";
s_oss << indent1; s_oss << indent1;
s_oss << "-count " << this->count << std::endl; s_oss << "-count " << this->count << "\n";
s_oss << indent1; s_oss << indent1;
s_oss << "-equal_increments " << this->equalIncrements << std::endl; s_oss << "-equal_increments " << this->equalIncrements << "\n";
// Temperature element and attributes // Temperature element and attributes
s_oss << indent1; s_oss << indent1;
s_oss << "-pressures " << std::endl; s_oss << "-pressures " << "\n";
{ {
int i = 0; int i = 0;
s_oss << indent2; s_oss << indent2;
@ -185,13 +185,13 @@ cxxPressure::dump_raw(std::ostream & s_oss, unsigned int indent, int *n_out) con
{ {
if (i++ == 5) if (i++ == 5)
{ {
s_oss << std::endl; s_oss << "\n";
s_oss << indent2; s_oss << indent2;
i = 0; i = 0;
} }
s_oss << *it << " "; s_oss << *it << " ";
} }
s_oss << std::endl; s_oss << "\n";
} }
} }
@ -218,6 +218,7 @@ cxxPressure::read_raw(CParser & parser)
bool useLastLine(false); bool useLastLine(false);
// Number and description set in read_reaction_pressure_raw // Number and description set in read_reaction_pressure_raw
this->read_number_description(parser);
opt_save = CParser::OPT_ERROR; opt_save = CParser::OPT_ERROR;
bool equalIncrements_defined(false); bool equalIncrements_defined(false);
@ -248,8 +249,8 @@ cxxPressure::read_raw(CParser & parser)
case CParser::OPT_ERROR: case CParser::OPT_ERROR:
opt = CParser::OPT_EOF; opt = CParser::OPT_EOF;
parser.error_msg("Unknown input in REACTION_PRESSURE_RAW keyword.", parser.error_msg("Unknown input in REACTION_PRESSURE_RAW keyword.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
parser.error_msg(parser.line().c_str(), CParser::OT_CONTINUE); parser.error_msg(parser.line().c_str(), PHRQ_io::OT_CONTINUE);
useLastLine = false; useLastLine = false;
break; break;
@ -266,7 +267,7 @@ cxxPressure::read_raw(CParser & parser)
{ {
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Expected numeric value for pressures.", parser.error_msg("Expected numeric value for pressures.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
else else
{ {
@ -282,7 +283,7 @@ cxxPressure::read_raw(CParser & parser)
{ {
this->equalIncrements = 0; this->equalIncrements = 0;
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Expected boolean value for equalIncrements.", CParser::OT_CONTINUE); parser.error_msg("Expected boolean value for equalIncrements.", PHRQ_io::OT_CONTINUE);
} }
opt_save = CParser::OPT_DEFAULT; opt_save = CParser::OPT_DEFAULT;
useLastLine = false; useLastLine = false;
@ -294,7 +295,7 @@ cxxPressure::read_raw(CParser & parser)
{ {
this->count = 0; this->count = 0;
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Expected integer value for count.", CParser::OT_CONTINUE); parser.error_msg("Expected integer value for count.", PHRQ_io::OT_CONTINUE);
} }
opt_save = CParser::OPT_DEFAULT; opt_save = CParser::OPT_DEFAULT;
useLastLine = false; useLastLine = false;
@ -309,13 +310,13 @@ cxxPressure::read_raw(CParser & parser)
{ {
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Equal_increments not defined for REACTION_PRESSURE_RAW input.", parser.error_msg("Equal_increments not defined for REACTION_PRESSURE_RAW input.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
if (count_defined == false) if (count_defined == false)
{ {
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Count_temps not defined for REACTION_PRESSURE_RAW input.", parser.error_msg("Count_temps not defined for REACTION_PRESSURE_RAW input.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
} }
#ifdef SKIP #ifdef SKIP
@ -335,15 +336,15 @@ cxxPressure::dump_xml(std::ostream & s_oss, unsigned int indent) const const
// Temperature element and attributes // Temperature element and attributes
s_oss << indent0; s_oss << indent0;
s_oss << "<temperature " << std::endl; s_oss << "<temperature " << "\n";
s_oss << indent1; s_oss << indent1;
s_oss << "pitzer_temperature_gammas=\"" << this-> s_oss << "pitzer_temperature_gammas=\"" << this->
pitzer_temperature_gammas << "\"" << std::endl; pitzer_temperature_gammas << "\"" << "\n";
// components // components
s_oss << indent1; s_oss << indent1;
s_oss << "<component " << std::endl; s_oss << "<component " << "\n";
for (std::list < cxxPressureComp >::const_iterator it = for (std::list < cxxPressureComp >::const_iterator it =
temperatureComps.begin(); it != temperatureComps.end(); ++it) temperatureComps.begin(); it != temperatureComps.end(); ++it)
{ {

View File

@ -23,11 +23,11 @@ class cxxPressure:public cxxNumKeyword
int read(CParser & parser); int read(CParser & parser);
void read_raw(CParser & parser); void read_raw(CParser & parser);
LDBLE Pressure_for_step(int step_number); LDBLE Pressure_for_step(int step_number);
std::vector<double> & Get_pressures(void) {return pressures;}; std::vector<double> & Get_pressures(void) {return pressures;}
int Get_count(void) const; int Get_count(void) const;
void Set_count(int i) {count = i;}; void Set_count(int i) {count = i;}
bool Get_equalIncrements(void) const {return equalIncrements;}; bool Get_equalIncrements(void) const {return equalIncrements;}
void Set_equalIncrements(bool tf) {equalIncrements = tf;}; void Set_equalIncrements(bool tf) {equalIncrements = tf;}
protected: protected:
std::vector < double >pressures; std::vector < double >pressures;

View File

@ -29,6 +29,7 @@ cxxReaction::cxxReaction(PHRQ_io *io)
reactantList.type = cxxNameDouble::ND_NAME_COEF; reactantList.type = cxxNameDouble::ND_NAME_COEF;
elementList.type = cxxNameDouble::ND_ELT_MOLES; elementList.type = cxxNameDouble::ND_ELT_MOLES;
} }
#ifdef SKIP
cxxReaction::cxxReaction(struct irrev *irrev_ptr, PHRQ_io *io) cxxReaction::cxxReaction(struct irrev *irrev_ptr, PHRQ_io *io)
// //
// constructor for cxxReaction from struct irrev // constructor for cxxReaction from struct irrev
@ -64,7 +65,7 @@ elementList(irrev_ptr->elts)
this->equalIncrements = false; this->equalIncrements = false;
} }
} }
#endif
cxxReaction::~cxxReaction() cxxReaction::~cxxReaction()
{ {
} }
@ -86,15 +87,15 @@ cxxReaction::dump_xml(std::ostream & s_oss, unsigned int indent) const const
// Reaction element and attributes // Reaction element and attributes
s_oss << indent0; s_oss << indent0;
s_oss << "<irrev " << std::endl; s_oss << "<irrev " << "\n";
s_oss << indent1; s_oss << indent1;
s_oss << "pitzer_irrev_gammas=\"" << this-> s_oss << "pitzer_irrev_gammas=\"" << this->
pitzer_irrev_gammas << "\"" << std::endl; pitzer_irrev_gammas << "\"" << "\n";
// components // components
s_oss << indent1; s_oss << indent1;
s_oss << "<component " << std::endl; s_oss << "<component " << "\n";
for (std::list < cxxReactionComp >::const_iterator it = for (std::list < cxxReactionComp >::const_iterator it =
irrevComps.begin(); it != irrevComps.end(); ++it) irrevComps.begin(); it != irrevComps.end(); ++it)
{ {
@ -122,21 +123,21 @@ cxxReaction::dump_raw(std::ostream & s_oss, unsigned int indent, int *n_out) con
// Reaction element and attributes // Reaction element and attributes
s_oss << indent0; s_oss << indent0;
int n_user_local = (n_out != NULL) ? *n_out : this->n_user; int n_user_local = (n_out != NULL) ? *n_out : this->n_user;
s_oss << "REACTION_RAW " << n_user_local << " " << this->description << std::endl; s_oss << "REACTION_RAW " << n_user_local << " " << this->description << "\n";
s_oss << indent1; s_oss << indent1;
s_oss << "-units " << this->units << std::endl; s_oss << "-units " << this->units << "\n";
s_oss << indent1; s_oss << indent1;
s_oss << "-reactant_list " << std::endl; s_oss << "-reactant_list " << "\n";
this->reactantList.dump_raw(s_oss, indent + 2); this->reactantList.dump_raw(s_oss, indent + 2);
s_oss << indent1; s_oss << indent1;
s_oss << "-element_list " << std::endl; s_oss << "-element_list " << "\n";
this->elementList.dump_raw(s_oss, indent + 2); this->elementList.dump_raw(s_oss, indent + 2);
s_oss << indent1; s_oss << indent1;
s_oss << "-steps " << std::endl; s_oss << "-steps " << "\n";
{ {
int i = 0; int i = 0;
s_oss << indent2; s_oss << indent2;
@ -145,20 +146,20 @@ cxxReaction::dump_raw(std::ostream & s_oss, unsigned int indent, int *n_out) con
{ {
if (i++ == 5) if (i++ == 5)
{ {
s_oss << std::endl; s_oss << "\n";
s_oss << indent2; s_oss << indent2;
i = 0; i = 0;
} }
s_oss << *it << " "; s_oss << *it << " ";
} }
s_oss << std::endl; s_oss << "\n";
} }
s_oss << indent1; s_oss << indent1;
s_oss << "-equal_increments " << this->equalIncrements << std::endl; s_oss << "-equal_increments " << this->equalIncrements << "\n";
s_oss << indent1; s_oss << indent1;
s_oss << "-count_steps " << this->countSteps << std::endl; s_oss << "-count_steps " << this->countSteps << "\n";
} }
@ -224,8 +225,8 @@ cxxReaction::read_raw(CParser & parser, const bool check)
case CParser::OPT_ERROR: case CParser::OPT_ERROR:
opt = CParser::OPT_EOF; opt = CParser::OPT_EOF;
parser.error_msg("Unknown input in IRREV_COMP_RAW keyword.", parser.error_msg("Unknown input in IRREV_COMP_RAW keyword.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
parser.error_msg(parser.line().c_str(), CParser::OT_CONTINUE); parser.error_msg(parser.line().c_str(), PHRQ_io::OT_CONTINUE);
useLastLine = false; useLastLine = false;
break; break;
@ -245,7 +246,7 @@ cxxReaction::read_raw(CParser & parser, const bool check)
{ {
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Expected reactant formula and coefficient.", parser.error_msg("Expected reactant formula and coefficient.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
opt_save = 1; opt_save = 1;
useLastLine = false; useLastLine = false;
@ -257,7 +258,7 @@ cxxReaction::read_raw(CParser & parser, const bool check)
{ {
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Expected element formula and coefficient.", parser.error_msg("Expected element formula and coefficient.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
opt_save = 2; opt_save = 2;
useLastLine = false; useLastLine = false;
@ -277,7 +278,7 @@ cxxReaction::read_raw(CParser & parser, const bool check)
{ {
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Expected numeric value for steps.", parser.error_msg("Expected numeric value for steps.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
else else
{ {
@ -295,7 +296,7 @@ cxxReaction::read_raw(CParser & parser, const bool check)
parser.incr_input_error(); parser.incr_input_error();
parser. parser.
error_msg("Expected boolean value for equalIncrements.", error_msg("Expected boolean value for equalIncrements.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
opt_save = CParser::OPT_DEFAULT; opt_save = CParser::OPT_DEFAULT;
useLastLine = false; useLastLine = false;
@ -308,7 +309,7 @@ cxxReaction::read_raw(CParser & parser, const bool check)
this->countSteps = 0; this->countSteps = 0;
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Expected integer value for countSteps.", parser.error_msg("Expected integer value for countSteps.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
opt_save = CParser::OPT_DEFAULT; opt_save = CParser::OPT_DEFAULT;
useLastLine = false; useLastLine = false;
@ -325,20 +326,29 @@ cxxReaction::read_raw(CParser & parser, const bool check)
{ {
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Units not defined for REACTION_RAW input.", parser.error_msg("Units not defined for REACTION_RAW input.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
if (equalIncrements_defined == false) if (equalIncrements_defined == false)
{ {
parser.incr_input_error(); parser.incr_input_error();
parser. parser.
error_msg("Equal_increments not defined for REACTION_RAW input.", error_msg("Equal_increments not defined for REACTION_RAW input.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
if (countSteps_defined == false) if (countSteps_defined == false)
{ {
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Count_steps not defined for REACTION_RAW input.", parser.error_msg("Count_steps not defined for REACTION_RAW input.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
} }
} }
int cxxReaction::
Get_actualSteps(void) const
{
if (equalIncrements)
{
return this->countSteps;
}
return (int) this->steps.size();
}

View File

@ -15,20 +15,25 @@ class cxxReaction:public cxxNumKeyword
public: public:
cxxReaction(PHRQ_io *io = NULL); cxxReaction(PHRQ_io *io = NULL);
cxxReaction(struct irrev *, PHRQ_io *io = NULL); //cxxReaction(struct irrev *, PHRQ_io *io = NULL);
~cxxReaction(); ~cxxReaction();
//void dump_xml(std::ostream& os, unsigned int indent = 0)const; //void dump_xml(std::ostream& os, unsigned int indent = 0)const;
void dump_raw(std::ostream & s_oss, unsigned int indent, int *n_out=NULL) const; void dump_raw(std::ostream & s_oss, unsigned int indent, int *n_out=NULL) const;
void read_raw(CParser & parser, bool check); void read_raw(CParser & parser, bool check=true);
const cxxNameDouble &Get_elementList(void) const {return this->elementList;}; const cxxNameDouble &Get_elementList(void) const {return this->elementList;}
const cxxNameDouble &Get_reactantList(void) const {return this->reactantList;}; void Set_elementList(cxxNameDouble nd) {this->elementList = nd;}
const std::vector < double > &Get_steps(void) const {return this->steps;}; cxxNameDouble &Get_reactantList(void) {return this->reactantList;}
int Get_countSteps(void) const {return this->countSteps;}; std::vector < double > &Get_steps(void) {return this->steps;}
bool Get_equalIncrements(void) const {return this->equalIncrements;}; void Set_steps(std::vector<LDBLE> &v) {steps = v;}
const std::string &Get_units(void) const {return this->units;}; int Get_actualSteps(void) const;
int Get_countSteps(void) const {return this->countSteps;}
void Set_countSteps(int i) {countSteps = i;}
bool Get_equalIncrements(void) const {return this->equalIncrements;}
void Set_equalIncrements(bool tf) {equalIncrements = tf;}
const std::string &Get_units(void) const {return this->units;}
void Set_units(const char * s) void Set_units(const char * s)
{ {

View File

@ -69,10 +69,7 @@ read_solution_raw(void)
pr.echo_input = save_echo_input; pr.echo_input = save_echo_input;
std::istringstream iss_in(keywordLines); std::istringstream iss_in(keywordLines);
std::ostringstream oss_out; CParser parser(iss_in, phrq_io);
std::ostringstream oss_err;
CParser parser(iss_in, oss_out, oss_err, phrq_io);
assert(!reading_database()); assert(!reading_database());
if (pr.echo_input == FALSE) if (pr.echo_input == FALSE)
{ {
@ -119,7 +116,7 @@ read_solution_raw(void)
if (return_value == KEYWORD) echo_msg(sformatf( "\t%s\n", line)); if (return_value == KEYWORD) echo_msg(sformatf( "\t%s\n", line));
return (return_value); return (return_value);
} }
#ifdef SKIP
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
int Phreeqc:: int Phreeqc::
read_exchange_raw(void) read_exchange_raw(void)
@ -163,10 +160,7 @@ read_exchange_raw(void)
pr.echo_input = save_echo_input; pr.echo_input = save_echo_input;
std::istringstream iss_in(keywordLines); std::istringstream iss_in(keywordLines);
std::ostringstream oss_out; CParser parser(iss_in, phrq_io);
std::ostringstream oss_err;
CParser parser(iss_in, oss_out, oss_err, phrq_io);
assert(!reading_database()); assert(!reading_database());
if (pr.echo_input == FALSE) if (pr.echo_input == FALSE)
{ {
@ -194,6 +188,7 @@ read_exchange_raw(void)
Utilities::Rxn_copy(Rxn_exchange_map, n_user, i); Utilities::Rxn_copy(Rxn_exchange_map, n_user, i);
} }
} }
#ifdef SKIP #ifdef SKIP
//struct exchange *exchange_ptr = ex.cxxExchange2exchange(PHREEQC_THIS); //struct exchange *exchange_ptr = ex.cxxExchange2exchange(PHREEQC_THIS);
struct exchange *exchange_ptr = cxxExchange2exchange(&ex); struct exchange *exchange_ptr = cxxExchange2exchange(&ex);
@ -227,7 +222,7 @@ read_exchange_raw(void)
if (return_value == KEYWORD) echo_msg(sformatf( "\t%s\n", line)); if (return_value == KEYWORD) echo_msg(sformatf( "\t%s\n", line));
return (return_value); return (return_value);
} }
#endif
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
int Phreeqc:: int Phreeqc::
read_surface_raw(void) read_surface_raw(void)
@ -271,10 +266,7 @@ read_surface_raw(void)
pr.echo_input = save_echo_input; pr.echo_input = save_echo_input;
std::istringstream iss_in(keywordLines); std::istringstream iss_in(keywordLines);
std::ostringstream oss_out; CParser parser(iss_in, phrq_io);
std::ostringstream oss_err;
CParser parser(iss_in, oss_out, oss_err, phrq_io);
assert(!reading_database()); assert(!reading_database());
if (pr.echo_input == FALSE) if (pr.echo_input == FALSE)
{ {
@ -367,10 +359,7 @@ read_equilibrium_phases_raw(void)
pr.echo_input = save_echo_input; pr.echo_input = save_echo_input;
std::istringstream iss_in(keywordLines); std::istringstream iss_in(keywordLines);
std::ostringstream oss_out; CParser parser(iss_in, phrq_io);
std::ostringstream oss_err;
CParser parser(iss_in, oss_out, oss_err, phrq_io);
assert(!reading_database()); assert(!reading_database());
if (pr.echo_input == FALSE) if (pr.echo_input == FALSE)
{ {
@ -464,10 +453,7 @@ read_kinetics_raw(void)
pr.echo_input = save_echo_input; pr.echo_input = save_echo_input;
std::istringstream iss_in(keywordLines); std::istringstream iss_in(keywordLines);
std::ostringstream oss_out; CParser parser(iss_in, phrq_io);
std::ostringstream oss_err;
CParser parser(iss_in, oss_out, oss_err, phrq_io);
assert(!reading_database()); assert(!reading_database());
if (pr.echo_input == FALSE) if (pr.echo_input == FALSE)
{ {
@ -560,10 +546,7 @@ read_solid_solutions_raw(void)
pr.echo_input = save_echo_input; pr.echo_input = save_echo_input;
std::istringstream iss_in(keywordLines); std::istringstream iss_in(keywordLines);
std::ostringstream oss_out; CParser parser(iss_in, phrq_io);
std::ostringstream oss_err;
CParser parser(iss_in, oss_out, oss_err, phrq_io);
assert(!reading_database()); assert(!reading_database());
if (pr.echo_input == FALSE) if (pr.echo_input == FALSE)
{ {
@ -614,7 +597,76 @@ read_solid_solutions_raw(void)
if (return_value == KEYWORD) echo_msg(sformatf( "\t%s\n", line)); if (return_value == KEYWORD) echo_msg(sformatf( "\t%s\n", line));
return (return_value); return (return_value);
} }
#ifdef SKIP
/* ---------------------------------------------------------------------- */
int Phreeqc::
read_gas_phase_raw(void)
/* ---------------------------------------------------------------------- */
{
/*
* Reads GAS_PHASE_RAW data block
*
* Arguments:
* none
*
* Returns:
* KEYWORD if keyword encountered, input_error may be incremented if
* a keyword is encountered in an unexpected position
* EOF if eof encountered while reading mass balance concentrations
* ERROR if error occurred reading data
*
*/
int return_value;
/*
* Accumulate lines in std string
*/
std::string keywordLines("");
keywordLines.append(line);
keywordLines.append("\n");
/*
* Read additonal lines
*/
int save_echo_input = pr.echo_input;
pr.echo_input = FALSE;
for (;;)
{
return_value = check_line("gas_phase_raw", TRUE, TRUE, TRUE, FALSE);
/* empty, eof, keyword, print */
if (return_value == EOF || return_value == KEYWORD)
break;
keywordLines.append(line);
keywordLines.append("\n");
}
pr.echo_input = save_echo_input;
std::istringstream iss_in(keywordLines);
CParser parser(iss_in, phrq_io);
assert(!reading_database());
if (pr.echo_input == FALSE)
{
parser.set_echo_file(CParser::EO_NONE);
}
else
{
parser.set_echo_file(CParser::EO_NOKEYWORDS);
}
//For testing, need to read line to get started
std::vector < std::string > vopts;
std::istream::pos_type next_char;
parser.get_option(vopts, next_char);
cxxGasPhase entity(phrq_io);
entity.read_raw(parser);
Rxn_gas_phase_map[entity.Get_n_user()] = entity;
// Need to output the next keyword
if (return_value == KEYWORD) echo_msg(sformatf( "\t%s\n", line));
return (return_value);
}
#endif
#ifdef SKIP
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
int Phreeqc:: int Phreeqc::
read_gas_phase_raw(void) read_gas_phase_raw(void)
@ -709,7 +761,8 @@ read_gas_phase_raw(void)
if (return_value == KEYWORD) echo_msg(sformatf( "\t%s\n", line)); if (return_value == KEYWORD) echo_msg(sformatf( "\t%s\n", line));
return (return_value); return (return_value);
} }
#endif
#ifdef SKIP
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
int Phreeqc:: int Phreeqc::
read_reaction_raw(void) read_reaction_raw(void)
@ -753,10 +806,8 @@ read_reaction_raw(void)
pr.echo_input = save_echo_input; pr.echo_input = save_echo_input;
std::istringstream iss_in(keywordLines); std::istringstream iss_in(keywordLines);
std::ostringstream oss_out;
std::ostringstream oss_err;
CParser parser(iss_in, oss_out, oss_err, phrq_io); CParser parser(iss_in, phrq_io);
assert(!reading_database()); assert(!reading_database());
if (pr.echo_input == FALSE) if (pr.echo_input == FALSE)
{ {
@ -805,6 +856,7 @@ read_reaction_raw(void)
if (return_value == KEYWORD) echo_msg(sformatf( "\t%s\n", line)); if (return_value == KEYWORD) echo_msg(sformatf( "\t%s\n", line));
return (return_value); return (return_value);
} }
#endif
#ifdef SKIP #ifdef SKIP
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
int Phreeqc:: int Phreeqc::
@ -926,9 +978,7 @@ read_dump(void)
*/ */
std::istringstream iss_in; std::istringstream iss_in;
return_value = streamify_to_next_keyword(iss_in); return_value = streamify_to_next_keyword(iss_in);
std::ostringstream oss_out; CParser parser(iss_in, phrq_io);
std::ostringstream oss_err;
CParser parser(iss_in, oss_out, oss_err, phrq_io);
assert(!reading_database()); assert(!reading_database());
//For testing, need to read line to get started //For testing, need to read line to get started
@ -976,9 +1026,7 @@ read_delete(void)
*/ */
std::istringstream iss_in; std::istringstream iss_in;
return_value = streamify_to_next_keyword(iss_in); return_value = streamify_to_next_keyword(iss_in);
std::ostringstream oss_out; CParser parser(iss_in, phrq_io);
std::ostringstream oss_err;
CParser parser(iss_in, oss_out, oss_err, phrq_io);
assert(!reading_database()); assert(!reading_database());
//For testing, need to read line to get started //For testing, need to read line to get started
@ -1028,9 +1076,7 @@ read_run_cells(void)
*/ */
std::istringstream iss_in; std::istringstream iss_in;
return_value = streamify_to_next_keyword(iss_in); return_value = streamify_to_next_keyword(iss_in);
std::ostringstream oss_out; CParser parser(iss_in, phrq_io);
std::ostringstream oss_err;
CParser parser(iss_in, oss_out, oss_err, phrq_io);
assert(!reading_database()); assert(!reading_database());
//For testing, need to read line to get started //For testing, need to read line to get started
@ -1100,9 +1146,7 @@ read_solution_modify(void)
*/ */
std::istringstream iss_in; std::istringstream iss_in;
return_value = streamify_to_next_keyword(iss_in); return_value = streamify_to_next_keyword(iss_in);
std::ostringstream oss_out; CParser parser(iss_in, phrq_io);
std::ostringstream oss_err;
CParser parser(iss_in, oss_out, oss_err, phrq_io);
assert(!reading_database()); assert(!reading_database());
//For testing, need to read line to get started //For testing, need to read line to get started
@ -1199,9 +1243,7 @@ read_equilibrium_phases_modify(void)
*/ */
std::istringstream iss_in; std::istringstream iss_in;
return_value = streamify_to_next_keyword(iss_in); return_value = streamify_to_next_keyword(iss_in);
std::ostringstream oss_out; CParser parser(iss_in, phrq_io);
std::ostringstream oss_err;
CParser parser(iss_in, oss_out, oss_err, phrq_io);
assert(!reading_database()); assert(!reading_database());
//For testing, need to read line to get started //For testing, need to read line to get started
@ -1248,6 +1290,7 @@ read_equilibrium_phases_modify(void)
if (return_value == OPTION_KEYWORD) echo_msg(sformatf( "\t%s\n", line)); if (return_value == OPTION_KEYWORD) echo_msg(sformatf( "\t%s\n", line));
return (return_value); return (return_value);
} }
#ifdef SKIP
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
int Phreeqc:: int Phreeqc::
read_exchange_modify(void) read_exchange_modify(void)
@ -1293,9 +1336,7 @@ read_exchange_modify(void)
*/ */
std::istringstream iss_in; std::istringstream iss_in;
return_value = streamify_to_next_keyword(iss_in); return_value = streamify_to_next_keyword(iss_in);
std::ostringstream oss_out; CParser parser(iss_in, phrq_io);
std::ostringstream oss_err;
CParser parser(iss_in, oss_out, oss_err, phrq_io);
assert(!reading_database()); assert(!reading_database());
//For testing, need to read line to get started //For testing, need to read line to get started
@ -1392,6 +1433,7 @@ read_exchange_modify(void)
if (return_value == OPTION_KEYWORD) echo_msg(sformatf( "\t%s\n", line)); if (return_value == OPTION_KEYWORD) echo_msg(sformatf( "\t%s\n", line));
return (return_value); return (return_value);
} }
#endif
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
int Phreeqc:: int Phreeqc::
read_surface_modify(void) read_surface_modify(void)
@ -1436,9 +1478,7 @@ read_surface_modify(void)
*/ */
std::istringstream iss_in; std::istringstream iss_in;
return_value = streamify_to_next_keyword(iss_in); return_value = streamify_to_next_keyword(iss_in);
std::ostringstream oss_out; CParser parser(iss_in, phrq_io);
std::ostringstream oss_err;
CParser parser(iss_in, oss_out, oss_err, phrq_io);
assert(!reading_database()); assert(!reading_database());
//For testing, need to read line to get started //For testing, need to read line to get started
@ -1526,9 +1566,7 @@ read_solid_solutions_modify(void)
*/ */
std::istringstream iss_in; std::istringstream iss_in;
return_value = streamify_to_next_keyword(iss_in); return_value = streamify_to_next_keyword(iss_in);
std::ostringstream oss_out; CParser parser(iss_in, phrq_io);
std::ostringstream oss_err;
CParser parser(iss_in, oss_out, oss_err, phrq_io);
assert(!reading_database()); assert(!reading_database());
//For testing, need to read line to get started //For testing, need to read line to get started
@ -1572,6 +1610,86 @@ read_solid_solutions_modify(void)
if (return_value == OPTION_KEYWORD) echo_msg(sformatf( "\t%s\n", line)); if (return_value == OPTION_KEYWORD) echo_msg(sformatf( "\t%s\n", line));
return (return_value); return (return_value);
} }
#ifdef SKIP
/* ---------------------------------------------------------------------- */
int Phreeqc::
read_gas_phase_modify(void)
/* ---------------------------------------------------------------------- */
{
/*
* Reads GAS_PHASE_MODIFY data block
*
* Arguments:
* none
*
* Returns:
* KEYWORD if keyword encountered, input_error may be incremented if
* a keyword is encountered in an unexpected position
* EOF if eof encountered while reading mass balance concentrations
* ERROR if error occurred reading data
*
*/
int return_value;
// find gas_phase number
char token[MAX_LENGTH];
char *next;
int l, n_user;
next = line;
copy_token(token, &next, &l);
if (copy_token(token, &next, &l) != DIGIT)
{
input_error++;
error_string = sformatf( "Expected gas_phase number following GAS_PHASE_MODIFY.\n%s\n", line_save);
error_msg(error_string, CONTINUE);
std::istringstream iss_in;
return_value = streamify_to_next_keyword(iss_in);
return (ERROR);
}
else
{
sscanf(token,"%d", &n_user);
}
/*
* Make parser
*/
std::istringstream iss_in;
return_value = streamify_to_next_keyword(iss_in);
CParser parser(iss_in, phrq_io);
assert(!reading_database());
//For testing, need to read line to get started
parser.set_echo_file(CParser::EO_NONE);
std::vector < std::string > vopts;
std::istream::pos_type next_char;
parser.get_option(vopts, next_char);
if (pr.echo_input == FALSE)
{
parser.set_echo_file(CParser::EO_NONE);
}
else
{
parser.set_echo_file(CParser::EO_NOKEYWORDS);
}
cxxGasPhase *gas_phase_ptr = Utilities::Rxn_find(Rxn_gas_phase_map, n_user);
if (gas_phase_ptr == NULL)
{
input_error++;
error_string = sformatf( "Gas_phase %d not found for GAS_PHASE_MODIFY.\n", n_user);
error_msg(error_string, CONTINUE);
return (ERROR);
}
// read entity
gas_phase_ptr->read_raw(parser, false);
// Need to output the next keyword
if (return_value == OPTION_KEYWORD) echo_msg(sformatf( "\t%s\n", line));
return (return_value);
}
#endif
#ifdef SKIP
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
int Phreeqc:: int Phreeqc::
read_gas_phase_modify(void) read_gas_phase_modify(void)
@ -1660,6 +1778,7 @@ read_gas_phase_modify(void)
if (return_value == OPTION_KEYWORD) echo_msg(sformatf( "\t%s\n", line)); if (return_value == OPTION_KEYWORD) echo_msg(sformatf( "\t%s\n", line));
return (return_value); return (return_value);
} }
#endif
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
int Phreeqc:: int Phreeqc::
read_kinetics_modify(void) read_kinetics_modify(void)
@ -1704,9 +1823,7 @@ read_kinetics_modify(void)
*/ */
std::istringstream iss_in; std::istringstream iss_in;
return_value = streamify_to_next_keyword(iss_in); return_value = streamify_to_next_keyword(iss_in);
std::ostringstream oss_out; // ?? CParser parser(iss_in, phrq_io);
std::ostringstream oss_err; // ??
CParser parser(iss_in, oss_out, oss_err, phrq_io);
assert(!reading_database()); assert(!reading_database());
//For testing, need to read line to get started //For testing, need to read line to get started
@ -1750,6 +1867,7 @@ read_kinetics_modify(void)
if (return_value == OPTION_KEYWORD) echo_msg(sformatf( "\t%s\n", line)); if (return_value == OPTION_KEYWORD) echo_msg(sformatf( "\t%s\n", line));
return (return_value); return (return_value);
} }
#ifdef SKIP
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
int Phreeqc:: int Phreeqc::
read_reaction_modify(void) read_reaction_modify(void)
@ -1793,9 +1911,7 @@ read_reaction_modify(void)
*/ */
std::istringstream iss_in; std::istringstream iss_in;
return_value = streamify_to_next_keyword(iss_in); return_value = streamify_to_next_keyword(iss_in);
std::ostringstream oss_out; CParser parser(iss_in, phrq_io);
std::ostringstream oss_err;
CParser parser(iss_in, oss_out, oss_err, phrq_io);
assert(!reading_database()); assert(!reading_database());
//For testing, need to read line to get started //For testing, need to read line to get started
@ -1838,6 +1954,7 @@ read_reaction_modify(void)
if (return_value == OPTION_KEYWORD) echo_msg(sformatf( "\t%s\n", line)); if (return_value == OPTION_KEYWORD) echo_msg(sformatf( "\t%s\n", line));
return (return_value); return (return_value);
} }
#endif
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
int Phreeqc:: int Phreeqc::
streamify_to_next_keyword(std::istringstream & lines) streamify_to_next_keyword(std::istringstream & lines)
@ -2075,6 +2192,22 @@ delete_entities(void)
} }
// gas_phases // gas_phases
if (delete_info.Get_gas_phase().Get_defined())
{
if (delete_info.Get_gas_phase().Get_numbers().size() == 0)
{
Rxn_gas_phase_map.clear();
}
else
{
std::set < int >::iterator it;
for (it = delete_info.Get_gas_phase().Get_numbers().begin(); it != delete_info.Get_gas_phase().Get_numbers().end(); it++)
{
Rxn_gas_phase_map.erase(*it);
}
}
}
#ifdef SKIP
if (delete_info.Get_gas_phase().Get_defined()) if (delete_info.Get_gas_phase().Get_defined())
{ {
if (delete_info.Get_gas_phase().Get_numbers().size() == 0) if (delete_info.Get_gas_phase().Get_numbers().size() == 0)
@ -2096,7 +2229,7 @@ delete_entities(void)
} }
} }
} }
#endif
// kineticss // kineticss
if (delete_info.Get_kinetics().Get_defined()) if (delete_info.Get_kinetics().Get_defined())
{ {
@ -2159,6 +2292,22 @@ delete_entities(void)
} }
#endif #endif
// reactions // reactions
if (delete_info.Get_reaction().Get_defined())
{
if (delete_info.Get_reaction().Get_numbers().size() == 0)
{
Rxn_reaction_map.clear();
}
else
{
std::set < int >::iterator it;
for (it = delete_info.Get_reaction().Get_numbers().begin(); it != delete_info.Get_reaction().Get_numbers().end(); it++)
{
Rxn_reaction_map.erase(*it);
}
}
}
#ifdef SKIP
if (delete_info.Get_reaction().Get_defined()) if (delete_info.Get_reaction().Get_defined())
{ {
if (delete_info.Get_reaction().Get_numbers().size() == 0) if (delete_info.Get_reaction().Get_numbers().size() == 0)
@ -2180,6 +2329,7 @@ delete_entities(void)
} }
} }
} }
#endif
// temperatures // temperatures
if (delete_info.Get_temperature().Get_defined()) if (delete_info.Get_temperature().Get_defined())
{ {
@ -2261,10 +2411,11 @@ run_as_cells(void)
*/ */
dup_print("Beginning of batch-reaction calculations.", TRUE); dup_print("Beginning of batch-reaction calculations.", TRUE);
count_steps = 1; count_steps = 1;
if (use.irrev_in == TRUE && use.irrev_ptr != NULL) if (use.reaction_in == TRUE && use.reaction_ptr != NULL)
{ {
if (abs(use.irrev_ptr->count_steps) > count_steps) int count = ((cxxReaction *) use.reaction_ptr)->Get_actualSteps();
count_steps = abs(use.irrev_ptr->count_steps); if (count > count_steps)
count_steps = count;
} }
if (use.kinetics_in == TRUE && use.kinetics_ptr != NULL) if (use.kinetics_in == TRUE && use.kinetics_ptr != NULL)
{ {
@ -2593,6 +2744,27 @@ dump_ostream(std::ostream& os)
} }
// gas_phases // gas_phases
if (dump_info.Get_bool_gas_phase())
{
if (dump_info.Get_gas_phase().size() == 0)
{
Utilities::Rxn_dump_raw(Rxn_gas_phase_map, os, 0);
}
else
{
std::set < int >::iterator it;
for (it = dump_info.Get_gas_phase().begin(); it != dump_info.Get_gas_phase().end(); it++)
{
cxxGasPhase *p = Utilities::Rxn_find(Rxn_gas_phase_map, *it);
if (p != NULL)
{
p->dump_raw(os, 0);
}
}
}
}
#ifdef SKIP
if (dump_info.Get_bool_gas_phase()) if (dump_info.Get_bool_gas_phase())
{ {
if (dump_info.Get_gas_phase().size() == 0) if (dump_info.Get_gas_phase().size() == 0)
@ -2617,7 +2789,7 @@ dump_ostream(std::ostream& os)
} }
} }
} }
#endif
// kinetics // kinetics
if (dump_info.Get_bool_kinetics()) if (dump_info.Get_bool_kinetics())
{ {
@ -2692,6 +2864,27 @@ dump_ostream(std::ostream& os)
} }
#endif #endif
// reaction // reaction
if (dump_info.Get_bool_reaction())
{
if (dump_info.Get_reaction().size() == 0)
{
Utilities::Rxn_dump_raw(Rxn_reaction_map, os, 0);
}
else
{
std::set < int >::iterator it;
for (it = dump_info.Get_reaction().begin(); it != dump_info.Get_reaction().end(); it++)
{
cxxReaction *p = Utilities::Rxn_find(Rxn_reaction_map, *it);
if (p != NULL)
{
p->dump_raw(os, 0);
}
}
}
}
#ifdef SKIP
if (dump_info.Get_bool_reaction()) if (dump_info.Get_bool_reaction())
{ {
if (dump_info.Get_reaction().size() == 0) if (dump_info.Get_reaction().size() == 0)
@ -2716,7 +2909,7 @@ dump_ostream(std::ostream& os)
} }
} }
} }
#endif
// temperature // temperature
if (dump_info.Get_bool_temperature()) if (dump_info.Get_bool_temperature())
{ {
@ -2760,10 +2953,10 @@ dump_ostream(std::ostream& os)
} }
} }
// Turn off any reaction calculation // Turn off any reaction calculation
os << "USE mix none" << std::endl; os << "USE mix none" << "\n";
os << "USE reaction none" << std::endl; os << "USE reaction none" << "\n";
os << "USE reaction_temperature none" << std::endl; os << "USE reaction_temperature none" << "\n";
os << "USE reaction_pressure none" << std::endl; os << "USE reaction_pressure none" << "\n";
// Turn off dump until next read // Turn off dump until next read
dump_info.SetAll(false); dump_info.SetAll(false);
@ -2794,9 +2987,10 @@ read_user_graph_handler(void)
*/ */
std::istringstream iss_in; std::istringstream iss_in;
return_value = streamify_to_next_keyword(iss_in); return_value = streamify_to_next_keyword(iss_in);
std::ostringstream oss_out; //std::ostringstream oss_out;
std::ostringstream oss_err; //std::ostringstream oss_err;
CParser parser(iss_in, oss_out, oss_err, phrq_io); //CParser parser(iss_in, oss_out, oss_err, phrq_io);
CParser parser(iss_in, phrq_io);
//For testing, need to read line to get started //For testing, need to read line to get started
std::vector < std::string > vopts; std::vector < std::string > vopts;
@ -2820,4 +3014,86 @@ read_user_graph_handler(void)
if (return_value == OPTION_KEYWORD) echo_msg(sformatf( "\t%s\n", line)); if (return_value == OPTION_KEYWORD) echo_msg(sformatf( "\t%s\n", line));
return (return_value); return (return_value);
} }
#endif
#ifdef SKIP
/* ---------------------------------------------------------------------- */
int Phreeqc::
read_generic(Keywords::KEYWORDS key)
/* ---------------------------------------------------------------------- */
{
/*
* Reads _raw and _modify data blocks
*
* Arguments:
* none
*
* Returns:
* KEYWORD if keyword encountered, input_error may be incremented if
* a keyword is encountered in an unexpected position
* EOF if eof encountered while reading mass balance concentrations
* ERROR if error occurred reading data
*
*/
int return_value;
std::string token;
char *next;
int n_user;
next = line;
copy_token(token, &next);
if (copy_token(token, &next) != DIGIT)
{
input_error++;
error_string = sformatf( "Expected reactant number following keyword.\n%s\n", line_save);
error_msg(error_string, CONTINUE);
std::istringstream iss_in;
return_value = streamify_to_next_keyword(iss_in);
return (ERROR);
}
else
{
sscanf(token.c_str(),"%d", &n_user);
}
/*
* Make parser
*/
std::istringstream iss_in;
return_value = streamify_to_next_keyword(iss_in);
CParser parser(iss_in, phrq_io);
assert(!reading_database());
//For testing, need to read line to get started
parser.set_echo_file(CParser::EO_NONE);
std::vector < std::string > vopts;
std::istream::pos_type next_char;
parser.get_option(vopts, next_char);
if (pr.echo_input == FALSE)
{
parser.set_echo_file(CParser::EO_NONE);
}
else
{
parser.set_echo_file(CParser::EO_NOKEYWORDS);
}
switch (key)
{
case Keywords::KEY_REACTION_PRESSURE_RAW:
{
cxxPressure entity(this->phrq_io);
entity.read_raw(parser);
if (entity.Get_base_error_count() == 0)
{
Rxn_pressure_map[n_user] = entity;
}
// Make copies if necessary
Utilities::Rxn_copies(Rxn_pressure_map, entity.Get_n_user(), entity.Get_n_user_end());
}
break;
}
// Need to output the next keyword
if (return_value == OPTION_KEYWORD) echo_msg(sformatf( "\t%s\n", line));
return (return_value);
}
#endif #endif

View File

@ -90,14 +90,14 @@ cxxSSassemblage::dump_xml(std::ostream & s_oss, unsigned int indent) const const
// SSassemblage element and attributes // SSassemblage element and attributes
s_oss << indent0; s_oss << indent0;
s_oss << "<EQUILIBRIUM_PHASES " << std::endl; s_oss << "<EQUILIBRIUM_PHASES " << "\n";
// eltList // eltList
this->eltList.dump_xml(s_oss, indent + 1); this->eltList.dump_xml(s_oss, indent + 1);
// ssAssemblageSSs // ssAssemblageSSs
s_oss << indent1; s_oss << indent1;
s_oss << "<pure_phases " << std::endl; s_oss << "<pure_phases " << "\n";
for (std::list < cxxSSassemblageSS >::const_iterator it = for (std::list < cxxSSassemblageSS >::const_iterator it =
ssAssemblageSSs.begin(); it != ssAssemblageSSs.end(); ++it) ssAssemblageSSs.begin(); it != ssAssemblageSSs.end(); ++it)
{ {
@ -122,14 +122,14 @@ cxxSSassemblage::dump_raw(std::ostream & s_oss, unsigned int indent, int *n_out)
// SSassemblage element and attributes // SSassemblage element and attributes
s_oss << indent0; s_oss << indent0;
int n_user_local = (n_out != NULL) ? *n_out : this->n_user; int n_user_local = (n_out != NULL) ? *n_out : this->n_user;
s_oss << "SOLID_SOLUTIONS_RAW " << n_user_local << " " << this->description << std::endl; s_oss << "SOLID_SOLUTIONS_RAW " << n_user_local << " " << this->description << "\n";
// ssAssemblageSSs // ssAssemblageSSs
for (std::map < std::string, cxxSSassemblageSS >::const_iterator it = for (std::map < std::string, cxxSSassemblageSS >::const_iterator it =
ssAssemblageSSs.begin(); it != ssAssemblageSSs.end(); ++it) ssAssemblageSSs.begin(); it != ssAssemblageSSs.end(); ++it)
{ {
s_oss << indent1; s_oss << indent1;
s_oss << "-solid_solution" << std::endl; s_oss << "-solid_solution" << "\n";
(*it).second.dump_raw(s_oss, indent + 2); (*it).second.dump_raw(s_oss, indent + 2);
} }
} }
@ -181,8 +181,8 @@ cxxSSassemblage::read_raw(CParser & parser, bool check)
opt = CParser::OPT_EOF; opt = CParser::OPT_EOF;
parser. parser.
error_msg("Unknown input in SOLID_SOLUTIONS_RAW or SOLID_SOLUTIONS_MODIFY keyword.", error_msg("Unknown input in SOLID_SOLUTIONS_RAW or SOLID_SOLUTIONS_MODIFY keyword.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
parser.error_msg(parser.line().c_str(), CParser::OT_CONTINUE); parser.error_msg(parser.line().c_str(), PHRQ_io::OT_CONTINUE);
useLastLine = false; useLastLine = false;
break; break;

View File

@ -8,7 +8,6 @@
#include <algorithm> // std::sort #include <algorithm> // std::sort
#include "Utils.h" // define first #include "Utils.h" // define first
#include "Phreeqc.h"
#include "SSassemblageSS.h" #include "SSassemblageSS.h"
//#include "Dictionary.h" //#include "Dictionary.h"
#include "phqalloc.h" #include "phqalloc.h"
@ -91,16 +90,16 @@ cxxSSassemblageSS::dump_xml(std::ostream & s_oss, unsigned int indent) const con
// S_S element and attributes // S_S element and attributes
s_oss << indent0 << "name=\"" << this->name << "\"" << std::endl; s_oss << indent0 << "name=\"" << this->name << "\"" << "\n";
s_oss << indent0 << "add_formula=\"" << this-> s_oss << indent0 << "add_formula=\"" << this->
add_formula << "\"" << std::endl; add_formula << "\"" << "\n";
s_oss << indent0 << "si=\"" << this->si << "\"" << std::endl; s_oss << indent0 << "si=\"" << this->si << "\"" << "\n";
s_oss << indent0 << "moles=\"" << this->moles << "\"" << std::endl; s_oss << indent0 << "moles=\"" << this->moles << "\"" << "\n";
s_oss << indent0 << "delta=\"" << this->delta << "\"" << std::endl; s_oss << indent0 << "delta=\"" << this->delta << "\"" << "\n";
s_oss << indent0 << "initial_moles=\"" << this-> s_oss << indent0 << "initial_moles=\"" << this->
initial_moles << "\"" << std::endl; initial_moles << "\"" << "\n";
s_oss << indent0 << "dissolve_only=\"" << this-> s_oss << indent0 << "dissolve_only=\"" << this->
dissolve_only << "\"" << std::endl; dissolve_only << "\"" << "\n";
} }
#endif #endif
@ -117,18 +116,18 @@ cxxSSassemblageSS::dump_raw(std::ostream & s_oss, unsigned int indent) const
indent1.append(Utilities::INDENT); indent1.append(Utilities::INDENT);
// S_S element and attributes // S_S element and attributes
s_oss << indent0 << "-name " << this->name << std::endl; s_oss << indent0 << "-name " << this->name << "\n";
//s_oss << indent0 << "-total_moles " << this->total_moles << std::endl; //s_oss << indent0 << "-total_moles " << this->total_moles << "\n";
s_oss << indent1 << "-a0 " << this->a0 << std::endl; s_oss << indent1 << "-a0 " << this->a0 << "\n";
s_oss << indent1 << "-a1 " << this->a1 << std::endl; s_oss << indent1 << "-a1 " << this->a1 << "\n";
s_oss << indent1 << "-ag0 " << this->ag0 << std::endl; s_oss << indent1 << "-ag0 " << this->ag0 << "\n";
s_oss << indent1 << "-ag1 " << this->ag1 << std::endl; s_oss << indent1 << "-ag1 " << this->ag1 << "\n";
s_oss << indent1 << "-miscibility " << this->miscibility << std::endl; s_oss << indent1 << "-miscibility " << this->miscibility << "\n";
//s_oss << indent0 << "-spinodal " << this->spinodal << std::endl; //s_oss << indent0 << "-spinodal " << this->spinodal << "\n";
//s_oss << indent0 << "-tk " << this->tk << std::endl; //s_oss << indent0 << "-tk " << this->tk << "\n";
s_oss << indent1 << "-xb1 " << this->xb1 << std::endl; s_oss << indent1 << "-xb1 " << this->xb1 << "\n";
s_oss << indent1 << "-xb2 " << this->xb2 << std::endl; s_oss << indent1 << "-xb2 " << this->xb2 << "\n";
s_oss << indent1 << "-components " << std::endl; s_oss << indent1 << "-components " << "\n";
this->comps.dump_raw(s_oss, indent + 2); this->comps.dump_raw(s_oss, indent + 2);
} }
@ -191,8 +190,8 @@ cxxSSassemblageSS::read_raw(CParser & parser, bool check)
case CParser::OPT_ERROR: case CParser::OPT_ERROR:
opt = CParser::OPT_KEYWORD; opt = CParser::OPT_KEYWORD;
// Allow return to Exchange for more processing // Allow return to Exchange for more processing
//parser.error_msg("Unknown input in S_S read.", CParser::OT_CONTINUE); //parser.error_msg("Unknown input in S_S read.", PHRQ_io::OT_CONTINUE);
//parser.error_msg(parser.line().c_str(), CParser::OT_CONTINUE); //parser.error_msg(parser.line().c_str(), PHRQ_io::OT_CONTINUE);
break; break;
case 0: // name case 0: // name
@ -201,7 +200,7 @@ cxxSSassemblageSS::read_raw(CParser & parser, bool check)
this->name.clear(); this->name.clear();
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Expected string value for name.", parser.error_msg("Expected string value for name.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
else else
{ {
@ -217,7 +216,7 @@ cxxSSassemblageSS::read_raw(CParser & parser, bool check)
{ {
this->total_moles = 0; this->total_moles = 0;
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Expected numeric value for total_moles.", CParser::OT_CONTINUE); parser.error_msg("Expected numeric value for total_moles.", PHRQ_io::OT_CONTINUE);
} }
total_moles_defined = true; total_moles_defined = true;
*/ */
@ -230,7 +229,7 @@ cxxSSassemblageSS::read_raw(CParser & parser, bool check)
this->a0 = 0; this->a0 = 0;
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Expected numeric value for a0.", parser.error_msg("Expected numeric value for a0.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
a0_defined = true; a0_defined = true;
opt_save = CParser::OPT_DEFAULT; opt_save = CParser::OPT_DEFAULT;
@ -242,7 +241,7 @@ cxxSSassemblageSS::read_raw(CParser & parser, bool check)
this->a1 = 0; this->a1 = 0;
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Expected numeric value for a1.", parser.error_msg("Expected numeric value for a1.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
a1_defined = true; a1_defined = true;
opt_save = CParser::OPT_DEFAULT; opt_save = CParser::OPT_DEFAULT;
@ -253,7 +252,7 @@ cxxSSassemblageSS::read_raw(CParser & parser, bool check)
{ {
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Expected phase name and moles for comps.", parser.error_msg("Expected phase name and moles for comps.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
opt_save = 4; opt_save = 4;
break; break;
@ -264,7 +263,7 @@ cxxSSassemblageSS::read_raw(CParser & parser, bool check)
this->miscibility = 0; this->miscibility = 0;
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Expected boolean value for miscibility.", parser.error_msg("Expected boolean value for miscibility.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
miscibility_defined = true; miscibility_defined = true;
opt_save = CParser::OPT_DEFAULT; opt_save = CParser::OPT_DEFAULT;
@ -276,7 +275,7 @@ cxxSSassemblageSS::read_raw(CParser & parser, bool check)
{ {
this->spinodal = 0; this->spinodal = 0;
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Expected boolean value for spinodal.", CParser::OT_CONTINUE); parser.error_msg("Expected boolean value for spinodal.", PHRQ_io::OT_CONTINUE);
} }
spinodal_defined = true; spinodal_defined = true;
*/ */
@ -289,7 +288,7 @@ cxxSSassemblageSS::read_raw(CParser & parser, bool check)
{ {
this->tk = 0; this->tk = 0;
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Expected numeric value for tk.", CParser::OT_CONTINUE); parser.error_msg("Expected numeric value for tk.", PHRQ_io::OT_CONTINUE);
} }
tk_defined = true; tk_defined = true;
*/ */
@ -302,7 +301,7 @@ cxxSSassemblageSS::read_raw(CParser & parser, bool check)
this->xb1 = 0; this->xb1 = 0;
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Expected numeric value for xb1.", parser.error_msg("Expected numeric value for xb1.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
xb1_defined = true; xb1_defined = true;
opt_save = CParser::OPT_DEFAULT; opt_save = CParser::OPT_DEFAULT;
@ -314,7 +313,7 @@ cxxSSassemblageSS::read_raw(CParser & parser, bool check)
this->xb2 = 0; this->xb2 = 0;
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Expected numeric value for xb2.", parser.error_msg("Expected numeric value for xb2.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
xb2_defined = true; xb2_defined = true;
opt_save = CParser::OPT_DEFAULT; opt_save = CParser::OPT_DEFAULT;
@ -326,7 +325,7 @@ cxxSSassemblageSS::read_raw(CParser & parser, bool check)
this->ag0 = 0; this->ag0 = 0;
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Expected numeric value for ag0.", parser.error_msg("Expected numeric value for ag0.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
ag0_defined = true; ag0_defined = true;
opt_save = CParser::OPT_DEFAULT; opt_save = CParser::OPT_DEFAULT;
@ -338,7 +337,7 @@ cxxSSassemblageSS::read_raw(CParser & parser, bool check)
this->ag1 = 0; this->ag1 = 0;
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Expected numeric value for ag1.", parser.error_msg("Expected numeric value for ag1.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
ag1_defined = true; ag1_defined = true;
opt_save = CParser::OPT_DEFAULT; opt_save = CParser::OPT_DEFAULT;
@ -356,65 +355,65 @@ cxxSSassemblageSS::read_raw(CParser & parser, bool check)
{ {
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Name not defined for SSassemblageSS input.", parser.error_msg("Name not defined for SSassemblageSS input.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
/* /*
if (total_moles_defined == false) { if (total_moles_defined == false) {
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Total_moles not defined for SSassemblageSS input.", CParser::OT_CONTINUE); parser.error_msg("Total_moles not defined for SSassemblageSS input.", PHRQ_io::OT_CONTINUE);
} }
*/ */
if (a0_defined == false) if (a0_defined == false)
{ {
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("A0 not defined for SSassemblageSS input.", parser.error_msg("A0 not defined for SSassemblageSS input.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
if (a1_defined == false) if (a1_defined == false)
{ {
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("A1 not defined for SSassemblageSS input.", parser.error_msg("A1 not defined for SSassemblageSS input.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
if (ag0_defined == false) if (ag0_defined == false)
{ {
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Ag0 not defined for SSassemblageSS input.", parser.error_msg("Ag0 not defined for SSassemblageSS input.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
if (ag1_defined == false) if (ag1_defined == false)
{ {
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Ag1 not defined for SSassemblageSS input.", parser.error_msg("Ag1 not defined for SSassemblageSS input.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
if (miscibility_defined == false) if (miscibility_defined == false)
{ {
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Miscibility not defined for SSassemblageSS input.", parser.error_msg("Miscibility not defined for SSassemblageSS input.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
/* /*
if (spinodal_defined == false) { if (spinodal_defined == false) {
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Spinodal not defined for SSassemblageSS input.", CParser::OT_CONTINUE); parser.error_msg("Spinodal not defined for SSassemblageSS input.", PHRQ_io::OT_CONTINUE);
} }
if (tk_defined == false) { if (tk_defined == false) {
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Tk not defined for SSassemblageSS input.", CParser::OT_CONTINUE); parser.error_msg("Tk not defined for SSassemblageSS input.", PHRQ_io::OT_CONTINUE);
} }
*/ */
if (xb1_defined == false) if (xb1_defined == false)
{ {
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Xb1 not defined for SSassemblageSS input.", parser.error_msg("Xb1 not defined for SSassemblageSS input.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
if (xb2_defined == false) if (xb2_defined == false)
{ {
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Xb2 not defined for SSassemblageSS input.", parser.error_msg("Xb2 not defined for SSassemblageSS input.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
} }
} }

View File

@ -144,50 +144,50 @@ cxxSolution::dump_xml(std::ostream & s_oss, unsigned int indent) const
// Solution element and attributes // Solution element and attributes
s_oss << indent0; s_oss << indent0;
s_oss << "<solution " << std::endl; s_oss << "<solution " << "\n";
//s_oss << indent1; //s_oss << indent1;
//s_oss << "soln_new_def=\"" << this->new_def << "\"" << std::endl; //s_oss << "soln_new_def=\"" << this->new_def << "\"" << "\n";
s_oss << indent1; s_oss << indent1;
s_oss << "soln_n_user=\"" << this->n_user << "\" " << std::endl; s_oss << "soln_n_user=\"" << this->n_user << "\" " << "\n";
s_oss << indent1; s_oss << indent1;
s_oss << "soln_description=\"" << this->description << "\"" << std::endl; s_oss << "soln_description=\"" << this->description << "\"" << "\n";
s_oss << indent1; s_oss << indent1;
s_oss << "soln_tc=\"" << this->tc << "\"" << std::endl; s_oss << "soln_tc=\"" << this->tc << "\"" << "\n";
s_oss << indent1; s_oss << indent1;
s_oss << "soln_ph=\"" << this->ph << "\"" << std::endl; s_oss << "soln_ph=\"" << this->ph << "\"" << "\n";
s_oss << indent1; s_oss << indent1;
s_oss << "soln_solution_pe=\"" << this->pe << "\"" << std::endl; s_oss << "soln_solution_pe=\"" << this->pe << "\"" << "\n";
s_oss << indent1; s_oss << indent1;
s_oss << "soln_mu=\"" << this->mu << "\"" << std::endl; s_oss << "soln_mu=\"" << this->mu << "\"" << "\n";
s_oss << indent1; s_oss << indent1;
s_oss << "soln_ah2o=\"" << this->ah2o << "\"" << std::endl; s_oss << "soln_ah2o=\"" << this->ah2o << "\"" << "\n";
s_oss << indent1; s_oss << indent1;
s_oss << "soln_total_h=\"" << this->total_h << "\"" << std::endl; s_oss << "soln_total_h=\"" << this->total_h << "\"" << "\n";
s_oss << indent1; s_oss << indent1;
s_oss << "soln_total_o=\"" << this->total_o << "\"" << std::endl; s_oss << "soln_total_o=\"" << this->total_o << "\"" << "\n";
s_oss << indent1; s_oss << indent1;
s_oss << "soln_cb=\"" << this->cb << "\"" << std::endl; s_oss << "soln_cb=\"" << this->cb << "\"" << "\n";
s_oss << indent1; s_oss << indent1;
s_oss << "soln_mass_water=\"" << this->mass_water << "\"" << std::endl; s_oss << "soln_mass_water=\"" << this->mass_water << "\"" << "\n";
s_oss << indent1; s_oss << indent1;
s_oss << "soln_total_alkalinity=\"" << this-> s_oss << "soln_total_alkalinity=\"" << this->
total_alkalinity << "\"" << std::endl; total_alkalinity << "\"" << "\n";
s_oss << indent1; s_oss << indent1;
s_oss << "\">" << std::endl; s_oss << "\">" << "\n";
// soln_total conc structures // soln_total conc structures
this->totals.dump_xml(s_oss, indent + 1); this->totals.dump_xml(s_oss, indent + 1);
@ -201,7 +201,7 @@ cxxSolution::dump_xml(std::ostream & s_oss, unsigned int indent) const
s_oss << "<soln_m_a"; s_oss << "<soln_m_a";
s_oss << " m_a_desc=\"" << it->first << "\"" ; s_oss << " m_a_desc=\"" << it->first << "\"" ;
s_oss << " m_a_la=\"" << it->second << "\"" ; s_oss << " m_a_la=\"" << it->second << "\"" ;
s_oss << "\">" << std::endl; s_oss << "\">" << "\n";
} }
} }
*/ */
@ -214,7 +214,7 @@ cxxSolution::dump_xml(std::ostream & s_oss, unsigned int indent) const
s_oss << "<soln_s_g"; s_oss << "<soln_s_g";
s_oss << " m_a_desc=\"" << it->first << "\"" ; s_oss << " m_a_desc=\"" << it->first << "\"" ;
s_oss << " m_a_la=\"" << it->second << "\"" ; s_oss << " m_a_la=\"" << it->second << "\"" ;
s_oss << "\">" << std::endl; s_oss << "\">" << "\n";
} }
} }
*/ */
@ -227,7 +227,7 @@ cxxSolution::dump_xml(std::ostream & s_oss, unsigned int indent) const
// End of solution // End of solution
s_oss << indent0; s_oss << indent0;
s_oss << "</solution>" << std::endl; s_oss << "</solution>" << "\n";
return; return;
} }
@ -249,35 +249,35 @@ cxxSolution::dump_raw(std::ostream & s_oss, unsigned int indent, int *n_out) con
// Solution element and attributes // Solution element and attributes
s_oss << indent0; s_oss << indent0;
int n_user_local = (n_out != NULL) ? *n_out : this->n_user; int n_user_local = (n_out != NULL) ? *n_out : this->n_user;
s_oss << "SOLUTION_RAW " << n_user_local << " " << this->description << std::endl; s_oss << "SOLUTION_RAW " << n_user_local << " " << this->description << "\n";
//s_oss << "# Critical values" << std::endl; //s_oss << "# Critical values" << "\n";
s_oss << indent1; s_oss << indent1;
s_oss << "-temp " << this->tc << std::endl; s_oss << "-temp " << this->tc << "\n";
// new identifier // new identifier
s_oss << indent1; s_oss << indent1;
s_oss << "-total_h " << this->total_h << std::endl; s_oss << "-total_h " << this->total_h << "\n";
// new identifier // new identifier
s_oss << indent1; s_oss << indent1;
s_oss << "-total_o " << this->total_o << std::endl; s_oss << "-total_o " << this->total_o << "\n";
// new identifier // new identifier
s_oss << indent1; s_oss << indent1;
s_oss << "-cb " << this->cb << std::endl; s_oss << "-cb " << this->cb << "\n";
// soln_total conc structures // soln_total conc structures
s_oss << indent1; s_oss << indent1;
s_oss << "-totals" << std::endl; s_oss << "-totals" << "\n";
this->totals.dump_raw(s_oss, indent + 2); this->totals.dump_raw(s_oss, indent + 2);
//s_oss << "# Optional critical values" << std::endl; //s_oss << "# Optional critical values" << "\n";
// Isotopes // Isotopes
s_oss << indent1; s_oss << indent1;
s_oss << "-Isotopes" << std::endl; s_oss << "-Isotopes" << "\n";
{ {
for (std::list < cxxSolutionIsotope >::const_iterator it = for (std::list < cxxSolutionIsotope >::const_iterator it =
this->isotopes.begin(); it != isotopes.end(); ++it) this->isotopes.begin(); it != isotopes.end(); ++it)
@ -287,49 +287,49 @@ cxxSolution::dump_raw(std::ostream & s_oss, unsigned int indent, int *n_out) con
} }
s_oss << indent1; s_oss << indent1;
s_oss << "-pH " << this->ph << std::endl; s_oss << "-pH " << this->ph << "\n";
s_oss << indent1; s_oss << indent1;
s_oss << "-pe " << this->pe << std::endl; s_oss << "-pe " << this->pe << "\n";
// new identifier // new identifier
s_oss << indent1; s_oss << indent1;
s_oss << "-mu " << this->mu << std::endl; s_oss << "-mu " << this->mu << "\n";
// new identifier // new identifier
s_oss << indent1; s_oss << indent1;
s_oss << "-ah2o " << this->ah2o << std::endl; s_oss << "-ah2o " << this->ah2o << "\n";
// new identifier // new identifier
s_oss << indent1; s_oss << indent1;
s_oss << "-mass_water " << this->mass_water << std::endl; s_oss << "-mass_water " << this->mass_water << "\n";
// new identifier // new identifier
s_oss << indent1; s_oss << indent1;
s_oss << "-total_alkalinity " << this->total_alkalinity << std::endl; s_oss << "-total_alkalinity " << this->total_alkalinity << "\n";
// master_activity map // master_activity map
s_oss << indent1; s_oss << indent1;
s_oss << "-activities" << std::endl; s_oss << "-activities" << "\n";
this->master_activity.dump_raw(s_oss, indent + 2); this->master_activity.dump_raw(s_oss, indent + 2);
/* /*
{ {
for (std::map <char *, double>::const_iterator it = master_activity.begin(); it != master_activity.end(); ++it) { for (std::map <char *, double>::const_iterator it = master_activity.begin(); it != master_activity.end(); ++it) {
s_oss << indent2; s_oss << indent2;
s_oss << it->first << " " << it->second << std::endl; s_oss << it->first << " " << it->second << "\n";
} }
} }
*/ */
// species_gamma map // species_gamma map
s_oss << indent1; s_oss << indent1;
s_oss << "-gammas" << std::endl; s_oss << "-gammas" << "\n";
this->species_gamma.dump_raw(s_oss, indent + 2); this->species_gamma.dump_raw(s_oss, indent + 2);
/* /*
{ {
{ {
for (std::map <char *, double>::const_iterator it = species_gamma.begin(); it != species_gamma.end(); ++it) { for (std::map <char *, double>::const_iterator it = species_gamma.begin(); it != species_gamma.end(); ++it) {
s_oss << indent2; s_oss << indent2;
s_oss << it->first << " " << it->second << std::endl; s_oss << it->first << " " << it->second << "\n";
} }
} }
} }
@ -406,8 +406,8 @@ cxxSolution::read_raw(CParser & parser, bool check)
case CParser::OPT_ERROR: case CParser::OPT_ERROR:
opt = CParser::OPT_EOF; opt = CParser::OPT_EOF;
parser.error_msg("Unknown input in SOLUTION_RAW keyword.", parser.error_msg("Unknown input in SOLUTION_RAW keyword.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
parser.error_msg(parser.line().c_str(), CParser::OT_CONTINUE); parser.error_msg(parser.line().c_str(), PHRQ_io::OT_CONTINUE);
continue; continue;
case 0: // totals case 0: // totals
@ -417,7 +417,7 @@ cxxSolution::read_raw(CParser & parser, bool check)
// parser.incr_input_error(); // parser.incr_input_error();
// parser. // parser.
// error_msg("Expected element name and moles for totals.", // error_msg("Expected element name and moles for totals.",
// CParser::OT_CONTINUE); // PHRQ_io::OT_CONTINUE);
//} //}
{ {
cxxNameDouble temp_totals; cxxNameDouble temp_totals;
@ -426,7 +426,7 @@ cxxSolution::read_raw(CParser & parser, bool check)
parser.incr_input_error(); parser.incr_input_error();
parser. parser.
error_msg("Expected element name and moles for totals.", error_msg("Expected element name and moles for totals.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
else else
{ {
@ -444,7 +444,7 @@ cxxSolution::read_raw(CParser & parser, bool check)
parser. parser.
error_msg error_msg
("Expected species name and log activity for activities.", ("Expected species name and log activity for activities.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
opt_save = 1; opt_save = 1;
break; break;
@ -457,7 +457,7 @@ cxxSolution::read_raw(CParser & parser, bool check)
parser. parser.
error_msg error_msg
("Expected species name and activity coefficient for gammas.", ("Expected species name and activity coefficient for gammas.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
opt_save = 2; opt_save = 2;
break; break;
@ -469,7 +469,7 @@ cxxSolution::read_raw(CParser & parser, bool check)
{ {
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Expected data for isotopes.", parser.error_msg("Expected data for isotopes.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
else else
{ {
@ -490,7 +490,7 @@ cxxSolution::read_raw(CParser & parser, bool check)
this->tc = 25.0; this->tc = 25.0;
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Expected numeric value for temperature.", parser.error_msg("Expected numeric value for temperature.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
tc_defined = true; tc_defined = true;
opt_save = CParser::OPT_DEFAULT; opt_save = CParser::OPT_DEFAULT;
@ -502,7 +502,7 @@ cxxSolution::read_raw(CParser & parser, bool check)
this->ph = 7.0; this->ph = 7.0;
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Expected numeric value for pH.", parser.error_msg("Expected numeric value for pH.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
ph_defined = true; ph_defined = true;
opt_save = CParser::OPT_DEFAULT; opt_save = CParser::OPT_DEFAULT;
@ -514,7 +514,7 @@ cxxSolution::read_raw(CParser & parser, bool check)
this->pe = 4.0; this->pe = 4.0;
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Expected numeric value for pe.", parser.error_msg("Expected numeric value for pe.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
pe_defined = true; pe_defined = true;
opt_save = CParser::OPT_DEFAULT; opt_save = CParser::OPT_DEFAULT;
@ -527,7 +527,7 @@ cxxSolution::read_raw(CParser & parser, bool check)
this->mu = 1e-7; this->mu = 1e-7;
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Expected numeric value for ionic strength.", parser.error_msg("Expected numeric value for ionic strength.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
mu_defined = true; mu_defined = true;
opt_save = CParser::OPT_DEFAULT; opt_save = CParser::OPT_DEFAULT;
@ -541,7 +541,7 @@ cxxSolution::read_raw(CParser & parser, bool check)
parser.incr_input_error(); parser.incr_input_error();
parser. parser.
error_msg("Expected numeric value for activity of water.", error_msg("Expected numeric value for activity of water.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
ah2o_defined = true; ah2o_defined = true;
opt_save = CParser::OPT_DEFAULT; opt_save = CParser::OPT_DEFAULT;
@ -553,7 +553,7 @@ cxxSolution::read_raw(CParser & parser, bool check)
this->total_h = 111.1; this->total_h = 111.1;
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Expected numeric value for total hydrogen.", parser.error_msg("Expected numeric value for total hydrogen.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
total_h_defined = true; total_h_defined = true;
opt_save = CParser::OPT_DEFAULT; opt_save = CParser::OPT_DEFAULT;
@ -565,7 +565,7 @@ cxxSolution::read_raw(CParser & parser, bool check)
this->total_o = 55.55; this->total_o = 55.55;
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Expected numeric value for total oxygen.", parser.error_msg("Expected numeric value for total oxygen.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
total_o_defined = true; total_o_defined = true;
opt_save = CParser::OPT_DEFAULT; opt_save = CParser::OPT_DEFAULT;
@ -578,7 +578,7 @@ cxxSolution::read_raw(CParser & parser, bool check)
this->mass_water = 1.0; this->mass_water = 1.0;
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Expected numeric value for mass of water.", parser.error_msg("Expected numeric value for mass of water.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
mass_water_defined = true; mass_water_defined = true;
opt_save = CParser::OPT_DEFAULT; opt_save = CParser::OPT_DEFAULT;
@ -592,7 +592,7 @@ cxxSolution::read_raw(CParser & parser, bool check)
parser.incr_input_error(); parser.incr_input_error();
parser. parser.
error_msg("Expected numeric value for total_alkalinity.", error_msg("Expected numeric value for total_alkalinity.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
total_alkalinity_defined = true; total_alkalinity_defined = true;
opt_save = CParser::OPT_DEFAULT; opt_save = CParser::OPT_DEFAULT;
@ -605,7 +605,7 @@ cxxSolution::read_raw(CParser & parser, bool check)
this->cb = 0; this->cb = 0;
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Expected numeric value for charge balance.", parser.error_msg("Expected numeric value for charge balance.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
cb_defined = true; cb_defined = true;
opt_save = CParser::OPT_DEFAULT; opt_save = CParser::OPT_DEFAULT;
@ -623,63 +623,63 @@ cxxSolution::read_raw(CParser & parser, bool check)
{ {
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Temp not defined for SOLUTION_RAW input.", parser.error_msg("Temp not defined for SOLUTION_RAW input.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
if (ph_defined == false) if (ph_defined == false)
{ {
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("pH not defined for SOLUTION_RAW input.", parser.error_msg("pH not defined for SOLUTION_RAW input.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
if (pe_defined == false) if (pe_defined == false)
{ {
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("pe not defined for SOLUTION_RAW input.", parser.error_msg("pe not defined for SOLUTION_RAW input.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
if (mu_defined == false) if (mu_defined == false)
{ {
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Ionic strength not defined for SOLUTION_RAW input.", parser.error_msg("Ionic strength not defined for SOLUTION_RAW input.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
if (ah2o_defined == false) if (ah2o_defined == false)
{ {
parser.incr_input_error(); parser.incr_input_error();
parser. parser.
error_msg("Activity of water not defined for SOLUTION_RAW input.", error_msg("Activity of water not defined for SOLUTION_RAW input.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
if (total_h_defined == false) if (total_h_defined == false)
{ {
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Total hydrogen not defined for SOLUTION_RAW input.", parser.error_msg("Total hydrogen not defined for SOLUTION_RAW input.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
if (total_o_defined == false) if (total_o_defined == false)
{ {
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Total oxygen not defined for SOLUTION_RAW input.", parser.error_msg("Total oxygen not defined for SOLUTION_RAW input.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
if (cb_defined == false) if (cb_defined == false)
{ {
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Charge balance not defined for SOLUTION_RAW input.", parser.error_msg("Charge balance not defined for SOLUTION_RAW input.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
if (mass_water_defined == false) if (mass_water_defined == false)
{ {
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Temp not defined for SOLUTION_RAW input.", parser.error_msg("Temp not defined for SOLUTION_RAW input.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
if (total_alkalinity_defined == false) if (total_alkalinity_defined == false)
{ {
parser.incr_input_error(); parser.incr_input_error();
parser. parser.
error_msg("Total alkalinity not defined for SOLUTION_RAW input.", error_msg("Total alkalinity not defined for SOLUTION_RAW input.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
} }
return; return;
@ -1469,13 +1469,13 @@ cxxSolution::Update(const cxxNameDouble &nd)
// */ // */
// std::ostringstream msg; // std::ostringstream msg;
// status_on = FALSE; // status_on = FALSE;
// std::cout << std::endl << "TEST CLASSES" << std::endl; // std::cout << "\n" << "TEST CLASSES" << "\n";
// for (i = 0; i < count_solution; i++) // for (i = 0; i < count_solution; i++)
// { // {
// if (solution[i]->new_def == TRUE) // if (solution[i]->new_def == TRUE)
// { // {
// std::cout << "Solution new_def " << solution[i]-> // std::cout << "Solution new_def " << solution[i]->
// n_user << std::endl; // n_user << "\n";
// cxxISolution sol(solution[i]); // cxxISolution sol(solution[i]);
// solution_free(solution[i]); // solution_free(solution[i]);
// solution[i] = NULL; // solution[i] = NULL;
@ -1486,7 +1486,7 @@ cxxSolution::Update(const cxxNameDouble &nd)
// } // }
// else // else
// { // {
// std::cout << "Solution " << solution[i]->n_user << std::endl; // std::cout << "Solution " << solution[i]->n_user << "\n";
// std::ostringstream oss; // std::ostringstream oss;
// cxxSolution sol(solution[i]); // cxxSolution sol(solution[i]);
// solution_free(solution[i]); // solution_free(solution[i]);
@ -1515,7 +1515,7 @@ cxxSolution::Update(const cxxNameDouble &nd)
// { // {
// if (exchange[i].new_def != TRUE) // if (exchange[i].new_def != TRUE)
// { // {
// std::cout << "Exchange " << exchange[i].n_user << std::endl; // std::cout << "Exchange " << exchange[i].n_user << "\n";
// std::ostringstream oss; // std::ostringstream oss;
// cxxExchange ex(&(exchange[i])); // cxxExchange ex(&(exchange[i]));
// ex.dump_raw(oss, 0); // ex.dump_raw(oss, 0);
@ -1544,7 +1544,7 @@ cxxSolution::Update(const cxxNameDouble &nd)
// { // {
// if (surface[i].new_def != TRUE) // if (surface[i].new_def != TRUE)
// { // {
// std::cout << "Surface " << surface[i].n_user << std::endl; // std::cout << "Surface " << surface[i].n_user << "\n";
// std::ostringstream oss; // std::ostringstream oss;
// cxxSurface ex(&(surface[i])); // cxxSurface ex(&(surface[i]));
// ex.dump_raw(oss, 0); // ex.dump_raw(oss, 0);
@ -1577,7 +1577,7 @@ cxxSolution::Update(const cxxNameDouble &nd)
// if (pp_assemblage[i].new_def != TRUE) // if (pp_assemblage[i].new_def != TRUE)
// { // {
// std::cout << "PPassemblage " << pp_assemblage[i]. // std::cout << "PPassemblage " << pp_assemblage[i].
// n_user << std::endl; // n_user << "\n";
// std::ostringstream oss; // std::ostringstream oss;
// cxxPPassemblage ex(&(pp_assemblage[i])); // cxxPPassemblage ex(&(pp_assemblage[i]));
// ex.dump_raw(oss, 0); // ex.dump_raw(oss, 0);
@ -1609,7 +1609,7 @@ cxxSolution::Update(const cxxNameDouble &nd)
// } // }
// for (i = 0; i < count_kinetics; i++) // for (i = 0; i < count_kinetics; i++)
// { // {
// std::cout << "Kinetics " << kinetics[i].n_user << std::endl; // std::cout << "Kinetics " << kinetics[i].n_user << "\n";
// std::ostringstream oss; // std::ostringstream oss;
// cxxKinetics ex(&(kinetics[i])); // cxxKinetics ex(&(kinetics[i]));
// ex.dump_raw(oss, 0); // ex.dump_raw(oss, 0);
@ -1640,7 +1640,7 @@ cxxSolution::Update(const cxxNameDouble &nd)
// if (s_s_assemblage[i].new_def != TRUE) // if (s_s_assemblage[i].new_def != TRUE)
// { // {
// std::cout << "Solid solution " << s_s_assemblage[i]. // std::cout << "Solid solution " << s_s_assemblage[i].
// n_user << std::endl; // n_user << "\n";
// std::ostringstream oss; // std::ostringstream oss;
// cxxSSassemblage ex(&(s_s_assemblage[i])); // cxxSSassemblage ex(&(s_s_assemblage[i]));
// ex.dump_raw(oss, 0); // ex.dump_raw(oss, 0);
@ -1674,7 +1674,7 @@ cxxSolution::Update(const cxxNameDouble &nd)
// { // {
// if (gas_phase[i].new_def != TRUE) // if (gas_phase[i].new_def != TRUE)
// { // {
// std::cout << "Gas phase " << gas_phase[i].n_user << std::endl; // std::cout << "Gas phase " << gas_phase[i].n_user << "\n";
// std::ostringstream oss; // std::ostringstream oss;
// cxxGasPhase ex(&(gas_phase[i])); // cxxGasPhase ex(&(gas_phase[i]));
// ex.dump_raw(oss, 0); // ex.dump_raw(oss, 0);
@ -1705,7 +1705,7 @@ cxxSolution::Update(const cxxNameDouble &nd)
// } // }
// for (i = 0; i < count_irrev; i++) // for (i = 0; i < count_irrev; i++)
// { // {
// std::cout << "Reaction " << irrev[i].n_user << std::endl; // std::cout << "Reaction " << irrev[i].n_user << "\n";
// std::ostringstream oss; // std::ostringstream oss;
// cxxReaction ex(&(irrev[i])); // cxxReaction ex(&(irrev[i]));
// ex.dump_raw(oss, 0); // ex.dump_raw(oss, 0);
@ -1734,7 +1734,7 @@ cxxSolution::Update(const cxxNameDouble &nd)
// } // }
// for (i = 0; i < count_mix; i++) // for (i = 0; i < count_mix; i++)
// { // {
// std::cout << "Mix " << mix[i].n_user << std::endl; // std::cout << "Mix " << mix[i].n_user << "\n";
// std::ostringstream oss; // std::ostringstream oss;
// cxxMix ex(&(mix[i])); // cxxMix ex(&(mix[i]));
// ex.dump_raw(oss, 0); // ex.dump_raw(oss, 0);
@ -1763,7 +1763,7 @@ cxxSolution::Update(const cxxNameDouble &nd)
// } // }
// for (i = 0; i < count_temperature; i++) // for (i = 0; i < count_temperature; i++)
// { // {
// std::cout << "Temperature " << temperature[i].n_user << std::endl; // std::cout << "Temperature " << temperature[i].n_user << "\n";
// std::ostringstream oss; // std::ostringstream oss;
// cxxTemperature ex(&(temperature[i])); // cxxTemperature ex(&(temperature[i]));
// ex.dump_raw(oss, 0); // ex.dump_raw(oss, 0);

View File

@ -91,32 +91,32 @@ cxxSolutionIsotope::dump_xml(std::ostream & s_oss, unsigned int indent) const
indent1.append(Utilities::INDENT); indent1.append(Utilities::INDENT);
s_oss << indent0; s_oss << indent0;
s_oss << "<soln_isotope=\"" << std::endl; s_oss << "<soln_isotope=\"" << "\n";
s_oss << indent1; s_oss << indent1;
s_oss << "iso_isotope_number=\"" << this-> s_oss << "iso_isotope_number=\"" << this->
isotope_number << "\"" << std::endl; isotope_number << "\"" << "\n";
s_oss << indent1; s_oss << indent1;
s_oss << "iso_elt_name=\"" << this->elt_name << "\"" << std::endl; s_oss << "iso_elt_name=\"" << this->elt_name << "\"" << "\n";
s_oss << indent1; s_oss << indent1;
s_oss << "iso_isotope_name=\"" << this->isotope_name << "\"" << std::endl; s_oss << "iso_isotope_name=\"" << this->isotope_name << "\"" << "\n";
s_oss << indent1; s_oss << indent1;
s_oss << "iso_total=\"" << this->total << "\"" << std::endl; s_oss << "iso_total=\"" << this->total << "\"" << "\n";
s_oss << indent1; s_oss << indent1;
s_oss << "iso_ratio=\"" << this->ratio << "\"" << std::endl; s_oss << "iso_ratio=\"" << this->ratio << "\"" << "\n";
if (this->ratio_uncertainty != NAN) if (this->ratio_uncertainty != NAN)
{ {
s_oss << indent1; s_oss << indent1;
s_oss << "iso_ratio_uncertainty=\"" << this-> s_oss << "iso_ratio_uncertainty=\"" << this->
ratio_uncertainty << "\"" << std::endl; ratio_uncertainty << "\"" << "\n";
} }
s_oss << indent0; s_oss << indent0;
s_oss << "\">" << std::endl; s_oss << "\">" << "\n";
} }
void void
@ -138,7 +138,7 @@ cxxSolutionIsotope::dump_raw(std::ostream & s_oss, unsigned int indent) const
{ {
s_oss << this->ratio_uncertainty << " "; s_oss << this->ratio_uncertainty << " ";
} }
s_oss << std::endl; s_oss << "\n";
} }
CParser::STATUS_TYPE cxxSolutionIsotope::read_raw(CParser & parser, std::istream::pos_type next_char ) CParser::STATUS_TYPE cxxSolutionIsotope::read_raw(CParser & parser, std::istream::pos_type next_char )
@ -192,7 +192,7 @@ CParser::STATUS_TYPE cxxSolutionIsotope::read_raw(CParser & parser, std::istream
parser.incr_input_error(); parser.incr_input_error();
parser. parser.
error_msg("Expected numeric value for mass of water in solution.", error_msg("Expected numeric value for mass of water in solution.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
else else
{ {
@ -243,7 +243,7 @@ cxxSolutionIsotope::STATUS cxxSolutionIsotope::read(CParser & parser)
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Expected isotope name to" parser.error_msg("Expected isotope name to"
" begin with an isotopic number.", " begin with an isotopic number.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
return ERROR; return ERROR;
} }
assert(parser.get_iss().good() || parser.get_iss().eof()); assert(parser.get_iss().good() || parser.get_iss().eof());
@ -252,8 +252,8 @@ cxxSolutionIsotope::STATUS cxxSolutionIsotope::read(CParser & parser)
std::istringstream::int_type c = parser.get_iss().peek(); std::istringstream::int_type c = parser.get_iss().peek();
if (c == std::char_traits < char >::eof() || !(::isupper(c))) if (c == std::char_traits < char >::eof() || !(::isupper(c)))
{ {
parser.error_msg("Expecting element name.", CParser::OT_CONTINUE); parser.error_msg("Expecting element name.", PHRQ_io::OT_CONTINUE);
parser.error_msg(parser.line().c_str(), CParser::OT_CONTINUE); parser.error_msg(parser.line().c_str(), PHRQ_io::OT_CONTINUE);
parser.incr_input_error(); parser.incr_input_error();
return ERROR; return ERROR;
} }
@ -272,7 +272,7 @@ cxxSolutionIsotope::STATUS cxxSolutionIsotope::read(CParser & parser)
assert(parser.get_iss().fail()); assert(parser.get_iss().fail());
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Expected numeric value for isotope ratio.", parser.error_msg("Expected numeric value for isotope ratio.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
return ERROR; return ERROR;
} }
assert(parser.get_iss().good() || parser.get_iss().eof()); assert(parser.get_iss().good() || parser.get_iss().eof());
@ -287,7 +287,7 @@ cxxSolutionIsotope::STATUS cxxSolutionIsotope::read(CParser & parser)
parser. parser.
error_msg error_msg
("Expected numeric value for uncertainty in isotope ratio.", ("Expected numeric value for uncertainty in isotope ratio.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
return ERROR; return ERROR;
} }
} }

View File

@ -375,15 +375,15 @@ cxxStorageBin::dump_xml(std::ostream & s_oss, unsigned int indent) const const
// StorageBin element and attributes // StorageBin element and attributes
s_oss << indent0; s_oss << indent0;
s_oss << "<mix " << std::endl; s_oss << "<mix " << "\n";
s_oss << indent1; s_oss << indent1;
s_oss << "pitzer_mix_gammas=\"" << this-> s_oss << "pitzer_mix_gammas=\"" << this->
pitzer_mix_gammas << "\"" << std::endl; pitzer_mix_gammas << "\"" << "\n";
// components // components
s_oss << indent1; s_oss << indent1;
s_oss << "<component " << std::endl; s_oss << "<component " << "\n";
for (std::list < cxxStorageBinComp >::const_iterator it = for (std::list < cxxStorageBinComp >::const_iterator it =
mixComps.begin(); it != mixComps.end(); ++it) mixComps.begin(); it != mixComps.end(); ++it)
{ {
@ -505,13 +505,13 @@ cxxStorageBin::dump_raw(std::ostream & s_oss, int n, unsigned int indent, int *n
void void
cxxStorageBin::read_raw(CParser & parser) cxxStorageBin::read_raw(CParser & parser)
{ {
CParser::LINE_TYPE i; PHRQ_io::LINE_TYPE i;
while ((i = while ((i =
parser.check_line("StorageBin read_raw", false, true, true, parser.check_line("StorageBin read_raw", false, true, true,
true)) != CParser::LT_KEYWORD) true)) != PHRQ_io::LT_KEYWORD)
{ {
if (i == CParser::LT_EOF) if (i == PHRQ_io::LT_EOF)
return; // CParser::LT_EOF; return; // PHRQ_io::LT_EOF;
} }
for (;;) for (;;)
@ -624,13 +624,13 @@ cxxStorageBin::read_raw(CParser & parser)
} }
END_OF_SIMULATION_INPUT: END_OF_SIMULATION_INPUT:
return; //CParser::LT_OK; return; //PHRQ_io::LT_OK;
} }
int int
cxxStorageBin::read_raw_keyword(CParser & parser) cxxStorageBin::read_raw_keyword(CParser & parser)
{ {
CParser::LINE_TYPE i; PHRQ_io::LINE_TYPE i;
int entity_number = -999; int entity_number = -999;
switch (parser.next_keyword()) switch (parser.next_keyword())
@ -641,10 +641,10 @@ cxxStorageBin::read_raw_keyword(CParser & parser)
case Keywords::KEY_END: case Keywords::KEY_END:
while ((i = while ((i =
parser.check_line("StorageBin read_raw_keyword", false, true, parser.check_line("StorageBin read_raw_keyword", false, true,
true, true)) != CParser::LT_KEYWORD) true, true)) != PHRQ_io::LT_KEYWORD)
{ {
if (i == CParser::LT_EOF) if (i == PHRQ_io::LT_EOF)
break; // CParser::LT_EOF; break; // PHRQ_io::LT_EOF;
} }
break; break;
/*case CParser::KT_EOF: /*case CParser::KT_EOF:
@ -753,7 +753,7 @@ cxxStorageBin::read_raw_keyword(CParser & parser)
default: default:
break; break;
} }
return (entity_number); //CParser::LT_OK; return (entity_number); //PHRQ_io::LT_OK;
} }
//void //void
@ -1060,7 +1060,7 @@ cxxStorageBin::mpi_send(int n, int task_number)
{ {
ints.push_back(0); ints.push_back(0);
} }
//std::cerr << "Packed Solution" << std::endl; //std::cerr << "Packed Solution" << "\n";
// Exchanger // Exchanger
if (this->getExchange(n) != NULL) if (this->getExchange(n) != NULL)
@ -1072,7 +1072,7 @@ cxxStorageBin::mpi_send(int n, int task_number)
{ {
ints.push_back(0); ints.push_back(0);
} }
//std::cerr << "Packed Exchange" << std::endl; //std::cerr << "Packed Exchange" << "\n";
// GasPhase // GasPhase
if (this->getGasPhase(n) != NULL) if (this->getGasPhase(n) != NULL)
@ -1084,7 +1084,7 @@ cxxStorageBin::mpi_send(int n, int task_number)
{ {
ints.push_back(0); ints.push_back(0);
} }
//std::cerr << "Packed GasPhase" << std::endl; //std::cerr << "Packed GasPhase" << "\n";
// Kinetics // Kinetics
if (this->getKinetics(n) != NULL) if (this->getKinetics(n) != NULL)
@ -1096,7 +1096,7 @@ cxxStorageBin::mpi_send(int n, int task_number)
{ {
ints.push_back(0); ints.push_back(0);
} }
//std::cerr << "Packed Kinetics" << std::endl; //std::cerr << "Packed Kinetics" << "\n";
// PPassemblages // PPassemblages
if (this->getPPassemblage(n) != NULL) if (this->getPPassemblage(n) != NULL)
@ -1108,7 +1108,7 @@ cxxStorageBin::mpi_send(int n, int task_number)
{ {
ints.push_back(0); ints.push_back(0);
} }
//std::cerr << "Packed PPassemblage" << std::endl; //std::cerr << "Packed PPassemblage" << "\n";
// SSassemblages // SSassemblages
if (this->getSSassemblage(n) != NULL) if (this->getSSassemblage(n) != NULL)
@ -1120,7 +1120,7 @@ cxxStorageBin::mpi_send(int n, int task_number)
{ {
ints.push_back(0); ints.push_back(0);
} }
//std::cerr << "Packed SSassemblage" << std::endl; //std::cerr << "Packed SSassemblage" << "\n";
// Surfaces // Surfaces
if (this->getSurface(n) != NULL) if (this->getSurface(n) != NULL)
@ -1132,7 +1132,7 @@ cxxStorageBin::mpi_send(int n, int task_number)
{ {
ints.push_back(0); ints.push_back(0);
} }
//std::cerr << "Packed Surface" << std::endl; //std::cerr << "Packed Surface" << "\n";
// Pack data // Pack data
int max_size = 0; int max_size = 0;
@ -1155,11 +1155,11 @@ cxxStorageBin::mpi_send(int n, int task_number)
/* /*
for (int j = 0; j < i; j++) { for (int j = 0; j < i; j++) {
int_array[j] = ints[j]; int_array[j] = ints[j];
//std::cerr << "Sending ints " << j << " value " << ints[j] << std::endl; //std::cerr << "Sending ints " << j << " value " << ints[j] << "\n";
} }
for (int j = 0; j < d; j++) { for (int j = 0; j < d; j++) {
double_array[j] = doubles[j]; double_array[j] = doubles[j];
//std::cerr << "Sending doubles " << j << " value " << doubles[j] << std::endl; //std::cerr << "Sending doubles " << j << " value " << doubles[j] << "\n";
} }
*/ */
/* /*
@ -1243,7 +1243,7 @@ cxxStorageBin::mpi_recv(int task_number)
entity.mpi_unpack(ints, &i, doubles, &d); entity.mpi_unpack(ints, &i, doubles, &d);
this->setSolution(entity.Get_n_user(), &entity); this->setSolution(entity.Get_n_user(), &entity);
} }
//std::cerr << "Unpacked Solution" << std::endl; //std::cerr << "Unpacked Solution" << "\n";
// Exchanger // Exchanger
if (ints[i++] != 0) if (ints[i++] != 0)
@ -1252,7 +1252,7 @@ cxxStorageBin::mpi_recv(int task_number)
entity.mpi_unpack(ints, &i, doubles, &d); entity.mpi_unpack(ints, &i, doubles, &d);
this->setExchange(entity.Get_n_user(), &entity); this->setExchange(entity.Get_n_user(), &entity);
} }
//std::cerr << "Unpacked Exchange" << std::endl; //std::cerr << "Unpacked Exchange" << "\n";
// GasPhase // GasPhase
if (ints[i++] != 0) if (ints[i++] != 0)
@ -1261,7 +1261,7 @@ cxxStorageBin::mpi_recv(int task_number)
entity.mpi_unpack(ints, &i, doubles, &d); entity.mpi_unpack(ints, &i, doubles, &d);
this->setGasPhase(entity.Get_n_user(), &entity); this->setGasPhase(entity.Get_n_user(), &entity);
} }
//std::cerr << "Unpacked GasPhase" << std::endl; //std::cerr << "Unpacked GasPhase" << "\n";
// Kinetics // Kinetics
if (ints[i++] != 0) if (ints[i++] != 0)
@ -1270,7 +1270,7 @@ cxxStorageBin::mpi_recv(int task_number)
entity.mpi_unpack(ints, &i, doubles, &d); entity.mpi_unpack(ints, &i, doubles, &d);
this->setKinetics(entity.Get_n_user(), &entity); this->setKinetics(entity.Get_n_user(), &entity);
} }
//std::cerr << "Unpacked Kinetics" << std::endl; //std::cerr << "Unpacked Kinetics" << "\n";
// PPassemblage // PPassemblage
if (ints[i++] != 0) if (ints[i++] != 0)
@ -1279,7 +1279,7 @@ cxxStorageBin::mpi_recv(int task_number)
entity.mpi_unpack(ints, &i, doubles, &d); entity.mpi_unpack(ints, &i, doubles, &d);
this->setPPassemblage(entity.Get_n_user(), &entity); this->setPPassemblage(entity.Get_n_user(), &entity);
} }
//std::cerr << "Unpacked PPassemblage" << std::endl; //std::cerr << "Unpacked PPassemblage" << "\n";
// SSassemblage // SSassemblage
if (ints[i++] != 0) if (ints[i++] != 0)
@ -1288,7 +1288,7 @@ cxxStorageBin::mpi_recv(int task_number)
entity.mpi_unpack(ints, &i, doubles, &d); entity.mpi_unpack(ints, &i, doubles, &d);
this->setSSassemblage(entity.Get_n_user(), &entity); this->setSSassemblage(entity.Get_n_user(), &entity);
} }
//std::cerr << "Unpacked SSassemblage" << std::endl; //std::cerr << "Unpacked SSassemblage" << "\n";
// Surfaces // Surfaces
if (ints[i++] != 0) if (ints[i++] != 0)
@ -1297,7 +1297,7 @@ cxxStorageBin::mpi_recv(int task_number)
entity.mpi_unpack(ints, &i, doubles, &d); entity.mpi_unpack(ints, &i, doubles, &d);
this->setSurface(entity.Get_n_user(), &entity); this->setSurface(entity.Get_n_user(), &entity);
} }
//std::cerr << "Unpacked Surface" << std::endl; //std::cerr << "Unpacked Surface" << "\n";
delete[]ints; delete[]ints;
delete[]doubles; delete[]doubles;
@ -1503,10 +1503,10 @@ cxxStorageBin::Set_System(struct Use *use_ptr)
} }
} }
// reaction // reaction
if (use_ptr->irrev_ptr != NULL) if (use_ptr->reaction_ptr != NULL)
{ {
std::map < int, cxxReaction >::iterator it = std::map < int, cxxReaction >::iterator it =
this->Reactions.find(use_ptr->n_irrev_user); this->Reactions.find(use_ptr->n_reaction_user);
if (it != this->Reactions.end()) if (it != this->Reactions.end())
{ {
this->system.Set_Reaction(&(it->second)); this->system.Set_Reaction(&(it->second));

View File

@ -17,9 +17,9 @@ StorageBinListItem::StorageBinListItem(CParser & parser)
for (;;) for (;;)
{ {
//read lines //read lines
CParser::LINE_TYPE l = parser.check_line("read StorageBinListLtem", false, true, true, true); PHRQ_io::LINE_TYPE l = parser.check_line("read StorageBinListLtem", false, true, true, true);
std::istream::pos_type next_char = 0; std::istream::pos_type next_char = 0;
if (l == CParser::LT_EOF) break; if (l == PHRQ_io::LT_EOF) break;
for (;;) for (;;)
{ {
std::string token; std::string token;
@ -36,7 +36,7 @@ StorageBinListItem::StorageBinListItem(CParser & parser)
{ {
// ignore characters like RUN // ignore characters like RUN
//parser.error_msg("Expected single number or range of numbers.", //parser.error_msg("Expected single number or range of numbers.",
// CParser::OT_CONTINUE); // PHRQ_io::OT_CONTINUE);
//break; //break;
} }
} }
@ -259,7 +259,7 @@ bool StorageBinList::Read(CParser & parser)
else else
{ {
parser.error_msg("Expected single number or range of numbers.", parser.error_msg("Expected single number or range of numbers.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
break; break;
} }
} }
@ -302,8 +302,8 @@ bool StorageBinList::Read(CParser & parser)
case CParser::OPT_ERROR: case CParser::OPT_ERROR:
opt = CParser::OPT_EOF; opt = CParser::OPT_EOF;
parser.error_msg("Unknown input reading DELETE definition.", parser.error_msg("Unknown input reading DELETE definition.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
parser.error_msg(parser.line().c_str(), CParser::OT_CONTINUE); parser.error_msg(parser.line().c_str(), PHRQ_io::OT_CONTINUE);
useLastLine = false; useLastLine = false;
return_value = false; return_value = false;
break; break;

View File

@ -154,44 +154,44 @@ cxxSurface::dump_xml(std::ostream & s_oss, unsigned int indent) const
// Surface element and attributes // Surface element and attributes
s_oss << indent0; s_oss << indent0;
s_oss << "<surface " << std::endl; s_oss << "<surface " << "\n";
s_oss << indent1; s_oss << indent1;
//s_oss << "diffuse_layer=\"" << this->diffuse_layer << "\"" << std::endl; //s_oss << "diffuse_layer=\"" << this->diffuse_layer << "\"" << "\n";
s_oss << "surface_type=\"" << this->type << "\"" << std::endl; s_oss << "surface_type=\"" << this->type << "\"" << "\n";
s_oss << indent1; s_oss << indent1;
//s_oss << "edl=\"" << this->edl << "\"" << std::endl; //s_oss << "edl=\"" << this->edl << "\"" << "\n";
s_oss << "dl_type=\"" << this->dl_type << "\"" << std::endl; s_oss << "dl_type=\"" << this->dl_type << "\"" << "\n";
s_oss << indent1; s_oss << indent1;
s_oss << "sites_units=\"" << this->sites_units << "\"" << std::endl; s_oss << "sites_units=\"" << this->sites_units << "\"" << "\n";
s_oss << indent1; s_oss << indent1;
s_oss << "only_counter_ions=\"" << this-> s_oss << "only_counter_ions=\"" << this->
only_counter_ions << "\"" << std::endl; only_counter_ions << "\"" << "\n";
//s_oss << indent1; //s_oss << indent1;
//s_oss << "donnan=\"" << this->donnan << "\"" << std::endl; //s_oss << "donnan=\"" << this->donnan << "\"" << "\n";
s_oss << indent1; s_oss << indent1;
s_oss << "thickness=\"" << this->thickness << "\"" << std::endl; s_oss << "thickness=\"" << this->thickness << "\"" << "\n";
s_oss << indent1; s_oss << indent1;
s_oss << "debye_lengths=\"" << this->debye_lengths << "\"" << std::endl; s_oss << "debye_lengths=\"" << this->debye_lengths << "\"" << "\n";
s_oss << indent1; s_oss << indent1;
s_oss << "DDL_viscosity=\"" << this->DDL_viscosity << "\"" << std::endl; s_oss << "DDL_viscosity=\"" << this->DDL_viscosity << "\"" << "\n";
s_oss << indent1; s_oss << indent1;
s_oss << "DDL_limit=\"" << this->DDL_limit << "\"" << std::endl; s_oss << "DDL_limit=\"" << this->DDL_limit << "\"" << "\n";
s_oss << indent1; s_oss << indent1;
s_oss << "transport=\"" << this->transport << "\"" << std::endl; s_oss << "transport=\"" << this->transport << "\"" << "\n";
// surface component structures // surface component structures
s_oss << indent1; s_oss << indent1;
s_oss << "<component " << std::endl; s_oss << "<component " << "\n";
{ {
for (std::map < std::string, cxxSurfaceComp >::const_iterator it = for (std::map < std::string, cxxSurfaceComp >::const_iterator it =
this->surfaceComps.begin(); it != this->surfaceComps.end(); ++it) this->surfaceComps.begin(); it != this->surfaceComps.end(); ++it)
@ -201,7 +201,7 @@ cxxSurface::dump_xml(std::ostream & s_oss, unsigned int indent) const
} }
// surface charge structures // surface charge structures
s_oss << indent1; s_oss << indent1;
s_oss << "<charge_component " << std::endl; s_oss << "<charge_component " << "\n";
for (std::map < std::string, cxxSurfaceCharge >::const_iterator it = for (std::map < std::string, cxxSurfaceCharge >::const_iterator it =
surfaceCharges.begin(); it != surfaceCharges.end(); ++it) surfaceCharges.begin(); it != surfaceCharges.end(); ++it)
{ {
@ -228,46 +228,46 @@ cxxSurface::dump_raw(std::ostream & s_oss, unsigned int indent, int *n_out) cons
// Surface element and attributes // Surface element and attributes
s_oss << indent0; s_oss << indent0;
int n_user_local = (n_out != NULL) ? *n_out : this->n_user; int n_user_local = (n_out != NULL) ? *n_out : this->n_user;
s_oss << "SURFACE_RAW " << n_user_local << " " << this->description << std::endl; s_oss << "SURFACE_RAW " << n_user_local << " " << this->description << "\n";
s_oss << indent1; s_oss << indent1;
//s_oss << "-diffuse_layer " << this->diffuse_layer << std::endl; //s_oss << "-diffuse_layer " << this->diffuse_layer << "\n";
s_oss << "-type " << this->type << std::endl; s_oss << "-type " << this->type << "\n";
s_oss << indent1; s_oss << indent1;
//s_oss << "-edl " << this->edl << std::endl; //s_oss << "-edl " << this->edl << "\n";
s_oss << "-dl_type " << this->dl_type << std::endl; s_oss << "-dl_type " << this->dl_type << "\n";
s_oss << indent1; s_oss << indent1;
s_oss << "-sites_units " << this->sites_units << std::endl; s_oss << "-sites_units " << this->sites_units << "\n";
s_oss << indent1; s_oss << indent1;
s_oss << "-only_counter_ions " << this->only_counter_ions << std::endl; s_oss << "-only_counter_ions " << this->only_counter_ions << "\n";
//s_oss << indent1; //s_oss << indent1;
//s_oss << "-donnan " << this->donnan << std::endl; //s_oss << "-donnan " << this->donnan << "\n";
s_oss << indent1; s_oss << indent1;
s_oss << "-thickness " << this->thickness << std::endl; s_oss << "-thickness " << this->thickness << "\n";
s_oss << indent1; s_oss << indent1;
s_oss << "-debye_lengths " << this->debye_lengths << std::endl; s_oss << "-debye_lengths " << this->debye_lengths << "\n";
s_oss << indent1; s_oss << indent1;
s_oss << "-DDL_viscosity " << this->DDL_viscosity << std::endl; s_oss << "-DDL_viscosity " << this->DDL_viscosity << "\n";
s_oss << indent1; s_oss << indent1;
s_oss << "-DDL_limit " << this->DDL_limit << std::endl; s_oss << "-DDL_limit " << this->DDL_limit << "\n";
s_oss << indent1; s_oss << indent1;
s_oss << "-transport " << this->transport << std::endl; s_oss << "-transport " << this->transport << "\n";
// surfaceComps structures // surfaceComps structures
for (std::map < std::string, cxxSurfaceComp >::const_iterator it = for (std::map < std::string, cxxSurfaceComp >::const_iterator it =
surfaceComps.begin(); it != surfaceComps.end(); ++it) surfaceComps.begin(); it != surfaceComps.end(); ++it)
{ {
s_oss << indent1; s_oss << indent1;
s_oss << "-component" << std::endl; s_oss << "-component" << "\n";
(*it).second.dump_raw(s_oss, indent + 2); (*it).second.dump_raw(s_oss, indent + 2);
} }
// surface charge structures // surface charge structures
@ -276,7 +276,7 @@ cxxSurface::dump_raw(std::ostream & s_oss, unsigned int indent, int *n_out) cons
surfaceCharges.begin(); it != surfaceCharges.end(); ++it) surfaceCharges.begin(); it != surfaceCharges.end(); ++it)
{ {
s_oss << indent1; s_oss << indent1;
s_oss << "-charge_component " << std::endl; s_oss << "-charge_component " << "\n";
(*it).second.dump_raw(s_oss, indent + 2); (*it).second.dump_raw(s_oss, indent + 2);
} }
} }
@ -352,21 +352,21 @@ cxxSurface::read_raw(CParser & parser, bool check)
case CParser::OPT_ERROR: case CParser::OPT_ERROR:
opt = CParser::OPT_EOF; opt = CParser::OPT_EOF;
parser.error_msg("Unknown input in SURFACE keyword.", parser.error_msg("Unknown input in SURFACE keyword.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
parser.error_msg(parser.line().c_str(), CParser::OT_CONTINUE); parser.error_msg(parser.line().c_str(), PHRQ_io::OT_CONTINUE);
useLastLine = false; useLastLine = false;
break; break;
case 0: // diffuse_layer case 0: // diffuse_layer
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Diffuse layer is obsolete, use -type.", parser.error_msg("Diffuse layer is obsolete, use -type.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
/* /*
if (!(parser.get_iss() >> this->diffuse_layer)) if (!(parser.get_iss() >> this->diffuse_layer))
{ {
this->diffuse_layer = false; this->diffuse_layer = false;
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Expected boolean value for diffuse_layer.", CParser::OT_CONTINUE); parser.error_msg("Expected boolean value for diffuse_layer.", PHRQ_io::OT_CONTINUE);
} }
diffuse_layer_defined = true; diffuse_layer_defined = true;
*/ */
@ -376,13 +376,13 @@ cxxSurface::read_raw(CParser & parser, bool check)
case 1: // edl case 1: // edl
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("-edl is obsolete, use -type.", parser.error_msg("-edl is obsolete, use -type.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
/* /*
if (!(parser.get_iss() >> this->edl)) if (!(parser.get_iss() >> this->edl))
{ {
this->edl = false; this->edl = false;
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Expected boolean value for edl.", CParser::OT_CONTINUE); parser.error_msg("Expected boolean value for edl.", PHRQ_io::OT_CONTINUE);
} }
edl_defined = true; edl_defined = true;
*/ */
@ -396,7 +396,7 @@ cxxSurface::read_raw(CParser & parser, bool check)
parser.incr_input_error(); parser.incr_input_error();
parser. parser.
error_msg("Expected boolean value for only_counter_ions.", error_msg("Expected boolean value for only_counter_ions.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
only_counter_ions_defined = true; only_counter_ions_defined = true;
useLastLine = false; useLastLine = false;
@ -405,13 +405,13 @@ cxxSurface::read_raw(CParser & parser, bool check)
case 3: // donnan case 3: // donnan
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("-Donnan is obsolete, use -dl_type.", parser.error_msg("-Donnan is obsolete, use -dl_type.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
/* /*
if (!(parser.get_iss() >> this->donnan)) if (!(parser.get_iss() >> this->donnan))
{ {
this->donnan = false; this->donnan = false;
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Expected boolean value for donnan.", CParser::OT_CONTINUE); parser.error_msg("Expected boolean value for donnan.", PHRQ_io::OT_CONTINUE);
} }
donnan_defined = true; donnan_defined = true;
*/ */
@ -424,7 +424,7 @@ cxxSurface::read_raw(CParser & parser, bool check)
this->thickness = 0.0; this->thickness = 0.0;
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Expected numeric value for thickness.", parser.error_msg("Expected numeric value for thickness.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
thickness_defined = true; thickness_defined = true;
useLastLine = false; useLastLine = false;
@ -492,7 +492,7 @@ cxxSurface::read_raw(CParser & parser, bool check)
this->type = NO_EDL; this->type = NO_EDL;
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Expected numeric value for type.", parser.error_msg("Expected numeric value for type.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
this->type = (SURFACE_TYPE) i; this->type = (SURFACE_TYPE) i;
type_defined = true; type_defined = true;
@ -505,7 +505,7 @@ cxxSurface::read_raw(CParser & parser, bool check)
this->dl_type = NO_DL; this->dl_type = NO_DL;
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Expected numeric value for dl_type.", parser.error_msg("Expected numeric value for dl_type.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
this->dl_type = (DIFFUSE_LAYER_TYPE) i; this->dl_type = (DIFFUSE_LAYER_TYPE) i;
dl_type_defined = true; dl_type_defined = true;
@ -518,7 +518,7 @@ cxxSurface::read_raw(CParser & parser, bool check)
this->sites_units = SITES_ABSOLUTE; this->sites_units = SITES_ABSOLUTE;
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Expected numeric value for sites_units.", parser.error_msg("Expected numeric value for sites_units.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
this->sites_units = (SITES_UNITS) i; this->sites_units = (SITES_UNITS) i;
sites_units_defined = true; sites_units_defined = true;
@ -531,7 +531,7 @@ cxxSurface::read_raw(CParser & parser, bool check)
this->debye_lengths = 0.0; this->debye_lengths = 0.0;
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Expected numeric value for debye_lengths.", parser.error_msg("Expected numeric value for debye_lengths.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
debye_lengths_defined = true; debye_lengths_defined = true;
useLastLine = false; useLastLine = false;
@ -543,7 +543,7 @@ cxxSurface::read_raw(CParser & parser, bool check)
this->DDL_viscosity = 0.0; this->DDL_viscosity = 0.0;
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Expected numeric value for DDL_viscosity.", parser.error_msg("Expected numeric value for DDL_viscosity.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
DDL_viscosity_defined = true; DDL_viscosity_defined = true;
useLastLine = false; useLastLine = false;
@ -555,7 +555,7 @@ cxxSurface::read_raw(CParser & parser, bool check)
this->DDL_limit = 0.0; this->DDL_limit = 0.0;
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Expected numeric value for DDL_limit.", parser.error_msg("Expected numeric value for DDL_limit.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
DDL_limit_defined = true; DDL_limit_defined = true;
useLastLine = false; useLastLine = false;
@ -567,7 +567,7 @@ cxxSurface::read_raw(CParser & parser, bool check)
this->transport = false; this->transport = false;
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Expected boolean value for transport.", parser.error_msg("Expected boolean value for transport.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
transport_defined = true; transport_defined = true;
useLastLine = false; useLastLine = false;
@ -583,11 +583,11 @@ cxxSurface::read_raw(CParser & parser, bool check)
/* /*
if (diffuse_layer_defined == false) { if (diffuse_layer_defined == false) {
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Diffuse_layer not defined for SURFACE_RAW input.", CParser::OT_CONTINUE); parser.error_msg("Diffuse_layer not defined for SURFACE_RAW input.", PHRQ_io::OT_CONTINUE);
} }
if (edl_defined == false) { if (edl_defined == false) {
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Edl not defined for SURFACE_RAW input.", CParser::OT_CONTINUE); parser.error_msg("Edl not defined for SURFACE_RAW input.", PHRQ_io::OT_CONTINUE);
} }
*/ */
if (only_counter_ions_defined == false) if (only_counter_ions_defined == false)
@ -595,61 +595,61 @@ cxxSurface::read_raw(CParser & parser, bool check)
parser.incr_input_error(); parser.incr_input_error();
parser. parser.
error_msg("Only_counter_ions not defined for SURFACE_RAW input.", error_msg("Only_counter_ions not defined for SURFACE_RAW input.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
/* /*
if (donnan_defined == false) { if (donnan_defined == false) {
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Donnan not defined for SURFACE_RAW input.", CParser::OT_CONTINUE); parser.error_msg("Donnan not defined for SURFACE_RAW input.", PHRQ_io::OT_CONTINUE);
} }
*/ */
if (thickness_defined == false) if (thickness_defined == false)
{ {
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Thickness not defined for SURFACE_RAW input.", parser.error_msg("Thickness not defined for SURFACE_RAW input.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
if (type_defined == false) if (type_defined == false)
{ {
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Surface type not defined for SURFACE_RAW input.", parser.error_msg("Surface type not defined for SURFACE_RAW input.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
if (dl_type_defined == false) if (dl_type_defined == false)
{ {
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Dl_type not defined for SURFACE_RAW input.", parser.error_msg("Dl_type not defined for SURFACE_RAW input.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
if (sites_units_defined == false) if (sites_units_defined == false)
{ {
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Sites_units not defined for SURFACE_RAW input.", parser.error_msg("Sites_units not defined for SURFACE_RAW input.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
if (debye_lengths_defined == false) if (debye_lengths_defined == false)
{ {
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Debye_lengths not defined for SURFACE_RAW input.", parser.error_msg("Debye_lengths not defined for SURFACE_RAW input.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
if (DDL_viscosity_defined == false) if (DDL_viscosity_defined == false)
{ {
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("DDL_viscosity not defined for SURFACE_RAW input.", parser.error_msg("DDL_viscosity not defined for SURFACE_RAW input.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
if (DDL_limit_defined == false) if (DDL_limit_defined == false)
{ {
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("DDL_limit not defined for SURFACE_RAW input.", parser.error_msg("DDL_limit not defined for SURFACE_RAW input.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
if (transport_defined == false) if (transport_defined == false)
{ {
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Transport not defined for SURFACE_RAW input.", parser.error_msg("Transport not defined for SURFACE_RAW input.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
} }
} }

View File

@ -73,7 +73,7 @@ cxxSurfaceCharge::~cxxSurfaceCharge()
// { // {
// std::ostringstream error_oss; // std::ostringstream error_oss;
// error_oss << "Surface charge psi_master not found." << this-> // error_oss << "Surface charge psi_master not found." << this->
// name << std::endl; // name << "\n";
// //Utilities::error_msg(error_oss.str(), CONTINUE); // //Utilities::error_msg(error_oss.str(), CONTINUE);
// error_msg(error_oss.str().c_str(), CONTINUE); // error_msg(error_oss.str().c_str(), CONTINUE);
// } // }
@ -96,23 +96,23 @@ cxxSurfaceCharge::dump_xml(std::ostream & s_oss, unsigned int indent) const
// Surf_Charge element and attributes // Surf_Charge element and attributes
s_oss << indent0 << "name=\"" << this->name << "\"" << std::endl; s_oss << indent0 << "name=\"" << this->name << "\"" << "\n";
s_oss << indent0 << "specific_area=\"" << this-> s_oss << indent0 << "specific_area=\"" << this->
specific_area << "\"" << std::endl; specific_area << "\"" << "\n";
s_oss << indent0 << "grams=\"" << this->grams << "\"" << std::endl; s_oss << indent0 << "grams=\"" << this->grams << "\"" << "\n";
s_oss << indent0 << "charge_balance=\"" << this-> s_oss << indent0 << "charge_balance=\"" << this->
charge_balance << "\"" << std::endl; charge_balance << "\"" << "\n";
s_oss << indent0 << "mass_water=\"" << this-> s_oss << indent0 << "mass_water=\"" << this->
mass_water << "\"" << std::endl; mass_water << "\"" << "\n";
s_oss << indent0 << "la_psi=\"" << this->la_psi << "\"" << std::endl; s_oss << indent0 << "la_psi=\"" << this->la_psi << "\"" << "\n";
s_oss << indent0 << "la_psi1=\"" << this->la_psi1 << "\"" << std::endl; s_oss << indent0 << "la_psi1=\"" << this->la_psi1 << "\"" << "\n";
s_oss << indent0 << "la_psi2=\"" << this->la_psi2 << "\"" << std::endl; s_oss << indent0 << "la_psi2=\"" << this->la_psi2 << "\"" << "\n";
s_oss << indent0 << "capacitance=\"" << this-> s_oss << indent0 << "capacitance=\"" << this->
capacitance[0] << " " << this->capacitance[0] << "\"" << std::endl; capacitance[0] << " " << this->capacitance[0] << "\"" << "\n";
// totals // totals
s_oss << indent0; s_oss << indent0;
s_oss << "<diffuse_layer_totals " << std::endl; s_oss << "<diffuse_layer_totals " << "\n";
this->diffuse_layer_totals.dump_xml(s_oss, indent + 1); this->diffuse_layer_totals.dump_xml(s_oss, indent + 1);
} }
@ -133,28 +133,28 @@ cxxSurfaceCharge::dump_raw(std::ostream & s_oss, unsigned int indent) const
// Surf_Charge element and attributes // Surf_Charge element and attributes
s_oss << indent0 << "-name " << this->name << std::endl; s_oss << indent0 << "-name " << this->name << "\n";
s_oss << indent1 << "-specific_area " << this-> s_oss << indent1 << "-specific_area " << this->
specific_area << std::endl; specific_area << "\n";
s_oss << indent1 << "-grams " << this->grams << std::endl; s_oss << indent1 << "-grams " << this->grams << "\n";
s_oss << indent1 << "-charge_balance " << this-> s_oss << indent1 << "-charge_balance " << this->
charge_balance << std::endl; charge_balance << "\n";
s_oss << indent1 << "-mass_water " << this-> s_oss << indent1 << "-mass_water " << this->
mass_water << std::endl; mass_water << "\n";
s_oss << indent1 << "-la_psi " << this-> s_oss << indent1 << "-la_psi " << this->
la_psi << std::endl; la_psi << "\n";
s_oss << indent1 << "-la_psi1 " << this-> s_oss << indent1 << "-la_psi1 " << this->
la_psi1 << std::endl; la_psi1 << "\n";
s_oss << indent1 << "-la_psi2 " << this-> s_oss << indent1 << "-la_psi2 " << this->
la_psi2 << std::endl; la_psi2 << "\n";
s_oss << indent1 << "-capacitance0 " << this-> s_oss << indent1 << "-capacitance0 " << this->
capacitance[0] << std::endl; capacitance[0] << "\n";
s_oss << indent1 << "-capacitance1 " << this-> s_oss << indent1 << "-capacitance1 " << this->
capacitance[1] << std::endl; capacitance[1] << "\n";
// totals // totals
s_oss << indent1; s_oss << indent1;
s_oss << "-diffuse_layer_totals" << std::endl; s_oss << "-diffuse_layer_totals" << "\n";
this->diffuse_layer_totals.dump_raw(s_oss, indent + 2); this->diffuse_layer_totals.dump_raw(s_oss, indent + 2);
} }
@ -216,8 +216,8 @@ cxxSurfaceCharge::read_raw(CParser & parser, bool check)
case CParser::OPT_ERROR: case CParser::OPT_ERROR:
opt = CParser::OPT_KEYWORD; opt = CParser::OPT_KEYWORD;
// Allow return to Surface for more processing // Allow return to Surface for more processing
//parser.error_msg("Unknown input in SURF_CHARGE read.", CParser::OT_CONTINUE); //parser.error_msg("Unknown input in SURF_CHARGE read.", PHRQ_io::OT_CONTINUE);
//parser.error_msg(parser.line().c_str(), CParser::OT_CONTINUE); //parser.error_msg(parser.line().c_str(), PHRQ_io::OT_CONTINUE);
break; break;
case 0: // name case 0: // name
@ -226,7 +226,7 @@ cxxSurfaceCharge::read_raw(CParser & parser, bool check)
this->name.clear(); this->name.clear();
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Expected string value for name.", parser.error_msg("Expected string value for name.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
else else
{ {
@ -241,7 +241,7 @@ cxxSurfaceCharge::read_raw(CParser & parser, bool check)
this->specific_area = 0; this->specific_area = 0;
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Expected numeric value for specific_area.", parser.error_msg("Expected numeric value for specific_area.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
specific_area_defined = true; specific_area_defined = true;
break; break;
@ -252,7 +252,7 @@ cxxSurfaceCharge::read_raw(CParser & parser, bool check)
this->grams = 0; this->grams = 0;
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Expected numeric value for grams.", parser.error_msg("Expected numeric value for grams.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
grams_defined = true; grams_defined = true;
break; break;
@ -264,7 +264,7 @@ cxxSurfaceCharge::read_raw(CParser & parser, bool check)
this->charge_balance = 0; this->charge_balance = 0;
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Expected numeric value for charge_balance.", parser.error_msg("Expected numeric value for charge_balance.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
charge_balance_defined = true; charge_balance_defined = true;
break; break;
@ -275,7 +275,7 @@ cxxSurfaceCharge::read_raw(CParser & parser, bool check)
this->mass_water = 0; this->mass_water = 0;
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Expected numeric value for mass_water.", parser.error_msg("Expected numeric value for mass_water.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
mass_water_defined = true; mass_water_defined = true;
break; break;
@ -287,7 +287,7 @@ cxxSurfaceCharge::read_raw(CParser & parser, bool check)
this->la_psi = 0; this->la_psi = 0;
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Expected numeric value for la_psi.", parser.error_msg("Expected numeric value for la_psi.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
la_psi_defined = true; la_psi_defined = true;
break; break;
@ -301,7 +301,7 @@ cxxSurfaceCharge::read_raw(CParser & parser, bool check)
parser. parser.
error_msg error_msg
("Expected element name and molality for SurfaceCharge diffuse_layer_totals.", ("Expected element name and molality for SurfaceCharge diffuse_layer_totals.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
opt_save = 6; opt_save = 6;
break; break;
@ -312,7 +312,7 @@ cxxSurfaceCharge::read_raw(CParser & parser, bool check)
this->la_psi1 = 0; this->la_psi1 = 0;
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Expected numeric value for la_psi1.", parser.error_msg("Expected numeric value for la_psi1.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
la_psi1_defined = true; la_psi1_defined = true;
break; break;
@ -323,7 +323,7 @@ cxxSurfaceCharge::read_raw(CParser & parser, bool check)
this->la_psi2 = 0; this->la_psi2 = 0;
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Expected numeric value for la_psi.", parser.error_msg("Expected numeric value for la_psi.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
la_psi2_defined = true; la_psi2_defined = true;
break; break;
@ -334,7 +334,7 @@ cxxSurfaceCharge::read_raw(CParser & parser, bool check)
this->capacitance[0] = 0; this->capacitance[0] = 0;
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Expected numeric value for capacitance0.", parser.error_msg("Expected numeric value for capacitance0.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
capacitance0_defined = true; capacitance0_defined = true;
break; break;
@ -345,7 +345,7 @@ cxxSurfaceCharge::read_raw(CParser & parser, bool check)
this->capacitance[1] = 0; this->capacitance[1] = 0;
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Expected numeric value for capacitance1.", parser.error_msg("Expected numeric value for capacitance1.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
capacitance1_defined = true; capacitance1_defined = true;
break; break;
@ -361,62 +361,62 @@ cxxSurfaceCharge::read_raw(CParser & parser, bool check)
{ {
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Name not defined for SurfaceCharge input.", parser.error_msg("Name not defined for SurfaceCharge input.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
if (specific_area_defined == false) if (specific_area_defined == false)
{ {
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Specific_area not defined for SurfaceCharge input.", parser.error_msg("Specific_area not defined for SurfaceCharge input.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
if (grams_defined == false) if (grams_defined == false)
{ {
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Grams not defined for SurfaceCharge input.", parser.error_msg("Grams not defined for SurfaceCharge input.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
if (charge_balance_defined == false) if (charge_balance_defined == false)
{ {
parser.incr_input_error(); parser.incr_input_error();
parser. parser.
error_msg("Charge_balance not defined for SurfaceCharge input.", error_msg("Charge_balance not defined for SurfaceCharge input.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
if (mass_water_defined == false) if (mass_water_defined == false)
{ {
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Mass_water not defined for SurfaceCharge input.", parser.error_msg("Mass_water not defined for SurfaceCharge input.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
if (la_psi_defined == false) if (la_psi_defined == false)
{ {
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("La_psi not defined for SurfaceCharge input.", parser.error_msg("La_psi not defined for SurfaceCharge input.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
if (la_psi1_defined == false) if (la_psi1_defined == false)
{ {
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("La_psi1 not defined for SurfaceCharge input.", parser.error_msg("La_psi1 not defined for SurfaceCharge input.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
if (la_psi2_defined == false) if (la_psi2_defined == false)
{ {
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("La_psi2 not defined for SurfaceCharge input.", parser.error_msg("La_psi2 not defined for SurfaceCharge input.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
if (capacitance0_defined == false) if (capacitance0_defined == false)
{ {
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Capacitance0 not defined for SurfaceCharge input.", parser.error_msg("Capacitance0 not defined for SurfaceCharge input.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
if (capacitance1_defined == false) if (capacitance1_defined == false)
{ {
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Capacitance1 not defined for SurfaceCharge input.", parser.error_msg("Capacitance1 not defined for SurfaceCharge input.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
} }
} }

View File

@ -77,36 +77,36 @@ cxxSurfaceComp::dump_xml(std::ostream & s_oss, unsigned int indent) const
// Surf_Comp element and attributes // Surf_Comp element and attributes
s_oss << indent0 << "formula=\"" << this->formula << "\"" << std::endl; s_oss << indent0 << "formula=\"" << this->formula << "\"" << "\n";
s_oss << indent0 << "formula_z=\"" << this-> s_oss << indent0 << "formula_z=\"" << this->
formula_z << "\"" << std::endl; formula_z << "\"" << "\n";
s_oss << indent0 << "moles=\"" << this->moles << "\"" << std::endl; s_oss << indent0 << "moles=\"" << this->moles << "\"" << "\n";
s_oss << indent0 << "la=\"" << this->la << "\"" << std::endl; s_oss << indent0 << "la=\"" << this->la << "\"" << "\n";
//s_oss << indent0 << "charge_number=\"" << this->charge_number << "\"" << std::endl; //s_oss << indent0 << "charge_number=\"" << this->charge_number << "\"" << "\n";
s_oss << indent0 << "charge_balance=\"" << this-> s_oss << indent0 << "charge_balance=\"" << this->
charge_balance << "\"" << std::endl; charge_balance << "\"" << "\n";
if (this->phase_name.size() != 0) if (this->phase_name.size() != 0)
{ {
s_oss << indent0 << "phase_name=\"" << this-> s_oss << indent0 << "phase_name=\"" << this->
phase_name << "\"" << std::endl; phase_name << "\"" << "\n";
} }
if (this->rate_name.size() != 0) if (this->rate_name.size() != 0)
{ {
s_oss << indent0 << "rate_name=\"" << this-> s_oss << indent0 << "rate_name=\"" << this->
rate_name << "\"" << std::endl; rate_name << "\"" << "\n";
} }
s_oss << indent0 << "phase_proportion=\"" << this-> s_oss << indent0 << "phase_proportion=\"" << this->
phase_proportion << "\"" << std::endl; phase_proportion << "\"" << "\n";
s_oss << indent0 << "Dw=\"" << this->Dw << "\"" << std::endl; s_oss << indent0 << "Dw=\"" << this->Dw << "\"" << "\n";
// formula_totals // formula_totals
s_oss << indent0; s_oss << indent0;
s_oss << "<formula_totals " << std::endl; s_oss << "<formula_totals " << "\n";
this->formula_totals.dump_xml(s_oss, indent + 1); this->formula_totals.dump_xml(s_oss, indent + 1);
// totals // totals
s_oss << indent0; s_oss << indent0;
s_oss << "<totals " << std::endl; s_oss << "<totals " << "\n";
this->totals.dump_xml(s_oss, indent + 1); this->totals.dump_xml(s_oss, indent + 1);
} }
@ -128,36 +128,36 @@ cxxSurfaceComp::dump_raw(std::ostream & s_oss, unsigned int indent) const
// Surf_Comp element and attributes // Surf_Comp element and attributes
s_oss << indent0 << "-formula " << this-> s_oss << indent0 << "-formula " << this->
formula << std::endl; formula << "\n";
s_oss << indent1 << "-formula_z " << this-> s_oss << indent1 << "-formula_z " << this->
formula_z << std::endl; formula_z << "\n";
s_oss << indent1 << "-moles " << this->moles << std::endl; s_oss << indent1 << "-moles " << this->moles << "\n";
s_oss << indent1 << "-la " << this->la << std::endl; s_oss << indent1 << "-la " << this->la << "\n";
//s_oss << indent1 << "-charge_number " << this->charge_number << std::endl; //s_oss << indent1 << "-charge_number " << this->charge_number << "\n";
s_oss << indent1 << "-charge_balance " << this-> s_oss << indent1 << "-charge_balance " << this->
charge_balance << std::endl; charge_balance << "\n";
if (this->phase_name.size() != 0) if (this->phase_name.size() != 0)
{ {
s_oss << indent1 << "-phase_name " << this-> s_oss << indent1 << "-phase_name " << this->
phase_name << std::endl; phase_name << "\n";
} }
if (this->rate_name.size() != 0) if (this->rate_name.size() != 0)
{ {
s_oss << indent1 << "-rate_name " << this-> s_oss << indent1 << "-rate_name " << this->
rate_name << std::endl; rate_name << "\n";
} }
s_oss << indent1 << "-phase_proportion " << this-> s_oss << indent1 << "-phase_proportion " << this->
phase_proportion << std::endl; phase_proportion << "\n";
s_oss << indent1 << "-Dw " << this->Dw << std::endl; s_oss << indent1 << "-Dw " << this->Dw << "\n";
// formula_totals // formula_totals
s_oss << indent1; s_oss << indent1;
s_oss << "-formula_totals" << std::endl; s_oss << "-formula_totals" << "\n";
this->formula_totals.dump_raw(s_oss, indent + 2); this->formula_totals.dump_raw(s_oss, indent + 2);
// totals // totals
s_oss << indent1; s_oss << indent1;
s_oss << "-totals" << std::endl; s_oss << "-totals" << "\n";
this->totals.dump_raw(s_oss, indent + 2); this->totals.dump_raw(s_oss, indent + 2);
} }
@ -217,8 +217,8 @@ cxxSurfaceComp::read_raw(CParser & parser, bool check)
case CParser::OPT_ERROR: case CParser::OPT_ERROR:
opt = CParser::OPT_KEYWORD; opt = CParser::OPT_KEYWORD;
// Allow return to Surface for more processing // Allow return to Surface for more processing
//parser.error_msg("Unknown input in SURF_COMP read.", CParser::OT_CONTINUE); //parser.error_msg("Unknown input in SURF_COMP read.", PHRQ_io::OT_CONTINUE);
//parser.error_msg(parser.line().c_str(), CParser::OT_CONTINUE); //parser.error_msg(parser.line().c_str(), PHRQ_io::OT_CONTINUE);
break; break;
case 0: // formula case 0: // formula
@ -227,7 +227,7 @@ cxxSurfaceComp::read_raw(CParser & parser, bool check)
this->formula.clear(); this->formula.clear();
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Expected string value for formula.", parser.error_msg("Expected string value for formula.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
else else
{ {
@ -242,7 +242,7 @@ cxxSurfaceComp::read_raw(CParser & parser, bool check)
this->moles = 0; this->moles = 0;
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Expected numeric value for moles.", parser.error_msg("Expected numeric value for moles.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
moles_defined = true; moles_defined = true;
break; break;
@ -253,7 +253,7 @@ cxxSurfaceComp::read_raw(CParser & parser, bool check)
this->la = 0; this->la = 0;
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Expected numeric value for la.", parser.error_msg("Expected numeric value for la.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
la_defined = true; la_defined = true;
break; break;
@ -264,7 +264,7 @@ cxxSurfaceComp::read_raw(CParser & parser, bool check)
this->charge_number = 0; this->charge_number = 0;
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Expected integer value for charge_number.", parser.error_msg("Expected integer value for charge_number.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
charge_number_defined = true; charge_number_defined = true;
break; break;
@ -275,7 +275,7 @@ cxxSurfaceComp::read_raw(CParser & parser, bool check)
this->charge_balance = 0; this->charge_balance = 0;
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Expected numeric value for charge_balance.", parser.error_msg("Expected numeric value for charge_balance.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
charge_balance_defined = true; charge_balance_defined = true;
break; break;
@ -286,7 +286,7 @@ cxxSurfaceComp::read_raw(CParser & parser, bool check)
this->phase_name.clear(); this->phase_name.clear();
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Expected string value for phase_name.", parser.error_msg("Expected string value for phase_name.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
else else
{ {
@ -300,7 +300,7 @@ cxxSurfaceComp::read_raw(CParser & parser, bool check)
this->rate_name.clear(); this->rate_name.clear();
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Expected string value for rate_name.", parser.error_msg("Expected string value for rate_name.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
else else
{ {
@ -315,7 +315,7 @@ cxxSurfaceComp::read_raw(CParser & parser, bool check)
parser.incr_input_error(); parser.incr_input_error();
parser. parser.
error_msg("Expected numeric value for phase_proportion.", error_msg("Expected numeric value for phase_proportion.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
break; break;
@ -327,7 +327,7 @@ cxxSurfaceComp::read_raw(CParser & parser, bool check)
parser. parser.
error_msg error_msg
("Expected element name and molality for SurfaceComp totals.", ("Expected element name and molality for SurfaceComp totals.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
opt_save = 8; opt_save = 8;
break; break;
@ -338,7 +338,7 @@ cxxSurfaceComp::read_raw(CParser & parser, bool check)
this->formula_z = 0; this->formula_z = 0;
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Expected numeric value for formula_z.", parser.error_msg("Expected numeric value for formula_z.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
formula_z_defined = true; formula_z_defined = true;
break; break;
@ -351,7 +351,7 @@ cxxSurfaceComp::read_raw(CParser & parser, bool check)
parser. parser.
error_msg error_msg
("Expected element name and molality for SurfaceComp formula totals.", ("Expected element name and molality for SurfaceComp formula totals.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
opt_save = 10; opt_save = 10;
break; break;
@ -362,7 +362,7 @@ cxxSurfaceComp::read_raw(CParser & parser, bool check)
this->Dw = 0.0; this->Dw = 0.0;
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Expected numeric value for Dw.", parser.error_msg("Expected numeric value for Dw.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
Dw_defined = true; Dw_defined = true;
break; break;
@ -377,45 +377,45 @@ cxxSurfaceComp::read_raw(CParser & parser, bool check)
{ {
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Formula not defined for SurfaceComp input.", parser.error_msg("Formula not defined for SurfaceComp input.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
if (formula_z_defined == false) if (formula_z_defined == false)
{ {
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Formula_z not defined for ExchComp input.", parser.error_msg("Formula_z not defined for ExchComp input.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
if (moles_defined == false) if (moles_defined == false)
{ {
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Moles not defined for SurfaceComp input.", parser.error_msg("Moles not defined for SurfaceComp input.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
if (la_defined == false) if (la_defined == false)
{ {
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("La not defined for SurfaceComp input.", parser.error_msg("La not defined for SurfaceComp input.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
#ifdef SKIP #ifdef SKIP
if (charge_number_defined == false) if (charge_number_defined == false)
{ {
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Charge_number not defined for SurfaceComp input.", parser.error_msg("Charge_number not defined for SurfaceComp input.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
#endif #endif
if (charge_balance_defined == false) if (charge_balance_defined == false)
{ {
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Charge_balance not defined for SurfaceComp input.", parser.error_msg("Charge_balance not defined for SurfaceComp input.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
if (Dw_defined == false) if (Dw_defined == false)
{ {
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Dw not defined for SurfaceComp input.", parser.error_msg("Dw not defined for SurfaceComp input.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
} }
} }

View File

@ -49,15 +49,15 @@ cxxTemperature::dump_xml(std::ostream & s_oss, unsigned int indent) const const
// Temperature element and attributes // Temperature element and attributes
s_oss << indent0; s_oss << indent0;
s_oss << "<temperature " << std::endl; s_oss << "<temperature " << "\n";
s_oss << indent1; s_oss << indent1;
s_oss << "pitzer_temperature_gammas=\"" << this-> s_oss << "pitzer_temperature_gammas=\"" << this->
pitzer_temperature_gammas << "\"" << std::endl; pitzer_temperature_gammas << "\"" << "\n";
// components // components
s_oss << indent1; s_oss << indent1;
s_oss << "<component " << std::endl; s_oss << "<component " << "\n";
for (std::list < cxxTemperatureComp >::const_iterator it = for (std::list < cxxTemperatureComp >::const_iterator it =
temperatureComps.begin(); it != temperatureComps.end(); ++it) temperatureComps.begin(); it != temperatureComps.end(); ++it)
{ {
@ -86,7 +86,7 @@ cxxTemperature::read(CParser & parser)
*/ */
// Number and description set in read_reaction_temperature // Number and description set in read_reaction_temperature
CParser::LINE_TYPE lt; PHRQ_io::LINE_TYPE lt;
bool done = false; bool done = false;
for (;;) for (;;)
{ {
@ -95,21 +95,21 @@ cxxTemperature::read(CParser & parser)
std::string token, str; std::string token, str;
lt = parser.check_line(str, false, true, true, true); lt = parser.check_line(str, false, true, true, true);
if (lt == CParser::LT_EMPTY || if (lt == PHRQ_io::LT_EMPTY ||
lt == CParser::LT_KEYWORD || lt == PHRQ_io::LT_KEYWORD ||
lt == CParser::LT_EOF) lt == PHRQ_io::LT_EOF)
{ {
break; break;
} }
if (lt == CParser::LT_OPTION) if (lt == PHRQ_io::LT_OPTION)
{ {
this->error_msg("Expected numeric value for temperatures.", CParser::OT_CONTINUE); this->error_msg("Expected numeric value for temperatures.", PHRQ_io::OT_CONTINUE);
break; break;
} }
if (done) if (done)
{ {
this->error_msg("Unknown input following equal increment definition.", CParser::OT_CONTINUE); this->error_msg("Unknown input following equal increment definition.", PHRQ_io::OT_CONTINUE);
continue; continue;
} }
@ -136,7 +136,7 @@ cxxTemperature::read(CParser & parser)
if (!(iss >> d)) if (!(iss >> d))
{ {
this->error_msg("Expected numeric value for temperatures.", this->error_msg("Expected numeric value for temperatures.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
else else
{ {
@ -200,18 +200,18 @@ cxxTemperature::dump_raw(std::ostream & s_oss, unsigned int indent, int *n_out)
s_oss << indent0; s_oss << indent0;
int n_user_local = (n_out != NULL) ? *n_out : this->n_user; int n_user_local = (n_out != NULL) ? *n_out : this->n_user;
s_oss << "REACTION_TEMPERATURE_RAW " << n_user_local << " " << this->description << std::endl; s_oss << "REACTION_TEMPERATURE_RAW " << n_user_local << " " << this->description << "\n";
s_oss << indent1; s_oss << indent1;
s_oss << "-count_temps " << this->Get_countTemps() << std::endl; s_oss << "-count_temps " << this->Get_countTemps() << "\n";
s_oss << indent1; s_oss << indent1;
s_oss << "-equal_increments " << this->equalIncrements << std::endl; s_oss << "-equal_increments " << this->equalIncrements << "\n";
// Temperature element and attributes // Temperature element and attributes
s_oss << indent1; s_oss << indent1;
s_oss << "-temps " << std::endl; s_oss << "-temps " << "\n";
{ {
int i = 0; int i = 0;
s_oss << indent2; s_oss << indent2;
@ -220,13 +220,13 @@ cxxTemperature::dump_raw(std::ostream & s_oss, unsigned int indent, int *n_out)
{ {
if (i++ == 5) if (i++ == 5)
{ {
s_oss << std::endl; s_oss << "\n";
s_oss << indent2; s_oss << indent2;
i = 0; i = 0;
} }
s_oss << *it << " "; s_oss << *it << " ";
} }
s_oss << std::endl; s_oss << "\n";
} }
} }
@ -285,8 +285,8 @@ cxxTemperature::read_raw(CParser & parser)
case CParser::OPT_ERROR: case CParser::OPT_ERROR:
opt = CParser::OPT_EOF; opt = CParser::OPT_EOF;
parser.error_msg("Unknown input in TEMPERATURE_COMP_RAW keyword.", parser.error_msg("Unknown input in TEMPERATURE_COMP_RAW keyword.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
parser.error_msg(parser.line().c_str(), CParser::OT_CONTINUE); parser.error_msg(parser.line().c_str(), PHRQ_io::OT_CONTINUE);
useLastLine = false; useLastLine = false;
break; break;
@ -304,7 +304,7 @@ cxxTemperature::read_raw(CParser & parser)
{ {
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Expected numeric value for temps.", parser.error_msg("Expected numeric value for temps.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
else else
{ {
@ -322,7 +322,7 @@ cxxTemperature::read_raw(CParser & parser)
parser.incr_input_error(); parser.incr_input_error();
parser. parser.
error_msg("Expected boolean value for equalIncrements.", error_msg("Expected boolean value for equalIncrements.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
opt_save = CParser::OPT_DEFAULT; opt_save = CParser::OPT_DEFAULT;
useLastLine = false; useLastLine = false;
@ -335,7 +335,7 @@ cxxTemperature::read_raw(CParser & parser)
this->countTemps = 0; this->countTemps = 0;
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Expected integer value for countTemps.", parser.error_msg("Expected integer value for countTemps.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
opt_save = CParser::OPT_DEFAULT; opt_save = CParser::OPT_DEFAULT;
useLastLine = false; useLastLine = false;
@ -352,7 +352,7 @@ cxxTemperature::read_raw(CParser & parser)
parser. parser.
error_msg error_msg
("Equal_increments not defined for REACTION_TEMPERATURE_RAW input.", ("Equal_increments not defined for REACTION_TEMPERATURE_RAW input.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
if (countTemps_defined == false) if (countTemps_defined == false)
{ {
@ -360,7 +360,7 @@ cxxTemperature::read_raw(CParser & parser)
parser. parser.
error_msg error_msg
("Count_temps not defined for REACTION_TEMPERATURE_RAW input.", ("Count_temps not defined for REACTION_TEMPERATURE_RAW input.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */

View File

@ -23,11 +23,11 @@ class cxxTemperature:public cxxNumKeyword
void read_raw(CParser & parser); void read_raw(CParser & parser);
int read(CParser & parser); int read(CParser & parser);
LDBLE Temperature_for_step(int step_number); LDBLE Temperature_for_step(int step_number);
std::vector<double> & Get_temps(void) {return temps;}; std::vector<double> & Get_temps(void) {return temps;}
int Get_countTemps(void) const; int Get_countTemps(void) const;
void Set_countTemps(int i) {countTemps = i;}; void Set_countTemps(int i) {countTemps = i;}
bool Get_equalIncrements(void) const {return equalIncrements;}; bool Get_equalIncrements(void) const {return equalIncrements;}
void Set_equalIncrements(bool tf) {equalIncrements = tf;}; void Set_equalIncrements(bool tf) {equalIncrements = tf;}
protected: protected:
std::vector < double >temps; std::vector < double >temps;

View File

@ -9,6 +9,7 @@
#include "Utils.h" #include "Utils.h"
#include "Parser.h" #include "Parser.h"
//////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////
int int
Utilities::strcmp_nocase_arg1(const char *str1, const char *str2) Utilities::strcmp_nocase_arg1(const char *str1, const char *str2)

86
Utils.h
View File

@ -1,6 +1,6 @@
#if !defined(UTILITIES_H_INCLUDED) #if !defined(UTILITIES_H_INCLUDED)
#define UTILITIES_H_INCLUDED #define UTILITIES_H_INCLUDED
#include "Phreeqc.h"
#include <string> #include <string>
#include <sstream> // std::istringstream std::ostringstream #include <sstream> // std::istringstream std::ostringstream
#include <ostream> // std::ostream #include <ostream> // std::ostream
@ -11,14 +11,14 @@ namespace Utilities
{ {
const char INDENT[] = " "; const char INDENT[] = " ";
#ifdef SKIP
enum STATUS_TYPE enum STATUS_TYPE
{ {
OK = 0, ST_OK = 0,
ERROR = 1 ST_ERROR = 1
}; };
#endif
STATUS_TYPE parse_couple(std::string & token); //STATUS_TYPE parse_couple(std::string & token);
int strcmp_nocase(const char *str1, const char *str2); int strcmp_nocase(const char *str1, const char *str2);
@ -89,6 +89,78 @@ namespace Utilities
return (b.find(i) != b.end());} return (b.find(i) != b.end());}
*/ */
} template < typename T >
void Rxn_copies(std::map < int, T > &b, int n_user, int n_user_end)
{
if (n_user_end <= n_user) return;
typename std::map < int, T >::iterator it;
it = b.find(n_user);
if (it != b.end())
{
for (int j = n_user + 1; j <= n_user_end; j++)
{
b[j] = it->second;
it = b.find(j);
it->second.Set_n_user(j);
it->second.Set_n_user_end(j);
}
}
}
template < typename T >
int Rxn_read_raw(std::map < int, T > &m, Phreeqc * phreeqc_cookie)
{
typename std::map < int, T >::iterator it;
assert(!phreeqc_cookie->reading_database());
T entity(phreeqc_cookie->Get_phrq_io());
CParser parser(phreeqc_cookie->Get_phrq_io());
//if (phreeqc_cookie->pr.echo_input == FALSE) parser.set_echo_file(CParser::EO_NONE);
entity.read_raw(parser);
// Store
if (entity.Get_base_error_count() == 0)
{
m[entity.Get_n_user()] = entity;
}
// Make copies if necessary
Utilities::Rxn_copies(m, entity.Get_n_user(), entity.Get_n_user_end());
return phreeqc_cookie->cleanup_after_parser(parser);
}
template < typename T >
int Rxn_read_modify(std::map < int, T > &m, Phreeqc * phreeqc_cookie)
{
typename std::map < int, T >::iterator it;
CParser parser(phreeqc_cookie->Get_phrq_io());
std::string key_name;
std::string::iterator b = parser.line().begin();
std::string::iterator e = parser.line().end();
CParser::copy_token(key_name, b, e);
cxxNumKeyword nk;
nk.read_number_description(parser);
T * entity_ptr = Utilities::Rxn_find(m, nk.Get_n_user());
if (!entity_ptr)
{
std::ostringstream errstr;
errstr << "Could not find " << key_name << " " << nk.Get_n_user() << " to modify.\n";
phreeqc_cookie->error_msg(errstr.str().c_str(), PHRQ_io::OT_STOP);
}
entity_ptr->read_raw(parser, false);
return phreeqc_cookie->cleanup_after_parser(parser);
}
/*
template<class T>
bool exists (std::map<int, T> b, int i){
return (b.find(i) != b.end());}
*/
}
#endif // UTILITIES_H_INCLUDED #endif // UTILITIES_H_INCLUDED

View File

@ -129,15 +129,15 @@ cxxKinetics::dump_xml(std::ostream & s_oss, unsigned int indent) const const
// Kinetics element and attributes // Kinetics element and attributes
s_oss << indent0; s_oss << indent0;
s_oss << "<kinetics " << std::endl; s_oss << "<kinetics " << "\n";
s_oss << indent1; s_oss << indent1;
s_oss << "pitzer_kinetics_gammas=\"" << this-> s_oss << "pitzer_kinetics_gammas=\"" << this->
pitzer_kinetics_gammas << "\"" << std::endl; pitzer_kinetics_gammas << "\"" << "\n";
// components // components
s_oss << indent1; s_oss << indent1;
s_oss << "<component " << std::endl; s_oss << "<component " << "\n";
for (std::list < cxxKineticsComp >::const_iterator it = for (std::list < cxxKineticsComp >::const_iterator it =
kineticsComps.begin(); it != kineticsComps.end(); ++it) kineticsComps.begin(); it != kineticsComps.end(); ++it)
{ {
@ -165,47 +165,47 @@ cxxKinetics::dump_raw(std::ostream & s_oss, unsigned int indent, int * n_out) co
// Kinetics element and attributes // Kinetics element and attributes
s_oss << indent0; s_oss << indent0;
int n_user_local = (n_out != NULL) ? *n_out : this->n_user; int n_user_local = (n_out != NULL) ? *n_out : this->n_user;
s_oss << "KINETICS_RAW " << n_user_local << " " << this->description << std::endl; s_oss << "KINETICS_RAW " << n_user_local << " " << this->description << "\n";
s_oss << indent1; s_oss << indent1;
s_oss << "-step_divide " << this->step_divide << std::endl; s_oss << "-step_divide " << this->step_divide << "\n";
s_oss << indent1; s_oss << indent1;
s_oss << "-rk " << this->rk << std::endl; s_oss << "-rk " << this->rk << "\n";
s_oss << indent1; s_oss << indent1;
s_oss << "-bad_step_max " << this->bad_step_max << std::endl; s_oss << "-bad_step_max " << this->bad_step_max << "\n";
s_oss << indent1; s_oss << indent1;
s_oss << "-use_cvode " << this->use_cvode << std::endl; s_oss << "-use_cvode " << this->use_cvode << "\n";
s_oss << indent1; s_oss << indent1;
s_oss << "-cvode_steps " << this->cvode_steps << std::endl; s_oss << "-cvode_steps " << this->cvode_steps << "\n";
s_oss << indent1; s_oss << indent1;
s_oss << "-cvode_order " << this->cvode_order << std::endl; s_oss << "-cvode_order " << this->cvode_order << "\n";
// kineticsComps structures // kineticsComps structures
for (std::list < cxxKineticsComp >::const_iterator it = for (std::list < cxxKineticsComp >::const_iterator it =
kineticsComps.begin(); it != kineticsComps.end(); ++it) kineticsComps.begin(); it != kineticsComps.end(); ++it)
{ {
s_oss << indent1; s_oss << indent1;
s_oss << "-component" << std::endl; s_oss << "-component" << "\n";
(*it).dump_raw(s_oss, indent + 2); (*it).dump_raw(s_oss, indent + 2);
} }
// totals // totals
s_oss << indent1; s_oss << indent1;
s_oss << "-totals " << std::endl; s_oss << "-totals " << "\n";
this->totals.dump_raw(s_oss, indent + 2); this->totals.dump_raw(s_oss, indent + 2);
// equal_steps // equal_steps
s_oss << indent1; s_oss << indent1;
s_oss << "-equal_steps " << this->equal_steps << std::endl; s_oss << "-equal_steps " << this->equal_steps << "\n";
// steps // steps
s_oss << indent1; s_oss << indent1;
s_oss << "-steps " << std::endl; s_oss << "-steps " << "\n";
{ {
int i = 0; int i = 0;
s_oss << indent2; s_oss << indent2;
@ -214,13 +214,13 @@ cxxKinetics::dump_raw(std::ostream & s_oss, unsigned int indent, int * n_out) co
{ {
if (i++ == 5) if (i++ == 5)
{ {
s_oss << std::endl; s_oss << "\n";
s_oss << indent2; s_oss << indent2;
i = 0; i = 0;
} }
s_oss << *it << " "; s_oss << *it << " ";
} }
s_oss << std::endl; s_oss << "\n";
} }
return; return;
} }
@ -291,8 +291,8 @@ cxxKinetics::read_raw(CParser & parser, bool check)
case CParser::OPT_ERROR: case CParser::OPT_ERROR:
opt = CParser::OPT_EOF; opt = CParser::OPT_EOF;
parser.error_msg("Unknown input in KINETICS_COMP_RAW keyword.", parser.error_msg("Unknown input in KINETICS_COMP_RAW keyword.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
parser.error_msg(parser.line().c_str(), CParser::OT_CONTINUE); parser.error_msg(parser.line().c_str(), PHRQ_io::OT_CONTINUE);
useLastLine = false; useLastLine = false;
break; break;
@ -302,7 +302,7 @@ cxxKinetics::read_raw(CParser & parser, bool check)
this->step_divide = 1.0; this->step_divide = 1.0;
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Expected numeric value for step_divide.", parser.error_msg("Expected numeric value for step_divide.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
step_divide_defined = true; step_divide_defined = true;
useLastLine = false; useLastLine = false;
@ -314,7 +314,7 @@ cxxKinetics::read_raw(CParser & parser, bool check)
this->rk = 3; this->rk = 3;
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Expected integer value for rk.", parser.error_msg("Expected integer value for rk.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
rk_defined = true; rk_defined = true;
useLastLine = false; useLastLine = false;
@ -326,7 +326,7 @@ cxxKinetics::read_raw(CParser & parser, bool check)
this->bad_step_max = 500; this->bad_step_max = 500;
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Expected integer value for bad_step_max.", parser.error_msg("Expected integer value for bad_step_max.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
bad_step_max_defined = true; bad_step_max_defined = true;
useLastLine = false; useLastLine = false;
@ -338,7 +338,7 @@ cxxKinetics::read_raw(CParser & parser, bool check)
this->use_cvode = false; this->use_cvode = false;
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Expected boolean value for use_cvode.", parser.error_msg("Expected boolean value for use_cvode.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
use_cvode_defined = true; use_cvode_defined = true;
useLastLine = false; useLastLine = false;
@ -404,7 +404,7 @@ cxxKinetics::read_raw(CParser & parser, bool check)
parser. parser.
error_msg error_msg
("Expected element name and molality for KineticsComp totals.", ("Expected element name and molality for KineticsComp totals.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
opt_save = 5; opt_save = 5;
useLastLine = false; useLastLine = false;
@ -420,7 +420,7 @@ cxxKinetics::read_raw(CParser & parser, bool check)
{ {
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Expected numeric value for steps.", parser.error_msg("Expected numeric value for steps.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
else else
{ {
@ -438,7 +438,7 @@ cxxKinetics::read_raw(CParser & parser, bool check)
this->cvode_steps = 100; this->cvode_steps = 100;
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Expected integer value for cvode_steps.", parser.error_msg("Expected integer value for cvode_steps.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
cvode_steps_defined = true; cvode_steps_defined = true;
useLastLine = false; useLastLine = false;
@ -450,7 +450,7 @@ cxxKinetics::read_raw(CParser & parser, bool check)
this->cvode_order = 5; this->cvode_order = 5;
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Expected integer value for cvode_order.", parser.error_msg("Expected integer value for cvode_order.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
cvode_order_defined = true; cvode_order_defined = true;
useLastLine = false; useLastLine = false;
@ -461,7 +461,7 @@ cxxKinetics::read_raw(CParser & parser, bool check)
this->equal_steps = 0; this->equal_steps = 0;
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Expected integer value for equal_steps.", parser.error_msg("Expected integer value for equal_steps.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
equal_steps_defined = true; equal_steps_defined = true;
useLastLine = false; useLastLine = false;
@ -482,44 +482,44 @@ cxxKinetics::read_raw(CParser & parser, bool check)
{ {
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Step_divide not defined for KINETICS_RAW input.", parser.error_msg("Step_divide not defined for KINETICS_RAW input.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
if (rk_defined == false) if (rk_defined == false)
{ {
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Rk not defined for KINETICS_RAW input.", parser.error_msg("Rk not defined for KINETICS_RAW input.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
if (bad_step_max_defined == false) if (bad_step_max_defined == false)
{ {
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Bad_step_max not defined for KINETICS_RAW input.", parser.error_msg("Bad_step_max not defined for KINETICS_RAW input.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
if (use_cvode_defined == false) if (use_cvode_defined == false)
{ {
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Use_cvode not defined for KINETICS_RAW input.", parser.error_msg("Use_cvode not defined for KINETICS_RAW input.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
if (cvode_steps_defined == false) if (cvode_steps_defined == false)
{ {
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Cvode_steps not defined for KINETICS_RAW input.", parser.error_msg("Cvode_steps not defined for KINETICS_RAW input.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
if (cvode_order_defined == false) if (cvode_order_defined == false)
{ {
parser.incr_input_error(); parser.incr_input_error();
parser.error_msg("Cvode_order not defined for KINETICS_RAW input.", parser.error_msg("Cvode_order not defined for KINETICS_RAW input.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
// disable to remain backward compatible with PHAST restart files? // disable to remain backward compatible with PHAST restart files?
//if (equal_steps_defined == false) //if (equal_steps_defined == false)
//{ //{
// parser.incr_input_error(); // parser.incr_input_error();
// parser.error_msg("Equal_steps not defined for KINETICS_RAW input.", // parser.error_msg("Equal_steps not defined for KINETICS_RAW input.",
// CParser::OT_CONTINUE); // PHRQ_io::OT_CONTINUE);
//} //}
} }
} }

View File

@ -71,15 +71,15 @@ cxxMix::dump_xml(std::ostream & s_oss, unsigned int indent) const const
// Mix element and attributes // Mix element and attributes
s_oss << indent0; s_oss << indent0;
s_oss << "<mix " << std::endl; s_oss << "<mix " << "\n";
s_oss << indent1; s_oss << indent1;
s_oss << "pitzer_mix_gammas=\"" << this-> s_oss << "pitzer_mix_gammas=\"" << this->
pitzer_mix_gammas << "\"" << std::endl; pitzer_mix_gammas << "\"" << "\n";
// components // components
s_oss << indent1; s_oss << indent1;
s_oss << "<component " << std::endl; s_oss << "<component " << "\n";
for (std::list < cxxMixComp >::const_iterator it = mixComps.begin(); for (std::list < cxxMixComp >::const_iterator it = mixComps.begin();
it != mixComps.end(); ++it) it != mixComps.end(); ++it)
{ {
@ -107,12 +107,12 @@ cxxMix::dump_raw(std::ostream & s_oss, unsigned int indent, int *n_out) const
// Mix element and attributes // Mix element and attributes
s_oss << indent0; s_oss << indent0;
int n_user_local = (n_out != NULL) ? *n_out : this->n_user; int n_user_local = (n_out != NULL) ? *n_out : this->n_user;
s_oss << "MIX " << n_user_local << " " << this->description << std::endl; s_oss << "MIX " << n_user_local << " " << this->description << "\n";
for (std::map < int, double >::const_iterator it = this->mixComps.begin(); for (std::map < int, double >::const_iterator it = this->mixComps.begin();
it != this->mixComps.end(); it++) it != this->mixComps.end(); it++)
{ {
s_oss << indent1 << it->first << " " << it->second << std::endl; s_oss << indent1 << it->first << " " << it->second << "\n";
} }
} }
@ -163,8 +163,8 @@ cxxMix::read_raw(CParser & parser)
case CParser::OPT_ERROR: case CParser::OPT_ERROR:
opt = CParser::OPT_EOF; opt = CParser::OPT_EOF;
parser.error_msg("Unknown input in MIX_COMP_RAW keyword.", parser.error_msg("Unknown input in MIX_COMP_RAW keyword.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
parser.error_msg(parser.line().c_str(), CParser::OT_CONTINUE); parser.error_msg(parser.line().c_str(), PHRQ_io::OT_CONTINUE);
useLastLine = false; useLastLine = false;
break; break;
@ -178,7 +178,7 @@ cxxMix::read_raw(CParser & parser)
parser. parser.
error_msg error_msg
("Expected integer value for solution number.", ("Expected integer value for solution number.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
break; break;
} }
if (!(parser.get_iss() >> d)) if (!(parser.get_iss() >> d))
@ -187,7 +187,7 @@ cxxMix::read_raw(CParser & parser)
parser. parser.
error_msg error_msg
("Expected numeric value for solution fraction.", ("Expected numeric value for solution fraction.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
break; break;
} }
this->mixComps[i] = d; this->mixComps[i] = d;

View File

@ -34,7 +34,7 @@ class cxxMix:public cxxNumKeyword
{ {
mixComps[n] = f; mixComps[n] = f;
} }
}; }
void Multiply(LDBLE f) void Multiply(LDBLE f)
{ {
for (std::map < int, LDBLE >::iterator it = this->mixComps.begin(); for (std::map < int, LDBLE >::iterator it = this->mixComps.begin();
@ -42,7 +42,7 @@ class cxxMix:public cxxNumKeyword
{ {
it->second *= f; it->second *= f;
} }
}; }
const std::map < int, LDBLE > & Get_mixComps() const const std::map < int, LDBLE > & Get_mixComps() const
{ {

View File

@ -2,6 +2,7 @@
#include "dumper.h" #include "dumper.h"
#include "Parser.h" #include "Parser.h"
#include "PHRQ_io.h"
dumper::dumper(PHRQ_io *io) dumper::dumper(PHRQ_io *io)
: :
@ -170,7 +171,7 @@ bool dumper::Read(CParser & parser)
else else
{ {
parser.error_msg("Expected single number or range of numbers.", parser.error_msg("Expected single number or range of numbers.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
} }
} }
@ -241,8 +242,8 @@ bool dumper::Read(CParser & parser)
case CParser::OPT_ERROR: case CParser::OPT_ERROR:
opt = CParser::OPT_EOF; opt = CParser::OPT_EOF;
parser.error_msg("Unknown input reading DUMP definition.", parser.error_msg("Unknown input reading DUMP definition.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
parser.error_msg(parser.line().c_str(), CParser::OT_CONTINUE); parser.error_msg(parser.line().c_str(), PHRQ_io::OT_CONTINUE);
useLastLine = false; useLastLine = false;
return_value = false; return_value = false;
break; break;
@ -393,7 +394,7 @@ bool dumper::Read(CParser & parser)
else else
{ {
parser.error_msg("Expected single number or range of numbers.", parser.error_msg("Expected single number or range of numbers.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
} }
} }
@ -465,8 +466,8 @@ bool dumper::Read(CParser & parser)
case CParser::OPT_ERROR: case CParser::OPT_ERROR:
opt = CParser::OPT_EOF; opt = CParser::OPT_EOF;
parser.error_msg("Unknown input reading DUMP definition.", parser.error_msg("Unknown input reading DUMP definition.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
parser.error_msg(parser.line().c_str(), CParser::OT_CONTINUE); parser.error_msg(parser.line().c_str(), PHRQ_io::OT_CONTINUE);
useLastLine = false; useLastLine = false;
return_value = false; return_value = false;
break; break;

View File

@ -95,7 +95,7 @@ bool runner::Read(CParser & parser)
else else
{ {
parser.error_msg("Expected single number or range of numbers.", parser.error_msg("Expected single number or range of numbers.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
} }
} }
break; break;
@ -103,8 +103,8 @@ bool runner::Read(CParser & parser)
if (!(parser.get_iss() >> this->start_time)) if (!(parser.get_iss() >> this->start_time))
{ {
parser.error_msg("Expected start_time for RUN_CELLS.", parser.error_msg("Expected start_time for RUN_CELLS.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
parser.error_msg(parser.line().c_str(), CParser::OT_CONTINUE); parser.error_msg(parser.line().c_str(), PHRQ_io::OT_CONTINUE);
} }
break; break;
case 3: //time_step case 3: //time_step
@ -114,8 +114,8 @@ bool runner::Read(CParser & parser)
if (!(parser.get_iss() >> this->time_step)) if (!(parser.get_iss() >> this->time_step))
{ {
parser.error_msg("Expected time_step for RUN_CELLS.", parser.error_msg("Expected time_step for RUN_CELLS.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
parser.error_msg(parser.line().c_str(), CParser::OT_CONTINUE); parser.error_msg(parser.line().c_str(), PHRQ_io::OT_CONTINUE);
} }
break; break;
default: default:
@ -123,8 +123,8 @@ bool runner::Read(CParser & parser)
case CParser::OPT_ERROR: case CParser::OPT_ERROR:
opt = CParser::OPT_EOF; opt = CParser::OPT_EOF;
parser.error_msg("Unknown input reading RUN_CELLS definition.", parser.error_msg("Unknown input reading RUN_CELLS definition.",
CParser::OT_CONTINUE); PHRQ_io::OT_CONTINUE);
parser.error_msg(parser.line().c_str(), CParser::OT_CONTINUE); parser.error_msg(parser.line().c_str(), PHRQ_io::OT_CONTINUE);
useLastLine = false; useLastLine = false;
return_value = false; return_value = false;
break; break;