mirror of
https://git.gfz-potsdam.de/naaice/iphreeqc.git
synced 2025-12-16 08:38:23 +01:00
Removed P_INSTANCE for error_msg, which removed entirely from
some methods. Began moving xx2struct into phreeqc from class definitions. First moved was cxxMix2mix to structures.c. git-svn-id: svn://136.177.114.72/svn_GW/phreeqcpp/branches/ErrorHandling@5648 1feff8c3-07ed-0310-ac33-dd36852eb9cd
This commit is contained in:
parent
c2987e2d6b
commit
12d62e8e54
@ -120,7 +120,7 @@ ChartHandler::Read(PHREEQC_PTR_ARG_COMMA CParser &parser)
|
||||
return true;
|
||||
}
|
||||
bool
|
||||
ChartHandler::End_timer(PHREEQC_PTR_ARG)
|
||||
ChartHandler::End_timer()
|
||||
{
|
||||
|
||||
size_t max_tries = 1000;
|
||||
@ -156,7 +156,7 @@ ChartHandler::End_timer(PHREEQC_PTR_ARG)
|
||||
}
|
||||
if (i >= max_tries || i2 >= max_tries)
|
||||
{
|
||||
P_INSTANCE_POINTER error_msg("Chart did not respond.", CONTINUE);
|
||||
error_msg("Chart did not respond.", CONTINUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -29,7 +29,7 @@ public:
|
||||
}
|
||||
bool Read(PHREEQC_PTR_ARG_COMMA CParser &parser);
|
||||
void Punch_user_graph(PHREEQC_PTR_ARG);
|
||||
bool End_timer(PHREEQC_PTR_ARG);
|
||||
bool End_timer();
|
||||
bool dump(std::ostream & oss, unsigned int indent);
|
||||
protected:
|
||||
std::map<int, ChartObject *> chart_map;
|
||||
|
||||
@ -152,7 +152,7 @@ ChartObject::Set_axis_scale(CParser & parser)
|
||||
}
|
||||
if (string_vector.size() == 0)
|
||||
{
|
||||
P_INSTANCE_POINTER error_msg("No axis defined for scales", CParser::OT_CONTINUE);
|
||||
error_msg("No axis defined for scales", CParser::OT_CONTINUE);
|
||||
return false;
|
||||
}
|
||||
std::string str = string_vector[0];
|
||||
@ -179,7 +179,7 @@ ChartObject::Set_axis_scale(CParser & parser)
|
||||
estream << "Found " << str;
|
||||
estream << ", but expect axis type \'x\', \'y\', \'y2\'or \'sy\'.";
|
||||
estream << std::endl;
|
||||
P_INSTANCE_POINTER error_msg(estream.str().c_str(), CParser::OT_CONTINUE);
|
||||
error_msg(estream.str().c_str(), CParser::OT_CONTINUE);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -200,7 +200,7 @@ ChartObject::Set_axis_scale(CParser & parser)
|
||||
estream << "Found " << s;
|
||||
estream << ", but expect number or 'a(uto)'.";
|
||||
estream << std::endl;
|
||||
P_INSTANCE_POINTER error_msg(estream.str().c_str(), CONTINUE);
|
||||
error_msg(estream.str().c_str(), CONTINUE);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -216,7 +216,7 @@ ChartObject::Set_axis_scale(CParser & parser)
|
||||
std::ostringstream estream;
|
||||
estream << "MIN and MAX must be > 0 for log " << type << "-scale.";
|
||||
estream << std::endl;
|
||||
P_INSTANCE_POINTER error_msg(estream.str().c_str(), CONTINUE);
|
||||
error_msg(estream.str().c_str(), CONTINUE);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -229,7 +229,7 @@ ChartObject::Set_axis_scale(CParser & parser)
|
||||
std::ostringstream estream;
|
||||
estream << "Maximum must be larger than minimum of axis_scale " << type << "-scale." << std::endl;
|
||||
estream << "Switching values for MIN and MAX. " << std::endl;
|
||||
P_INSTANCE_POINTER warning_msg(estream.str().c_str());
|
||||
warning_msg(estream.str().c_str());
|
||||
double t;
|
||||
t = scale_ptr[0];
|
||||
scale_ptr[0] = scale_ptr[1];
|
||||
@ -315,8 +315,8 @@ ChartObject::Read(CParser & parser)
|
||||
break;
|
||||
case CParser::OPT_ERROR:
|
||||
opt = CParser::OPT_EOF;
|
||||
P_INSTANCE_POINTER error_msg("Unknown input in USER_GRAPH keyword.", CONTINUE);
|
||||
P_INSTANCE_POINTER error_msg(parser.line().c_str(), CONTINUE);
|
||||
error_msg("Unknown input in USER_GRAPH keyword.", CONTINUE);
|
||||
error_msg(parser.line().c_str(), CONTINUE);
|
||||
useLastLine = false;
|
||||
break;
|
||||
case 0: /* start */
|
||||
@ -376,7 +376,7 @@ ChartObject::Read(CParser & parser)
|
||||
{
|
||||
std::ostringstream estream;
|
||||
estream << "Found " << token << ", but expect plot type: (\'x\' or \'dist\') for distance, (\'t\') for time.";
|
||||
P_INSTANCE_POINTER error_msg(estream.str().c_str(), CONTINUE);
|
||||
error_msg(estream.str().c_str(), CONTINUE);
|
||||
}
|
||||
break;
|
||||
case 9: /* shifts_as_points */
|
||||
@ -474,7 +474,7 @@ ChartObject::OpenCSVFile(std::string file_name)
|
||||
{
|
||||
std::ostringstream estream;
|
||||
estream << "Could not open csv file for USER_GRAPH " << file_name;
|
||||
P_INSTANCE_POINTER error_msg(estream.str().c_str(), CONTINUE);
|
||||
error_msg(estream.str().c_str(), CONTINUE);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -904,7 +904,7 @@ ChartObject::SaveCurvesToFile(std::string &file_name)
|
||||
{
|
||||
std::ostringstream estream;
|
||||
estream << "Could not open csv file for USER_GRAPH " << file_name;
|
||||
P_INSTANCE_POINTER error_msg(estream.str().c_str(), CONTINUE);
|
||||
error_msg(estream.str().c_str(), CONTINUE);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
20
ExchComp.cxx
20
ExchComp.cxx
@ -148,7 +148,7 @@ cxxExchComp::get_master(PHREEQC_PTR_ARG)
|
||||
error_oss << "Master species not in data base for " << elt_ptr->
|
||||
name << std::endl;
|
||||
//Utilities::error_msg(error_oss.str(), STOP);
|
||||
P_INSTANCE_POINTER error_msg(error_oss.str().c_str(), CONTINUE);
|
||||
error_msg(error_oss.str().c_str(), CONTINUE);
|
||||
return (NULL);
|
||||
}
|
||||
if (elt_ptr->master->type != EX)
|
||||
@ -172,7 +172,7 @@ cxxExchComp::get_master(PHREEQC_PTR_ARG)
|
||||
error_oss << "Master species not in data base for " <<
|
||||
elt_ptr->name << std::endl;
|
||||
//Utilities::error_msg(error_oss.str(), STOP);
|
||||
P_INSTANCE_POINTER error_msg(error_oss.str().c_str(), CONTINUE);
|
||||
error_msg(error_oss.str().c_str(), CONTINUE);
|
||||
return (NULL);
|
||||
}
|
||||
if (elt_ptr->master->type != EX)
|
||||
@ -188,7 +188,7 @@ cxxExchComp::get_master(PHREEQC_PTR_ARG)
|
||||
"Exchange formula does not contain an exchange master species, "
|
||||
<< this->formula << std::endl;
|
||||
//Utilities::error_msg(error_oss.str(), CONTINUE);
|
||||
P_INSTANCE_POINTER error_msg(error_oss.str().c_str(), CONTINUE);
|
||||
error_msg(error_oss.str().c_str(), CONTINUE);
|
||||
|
||||
std::ostringstream oss;
|
||||
this->dump_raw(oss, 0);
|
||||
@ -552,7 +552,7 @@ cxxExchComp::read_raw(CParser & parser, bool check)
|
||||
}
|
||||
}
|
||||
void
|
||||
cxxExchComp::add(PHREEQC_PTR_ARG_COMMA const cxxExchComp & addee, double extensive)
|
||||
cxxExchComp::add(const cxxExchComp & addee, double extensive)
|
||||
{
|
||||
double ext1, ext2, f1, f2;
|
||||
if (extensive == 0.0)
|
||||
@ -604,8 +604,8 @@ cxxExchComp::add(PHREEQC_PTR_ARG_COMMA const cxxExchComp & addee, double extensi
|
||||
oss <<
|
||||
"Can not mix two exchange components with same formula and different related phases, "
|
||||
<< this->formula;
|
||||
P_INSTANCE_POINTER error_msg(oss.str().c_str(), CONTINUE);
|
||||
P_INSTANCE_POINTER input_error++;
|
||||
error_msg(oss.str().c_str(), CONTINUE);
|
||||
//input_error++;
|
||||
return;
|
||||
}
|
||||
else if (this->phase_name.size() != 0)
|
||||
@ -620,8 +620,8 @@ cxxExchComp::add(PHREEQC_PTR_ARG_COMMA const cxxExchComp & addee, double extensi
|
||||
oss <<
|
||||
"Can not mix two exchange components with same formula and different related kinetics, "
|
||||
<< this->formula;
|
||||
P_INSTANCE_POINTER error_msg(oss.str().c_str(), CONTINUE);
|
||||
P_INSTANCE_POINTER input_error++;
|
||||
error_msg(oss.str().c_str(), CONTINUE);
|
||||
//input_error++;
|
||||
return;
|
||||
}
|
||||
else if (this->rate_name.size() != 0)
|
||||
@ -637,8 +637,8 @@ cxxExchComp::add(PHREEQC_PTR_ARG_COMMA const cxxExchComp & addee, double extensi
|
||||
oss <<
|
||||
"Can not mix exchange components related to phase with exchange components related to kinetics, "
|
||||
<< this->formula;
|
||||
P_INSTANCE_POINTER error_msg(oss.str().c_str(), CONTINUE);
|
||||
P_INSTANCE_POINTER input_error++;
|
||||
error_msg(oss.str().c_str(), CONTINUE);
|
||||
//input_error++;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@ -132,7 +132,7 @@ class cxxExchComp: public PHRQ_base
|
||||
};
|
||||
|
||||
|
||||
void add(PHREEQC_PTR_ARG_COMMA const cxxExchComp & comp, double extensive);
|
||||
void add(const cxxExchComp & comp, double extensive);
|
||||
void multiply(double extensive);
|
||||
|
||||
|
||||
|
||||
10
Exchange.cxx
10
Exchange.cxx
@ -67,15 +67,15 @@ cxxNumKeyword(io)
|
||||
//
|
||||
// Mix exchangers
|
||||
//
|
||||
std::map < int, double >*mixcomps = mix.comps();
|
||||
std::map < int, double >&mixcomps = mix.Get_mixComps();
|
||||
std::map < int, double >::const_iterator it;
|
||||
for (it = mixcomps->begin(); it != mixcomps->end(); it++)
|
||||
for (it = mixcomps.begin(); it != mixcomps.end(); it++)
|
||||
{
|
||||
if (entities.find(it->first) != entities.end())
|
||||
{
|
||||
const cxxExchange *entity_ptr =
|
||||
&(entities.find(it->first)->second);
|
||||
this->add(P_INSTANCE_COMMA *entity_ptr, it->second);
|
||||
this->add(*entity_ptr, it->second);
|
||||
this->pitzer_exchange_gammas = entity_ptr->pitzer_exchange_gammas;
|
||||
}
|
||||
#ifdef SKIP
|
||||
@ -465,7 +465,7 @@ cxxExchange::add(const cxxExchange & addee, double extensive)
|
||||
}
|
||||
#endif
|
||||
void
|
||||
cxxExchange::add(PHREEQC_PTR_ARG_COMMA const cxxExchange & addee, double extensive)
|
||||
cxxExchange::add(const cxxExchange & addee, double extensive)
|
||||
//
|
||||
// Add existing exchange to "this" exchange
|
||||
//
|
||||
@ -479,7 +479,7 @@ cxxExchange::add(PHREEQC_PTR_ARG_COMMA const cxxExchange & addee, double extensi
|
||||
std::map < std::string, cxxExchComp >::iterator it = this->exchComps.find((*itadd).first);
|
||||
if (it != this->exchComps.end())
|
||||
{
|
||||
(*it).second.add(P_INSTANCE_COMMA (*itadd).second, extensive);
|
||||
(*it).second.add((*itadd).second, extensive);
|
||||
//bool found = false;
|
||||
//for (std::list < cxxExchComp >::iterator it = this->exchComps.begin();
|
||||
// it != this->exchComps.end(); ++it)
|
||||
|
||||
@ -47,7 +47,7 @@ public:
|
||||
void mpi_unpack(int *ints, int *ii, double *doubles, int *dd);
|
||||
#endif
|
||||
private:
|
||||
void add(PHREEQC_PTR_ARG_COMMA const cxxExchange & addee, double extensive);
|
||||
void add(const cxxExchange & addee, double extensive);
|
||||
// not written
|
||||
void dump_xml(std::ostream & os, unsigned int indent = 0) const;
|
||||
|
||||
|
||||
10
GasPhase.cxx
10
GasPhase.cxx
@ -69,7 +69,7 @@ cxxNumKeyword(io)
|
||||
gas_phase_ptr->comps[i].moles;
|
||||
}
|
||||
}
|
||||
cxxGasPhase::cxxGasPhase(PHREEQC_PTR_ARG_COMMA const std::map < int, cxxGasPhase > &entities,
|
||||
cxxGasPhase::cxxGasPhase(const std::map < int, cxxGasPhase > &entities,
|
||||
cxxMix & mix, int l_n_user, PHRQ_io * io):
|
||||
cxxNumKeyword(io)
|
||||
{
|
||||
@ -82,9 +82,9 @@ cxxNumKeyword(io)
|
||||
// Mix
|
||||
//
|
||||
//cxxNameDouble gasPhaseComps;
|
||||
std::map < int, double >*mixcomps = mix.comps();
|
||||
std::map < int, double >&mixcomps = mix.Get_mixComps();
|
||||
std::map < int, double >::const_iterator it;
|
||||
for (it = mixcomps->begin(); it != mixcomps->end(); it++)
|
||||
for (it = mixcomps.begin(); it != mixcomps.end(); it++)
|
||||
{
|
||||
if (entities.find(it->first) != entities.end())
|
||||
{
|
||||
@ -108,8 +108,8 @@ cxxNumKeyword(io)
|
||||
{
|
||||
std::ostringstream oss;
|
||||
oss << "Can not mix two gas_phases with differing types.";
|
||||
P_INSTANCE_POINTER error_msg(oss.str().c_str(), CONTINUE);
|
||||
P_INSTANCE_POINTER input_error++;
|
||||
error_msg(oss.str().c_str(), CONTINUE);
|
||||
//input_error++;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@ -17,7 +17,7 @@ class cxxGasPhase:public cxxNumKeyword
|
||||
public:
|
||||
cxxGasPhase(PHRQ_io * io=NULL);
|
||||
cxxGasPhase(struct gas_phase *, PHRQ_io * io=NULL);
|
||||
cxxGasPhase(PHREEQC_PTR_ARG_COMMA const std::map < int, cxxGasPhase > &entity_map,
|
||||
cxxGasPhase(const std::map < int, cxxGasPhase > &entity_map,
|
||||
cxxMix & mx, int n_user, PHRQ_io * io=NULL);
|
||||
~cxxGasPhase();
|
||||
|
||||
|
||||
@ -133,8 +133,8 @@ cxxISolution::ConvertUnits(PHREEQC_PTR_ARG)
|
||||
std::ostringstream oss;
|
||||
oss << "Could not find gfw, " << iter->second.
|
||||
get_description();
|
||||
P_INSTANCE_POINTER error_msg(oss.str().c_str(), CONTINUE);
|
||||
P_INSTANCE_POINTER input_error++;
|
||||
error_msg(oss.str().c_str(), CONTINUE);
|
||||
//P_INSTANCE_POINTER input_error++;
|
||||
}
|
||||
}
|
||||
/*
|
||||
@ -775,7 +775,7 @@ cxxISolution::ORCH_write_chemistry_alkalinity(std::ostream & chemistry_dat)
|
||||
oss <<
|
||||
"pH can not be adjusted to charge balance or phase equilibrium when specifying C or C(4) and Alkalinty.";
|
||||
error_msg(oss.str().c_str(), CONTINUE);
|
||||
P_INSTANCE_POINTER input_error++;
|
||||
//P_INSTANCE_POINTER input_error++;
|
||||
}
|
||||
chemistry_dat << "@solve (pH, 1e-6, lin, 1, Alkalinity, 7)" <<
|
||||
std::endl;
|
||||
|
||||
@ -130,8 +130,8 @@ cxxISolutionComp::set_gfw(PHREEQC_PTR_ARG)
|
||||
{
|
||||
std::ostringstream oss;
|
||||
oss << "Could not compute gfw, " << this->as;
|
||||
P_INSTANCE_POINTER error_msg(oss.str().c_str(), CONTINUE);
|
||||
P_INSTANCE_POINTER input_error++;
|
||||
error_msg(oss.str().c_str(), CONTINUE);
|
||||
//P_INSTANCE_POINTER input_error++;
|
||||
return;
|
||||
}
|
||||
//if (this->description == "Alkalinity" && this->as == "CaCO3")
|
||||
@ -154,8 +154,8 @@ cxxISolutionComp::set_gfw(PHREEQC_PTR_ARG)
|
||||
}
|
||||
std::ostringstream oss;
|
||||
oss << "Could not find gfw, " << this->description;
|
||||
P_INSTANCE_POINTER error_msg(oss.str().c_str(), CONTINUE);
|
||||
P_INSTANCE_POINTER input_error++;
|
||||
error_msg(oss.str().c_str(), CONTINUE);
|
||||
//P_INSTANCE_POINTER input_error++;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@ -581,7 +581,7 @@ cxxNameDouble::mpi_pack(std::vector < int >&ints,
|
||||
}
|
||||
}
|
||||
void
|
||||
cxxNameDouble::mpi_pack(PHREEQC_PTR_ARG_COMMA int *ints, int *ii, double *doubles, int *dd)
|
||||
cxxNameDouble::mpi_pack(int *ints, int *ii, double *doubles, int *dd)
|
||||
{
|
||||
int i = *ii;
|
||||
int d = *dd;
|
||||
@ -594,7 +594,7 @@ cxxNameDouble::mpi_pack(PHREEQC_PTR_ARG_COMMA int *ints, int *ii, double *double
|
||||
if (n < 0)
|
||||
{
|
||||
std::cerr << it->first << std::endl;
|
||||
P_INSTANCE_POINTER error_msg("Name in NameDouble was not defined in dictionary?\n",
|
||||
error_msg("Name in NameDouble was not defined in dictionary?\n",
|
||||
STOP);
|
||||
}
|
||||
//ints.push_back(n);
|
||||
|
||||
1454
PHRQ_Parser.cxx
1454
PHRQ_Parser.cxx
File diff suppressed because it is too large
Load Diff
347
PHRQ_Parser.h
347
PHRQ_Parser.h
@ -1,347 +0,0 @@
|
||||
#if !defined(PHRQ_PARSER_H_INCLUDED)
|
||||
#define PHRQ_PARSER_H_INCLUDED
|
||||
|
||||
#include <string> // std::string
|
||||
#include <map> // std::map
|
||||
#include <vector> // std::vector
|
||||
#include <sstream> // std::istringstream std::ostringstream
|
||||
#include <ostream> // std::ostream
|
||||
#include <istream> // std::istream
|
||||
#include "Phreeqc_class.h"
|
||||
#if defined (PHREEQC_CLASS)
|
||||
class Phreeqc;
|
||||
#define PHREEQC_NAME_SPACE Phreeqc::
|
||||
#define PHREEQC_COOKIE this->p_instance->
|
||||
#define ERROR_MESSAGE_QUALIFIER this->p_instance->
|
||||
#else
|
||||
#define PHREEQC_NAME_SPACE ::
|
||||
#define PHREEQC_COOKIE
|
||||
#define ERROR_MESSAGE_QUALIFIER ::
|
||||
extern int input_error;
|
||||
#endif
|
||||
|
||||
class PHRQ_Parser
|
||||
{
|
||||
public:
|
||||
PHRQ_Parser(PHREEQC_PTR_ARG_COMMA std::istream & input);
|
||||
PHRQ_Parser(PHREEQC_PTR_ARG_COMMA std::istream & input, std::ostream & output);
|
||||
PHRQ_Parser(PHREEQC_PTR_ARG_COMMA std::istream & input, std::ostream & output,
|
||||
std::ostream & error);
|
||||
|
||||
virtual ~ PHRQ_Parser();
|
||||
|
||||
enum LINE_TYPE
|
||||
{
|
||||
LT_EOF = -1,
|
||||
LT_OK = 1,
|
||||
LT_EMPTY = 2,
|
||||
LT_KEYWORD = 3,
|
||||
LT_OPTION = 8
|
||||
};
|
||||
|
||||
enum TOKEN_TYPE
|
||||
{
|
||||
TT_EMPTY = 2,
|
||||
TT_UPPER = 4,
|
||||
TT_LOWER = 5,
|
||||
TT_DIGIT = 6,
|
||||
TT_UNKNOWN = 7
|
||||
};
|
||||
|
||||
enum FIND_TYPE
|
||||
{
|
||||
FT_OK = 0,
|
||||
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
|
||||
#if defined MULTICHART
|
||||
, KT_USER_GRAPH = 14
|
||||
#endif
|
||||
};
|
||||
|
||||
enum OPT_TYPE
|
||||
{
|
||||
OPT_DEFAULT = -4,
|
||||
OPT_ERROR = -3,
|
||||
OPT_KEYWORD = -2,
|
||||
OPT_EOF = -1
|
||||
};
|
||||
|
||||
enum ONERROR_TYPE
|
||||
{
|
||||
OT_CONTINUE = 0,
|
||||
OT_STOP = 1
|
||||
};
|
||||
|
||||
enum ECHO_OPTION
|
||||
{
|
||||
EO_NONE = 0,
|
||||
EO_ALL = 1,
|
||||
EO_KEYWORDS = 2,
|
||||
EO_NOKEYWORDS = 3
|
||||
};
|
||||
|
||||
enum STATUS_TYPE
|
||||
{
|
||||
PARSER_ERROR = 0,
|
||||
PARSER_OK = 1
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
Function gets a new line and checks for empty, eof, and keywords.
|
||||
|
||||
Arguments:
|
||||
string Input, character string used in printing error message
|
||||
allow_empty Input, True or false, if a blank line is accepable
|
||||
if false, another line is read
|
||||
allow_eof Input, True or false, if EOF is acceptable
|
||||
allow_keyword Input, True or false, if a keyword is acceptable
|
||||
|
||||
Returns:
|
||||
LT_EMPTY if empty line read and allow_empty == true
|
||||
LT_KEYWORD if line begins with keyword
|
||||
LT_EOF if eof and allow_eof == true
|
||||
LT_OK otherwise
|
||||
LT_OPTION if line begins with -[alpha]
|
||||
|
||||
Terminates if EOF and allow_eof == false.
|
||||
*/
|
||||
LINE_TYPE check_line(const std::string & str, bool allow_empty,
|
||||
bool allow_eof, bool allow_keyword, bool print);
|
||||
|
||||
/**
|
||||
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:
|
||||
None
|
||||
Returns:
|
||||
LT_EMPTY,
|
||||
LT_EOF,
|
||||
LT_KEYWORD,
|
||||
LT_OK,
|
||||
LT_OPTION
|
||||
*/
|
||||
LINE_TYPE get_line();
|
||||
|
||||
// bool check_key(const std::string::iterator ptr);
|
||||
bool check_key(std::string::iterator begin, std::string::iterator end);
|
||||
|
||||
STATUS_TYPE check_units(std::string & tot_units, bool alkalinity,
|
||||
bool check_compatibility,
|
||||
const std::string & default_units, bool print);
|
||||
|
||||
|
||||
KEY_TYPE next_keyword() const
|
||||
{
|
||||
return m_next_keyword;
|
||||
}
|
||||
int get_option(const std::vector < std::string > &opt_list,
|
||||
std::string::iterator & next_char);
|
||||
int get_option(const std::vector < std::string > &opt_list,
|
||||
std::istream::pos_type & next_pos);
|
||||
int getOptionFromLastLine(const std::vector < std::string > &opt_list,
|
||||
std::string::iterator & next_char);
|
||||
int getOptionFromLastLine(const std::vector < std::string > &opt_list,
|
||||
std::istream::pos_type & next_pos);
|
||||
|
||||
|
||||
std::string & line()
|
||||
{
|
||||
return m_line;
|
||||
}
|
||||
std::string & get_accumulated()
|
||||
{
|
||||
return accumulated;
|
||||
}
|
||||
void set_accumulate(bool tf)
|
||||
{
|
||||
if (tf)
|
||||
{
|
||||
accumulated.clear();
|
||||
}
|
||||
this->accumulate = tf;
|
||||
}
|
||||
std::istringstream & get_iss()
|
||||
{
|
||||
return m_line_iss;
|
||||
}
|
||||
int incr_input_error();
|
||||
std::ostream & get_output()
|
||||
{
|
||||
return m_output_stream;
|
||||
}
|
||||
int get_input_error()
|
||||
{
|
||||
return m_input_error;
|
||||
}
|
||||
|
||||
std::istream::pos_type tellg()
|
||||
{
|
||||
return m_input_stream.tellg();
|
||||
}
|
||||
std::istream& seekg(std::istream::pos_type p)
|
||||
{
|
||||
return m_input_stream.seekg(p);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Copies from begin to token until first space is encountered.
|
||||
|
||||
Arguments:
|
||||
token output, the token
|
||||
begin input, begin iterator
|
||||
end input, end iterator
|
||||
|
||||
Returns:
|
||||
TT_EMPTY
|
||||
TT_UPPER
|
||||
TT_LOWER
|
||||
TT_DIGIT
|
||||
TT_UNKNOWN
|
||||
*/
|
||||
static TOKEN_TYPE copy_token(std::string & token,
|
||||
std::string::iterator & begin,
|
||||
std::string::iterator & end);
|
||||
static PHRQ_Parser::TOKEN_TYPE copy_title(std::string & token,
|
||||
std::string::iterator & begin,
|
||||
std::string::iterator & end);
|
||||
static TOKEN_TYPE token_type(const std::string & token);
|
||||
static TOKEN_TYPE copy_token(std::string & token, std::istream & is);
|
||||
TOKEN_TYPE copy_token(std::string & token, std::istream::pos_type & pos);
|
||||
bool get_true_false(std::istream::pos_type & pos, bool def);
|
||||
TOKEN_TYPE get_rest_of_line(std::string &token);
|
||||
static TOKEN_TYPE parse_delimited(std::string & source, std::string & result, const std::string& t);
|
||||
PHRQ_Parser::TOKEN_TYPE peek_token();
|
||||
|
||||
/**
|
||||
Function reads an element name out of the equation string.
|
||||
An element name is composed of a capital letter followed by any number
|
||||
of lower case characters.
|
||||
|
||||
Arguments:
|
||||
begin input, points to position in the equation to begin
|
||||
output, points to next character of equation after
|
||||
element name.
|
||||
end input, points to last position in the equation
|
||||
element input pointer to place to return element character string
|
||||
*/
|
||||
STATUS_TYPE get_elt(std::string::iterator & begin,
|
||||
const std::string::iterator end,
|
||||
std::string & element);
|
||||
|
||||
|
||||
/**
|
||||
Compares a string value to match beginning letters of a list of options
|
||||
|
||||
Arguments:
|
||||
item entry: pointer to string to compare
|
||||
n exit: item in list that was matched
|
||||
list entry: pointer to list of character values, assumed to
|
||||
be lower case
|
||||
count_list entry: number of character values in list
|
||||
|
||||
Returns:
|
||||
OK item matched
|
||||
ERROR item not matched
|
||||
n -1 item not matched
|
||||
i position of match in list
|
||||
*/
|
||||
static FIND_TYPE find_option(const std::string & item, int *n,
|
||||
const std::vector < std::string > &list,
|
||||
bool exact);
|
||||
|
||||
|
||||
int error_msg(const std::ostringstream & err_str, ONERROR_TYPE stop)
|
||||
{
|
||||
return error_msg(err_str.str().c_str(), stop);
|
||||
}
|
||||
int error_msg(const char *err_str, ONERROR_TYPE stop);
|
||||
int warning_msg(const char *err_str);
|
||||
|
||||
void set_echo_file(ECHO_OPTION opt)
|
||||
{
|
||||
echo_file = opt;
|
||||
}
|
||||
ECHO_OPTION get_echo_file()
|
||||
{
|
||||
return this->echo_file;
|
||||
};
|
||||
|
||||
void set_echo_stream(ECHO_OPTION opt)
|
||||
{
|
||||
echo_stream = opt;
|
||||
}
|
||||
ECHO_OPTION get_echo_stream()
|
||||
{
|
||||
return this->echo_stream;
|
||||
};
|
||||
|
||||
STATUS_TYPE parse_couple(std::string & token);
|
||||
|
||||
//STATUS_TYPE addPair(std::map < char *, double, CHARSTAR_LESS > &totals,
|
||||
// std::istream::pos_type & pos);
|
||||
STATUS_TYPE addPair(std::map < std::string, double >&totals,
|
||||
std::istream::pos_type & pos);
|
||||
|
||||
protected:
|
||||
LINE_TYPE get_logical_line();
|
||||
|
||||
private:
|
||||
std::istream & m_input_stream;
|
||||
std::ostream & m_output_stream;
|
||||
std::ostream & m_error_stream;
|
||||
int m_input_error;
|
||||
KEY_TYPE m_next_keyword;
|
||||
std::string m_line;
|
||||
std::string m_line_save;
|
||||
std::istringstream m_line_iss;
|
||||
LINE_TYPE m_line_type;
|
||||
ECHO_OPTION echo_stream;
|
||||
ECHO_OPTION echo_file;
|
||||
std::string accumulated;
|
||||
bool accumulate;
|
||||
#if defined(PHREEQC_CLASS)
|
||||
Phreeqc * p_instance;
|
||||
#endif
|
||||
};
|
||||
|
||||
//// Global functions
|
||||
//inline std::string trim_right(const std::string &source , const std::string& t = " \t")
|
||||
//{
|
||||
// std::string str = source;
|
||||
// return str.erase( str.find_last_not_of(t) + 1);
|
||||
//}
|
||||
//
|
||||
//inline std::string trim_left( const std::string& source, const std::string& t = " \t")
|
||||
//{
|
||||
// std::string str = source;
|
||||
// return str.erase(0 , source.find_first_not_of(t) );
|
||||
//}
|
||||
//
|
||||
//inline std::string trim(const std::string& source, const std::string& t = " \t")
|
||||
//{
|
||||
// std::string str = source;
|
||||
// return trim_left( trim_right( str , t) , t );
|
||||
//}
|
||||
|
||||
#endif // PHRQ_PARSER_H_INCLUDED
|
||||
@ -63,9 +63,9 @@ cxxNumKeyword(io)
|
||||
//
|
||||
// Mix
|
||||
//
|
||||
std::map < int, double >*mixcomps = mix.comps();
|
||||
std::map < int, double >&mixcomps = mix.Get_mixComps();
|
||||
std::map < int, double >::const_iterator it;
|
||||
for (it = mixcomps->begin(); it != mixcomps->end(); it++)
|
||||
for (it = mixcomps.begin(); it != mixcomps.end(); it++)
|
||||
{
|
||||
if (entities.find(it->first) != entities.end())
|
||||
{
|
||||
@ -372,7 +372,7 @@ cxxPPassemblage::add(PHREEQC_PTR_ARG_COMMA const cxxPPassemblage & addee, double
|
||||
{
|
||||
if ((*it).second.get_name() == itadd->second.get_name())
|
||||
{
|
||||
(*it).second.add(P_INSTANCE_COMMA (*itadd).second, extensive);
|
||||
(*it).second.add((*itadd).second, extensive);
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
|
||||
@ -464,7 +464,7 @@ cxxPPassemblageComp::totalize(PHREEQC_PTR_ARG)
|
||||
|
||||
|
||||
void
|
||||
cxxPPassemblageComp::add(PHREEQC_PTR_ARG_COMMA const cxxPPassemblageComp & addee, double extensive)
|
||||
cxxPPassemblageComp::add(const cxxPPassemblageComp & addee, double extensive)
|
||||
{
|
||||
double ext1, ext2, f1, f2;
|
||||
if (extensive == 0.0)
|
||||
@ -500,8 +500,8 @@ cxxPPassemblageComp::add(PHREEQC_PTR_ARG_COMMA const cxxPPassemblageComp & addee
|
||||
oss <<
|
||||
"Can not mix two Equilibrium_phases with differing add_formulae., "
|
||||
<< this->name;
|
||||
P_INSTANCE_POINTER error_msg(oss.str().c_str(), CONTINUE);
|
||||
P_INSTANCE_POINTER input_error++;
|
||||
error_msg(oss.str().c_str(), CONTINUE);
|
||||
//P_INSTANCE_POINTER input_error++;
|
||||
return;
|
||||
}
|
||||
//double si;
|
||||
|
||||
@ -56,7 +56,7 @@ class cxxPPassemblageComp: public PHRQ_base
|
||||
return (this->totals);
|
||||
};
|
||||
|
||||
void add(PHREEQC_PTR_ARG_COMMA const cxxPPassemblageComp & comp, double extensive);
|
||||
void add(const cxxPPassemblageComp & comp, double extensive);
|
||||
void multiply(double extensive);
|
||||
|
||||
#ifdef USE_MPI
|
||||
|
||||
@ -35,6 +35,7 @@ class cxxNameDouble;
|
||||
#undef extern
|
||||
#include "global_structures.h"
|
||||
#include "pitzer_structures.h"
|
||||
class cxxMix;
|
||||
class Phreeqc
|
||||
{
|
||||
public:
|
||||
@ -1228,6 +1229,9 @@ extern void free_spread(void);
|
||||
extern void MergeFinalize(void);
|
||||
#endif
|
||||
|
||||
// convert class to struct
|
||||
struct mix * cxxMix2mix(cxxMix &mx);
|
||||
|
||||
/* tally.c */
|
||||
|
||||
void add_all_components_tally(void);
|
||||
|
||||
@ -870,7 +870,8 @@ read_mix_raw(void)
|
||||
|
||||
cxxMix ex(&phrq_io);
|
||||
ex.read_raw(parser);
|
||||
struct mix *mix_ptr = ex.cxxMix2mix(PHREEQC_THIS);
|
||||
//struct mix *mix_ptr = ex.cxxMix2mix(PHREEQC_THIS);
|
||||
struct mix *mix_ptr = cxxMix2mix(ex);
|
||||
int n;
|
||||
|
||||
/*
|
||||
|
||||
@ -61,9 +61,9 @@ cxxNumKeyword(io)
|
||||
//
|
||||
// Mix
|
||||
//
|
||||
std::map < int, double >*mixcomps = mix.comps();
|
||||
std::map < int, double >&mixcomps = mix.Get_mixComps();
|
||||
std::map < int, double >::const_iterator it;
|
||||
for (it = mixcomps->begin(); it != mixcomps->end(); it++)
|
||||
for (it = mixcomps.begin(); it != mixcomps.end(); it++)
|
||||
{
|
||||
if (entities.find(it->first) != entities.end())
|
||||
{
|
||||
|
||||
21
Solution.cxx
21
Solution.cxx
@ -96,7 +96,7 @@ isotopes(solution_ptr, io)
|
||||
}
|
||||
|
||||
|
||||
cxxSolution::cxxSolution(PHREEQC_PTR_ARG_COMMA const std::map < int, cxxSolution > &solutions,
|
||||
cxxSolution::cxxSolution(const std::map < int, cxxSolution > &solutions,
|
||||
cxxMix & mix, int l_n_user, PHRQ_io * io)
|
||||
//
|
||||
// constructor for cxxSolution from mixture of solutions
|
||||
@ -114,18 +114,21 @@ isotopes(io)
|
||||
//
|
||||
// Mix solutions
|
||||
//
|
||||
std::map < int, double >*mixcomps = mix.comps();
|
||||
std::map < int, double >&mixcomps = mix.Get_mixComps();
|
||||
std::map < int, double >::const_iterator it;
|
||||
for (it = mixcomps->begin(); it != mixcomps->end(); it++)
|
||||
for (it = mixcomps.begin(); it != mixcomps.end(); it++)
|
||||
{
|
||||
std::map < int, cxxSolution >::const_iterator sol =
|
||||
solutions.find(it->first);
|
||||
if (sol == solutions.end())
|
||||
{
|
||||
sprintf(P_INSTANCE_POINTER error_string,
|
||||
"Solution %d not found in mix_cxxSolutions.", it->first);
|
||||
P_INSTANCE_POINTER error_msg(P_INSTANCE_POINTER error_string, CONTINUE);
|
||||
P_INSTANCE_POINTER input_error++;
|
||||
//sprintf(P_INSTANCE_POINTER error_string,
|
||||
// "Solution %d not found in mix_cxxSolutions.", it->first);
|
||||
//error_msg(P_INSTANCE_POINTER error_string, CONTINUE);
|
||||
//P_INSTANCE_POINTER input_error++;
|
||||
std::ostringstream msg;
|
||||
msg << "Solution " << it->first << " not found in mix_cxxSolutions.";
|
||||
error_msg(msg.str(), CONTINUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1574,7 +1577,7 @@ cxxSolution::modify_activities(PHREEQC_PTR_ARG_COMMA const cxxSolution & origina
|
||||
}
|
||||
else
|
||||
{
|
||||
P_INSTANCE_POINTER error_msg("Could not find master species in modify_activities.", STOP);
|
||||
error_msg("Could not find master species in modify_activities.", STOP);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1607,7 +1610,7 @@ cxxSolution::modify_activities(PHREEQC_PTR_ARG_COMMA const cxxSolution & origina
|
||||
}
|
||||
else
|
||||
{
|
||||
P_INSTANCE_POINTER error_msg("Could not find master species in modify_activities.", STOP);
|
||||
error_msg("Could not find master species in modify_activities.", STOP);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -20,7 +20,7 @@ class cxxSolution:public cxxNumKeyword
|
||||
cxxSolution(PHRQ_io *io=NULL);
|
||||
cxxSolution(struct solution *, PHRQ_io *io=NULL);
|
||||
cxxSolution(PHREEQC_PTR_ARG_COMMA int n_user, PHRQ_io *io=NULL);
|
||||
cxxSolution(PHREEQC_PTR_ARG_COMMA const std::map < int, cxxSolution > &solution_map,
|
||||
cxxSolution( const std::map < int, cxxSolution > &solution_map,
|
||||
cxxMix & mx, int n_user, PHRQ_io *io=NULL);
|
||||
~cxxSolution();
|
||||
|
||||
|
||||
@ -133,7 +133,7 @@ PHRQ_base(io)
|
||||
cxxMix entity(struct_entity, this->Get_io());
|
||||
this->setMix(use_ptr->n_mix_user, &entity);
|
||||
|
||||
std::map<int, double> c = *(this->getMix(use_ptr->n_mix_user)->comps());
|
||||
std::map<int, double> c = (this->getMix(use_ptr->n_mix_user)->Get_mixComps());
|
||||
std::map<int, double>::iterator it;
|
||||
for (it = c.begin(); it != c.end(); it++)
|
||||
{
|
||||
@ -1008,7 +1008,7 @@ cxxStorageBin::cxxStorageBin2phreeqc(PHREEQC_PTR_ARG_COMMA int n)
|
||||
}
|
||||
else
|
||||
{
|
||||
P_INSTANCE_POINTER error_msg("cxxSolution not found in system2phreeqc", STOP);
|
||||
error_msg("cxxSolution not found in system2phreeqc", STOP);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -99,9 +99,9 @@ cxxNumKeyword(io)
|
||||
//
|
||||
// Mix exchangers
|
||||
//
|
||||
std::map < int, double >*mixcomps = mix.comps();
|
||||
std::map < int, double >&mixcomps = mix.Get_mixComps();
|
||||
std::map < int, double >::const_iterator it;
|
||||
for (it = mixcomps->begin(); it != mixcomps->end(); it++)
|
||||
for (it = mixcomps.begin(); it != mixcomps.end(); it++)
|
||||
{
|
||||
if (entities.find(it->first) != entities.end())
|
||||
{
|
||||
@ -1009,7 +1009,7 @@ cxxSurface::add(PHREEQC_PTR_ARG_COMMA const cxxSurface & addee, double extensive
|
||||
std::map < std::string, cxxSurfaceComp >::iterator it = this->surfaceComps.find((*itadd).first);
|
||||
if (it != this->surfaceComps.end())
|
||||
{
|
||||
(*it).second.add(P_INSTANCE_COMMA (*itadd).second, extensive);
|
||||
(*it).second.add((*itadd).second, extensive);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@ -85,7 +85,7 @@ struct master *
|
||||
error_oss << "Master species not in data base for " << elt_ptr->
|
||||
name << std::endl;
|
||||
//Utilities::error_msg(error_oss.str(), CONTINUE);
|
||||
P_INSTANCE_POINTER error_msg(error_oss.str().c_str(), CONTINUE);
|
||||
error_msg(error_oss.str().c_str(), CONTINUE);
|
||||
return (NULL);
|
||||
}
|
||||
if (elt_ptr->master->type != SURF)
|
||||
@ -100,7 +100,7 @@ struct master *
|
||||
"Surface formula does not contain an surface master species, " <<
|
||||
this->formula << std::endl;
|
||||
//Utilities::error_msg(error_oss.str(), CONTINUE);
|
||||
P_INSTANCE_POINTER error_msg(error_oss.str().c_str(), CONTINUE);
|
||||
error_msg(error_oss.str().c_str(), CONTINUE);
|
||||
}
|
||||
return (master_ptr);
|
||||
}
|
||||
@ -550,7 +550,7 @@ cxxSurfaceComp::mpi_unpack(int *ints, int *ii, double *doubles, int *dd)
|
||||
}
|
||||
#endif
|
||||
void
|
||||
cxxSurfaceComp::add(PHREEQC_PTR_ARG_COMMA const cxxSurfaceComp & addee, double extensive)
|
||||
cxxSurfaceComp::add(const cxxSurfaceComp & addee, double extensive)
|
||||
{
|
||||
if (extensive == 0.0)
|
||||
return;
|
||||
@ -605,8 +605,8 @@ cxxSurfaceComp::add(PHREEQC_PTR_ARG_COMMA const cxxSurfaceComp & addee, double e
|
||||
oss <<
|
||||
"Can not mix two Surface components with same formula and different related phases, "
|
||||
<< this->formula;
|
||||
P_INSTANCE_POINTER error_msg(oss.str().c_str(), CONTINUE);
|
||||
P_INSTANCE_POINTER input_error++;
|
||||
error_msg(oss.str().c_str(), CONTINUE);
|
||||
//P_INSTANCE_POINTER input_error++;
|
||||
return;
|
||||
}
|
||||
else if (this->phase_name.size() != 0)
|
||||
@ -622,8 +622,8 @@ cxxSurfaceComp::add(PHREEQC_PTR_ARG_COMMA const cxxSurfaceComp & addee, double e
|
||||
oss <<
|
||||
"Can not mix two exchange components with same formula and different related kinetics, "
|
||||
<< this->formula;
|
||||
P_INSTANCE_POINTER error_msg(oss.str().c_str(), CONTINUE);
|
||||
P_INSTANCE_POINTER input_error++;
|
||||
error_msg(oss.str().c_str(), CONTINUE);
|
||||
//P_INSTANCE_POINTER input_error++;
|
||||
return;
|
||||
}
|
||||
else if (this->rate_name.size() != 0)
|
||||
@ -639,8 +639,8 @@ cxxSurfaceComp::add(PHREEQC_PTR_ARG_COMMA const cxxSurfaceComp & addee, double e
|
||||
oss <<
|
||||
"Can not mix exchange components related to phase with exchange components related to kinetics, "
|
||||
<< this->formula;
|
||||
P_INSTANCE_POINTER error_msg(oss.str().c_str(), CONTINUE);
|
||||
P_INSTANCE_POINTER input_error++;
|
||||
error_msg(oss.str().c_str(), CONTINUE);
|
||||
//P_INSTANCE_POINTER input_error++;
|
||||
return;
|
||||
}
|
||||
//double Dw;
|
||||
|
||||
@ -32,7 +32,7 @@ public:
|
||||
void dump_raw(std::ostream & s_oss, unsigned int indent) const;
|
||||
void read_raw(CParser & parser, bool check = true);
|
||||
const cxxNameDouble & get_totals() const;
|
||||
void add(PHREEQC_PTR_ARG_COMMA const cxxSurfaceComp & comp, double extensive);
|
||||
void add(const cxxSurfaceComp & comp, double extensive);
|
||||
void multiply(double extensive);
|
||||
std::string charge_name(PHREEQC_PTR_ARG);
|
||||
static std::string get_charge_name(PHREEQC_PTR_ARG_COMMA char *token);
|
||||
|
||||
@ -100,9 +100,9 @@ cxxNumKeyword(io)
|
||||
//
|
||||
// Mix
|
||||
//
|
||||
std::map < int, double >*mixcomps = mix.comps();
|
||||
std::map < int, double >&mixcomps = mix.Get_mixComps();
|
||||
std::map < int, double >::const_iterator it;
|
||||
for (it = mixcomps->begin(); it != mixcomps->end(); it++)
|
||||
for (it = mixcomps.begin(); it != mixcomps.end(); it++)
|
||||
{
|
||||
if (entities.find(it->first) != entities.end())
|
||||
{
|
||||
|
||||
@ -59,7 +59,7 @@ cxxMix::~cxxMix()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
#ifdef MOVE_TO_STRUCTURES
|
||||
struct mix *
|
||||
cxxMix::cxxMix2mix(PHREEQC_PTR_ARG)
|
||||
//
|
||||
@ -97,6 +97,7 @@ cxxMix::cxxMix2mix(PHREEQC_PTR_ARG)
|
||||
mix_ptr->count_comps = (int) this->mixComps.size();
|
||||
return (mix_ptr);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef SKIP
|
||||
void
|
||||
|
||||
6
cxxMix.h
6
cxxMix.h
@ -18,7 +18,7 @@ class cxxMix:public cxxNumKeyword
|
||||
cxxMix(struct mix *, PHRQ_io *io=NULL);
|
||||
~cxxMix();
|
||||
|
||||
struct mix *cxxMix2mix(PHREEQC_PTR_ARG);
|
||||
//struct mix *cxxMix2mix(PHREEQC_PTR_ARG);
|
||||
|
||||
//void dump_xml(std::ostream& os, unsigned int indent = 0)const;
|
||||
|
||||
@ -46,9 +46,9 @@ class cxxMix:public cxxNumKeyword
|
||||
}
|
||||
};
|
||||
|
||||
std::map < int, double >*comps()
|
||||
std::map < int, double > & Get_mixComps()
|
||||
{
|
||||
return &mixComps;
|
||||
return mixComps;
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user