From b9e38f4da8e239ef4410e2ec4d0b32e5787b5d86 Mon Sep 17 00:00:00 2001 From: David L Parkhurst Date: Tue, 27 Oct 2009 20:29:04 +0000 Subject: [PATCH] Updated phreeqcpp to have examples from phreeqc. equilibrium_phases_read_raw has duplicate lines. git-svn-id: svn://136.177.114.72/svn_GW/phreeqcpp/trunk@3724 1feff8c3-07ed-0310-ac33-dd36852eb9cd --- Makefile | 49 ++++++++++++++++++++++++++++++++++------------ PPassemblage.cxx | 5 +++-- ReadClass.cxx | 17 ++++++++-------- StorageBinList.cpp | 13 ++++++------ StorageBinList.h | 2 +- Utils.cxx | 3 +++ dumper.cpp | 2 +- dumper.h | 2 +- 8 files changed, 60 insertions(+), 33 deletions(-) diff --git a/Makefile b/Makefile index dbc52345..ec0ea045 100644 --- a/Makefile +++ b/Makefile @@ -59,7 +59,7 @@ debug: # ============================================================================= #SRC = ../phreeqc -.SUFFIXES : .o .c .cxx +.SUFFIXES : .o .c .cxx .cpp # compilers @@ -70,6 +70,9 @@ debug: .cxx.o : ${CXX} ${CXXFLAGS} -c -o $@ $< +.cpp.o : + ${CXX} ${CXXFLAGS} -c -o $@ $< + # ----------------------------------------------------------------------------- #hdf options #HDF5_ROOT=$(HOME)/../../usr @@ -149,6 +152,7 @@ COMMON_COBJS = \ print.o \ read.o \ readtr.o \ + sit.o \ smalldense.o \ spread.o \ step.o \ @@ -160,6 +164,7 @@ COMMON_COBJS = \ utilities.o COMMON_CXXOBJS = \ + dumper.o \ Exchange.o \ ExchComp.o \ GasPhase.o \ @@ -181,6 +186,7 @@ COMMON_CXXOBJS = \ SSassemblage.o \ SSassemblageSS.o \ StorageBin.o \ + StorageBinList.o \ Surface.o \ SurfaceCharge.o \ SurfaceComp.o \ @@ -220,7 +226,9 @@ Exchange.o: ../Exchange.cxx ../Utils.h ../char_star.h ../Exchange.h \ ../phreeqc/phrqproto.h ../phreeqc/output.h ExchComp.o: ../ExchComp.cxx ../Utils.h ../char_star.h ../ExchComp.h \ ../NameDouble.h ../Parser.h ../phreeqc/global.h ../phreeqc/phrqtype.h \ - ../phreeqc/phqalloc.h ../phreeqc/phrqproto.h ../phreeqc/output.h + ../Dictionary.h ../Solution.h ../NumKeyword.h ../SolutionIsotopeList.h \ + ../SolutionIsotope.h ../cxxMix.h ../phreeqc/phqalloc.h \ + ../phreeqc/phrqproto.h ../phreeqc/output.h GasPhase.o: ../GasPhase.cxx ../Utils.h ../char_star.h ../GasPhase.h \ ../NumKeyword.h ../Parser.h ../NameDouble.h ../phreeqc/global.h \ ../phreeqc/phrqtype.h ../cxxMix.h ../phreeqc/phqalloc.h \ @@ -237,18 +245,23 @@ ISolution.o: ../ISolution.cxx ../ISolution.h ../ISolutionComp.h \ ../NameDouble.h ../cxxMix.h ../phreeqc/output.h KineticsComp.o: ../KineticsComp.cxx ../Utils.h ../char_star.h \ ../KineticsComp.h ../NameDouble.h ../Parser.h ../phreeqc/global.h \ - ../phreeqc/phrqtype.h ../phreeqc/phqalloc.h ../phreeqc/phrqproto.h + ../phreeqc/phrqtype.h ../Dictionary.h ../Solution.h ../NumKeyword.h \ + ../SolutionIsotopeList.h ../SolutionIsotope.h ../cxxMix.h \ + ../phreeqc/phqalloc.h ../phreeqc/phrqproto.h NameDouble.o: ../NameDouble.cxx ../Utils.h ../char_star.h ../NameDouble.h \ - ../Parser.h ../phreeqc/global.h ../phreeqc/phrqtype.h \ - ../phreeqc/output.h ../phreeqc/phqalloc.h ../phreeqc/phrqproto.h + ../Parser.h ../Dictionary.h ../Solution.h ../NumKeyword.h \ + ../SolutionIsotopeList.h ../SolutionIsotope.h ../cxxMix.h \ + ../phreeqc/global.h ../phreeqc/phrqtype.h ../phreeqc/output.h \ + ../phreeqc/phqalloc.h ../phreeqc/phrqproto.h NumKeyword.o: ../NumKeyword.cxx ../NumKeyword.h ../Parser.h \ ../char_star.h Parser.o: ../Parser.cxx ../Parser.h ../char_star.h ../Utils.h \ ../phreeqc/output.h PPassemblageComp.o: ../PPassemblageComp.cxx ../Utils.h ../char_star.h \ ../PPassemblageComp.h ../NameDouble.h ../Parser.h ../phreeqc/global.h \ - ../phreeqc/phrqtype.h ../phreeqc/phqalloc.h ../phreeqc/phrqproto.h \ - ../phreeqc/output.h + ../phreeqc/phrqtype.h ../Dictionary.h ../Solution.h ../NumKeyword.h \ + ../SolutionIsotopeList.h ../SolutionIsotope.h ../cxxMix.h \ + ../phreeqc/phqalloc.h ../phreeqc/phrqproto.h ../phreeqc/output.h PPassemblage.o: ../PPassemblage.cxx ../Utils.h ../char_star.h \ ../PPassemblage.h ../NumKeyword.h ../Parser.h ../phreeqc/global.h \ ../phreeqc/phrqtype.h ../PPassemblageComp.h ../NameDouble.h ../cxxMix.h \ @@ -263,7 +276,8 @@ ReadClass.o: ../ReadClass.cxx ../Parser.h ../char_star.h ../Solution.h \ ../phreeqc/phrqproto.h ../SurfaceCharge.h ../PPassemblage.h \ ../PPassemblageComp.h ../cxxKinetics.h ../KineticsComp.h \ ../SSassemblage.h ../SSassemblageSS.h ../GasPhase.h ../Reaction.h \ - ../Temperature.h ../phreeqc/phqalloc.h ../phreeqc/output.h + ../Temperature.h ../dumper.h ../StorageBinList.h ../phreeqc/phqalloc.h \ + ../phreeqc/output.h SAXPhreeqc.o: ../SAXPhreeqc.cxx ../SAXPhreeqc.h ../SaxPhreeqcHandlers.h \ ../phreeqc/global.h ../phreeqc/phrqtype.h ../phreeqc/phrqproto.h \ ../phreeqc/phqalloc.h ../phreeqc/output.h @@ -289,7 +303,9 @@ SSassemblage.o: ../SSassemblage.cxx ../Utils.h ../char_star.h \ ../phreeqc/phqalloc.h ../phreeqc/phrqproto.h SSassemblageSS.o: ../SSassemblageSS.cxx ../Utils.h ../char_star.h \ ../SSassemblageSS.h ../NameDouble.h ../Parser.h ../phreeqc/global.h \ - ../phreeqc/phrqtype.h ../phreeqc/phqalloc.h ../phreeqc/phrqproto.h + ../phreeqc/phrqtype.h ../Dictionary.h ../Solution.h ../NumKeyword.h \ + ../SolutionIsotopeList.h ../SolutionIsotope.h ../cxxMix.h \ + ../phreeqc/phqalloc.h ../phreeqc/phrqproto.h StorageBin.o: ../StorageBin.cxx ../Utils.h ../char_star.h ../StorageBin.h \ ../Parser.h ../Solution.h ../NumKeyword.h ../SolutionIsotopeList.h \ ../SolutionIsotope.h ../NameDouble.h ../cxxMix.h ../Exchange.h \ @@ -301,11 +317,14 @@ StorageBin.o: ../StorageBin.cxx ../Utils.h ../char_star.h ../StorageBin.h \ ../phreeqc/output.h SurfaceCharge.o: ../SurfaceCharge.cxx ../Utils.h ../char_star.h \ ../SurfaceCharge.h ../NameDouble.h ../Parser.h ../phreeqc/global.h \ - ../phreeqc/phrqtype.h ../phreeqc/output.h ../phreeqc/phqalloc.h \ - ../phreeqc/phrqproto.h + ../phreeqc/phrqtype.h ../Dictionary.h ../Solution.h ../NumKeyword.h \ + ../SolutionIsotopeList.h ../SolutionIsotope.h ../cxxMix.h \ + ../phreeqc/output.h ../phreeqc/phqalloc.h ../phreeqc/phrqproto.h SurfaceComp.o: ../SurfaceComp.cxx ../Utils.h ../char_star.h \ ../SurfaceComp.h ../NameDouble.h ../Parser.h ../phreeqc/global.h \ - ../phreeqc/phrqtype.h ../phreeqc/phrqproto.h ../phreeqc/phqalloc.h \ + ../phreeqc/phrqtype.h ../phreeqc/phrqproto.h ../Dictionary.h \ + ../Solution.h ../NumKeyword.h ../SolutionIsotopeList.h \ + ../SolutionIsotope.h ../cxxMix.h ../phreeqc/phqalloc.h \ ../phreeqc/output.h Surface.o: ../Surface.cxx ../Utils.h ../char_star.h ../Surface.h \ ../NumKeyword.h ../Parser.h ../phreeqc/global.h ../phreeqc/phrqtype.h \ @@ -324,6 +343,10 @@ Temperature.o: ../Temperature.cxx ../Utils.h ../char_star.h \ ../phreeqc/phrqtype.h ../phreeqc/phqalloc.h ../phreeqc/phrqproto.h Utils.o: ../Utils.cxx ../Utils.h ../char_star.h ../Parser.h \ ../phreeqc/output.h +dumper.o: ../dumper.cpp ../dumper.h ../Parser.h ../char_star.h \ + ../StorageBinList.h +StorageBinList.o: ../StorageBinList.cpp ../StorageBinList.h ../Parser.h \ + ../char_star.h # # PHREEQC files # @@ -435,7 +458,7 @@ clean: dependencies: mkdir -p $(DEBUG_DIR) - cd $(DEBUG_DIR); gcc -MM -I../phreeqc ../*.cxx + cd $(DEBUG_DIR); gcc -MM -I../phreeqc ../*.cxx ../*.cpp tester: cd ../mytest; make clean; make -k $(SPOOL) make.out $(SPOOL2); make zero; make diff $(SPOOL) diff.out $(SPOOL2) diff --git a/PPassemblage.cxx b/PPassemblage.cxx index d33096a6..884672e0 100644 --- a/PPassemblage.cxx +++ b/PPassemblage.cxx @@ -232,8 +232,10 @@ cxxPPassemblage::read_raw(CParser & parser, bool check) { std::istream::pos_type pos = parser.tellg(); cxxPPassemblageComp ppComp; + CParser::ECHO_OPTION eo = parser.get_echo_stream(); + parser.set_echo_stream(CParser::EO_NONE); ppComp.read_raw(parser, false); - + parser.set_echo_stream(eo); if (this->ppAssemblageComps.find(ppComp.get_name()) != this->ppAssemblageComps.end()) { @@ -241,7 +243,6 @@ cxxPPassemblage::read_raw(CParser & parser, bool check) parser.seekg(pos).clear(); parser.seekg(pos); comp.read_raw(parser, false); - int i=1; } else { diff --git a/ReadClass.cxx b/ReadClass.cxx index 87ea75a6..5f248eae 100644 --- a/ReadClass.cxx +++ b/ReadClass.cxx @@ -1085,7 +1085,6 @@ read_delete(void) output_msg(OUTPUT_CHECKLINE, "\t%s\n", line); return (return_value); } -/* /* ---------------------------------------------------------------------- */ int read_solution_modify(void) @@ -1152,7 +1151,7 @@ read_solution_modify(void) if (solution_bsearch(n_user, &n, FALSE) == NULL) { input_error++; - sprintf(error_string, "Solution %d not found for SOLUTION_MODIFY.\n%s\n", line_save); + sprintf(error_string, "Solution %d not found for SOLUTION_MODIFY.\n%s\n", n_user, line_save); error_msg(error_string, CONTINUE); return (ERROR); } @@ -1238,7 +1237,7 @@ read_equilibrium_phases_modify(void) if (pp_assemblage_bsearch(n_user, &n) == NULL) { input_error++; - sprintf(error_string, "Equlibrium_phases %d not found for EQUILIBRIUM_PHASES_MODIFY.\n%s\n", line_save); + sprintf(error_string, "Equlibrium_phases %d not found for EQUILIBRIUM_PHASES_MODIFY.\n%s\n", n_user, line_save); error_msg(error_string, CONTINUE); return (ERROR); } @@ -1322,7 +1321,7 @@ read_exchange_modify(void) if (exchange_bsearch(n_user, &n) == NULL) { input_error++; - sprintf(error_string, "Exchange %d not found for EXCHANGE_MODIFY.\n%s\n", line_save); + sprintf(error_string, "Exchange %d not found for EXCHANGE_MODIFY.\n%s\n", n_user, line_save); error_msg(error_string, CONTINUE); return (ERROR); } @@ -1405,7 +1404,7 @@ read_surface_modify(void) if (surface_bsearch(n_user, &n) == NULL) { input_error++; - sprintf(error_string, "Surface %d not found for SURFACE_MODIFY.\n%s\n", line_save); + sprintf(error_string, "Surface %d not found for SURFACE_MODIFY.\n%s\n", n_user, line_save); error_msg(error_string, CONTINUE); return (ERROR); } @@ -1488,7 +1487,7 @@ read_solid_solutions_modify(void) if (s_s_assemblage_bsearch(n_user, &n) == NULL) { input_error++; - sprintf(error_string, "Solid_solutions %d not found for SOLID_SOLUTIONS_MODIFY.\n%s\n", line_save); + sprintf(error_string, "Solid_solutions %d not found for SOLID_SOLUTIONS_MODIFY.\n%s\n", n_user, line_save); error_msg(error_string, CONTINUE); return (ERROR); } @@ -1571,7 +1570,7 @@ read_gas_phase_modify(void) if (gas_phase_bsearch(n_user, &n) == NULL) { input_error++; - sprintf(error_string, "Gas_phase %d not found for GAS_PHASE_MODIFY.\n%s\n", line_save); + sprintf(error_string, "Gas_phase %d not found for GAS_PHASE_MODIFY.\n%s\n", n_user, line_save); error_msg(error_string, CONTINUE); return (ERROR); } @@ -1653,7 +1652,7 @@ read_kinetics_modify(void) if (kinetics_bsearch(n_user, &n) == NULL) { input_error++; - sprintf(error_string, "Kinetics %d not found for KINETICS_MODIFY.\n%s\n", line_save); + sprintf(error_string, "Kinetics %d not found for KINETICS_MODIFY.\n%s\n", n_user, line_save); error_msg(error_string, CONTINUE); return (ERROR); } @@ -2184,4 +2183,4 @@ delete_entities(void) // Turn off delete until next read delete_info.SetAll(false); return (OK); -} \ No newline at end of file +} diff --git a/StorageBinList.cpp b/StorageBinList.cpp index 617d7197..d65f8bf0 100644 --- a/StorageBinList.cpp +++ b/StorageBinList.cpp @@ -3,18 +3,18 @@ StorageBinListItem::StorageBinListItem(void) { this->defined = false; -}; +} StorageBinListItem::~StorageBinListItem(void) { -}; +} void StorageBinListItem::Augment(std::string token) { this->defined = true; if (token.size() == 0) return; // split string accounting for possible negative numbers - int pos; + unsigned int pos; if ((pos = token.find("--")) != std::string::npos) { token.replace(pos,2," &"); @@ -55,7 +55,7 @@ void StorageBinListItem::Augment(std::string token) this->numbers.insert(i); } } -}; +} StorageBinList::StorageBinList(void) { } @@ -136,7 +136,7 @@ bool StorageBinList::Read(CParser & parser) } // Select StorageBinListItem - StorageBinListItem *item; + StorageBinListItem *item = NULL; switch (opt) { case 0: @@ -240,4 +240,5 @@ bool StorageBinList::Read(CParser & parser) break; } return(return_value); -} \ No newline at end of file +} + diff --git a/StorageBinList.h b/StorageBinList.h index 66fc52e7..5f0d6db9 100644 --- a/StorageBinList.h +++ b/StorageBinList.h @@ -52,4 +52,4 @@ protected: }; -#endif // !defined(STORAGEBINLIST_H_INCLUDED) \ No newline at end of file +#endif // !defined(STORAGEBINLIST_H_INCLUDED) diff --git a/Utils.cxx b/Utils.cxx index f11f3416..230523c3 100644 --- a/Utils.cxx +++ b/Utils.cxx @@ -95,6 +95,7 @@ Utilities::error_msg(const std::string & err_str, const int stop) //+NAN double: 7ff8000000000000 //-NAN double: fff8000000000000 +/* double Utilities::get_nan(void) { unsigned long long raw = 0x7ff0000000000000; @@ -102,3 +103,5 @@ double Utilities::get_nan(void) return(d); } +*/ + diff --git a/dumper.cpp b/dumper.cpp index e3caf53e..7d2d9628 100644 --- a/dumper.cpp +++ b/dumper.cpp @@ -288,7 +288,7 @@ bool dumper::Read(CParser & parser) } // Select StorageBinListItem - StorageBinListItem *item; + StorageBinListItem *item = NULL; switch (opt) { case 0: diff --git a/dumper.h b/dumper.h index dde23e84..f951aa96 100644 --- a/dumper.h +++ b/dumper.h @@ -38,4 +38,4 @@ protected: StorageBinList binList; }; -#endif // !defined(DUMPER_H_INCLUDED) \ No newline at end of file +#endif // !defined(DUMPER_H_INCLUDED)