diff --git a/phreeqcpp/Phreeqc.cpp b/phreeqcpp/Phreeqc.cpp index b1cf8cf9..07d8c829 100644 --- a/phreeqcpp/Phreeqc.cpp +++ b/phreeqcpp/Phreeqc.cpp @@ -427,9 +427,11 @@ size_t Phreeqc::list_Exchangers(std::list &list_exname) } Phreeqc::Phreeqc(PHRQ_io *io) { - //user_print = NULL; - //sformatf_buffer = NULL; - //basic_interpreter = NULL; + user_print = NULL; + sformatf_buffer = NULL; + basic_interpreter = NULL; + count_elts = 0; + aphi = NULL; // phrq_io if (io) { @@ -1141,9 +1143,11 @@ void Phreeqc::init(void) /*-----------------------------------------------------*/ Phreeqc::Phreeqc(const Phreeqc &src) { - //user_print = NULL; - //sformatf_buffer = NULL; - //basic_interpreter = NULL; + user_print = NULL; + sformatf_buffer = NULL; + basic_interpreter = NULL; + count_elts = 0; + aphi = NULL; //this->phrq_io = src.phrq_io; this->phrq_io = &this->ioInstance; this->init(); diff --git a/phreeqcpp/Phreeqc.h b/phreeqcpp/Phreeqc.h index 92d188aa..e1a30274 100644 --- a/phreeqcpp/Phreeqc.h +++ b/phreeqcpp/Phreeqc.h @@ -1352,7 +1352,7 @@ protected: * Element List *---------------------------------------------------------------------- */ std::vector elt_list; - size_t count_elts = 0; /* number of elements in elt_list = position of next */ + size_t count_elts; /* number of elements in elt_list = position of next */ /*---------------------------------------------------------------------- * Reaction *---------------------------------------------------------------------- */ @@ -1442,7 +1442,7 @@ protected: /* ---------------------------------------------------------------------- * USER PRINT COMMANDS * ---------------------------------------------------------------------- */ - class rate* user_print = 0; + class rate* user_print; int n_user_punch_index; int fpunchf_user_s_warning; @@ -1615,7 +1615,7 @@ protected: PHRQMemHeader* s_pTail; /* Basic */ - PBasic* basic_interpreter = NULL; + PBasic* basic_interpreter; double (*basic_callback_ptr) (double x1, double x2, const char* str, void* cookie); void* basic_callback_cookie; @@ -1716,7 +1716,7 @@ protected: int use_etheta; LDBLE OTEMP, OPRESS; LDBLE A0; - class pitz_param* aphi = NULL; + class pitz_param* aphi/* = NULL*/; std::vector spec; class species** cations, ** anions, ** neutrals; // pointers to spec int count_cations, count_anions, count_neutrals; @@ -1740,8 +1740,8 @@ protected: dumper dump_info; StorageBinList delete_info; runner run_info; - char* sformatf_buffer = NULL; - size_t sformatf_buffer_size = 0; + char* sformatf_buffer; + size_t sformatf_buffer_size; /* readtr.cpp */ std::string dump_file_name_cpp; diff --git a/phreeqcpp/class_main.cpp b/phreeqcpp/class_main.cpp index c7e87216..7fc4b8b7 100644 --- a/phreeqcpp/class_main.cpp +++ b/phreeqcpp/class_main.cpp @@ -501,8 +501,8 @@ process_file_names(int argc, char *argv[], std::istream **db_cookie, line = (char *) free_check_null(line); line_save = (char *) free_check_null(line_save); - *db_cookie = new std::ifstream(db_file, std::ios_base::in); - *input_cookie = new std::ifstream(in_file, std::ios_base::in); + *db_cookie = new std::ifstream(db_file.c_str(), std::ios_base::in); + *input_cookie = new std::ifstream(in_file.c_str(), std::ios_base::in); } catch (const PhreeqcStop&) { @@ -547,7 +547,7 @@ open_input_stream(std::string query, std::string& default_name, std::ios_base::o /* * Open existing file to read */ - new_stream = new std::ifstream(name, mode); + new_stream = new std::ifstream(name.c_str(), mode); if (new_stream == NULL || !new_stream->is_open()) { phrq_io->Set_error_ostream(&std::cerr); @@ -606,7 +606,7 @@ open_output_stream(std::string query, std::string& default_name, std::ios_base:: /* * Open existing file to read */ - new_stream = new std::ofstream(name, mode); + new_stream = new std::ofstream(name.c_str(), mode); if (new_stream == NULL || !new_stream->is_open()) { phrq_io->Set_error_ostream(&std::cerr); diff --git a/phreeqcpp/global_structures.h b/phreeqcpp/global_structures.h index df592fe5..1ecb2b82 100644 --- a/phreeqcpp/global_structures.h +++ b/phreeqcpp/global_structures.h @@ -448,16 +448,16 @@ public: ~Model() { }; - bool force_prep = false; - bool numerical_fixed_volume = false; - cxxGasPhase::GP_TYPE gas_phase_type = cxxGasPhase::GP_UNKNOWN; + bool force_prep; + bool numerical_fixed_volume; + cxxGasPhase::GP_TYPE gas_phase_type; std::vector gas_phase; std::vector ss_assemblage; std::vector pp_assemblage; std::vector si; std::vector add_formula; - cxxSurface::DIFFUSE_LAYER_TYPE dl_type = cxxSurface::NO_DL; - cxxSurface::SURFACE_TYPE surface_type = cxxSurface::UNKNOWN_DL; + cxxSurface::DIFFUSE_LAYER_TYPE dl_type; + cxxSurface::SURFACE_TYPE surface_type; std::vector surface_comp; std::vector surface_charge; }; @@ -763,7 +763,7 @@ public: } const char* name; const char* mole_balance; - int in = FALSE; + int in; int number; class master* primary; class master* secondary; @@ -926,15 +926,15 @@ public: LDBLE delta_v[9]; LDBLE pr_si_f; bool pr_in; - int type = SOLID; + int type; std::vector next_elt; std::vector next_sys_total; int check_equation; CReaction rxn; CReaction rxn_s; CReaction rxn_x; - int replaced = FALSE; - int in_system = FALSE; + int replaced; + int in_system; }; /*---------------------------------------------------------------------- * Master species @@ -995,7 +995,7 @@ public: LDBLE total_primary; class element* elt; LDBLE alk; - LDBLE gfw = 1; + LDBLE gfw; const char* gfw_formula; class unknown* unknown; class species* s; @@ -1075,7 +1075,7 @@ public: const char* ss_comp_name; void* ss_comp_ptr; int ss_comp_number; - int ss_in = FALSE; + int ss_in; const char* surface_comp; const char* surface_charge; LDBLE related_moles; @@ -1085,7 +1085,7 @@ public: std::vector comp_unknowns; class unknown* phase_unknown; LDBLE mass_water; - int dissolve_only = FALSE; + int dissolve_only; LDBLE inert_moles; LDBLE V_m; LDBLE pressure; @@ -1122,10 +1122,10 @@ public: coef = 0; // coefficient of species name } const char* name; - LDBLE z = 0; + LDBLE z; class species* s; class unknown* unknown; - LDBLE coef = 0; + LDBLE coef; }; class unknown_list { @@ -1236,7 +1236,7 @@ public: varbase = NULL; loopbase = NULL; } - const char* name = NULL; + const char* name; std::string commands; int new_def; void* linebase; @@ -1306,7 +1306,7 @@ public: } class spread_row* heading; class spread_row* units; - int count_rows = 0; + int count_rows; class spread_row** rows; class defaults defaults; }; @@ -1535,7 +1535,7 @@ public: tot_stag = 0; charge = 0; } - const char* name = NULL; + const char* name; LDBLE tot1, tot2, tot_stag, charge; }; class M_S @@ -1580,7 +1580,7 @@ public: const char* species[3]; int ispec[3]; pitz_param_type type; - LDBLE p = 0; + LDBLE p; union { LDBLE b0; diff --git a/phreeqcpp/inverse.cpp b/phreeqcpp/inverse.cpp index f4398288..4cc7c5a5 100644 --- a/phreeqcpp/inverse.cpp +++ b/phreeqcpp/inverse.cpp @@ -1416,20 +1416,18 @@ solve_with_mask(class inverse *inv_ptr, unsigned long cur_bits) kode = 1; iter = 100000; count_calls++; - #ifdef INVERSE_CL1MP if (inv_ptr->mp == TRUE) { - cl1mp(k, l, m, n, - nklmd, n2d, array1, - &kode, inv_ptr->mp_tolerance, &iter, - delta2, inv_res, &error, inv_cu, inv_iu, inv_is, TRUE, inv_ptr->mp_censor); + cl1mp(k, l, m, n, (int)nklmd, (int)n2d, &array1[0], + &kode, inv_ptr->mp_tolerance, &iter, &delta2[0], &inv_res[0], + &error, &inv_cu[0], &inv_iu[0], &inv_is[0], TRUE, inv_ptr->mp_censor); } else { - cl1(k, l, m, n, - nklmd, n2d, array1, - &kode, toler, &iter, delta2, inv_res, &error, inv_cu, inv_iu, inv_is, TRUE); + cl1(k, l, m, n, (int)nklmd, (int)n2d, &array1[0], + &kode, toler, &iter, &delta2[0], &inv_res[0], + &error, &inv_cu[0], &inv_iu[0], &inv_is[0], TRUE); } #else cl1(k, l, m, n, (int)nklmd, (int)n2d, &array1[0], @@ -2422,16 +2420,14 @@ range(class inverse *inv_ptr, unsigned long cur_bits) #ifdef INVERSE_CL1MP if (inv_ptr->mp == TRUE) { - cl1mp(k, l, m, n, - nklmd, n2d, array1, - &kode, inv_ptr->mp_tolerance, &iter, - delta2, inv_res, &error2, inv_cu, inv_iu, inv_is, TRUE, - inv_ptr->mp_censor); + cl1mp(k, l, m, n, (int)nklmd, (int)n2d, &array1[0], + &kode, inv_ptr->mp_tolerance, &iter, &delta2[0], &inv_res[0], + &error2, &inv_cu[0], &inv_iu[0], &inv_is[0], TRUE, inv_ptr->mp_censor); } else { - cl1(k, l, m, n, nklmd, n2d, array1, &kode, toler, &iter, delta2, - inv_res, &error2, inv_cu, inv_iu, inv_is, TRUE); + cl1(k, l, m, n, (int)nklmd, (int)n2d, &array1[0], &kode, toler, &iter, &delta2[0], + &inv_res[0], &error2, &inv_cu[0], &inv_iu[0], &inv_is[0], TRUE); } #else cl1(k, l, m, n, (int)nklmd, (int)n2d, &array1[0], &kode, toler, &iter, &delta2[0],