mirror of
https://git.gfz-potsdam.de/naaice/iphreeqc.git
synced 2025-12-16 16:44:49 +01:00
Merge commit '1986e00a933549022abb335d82f40c65abf2a292'
This commit is contained in:
commit
7b0c2df096
@ -2415,7 +2415,7 @@ factor(struct LOC_exec * LINK)
|
|||||||
//PhreeqcPtr->count_sys = 1000;
|
//PhreeqcPtr->count_sys = 1000;
|
||||||
//int count_sys = PhreeqcPtr->count_sys;
|
//int count_sys = PhreeqcPtr->count_sys;
|
||||||
int count_sys = 1000;
|
int count_sys = 1000;
|
||||||
names_arg = (char**)PhreeqcPtr->PHRQ_calloc((size_t)(count_sys + 1), sizeof(char*));
|
names_arg = (char**)PhreeqcPtr->PHRQ_calloc(((size_t)count_sys + 1), sizeof(char*));
|
||||||
if (names_arg == NULL)
|
if (names_arg == NULL)
|
||||||
{
|
{
|
||||||
PhreeqcPtr->malloc_error();
|
PhreeqcPtr->malloc_error();
|
||||||
@ -2423,7 +2423,7 @@ factor(struct LOC_exec * LINK)
|
|||||||
exit(4);
|
exit(4);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
moles_arg = (LDBLE*)PhreeqcPtr->PHRQ_calloc((size_t)(count_sys + 1), sizeof(LDBLE));
|
moles_arg = (LDBLE*)PhreeqcPtr->PHRQ_calloc(((size_t)count_sys + 1), sizeof(LDBLE));
|
||||||
if (moles_arg == NULL)
|
if (moles_arg == NULL)
|
||||||
{
|
{
|
||||||
PhreeqcPtr->malloc_error();
|
PhreeqcPtr->malloc_error();
|
||||||
@ -2574,10 +2574,8 @@ factor(struct LOC_exec * LINK)
|
|||||||
if (s_v.subscripts == NULL)
|
if (s_v.subscripts == NULL)
|
||||||
PhreeqcPtr->malloc_error();
|
PhreeqcPtr->malloc_error();
|
||||||
}
|
}
|
||||||
s_v.subscripts =
|
s_v.subscripts = (int*)PhreeqcPtr->PHRQ_realloc(s_v.subscripts,
|
||||||
(int*)PhreeqcPtr->PHRQ_realloc(s_v.subscripts,
|
((size_t)s_v.count_subscripts + 1) * sizeof(int));
|
||||||
(size_t)(s_v.count_subscripts +
|
|
||||||
1) * sizeof(int));
|
|
||||||
if (s_v.subscripts == NULL)
|
if (s_v.subscripts == NULL)
|
||||||
{
|
{
|
||||||
PhreeqcPtr->malloc_error();
|
PhreeqcPtr->malloc_error();
|
||||||
@ -2602,10 +2600,8 @@ factor(struct LOC_exec * LINK)
|
|||||||
if (s_v.subscripts == NULL)
|
if (s_v.subscripts == NULL)
|
||||||
PhreeqcPtr->malloc_error();
|
PhreeqcPtr->malloc_error();
|
||||||
}
|
}
|
||||||
s_v.subscripts =
|
s_v.subscripts = (int*)PhreeqcPtr->PHRQ_realloc(s_v.subscripts,
|
||||||
(int*)PhreeqcPtr->PHRQ_realloc(s_v.subscripts,
|
((size_t)s_v.count_subscripts + 1) * sizeof(int));
|
||||||
(size_t)(s_v.count_subscripts +
|
|
||||||
1) * sizeof(int));
|
|
||||||
if (s_v.subscripts == NULL)
|
if (s_v.subscripts == NULL)
|
||||||
{
|
{
|
||||||
PhreeqcPtr->malloc_error();
|
PhreeqcPtr->malloc_error();
|
||||||
@ -2689,10 +2685,8 @@ factor(struct LOC_exec * LINK)
|
|||||||
if (s_v.subscripts == NULL)
|
if (s_v.subscripts == NULL)
|
||||||
PhreeqcPtr->malloc_error();
|
PhreeqcPtr->malloc_error();
|
||||||
}
|
}
|
||||||
s_v.subscripts =
|
s_v.subscripts = (int*)PhreeqcPtr->PHRQ_realloc(s_v.subscripts,
|
||||||
(int*)PhreeqcPtr->PHRQ_realloc(s_v.subscripts,
|
((size_t)s_v.count_subscripts + 1) * sizeof(int));
|
||||||
(size_t)(s_v.count_subscripts +
|
|
||||||
1) * sizeof(int));
|
|
||||||
if (s_v.subscripts == NULL)
|
if (s_v.subscripts == NULL)
|
||||||
PhreeqcPtr->malloc_error();
|
PhreeqcPtr->malloc_error();
|
||||||
s_v.subscripts[s_v.count_subscripts] = i;
|
s_v.subscripts[s_v.count_subscripts] = i;
|
||||||
@ -2712,10 +2706,8 @@ factor(struct LOC_exec * LINK)
|
|||||||
if (s_v.subscripts == NULL)
|
if (s_v.subscripts == NULL)
|
||||||
PhreeqcPtr->malloc_error();
|
PhreeqcPtr->malloc_error();
|
||||||
}
|
}
|
||||||
s_v.subscripts =
|
s_v.subscripts = (int*)PhreeqcPtr->PHRQ_realloc(s_v.subscripts,
|
||||||
(int*)PhreeqcPtr->PHRQ_realloc(s_v.subscripts,
|
((size_t)s_v.count_subscripts + 1) * sizeof(int));
|
||||||
(size_t)(s_v.count_subscripts +
|
|
||||||
1) * sizeof(int));
|
|
||||||
if (s_v.subscripts == NULL)
|
if (s_v.subscripts == NULL)
|
||||||
PhreeqcPtr->malloc_error();
|
PhreeqcPtr->malloc_error();
|
||||||
s_v.subscripts[s_v.count_subscripts] = j;
|
s_v.subscripts[s_v.count_subscripts] = j;
|
||||||
@ -3212,7 +3204,7 @@ factor(struct LOC_exec * LINK)
|
|||||||
{
|
{
|
||||||
errormsg("Parameter subscript out of range.");
|
errormsg("Parameter subscript out of range.");
|
||||||
}
|
}
|
||||||
n.UU.val = PhreeqcPtr->rate_p[i_rate - 1];
|
n.UU.val = PhreeqcPtr->rate_p[(size_t)i_rate - 1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -3650,7 +3642,7 @@ factor(struct LOC_exec * LINK)
|
|||||||
|
|
||||||
// Make work space
|
// Make work space
|
||||||
int max_length = length < 256 ? 256 : length;
|
int max_length = length < 256 ? 256 : length;
|
||||||
char* token = (char*)PhreeqcPtr->PHRQ_calloc(size_t(max_length + 1), sizeof(char));
|
char* token = (char*)PhreeqcPtr->PHRQ_calloc(((size_t)max_length + 1), sizeof(char));
|
||||||
if (token == NULL) PhreeqcPtr->malloc_error();
|
if (token == NULL) PhreeqcPtr->malloc_error();
|
||||||
|
|
||||||
std::string std_num;
|
std::string std_num;
|
||||||
@ -3693,7 +3685,7 @@ factor(struct LOC_exec * LINK)
|
|||||||
|
|
||||||
// Make work space
|
// Make work space
|
||||||
int max_length = length < 256 ? 256 : length;
|
int max_length = length < 256 ? 256 : length;
|
||||||
char* token = (char*)PhreeqcPtr->PHRQ_calloc(size_t(max_length + 1), sizeof(char));
|
char* token = (char*)PhreeqcPtr->PHRQ_calloc(((size_t)max_length + 1), sizeof(char));
|
||||||
if (token == NULL) PhreeqcPtr->malloc_error();
|
if (token == NULL) PhreeqcPtr->malloc_error();
|
||||||
|
|
||||||
std::string std_num;
|
std::string std_num;
|
||||||
@ -4231,7 +4223,7 @@ factor(struct LOC_exec * LINK)
|
|||||||
case toksgn:
|
case toksgn:
|
||||||
{
|
{
|
||||||
n.UU.val = realfactor(LINK);
|
n.UU.val = realfactor(LINK);
|
||||||
n.UU.val = (n.UU.val > 0) - (n.UU.val < 0);
|
n.UU.val = (double)(n.UU.val > 0) - (double)(n.UU.val < 0);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -4290,7 +4282,7 @@ factor(struct LOC_exec * LINK)
|
|||||||
}
|
}
|
||||||
{
|
{
|
||||||
std::string str = n.UU.sval;
|
std::string str = n.UU.sval;
|
||||||
str = str.substr(i - 1, j);
|
str = str.substr((size_t)i - 1, (size_t)j);
|
||||||
strcpy(n.UU.sval, str.c_str());
|
strcpy(n.UU.sval, str.c_str());
|
||||||
}
|
}
|
||||||
require(tokrp, LINK);
|
require(tokrp, LINK);
|
||||||
@ -6876,8 +6868,8 @@ void PBasic::
|
|||||||
strmove(int len, char *l_s, int spos,
|
strmove(int len, char *l_s, int spos,
|
||||||
char *d, int dpos)
|
char *d, int dpos)
|
||||||
{
|
{
|
||||||
l_s += spos - 1;
|
l_s += (size_t)spos - 1;
|
||||||
d += dpos - 1;
|
d += (size_t)dpos - 1;
|
||||||
while (*d && --len >= 0)
|
while (*d && --len >= 0)
|
||||||
*d++ = *l_s++;
|
*d++ = *l_s++;
|
||||||
if (len > 0)
|
if (len > 0)
|
||||||
@ -7133,40 +7125,40 @@ P_addset(long *l_s, unsigned val) /* s := s + [val] */
|
|||||||
return sbase;
|
return sbase;
|
||||||
}
|
}
|
||||||
|
|
||||||
long * PBasic::
|
//long * PBasic::
|
||||||
P_addsetr(long *l_s, unsigned v1, unsigned v2) /* s := s + [v1..v2] */
|
//P_addsetr(long *l_s, unsigned v1, unsigned v2) /* s := s + [v1..v2] */
|
||||||
{
|
//{
|
||||||
long *sbase = l_s;
|
// long *sbase = l_s;
|
||||||
int b1, b2, size;
|
// int b1, b2, size;
|
||||||
if ((int) v1 > (int) v2)
|
// if ((int) v1 > (int) v2)
|
||||||
return sbase;
|
// return sbase;
|
||||||
b1 = v1 % SETBITS;
|
// b1 = v1 % SETBITS;
|
||||||
v1 /= SETBITS;
|
// v1 /= SETBITS;
|
||||||
b2 = v2 % SETBITS;
|
// b2 = v2 % SETBITS;
|
||||||
v2 /= SETBITS;
|
// v2 /= SETBITS;
|
||||||
size = *l_s;
|
// size = *l_s;
|
||||||
v1++;
|
// v1++;
|
||||||
if ((int) ++v2 > size)
|
// if ((int) ++v2 > size)
|
||||||
{
|
// {
|
||||||
while ((int) v2 > size)
|
// while ((int) v2 > size)
|
||||||
l_s[++size] = 0;
|
// l_s[++size] = 0;
|
||||||
l_s[v2] = 0;
|
// l_s[v2] = 0;
|
||||||
*l_s = v2;
|
// *l_s = v2;
|
||||||
}
|
// }
|
||||||
l_s += v1;
|
// l_s += v1;
|
||||||
if (v1 == v2)
|
// if (v1 == v2)
|
||||||
{
|
// {
|
||||||
*l_s |= (~((-2L) << (b2 - b1))) << b1;
|
// *l_s |= (~((-2L) << (b2 - b1))) << b1;
|
||||||
}
|
// }
|
||||||
else
|
// else
|
||||||
{
|
// {
|
||||||
*l_s++ |= (-1L) << b1;
|
// *l_s++ |= (-1L) << b1;
|
||||||
while (++v1 < v2)
|
// while (++v1 < v2)
|
||||||
*l_s++ = -1;
|
// *l_s++ = -1;
|
||||||
*l_s |= ~((-2L) << b2);
|
// *l_s |= ~((-2L) << b2);
|
||||||
}
|
// }
|
||||||
return sbase;
|
// return sbase;
|
||||||
}
|
//}
|
||||||
|
|
||||||
long * PBasic::
|
long * PBasic::
|
||||||
P_remset(long *l_s, unsigned val) /* s := s - [val] */
|
P_remset(long *l_s, unsigned val) /* s := s - [val] */
|
||||||
|
|||||||
@ -170,6 +170,7 @@ public:
|
|||||||
toktan,
|
toktan,
|
||||||
tokarctan,
|
tokarctan,
|
||||||
toklog,
|
toklog,
|
||||||
|
toklog10,
|
||||||
tokexp,
|
tokexp,
|
||||||
tokabs,
|
tokabs,
|
||||||
toksgn,
|
toksgn,
|
||||||
@ -182,7 +183,6 @@ public:
|
|||||||
tokpeek,
|
tokpeek,
|
||||||
tokrem,
|
tokrem,
|
||||||
toklet,
|
toklet,
|
||||||
tokprint,
|
|
||||||
tokinput,
|
tokinput,
|
||||||
tokgoto,
|
tokgoto,
|
||||||
tokif,
|
tokif,
|
||||||
@ -206,7 +206,6 @@ public:
|
|||||||
toknew,
|
toknew,
|
||||||
tokload,
|
tokload,
|
||||||
tokmerge,
|
tokmerge,
|
||||||
toksave,
|
|
||||||
tokbye,
|
tokbye,
|
||||||
tokdel,
|
tokdel,
|
||||||
tokrenum,
|
tokrenum,
|
||||||
@ -214,143 +213,142 @@ public:
|
|||||||
tokelse,
|
tokelse,
|
||||||
tokto,
|
tokto,
|
||||||
tokstep,
|
tokstep,
|
||||||
toktc,
|
/* start phreeqc */
|
||||||
tokm0,
|
|
||||||
tokm,
|
|
||||||
tokparm,
|
|
||||||
tokact,
|
tokact,
|
||||||
tokmol,
|
tokadd_heading,
|
||||||
tokla,
|
|
||||||
toklm,
|
|
||||||
toksr,
|
|
||||||
toksi,
|
|
||||||
toktot,
|
|
||||||
toktk,
|
|
||||||
toktime,
|
|
||||||
toklog10,
|
|
||||||
toksim_time,
|
|
||||||
tokequi,
|
|
||||||
tokgas,
|
|
||||||
tokpunch,
|
|
||||||
tokkin,
|
|
||||||
toks_s,
|
|
||||||
tokmu,
|
|
||||||
tokalk,
|
tokalk,
|
||||||
tokrxn,
|
tokaphi,
|
||||||
tokdist,
|
tokcalc_value,
|
||||||
tokmisc1,
|
tokceil,
|
||||||
tokmisc2,
|
tokcell_no,
|
||||||
tokedl,
|
tokchange_por,
|
||||||
tokstep_no,
|
tokchange_surf,
|
||||||
toksim_no,
|
|
||||||
toktotal_time,
|
|
||||||
tokput,
|
|
||||||
tokget,
|
|
||||||
tokcharge_balance,
|
tokcharge_balance,
|
||||||
tokpercent_error,
|
tokcurrent_a,
|
||||||
#if defined (PHREEQ98) || defined (MULTICHART)
|
tokdebye_length,
|
||||||
|
tokdelta_h_phase,
|
||||||
|
tokdelta_h_species,
|
||||||
|
tokdescription,
|
||||||
|
tokdh_a,
|
||||||
|
tokdh_a0,
|
||||||
|
tokdh_av,
|
||||||
|
tokdh_b,
|
||||||
|
tokdh_bdot,
|
||||||
|
tokdiff_c,
|
||||||
|
tokdist,
|
||||||
|
tokedl,
|
||||||
|
tokedl_species,
|
||||||
|
tokeol_,
|
||||||
|
tokeol_notab_,
|
||||||
|
tokeps_r,
|
||||||
|
tokeq_frac,
|
||||||
|
tokequiv_frac,
|
||||||
|
tokequi,
|
||||||
|
tokequi_delta,
|
||||||
|
tokerase,
|
||||||
|
tokexists,
|
||||||
|
tokfloor,
|
||||||
|
tokgamma,
|
||||||
|
tokgas,
|
||||||
|
tokgas_p,
|
||||||
|
tokgas_vm,
|
||||||
|
tokget,
|
||||||
|
tokget_por,
|
||||||
|
tokgfw,
|
||||||
tokgraph_x,
|
tokgraph_x,
|
||||||
tokgraph_y,
|
tokgraph_y,
|
||||||
tokgraph_sy,
|
tokgraph_sy,
|
||||||
#endif
|
|
||||||
tokcell_no,
|
|
||||||
tokexists,
|
|
||||||
toksurf,
|
|
||||||
toklk_species,
|
|
||||||
toklk_named,
|
|
||||||
toklk_phase,
|
|
||||||
tokdelta_h_phase,
|
|
||||||
tokdelta_h_species,
|
|
||||||
tokdh_a0,
|
|
||||||
tokdh_bdot,
|
|
||||||
toksum_species,
|
|
||||||
toksum_gas,
|
|
||||||
toksum_s_s,
|
|
||||||
tokcalc_value,
|
|
||||||
tokdescription,
|
|
||||||
toktitle,
|
|
||||||
toksys,
|
|
||||||
tokadd_heading,
|
|
||||||
tokinstr,
|
tokinstr,
|
||||||
tokltrim,
|
|
||||||
tokrtrim,
|
|
||||||
toktrim,
|
|
||||||
tokpad,
|
|
||||||
tokpad_,
|
|
||||||
tokchange_por,
|
|
||||||
tokget_por,
|
|
||||||
tokosmotic,
|
|
||||||
tokchange_surf,
|
|
||||||
tokporevolume,
|
|
||||||
toksc,
|
|
||||||
tokgamma,
|
|
||||||
toklg,
|
|
||||||
tokrho,
|
|
||||||
tokrho_0,
|
|
||||||
tokcell_volume,
|
|
||||||
tokcell_pore_volume,
|
|
||||||
tokcell_porosity,
|
|
||||||
tokcell_saturation,
|
|
||||||
tokvelocity_x,
|
|
||||||
tokvelocity_y,
|
|
||||||
tokvelocity_z,
|
|
||||||
toktransport_cell_no,
|
|
||||||
#if defined MULTICHART
|
|
||||||
tokplot_xy,
|
|
||||||
#endif
|
|
||||||
toktotmole,
|
|
||||||
tokiso,
|
tokiso,
|
||||||
tokiso_unit,
|
tokiso_unit,
|
||||||
toktotmol,
|
tokiterations,
|
||||||
toktotmoles,
|
|
||||||
tokeol_,
|
|
||||||
tokeol_notab_,
|
|
||||||
tokno_newline_,
|
|
||||||
tokceil,
|
|
||||||
tokfloor,
|
|
||||||
tokkinetics_formula,
|
|
||||||
tokkinetics_formula_,
|
|
||||||
tokphase_formula,
|
|
||||||
tokphase_formula_,
|
|
||||||
tokspecies_formula,
|
|
||||||
tokspecies_formula_,
|
|
||||||
toklist_s_s,
|
|
||||||
tokpr_p,
|
|
||||||
tokpr_phi,
|
|
||||||
tokgas_p,
|
|
||||||
tokgas_vm,
|
|
||||||
tokpressure,
|
|
||||||
tokerase,
|
|
||||||
tokeps_r,
|
|
||||||
tokvm,
|
|
||||||
tokphase_vm,
|
|
||||||
tokdh_a,
|
|
||||||
tokdebye_length,
|
|
||||||
tokdh_b,
|
|
||||||
tokdh_av,
|
|
||||||
tokqbrn,
|
|
||||||
tokkappa,
|
tokkappa,
|
||||||
tokgfw,
|
tokkin,
|
||||||
toksoln_vol,
|
|
||||||
tokequi_delta,
|
|
||||||
tokkin_delta,
|
tokkin_delta,
|
||||||
tokkin_time,
|
tokkin_time,
|
||||||
tokstr_f_,
|
tokkinetics_formula,
|
||||||
tokstr_e_,
|
tokkinetics_formula_,
|
||||||
tokeq_frac,
|
tokla,
|
||||||
tokequiv_frac,
|
toklg,
|
||||||
tokcallback,
|
toklist_s_s,
|
||||||
tokdiff_c,
|
toklk_named,
|
||||||
|
toklk_phase,
|
||||||
|
toklk_species,
|
||||||
|
toklm,
|
||||||
|
tokltrim,
|
||||||
|
tokm,
|
||||||
|
tokm0,
|
||||||
|
tokmisc1,
|
||||||
|
tokmisc2,
|
||||||
|
tokmol,
|
||||||
|
tokmu,
|
||||||
|
tokno_newline_,
|
||||||
|
tokosmotic,
|
||||||
|
tokpad_,
|
||||||
|
tokpad,
|
||||||
|
tokparm,
|
||||||
|
tokpercent_error,
|
||||||
|
tokphase_formula,
|
||||||
|
tokphase_formula_,
|
||||||
|
tokphase_vm,
|
||||||
|
tokplot_xy,
|
||||||
|
tokpot_v,
|
||||||
|
tokpr_p,
|
||||||
|
tokpr_phi,
|
||||||
|
tokpressure,
|
||||||
|
tokprint,
|
||||||
|
tokpunch,
|
||||||
|
tokput,
|
||||||
|
tokqbrn,
|
||||||
|
tokrho,
|
||||||
|
tokrho_0,
|
||||||
|
tokrtrim,
|
||||||
|
tokrxn,
|
||||||
|
toks_s,
|
||||||
|
toksave,
|
||||||
|
toksc,
|
||||||
toksetdiff_c,
|
toksetdiff_c,
|
||||||
toksa_declercq,
|
toksi,
|
||||||
tokedl_species,
|
toksim_no,
|
||||||
|
toksim_time,
|
||||||
|
toksoln_vol,
|
||||||
|
tokspecies_formula,
|
||||||
|
tokspecies_formula_,
|
||||||
|
toksr,
|
||||||
|
tokstep_no,
|
||||||
|
tokstr_e_,
|
||||||
|
tokstr_f_,
|
||||||
|
toksum_gas,
|
||||||
|
toksum_s_s,
|
||||||
|
toksum_species,
|
||||||
|
toksurf,
|
||||||
|
toksys,
|
||||||
|
tokt_sc,
|
||||||
|
toktc,
|
||||||
|
toktime,
|
||||||
|
toktitle,
|
||||||
|
toktk,
|
||||||
|
toktot,
|
||||||
|
toktotal_time,
|
||||||
|
toktotmole,
|
||||||
|
toktotmol,
|
||||||
|
toktotmoles,
|
||||||
|
toktrim,
|
||||||
tokviscos,
|
tokviscos,
|
||||||
tokviscos_0,
|
tokviscos_0,
|
||||||
tokcurrent_a,
|
tokvm,
|
||||||
tokpot_v,
|
/* end phreeqc */
|
||||||
tokt_sc,
|
toksa_declercq, // Undocumented function
|
||||||
tokaphi,
|
tokcallback, // PHAST function
|
||||||
tokiterations
|
tokcell_pore_volume, // PHAST function
|
||||||
|
tokporevolume, // PHAST function
|
||||||
|
tokcell_porosity, // PHAST function
|
||||||
|
tokcell_saturation, // PHAST function
|
||||||
|
tokcell_volume, // PHAST function
|
||||||
|
toktransport_cell_no, // PHAST function
|
||||||
|
tokvelocity_x, // PHAST function
|
||||||
|
tokvelocity_y, // PHAST function
|
||||||
|
tokvelocity_z // PHAST function
|
||||||
};
|
};
|
||||||
|
|
||||||
#if !defined(PHREEQCI_GUI)
|
#if !defined(PHREEQCI_GUI)
|
||||||
@ -511,7 +509,7 @@ public:
|
|||||||
long * P_setdiff(long *d, long *s1, long *s2);
|
long * P_setdiff(long *d, long *s1, long *s2);
|
||||||
long * P_setxor(long *d, long *s1, long *s2);
|
long * P_setxor(long *d, long *s1, long *s2);
|
||||||
long * P_addset(long *s, unsigned val);
|
long * P_addset(long *s, unsigned val);
|
||||||
long * P_addsetr(long *s, unsigned v1, unsigned v2);
|
// long * P_addsetr(long *s, unsigned v1, unsigned v2);
|
||||||
long * P_remset(long *s, unsigned val);
|
long * P_remset(long *s, unsigned val);
|
||||||
int P_setequal(long *s1, long *s2);
|
int P_setequal(long *s1, long *s2);
|
||||||
int P_subset(long *s1, long *s2);
|
int P_subset(long *s1, long *s2);
|
||||||
|
|||||||
@ -1762,7 +1762,8 @@ protected:
|
|||||||
*delta_save;
|
*delta_save;
|
||||||
LDBLE *min_delta, *max_delta;
|
LDBLE *min_delta, *max_delta;
|
||||||
int *inv_iu, *inv_is;
|
int *inv_iu, *inv_is;
|
||||||
int klmd, nklmd, n2d, kode, iter;
|
int klmd, nklmd, n2d;
|
||||||
|
int kode, iter;
|
||||||
LDBLE toler, error, max_pct, scaled_error;
|
LDBLE toler, error, max_pct, scaled_error;
|
||||||
struct master *master_alk;
|
struct master *master_alk;
|
||||||
int *row_back, *col_back;
|
int *row_back, *col_back;
|
||||||
|
|||||||
@ -336,9 +336,9 @@ Pressure_for_step(int step_number)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
LDBLE denom;
|
LDBLE denom;
|
||||||
denom = (this->count <= 1) ? 1 : (LDBLE) (this->count - 1);
|
denom = (this->count <= 1) ? 1 : ((LDBLE)this->count - 1);
|
||||||
p_temp = this->pressures[0] + ( this->pressures[1] - this->pressures[0]) *
|
p_temp = this->pressures[0] + ( this->pressures[1] - this->pressures[0]) *
|
||||||
((LDBLE) (step_number - 1)) / (denom);
|
(((LDBLE)step_number - 1)) / (denom);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -349,7 +349,7 @@ Pressure_for_step(int step_number)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
p_temp = this->pressures[step_number - 1];
|
p_temp = this->pressures[(size_t)step_number - 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -346,9 +346,9 @@ Temperature_for_step(int step_number)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
LDBLE denom;
|
LDBLE denom;
|
||||||
denom = (this->countTemps <= 1) ? 1 : (LDBLE) (this->countTemps - 1);
|
denom = (this->countTemps <= 1) ? 1 : (LDBLE)this->countTemps - 1;
|
||||||
t_temp = this->temps[0] + ( this->temps[1] - this->temps[0]) *
|
t_temp = this->temps[0] + ( this->temps[1] - this->temps[0]) *
|
||||||
((LDBLE) (step_number - 1)) / (denom);
|
((LDBLE)step_number - 1) / (denom);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -359,7 +359,7 @@ Temperature_for_step(int step_number)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
t_temp = this->temps[step_number - 1];
|
t_temp = this->temps[(size_t)step_number - 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -489,7 +489,7 @@ Current_step(bool incremental_reactions, int reaction_step) const
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
kin_time = this->steps[reaction_step - 1];
|
kin_time = this->steps[(size_t)reaction_step - 1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -515,7 +515,7 @@ Current_step(bool incremental_reactions, int reaction_step) const
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
kin_time = this->steps[reaction_step - 1];
|
kin_time = this->steps[(size_t)reaction_step - 1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@ -218,7 +218,7 @@ build_fixed_volume_gas(void)
|
|||||||
row / (count_unknowns + 1), col));
|
row / (count_unknowns + 1), col));
|
||||||
}
|
}
|
||||||
store_jacob(&(gas_unknowns[i]->moles),
|
store_jacob(&(gas_unknowns[i]->moles),
|
||||||
&(my_array[row + col]), coef);
|
&(my_array[(size_t)row + (size_t)col]), coef);
|
||||||
}
|
}
|
||||||
if (gas_phase_ptr->Get_type() == cxxGasPhase::GP_PRESSURE)
|
if (gas_phase_ptr->Get_type() == cxxGasPhase::GP_PRESSURE)
|
||||||
{
|
{
|
||||||
@ -231,7 +231,7 @@ build_fixed_volume_gas(void)
|
|||||||
gas_unknown->number));
|
gas_unknown->number));
|
||||||
}
|
}
|
||||||
store_jacob(&(phase_ptr->fraction_x),
|
store_jacob(&(phase_ptr->fraction_x),
|
||||||
&(my_array[row + gas_unknown->number]), coef_elt);
|
&(my_array[(size_t)row + (size_t)gas_unknown->number]), coef_elt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
@ -309,7 +309,7 @@ build_fixed_volume_gas(void)
|
|||||||
master_ptr->s->name, (double) coef,
|
master_ptr->s->name, (double) coef,
|
||||||
row / (count_unknowns + 1), col));
|
row / (count_unknowns + 1), col));
|
||||||
}
|
}
|
||||||
store_jacob(&(phase_ptr->p_soln_x), &(my_array[row + col]), coef);
|
store_jacob(&(phase_ptr->p_soln_x), &(my_array[(size_t)row + (size_t)col]), coef);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -305,10 +305,10 @@ polint(LDBLE * xa, LDBLE * ya, int n, LDBLE xv, LDBLE * yv, LDBLE * dy)
|
|||||||
/*
|
/*
|
||||||
* Malloc work space
|
* Malloc work space
|
||||||
*/
|
*/
|
||||||
c = (LDBLE *) PHRQ_malloc((size_t) (n + 1) * sizeof(LDBLE));
|
c = (LDBLE *) PHRQ_malloc(((size_t)n + 1) * sizeof(LDBLE));
|
||||||
if (c == NULL)
|
if (c == NULL)
|
||||||
malloc_error();
|
malloc_error();
|
||||||
d = (LDBLE *) PHRQ_malloc((size_t) (n + 1) * sizeof(LDBLE));
|
d = (LDBLE *) PHRQ_malloc(((size_t)n + 1) * sizeof(LDBLE));
|
||||||
if (d == NULL)
|
if (d == NULL)
|
||||||
malloc_error();
|
malloc_error();
|
||||||
|
|
||||||
@ -775,7 +775,7 @@ calc_all_donnan(void)
|
|||||||
A_surf = charge_ptr->Get_specific_area() * charge_ptr->Get_grams();
|
A_surf = charge_ptr->Get_specific_area() * charge_ptr->Get_grams();
|
||||||
if (use.Get_surface_ptr()->Get_type() == cxxSurface::CD_MUSIC)
|
if (use.Get_surface_ptr()->Get_type() == cxxSurface::CD_MUSIC)
|
||||||
{
|
{
|
||||||
f_psi = x[j + 2]->master[0]->s->la * LOG_10; /* -FPsi/RT */
|
f_psi = x[(size_t)j + 2]->master[0]->s->la * LOG_10; /* -FPsi/RT */
|
||||||
f_psi = f_psi / 2;
|
f_psi = f_psi / 2;
|
||||||
cd_m = 1;
|
cd_m = 1;
|
||||||
} else
|
} else
|
||||||
@ -946,7 +946,7 @@ calc_init_donnan(void)
|
|||||||
A_surf = charge_ptr->Get_specific_area() * charge_ptr->Get_grams();
|
A_surf = charge_ptr->Get_specific_area() * charge_ptr->Get_grams();
|
||||||
if (use.Get_surface_ptr()->Get_type() == cxxSurface::CD_MUSIC)
|
if (use.Get_surface_ptr()->Get_type() == cxxSurface::CD_MUSIC)
|
||||||
{
|
{
|
||||||
f_psi = x[j + 2]->master[0]->s->la * LOG_10; /* -FPsi/RT */
|
f_psi = x[(size_t)j + 2]->master[0]->s->la * LOG_10; /* -FPsi/RT */
|
||||||
f_psi = f_psi / 2;
|
f_psi = f_psi / 2;
|
||||||
} else
|
} else
|
||||||
f_psi = x[j]->master[0]->s->la * LOG_10;
|
f_psi = x[j]->master[0]->s->la * LOG_10;
|
||||||
|
|||||||
@ -340,8 +340,8 @@ setup_inverse(struct inverse *inv_ptr)
|
|||||||
(size_t) max_column_count * sizeof(LDBLE));
|
(size_t) max_column_count * sizeof(LDBLE));
|
||||||
for (i = 0; i < max_row_count; i++)
|
for (i = 0; i < max_row_count; i++)
|
||||||
{
|
{
|
||||||
memcpy((void *) &(my_array[i * max_column_count]), (void *) &(inv_zero[0]),
|
memcpy((void *) &(my_array[(size_t)i * (size_t)max_column_count]), (void *) &(inv_zero[0]),
|
||||||
(size_t) max_column_count * sizeof(LDBLE));
|
(size_t)max_column_count * sizeof(LDBLE));
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
* begin filling array
|
* begin filling array
|
||||||
@ -434,11 +434,11 @@ setup_inverse(struct inverse *inv_ptr)
|
|||||||
{
|
{
|
||||||
if (master[j]->in >= 0)
|
if (master[j]->in >= 0)
|
||||||
{
|
{
|
||||||
my_array[master[j]->in * max_column_count + i] =
|
my_array[(size_t)master[j]->in * (size_t)max_column_count + (size_t)i] =
|
||||||
f * master[j]->total;
|
f * master[j]->total;
|
||||||
if (master[j]->s == s_eminus)
|
if (master[j]->s == s_eminus)
|
||||||
{
|
{
|
||||||
my_array[master[j]->in * max_column_count + i] = 0.0;
|
my_array[(size_t)master[j]->in * (size_t)max_column_count + (size_t)i] = 0.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -465,7 +465,7 @@ setup_inverse(struct inverse *inv_ptr)
|
|||||||
}
|
}
|
||||||
if (fabs(cb) < toler)
|
if (fabs(cb) < toler)
|
||||||
cb = 0.0;
|
cb = 0.0;
|
||||||
my_array[(row_charge + i) * max_column_count + i] = cb;
|
my_array[((size_t)row_charge + (size_t)i) * (size_t)max_column_count + (size_t)i] = cb;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* mass_balance: phase data */
|
/* mass_balance: phase data */
|
||||||
@ -511,11 +511,11 @@ setup_inverse(struct inverse *inv_ptr)
|
|||||||
coef = master_ptr->coef;
|
coef = master_ptr->coef;
|
||||||
if (coef <= 0)
|
if (coef <= 0)
|
||||||
coef = 1.0;
|
coef = 1.0;
|
||||||
my_array[row * max_column_count + column] =
|
my_array[(size_t)row * (size_t)max_column_count + (size_t)column] =
|
||||||
rxn_ptr->token[j].coef * coef;
|
rxn_ptr->token[j].coef * coef;
|
||||||
}
|
}
|
||||||
row = master_alk->in; /* include alkalinity for phase */
|
row = master_alk->in; /* include alkalinity for phase */
|
||||||
my_array[row * max_column_count + column] = calc_alk(rxn_ptr);
|
my_array[(size_t)row * (size_t)max_column_count + (size_t)column] = calc_alk(rxn_ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* mass balance: redox reaction data */
|
/* mass balance: redox reaction data */
|
||||||
@ -563,14 +563,14 @@ setup_inverse(struct inverse *inv_ptr)
|
|||||||
assert(row * max_column_count + column < max_column_count * max_row_count);
|
assert(row * max_column_count + column < max_column_count * max_row_count);
|
||||||
assert(row >= 0);
|
assert(row >= 0);
|
||||||
assert(column >= 0);
|
assert(column >= 0);
|
||||||
my_array[row * max_column_count + column] =
|
my_array[(size_t)row * (size_t)max_column_count + (size_t)column] =
|
||||||
rxn_ptr->token[j].coef;
|
rxn_ptr->token[j].coef;
|
||||||
/* if coefficient of element is not 1.0 in master species */
|
/* if coefficient of element is not 1.0 in master species */
|
||||||
if (j != 0)
|
if (j != 0)
|
||||||
my_array[row * max_column_count + column] /= coef;
|
my_array[(size_t)row * (size_t)max_column_count + (size_t)column] /= coef;
|
||||||
}
|
}
|
||||||
row = master_alk->in; /* include alkalinity for redox reaction */
|
row = master_alk->in; /* include alkalinity for redox reaction */
|
||||||
my_array[row * max_column_count + column] =
|
my_array[(size_t)row * (size_t)max_column_count + (size_t)column] =
|
||||||
(calc_alk(rxn_ptr) - inv_ptr->elts[i].master->s->alk) / coef;
|
(calc_alk(rxn_ptr) - inv_ptr->elts[i].master->s->alk) / coef;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -585,15 +585,15 @@ setup_inverse(struct inverse *inv_ptr)
|
|||||||
{
|
{
|
||||||
if (j < (inv_ptr->count_solns - 1))
|
if (j < (inv_ptr->count_solns - 1))
|
||||||
{
|
{
|
||||||
my_array[row * max_column_count + column] = 1.0;
|
my_array[(size_t)row * (size_t)max_column_count + (size_t)column] = 1.0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
my_array[row * max_column_count + column] = -1.0;
|
my_array[(size_t)row * (size_t)max_column_count + (size_t)column] = -1.0;
|
||||||
}
|
}
|
||||||
if (inv_ptr->elts[i].master->s == s_eminus)
|
if (inv_ptr->elts[i].master->s == s_eminus)
|
||||||
{
|
{
|
||||||
my_array[row * max_column_count + column] = 0.0;
|
my_array[(size_t)row * (size_t)max_column_count + (size_t)column] = 0.0;
|
||||||
}
|
}
|
||||||
sprintf(token, "%s %d", row_name[row], j);
|
sprintf(token, "%s %d", row_name[row], j);
|
||||||
col_name[column] = string_hsave(token);
|
col_name[column] = string_hsave(token);
|
||||||
@ -655,19 +655,19 @@ setup_inverse(struct inverse *inv_ptr)
|
|||||||
solution_ptr = Utilities::Rxn_find(Rxn_solution_map, inv_ptr->solns[i]);
|
solution_ptr = Utilities::Rxn_find(Rxn_solution_map, inv_ptr->solns[i]);
|
||||||
if (i < inv_ptr->count_solns - 1)
|
if (i < inv_ptr->count_solns - 1)
|
||||||
{
|
{
|
||||||
my_array[count_rows * max_column_count + i] =
|
my_array[(size_t)count_rows * (size_t)max_column_count + (size_t)i] =
|
||||||
1.0 / gfw_water * solution_ptr->Get_mass_water();
|
1.0 / gfw_water * solution_ptr->Get_mass_water();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
my_array[count_rows * max_column_count + inv_ptr->count_solns - 1] =
|
my_array[(size_t)count_rows * (size_t)max_column_count + (size_t)inv_ptr->count_solns - 1] =
|
||||||
-1.0 / gfw_water * solution_ptr->Get_mass_water();
|
-1.0 / gfw_water * solution_ptr->Get_mass_water();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* coefficient for water uncertainty */
|
/* coefficient for water uncertainty */
|
||||||
if (inv_ptr->water_uncertainty > 0)
|
if (inv_ptr->water_uncertainty > 0)
|
||||||
{
|
{
|
||||||
my_array[count_rows * max_column_count + col_water] = 1.0;
|
my_array[(size_t)count_rows * (size_t)max_column_count + (size_t)col_water] = 1.0;
|
||||||
}
|
}
|
||||||
row_name[count_rows] = string_hsave("H2O");
|
row_name[count_rows] = string_hsave("H2O");
|
||||||
row_water = count_rows;
|
row_water = count_rows;
|
||||||
@ -677,8 +677,8 @@ setup_inverse(struct inverse *inv_ptr)
|
|||||||
* Final solution fraction equals 1.0
|
* Final solution fraction equals 1.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
my_array[count_rows * max_column_count + inv_ptr->count_solns - 1] = 1.0;
|
my_array[(size_t)count_rows * (size_t)max_column_count + (size_t)inv_ptr->count_solns - 1] = 1.0;
|
||||||
my_array[count_rows * max_column_count + count_unknowns] = 1.0;
|
my_array[(size_t)count_rows * (size_t)max_column_count + (size_t)count_unknowns] = 1.0;
|
||||||
row_name[count_rows] = string_hsave("fract, final");
|
row_name[count_rows] = string_hsave("fract, final");
|
||||||
count_rows++;
|
count_rows++;
|
||||||
|
|
||||||
@ -689,7 +689,7 @@ setup_inverse(struct inverse *inv_ptr)
|
|||||||
for (i = 0; i < inv_ptr->count_solns; i++)
|
for (i = 0; i < inv_ptr->count_solns; i++)
|
||||||
{
|
{
|
||||||
/* solution_ptr = solution_bsearch(inv_ptr->solns[i], &j, TRUE); */
|
/* solution_ptr = solution_bsearch(inv_ptr->solns[i], &j, TRUE); */
|
||||||
/* array[count_rows * max_column_count + i] = solution_ptr->cb; */
|
/* array[(size_t)count_rows * (size_t)max_column_count + (size_t)i] = solution_ptr->cb; */
|
||||||
for (j = 0; j < inv_ptr->count_elts; j++)
|
for (j = 0; j < inv_ptr->count_elts; j++)
|
||||||
{
|
{
|
||||||
column = col_epsilon + j * inv_ptr->count_solns + i;
|
column = col_epsilon + j * inv_ptr->count_solns + i;
|
||||||
@ -700,10 +700,10 @@ setup_inverse(struct inverse *inv_ptr)
|
|||||||
{
|
{
|
||||||
coef = -1.0;
|
coef = -1.0;
|
||||||
}
|
}
|
||||||
my_array[count_rows * max_column_count + column] = coef;
|
my_array[(size_t)count_rows * (size_t)max_column_count + (size_t)column] = coef;
|
||||||
if (inv_ptr->elts[j].master->s == s_eminus)
|
if (inv_ptr->elts[j].master->s == s_eminus)
|
||||||
{
|
{
|
||||||
my_array[count_rows * max_column_count + column] = 0.0;
|
my_array[(size_t)count_rows * (size_t)max_column_count + (size_t)column] = 0.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sprintf(token, "%s %d", "charge", i);
|
sprintf(token, "%s %d", "charge", i);
|
||||||
@ -721,12 +721,12 @@ setup_inverse(struct inverse *inv_ptr)
|
|||||||
if (inv_ptr->dalk_dph[i] != 0 || inv_ptr->dalk_dc[i] != 0)
|
if (inv_ptr->dalk_dph[i] != 0 || inv_ptr->dalk_dc[i] != 0)
|
||||||
{
|
{
|
||||||
column = col_ph + i;
|
column = col_ph + i;
|
||||||
my_array[count_rows * max_column_count + column] =
|
my_array[(size_t)count_rows * (size_t)max_column_count + (size_t)column] =
|
||||||
inv_ptr->dalk_dph[i];
|
inv_ptr->dalk_dph[i];
|
||||||
column = col_epsilon + i_alk * inv_ptr->count_solns + i;
|
column = col_epsilon + i_alk * inv_ptr->count_solns + i;
|
||||||
my_array[count_rows * max_column_count + column] = -1.0;
|
my_array[(size_t)count_rows * (size_t)max_column_count + (size_t)column] = -1.0;
|
||||||
column = col_epsilon + i_carb * inv_ptr->count_solns + i;
|
column = col_epsilon + i_carb * inv_ptr->count_solns + i;
|
||||||
my_array[count_rows * max_column_count + column] =
|
my_array[(size_t)count_rows * (size_t)max_column_count + (size_t)column] =
|
||||||
inv_ptr->dalk_dc[i];
|
inv_ptr->dalk_dc[i];
|
||||||
}
|
}
|
||||||
sprintf(token, "%s %d", "dAlk", i);
|
sprintf(token, "%s %d", "dAlk", i);
|
||||||
@ -772,9 +772,8 @@ setup_inverse(struct inverse *inv_ptr)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
coef =
|
coef = my_array[(size_t)inv_ptr->elts[j].master->in *
|
||||||
my_array[inv_ptr->elts[j].master->in * max_column_count +
|
(size_t)max_column_count + (size_t)i] * coef;
|
||||||
i] * coef;
|
|
||||||
coef = fabs(coef);
|
coef = fabs(coef);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -786,7 +785,7 @@ setup_inverse(struct inverse *inv_ptr)
|
|||||||
{
|
{
|
||||||
for (k = 0; k < count_rows; k++)
|
for (k = 0; k < count_rows; k++)
|
||||||
{
|
{
|
||||||
my_array[k * max_column_count + column] = 0.0;
|
my_array[(size_t)k * (size_t)max_column_count + (size_t)column] = 0.0;
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -798,12 +797,12 @@ setup_inverse(struct inverse *inv_ptr)
|
|||||||
|
|
||||||
if (coef < toler)
|
if (coef < toler)
|
||||||
{
|
{
|
||||||
my_array[(column - col_epsilon) * max_column_count + column] =
|
my_array[((size_t)column - (size_t)col_epsilon) * (size_t)max_column_count + (size_t)column] =
|
||||||
SCALE_EPSILON / toler;
|
SCALE_EPSILON / toler;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
my_array[(column - col_epsilon) * max_column_count + column] =
|
my_array[((size_t)column - (size_t)col_epsilon) * (size_t)max_column_count + (size_t)column] =
|
||||||
SCALE_EPSILON / coef;
|
SCALE_EPSILON / coef;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -817,15 +816,14 @@ setup_inverse(struct inverse *inv_ptr)
|
|||||||
{
|
{
|
||||||
f = 1.0;
|
f = 1.0;
|
||||||
}
|
}
|
||||||
my_array[count_rows * max_column_count + column] = 1.0 * f;
|
my_array[(size_t)count_rows * (size_t)max_column_count + (size_t)column] = 1.0 * f;
|
||||||
my_array[count_rows * max_column_count + i] = -coef * f;
|
my_array[(size_t)count_rows * (size_t)max_column_count + (size_t)i] = -coef * f;
|
||||||
sprintf(token, "%s %s", inv_ptr->elts[j].master->elt->name,
|
sprintf(token, "%s %s", inv_ptr->elts[j].master->elt->name, "eps+");
|
||||||
"eps+");
|
|
||||||
row_name[count_rows] = string_hsave(token);
|
row_name[count_rows] = string_hsave(token);
|
||||||
count_rows++;
|
count_rows++;
|
||||||
|
|
||||||
/* set lower limit of change in negative direction */
|
/* set lower limit of change in negative direction */
|
||||||
conc = my_array[inv_ptr->elts[j].master->in * max_column_count + i];
|
conc = my_array[(size_t)inv_ptr->elts[j].master->in * (size_t)max_column_count + (size_t)i];
|
||||||
|
|
||||||
/* if concentration is zero, only positive direction allowed */
|
/* if concentration is zero, only positive direction allowed */
|
||||||
if (conc == 0.0)
|
if (conc == 0.0)
|
||||||
@ -852,8 +850,8 @@ setup_inverse(struct inverse *inv_ptr)
|
|||||||
inv_ptr->elts[j].master->elt->name))
|
inv_ptr->elts[j].master->elt->name))
|
||||||
coef = fabs(conc) + toler;
|
coef = fabs(conc) + toler;
|
||||||
|
|
||||||
my_array[count_rows * max_column_count + i] = -coef * f;
|
my_array[(size_t)count_rows * (size_t)max_column_count + (size_t)i] = -coef * f;
|
||||||
my_array[count_rows * max_column_count + column] = -1.0 * f;
|
my_array[(size_t)count_rows * (size_t)max_column_count + (size_t)column] = -1.0 * f;
|
||||||
sprintf(token, "%s %s", inv_ptr->elts[j].master->elt->name,
|
sprintf(token, "%s %s", inv_ptr->elts[j].master->elt->name,
|
||||||
"eps-");
|
"eps-");
|
||||||
row_name[count_rows] = string_hsave(token);
|
row_name[count_rows] = string_hsave(token);
|
||||||
@ -873,21 +871,21 @@ setup_inverse(struct inverse *inv_ptr)
|
|||||||
|
|
||||||
/* scale epsilon in optimization equation */
|
/* scale epsilon in optimization equation */
|
||||||
|
|
||||||
my_array[(column - col_epsilon) * max_column_count + column] =
|
my_array[((size_t)column - (size_t)col_epsilon) * (size_t)max_column_count + (size_t)column] =
|
||||||
SCALE_EPSILON / coef;
|
SCALE_EPSILON / coef;
|
||||||
|
|
||||||
/* set upper limit of change in positive direction */
|
/* set upper limit of change in positive direction */
|
||||||
|
|
||||||
my_array[count_rows * max_column_count + column] = 1.0;
|
my_array[(size_t)count_rows * (size_t)max_column_count + (size_t)column] = 1.0;
|
||||||
my_array[count_rows * max_column_count + i] = -coef;
|
my_array[(size_t)count_rows * (size_t)max_column_count + (size_t)i] = -coef;
|
||||||
sprintf(token, "%s %s", "pH", "eps+");
|
sprintf(token, "%s %s", "pH", "eps+");
|
||||||
row_name[count_rows] = string_hsave(token);
|
row_name[count_rows] = string_hsave(token);
|
||||||
count_rows++;
|
count_rows++;
|
||||||
|
|
||||||
/* set lower limit of change in negative direction */
|
/* set lower limit of change in negative direction */
|
||||||
|
|
||||||
my_array[count_rows * max_column_count + column] = -1.0;
|
my_array[(size_t)count_rows * (size_t)max_column_count + (size_t)column] = -1.0;
|
||||||
my_array[count_rows * max_column_count + i] = -coef;
|
my_array[(size_t)count_rows * (size_t)max_column_count + (size_t)i] = -coef;
|
||||||
sprintf(token, "%s %s", "pH", "eps-");
|
sprintf(token, "%s %s", "pH", "eps-");
|
||||||
row_name[count_rows] = string_hsave(token);
|
row_name[count_rows] = string_hsave(token);
|
||||||
count_rows++;
|
count_rows++;
|
||||||
@ -902,16 +900,16 @@ setup_inverse(struct inverse *inv_ptr)
|
|||||||
if (coef > 0.0)
|
if (coef > 0.0)
|
||||||
{
|
{
|
||||||
/* set upper limit of change in positive direction */
|
/* set upper limit of change in positive direction */
|
||||||
my_array[count_rows * max_column_count + column] = 1.0;
|
my_array[(size_t)count_rows * (size_t)max_column_count + (size_t)column] = 1.0;
|
||||||
my_array[count_rows * max_column_count + count_unknowns] = coef;
|
my_array[(size_t)count_rows * (size_t)max_column_count + (size_t)count_unknowns] = coef;
|
||||||
sprintf(token, "%s %s", "water", "eps+");
|
sprintf(token, "%s %s", "water", "eps+");
|
||||||
row_name[count_rows] = string_hsave(token);
|
row_name[count_rows] = string_hsave(token);
|
||||||
count_rows++;
|
count_rows++;
|
||||||
|
|
||||||
/* set lower limit of change in negative direction */
|
/* set lower limit of change in negative direction */
|
||||||
|
|
||||||
my_array[count_rows * max_column_count + column] = -1.0;
|
my_array[(size_t)count_rows * (size_t)max_column_count + (size_t)column] = -1.0;
|
||||||
my_array[count_rows * max_column_count + count_unknowns] = coef;
|
my_array[(size_t)count_rows * (size_t)max_column_count + (size_t)count_unknowns] = coef;
|
||||||
sprintf(token, "%s %s", "water", "eps-");
|
sprintf(token, "%s %s", "water", "eps-");
|
||||||
row_name[count_rows] = string_hsave(token);
|
row_name[count_rows] = string_hsave(token);
|
||||||
count_rows++;
|
count_rows++;
|
||||||
@ -943,12 +941,12 @@ setup_inverse(struct inverse *inv_ptr)
|
|||||||
|
|
||||||
/* scale epsilon in optimization equation */
|
/* scale epsilon in optimization equation */
|
||||||
|
|
||||||
my_array[(column - col_epsilon) * max_column_count +
|
my_array[((size_t)column - (size_t)col_epsilon) * (size_t)max_column_count +
|
||||||
column] = SCALE_EPSILON / coef;
|
(size_t)column] = SCALE_EPSILON / coef;
|
||||||
|
|
||||||
/* set upper limit of change in positive direction */
|
/* set upper limit of change in positive direction */
|
||||||
my_array[count_rows * max_column_count + column] = 1.0;
|
my_array[(size_t)count_rows * (size_t)max_column_count + (size_t)column] = 1.0;
|
||||||
my_array[count_rows * max_column_count + i] = -coef;
|
my_array[(size_t)count_rows * (size_t)max_column_count + (size_t)i] = -coef;
|
||||||
sprintf(token, "%d%s %s",
|
sprintf(token, "%d%s %s",
|
||||||
(int) kit->second.Get_isotope_number(),
|
(int) kit->second.Get_isotope_number(),
|
||||||
kit->second.Get_elt_name().c_str(), "eps+");
|
kit->second.Get_elt_name().c_str(), "eps+");
|
||||||
@ -957,8 +955,8 @@ setup_inverse(struct inverse *inv_ptr)
|
|||||||
|
|
||||||
/* set lower limit of change in negative direction */
|
/* set lower limit of change in negative direction */
|
||||||
|
|
||||||
my_array[count_rows * max_column_count + column] = -1.0;
|
my_array[(size_t)count_rows * (size_t)max_column_count + (size_t)column] = -1.0;
|
||||||
my_array[count_rows * max_column_count + i] = -coef;
|
my_array[(size_t)count_rows * (size_t)max_column_count + (size_t)i] = -coef;
|
||||||
sprintf(token, "%d%s %s",
|
sprintf(token, "%d%s %s",
|
||||||
(int) kit->second.Get_isotope_number(),
|
(int) kit->second.Get_isotope_number(),
|
||||||
kit->second.Get_elt_name().c_str(), "eps-");
|
kit->second.Get_elt_name().c_str(), "eps-");
|
||||||
@ -987,11 +985,11 @@ setup_inverse(struct inverse *inv_ptr)
|
|||||||
{
|
{
|
||||||
if (inv_ptr->phases[i].constraint == PRECIPITATE)
|
if (inv_ptr->phases[i].constraint == PRECIPITATE)
|
||||||
{
|
{
|
||||||
delta[col_phases + i] = -1.0;
|
delta[(size_t)col_phases + (size_t)i] = -1.0;
|
||||||
}
|
}
|
||||||
else if (inv_ptr->phases[i].constraint == DISSOLVE)
|
else if (inv_ptr->phases[i].constraint == DISSOLVE)
|
||||||
{
|
{
|
||||||
delta[col_phases + i] = 1.0;
|
delta[(size_t)col_phases + (size_t)i] = 1.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (i = 0; i < (inv_ptr->count_solns - 1); i++)
|
for (i = 0; i < (inv_ptr->count_solns - 1); i++)
|
||||||
@ -1003,7 +1001,7 @@ setup_inverse(struct inverse *inv_ptr)
|
|||||||
*/
|
*/
|
||||||
for (i = 0; i < max_column_count; i++)
|
for (i = 0; i < max_column_count; i++)
|
||||||
{
|
{
|
||||||
my_array[row_water * max_column_count + i] *= SCALE_WATER;
|
my_array[(size_t)row_water * (size_t)max_column_count + (size_t)i] *= SCALE_WATER;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
* Arrays are complete
|
* Arrays are complete
|
||||||
@ -1025,8 +1023,8 @@ setup_inverse(struct inverse *inv_ptr)
|
|||||||
output_msg(sformatf( "\n"));
|
output_msg(sformatf( "\n"));
|
||||||
k = 0;
|
k = 0;
|
||||||
}
|
}
|
||||||
output_msg(sformatf( "%11.2e",
|
output_msg(sformatf("%11.2e",
|
||||||
(double) my_array[i * max_column_count + j]));
|
(double)my_array[(size_t)i * (size_t)max_column_count + (size_t)j]));
|
||||||
k++;
|
k++;
|
||||||
}
|
}
|
||||||
if (k != 0)
|
if (k != 0)
|
||||||
@ -1115,8 +1113,8 @@ solve_inverse(struct inverse *inv_ptr)
|
|||||||
inv_cu = (LDBLE *) PHRQ_malloc((size_t) 2 * nklmd * sizeof(LDBLE));
|
inv_cu = (LDBLE *) PHRQ_malloc((size_t) 2 * nklmd * sizeof(LDBLE));
|
||||||
if (inv_cu == NULL)
|
if (inv_cu == NULL)
|
||||||
malloc_error();
|
malloc_error();
|
||||||
memset(inv_cu, 0, ((size_t) (2 * nklmd * sizeof(LDBLE))));
|
memset(inv_cu, 0, ((2 * (size_t)nklmd * sizeof(LDBLE))));
|
||||||
inv_iu = (int *) PHRQ_malloc((size_t) 2 * nklmd * sizeof(int));
|
inv_iu = (int *) PHRQ_malloc(2 * (size_t)nklmd * sizeof(int));
|
||||||
if (inv_iu == NULL)
|
if (inv_iu == NULL)
|
||||||
malloc_error();
|
malloc_error();
|
||||||
inv_is = (int *) PHRQ_malloc((size_t) klmd * sizeof(int));
|
inv_is = (int *) PHRQ_malloc((size_t) klmd * sizeof(int));
|
||||||
@ -2769,8 +2767,8 @@ shrink(struct inverse *inv_ptr, LDBLE * array_in, LDBLE * array_out,
|
|||||||
|
|
||||||
|
|
||||||
memcpy(&(array_out[row * max_column_count]),
|
memcpy(&(array_out[row * max_column_count]),
|
||||||
&(array_out[i * max_column_count]),
|
&(array_out[(size_t)i * (size_t)max_column_count]),
|
||||||
(size_t) (*n + 1) * sizeof(LDBLE));
|
((size_t)*n + 1) * sizeof(LDBLE));
|
||||||
}
|
}
|
||||||
row_back_l[row] = i;
|
row_back_l[row] = i;
|
||||||
row++;
|
row++;
|
||||||
@ -2813,8 +2811,8 @@ shrink(struct inverse *inv_ptr, LDBLE * array_in, LDBLE * array_out,
|
|||||||
assert(false);
|
assert(false);
|
||||||
}
|
}
|
||||||
memcpy(&(array_out[row * max_column_count]),
|
memcpy(&(array_out[row * max_column_count]),
|
||||||
&(array_out[i * max_column_count]),
|
&(array_out[(size_t)i * (size_t)max_column_count]),
|
||||||
(size_t) (*n + 1) * sizeof(LDBLE));
|
((size_t)*n + 1) * sizeof(LDBLE));
|
||||||
}
|
}
|
||||||
row_back_l[row] = i;
|
row_back_l[row] = i;
|
||||||
row++;
|
row++;
|
||||||
@ -2855,9 +2853,9 @@ shrink(struct inverse *inv_ptr, LDBLE * array_in, LDBLE * array_out,
|
|||||||
{
|
{
|
||||||
assert(false);
|
assert(false);
|
||||||
}
|
}
|
||||||
memcpy(&(array_out[row * max_column_count]),
|
memcpy(&(array_out[(size_t)row * (size_t)max_column_count]),
|
||||||
&(array_out[i * max_column_count]),
|
&(array_out[(size_t)i * (size_t)max_column_count]),
|
||||||
(size_t) (*n + 1) * sizeof(LDBLE));
|
((size_t)*n + 1) * sizeof(LDBLE));
|
||||||
}
|
}
|
||||||
row_back_l[row] = i;
|
row_back_l[row] = i;
|
||||||
row++;
|
row++;
|
||||||
@ -3079,16 +3077,16 @@ post_mortem(void)
|
|||||||
sum = 0;
|
sum = 0;
|
||||||
for (j = 0; j < count_unknowns; j++)
|
for (j = 0; j < count_unknowns; j++)
|
||||||
{
|
{
|
||||||
sum += inv_delta1[j] * my_array[i * max_column_count + j];
|
sum += inv_delta1[j] * my_array[(size_t)i * (size_t)max_column_count + (size_t)j];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (equal(sum, my_array[(i * max_column_count) + count_unknowns], toler)
|
if (equal(sum, my_array[((size_t)i * (size_t)max_column_count) + (size_t)count_unknowns], toler)
|
||||||
== FALSE)
|
== FALSE)
|
||||||
{
|
{
|
||||||
output_msg(sformatf(
|
output_msg(sformatf(
|
||||||
"\tERROR: equality not satisfied for %s, %e.\n",
|
"\tERROR: equality not satisfied for %s, %e.\n",
|
||||||
row_name[i],
|
row_name[i],
|
||||||
(double) (sum - my_array[(i * max_column_count) + count_unknowns])));
|
(double) (sum - my_array[((size_t)i * (size_t)max_column_count) + (size_t)count_unknowns])));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
@ -3099,15 +3097,15 @@ post_mortem(void)
|
|||||||
sum = 0;
|
sum = 0;
|
||||||
for (j = 0; j < count_unknowns; j++)
|
for (j = 0; j < count_unknowns; j++)
|
||||||
{
|
{
|
||||||
sum += inv_delta1[j] * my_array[i * max_column_count + j];
|
sum += inv_delta1[j] * my_array[(size_t)i * (size_t)max_column_count + (size_t)j];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sum > my_array[(i * max_column_count) + count_unknowns] + toler)
|
if (sum > my_array[((size_t)i * (size_t)max_column_count) + (size_t)count_unknowns] + toler)
|
||||||
{
|
{
|
||||||
output_msg(sformatf(
|
output_msg(sformatf(
|
||||||
"\tERROR: inequality not satisfied for %s, %e\n",
|
"\tERROR: inequality not satisfied for %s, %e\n",
|
||||||
row_name[i],
|
row_name[i],
|
||||||
(double) (sum - my_array[(i * max_column_count) + count_unknowns])));
|
(double) (sum - my_array[((size_t)i * (size_t)max_column_count) + (size_t)count_unknowns])));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
@ -3156,15 +3154,15 @@ test_cl1_solution(void)
|
|||||||
sum = 0;
|
sum = 0;
|
||||||
for (j = 0; j < count_unknowns; j++)
|
for (j = 0; j < count_unknowns; j++)
|
||||||
{
|
{
|
||||||
sum += inv_delta1[j] * my_array[i * max_column_count + j];
|
sum += inv_delta1[j] * my_array[(size_t)i * (size_t)max_column_count + (size_t)j];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (equal(sum, my_array[(i * max_column_count) + count_unknowns], toler) == FALSE)
|
if (equal(sum, my_array[((size_t)i * (size_t)max_column_count) + (size_t)count_unknowns], toler) == FALSE)
|
||||||
{
|
{
|
||||||
if (debug_inverse)
|
if (debug_inverse)
|
||||||
{
|
{
|
||||||
output_msg(sformatf("\tERROR: equality not satisfied for %s, %e.\n", row_name[i],
|
output_msg(sformatf("\tERROR: equality not satisfied for %s, %e.\n", row_name[i],
|
||||||
(double) (sum - my_array[(i * max_column_count) + count_unknowns])));
|
(double) (sum - my_array[((size_t)i * (size_t)max_column_count) + (size_t)count_unknowns])));
|
||||||
}
|
}
|
||||||
rv = false;
|
rv = false;
|
||||||
}
|
}
|
||||||
@ -3177,17 +3175,17 @@ test_cl1_solution(void)
|
|||||||
sum = 0;
|
sum = 0;
|
||||||
for (j = 0; j < count_unknowns; j++)
|
for (j = 0; j < count_unknowns; j++)
|
||||||
{
|
{
|
||||||
sum += inv_delta1[j] * my_array[i * max_column_count + j];
|
sum += inv_delta1[j] * my_array[(size_t)i * (size_t)max_column_count + (size_t)j];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sum > my_array[(i * max_column_count) + count_unknowns] + toler)
|
if (sum > my_array[((size_t)i * (size_t)max_column_count) + (size_t)count_unknowns] + toler)
|
||||||
{
|
{
|
||||||
if (debug_inverse)
|
if (debug_inverse)
|
||||||
{
|
{
|
||||||
output_msg(sformatf(
|
output_msg(sformatf(
|
||||||
"\tERROR: inequality not satisfied for %s, %e\n",
|
"\tERROR: inequality not satisfied for %s, %e\n",
|
||||||
row_name[i],
|
row_name[i],
|
||||||
(double) (sum - my_array[(i * max_column_count) + count_unknowns])));
|
(double) (sum - my_array[((size_t)i * (size_t)max_column_count) + (size_t)count_unknowns])));
|
||||||
}
|
}
|
||||||
rv = false;
|
rv = false;
|
||||||
}
|
}
|
||||||
@ -3440,7 +3438,7 @@ isotope_balance_equation(struct inverse *inv_ptr, int row, int n)
|
|||||||
if (primary_jit == primary_ptr &&
|
if (primary_jit == primary_ptr &&
|
||||||
jit->second.Get_isotope_number() == isotope_number)
|
jit->second.Get_isotope_number() == isotope_number)
|
||||||
{
|
{
|
||||||
my_array[row * max_column_count + i] +=
|
my_array[(size_t)row * (size_t)max_column_count + (size_t)i] +=
|
||||||
f * jit->second.Get_total() * jit->second.Get_ratio();
|
f * jit->second.Get_total() * jit->second.Get_ratio();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3465,7 +3463,7 @@ isotope_balance_equation(struct inverse *inv_ptr, int row, int n)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
column = col_epsilon + (k * inv_ptr->count_solns) + i;
|
column = col_epsilon + (k * inv_ptr->count_solns) + i;
|
||||||
my_array[row * max_column_count + column] +=
|
my_array[(size_t)row * (size_t)max_column_count + (size_t)column] +=
|
||||||
f * jit->second.Get_ratio();
|
f * jit->second.Get_ratio();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3493,7 +3491,7 @@ isotope_balance_equation(struct inverse *inv_ptr, int row, int n)
|
|||||||
(i * inv_ptr->count_isotope_unknowns) + k;
|
(i * inv_ptr->count_isotope_unknowns) + k;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
my_array[row * max_column_count + column] +=
|
my_array[(size_t)row * (size_t)max_column_count + (size_t)column] +=
|
||||||
f * jit->second.Get_total();
|
f * jit->second.Get_total();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3513,11 +3511,11 @@ isotope_balance_equation(struct inverse *inv_ptr, int row, int n)
|
|||||||
{
|
{
|
||||||
/* term for alpha phase unknowns */
|
/* term for alpha phase unknowns */
|
||||||
column = col_phases + i;
|
column = col_phases + i;
|
||||||
my_array[row * max_column_count + column] =
|
my_array[(size_t)row * (size_t)max_column_count + (size_t)column] =
|
||||||
isotope_ptr[j].ratio * isotope_ptr[j].coef;
|
isotope_ptr[j].ratio * isotope_ptr[j].coef;
|
||||||
/* term for phase isotope uncertainty unknown */
|
/* term for phase isotope uncertainty unknown */
|
||||||
column = col_phase_isotopes + i * inv_ptr->count_isotopes + n;
|
column = col_phase_isotopes + i * inv_ptr->count_isotopes + n;
|
||||||
my_array[row * max_column_count + column] = isotope_ptr[j].coef;
|
my_array[(size_t)row * (size_t)max_column_count + (size_t)column] = isotope_ptr[j].coef;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3583,11 +3581,8 @@ count_isotope_unknowns(struct inverse *inv_ptr,
|
|||||||
/* nonredox element */
|
/* nonredox element */
|
||||||
if (primary_ptr->s->secondary == NULL)
|
if (primary_ptr->s->secondary == NULL)
|
||||||
{
|
{
|
||||||
isotopes =
|
isotopes = (struct isotope *) PHRQ_realloc(isotopes,
|
||||||
(struct isotope *) PHRQ_realloc(isotopes,
|
((size_t)count_isotopes + 1) * sizeof(struct isotope));
|
||||||
(size_t) (count_isotopes +
|
|
||||||
1) *
|
|
||||||
sizeof(struct isotope));
|
|
||||||
if (isotopes == NULL)
|
if (isotopes == NULL)
|
||||||
{
|
{
|
||||||
malloc_error();
|
malloc_error();
|
||||||
@ -3617,12 +3612,8 @@ count_isotope_unknowns(struct inverse *inv_ptr,
|
|||||||
{
|
{
|
||||||
if (master[k]->elt->primary != primary_ptr)
|
if (master[k]->elt->primary != primary_ptr)
|
||||||
break;
|
break;
|
||||||
isotopes =
|
isotopes = (struct isotope *) PHRQ_realloc(isotopes,
|
||||||
(struct isotope *) PHRQ_realloc(isotopes,
|
((size_t)count_isotopes + 1) * sizeof(struct isotope));
|
||||||
(size_t) (count_isotopes
|
|
||||||
+
|
|
||||||
1) *
|
|
||||||
sizeof(struct isotope));
|
|
||||||
if (isotopes == NULL)
|
if (isotopes == NULL)
|
||||||
{
|
{
|
||||||
malloc_error();
|
malloc_error();
|
||||||
@ -3759,7 +3750,7 @@ check_isotopes(struct inverse *inv_ptr)
|
|||||||
&& !isnan(inv_ptr->i_u[i].uncertainties[inv_ptr->i_u[i].count_uncertainties - 1]))
|
&& !isnan(inv_ptr->i_u[i].uncertainties[inv_ptr->i_u[i].count_uncertainties - 1]))
|
||||||
#else
|
#else
|
||||||
else if (inv_ptr->i_u[i].count_uncertainties > 0
|
else if (inv_ptr->i_u[i].count_uncertainties > 0
|
||||||
&& inv_ptr->i_u[i].uncertainties[inv_ptr->i_u[i].count_uncertainties - 1] != NAN)
|
&& inv_ptr->i_u[i].uncertainties[(size_t)inv_ptr->i_u[i].count_uncertainties - 1] != NAN)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
kit->second.Set_x_ratio_uncertainty(inv_ptr->i_u[i].uncertainties[inv_ptr->i_u[i].count_uncertainties - 1]);
|
kit->second.Set_x_ratio_uncertainty(inv_ptr->i_u[i].uncertainties[inv_ptr->i_u[i].count_uncertainties - 1]);
|
||||||
@ -3905,7 +3896,7 @@ phase_isotope_inequalities(struct inverse *inv_ptr)
|
|||||||
{
|
{
|
||||||
for (k = 0; k < count_rows; k++)
|
for (k = 0; k < count_rows; k++)
|
||||||
{
|
{
|
||||||
my_array[k * max_column_count + column] = 0.0;
|
my_array[(size_t)k * (size_t)max_column_count + (size_t)column] = 0.0;
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -3913,26 +3904,25 @@ phase_isotope_inequalities(struct inverse *inv_ptr)
|
|||||||
/*
|
/*
|
||||||
* optimization
|
* optimization
|
||||||
*/
|
*/
|
||||||
my_array[(column - col_epsilon) * max_column_count + column] =
|
my_array[((size_t)column - (size_t)col_epsilon) * (size_t)max_column_count + (size_t)column] =
|
||||||
SCALE_EPSILON /
|
SCALE_EPSILON / inv_ptr->phases[i].isotopes[j].ratio_uncertainty;
|
||||||
inv_ptr->phases[i].isotopes[j].ratio_uncertainty;
|
|
||||||
/*
|
/*
|
||||||
* two inequalities to account for absolute value
|
* two inequalities to account for absolute value
|
||||||
*/
|
*/
|
||||||
/* for phases constrained to precipitate */
|
/* for phases constrained to precipitate */
|
||||||
if (inv_ptr->phases[i].constraint == PRECIPITATE)
|
if (inv_ptr->phases[i].constraint == PRECIPITATE)
|
||||||
{
|
{
|
||||||
my_array[count_rows * max_column_count + col_phases + i] =
|
my_array[(size_t)count_rows * (size_t)max_column_count + (size_t)col_phases + (size_t)i] =
|
||||||
inv_ptr->phases[i].isotopes[j].ratio_uncertainty;
|
inv_ptr->phases[i].isotopes[j].ratio_uncertainty;
|
||||||
my_array[count_rows * max_column_count + column] = 1.0;
|
my_array[(size_t)count_rows * (size_t)max_column_count + (size_t)column] = 1.0;
|
||||||
sprintf(token, "%s %s", inv_ptr->phases[i].phase->name,
|
sprintf(token, "%s %s", inv_ptr->phases[i].phase->name,
|
||||||
"iso pos");
|
"iso pos");
|
||||||
row_name[count_rows] = string_hsave(token);
|
row_name[count_rows] = string_hsave(token);
|
||||||
count_rows++;
|
count_rows++;
|
||||||
|
|
||||||
my_array[count_rows * max_column_count + col_phases + i] =
|
my_array[(size_t)count_rows * (size_t)max_column_count + (size_t)col_phases + (size_t)i] =
|
||||||
inv_ptr->phases[i].isotopes[j].ratio_uncertainty;
|
inv_ptr->phases[i].isotopes[j].ratio_uncertainty;
|
||||||
my_array[count_rows * max_column_count + column] = -1.0;
|
my_array[(size_t)count_rows * (size_t)max_column_count + (size_t)column] = -1.0;
|
||||||
sprintf(token, "%s %s", inv_ptr->phases[i].phase->name,
|
sprintf(token, "%s %s", inv_ptr->phases[i].phase->name,
|
||||||
"iso neg");
|
"iso neg");
|
||||||
row_name[count_rows] = string_hsave(token);
|
row_name[count_rows] = string_hsave(token);
|
||||||
@ -3942,17 +3932,17 @@ phase_isotope_inequalities(struct inverse *inv_ptr)
|
|||||||
}
|
}
|
||||||
else if (inv_ptr->phases[i].constraint == DISSOLVE)
|
else if (inv_ptr->phases[i].constraint == DISSOLVE)
|
||||||
{
|
{
|
||||||
my_array[count_rows * max_column_count + col_phases + i] =
|
my_array[(size_t)count_rows * (size_t)max_column_count + (size_t)col_phases + (size_t)i] =
|
||||||
-inv_ptr->phases[i].isotopes[j].ratio_uncertainty;
|
-inv_ptr->phases[i].isotopes[j].ratio_uncertainty;
|
||||||
my_array[count_rows * max_column_count + column] = -1.0;
|
my_array[(size_t)count_rows * (size_t)max_column_count + (size_t)column] = -1.0;
|
||||||
sprintf(token, "%s %s", inv_ptr->phases[i].phase->name,
|
sprintf(token, "%s %s", inv_ptr->phases[i].phase->name,
|
||||||
"iso pos");
|
"iso pos");
|
||||||
row_name[count_rows] = string_hsave(token);
|
row_name[count_rows] = string_hsave(token);
|
||||||
count_rows++;
|
count_rows++;
|
||||||
|
|
||||||
my_array[count_rows * max_column_count + col_phases + i] =
|
my_array[(size_t)count_rows * (size_t)max_column_count + (size_t)col_phases + (size_t)i] =
|
||||||
-inv_ptr->phases[i].isotopes[j].ratio_uncertainty;
|
-inv_ptr->phases[i].isotopes[j].ratio_uncertainty;
|
||||||
my_array[count_rows * max_column_count + column] = 1.0;
|
my_array[(size_t)count_rows * (size_t)max_column_count + (size_t)column] = 1.0;
|
||||||
sprintf(token, "%s %s", inv_ptr->phases[i].phase->name,
|
sprintf(token, "%s %s", inv_ptr->phases[i].phase->name,
|
||||||
"iso neg");
|
"iso neg");
|
||||||
row_name[count_rows] = string_hsave(token);
|
row_name[count_rows] = string_hsave(token);
|
||||||
|
|||||||
@ -247,10 +247,8 @@ read_calculate_values(void)
|
|||||||
{
|
{
|
||||||
length = (int) strlen(calculate_value_ptr->commands);
|
length = (int) strlen(calculate_value_ptr->commands);
|
||||||
line_length = (int) strlen(line);
|
line_length = (int) strlen(line);
|
||||||
calculate_value_ptr->commands =
|
calculate_value_ptr->commands = (char *)PHRQ_realloc(calculate_value_ptr->commands,
|
||||||
(char *) PHRQ_realloc(calculate_value_ptr->commands,
|
((size_t)length + (size_t)line_length + 2) * sizeof(char));
|
||||||
(size_t) (length + line_length +
|
|
||||||
2) * sizeof(char));
|
|
||||||
if (calculate_value_ptr->commands == NULL)
|
if (calculate_value_ptr->commands == NULL)
|
||||||
malloc_error();
|
malloc_error();
|
||||||
calculate_value_ptr->commands[length] = ';';
|
calculate_value_ptr->commands[length] = ';';
|
||||||
@ -1547,8 +1545,7 @@ calculate_value_alloc(void)
|
|||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
struct calculate_value *calculate_value_ptr;
|
struct calculate_value *calculate_value_ptr;
|
||||||
calculate_value_ptr =
|
calculate_value_ptr = (struct calculate_value *)
|
||||||
(struct calculate_value *)
|
|
||||||
PHRQ_malloc(sizeof(struct calculate_value));
|
PHRQ_malloc(sizeof(struct calculate_value));
|
||||||
if (calculate_value_ptr == NULL)
|
if (calculate_value_ptr == NULL)
|
||||||
malloc_error();
|
malloc_error();
|
||||||
|
|||||||
@ -858,8 +858,9 @@ rk_kinetics(int i, LDBLE kin_time, int use_mix, int nsaver,
|
|||||||
/* define reaction for calculating k5 */
|
/* define reaction for calculating k5 */
|
||||||
rk_moles[k + j] = kinetics_comp_ptr->Get_moles();
|
rk_moles[k + j] = kinetics_comp_ptr->Get_moles();
|
||||||
kinetics_comp_ptr->Set_moles(b51 * rk_moles[j]
|
kinetics_comp_ptr->Set_moles(b51 * rk_moles[j]
|
||||||
+ 2.5 * rk_moles[n_reactions + j]
|
+ 2.5 * rk_moles[(size_t)n_reactions + j]
|
||||||
+ b53 * rk_moles[2 * n_reactions + j] + b54 * rk_moles[k + j]);
|
+ b53 * rk_moles[2 * (size_t)n_reactions + j]
|
||||||
|
+ b54 * rk_moles[(size_t)k + (size_t)j]);
|
||||||
}
|
}
|
||||||
if (moles_reduction > 1.0)
|
if (moles_reduction > 1.0)
|
||||||
goto MOLES_TOO_LARGE;
|
goto MOLES_TOO_LARGE;
|
||||||
@ -910,9 +911,10 @@ rk_kinetics(int i, LDBLE kin_time, int use_mix, int nsaver,
|
|||||||
/* define reaction for calculating k6 */
|
/* define reaction for calculating k6 */
|
||||||
rk_moles[k + j] = kinetics_comp_ptr->Get_moles();
|
rk_moles[k + j] = kinetics_comp_ptr->Get_moles();
|
||||||
kinetics_comp_ptr->Set_moles(b61 * rk_moles[j]
|
kinetics_comp_ptr->Set_moles(b61 * rk_moles[j]
|
||||||
+ b62 * rk_moles[n_reactions + j]
|
+ b62 * rk_moles[(size_t)n_reactions + j]
|
||||||
+ b63 * rk_moles[2 * n_reactions + j]
|
+ b63 * rk_moles[2 * (size_t)n_reactions + j]
|
||||||
+ b64 * rk_moles[3 * n_reactions + j] + b65 * rk_moles[k + j]);
|
+ b64 * rk_moles[3 * (size_t)n_reactions + j]
|
||||||
|
+ b65 * rk_moles[(size_t)k + (size_t)j]);
|
||||||
}
|
}
|
||||||
if (moles_reduction > 1.0)
|
if (moles_reduction > 1.0)
|
||||||
goto MOLES_TOO_LARGE;
|
goto MOLES_TOO_LARGE;
|
||||||
@ -964,10 +966,10 @@ rk_kinetics(int i, LDBLE kin_time, int use_mix, int nsaver,
|
|||||||
{
|
{
|
||||||
cxxKineticsComp * kinetics_comp_ptr = &(kinetics_ptr->Get_kinetics_comps()[j]);
|
cxxKineticsComp * kinetics_comp_ptr = &(kinetics_ptr->Get_kinetics_comps()[j]);
|
||||||
l_error = fabs(dc1 * rk_moles[j]
|
l_error = fabs(dc1 * rk_moles[j]
|
||||||
+ dc3 * rk_moles[2 * n_reactions + j]
|
+ dc3 * rk_moles[2 * (size_t)n_reactions + (size_t)j]
|
||||||
+ dc4 * rk_moles[3 * n_reactions + j]
|
+ dc4 * rk_moles[3 * (size_t)n_reactions + (size_t)j]
|
||||||
+ dc5 * rk_moles[4 * n_reactions + j]
|
+ dc5 * rk_moles[4 * (size_t)n_reactions + (size_t)j]
|
||||||
+ dc6 * rk_moles[5 * n_reactions + j]);
|
+ dc6 * rk_moles[5 * (size_t)n_reactions + (size_t)j]);
|
||||||
|
|
||||||
/* tol is in moles/l */
|
/* tol is in moles/l */
|
||||||
l_error /= kinetics_comp_ptr->Get_tol();
|
l_error /= kinetics_comp_ptr->Get_tol();
|
||||||
@ -998,9 +1000,9 @@ rk_kinetics(int i, LDBLE kin_time, int use_mix, int nsaver,
|
|||||||
{
|
{
|
||||||
cxxKineticsComp * kinetics_comp_ptr = &(kinetics_ptr->Get_kinetics_comps()[j]);
|
cxxKineticsComp * kinetics_comp_ptr = &(kinetics_ptr->Get_kinetics_comps()[j]);
|
||||||
kinetics_comp_ptr->Set_moles(c1 * rk_moles[j]
|
kinetics_comp_ptr->Set_moles(c1 * rk_moles[j]
|
||||||
+ c3 * rk_moles[2 * n_reactions + j]
|
+ c3 * rk_moles[2 * (size_t)n_reactions + (size_t)j]
|
||||||
+ c4 * rk_moles[3 * n_reactions + j]
|
+ c4 * rk_moles[3 * (size_t)n_reactions + (size_t)j]
|
||||||
+ c6 * rk_moles[5 * n_reactions + j]);
|
+ c6 * rk_moles[5 * (size_t)n_reactions + (size_t)j]);
|
||||||
}
|
}
|
||||||
calc_final_kinetic_reaction(kinetics_ptr);
|
calc_final_kinetic_reaction(kinetics_ptr);
|
||||||
for (size_t j = 0; j < kinetics_ptr->Get_kinetics_comps().size(); j++)
|
for (size_t j = 0; j < kinetics_ptr->Get_kinetics_comps().size(); j++)
|
||||||
|
|||||||
@ -1008,11 +1008,11 @@ ineq(int in_kode)
|
|||||||
{
|
{
|
||||||
for (j = 0; j < count_unknowns; j++)
|
for (j = 0; j < count_unknowns; j++)
|
||||||
{
|
{
|
||||||
my_array[j * (count_unknowns + 1) + i] = 0.0;
|
my_array[(size_t)j * ((size_t)count_unknowns + 1) + i] = 0.0;
|
||||||
}
|
}
|
||||||
for (j = 0; j < count_unknowns + 1; j++)
|
for (j = 0; j < count_unknowns + 1; j++)
|
||||||
{
|
{
|
||||||
my_array[i * (count_unknowns + 1) + j] = 0.0;
|
my_array[(size_t)i * ((size_t)count_unknowns + 1) + (size_t)j] = 0.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1046,24 +1046,24 @@ ineq(int in_kode)
|
|||||||
if (x[i]->type == SURFACE_CB1 && x[j]->type == SURFACE_CB2)
|
if (x[i]->type == SURFACE_CB1 && x[j]->type == SURFACE_CB2)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (fabs(my_array[j * (count_unknowns + 1) + i]) > max)
|
if (fabs(my_array[(size_t)j * ((size_t)count_unknowns + 1) + (size_t)i]) > max)
|
||||||
{
|
{
|
||||||
max = fabs(my_array[j * (count_unknowns + 1) + i]);
|
max = fabs(my_array[(size_t)j * ((size_t)count_unknowns + 1) + (size_t)i]);
|
||||||
if (max > min_value)
|
if (max > min_value)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (diagonal_scale == TRUE)
|
if (diagonal_scale == TRUE)
|
||||||
{
|
{
|
||||||
if (fabs(my_array[i * (count_unknowns + 1) + i]) < min_value)
|
if (fabs(my_array[(size_t)i * ((size_t)count_unknowns + 1) + (size_t)i]) < min_value)
|
||||||
{
|
{
|
||||||
max = fabs(my_array[i * (count_unknowns + 1) + i]);
|
max = fabs(my_array[(size_t)i * ((size_t)count_unknowns + 1) + (size_t)i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (max == 0)
|
if (max == 0)
|
||||||
{
|
{
|
||||||
my_array[i * (count_unknowns + 1) + i] = 1e-5 * x[i]->moles;
|
my_array[(size_t)i * ((size_t)count_unknowns + 1) + (size_t)i] = 1e-5 * x[i]->moles;
|
||||||
max = fabs(1e-5 * x[i]->moles);
|
max = fabs(1e-5 * x[i]->moles);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1074,12 +1074,9 @@ ineq(int in_kode)
|
|||||||
|
|
||||||
min = 1e-12;
|
min = 1e-12;
|
||||||
min = MIN_TOTAL;
|
min = MIN_TOTAL;
|
||||||
my_array[x[i]->number * (count_unknowns + 1) + x[i]->number] += min;
|
my_array[(size_t)x[i]->number * ((size_t)count_unknowns + 1) + (size_t)x[i]->number] += min;
|
||||||
if (fabs
|
if (fabs(my_array[(size_t)x[i]->number * ((size_t)count_unknowns + 1) + (size_t)x[i]->number]) < min)
|
||||||
(my_array[x[i]->number * (count_unknowns + 1) + x[i]->number]) <
|
my_array[(size_t)x[i]->number * ((size_t)count_unknowns + 1) + (size_t)x[i]->number] = min;
|
||||||
min)
|
|
||||||
my_array[x[i]->number * (count_unknowns + 1) + x[i]->number] =
|
|
||||||
min;
|
|
||||||
max = 0.0;
|
max = 0.0;
|
||||||
|
|
||||||
for (j = 0; j < count_unknowns; j++)
|
for (j = 0; j < count_unknowns; j++)
|
||||||
@ -1092,9 +1089,9 @@ ineq(int in_kode)
|
|||||||
x[j]->type != EXCH && x[j]->type != MH
|
x[j]->type != EXCH && x[j]->type != MH
|
||||||
&& x[j]->type != MH2O)
|
&& x[j]->type != MH2O)
|
||||||
continue;
|
continue;
|
||||||
if (fabs(my_array[j * (count_unknowns + 1) + i]) > max)
|
if (fabs(my_array[(size_t)j * ((size_t)count_unknowns + 1) + (size_t)i]) > max)
|
||||||
{
|
{
|
||||||
max = fabs(my_array[j * (count_unknowns + 1) + i]);
|
max = fabs(my_array[(size_t)j * ((size_t)count_unknowns + 1) + (size_t)i]);
|
||||||
if (max > min_value)
|
if (max > min_value)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1111,7 +1108,7 @@ ineq(int in_kode)
|
|||||||
}
|
}
|
||||||
for (j = 0; j < count_unknowns; j++)
|
for (j = 0; j < count_unknowns; j++)
|
||||||
{
|
{
|
||||||
my_array[j * (count_unknowns + 1) + i] *= min_value / max;
|
my_array[(size_t)j * ((size_t)count_unknowns + 1) + (size_t)i] *= min_value / max;
|
||||||
}
|
}
|
||||||
normal[i] = min_value / max;
|
normal[i] = min_value / max;
|
||||||
}
|
}
|
||||||
@ -1174,9 +1171,9 @@ ineq(int in_kode)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Copy in saturation index equation (has mass or supersaturated) */
|
/* Copy in saturation index equation (has mass or supersaturated) */
|
||||||
memcpy((void *) &(ineq_array[l_count_rows * max_column_count]),
|
memcpy((void *) &(ineq_array[(size_t)l_count_rows * (size_t)max_column_count]),
|
||||||
(void *) &(my_array[i * (count_unknowns + 1)]),
|
(void *) &(my_array[(size_t)i * ((size_t)count_unknowns + 1)]),
|
||||||
((size_t) count_unknowns + 1) * sizeof(LDBLE));
|
((size_t)count_unknowns + 1) * sizeof(LDBLE));
|
||||||
back_eq[l_count_rows] = i;
|
back_eq[l_count_rows] = i;
|
||||||
//if (it->second.Get_add_formula().size() == 0
|
//if (it->second.Get_add_formula().size() == 0
|
||||||
if (comp_ptr->Get_add_formula().size() == 0
|
if (comp_ptr->Get_add_formula().size() == 0
|
||||||
@ -1191,8 +1188,7 @@ ineq(int in_kode)
|
|||||||
{
|
{
|
||||||
for (j = 0; j < count_unknowns + 1; j++)
|
for (j = 0; j < count_unknowns + 1; j++)
|
||||||
{
|
{
|
||||||
ineq_array[l_count_rows * max_column_count + j] *=
|
ineq_array[(size_t)l_count_rows * (size_t)max_column_count + (size_t)j] *= pp_scale;
|
||||||
pp_scale;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1208,9 +1204,9 @@ ineq(int in_kode)
|
|||||||
/*
|
/*
|
||||||
* Alkalinity and solution phase boundary
|
* Alkalinity and solution phase boundary
|
||||||
*/
|
*/
|
||||||
memcpy((void *) &(ineq_array[l_count_rows * max_column_count]),
|
memcpy((void *) &(ineq_array[(size_t)l_count_rows * (size_t)max_column_count]),
|
||||||
(void *) &(my_array[i * (count_unknowns + 1)]),
|
(void *) &(my_array[(size_t)i * ((size_t)count_unknowns + 1)]),
|
||||||
((size_t) count_unknowns + 1) * sizeof(LDBLE));
|
((size_t)count_unknowns + 1) * sizeof(LDBLE));
|
||||||
back_eq[l_count_rows] = i;
|
back_eq[l_count_rows] = i;
|
||||||
l_count_rows++;
|
l_count_rows++;
|
||||||
/*
|
/*
|
||||||
@ -1219,9 +1215,9 @@ ineq(int in_kode)
|
|||||||
}
|
}
|
||||||
else if (x[i]->type == GAS_MOLES && gas_in == TRUE)
|
else if (x[i]->type == GAS_MOLES && gas_in == TRUE)
|
||||||
{
|
{
|
||||||
memcpy((void *) &(ineq_array[l_count_rows * max_column_count]),
|
memcpy((void *) &(ineq_array[(size_t)l_count_rows * (size_t)max_column_count]),
|
||||||
(void *) &(my_array[i * (count_unknowns + 1)]),
|
(void *) &(my_array[(size_t)i * ((size_t)count_unknowns + 1)]),
|
||||||
((size_t) count_unknowns + 1) * sizeof(LDBLE));
|
((size_t)count_unknowns + 1) * sizeof(LDBLE));
|
||||||
back_eq[l_count_rows] = i;
|
back_eq[l_count_rows] = i;
|
||||||
|
|
||||||
res[l_count_rows] = 1.0;
|
res[l_count_rows] = 1.0;
|
||||||
@ -1236,9 +1232,9 @@ ineq(int in_kode)
|
|||||||
}
|
}
|
||||||
else if (x[i]->type == SS_MOLES && x[i]->ss_in == TRUE)
|
else if (x[i]->type == SS_MOLES && x[i]->ss_in == TRUE)
|
||||||
{
|
{
|
||||||
memcpy((void *) &(ineq_array[l_count_rows * max_column_count]),
|
memcpy((void *) &(ineq_array[(size_t)l_count_rows * (size_t)max_column_count]),
|
||||||
(void *) &(my_array[i * (count_unknowns + 1)]),
|
(void *) &(my_array[(size_t)i * ((size_t)count_unknowns + 1)]),
|
||||||
((size_t) count_unknowns + 1) * sizeof(LDBLE));
|
((size_t)count_unknowns + 1) * sizeof(LDBLE));
|
||||||
back_eq[l_count_rows] = i;
|
back_eq[l_count_rows] = i;
|
||||||
res[l_count_rows] = 1.0;
|
res[l_count_rows] = 1.0;
|
||||||
if (in_kode != 1)
|
if (in_kode != 1)
|
||||||
@ -1267,9 +1263,9 @@ ineq(int in_kode)
|
|||||||
}
|
}
|
||||||
if ((x[i]->type == SURFACE_CB || x[i]->type == SURFACE_CB1
|
if ((x[i]->type == SURFACE_CB || x[i]->type == SURFACE_CB1
|
||||||
|| x[i]->type == SURFACE_CB2)
|
|| x[i]->type == SURFACE_CB2)
|
||||||
&& x[i - 1]->phase_unknown != NULL)
|
&& x[(size_t)i - 1]->phase_unknown != NULL)
|
||||||
{
|
{
|
||||||
comp_ptr1 = pp_assemblage_ptr->Find(x[i-1]->phase_unknown->phase->name);
|
comp_ptr1 = pp_assemblage_ptr->Find(x[(size_t)i-1]->phase_unknown->phase->name);
|
||||||
}
|
}
|
||||||
if (x[i]->type != SOLUTION_PHASE_BOUNDARY &&
|
if (x[i]->type != SOLUTION_PHASE_BOUNDARY &&
|
||||||
x[i]->type != ALK &&
|
x[i]->type != ALK &&
|
||||||
@ -1309,7 +1305,7 @@ ineq(int in_kode)
|
|||||||
continue;
|
continue;
|
||||||
if ((x[i]->type == SURFACE_CB || x[i]->type == SURFACE_CB1
|
if ((x[i]->type == SURFACE_CB || x[i]->type == SURFACE_CB1
|
||||||
|| x[i]->type == SURFACE_CB2)
|
|| x[i]->type == SURFACE_CB2)
|
||||||
&& x[i - 1]->phase_unknown != NULL)
|
&& x[(size_t)i - 1]->phase_unknown != NULL)
|
||||||
{
|
{
|
||||||
cxxSurfaceCharge *charge_ptr = use.Get_surface_ptr()->Find_charge(x[i]->surface_charge);
|
cxxSurfaceCharge *charge_ptr = use.Get_surface_ptr()->Find_charge(x[i]->surface_charge);
|
||||||
if (charge_ptr->Get_grams() <= MIN_RELATED_SURFACE &&
|
if (charge_ptr->Get_grams() <= MIN_RELATED_SURFACE &&
|
||||||
@ -1318,26 +1314,26 @@ ineq(int in_kode)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
memcpy((void *) &(ineq_array[l_count_rows * max_column_count]),
|
memcpy((void *) &(ineq_array[(size_t)l_count_rows * (size_t)max_column_count]),
|
||||||
(void *) &(my_array[i * (count_unknowns + 1)]),
|
(void *) &(my_array[(size_t)i * ((size_t)count_unknowns + 1)]),
|
||||||
((size_t) count_unknowns + 1) * sizeof(LDBLE));
|
((size_t)count_unknowns + 1) * sizeof(LDBLE));
|
||||||
back_eq[l_count_rows] = i;
|
back_eq[l_count_rows] = i;
|
||||||
if (mass_water_switch == TRUE && x[i] == mass_hydrogen_unknown)
|
if (mass_water_switch == TRUE && x[i] == mass_hydrogen_unknown)
|
||||||
{
|
{
|
||||||
k = mass_oxygen_unknown->number;
|
k = mass_oxygen_unknown->number;
|
||||||
for (j = 0; j < count_unknowns; j++)
|
for (j = 0; j < count_unknowns; j++)
|
||||||
{
|
{
|
||||||
ineq_array[l_count_rows * max_column_count + j] -=
|
ineq_array[(size_t)l_count_rows * (size_t)max_column_count + (size_t)j] -=
|
||||||
2 * my_array[k * (count_unknowns + 1) + j];
|
2 * my_array[(size_t)k * ((size_t)count_unknowns + 1) + (size_t)j];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
l_count_rows++;
|
l_count_rows++;
|
||||||
}
|
}
|
||||||
else if (x[i]->type == PITZER_GAMMA && full_pitzer == TRUE)
|
else if (x[i]->type == PITZER_GAMMA && full_pitzer == TRUE)
|
||||||
{
|
{
|
||||||
memcpy((void *) &(ineq_array[l_count_rows * max_column_count]),
|
memcpy((void *) &(ineq_array[(size_t)l_count_rows * (size_t)max_column_count]),
|
||||||
(void *) &(my_array[i * (count_unknowns + 1)]),
|
(void *) &(my_array[(size_t)i * ((size_t)count_unknowns + 1)]),
|
||||||
((size_t) count_unknowns + 1) * sizeof(LDBLE));
|
((size_t)count_unknowns + 1) * sizeof(LDBLE));
|
||||||
back_eq[l_count_rows] = i;
|
back_eq[l_count_rows] = i;
|
||||||
l_count_rows++;
|
l_count_rows++;
|
||||||
}
|
}
|
||||||
@ -1379,13 +1375,12 @@ ineq(int in_kode)
|
|||||||
|
|
||||||
/* Pure phase is present, force Mass transfer to be <= amount of mineral remaining */
|
/* Pure phase is present, force Mass transfer to be <= amount of mineral remaining */
|
||||||
//memcpy((void *)
|
//memcpy((void *)
|
||||||
// &(ineq_array[l_count_rows * max_column_count]),
|
// &(ineq_array[(size_t)l_count_rows * (size_t)max_column_count]),
|
||||||
// (void *) &(zero[0]),
|
// (void *) &(zero[0]),
|
||||||
// ((size_t) count_unknowns + 1) * sizeof(LDBLE));
|
// ((size_t) count_unknowns + 1) * sizeof(LDBLE));
|
||||||
memset(&ineq_array[l_count_rows * max_column_count], 0, ((size_t) count_unknowns + 1) * sizeof(LDBLE));
|
memset(&ineq_array[(size_t)l_count_rows * (size_t)max_column_count], 0, ((size_t) count_unknowns + 1) * sizeof(LDBLE));
|
||||||
ineq_array[l_count_rows * max_column_count + i] = 1.0;
|
ineq_array[(size_t)l_count_rows * (size_t)max_column_count + i] = 1.0;
|
||||||
ineq_array[l_count_rows * max_column_count +
|
ineq_array[(size_t)l_count_rows * (size_t)max_column_count + (size_t)count_unknowns] = x[i]->moles;
|
||||||
count_unknowns] = x[i]->moles;
|
|
||||||
back_eq[l_count_rows] = i;
|
back_eq[l_count_rows] = i;
|
||||||
l_count_rows++;
|
l_count_rows++;
|
||||||
}
|
}
|
||||||
@ -1393,13 +1388,12 @@ ineq(int in_kode)
|
|||||||
if (x[i]->dissolve_only == TRUE)
|
if (x[i]->dissolve_only == TRUE)
|
||||||
{
|
{
|
||||||
//memcpy((void *)
|
//memcpy((void *)
|
||||||
// &(ineq_array[l_count_rows * max_column_count]),
|
// &(ineq_array[(size_t)l_count_rows * (size_t)max_column_count]),
|
||||||
// (void *) &(zero[0]),
|
// (void *) &(zero[0]),
|
||||||
// ((size_t) count_unknowns + 1) * sizeof(LDBLE));
|
// ((size_t) count_unknowns + 1) * sizeof(LDBLE));
|
||||||
memset(&(ineq_array[l_count_rows * max_column_count]), 0, ((size_t)count_unknowns + 1) * sizeof(LDBLE));
|
memset(&(ineq_array[(size_t)l_count_rows * (size_t)max_column_count]), 0, ((size_t)count_unknowns + 1) * sizeof(LDBLE));
|
||||||
ineq_array[l_count_rows * max_column_count + i] = -1.0;
|
ineq_array[(size_t)l_count_rows * (size_t)max_column_count + i] = -1.0;
|
||||||
ineq_array[l_count_rows * max_column_count +
|
ineq_array[(size_t)l_count_rows * (size_t)max_column_count + (size_t)count_unknowns] =
|
||||||
count_unknowns] =
|
|
||||||
comp_ptr->Get_initial_moles() - x[i]->moles;
|
comp_ptr->Get_initial_moles() - x[i]->moles;
|
||||||
back_eq[l_count_rows] = i;
|
back_eq[l_count_rows] = i;
|
||||||
l_count_rows++;
|
l_count_rows++;
|
||||||
@ -1416,22 +1410,22 @@ ineq(int in_kode)
|
|||||||
{
|
{
|
||||||
if (x[i]->type == MH2O)
|
if (x[i]->type == MH2O)
|
||||||
{
|
{
|
||||||
memcpy((void *) &(ineq_array[l_count_rows * max_column_count]),
|
memcpy((void *) &(ineq_array[(size_t)l_count_rows * (size_t)max_column_count]),
|
||||||
(void *) &(my_array[i * (count_unknowns + 1)]),
|
(void *) &(my_array[(size_t)i * ((size_t)count_unknowns + 1)]),
|
||||||
((size_t) count_unknowns + 1) * sizeof(LDBLE));
|
((size_t)count_unknowns + 1) * sizeof(LDBLE));
|
||||||
back_eq[l_count_rows] = i;
|
back_eq[l_count_rows] = i;
|
||||||
for (j = 0; j < count_unknowns; j++)
|
for (j = 0; j < count_unknowns; j++)
|
||||||
{
|
{
|
||||||
if (x[j]->type < PP)
|
if (x[j]->type < PP)
|
||||||
{
|
{
|
||||||
ineq_array[l_count_rows * max_column_count + j] = 0.0;
|
ineq_array[(size_t)l_count_rows * (size_t)max_column_count + j] = 0.0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/*ineq_array[l_count_rows*max_column_count + j] = -ineq_array[l_count_rows*max_column_count + j]; */
|
/*ineq_array[l_count_rows*max_column_count + j] = -ineq_array[l_count_rows*max_column_count + j]; */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ineq_array[l_count_rows * max_column_count + count_unknowns] =
|
ineq_array[(size_t)l_count_rows * (size_t)max_column_count + (size_t)count_unknowns] =
|
||||||
0.5 * x[i]->moles;
|
0.5 * x[i]->moles;
|
||||||
l_count_rows++;
|
l_count_rows++;
|
||||||
}
|
}
|
||||||
@ -1459,7 +1453,7 @@ ineq(int in_kode)
|
|||||||
{
|
{
|
||||||
for (j = 0; j < l_count_rows; j++)
|
for (j = 0; j < l_count_rows; j++)
|
||||||
{
|
{
|
||||||
ineq_array[j * max_column_count + i] = 0.0;
|
ineq_array[(size_t)j * (size_t)max_column_count + i] = 0.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (x[i]->dissolve_only == TRUE)
|
if (x[i]->dissolve_only == TRUE)
|
||||||
@ -1470,7 +1464,7 @@ ineq(int in_kode)
|
|||||||
{
|
{
|
||||||
for (j = 0; j < l_count_rows; j++)
|
for (j = 0; j < l_count_rows; j++)
|
||||||
{
|
{
|
||||||
ineq_array[j * max_column_count + i] = 0.0;
|
ineq_array[(size_t)j * (size_t)max_column_count + (size_t)i] = 0.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1490,7 +1484,7 @@ ineq(int in_kode)
|
|||||||
{
|
{
|
||||||
for (j = 0; j < l_count_rows; j++)
|
for (j = 0; j < l_count_rows; j++)
|
||||||
{
|
{
|
||||||
ineq_array[j * max_column_count + i] = 0.0;
|
ineq_array[(size_t)j * (size_t)max_column_count + i] = 0.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1512,14 +1506,14 @@ ineq(int in_kode)
|
|||||||
}
|
}
|
||||||
if ((x[i]->type == SURFACE_CB || x[i]->type == SURFACE_CB1
|
if ((x[i]->type == SURFACE_CB || x[i]->type == SURFACE_CB1
|
||||||
|| x[i]->type == SURFACE_CB2)
|
|| x[i]->type == SURFACE_CB2)
|
||||||
&& (x[i - 1]->phase_unknown != NULL))
|
&& (x[(size_t)i - 1]->phase_unknown != NULL))
|
||||||
{
|
{
|
||||||
comp_ptr1 = pp_assemblage_ptr->Find(x[i-1]->phase_unknown->phase->name);
|
comp_ptr1 = pp_assemblage_ptr->Find(x[(size_t)i-1]->phase_unknown->phase->name);
|
||||||
}
|
}
|
||||||
LDBLE grams = 0;
|
LDBLE grams = 0;
|
||||||
if ((x[i]->type == SURFACE_CB || x[i]->type == SURFACE_CB1
|
if ((x[i]->type == SURFACE_CB || x[i]->type == SURFACE_CB1
|
||||||
|| x[i]->type == SURFACE_CB2)
|
|| x[i]->type == SURFACE_CB2)
|
||||||
&& x[i - 1]->phase_unknown != NULL)
|
&& x[(size_t)i - 1]->phase_unknown != NULL)
|
||||||
{
|
{
|
||||||
cxxSurfaceCharge *charge_ptr = use.Get_surface_ptr()->Find_charge(x[i]->surface_charge);
|
cxxSurfaceCharge *charge_ptr = use.Get_surface_ptr()->Find_charge(x[i]->surface_charge);
|
||||||
grams = charge_ptr->Get_grams();
|
grams = charge_ptr->Get_grams();
|
||||||
@ -1529,13 +1523,13 @@ ineq(int in_kode)
|
|||||||
comp_ptr->Get_add_formula().size() == 0) ||
|
comp_ptr->Get_add_formula().size() == 0) ||
|
||||||
((x[i]->type == SURFACE_CB || x[i]->type == SURFACE_CB1
|
((x[i]->type == SURFACE_CB || x[i]->type == SURFACE_CB1
|
||||||
|| x[i]->type == SURFACE_CB2)
|
|| x[i]->type == SURFACE_CB2)
|
||||||
&& x[i - 1]->phase_unknown != NULL &&
|
&& x[(size_t)i - 1]->phase_unknown != NULL &&
|
||||||
grams <= MIN_RELATED_SURFACE &&
|
grams <= MIN_RELATED_SURFACE &&
|
||||||
comp_ptr1->Get_add_formula().size() == 0))
|
comp_ptr1->Get_add_formula().size() == 0))
|
||||||
{
|
{
|
||||||
for (j = 0; j < l_count_rows; j++)
|
for (j = 0; j < l_count_rows; j++)
|
||||||
{
|
{
|
||||||
ineq_array[j * max_column_count + i] = 0.0;
|
ineq_array[(size_t)j * (size_t)max_column_count + (size_t)i] = 0.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1549,7 +1543,7 @@ ineq(int in_kode)
|
|||||||
for (i = 0; i < count_unknowns; i++)
|
for (i = 0; i < count_unknowns; i++)
|
||||||
{
|
{
|
||||||
if ((x[i]->type == SURFACE_CB || x[i]->type == SURFACE_CB1
|
if ((x[i]->type == SURFACE_CB || x[i]->type == SURFACE_CB1
|
||||||
|| x[i]->type == SURFACE_CB2) && x[i - 1]->phase_unknown == NULL)
|
|| x[i]->type == SURFACE_CB2) && x[(size_t)i - 1]->phase_unknown == NULL)
|
||||||
{
|
{
|
||||||
cxxSurfaceCharge *charge_ptr = use.Get_surface_ptr()->Find_charge(x[i]->surface_charge);
|
cxxSurfaceCharge *charge_ptr = use.Get_surface_ptr()->Find_charge(x[i]->surface_charge);
|
||||||
grams = charge_ptr->Get_grams();
|
grams = charge_ptr->Get_grams();
|
||||||
@ -1559,12 +1553,12 @@ ineq(int in_kode)
|
|||||||
x[i]->moles <= MIN_RELATED_SURFACE) ||
|
x[i]->moles <= MIN_RELATED_SURFACE) ||
|
||||||
((x[i]->type == SURFACE_CB || x[i]->type == SURFACE_CB1
|
((x[i]->type == SURFACE_CB || x[i]->type == SURFACE_CB1
|
||||||
|| x[i]->type == SURFACE_CB2)
|
|| x[i]->type == SURFACE_CB2)
|
||||||
&& x[i - 1]->phase_unknown == NULL
|
&& x[(size_t)i - 1]->phase_unknown == NULL
|
||||||
&& grams <= MIN_RELATED_SURFACE))
|
&& grams <= MIN_RELATED_SURFACE))
|
||||||
{
|
{
|
||||||
for (j = 0; j < l_count_rows; j++)
|
for (j = 0; j < l_count_rows; j++)
|
||||||
{
|
{
|
||||||
ineq_array[j * max_column_count + i] = 0.0;
|
ineq_array[(size_t)j * (size_t)max_column_count + (size_t)i] = 0.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1578,16 +1572,16 @@ ineq(int in_kode)
|
|||||||
{
|
{
|
||||||
if (x[i]->type == GAS_MOLES)
|
if (x[i]->type == GAS_MOLES)
|
||||||
{
|
{
|
||||||
//memcpy((void *) &(ineq_array[l_count_rows * max_column_count]),
|
//memcpy((void *) &(ineq_array[(size_t)l_count_rows * (size_t)max_column_count]),
|
||||||
// (void *) &(zero[0]),
|
// (void *) &(zero[0]),
|
||||||
// ((size_t) count_unknowns + 1) * sizeof(LDBLE));
|
// ((size_t) count_unknowns + 1) * sizeof(LDBLE));
|
||||||
//std::fill(&(ineq_array[l_count_rows * max_column_count]),
|
//std::fill(&(ineq_array[(size_t)l_count_rows * (size_t)max_column_count]),
|
||||||
// &(ineq_array[l_count_rows * max_column_count + count_unknowns]),
|
// &(ineq_array[l_count_rows * max_column_count + count_unknowns]),
|
||||||
// 0.0e0);
|
// 0.0e0);
|
||||||
memset(&(ineq_array[l_count_rows * max_column_count]), 0,
|
memset(&(ineq_array[(size_t)l_count_rows * (size_t)max_column_count]), 0,
|
||||||
((size_t)count_unknowns + 1) * sizeof(LDBLE));
|
((size_t)count_unknowns + 1) * sizeof(LDBLE));
|
||||||
ineq_array[l_count_rows * max_column_count + i] = -1.0;
|
ineq_array[(size_t)l_count_rows * (size_t)max_column_count + (size_t)i] = -1.0;
|
||||||
ineq_array[l_count_rows * max_column_count + count_unknowns] =
|
ineq_array[(size_t)l_count_rows * (size_t)max_column_count + (size_t)count_unknowns] =
|
||||||
x[i]->moles;
|
x[i]->moles;
|
||||||
back_eq[l_count_rows] = i;
|
back_eq[l_count_rows] = i;
|
||||||
l_count_rows++;
|
l_count_rows++;
|
||||||
@ -1606,7 +1600,7 @@ ineq(int in_kode)
|
|||||||
i = gas_unknown->number;
|
i = gas_unknown->number;
|
||||||
for (j = 0; j < l_count_rows; j++)
|
for (j = 0; j < l_count_rows; j++)
|
||||||
{
|
{
|
||||||
ineq_array[j * max_column_count + i] = 0.0;
|
ineq_array[(size_t)j * (size_t)max_column_count + (size_t)i] = 0.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
@ -1621,13 +1615,13 @@ ineq(int in_kode)
|
|||||||
break;
|
break;
|
||||||
if (x[i]->phase->in == TRUE && x[i]->ss_in == TRUE)
|
if (x[i]->phase->in == TRUE && x[i]->ss_in == TRUE)
|
||||||
{
|
{
|
||||||
//memcpy((void *) &(ineq_array[l_count_rows * max_column_count]),
|
//memcpy((void *) &(ineq_array[(size_t)l_count_rows * (size_t)max_column_count]),
|
||||||
// (void *) &(zero[0]),
|
// (void *) &(zero[0]),
|
||||||
// ((size_t) count_unknowns + 1) * sizeof(LDBLE));
|
// ((size_t) count_unknowns + 1) * sizeof(LDBLE));
|
||||||
memset(&(ineq_array[l_count_rows * max_column_count]), 0,
|
memset(&(ineq_array[(size_t)l_count_rows * (size_t)max_column_count]), 0,
|
||||||
((size_t)count_unknowns + 1) * sizeof(LDBLE));
|
((size_t)count_unknowns + 1) * sizeof(LDBLE));
|
||||||
ineq_array[l_count_rows * max_column_count + i] = 1.0;
|
ineq_array[(size_t)l_count_rows * (size_t)max_column_count + (size_t)i] = 1.0;
|
||||||
ineq_array[l_count_rows * max_column_count + count_unknowns] =
|
ineq_array[(size_t)l_count_rows * (size_t)max_column_count + (size_t)count_unknowns] =
|
||||||
0.99 * x[i]->moles - MIN_TOTAL_SS;
|
0.99 * x[i]->moles - MIN_TOTAL_SS;
|
||||||
back_eq[l_count_rows] = i;
|
back_eq[l_count_rows] = i;
|
||||||
l_count_rows++;
|
l_count_rows++;
|
||||||
@ -1636,7 +1630,7 @@ ineq(int in_kode)
|
|||||||
{
|
{
|
||||||
for (j = 0; j < l_count_rows; j++)
|
for (j = 0; j < l_count_rows; j++)
|
||||||
{
|
{
|
||||||
ineq_array[j * max_column_count + i] = 0.0;
|
ineq_array[(size_t)j * (size_t)max_column_count + (size_t)i] = 0.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1650,15 +1644,15 @@ ineq(int in_kode)
|
|||||||
{
|
{
|
||||||
if (x[i]->type == MB && x[i]->moles < 0.0)
|
if (x[i]->type == MB && x[i]->moles < 0.0)
|
||||||
{
|
{
|
||||||
memcpy((void *) &(ineq_array[l_count_rows * max_column_count]),
|
memcpy((void *) &(ineq_array[(size_t)l_count_rows * (size_t)max_column_count]),
|
||||||
(void *) &(my_array[i * (count_unknowns + 1)]),
|
(void *) &(my_array[(size_t)i * ((size_t)count_unknowns + 1)]),
|
||||||
((size_t) count_unknowns + 1) * sizeof(LDBLE));
|
((size_t) count_unknowns + 1) * sizeof(LDBLE));
|
||||||
back_eq[l_count_rows] = i;
|
back_eq[l_count_rows] = i;
|
||||||
for (j = 0; j < count_unknowns; j++)
|
for (j = 0; j < count_unknowns; j++)
|
||||||
{
|
{
|
||||||
if (x[j]->type < PP)
|
if (x[j]->type < PP)
|
||||||
{
|
{
|
||||||
ineq_array[l_count_rows * max_column_count + j] = 0.0;
|
ineq_array[(size_t)l_count_rows * (size_t)max_column_count + (size_t)j] = 0.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
l_count_rows++;
|
l_count_rows++;
|
||||||
@ -1673,7 +1667,7 @@ ineq(int in_kode)
|
|||||||
k = mass_oxygen_unknown->number;
|
k = mass_oxygen_unknown->number;
|
||||||
for (j = 0; j < l_count_rows + 1; j++)
|
for (j = 0; j < l_count_rows + 1; j++)
|
||||||
{
|
{
|
||||||
ineq_array[j * max_column_count + k] = 0;
|
ineq_array[(size_t)j * (size_t)max_column_count + (size_t)k] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
@ -1686,7 +1680,7 @@ ineq(int in_kode)
|
|||||||
{
|
{
|
||||||
for (j = 0; j < l_count_rows; j++)
|
for (j = 0; j < l_count_rows; j++)
|
||||||
{
|
{
|
||||||
ineq_array[j * max_column_count + i] *= pp_column_scale;
|
ineq_array[(size_t)j * (size_t)max_column_count + (size_t)i] *= pp_column_scale;
|
||||||
}
|
}
|
||||||
normal[i] = pp_column_scale;
|
normal[i] = pp_column_scale;
|
||||||
}
|
}
|
||||||
@ -1720,13 +1714,13 @@ ineq(int in_kode)
|
|||||||
{
|
{
|
||||||
for (int j = 0; j < n; j++)
|
for (int j = 0; j < n; j++)
|
||||||
{
|
{
|
||||||
ineq_array[i*(n+2) + j] = ineq_array[i*(count_unknowns+2) +j];
|
ineq_array[(size_t)i*((size_t)n+2) + (size_t)j] = ineq_array[(size_t)i*((size_t)count_unknowns+2) + (size_t)j];
|
||||||
}
|
}
|
||||||
//if (i > 0)
|
//if (i > 0)
|
||||||
//{
|
//{
|
||||||
// memcpy((void *) &ineq_array[i*(n+2)], (void *) &ineq_array[i*(count_unknowns+2)], (size_t) (n) * sizeof(LDBLE));
|
// memcpy((void *) &ineq_array[i*(n+2)], (void *) &ineq_array[i*(count_unknowns+2)], (size_t) (n) * sizeof(LDBLE));
|
||||||
//}
|
//}
|
||||||
ineq_array[i*(n+2) + n] = ineq_array[i*(count_unknowns+2) + count_unknowns];
|
ineq_array[(size_t)i*((size_t)n+2) + (size_t)n] = ineq_array[(size_t)i*((size_t)count_unknowns+2) + (size_t)count_unknowns];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -1866,7 +1860,7 @@ ineq(int in_kode)
|
|||||||
{
|
{
|
||||||
for (j = 0; j < count_unknowns; j++)
|
for (j = 0; j < count_unknowns; j++)
|
||||||
{
|
{
|
||||||
my_array[j * (count_unknowns + 1) + i] /= normal[i];
|
my_array[(size_t)j * ((size_t)count_unknowns + 1) + (size_t)i] /= normal[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1947,7 +1941,7 @@ jacobian_sums(void)
|
|||||||
}
|
}
|
||||||
for (i = 1; i < count_unknowns; i++)
|
for (i = 1; i < count_unknowns; i++)
|
||||||
{
|
{
|
||||||
memcpy((void *) &(my_array[i * (count_unknowns + 1)]),
|
memcpy((void *) &(my_array[(size_t)i * ((size_t)count_unknowns + 1)]),
|
||||||
(void *) &(my_array[0]), (size_t) count_unknowns * sizeof(LDBLE));
|
(void *) &(my_array[0]), (size_t) count_unknowns * sizeof(LDBLE));
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
@ -1982,18 +1976,18 @@ jacobian_sums(void)
|
|||||||
for (i = 0; i < count_unknowns; i++)
|
for (i = 0; i < count_unknowns; i++)
|
||||||
{
|
{
|
||||||
// using straight mu equation
|
// using straight mu equation
|
||||||
my_array[mu_unknown->number * (count_unknowns + 1) + i] *= 0.5;
|
my_array[(size_t)mu_unknown->number * ((size_t)count_unknowns + 1) + i] *= 0.5;
|
||||||
}
|
}
|
||||||
my_array[mu_unknown->number * (count_unknowns + 1) +
|
my_array[(size_t)mu_unknown->number * ((size_t)count_unknowns + 1) +
|
||||||
mu_unknown->number] -= mass_water_aq_x;
|
(size_t)mu_unknown->number] -= mass_water_aq_x;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
* Mass of oxygen
|
* Mass of oxygen
|
||||||
*/
|
*/
|
||||||
if (mass_oxygen_unknown != NULL && mu_unknown != NULL)
|
if (mass_oxygen_unknown != NULL && mu_unknown != NULL)
|
||||||
{
|
{
|
||||||
my_array[mu_unknown->number * (count_unknowns + 1) +
|
my_array[(size_t)mu_unknown->number * ((size_t)count_unknowns + 1) +
|
||||||
mass_oxygen_unknown->number] -= mu_x * mass_water_aq_x;
|
(size_t)mass_oxygen_unknown->number] -= mu_x * mass_water_aq_x;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
* Activity of water
|
* Activity of water
|
||||||
@ -2012,16 +2006,16 @@ jacobian_sums(void)
|
|||||||
|
|
||||||
for (i = 0; i < count_unknowns; i++)
|
for (i = 0; i < count_unknowns; i++)
|
||||||
{
|
{
|
||||||
my_array[ah2o_unknown->number * (count_unknowns + 1) + i] *= factor;
|
my_array[(size_t)ah2o_unknown->number * ((size_t)count_unknowns + 1) + (size_t)i] *= factor;
|
||||||
}
|
}
|
||||||
// activity of water term
|
// activity of water term
|
||||||
my_array[ah2o_unknown->number * (count_unknowns + 1) +
|
my_array[(size_t)ah2o_unknown->number * ((size_t)count_unknowns + 1) +
|
||||||
ah2o_unknown->number] -= exp(s_h2o->la * LOG_10);
|
(size_t)ah2o_unknown->number] -= exp(s_h2o->la * LOG_10);
|
||||||
|
|
||||||
// mass of water term
|
// mass of water term
|
||||||
if (mass_oxygen_unknown != NULL)
|
if (mass_oxygen_unknown != NULL)
|
||||||
{
|
{
|
||||||
my_array[ah2o_unknown->number * (count_unknowns + 1) + mass_oxygen_unknown->number] -=
|
my_array[(size_t)ah2o_unknown->number * ((size_t)count_unknowns + 1) + (size_t)mass_oxygen_unknown->number] -=
|
||||||
a*y_sum*(x_h2o*(0.5*tanh(lim) + 0.5) + (47.5*x_h2o - 50.0*a*y_sum)/(cosh(lim)*cosh(lim))) /
|
a*y_sum*(x_h2o*(0.5*tanh(lim) + 0.5) + (47.5*x_h2o - 50.0*a*y_sum)/(cosh(lim)*cosh(lim))) /
|
||||||
(x_h2o*x_h2o*x_h2o);
|
(x_h2o*x_h2o*x_h2o);
|
||||||
}
|
}
|
||||||
@ -2030,13 +2024,13 @@ jacobian_sums(void)
|
|||||||
{
|
{
|
||||||
for (i = 0; i < count_unknowns; i++)
|
for (i = 0; i < count_unknowns; i++)
|
||||||
{
|
{
|
||||||
my_array[ah2o_unknown->number * (count_unknowns + 1) + i] *= -AH2O_FACTOR;
|
my_array[(size_t)ah2o_unknown->number * ((size_t)count_unknowns + 1) + i] *= -AH2O_FACTOR;
|
||||||
}
|
}
|
||||||
my_array[ah2o_unknown->number * (count_unknowns + 1) + ah2o_unknown->number] -=
|
my_array[(size_t)ah2o_unknown->number * ((size_t)count_unknowns + 1) + (size_t)ah2o_unknown->number] -=
|
||||||
mass_water_aq_x * exp(s_h2o->la * LOG_10);
|
mass_water_aq_x * exp(s_h2o->la * LOG_10);
|
||||||
if (mass_oxygen_unknown != NULL)
|
if (mass_oxygen_unknown != NULL)
|
||||||
{
|
{
|
||||||
my_array[ah2o_unknown->number * (count_unknowns + 1) + mass_oxygen_unknown->number] -=
|
my_array[(size_t)ah2o_unknown->number * ((size_t)count_unknowns + 1) + (size_t)mass_oxygen_unknown->number] -=
|
||||||
(exp(s_h2o->la * LOG_10) - 1) * mass_water_aq_x;
|
(exp(s_h2o->la * LOG_10) - 1) * mass_water_aq_x;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2065,18 +2059,15 @@ jacobian_sums(void)
|
|||||||
{
|
{
|
||||||
for (j = 0; j < count_unknowns; j++)
|
for (j = 0; j < count_unknowns; j++)
|
||||||
{
|
{
|
||||||
my_array[x[i]->number * (count_unknowns + 1) + j] *=
|
my_array[(size_t)x[i]->number * ((size_t)count_unknowns + 1) + (size_t)j] *=
|
||||||
F_C_MOL / (charge_ptr->Get_specific_area() *
|
F_C_MOL / (charge_ptr->Get_specific_area() * charge_ptr->Get_grams());
|
||||||
charge_ptr->Get_grams());
|
|
||||||
}
|
}
|
||||||
my_array[x[i]->number * (count_unknowns + 1) + x[i]->number] -=
|
my_array[(size_t)x[i]->number * ((size_t)count_unknowns + 1) + (size_t)x[i]->number] -=
|
||||||
sinh_constant * sqrt(mu_x) *
|
sinh_constant * sqrt(mu_x) * cosh(x[i]->master[0]->s->la * LOG_10);
|
||||||
cosh(x[i]->master[0]->s->la * LOG_10);
|
|
||||||
if (mu_unknown != NULL)
|
if (mu_unknown != NULL)
|
||||||
{
|
{
|
||||||
my_array[x[i]->number * (count_unknowns + 1) +
|
my_array[(size_t)x[i]->number * ((size_t)count_unknowns + 1) +
|
||||||
mu_unknown->number] -=
|
(size_t)mu_unknown->number] -= 0.5 * sinh_constant / sqrt(mu_x) *
|
||||||
0.5 * sinh_constant / sqrt(mu_x) *
|
|
||||||
sinh(x[i]->master[0]->s->la * LOG_10);
|
sinh(x[i]->master[0]->s->la * LOG_10);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2095,13 +2086,11 @@ jacobian_sums(void)
|
|||||||
{
|
{
|
||||||
for (j = 0; j < count_unknowns; j++)
|
for (j = 0; j < count_unknowns; j++)
|
||||||
{
|
{
|
||||||
my_array[x[i]->number * (count_unknowns + 1) + j] *=
|
my_array[(size_t)x[i]->number * ((size_t)count_unknowns + 1) + (size_t)j] *=
|
||||||
F_C_MOL / (charge_ptr->Get_specific_area() *
|
F_C_MOL / (charge_ptr->Get_specific_area() * charge_ptr->Get_grams());
|
||||||
charge_ptr->Get_grams());
|
|
||||||
}
|
}
|
||||||
my_array[x[i]->number * (count_unknowns + 1) + x[i]->number] -=
|
my_array[(size_t)x[i]->number * ((size_t)count_unknowns + 1) + (size_t)x[i]->number] -=
|
||||||
charge_ptr->Get_capacitance0() * 2 * R_KJ_DEG_MOL *
|
charge_ptr->Get_capacitance0() * 2 * R_KJ_DEG_MOL * tk_x * LOG_10 / F_KJ_V_EQ;
|
||||||
tk_x * LOG_10 / F_KJ_V_EQ;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -4542,7 +4531,7 @@ residuals(void)
|
|||||||
/*
|
/*
|
||||||
* Store residuals in array
|
* Store residuals in array
|
||||||
*/
|
*/
|
||||||
my_array[(i + 1) * (count_unknowns + 1) - 1] = residual[i];
|
my_array[((size_t)i + 1) * ((size_t)count_unknowns + 1) - 1] = residual[i];
|
||||||
sum_residual += fabs(residual[i]);
|
sum_residual += fabs(residual[i]);
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
@ -5350,8 +5339,8 @@ numerical_jacobian(void)
|
|||||||
}
|
}
|
||||||
for (i = 1; i < count_unknowns; i++)
|
for (i = 1; i < count_unknowns; i++)
|
||||||
{
|
{
|
||||||
memcpy((void *) &(my_array[i * (count_unknowns + 1)]),
|
memcpy((void *) &(my_array[(size_t)i * ((size_t)count_unknowns + 1)]),
|
||||||
(void *) &(my_array[0]), (size_t) count_unknowns * sizeof(LDBLE));
|
(void *) &(my_array[0]), (size_t)count_unknowns * sizeof(LDBLE));
|
||||||
}
|
}
|
||||||
|
|
||||||
base = (LDBLE *) PHRQ_malloc((size_t) count_unknowns * sizeof(LDBLE));
|
base = (LDBLE *) PHRQ_malloc((size_t) count_unknowns * sizeof(LDBLE));
|
||||||
@ -5466,13 +5455,13 @@ numerical_jacobian(void)
|
|||||||
LDBLE t = (LDBLE) pow((LDBLE) 10.0, (LDBLE) (DBL_MAX_10_EXP - 50.0));
|
LDBLE t = (LDBLE) pow((LDBLE) 10.0, (LDBLE) (DBL_MAX_10_EXP - 50.0));
|
||||||
if (residual[j] > t)
|
if (residual[j] > t)
|
||||||
{
|
{
|
||||||
my_array[j * (count_unknowns + 1) + i] = -pow(10.0, DBL_MAX_10_EXP - 50.0);
|
my_array[(size_t)j * ((size_t)count_unknowns + 1) + (size_t)i] = -pow(10.0, DBL_MAX_10_EXP - 50.0);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
my_array[j * (count_unknowns + 1) + i] = -(residual[j] - base[j]) / d2;
|
my_array[(size_t)j * ((size_t)count_unknowns + 1) + (size_t)i] = -(residual[j] - base[j]) / d2;
|
||||||
if (x[i]->type == MH2O) // DL_pitz
|
if (x[i]->type == MH2O) // DL_pitz
|
||||||
my_array[j * (count_unknowns + 1) + i] *= mass_water_aq_x;
|
my_array[(size_t)j * ((size_t)count_unknowns + 1) + (size_t)i] *= mass_water_aq_x;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (residual[j] < -1.0e101)
|
else if (residual[j] < -1.0e101)
|
||||||
@ -5480,21 +5469,21 @@ numerical_jacobian(void)
|
|||||||
LDBLE t = pow((LDBLE) 10.0, (LDBLE) (DBL_MIN_10_EXP + 50.0));
|
LDBLE t = pow((LDBLE) 10.0, (LDBLE) (DBL_MIN_10_EXP + 50.0));
|
||||||
if (residual[j] < -t)
|
if (residual[j] < -t)
|
||||||
{
|
{
|
||||||
my_array[j * (count_unknowns + 1) + i] = pow(10.0, DBL_MIN_10_EXP + 50.0);
|
my_array[(size_t)j * ((size_t)count_unknowns + 1) + (size_t)i] = pow(10.0, DBL_MIN_10_EXP + 50.0);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
my_array[j * (count_unknowns + 1) + i] = -(residual[j] - base[j]) / d2;
|
my_array[(size_t)j * ((size_t)count_unknowns + 1) + (size_t)i] = -(residual[j] - base[j]) / d2;
|
||||||
if (x[i]->type == MH2O) // DL_pitz
|
if (x[i]->type == MH2O) // DL_pitz
|
||||||
my_array[j * (count_unknowns + 1) + i] *= mass_water_aq_x;
|
my_array[(size_t)j * ((size_t)count_unknowns + 1) + (size_t)i] *= mass_water_aq_x;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
my_array[j * (count_unknowns + 1) + i] = -(residual[j] - base[j]) / d2;
|
my_array[(size_t)j * ((size_t)count_unknowns + 1) + (size_t)i] = -(residual[j] - base[j]) / d2;
|
||||||
if (x[i]->type == MH2O) // DL_pitz
|
if (x[i]->type == MH2O) // DL_pitz
|
||||||
my_array[j * (count_unknowns + 1) + i] *= mass_water_aq_x;
|
my_array[(size_t)j * ((size_t)count_unknowns + 1) + (size_t)i] *= mass_water_aq_x;
|
||||||
if (!PHR_ISFINITE(my_array[j * (count_unknowns + 1) + i]))
|
if (!PHR_ISFINITE(my_array[(size_t)j * ((size_t)count_unknowns + 1) + (size_t)i]))
|
||||||
{
|
{
|
||||||
//fprintf(stderr, "oops, got NaN: %e, %e, %e, %e\n", residual[j], base[j], d2, array[j * (count_unknowns + 1) + i]);
|
//fprintf(stderr, "oops, got NaN: %e, %e, %e, %e\n", residual[j], base[j], d2, array[j * (count_unknowns + 1) + i]);
|
||||||
}
|
}
|
||||||
@ -5518,10 +5507,10 @@ numerical_jacobian(void)
|
|||||||
break;
|
break;
|
||||||
case MH:
|
case MH:
|
||||||
s_eminus->la -= d;
|
s_eminus->la -= d;
|
||||||
if (my_array[i * (count_unknowns + 1) + i] == 0)
|
if (my_array[(size_t)i * ((size_t)count_unknowns + 1) + (size_t)i] == 0)
|
||||||
{
|
{
|
||||||
/*output_msg(sformatf( "Zero diagonal for MH\n")); */
|
/*output_msg(sformatf( "Zero diagonal for MH\n")); */
|
||||||
my_array[i * (count_unknowns + 1) + i] =
|
my_array[(size_t)i * ((size_t)count_unknowns + 1) + (size_t)i] =
|
||||||
under(s_h2->lm) * 2;
|
under(s_h2->lm) * 2;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|||||||
@ -145,9 +145,8 @@ parse_eq(char *eqn, struct elt_list **elt_ptr, int association)
|
|||||||
/*
|
/*
|
||||||
* Malloc space and store element data for return
|
* Malloc space and store element data for return
|
||||||
*/
|
*/
|
||||||
*elt_ptr =
|
*elt_ptr = (struct elt_list *) PHRQ_malloc(((size_t)count_elts + 1) *
|
||||||
(struct elt_list *) PHRQ_malloc((size_t) (count_elts + 1) *
|
sizeof(struct elt_list));
|
||||||
sizeof(struct elt_list));
|
|
||||||
if (*elt_ptr == NULL)
|
if (*elt_ptr == NULL)
|
||||||
{
|
{
|
||||||
malloc_error();
|
malloc_error();
|
||||||
|
|||||||
@ -2084,9 +2084,9 @@ Restart:
|
|||||||
residuals();
|
residuals();
|
||||||
for (j = 0; j < count_unknowns; j++)
|
for (j = 0; j < count_unknowns; j++)
|
||||||
{
|
{
|
||||||
my_array[j * (count_unknowns + 1) + i] = -(residual[j] - base[j]) / d2;
|
my_array[(size_t)j * ((size_t)count_unknowns + 1) + (size_t)i] = -(residual[j] - base[j]) / d2;
|
||||||
if (x[i]->type == MH2O) // DL_pitz
|
if (x[i]->type == MH2O) // DL_pitz
|
||||||
my_array[j * (count_unknowns + 1) + i] *= mass_water_aq_x;
|
my_array[(size_t)j * ((size_t)count_unknowns + 1) + (size_t)i] *= mass_water_aq_x;
|
||||||
}
|
}
|
||||||
switch (x[i]->type)
|
switch (x[i]->type)
|
||||||
{
|
{
|
||||||
@ -2104,9 +2104,9 @@ Restart:
|
|||||||
break;
|
break;
|
||||||
case MH:
|
case MH:
|
||||||
s_eminus->la -= d;
|
s_eminus->la -= d;
|
||||||
if (my_array[i * (count_unknowns + 1) + i] == 0)
|
if (my_array[(size_t)i * ((size_t)count_unknowns + 1) + (size_t)i] == 0)
|
||||||
{
|
{
|
||||||
my_array[i * (count_unknowns + 1) + i] =
|
my_array[(size_t)i * ((size_t)count_unknowns + 1) + (size_t)i] =
|
||||||
exp(s_h2->lm * LOG_10) * 2;
|
exp(s_h2->lm * LOG_10) * 2;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|||||||
@ -544,7 +544,7 @@ build_gas_phase(void)
|
|||||||
row / (count_unknowns + 1), col));
|
row / (count_unknowns + 1), col));
|
||||||
}
|
}
|
||||||
store_jacob(&(phase_ptr->moles_x),
|
store_jacob(&(phase_ptr->moles_x),
|
||||||
&(my_array[row + col]), coef);
|
&(my_array[(size_t)row + (size_t)col]), coef);
|
||||||
}
|
}
|
||||||
if (gas_phase_ptr->Get_type() == cxxGasPhase::GP_PRESSURE)
|
if (gas_phase_ptr->Get_type() == cxxGasPhase::GP_PRESSURE)
|
||||||
{
|
{
|
||||||
@ -557,7 +557,7 @@ build_gas_phase(void)
|
|||||||
gas_unknown->number));
|
gas_unknown->number));
|
||||||
}
|
}
|
||||||
store_jacob(&(phase_ptr->fraction_x),
|
store_jacob(&(phase_ptr->fraction_x),
|
||||||
&(my_array[row + gas_unknown->number]), coef_elt);
|
&(my_array[(size_t)row + (size_t)gas_unknown->number]), coef_elt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
@ -634,7 +634,7 @@ build_gas_phase(void)
|
|||||||
master_ptr->s->name, (double) coef,
|
master_ptr->s->name, (double) coef,
|
||||||
row / (count_unknowns + 1), col));
|
row / (count_unknowns + 1), col));
|
||||||
}
|
}
|
||||||
store_jacob(&(phase_ptr->p_soln_x), &(my_array[row + col]), coef);
|
store_jacob(&(phase_ptr->p_soln_x), &(my_array[(size_t)row + (size_t)col]), coef);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -727,11 +727,11 @@ build_ss_assemblage(void)
|
|||||||
{
|
{
|
||||||
col = x[i]->number - 1;
|
col = x[i]->number - 1;
|
||||||
}
|
}
|
||||||
store_jacob(&(x[i]->phase->dnc), &(my_array[row + col]), -1);
|
store_jacob(&(x[i]->phase->dnc), &(my_array[(size_t)row + (size_t)col]), -1);
|
||||||
|
|
||||||
/* next dnb terms */
|
/* next dnb terms */
|
||||||
col++;
|
col++;
|
||||||
store_jacob(&(x[i]->phase->dnb), &(my_array[row + col]), -1);
|
store_jacob(&(x[i]->phase->dnb), &(my_array[(size_t)row + (size_t)col]), -1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -744,12 +744,12 @@ build_ss_assemblage(void)
|
|||||||
if ((int) j != x[i]->ss_comp_number)
|
if ((int) j != x[i]->ss_comp_number)
|
||||||
{
|
{
|
||||||
/* store_jacob (&(s_s_ptr->dn), &(array[row + col + j]), -1.0); */
|
/* store_jacob (&(s_s_ptr->dn), &(array[row + col + j]), -1.0); */
|
||||||
store_jacob(&(x[i]->phase->dn), &(my_array[row + col + j]),
|
store_jacob(&(x[i]->phase->dn), &(my_array[(size_t)row + (size_t)col + (size_t)j]),
|
||||||
-1.0);
|
-1.0);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
store_jacob(&(x[i]->phase->dnb), &(my_array[row + col + j]),
|
store_jacob(&(x[i]->phase->dnb), &(my_array[(size_t)row + (size_t)col + (size_t)j]),
|
||||||
-1.0);
|
-1.0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -905,10 +905,8 @@ build_jacobian_sums(int k)
|
|||||||
{
|
{
|
||||||
/* term for water, sum of all surfaces */
|
/* term for water, sum of all surfaces */
|
||||||
source = &s[k]->tot_dh2o_moles;
|
source = &s[k]->tot_dh2o_moles;
|
||||||
target =
|
target = &(my_array[(size_t)mb_unknowns[i].unknown->number *
|
||||||
&(my_array
|
((size_t)count_unknowns + 1) + (size_t)mass_oxygen_unknown->number]);
|
||||||
[mb_unknowns[i].unknown->number * (count_unknowns + 1) +
|
|
||||||
mass_oxygen_unknown->number]);
|
|
||||||
if (debug_prep == TRUE)
|
if (debug_prep == TRUE)
|
||||||
{
|
{
|
||||||
output_msg(sformatf( "\t\t%-24s%10.3f\t%d\t%d",
|
output_msg(sformatf( "\t\t%-24s%10.3f\t%d\t%d",
|
||||||
@ -927,8 +925,8 @@ build_jacobian_sums(int k)
|
|||||||
continue;
|
continue;
|
||||||
cxxSurfaceCharge *charge_ptr = use.Get_surface_ptr()->Find_charge(x[j]->surface_charge);
|
cxxSurfaceCharge *charge_ptr = use.Get_surface_ptr()->Find_charge(x[j]->surface_charge);
|
||||||
source = s_diff_layer[k][charge_ptr->Get_name()].Get_dx_moles_address();
|
source = s_diff_layer[k][charge_ptr->Get_name()].Get_dx_moles_address();
|
||||||
target = &(my_array[mb_unknowns[i].unknown->number *
|
target = &(my_array[(size_t)mb_unknowns[i].unknown->number *
|
||||||
(count_unknowns + 1) + x[j]->number]);
|
((size_t)count_unknowns + 1) + (size_t)x[j]->number]);
|
||||||
if (debug_prep == TRUE)
|
if (debug_prep == TRUE)
|
||||||
{
|
{
|
||||||
output_msg(sformatf( "\t\t%-24s%10.3f\t%d\t%d",
|
output_msg(sformatf( "\t\t%-24s%10.3f\t%d\t%d",
|
||||||
@ -949,7 +947,7 @@ build_jacobian_sums(int k)
|
|||||||
continue;
|
continue;
|
||||||
cxxSurfaceCharge *charge_ptr = use.Get_surface_ptr()->Find_charge(x[j]->surface_charge);
|
cxxSurfaceCharge *charge_ptr = use.Get_surface_ptr()->Find_charge(x[j]->surface_charge);
|
||||||
/* has related phase */
|
/* has related phase */
|
||||||
cxxSurfaceComp *comp_ptr = use.Get_surface_ptr()->Find_comp(x[j - 1]->surface_comp);
|
cxxSurfaceComp *comp_ptr = use.Get_surface_ptr()->Find_comp(x[(size_t)j - 1]->surface_comp);
|
||||||
if (comp_ptr->Get_phase_name().size() == 0)
|
if (comp_ptr->Get_phase_name().size() == 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@ -966,8 +964,8 @@ build_jacobian_sums(int k)
|
|||||||
if (kk >= 0)
|
if (kk >= 0)
|
||||||
{
|
{
|
||||||
source = s_diff_layer[k][charge_ptr->Get_name()].Get_drelated_moles_address();
|
source = s_diff_layer[k][charge_ptr->Get_name()].Get_drelated_moles_address();
|
||||||
target = &(my_array[mb_unknowns[i].unknown->number *
|
target = &(my_array[(size_t)mb_unknowns[i].unknown->number *
|
||||||
(count_unknowns + 1) + x[kk]->number]);
|
((size_t)count_unknowns + 1) + (size_t)x[kk]->number]);
|
||||||
if (debug_prep == TRUE)
|
if (debug_prep == TRUE)
|
||||||
{
|
{
|
||||||
output_msg(sformatf(
|
output_msg(sformatf(
|
||||||
@ -995,21 +993,20 @@ build_jacobian_sums(int k)
|
|||||||
if (mb_unknowns[i].unknown->number == x[j]->number)
|
if (mb_unknowns[i].unknown->number == x[j]->number)
|
||||||
{
|
{
|
||||||
source = s_diff_layer[k][charge_ptr->Get_name()].Get_dx_moles_address();
|
source = s_diff_layer[k][charge_ptr->Get_name()].Get_dx_moles_address();
|
||||||
target = &(my_array[mb_unknowns[i].unknown->number *
|
target = &(my_array[(size_t)mb_unknowns[i].unknown->number *
|
||||||
(count_unknowns + 1) + x[j]->number]);
|
((size_t)count_unknowns + 1) + (size_t)x[j]->number]);
|
||||||
if (debug_prep == TRUE)
|
if (debug_prep == TRUE)
|
||||||
{
|
{
|
||||||
output_msg(sformatf(
|
output_msg(sformatf("\t\t%-24s%10.3f\t%d\t%d", "dg/dlny",
|
||||||
"\t\t%-24s%10.3f\t%d\t%d", "dg/dlny",
|
(double)coef,
|
||||||
(double) coef,
|
mb_unknowns[i].unknown->number,
|
||||||
mb_unknowns[i].unknown->number,
|
x[j]->number));
|
||||||
x[j]->number));
|
|
||||||
}
|
}
|
||||||
store_jacob(source, target, coef);
|
store_jacob(source, target, coef);
|
||||||
|
|
||||||
/* term for related phase */
|
/* term for related phase */
|
||||||
/* has related phase */
|
/* has related phase */
|
||||||
cxxSurfaceComp *comp_ptr = use.Get_surface_ptr()->Find_comp(x[j - 1]->surface_comp);
|
cxxSurfaceComp *comp_ptr = use.Get_surface_ptr()->Find_comp(x[(size_t)j - 1]->surface_comp);
|
||||||
if (comp_ptr->Get_phase_name().size() > 0)
|
if (comp_ptr->Get_phase_name().size() > 0)
|
||||||
{
|
{
|
||||||
/* now find the related phase */
|
/* now find the related phase */
|
||||||
@ -1024,8 +1021,8 @@ build_jacobian_sums(int k)
|
|||||||
if (kk >= 0)
|
if (kk >= 0)
|
||||||
{
|
{
|
||||||
source = s_diff_layer[k][charge_ptr->Get_name()].Get_drelated_moles_address();
|
source = s_diff_layer[k][charge_ptr->Get_name()].Get_drelated_moles_address();
|
||||||
target = &(my_array[mb_unknowns[i].unknown->number *
|
target = &(my_array[(size_t)(size_t)mb_unknowns[i].unknown->number *
|
||||||
(count_unknowns + 1) + x[kk]->number]);
|
((size_t)count_unknowns + 1) + (size_t)x[kk]->number]);
|
||||||
if (debug_prep == TRUE)
|
if (debug_prep == TRUE)
|
||||||
{
|
{
|
||||||
output_msg(sformatf(
|
output_msg(sformatf(
|
||||||
@ -1042,9 +1039,9 @@ build_jacobian_sums(int k)
|
|||||||
{
|
{
|
||||||
/* term for water, for same surfaces */
|
/* term for water, for same surfaces */
|
||||||
source = s_diff_layer[k][charge_ptr->Get_name()].Get_dh2o_moles_address();
|
source = s_diff_layer[k][charge_ptr->Get_name()].Get_dh2o_moles_address();
|
||||||
target = &(my_array[mb_unknowns[i].unknown->number *
|
target = &(my_array[(size_t)mb_unknowns[i].unknown->number *
|
||||||
(count_unknowns + 1) +
|
((size_t)count_unknowns + 1) +
|
||||||
mass_oxygen_unknown->number]);
|
(size_t)mass_oxygen_unknown->number]);
|
||||||
if (debug_prep == TRUE)
|
if (debug_prep == TRUE)
|
||||||
{
|
{
|
||||||
output_msg(sformatf(
|
output_msg(sformatf(
|
||||||
@ -1296,14 +1293,14 @@ build_model(void)
|
|||||||
k = j0;
|
k = j0;
|
||||||
for (i = j0; i < j; i++)
|
for (i = j0; i < j; i++)
|
||||||
{
|
{
|
||||||
if (s_x[i - j0]->type == EX)
|
if (s_x[(size_t)i - (size_t)j0]->type == EX)
|
||||||
continue;
|
continue;
|
||||||
if (s_x[i - j0]->type == SURF)
|
if (s_x[(size_t)i - (size_t)j0]->type == SURF)
|
||||||
continue;
|
continue;
|
||||||
x[k]->number = k;
|
x[k]->number = k;
|
||||||
x[k]->type = PITZER_GAMMA;
|
x[k]->type = PITZER_GAMMA;
|
||||||
x[k]->s = s_x[i - j0];
|
x[k]->s = s_x[(size_t)i - (size_t)j0];
|
||||||
x[k]->description = s_x[i - j0]->name;
|
x[k]->description = s_x[(size_t)i - (size_t)j0]->name;
|
||||||
k++;
|
k++;
|
||||||
count_unknowns++;
|
count_unknowns++;
|
||||||
}
|
}
|
||||||
@ -2045,14 +2042,8 @@ get_list_master_ptrs(char *ptr, struct master *master_ptr)
|
|||||||
{
|
{
|
||||||
if (master[j]->s->primary == NULL)
|
if (master[j]->s->primary == NULL)
|
||||||
{
|
{
|
||||||
master_ptr_list =
|
master_ptr_list = (struct master **) PHRQ_realloc((void *)
|
||||||
(struct master **) PHRQ_realloc((void *)
|
master_ptr_list, ((size_t)count_list + 2) * sizeof(struct master *));
|
||||||
master_ptr_list,
|
|
||||||
(size_t) (count_list
|
|
||||||
+
|
|
||||||
2) *
|
|
||||||
sizeof(struct master
|
|
||||||
*));
|
|
||||||
if (master_ptr_list == NULL)
|
if (master_ptr_list == NULL)
|
||||||
malloc_error();
|
malloc_error();
|
||||||
master_ptr_list[count_list++] = master[j];
|
master_ptr_list[count_list++] = master[j];
|
||||||
@ -2072,11 +2063,8 @@ get_list_master_ptrs(char *ptr, struct master *master_ptr)
|
|||||||
master_ptr = master_bsearch(token);
|
master_ptr = master_bsearch(token);
|
||||||
if (master_ptr != NULL)
|
if (master_ptr != NULL)
|
||||||
{
|
{
|
||||||
master_ptr_list =
|
master_ptr_list = (struct master **) PHRQ_realloc((void *) master_ptr_list,
|
||||||
(struct master **) PHRQ_realloc((void *) master_ptr_list,
|
((size_t)count_list + 2) * sizeof(struct master *));
|
||||||
(size_t) (count_list +
|
|
||||||
2) *
|
|
||||||
sizeof(struct master *));
|
|
||||||
if (master_ptr_list == NULL)
|
if (master_ptr_list == NULL)
|
||||||
malloc_error();
|
malloc_error();
|
||||||
master_ptr_list[count_list++] = master_ptr;
|
master_ptr_list[count_list++] = master_ptr;
|
||||||
@ -2268,7 +2256,7 @@ mb_for_species_aq(int n)
|
|||||||
cxxSurfaceCharge *charge_ptr = use.Get_surface_ptr()->Find_charge(x[i]->surface_charge);
|
cxxSurfaceCharge *charge_ptr = use.Get_surface_ptr()->Find_charge(x[i]->surface_charge);
|
||||||
unknown_ptr = x[i];
|
unknown_ptr = x[i];
|
||||||
if (use.Get_surface_ptr()->Get_type() == cxxSurface::CD_MUSIC)
|
if (use.Get_surface_ptr()->Get_type() == cxxSurface::CD_MUSIC)
|
||||||
unknown_ptr = x[i + 2];
|
unknown_ptr = x[(size_t)i + 2];
|
||||||
|
|
||||||
store_mb_unknowns(unknown_ptr, s_diff_layer[n][charge_ptr->Get_name()].Get_g_moles_address(),
|
store_mb_unknowns(unknown_ptr, s_diff_layer[n][charge_ptr->Get_name()].Get_g_moles_address(),
|
||||||
s[n]->z, s_diff_layer[n][charge_ptr->Get_name()].Get_dg_g_moles_address());
|
s[n]->z, s_diff_layer[n][charge_ptr->Get_name()].Get_dg_g_moles_address());
|
||||||
@ -3413,7 +3401,7 @@ setup_surface(void)
|
|||||||
struct unknown *unknown_ptr = find_surface_charge_unknown(token, SURF_PSI);
|
struct unknown *unknown_ptr = find_surface_charge_unknown(token, SURF_PSI);
|
||||||
if (unknown_ptr != NULL)
|
if (unknown_ptr != NULL)
|
||||||
{
|
{
|
||||||
x[count_unknowns - 1]->potential_unknown = unknown_ptr;
|
x[(size_t)count_unknowns - 1]->potential_unknown = unknown_ptr;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -3445,10 +3433,8 @@ setup_surface(void)
|
|||||||
x[count_unknowns]->master = master_ptr_list;
|
x[count_unknowns]->master = master_ptr_list;
|
||||||
x[count_unknowns]->master[0]->unknown = x[count_unknowns];
|
x[count_unknowns]->master[0]->unknown = x[count_unknowns];
|
||||||
x[count_unknowns]->moles = 0.0;
|
x[count_unknowns]->moles = 0.0;
|
||||||
x[count_unknowns - 1]->potential_unknown =
|
x[(size_t)count_unknowns - 1]->potential_unknown = x[count_unknowns];
|
||||||
x[count_unknowns];
|
x[count_unknowns]->surface_comp = x[(size_t)count_unknowns - 1]->surface_comp;
|
||||||
x[count_unknowns]->surface_comp =
|
|
||||||
x[count_unknowns - 1]->surface_comp;
|
|
||||||
count_unknowns++;
|
count_unknowns++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3547,7 +3533,7 @@ setup_surface(void)
|
|||||||
/* Add SURFACE unknown to a list for SURF_PSI */
|
/* Add SURFACE unknown to a list for SURF_PSI */
|
||||||
struct unknown *unknown_ptr = find_surface_charge_unknown(token, SURF_PSI);
|
struct unknown *unknown_ptr = find_surface_charge_unknown(token, SURF_PSI);
|
||||||
unknown_ptr->comp_unknowns = (struct unknown **) PHRQ_realloc(unknown_ptr->comp_unknowns,
|
unknown_ptr->comp_unknowns = (struct unknown **) PHRQ_realloc(unknown_ptr->comp_unknowns,
|
||||||
(size_t) ((unknown_ptr->count_comp_unknowns + 1) * sizeof(struct unknown *)));
|
(((size_t)unknown_ptr->count_comp_unknowns + 1) * sizeof(struct unknown *)));
|
||||||
if (unknown_ptr->comp_unknowns == NULL)
|
if (unknown_ptr->comp_unknowns == NULL)
|
||||||
malloc_error();
|
malloc_error();
|
||||||
unknown_ptr->comp_unknowns[unknown_ptr->count_comp_unknowns++] =
|
unknown_ptr->comp_unknowns[unknown_ptr->count_comp_unknowns++] =
|
||||||
@ -4709,8 +4695,8 @@ setup_unknowns(void)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
max_unknowns += (int) (use.Get_surface_ptr()->Get_surface_comps().size() +
|
max_unknowns += (int)(use.Get_surface_ptr()->Get_surface_comps().size() +
|
||||||
4 * (int) use.Get_surface_ptr()->Get_surface_charges().size());
|
4 * use.Get_surface_ptr()->Get_surface_charges().size());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
@ -4794,7 +4780,7 @@ store_dn(int k, LDBLE * source, int row, LDBLE coef_in, LDBLE * gamma_source)
|
|||||||
/* mu term */
|
/* mu term */
|
||||||
if (gamma_source != NULL)
|
if (gamma_source != NULL)
|
||||||
{
|
{
|
||||||
store_jacob(gamma_source, &my_array[row + mu_unknown->number],
|
store_jacob(gamma_source, &my_array[(size_t)row + (size_t)mu_unknown->number],
|
||||||
-1.0 * coef_in);
|
-1.0 * coef_in);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -4810,7 +4796,7 @@ store_dn(int k, LDBLE * source, int row, LDBLE coef_in, LDBLE * gamma_source)
|
|||||||
(double) coef_in, row / (count_unknowns + 1),
|
(double) coef_in, row / (count_unknowns + 1),
|
||||||
mass_oxygen_unknown->number));
|
mass_oxygen_unknown->number));
|
||||||
}
|
}
|
||||||
store_jacob(source, &(my_array[row + mass_oxygen_unknown->number]),
|
store_jacob(source, &(my_array[(size_t)row + (size_t)mass_oxygen_unknown->number]),
|
||||||
coef_in);
|
coef_in);
|
||||||
}
|
}
|
||||||
if (s[k] == s_h2o)
|
if (s[k] == s_h2o)
|
||||||
@ -4840,7 +4826,7 @@ store_dn(int k, LDBLE * source, int row, LDBLE coef_in, LDBLE * gamma_source)
|
|||||||
master_ptr->s->name, (double) coef,
|
master_ptr->s->name, (double) coef,
|
||||||
row / (count_unknowns + 1), col));
|
row / (count_unknowns + 1), col));
|
||||||
}
|
}
|
||||||
store_jacob(source, &(my_array[row + col]), coef);
|
store_jacob(source, &(my_array[(size_t)row + (size_t)col]), coef);
|
||||||
}
|
}
|
||||||
return (OK);
|
return (OK);
|
||||||
}
|
}
|
||||||
@ -6281,9 +6267,9 @@ build_min_surface(void)
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* update grams == moles in this case */
|
/* update grams == moles in this case */
|
||||||
if (j < count_unknowns - 1 && x[j + 1]->type == SURFACE_CB)
|
if (j < count_unknowns - 1 && x[(size_t)j + 1]->type == SURFACE_CB)
|
||||||
{
|
{
|
||||||
store_sum_deltas(&delta[k], &(x[j + 1]->related_moles), -1.0);
|
store_sum_deltas(&delta[k], &(x[(size_t)j + 1]->related_moles), -1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* charge balance */
|
/* charge balance */
|
||||||
@ -6408,7 +6394,7 @@ setup_related_surface(void)
|
|||||||
}
|
}
|
||||||
else if (x[i]->type == SURFACE_CB)
|
else if (x[i]->type == SURFACE_CB)
|
||||||
{
|
{
|
||||||
cxxSurfaceComp *comp_ptr = use.Get_surface_ptr()->Find_comp(x[i-1]->surface_comp);
|
cxxSurfaceComp *comp_ptr = use.Get_surface_ptr()->Find_comp(x[(size_t)i-1]->surface_comp);
|
||||||
if (comp_ptr->Get_phase_name().size() > 0)
|
if (comp_ptr->Get_phase_name().size() > 0)
|
||||||
{
|
{
|
||||||
cxxSurfaceComp *comp_i_ptr = use.Get_surface_ptr()->Find_comp(x[i]->surface_comp);
|
cxxSurfaceComp *comp_i_ptr = use.Get_surface_ptr()->Find_comp(x[i]->surface_comp);
|
||||||
|
|||||||
@ -1892,9 +1892,8 @@ print_surface_cd_music(void)
|
|||||||
*/
|
*/
|
||||||
if (dl_type_x != cxxSurface::NO_DL)
|
if (dl_type_x != cxxSurface::NO_DL)
|
||||||
{
|
{
|
||||||
output_msg(sformatf(
|
output_msg(sformatf("\t%11.3e Surface + diffuse layer charge, eq\n\n",
|
||||||
"\t%11.3e Surface + diffuse layer charge, eq\n\n",
|
(double)(x[(size_t)j + 2]->f + (charge_ptr->Get_sigma0() + charge_ptr->Get_sigma1()) * (charge_ptr->Get_specific_area() * charge_ptr->Get_grams()) / F_C_MOL)));
|
||||||
(double) (x[j + 2]->f + (charge_ptr->Get_sigma0() + charge_ptr->Get_sigma1()) * (charge_ptr->Get_specific_area() * charge_ptr->Get_grams()) / F_C_MOL)));
|
|
||||||
}
|
}
|
||||||
master_ptr0 =
|
master_ptr0 =
|
||||||
surface_get_psi_master(charge_ptr->Get_name().c_str(), SURF_PSI);
|
surface_get_psi_master(charge_ptr->Get_name().c_str(), SURF_PSI);
|
||||||
|
|||||||
@ -656,15 +656,8 @@ read_exchange_species(void)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
s_ptr->add_logk =
|
s_ptr->add_logk = (struct name_coef *) PHRQ_realloc(s_ptr->add_logk,
|
||||||
(struct name_coef *) PHRQ_realloc(s_ptr->add_logk,
|
(((size_t)s_ptr->count_add_logk + 1) * sizeof(struct name_coef)));
|
||||||
(size_t) ((s_ptr->
|
|
||||||
count_add_logk
|
|
||||||
+
|
|
||||||
1) *
|
|
||||||
sizeof
|
|
||||||
(struct
|
|
||||||
name_coef)));
|
|
||||||
if (s_ptr->add_logk == NULL)
|
if (s_ptr->add_logk == NULL)
|
||||||
{
|
{
|
||||||
malloc_error();
|
malloc_error();
|
||||||
@ -714,15 +707,8 @@ read_exchange_species(void)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
s_ptr->add_logk =
|
s_ptr->add_logk = (struct name_coef *) PHRQ_realloc(s_ptr->add_logk,
|
||||||
(struct name_coef *) PHRQ_realloc(s_ptr->add_logk,
|
(((size_t)s_ptr->count_add_logk + 1) * sizeof(struct name_coef)));
|
||||||
(size_t) ((s_ptr->
|
|
||||||
count_add_logk
|
|
||||||
+
|
|
||||||
1) *
|
|
||||||
sizeof
|
|
||||||
(struct
|
|
||||||
name_coef)));
|
|
||||||
if (s_ptr->add_logk == NULL)
|
if (s_ptr->add_logk == NULL)
|
||||||
{
|
{
|
||||||
malloc_error();
|
malloc_error();
|
||||||
@ -1701,12 +1687,8 @@ read_inv_balances(struct inverse *inverse_ptr, char *ptr)
|
|||||||
}
|
}
|
||||||
else if (strcmp_nocase_arg1(token, "ph") != 0)
|
else if (strcmp_nocase_arg1(token, "ph") != 0)
|
||||||
{
|
{
|
||||||
inverse_ptr->elts =
|
inverse_ptr->elts = (struct inv_elts *) PHRQ_realloc(inverse_ptr->elts,
|
||||||
(struct inv_elts *) PHRQ_realloc(inverse_ptr->elts,
|
((size_t)inverse_ptr->count_elts + 1) * sizeof(struct inv_elts));
|
||||||
(size_t) (inverse_ptr->
|
|
||||||
count_elts +
|
|
||||||
1) *
|
|
||||||
sizeof(struct inv_elts));
|
|
||||||
if (inverse_ptr->elts == NULL)
|
if (inverse_ptr->elts == NULL)
|
||||||
malloc_error();
|
malloc_error();
|
||||||
replace("(+", "(", token);
|
replace("(+", "(", token);
|
||||||
@ -1794,18 +1776,12 @@ read_inv_isotopes(struct inverse *inverse_ptr, char *ptr)
|
|||||||
}
|
}
|
||||||
if (i == inverse_ptr->count_isotopes)
|
if (i == inverse_ptr->count_isotopes)
|
||||||
{
|
{
|
||||||
inverse_ptr->isotopes =
|
inverse_ptr->isotopes = (struct inv_isotope *) PHRQ_realloc(inverse_ptr->isotopes,
|
||||||
(struct inv_isotope *) PHRQ_realloc(inverse_ptr->isotopes,
|
((size_t)inverse_ptr->count_isotopes + 1) * sizeof(struct inv_isotope));
|
||||||
(size_t) (inverse_ptr->
|
|
||||||
count_isotopes +
|
|
||||||
1) *
|
|
||||||
sizeof(struct inv_isotope));
|
|
||||||
if (inverse_ptr->isotopes == NULL)
|
if (inverse_ptr->isotopes == NULL)
|
||||||
malloc_error();
|
malloc_error();
|
||||||
inverse_ptr->isotopes[inverse_ptr->count_isotopes].isotope_number =
|
inverse_ptr->isotopes[inverse_ptr->count_isotopes].isotope_number = isotope_number;
|
||||||
isotope_number;
|
inverse_ptr->isotopes[inverse_ptr->count_isotopes].elt_name = element_name;
|
||||||
inverse_ptr->isotopes[inverse_ptr->count_isotopes].elt_name =
|
|
||||||
element_name;
|
|
||||||
inverse_ptr->isotopes[inverse_ptr->count_isotopes].uncertainties =
|
inverse_ptr->isotopes[inverse_ptr->count_isotopes].uncertainties =
|
||||||
(LDBLE *) PHRQ_malloc((size_t) sizeof(LDBLE));
|
(LDBLE *) PHRQ_malloc((size_t) sizeof(LDBLE));
|
||||||
if (inverse_ptr->isotopes[inverse_ptr->count_isotopes].
|
if (inverse_ptr->isotopes[inverse_ptr->count_isotopes].
|
||||||
@ -1816,12 +1792,8 @@ read_inv_isotopes(struct inverse *inverse_ptr, char *ptr)
|
|||||||
/*
|
/*
|
||||||
* add redox state name to inv_ptr->i_u
|
* add redox state name to inv_ptr->i_u
|
||||||
*/
|
*/
|
||||||
inverse_ptr->i_u =
|
inverse_ptr->i_u = (struct inv_isotope *) PHRQ_realloc(inverse_ptr->i_u,
|
||||||
(struct inv_isotope *) PHRQ_realloc(inverse_ptr->i_u,
|
((size_t)inverse_ptr->count_i_u + 1) * sizeof(struct inv_isotope));
|
||||||
(size_t) (inverse_ptr->
|
|
||||||
count_i_u +
|
|
||||||
1) *
|
|
||||||
sizeof(struct inv_isotope));
|
|
||||||
if (inverse_ptr->i_u == NULL)
|
if (inverse_ptr->i_u == NULL)
|
||||||
{
|
{
|
||||||
malloc_error();
|
malloc_error();
|
||||||
@ -1853,12 +1825,8 @@ read_inv_phases(struct inverse *inverse_ptr, char *ptr)
|
|||||||
j = copy_token(token, &ptr, &l);
|
j = copy_token(token, &ptr, &l);
|
||||||
if (j == EMPTY)
|
if (j == EMPTY)
|
||||||
return (OK);
|
return (OK);
|
||||||
inverse_ptr->phases =
|
inverse_ptr->phases = (struct inv_phases *) PHRQ_realloc(inverse_ptr->phases,
|
||||||
(struct inv_phases *) PHRQ_realloc(inverse_ptr->phases,
|
((size_t)inverse_ptr->count_phases + 1) * sizeof(struct inv_phases));
|
||||||
(size_t) (inverse_ptr->
|
|
||||||
count_phases +
|
|
||||||
1) *
|
|
||||||
sizeof(struct inv_phases));
|
|
||||||
if (inverse_ptr->phases == NULL)
|
if (inverse_ptr->phases == NULL)
|
||||||
malloc_error();
|
malloc_error();
|
||||||
inverse_ptr->phases[inverse_ptr->count_phases].name = string_hsave(token);
|
inverse_ptr->phases[inverse_ptr->count_phases].name = string_hsave(token);
|
||||||
@ -3772,15 +3740,8 @@ read_phases(void)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
phase_ptr->add_logk =
|
phase_ptr->add_logk = (struct name_coef *) PHRQ_realloc(phase_ptr->add_logk,
|
||||||
(struct name_coef *) PHRQ_realloc(phase_ptr->add_logk,
|
(((size_t)phase_ptr->count_add_logk + 1) * sizeof(struct name_coef)));
|
||||||
(size_t) ((phase_ptr->
|
|
||||||
count_add_logk
|
|
||||||
+
|
|
||||||
1) *
|
|
||||||
sizeof
|
|
||||||
(struct
|
|
||||||
name_coef)));
|
|
||||||
if (phase_ptr->add_logk == NULL)
|
if (phase_ptr->add_logk == NULL)
|
||||||
malloc_error();
|
malloc_error();
|
||||||
}
|
}
|
||||||
@ -3818,20 +3779,13 @@ read_phases(void)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
phase_ptr->add_logk =
|
phase_ptr->add_logk = (struct name_coef *) PHRQ_realloc(phase_ptr->add_logk,
|
||||||
(struct name_coef *) PHRQ_realloc(phase_ptr->add_logk,
|
(((size_t)phase_ptr->count_add_logk + 1) * sizeof(struct name_coef)));
|
||||||
(size_t) ((phase_ptr->
|
|
||||||
count_add_logk
|
|
||||||
+
|
|
||||||
1) *
|
|
||||||
sizeof
|
|
||||||
(struct
|
|
||||||
name_coef)));
|
|
||||||
if (phase_ptr->add_logk == NULL)
|
if (phase_ptr->add_logk == NULL)
|
||||||
malloc_error();
|
malloc_error();
|
||||||
}
|
}
|
||||||
i = sscanf(next_char, SCANFORMAT,
|
i = sscanf(next_char, SCANFORMAT,
|
||||||
&phase_ptr->add_logk[phase_ptr->count_add_logk].coef);
|
&phase_ptr->add_logk[(size_t)phase_ptr->count_add_logk].coef);
|
||||||
if (i <= 0)
|
if (i <= 0)
|
||||||
{
|
{
|
||||||
input_error++;
|
input_error++;
|
||||||
@ -5678,15 +5632,8 @@ read_species(void)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
s_ptr->add_logk =
|
s_ptr->add_logk = (struct name_coef *) PHRQ_realloc(s_ptr->add_logk,
|
||||||
(struct name_coef *) PHRQ_realloc(s_ptr->add_logk,
|
(((size_t)s_ptr->count_add_logk + 1) * sizeof(struct name_coef)));
|
||||||
(size_t) ((s_ptr->
|
|
||||||
count_add_logk
|
|
||||||
+
|
|
||||||
1) *
|
|
||||||
sizeof
|
|
||||||
(struct
|
|
||||||
name_coef)));
|
|
||||||
if (s_ptr->add_logk == NULL)
|
if (s_ptr->add_logk == NULL)
|
||||||
malloc_error();
|
malloc_error();
|
||||||
}
|
}
|
||||||
@ -5730,15 +5677,8 @@ read_species(void)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
s_ptr->add_logk =
|
s_ptr->add_logk = (struct name_coef *) PHRQ_realloc(s_ptr->add_logk,
|
||||||
(struct name_coef *) PHRQ_realloc(s_ptr->add_logk,
|
(((size_t)s_ptr->count_add_logk + 1) * sizeof(struct name_coef)));
|
||||||
(size_t) ((s_ptr->
|
|
||||||
count_add_logk
|
|
||||||
+
|
|
||||||
1) *
|
|
||||||
sizeof
|
|
||||||
(struct
|
|
||||||
name_coef)));
|
|
||||||
if (s_ptr->add_logk == NULL)
|
if (s_ptr->add_logk == NULL)
|
||||||
malloc_error();
|
malloc_error();
|
||||||
}
|
}
|
||||||
@ -6391,15 +6331,8 @@ read_surface_species(void)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
s_ptr->add_logk =
|
s_ptr->add_logk = (struct name_coef *) PHRQ_realloc(s_ptr->add_logk,
|
||||||
(struct name_coef *) PHRQ_realloc(s_ptr->add_logk,
|
(((size_t)s_ptr->count_add_logk + 1) * sizeof(struct name_coef)));
|
||||||
(size_t) ((s_ptr->
|
|
||||||
count_add_logk
|
|
||||||
+
|
|
||||||
1) *
|
|
||||||
sizeof
|
|
||||||
(struct
|
|
||||||
name_coef)));
|
|
||||||
if (s_ptr->add_logk == NULL)
|
if (s_ptr->add_logk == NULL)
|
||||||
{
|
{
|
||||||
malloc_error();
|
malloc_error();
|
||||||
@ -6446,15 +6379,8 @@ read_surface_species(void)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
s_ptr->add_logk =
|
s_ptr->add_logk = (struct name_coef *) PHRQ_realloc(s_ptr->add_logk,
|
||||||
(struct name_coef *) PHRQ_realloc(s_ptr->add_logk,
|
(((size_t)s_ptr->count_add_logk + 1) * sizeof(struct name_coef)));
|
||||||
(size_t) ((s_ptr->
|
|
||||||
count_add_logk
|
|
||||||
+
|
|
||||||
1) *
|
|
||||||
sizeof
|
|
||||||
(struct
|
|
||||||
name_coef)));
|
|
||||||
if (s_ptr->add_logk == NULL)
|
if (s_ptr->add_logk == NULL)
|
||||||
malloc_error();
|
malloc_error();
|
||||||
}
|
}
|
||||||
@ -7448,10 +7374,8 @@ read_title(void)
|
|||||||
*/
|
*/
|
||||||
title_x_length = (int) strlen(title_x);
|
title_x_length = (int) strlen(title_x);
|
||||||
line_length = (int) strlen(line);
|
line_length = (int) strlen(line);
|
||||||
title_x =
|
title_x = (char *) PHRQ_realloc(title_x,
|
||||||
(char *) PHRQ_realloc(title_x,
|
((size_t)title_x_length + (size_t)line_length + 2) * sizeof(char));
|
||||||
(size_t) (title_x_length + line_length +
|
|
||||||
2) * sizeof(char));
|
|
||||||
if (title_x == NULL)
|
if (title_x == NULL)
|
||||||
malloc_error();
|
malloc_error();
|
||||||
if (title_x_length > 0)
|
if (title_x_length > 0)
|
||||||
@ -7656,9 +7580,8 @@ read_advection(void)
|
|||||||
/*
|
/*
|
||||||
* Fill in data for punch
|
* Fill in data for punch
|
||||||
*/
|
*/
|
||||||
advection_punch =
|
advection_punch = (int *) PHRQ_realloc(advection_punch,
|
||||||
(int *) PHRQ_realloc(advection_punch,
|
((size_t)count_ad_cells + 1) * sizeof(int));
|
||||||
(size_t) (count_ad_cells + 1) * sizeof(int));
|
|
||||||
if (advection_punch == NULL)
|
if (advection_punch == NULL)
|
||||||
malloc_error();
|
malloc_error();
|
||||||
if (count_punch != 0)
|
if (count_punch != 0)
|
||||||
@ -7689,9 +7612,8 @@ read_advection(void)
|
|||||||
/*
|
/*
|
||||||
* Fill in data for print
|
* Fill in data for print
|
||||||
*/
|
*/
|
||||||
advection_print =
|
advection_print = (int *) PHRQ_realloc(advection_print,
|
||||||
(int *) PHRQ_realloc(advection_print,
|
((size_t)count_ad_cells + 1) * sizeof(int));
|
||||||
(size_t) (count_ad_cells + 1) * sizeof(int));
|
|
||||||
if (advection_print == NULL)
|
if (advection_print == NULL)
|
||||||
malloc_error();
|
malloc_error();
|
||||||
if (count_print != 0)
|
if (count_print != 0)
|
||||||
@ -8602,10 +8524,8 @@ read_rates(void)
|
|||||||
}
|
}
|
||||||
length = (int) strlen(rate_ptr->commands);
|
length = (int) strlen(rate_ptr->commands);
|
||||||
line_length = (int) strlen(line);
|
line_length = (int) strlen(line);
|
||||||
rate_ptr->commands =
|
rate_ptr->commands = (char *) PHRQ_realloc(rate_ptr->commands,
|
||||||
(char *) PHRQ_realloc(rate_ptr->commands,
|
((size_t)length + (size_t)line_length + 2) * sizeof(char));
|
||||||
(size_t) (length + line_length +
|
|
||||||
2) * sizeof(char));
|
|
||||||
if (rate_ptr->commands == NULL)
|
if (rate_ptr->commands == NULL)
|
||||||
{
|
{
|
||||||
malloc_error();
|
malloc_error();
|
||||||
@ -8701,10 +8621,8 @@ read_user_print(void)
|
|||||||
case OPT_1: /* read command */
|
case OPT_1: /* read command */
|
||||||
length = (int) strlen(user_print->commands);
|
length = (int) strlen(user_print->commands);
|
||||||
line_length = (int) strlen(line);
|
line_length = (int) strlen(line);
|
||||||
user_print->commands =
|
user_print->commands = (char *) PHRQ_realloc(user_print->commands,
|
||||||
(char *) PHRQ_realloc(user_print->commands,
|
((size_t)length + (size_t)line_length + 2) * sizeof(char));
|
||||||
(size_t) (length + line_length +
|
|
||||||
2) * sizeof(char));
|
|
||||||
if (user_print->commands == NULL)
|
if (user_print->commands == NULL)
|
||||||
malloc_error();
|
malloc_error();
|
||||||
user_print->commands[length] = ';';
|
user_print->commands[length] = ';';
|
||||||
@ -8838,7 +8756,7 @@ read_user_punch(void)
|
|||||||
length = (int) strlen(r->commands);
|
length = (int) strlen(r->commands);
|
||||||
line_length = (int) strlen(line);
|
line_length = (int) strlen(line);
|
||||||
r->commands = (char *) PHRQ_realloc(r->commands,
|
r->commands = (char *) PHRQ_realloc(r->commands,
|
||||||
(size_t) (length + line_length + 2) * sizeof(char));
|
((size_t)length + (size_t)line_length + 2) * sizeof(char));
|
||||||
if (r->commands == NULL)
|
if (r->commands == NULL)
|
||||||
{
|
{
|
||||||
malloc_error();
|
malloc_error();
|
||||||
@ -9945,15 +9863,8 @@ read_named_logk(void)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
logk_ptr->add_logk =
|
logk_ptr->add_logk = (struct name_coef *) PHRQ_realloc(logk_ptr->add_logk,
|
||||||
(struct name_coef *) PHRQ_realloc(logk_ptr->add_logk,
|
(((size_t)logk_ptr->count_add_logk + 1) * sizeof(struct name_coef)));
|
||||||
(size_t) ((logk_ptr->
|
|
||||||
count_add_logk
|
|
||||||
+
|
|
||||||
1) *
|
|
||||||
sizeof
|
|
||||||
(struct
|
|
||||||
name_coef)));
|
|
||||||
if (logk_ptr->add_logk == NULL)
|
if (logk_ptr->add_logk == NULL)
|
||||||
malloc_error();
|
malloc_error();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -745,7 +745,7 @@ read_transport(void)
|
|||||||
if (count_disp > max_cells)
|
if (count_disp > max_cells)
|
||||||
max_cells = count_disp;
|
max_cells = count_disp;
|
||||||
if (count_por > max_cells * (1 + stag_data->count_stag))
|
if (count_por > max_cells * (1 + stag_data->count_stag))
|
||||||
max_cells = (int)ceil(((double)count_por / (double)(1 + stag_data->count_stag)));
|
max_cells = (int)ceil(((double)count_por / (1 + (double)stag_data->count_stag)));
|
||||||
if (max_cells > count_cells)
|
if (max_cells > count_cells)
|
||||||
{
|
{
|
||||||
if (max_cells == count_length)
|
if (max_cells == count_length)
|
||||||
@ -766,7 +766,7 @@ read_transport(void)
|
|||||||
{
|
{
|
||||||
sprintf(token,
|
sprintf(token,
|
||||||
"Number of mobile cells is increased to (ceil)(number of porosities) / (1 + number of stagnant zones) = %d.",
|
"Number of mobile cells is increased to (ceil)(number of porosities) / (1 + number of stagnant zones) = %d.",
|
||||||
(int) ceil(((double)count_por / (double)(1 + stag_data->count_stag))));
|
(int) ceil(((double)count_por / (1 + (double)stag_data->count_stag))));
|
||||||
warning_msg(token);
|
warning_msg(token);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -911,7 +911,7 @@ Restart:
|
|||||||
residuals();
|
residuals();
|
||||||
for (j = 0; j < count_unknowns; j++)
|
for (j = 0; j < count_unknowns; j++)
|
||||||
{
|
{
|
||||||
my_array[j * (count_unknowns + 1) + i] =
|
my_array[(size_t)j * ((size_t)count_unknowns + 1) + (size_t)i] =
|
||||||
-(residual[j] - base[j]) / d2;
|
-(residual[j] - base[j]) / d2;
|
||||||
}
|
}
|
||||||
switch (x[i]->type)
|
switch (x[i]->type)
|
||||||
@ -930,9 +930,9 @@ Restart:
|
|||||||
break;
|
break;
|
||||||
case MH:
|
case MH:
|
||||||
s_eminus->la -= d;
|
s_eminus->la -= d;
|
||||||
if (my_array[i * (count_unknowns + 1) + i] == 0)
|
if (my_array[(size_t)i * ((size_t)count_unknowns + 1) + (size_t)i] == 0)
|
||||||
{
|
{
|
||||||
my_array[i * (count_unknowns + 1) + i] =
|
my_array[(size_t)i * ((size_t)count_unknowns + 1) + (size_t)i] =
|
||||||
exp(s_h2->lm * LOG_10) * 2;
|
exp(s_h2->lm * LOG_10) * 2;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|||||||
@ -83,7 +83,7 @@ denalloc(integertype n)
|
|||||||
if (a == NULL)
|
if (a == NULL)
|
||||||
return (NULL);
|
return (NULL);
|
||||||
|
|
||||||
a[0] = (realtype *) malloc(n * n * sizeof(realtype));
|
a[0] = (realtype *) malloc((size_t)n * (size_t)n * sizeof(realtype));
|
||||||
if (a[0] == NULL)
|
if (a[0] == NULL)
|
||||||
{
|
{
|
||||||
free(a);
|
free(a);
|
||||||
@ -91,7 +91,7 @@ denalloc(integertype n)
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (j = 1; j < n; j++)
|
for (j = 1; j < n; j++)
|
||||||
a[j] = a[0] + j * n;
|
a[j] = a[0] + (size_t)j * (size_t)n;
|
||||||
|
|
||||||
return (a);
|
return (a);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -377,11 +377,8 @@ read_solution_spread(void)
|
|||||||
}
|
}
|
||||||
if (i == soln_defaults.count_iso)
|
if (i == soln_defaults.count_iso)
|
||||||
{
|
{
|
||||||
soln_defaults.iso =
|
soln_defaults.iso = (struct iso *) PHRQ_realloc(soln_defaults.iso,
|
||||||
(struct iso *) PHRQ_realloc(soln_defaults.iso,
|
((size_t)i + 1) * sizeof(struct iso));
|
||||||
(size_t) (i +
|
|
||||||
1) *
|
|
||||||
sizeof(struct iso));
|
|
||||||
if (soln_defaults.iso == NULL)
|
if (soln_defaults.iso == NULL)
|
||||||
{
|
{
|
||||||
malloc_error();
|
malloc_error();
|
||||||
@ -463,11 +460,8 @@ read_solution_spread(void)
|
|||||||
}
|
}
|
||||||
if (i == soln_defaults.count_iso)
|
if (i == soln_defaults.count_iso)
|
||||||
{
|
{
|
||||||
soln_defaults.iso =
|
soln_defaults.iso = (struct iso *) PHRQ_realloc(soln_defaults.iso,
|
||||||
(struct iso *) PHRQ_realloc(soln_defaults.iso,
|
((size_t)i + 1) * sizeof(struct iso));
|
||||||
(size_t) (i +
|
|
||||||
1) *
|
|
||||||
sizeof(struct iso));
|
|
||||||
if (soln_defaults.iso == NULL)
|
if (soln_defaults.iso == NULL)
|
||||||
{
|
{
|
||||||
malloc_error();
|
malloc_error();
|
||||||
|
|||||||
@ -823,7 +823,7 @@ add_reaction(cxxReaction *reaction_ptr, int step_number, LDBLE step_fraction)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
step_x = reaction_ptr->Get_steps()[step_number - 1];
|
step_x = reaction_ptr->Get_steps()[(size_t)step_number - 1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (reaction_ptr->Get_equalIncrements() && reaction_ptr->Get_steps().size()> 0)
|
else if (reaction_ptr->Get_equalIncrements() && reaction_ptr->Get_steps().size()> 0)
|
||||||
@ -851,11 +851,11 @@ add_reaction(cxxReaction *reaction_ptr, int step_number, LDBLE step_fraction)
|
|||||||
{
|
{
|
||||||
if (step_number > (int) reaction_ptr->Get_reaction_steps())
|
if (step_number > (int) reaction_ptr->Get_reaction_steps())
|
||||||
{
|
{
|
||||||
step_x = reaction_ptr->Get_steps()[reaction_ptr->Get_reaction_steps() - 1];
|
step_x = reaction_ptr->Get_steps()[(size_t)reaction_ptr->Get_reaction_steps() - 1];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
step_x = reaction_ptr->Get_steps()[step_number - 1];
|
step_x = reaction_ptr->Get_steps()[(size_t)step_number - 1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (reaction_ptr->Get_equalIncrements() && reaction_ptr->Get_steps().size()> 0)
|
else if (reaction_ptr->Get_equalIncrements() && reaction_ptr->Get_steps().size()> 0)
|
||||||
|
|||||||
@ -471,12 +471,12 @@ elt_list_dup(struct elt_list *elt_list_ptr_old)
|
|||||||
* Malloc space and store element data
|
* Malloc space and store element data
|
||||||
*/
|
*/
|
||||||
elt_list_ptr_new =
|
elt_list_ptr_new =
|
||||||
(struct elt_list *) PHRQ_malloc((size_t) (count_totals + 1) *
|
(struct elt_list *) PHRQ_malloc(((size_t)count_totals + 1) *
|
||||||
sizeof(struct elt_list));
|
sizeof(struct elt_list));
|
||||||
if (elt_list_ptr_new == NULL)
|
if (elt_list_ptr_new == NULL)
|
||||||
malloc_error();
|
malloc_error();
|
||||||
memcpy(elt_list_ptr_new, elt_list_ptr_old,
|
memcpy(elt_list_ptr_new, elt_list_ptr_old,
|
||||||
(size_t) (count_totals + 1) * sizeof(struct elt_list));
|
((size_t)count_totals + 1) * sizeof(struct elt_list));
|
||||||
return (elt_list_ptr_new);
|
return (elt_list_ptr_new);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -536,7 +536,7 @@ elt_list_save(void)
|
|||||||
/*
|
/*
|
||||||
* Malloc space and store element data
|
* Malloc space and store element data
|
||||||
*/
|
*/
|
||||||
elt_list_ptr = (struct elt_list*)PHRQ_malloc((size_t)(count_elts + 1) *
|
elt_list_ptr = (struct elt_list*)PHRQ_malloc(((size_t)count_elts + 1) *
|
||||||
sizeof(struct elt_list));
|
sizeof(struct elt_list));
|
||||||
if (elt_list_ptr == NULL)
|
if (elt_list_ptr == NULL)
|
||||||
{
|
{
|
||||||
@ -1078,7 +1078,7 @@ master_bsearch_secondary(char *ptr)
|
|||||||
if (master_ptr_primary)
|
if (master_ptr_primary)
|
||||||
{
|
{
|
||||||
if ((master_ptr_primary->number >= (int)master.size() - 1) ||
|
if ((master_ptr_primary->number >= (int)master.size() - 1) ||
|
||||||
(master[master_ptr_primary->number + 1]->elt->primary != master_ptr_primary))
|
(master[(size_t)master_ptr_primary->number + 1]->elt->primary != master_ptr_primary))
|
||||||
{
|
{
|
||||||
return(master_ptr_primary);
|
return(master_ptr_primary);
|
||||||
}
|
}
|
||||||
@ -1671,7 +1671,7 @@ rxn_dup(struct reaction *rxn_ptr_old)
|
|||||||
* Copy tokens
|
* Copy tokens
|
||||||
*/
|
*/
|
||||||
memcpy(rxn_ptr_new->token, rxn_ptr_old->token,
|
memcpy(rxn_ptr_new->token, rxn_ptr_old->token,
|
||||||
(size_t) (i + 1) * sizeof(struct rxn_token));
|
((size_t)i + 1) * sizeof(struct rxn_token));
|
||||||
|
|
||||||
return (rxn_ptr_new);
|
return (rxn_ptr_new);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1212,10 +1212,8 @@ extend_tally_table(void)
|
|||||||
* adds another column to tally_table
|
* adds another column to tally_table
|
||||||
* increments number of columns
|
* increments number of columns
|
||||||
*/
|
*/
|
||||||
tally_table =
|
tally_table = (struct tally *) PHRQ_realloc((void *) tally_table,
|
||||||
(struct tally *) PHRQ_realloc((void *) tally_table,
|
((size_t)count_tally_table_columns + 1) * sizeof(struct tally));
|
||||||
(size_t) (count_tally_table_columns +
|
|
||||||
1) * sizeof(struct tally));
|
|
||||||
if (tally_table == NULL)
|
if (tally_table == NULL)
|
||||||
malloc_error();
|
malloc_error();
|
||||||
for (i = 0; i < 3; i++)
|
for (i = 0; i < 3; i++)
|
||||||
|
|||||||
@ -1349,7 +1349,7 @@ tidy_inverse(void)
|
|||||||
continue;
|
continue;
|
||||||
/* if next master species is secondary, mark all
|
/* if next master species is secondary, mark all
|
||||||
secondary master species until a primary is found */
|
secondary master species until a primary is found */
|
||||||
if (master[j + 1]->primary == FALSE)
|
if (master[(size_t)j + 1]->primary == FALSE)
|
||||||
{
|
{
|
||||||
master[j]->in = FALSE;
|
master[j]->in = FALSE;
|
||||||
count_in--;
|
count_in--;
|
||||||
|
|||||||
@ -247,8 +247,8 @@ transport(void)
|
|||||||
"Electrical Field (potential) was defined, assuming constant boundary condition for last cell.");
|
"Electrical Field (potential) was defined, assuming constant boundary condition for last cell.");
|
||||||
warning_msg(error_string);
|
warning_msg(error_string);
|
||||||
}
|
}
|
||||||
current_cells = (struct CURRENT_CELLS *) PHRQ_malloc((size_t)
|
current_cells = (struct CURRENT_CELLS *) PHRQ_malloc(
|
||||||
(count_cells + 1) * sizeof(struct CURRENT_CELLS));
|
((size_t)count_cells + 1) * sizeof(struct CURRENT_CELLS));
|
||||||
if (current_cells == NULL)
|
if (current_cells == NULL)
|
||||||
malloc_error();
|
malloc_error();
|
||||||
for (int i = 0; i < count_cells + 1; i++)
|
for (int i = 0; i < count_cells + 1; i++)
|
||||||
@ -288,8 +288,8 @@ transport(void)
|
|||||||
//}
|
//}
|
||||||
if (implicit && current_cells == NULL)
|
if (implicit && current_cells == NULL)
|
||||||
{
|
{
|
||||||
current_cells = (struct CURRENT_CELLS *) PHRQ_malloc((size_t)
|
current_cells = (struct CURRENT_CELLS *) PHRQ_malloc(
|
||||||
(count_cells + 1) * sizeof(struct CURRENT_CELLS));
|
((size_t)count_cells + 1) * sizeof(struct CURRENT_CELLS));
|
||||||
if (current_cells == NULL)
|
if (current_cells == NULL)
|
||||||
malloc_error();
|
malloc_error();
|
||||||
for (int i = 0; i < count_cells + 1; i++)
|
for (int i = 0; i < count_cells + 1; i++)
|
||||||
@ -377,9 +377,9 @@ transport(void)
|
|||||||
if (nmix < 2)
|
if (nmix < 2)
|
||||||
stagkin_time = timest;
|
stagkin_time = timest;
|
||||||
else
|
else
|
||||||
stagkin_time = timest / nmix;
|
stagkin_time = timest / (double)nmix;
|
||||||
if (ishift != 0)
|
if (ishift != 0)
|
||||||
kin_time = timest / (1 + nmix);
|
kin_time = timest / (1 + (double)nmix);
|
||||||
else
|
else
|
||||||
kin_time = stagkin_time;
|
kin_time = stagkin_time;
|
||||||
kin_time_save = kin_time;
|
kin_time_save = kin_time;
|
||||||
@ -528,8 +528,8 @@ transport(void)
|
|||||||
/* For half of mixing steps */
|
/* For half of mixing steps */
|
||||||
for (j = 1; j <= floor((LDBLE)nmix / 2); j++)
|
for (j = 1; j <= floor((LDBLE)nmix / 2); j++)
|
||||||
{
|
{
|
||||||
rate_sim_time_start =
|
rate_sim_time_start = ((double)transport_step - 1) *
|
||||||
(transport_step - 1) * timest + (j - 1) * kin_time;
|
timest + ((double)j - 1) * kin_time;
|
||||||
rate_sim_time = rate_sim_time_start + kin_time;
|
rate_sim_time = rate_sim_time_start + kin_time;
|
||||||
|
|
||||||
mixrun = j;
|
mixrun = j;
|
||||||
@ -618,8 +618,8 @@ transport(void)
|
|||||||
Utilities::Rxn_copy(Rxn_solution_map, -2, count_cells);
|
Utilities::Rxn_copy(Rxn_solution_map, -2, count_cells);
|
||||||
/* Stagnant zone mixing after completion of each
|
/* Stagnant zone mixing after completion of each
|
||||||
diffusive/dispersive step ... */
|
diffusive/dispersive step ... */
|
||||||
rate_sim_time_start =
|
rate_sim_time_start = ((double)transport_step - 1) *
|
||||||
(transport_step - 1) * timest + (j - 1) * stagkin_time;
|
timest + ((double)j - 1) * stagkin_time;
|
||||||
rate_sim_time = rate_sim_time_start + stagkin_time;
|
rate_sim_time = rate_sim_time_start + stagkin_time;
|
||||||
|
|
||||||
if (stag_data->count_stag > 0)
|
if (stag_data->count_stag > 0)
|
||||||
@ -656,10 +656,10 @@ transport(void)
|
|||||||
sprintf(token, "Transport step %3d.", transport_step);
|
sprintf(token, "Transport step %3d.", transport_step);
|
||||||
dup_print(token, FALSE);
|
dup_print(token, FALSE);
|
||||||
if (b_c == 1)
|
if (b_c == 1)
|
||||||
rate_sim_time_start =
|
rate_sim_time_start = ((double)transport_step - 1) *
|
||||||
(transport_step - 1) * timest + (j - 1) * kin_time;
|
timest + ((double)j - 1) * kin_time;
|
||||||
else
|
else
|
||||||
rate_sim_time_start = (transport_step - 1) * timest;
|
rate_sim_time_start = ((double)transport_step - 1) * timest;
|
||||||
rate_sim_time = rate_sim_time_start + kin_time;
|
rate_sim_time = rate_sim_time_start + kin_time;
|
||||||
|
|
||||||
/* halftime kinetics for resident water in first cell ... */
|
/* halftime kinetics for resident water in first cell ... */
|
||||||
@ -806,8 +806,8 @@ transport(void)
|
|||||||
transport_step, j);
|
transport_step, j);
|
||||||
dup_print(token, FALSE);
|
dup_print(token, FALSE);
|
||||||
}
|
}
|
||||||
rate_sim_time_start =
|
rate_sim_time_start = ((double)transport_step - 1) *
|
||||||
(transport_step - 1) * timest + (j - 1) * kin_time;
|
timest + ((double)j - 1) * kin_time;
|
||||||
if (ishift != 0)
|
if (ishift != 0)
|
||||||
rate_sim_time_start += kin_time;
|
rate_sim_time_start += kin_time;
|
||||||
rate_sim_time = rate_sim_time_start + kin_time;
|
rate_sim_time = rate_sim_time_start + kin_time;
|
||||||
@ -876,8 +876,8 @@ transport(void)
|
|||||||
if (!dV_dcell)
|
if (!dV_dcell)
|
||||||
Utilities::Rxn_copy(Rxn_solution_map, -2, count_cells);
|
Utilities::Rxn_copy(Rxn_solution_map, -2, count_cells);
|
||||||
/* Stagnant zone mixing after completion of each diffusive/dispersive step ... */
|
/* Stagnant zone mixing after completion of each diffusive/dispersive step ... */
|
||||||
rate_sim_time_start =
|
rate_sim_time_start = ((double)transport_step - 1) *
|
||||||
(transport_step - 1) * timest + (j - 1) * stagkin_time;
|
timest + ((double)j - 1) * stagkin_time;
|
||||||
rate_sim_time = rate_sim_time_start + stagkin_time;
|
rate_sim_time = rate_sim_time_start + stagkin_time;
|
||||||
|
|
||||||
if (stag_data->count_stag > 0)
|
if (stag_data->count_stag > 0)
|
||||||
@ -1102,10 +1102,10 @@ init_mix(void)
|
|||||||
bool warning = false;
|
bool warning = false;
|
||||||
int i, l_nmix;
|
int i, l_nmix;
|
||||||
LDBLE *m, *m1;
|
LDBLE *m, *m1;
|
||||||
m = (LDBLE *)PHRQ_malloc((count_cells + 1) * sizeof(LDBLE));
|
m = (LDBLE *)PHRQ_malloc(((size_t)count_cells + 1) * sizeof(LDBLE));
|
||||||
if (m == NULL)
|
if (m == NULL)
|
||||||
malloc_error();
|
malloc_error();
|
||||||
m1 = (LDBLE *)PHRQ_malloc((count_cells + 1) * sizeof(LDBLE));
|
m1 = (LDBLE *)PHRQ_malloc(((size_t)count_cells + 1) * sizeof(LDBLE));
|
||||||
if (m1 == NULL)
|
if (m1 == NULL)
|
||||||
malloc_error();
|
malloc_error();
|
||||||
for (i = 0; i < count_cells + 1; i++)
|
for (i = 0; i < count_cells + 1; i++)
|
||||||
@ -1554,15 +1554,15 @@ init_heat_mix(int l_nmix)
|
|||||||
/*
|
/*
|
||||||
* Initialize arrays...
|
* Initialize arrays...
|
||||||
*/
|
*/
|
||||||
heat_mix_array = (LDBLE *)PHRQ_malloc((count_cells + 2) * sizeof(LDBLE));
|
heat_mix_array = (LDBLE *)PHRQ_malloc(((size_t)count_cells + 2) * sizeof(LDBLE));
|
||||||
if (heat_mix_array == NULL)
|
if (heat_mix_array == NULL)
|
||||||
malloc_error();
|
malloc_error();
|
||||||
|
|
||||||
temp1 = (LDBLE *)PHRQ_malloc((count_cells + 2) * sizeof(LDBLE));
|
temp1 = (LDBLE *)PHRQ_malloc(((size_t)count_cells + 2) * sizeof(LDBLE));
|
||||||
if (temp1 == NULL)
|
if (temp1 == NULL)
|
||||||
malloc_error();
|
malloc_error();
|
||||||
|
|
||||||
temp2 = (LDBLE *)PHRQ_malloc((count_cells + 2) * sizeof(LDBLE));
|
temp2 = (LDBLE *)PHRQ_malloc(((size_t)count_cells + 2) * sizeof(LDBLE));
|
||||||
if (temp2 == NULL)
|
if (temp2 == NULL)
|
||||||
malloc_error();
|
malloc_error();
|
||||||
/*
|
/*
|
||||||
@ -1897,7 +1897,7 @@ fill_spec(int l_cell_no, int ref_cell)
|
|||||||
// continue;
|
// continue;
|
||||||
//if (s_ptr->type == SURF)
|
//if (s_ptr->type == SURF)
|
||||||
// continue;
|
// continue;
|
||||||
if (i > 0 && strcmp(s_ptr->name, species_list[i - 1].s->name) == 0)
|
if (i > 0 && strcmp(s_ptr->name, species_list[(size_t)i - 1].s->name) == 0)
|
||||||
continue;
|
continue;
|
||||||
//if (s_ptr == s_h2o)
|
//if (s_ptr == s_h2o)
|
||||||
// continue;
|
// continue;
|
||||||
@ -2021,7 +2021,8 @@ fill_spec(int l_cell_no, int ref_cell)
|
|||||||
i3 = i2 - i1;
|
i3 = i2 - i1;
|
||||||
if (i3 + count_spec + 1 > sol_D[l_cell_no].spec_size)
|
if (i3 + count_spec + 1 > sol_D[l_cell_no].spec_size)
|
||||||
{
|
{
|
||||||
sol_D[l_cell_no].spec = (struct spec *) PHRQ_realloc(sol_D[l_cell_no].spec, (size_t)(i3 + count_spec + 1 + size_xt) * sizeof(struct spec));
|
sol_D[l_cell_no].spec = (struct spec *) PHRQ_realloc(sol_D[l_cell_no].spec,
|
||||||
|
((size_t)i3 + (size_t)count_spec + 1 + (size_t)size_xt) * sizeof(struct spec));
|
||||||
if (sol_D[l_cell_no].spec == NULL)
|
if (sol_D[l_cell_no].spec == NULL)
|
||||||
malloc_error();
|
malloc_error();
|
||||||
sol_D[l_cell_no].spec_size = i3 + count_spec + 1 + size_xt;
|
sol_D[l_cell_no].spec_size = i3 + count_spec + 1 + size_xt;
|
||||||
@ -2042,7 +2043,8 @@ fill_spec(int l_cell_no, int ref_cell)
|
|||||||
}
|
}
|
||||||
if (count_spec >= sol_D[l_cell_no].spec_size)
|
if (count_spec >= sol_D[l_cell_no].spec_size)
|
||||||
{
|
{
|
||||||
sol_D[l_cell_no].spec = (struct spec *) PHRQ_realloc(sol_D[l_cell_no].spec, (size_t)(count_spec + size_xt) * sizeof(struct spec));
|
sol_D[l_cell_no].spec = (struct spec *) PHRQ_realloc(sol_D[l_cell_no].spec,
|
||||||
|
((size_t)count_spec + (size_t)size_xt) * sizeof(struct spec));
|
||||||
if (sol_D[l_cell_no].spec == NULL)
|
if (sol_D[l_cell_no].spec == NULL)
|
||||||
malloc_error();
|
malloc_error();
|
||||||
sol_D[l_cell_no].spec_size = count_spec + size_xt;
|
sol_D[l_cell_no].spec_size = count_spec + size_xt;
|
||||||
@ -2093,7 +2095,8 @@ fill_spec(int l_cell_no, int ref_cell)
|
|||||||
i2 = sol_D[i1].count_spec + 1;
|
i2 = sol_D[i1].count_spec + 1;
|
||||||
if (i2 > sol_D[i1].spec_size)
|
if (i2 > sol_D[i1].spec_size)
|
||||||
{
|
{
|
||||||
sol_D[i1].spec = (struct spec *) PHRQ_realloc(sol_D[i1].spec, (size_t)(i2 + size_xt) * sizeof(struct spec));
|
sol_D[i1].spec = (struct spec *) PHRQ_realloc(sol_D[i1].spec,
|
||||||
|
((size_t)i2 + (size_t)size_xt) * sizeof(struct spec));
|
||||||
if (sol_D[i1].spec == NULL)
|
if (sol_D[i1].spec == NULL)
|
||||||
malloc_error();
|
malloc_error();
|
||||||
sol_D[i1].spec_size = i2 + size_xt;
|
sol_D[i1].spec_size = i2 + size_xt;
|
||||||
@ -2121,7 +2124,8 @@ fill_spec(int l_cell_no, int ref_cell)
|
|||||||
i3 = (int) dif_spec_names.size();
|
i3 = (int) dif_spec_names.size();
|
||||||
if (i3 > sol_D[l_cell_no].spec_size)
|
if (i3 > sol_D[l_cell_no].spec_size)
|
||||||
{
|
{
|
||||||
sol_D[l_cell_no].spec = (struct spec *) PHRQ_realloc(sol_D[l_cell_no].spec, (size_t)(i3 + size_xt) * sizeof(struct spec));
|
sol_D[l_cell_no].spec = (struct spec *) PHRQ_realloc(sol_D[l_cell_no].spec,
|
||||||
|
((size_t)i3 + (size_t)size_xt) * sizeof(struct spec));
|
||||||
if (sol_D[l_cell_no].spec == NULL)
|
if (sol_D[l_cell_no].spec == NULL)
|
||||||
malloc_error();
|
malloc_error();
|
||||||
sol_D[l_cell_no].spec_size = i3 + size_xt;
|
sol_D[l_cell_no].spec_size = i3 + size_xt;
|
||||||
@ -2212,41 +2216,41 @@ diffuse_implicit(LDBLE DDt, int stagnant)
|
|||||||
comp += 1;
|
comp += 1;
|
||||||
|
|
||||||
if (Ct2 == NULL)
|
if (Ct2 == NULL)
|
||||||
Ct2 = (LDBLE *) PHRQ_malloc((size_t) (count_cells + 2 + stagnant * count_cells) * sizeof(LDBLE));
|
Ct2 = (LDBLE *) PHRQ_malloc(((size_t)count_cells + 2 + (size_t)stagnant * (size_t)count_cells) * sizeof(LDBLE));
|
||||||
if (Ct2 == NULL) malloc_error();
|
if (Ct2 == NULL) malloc_error();
|
||||||
if (l_tk_x2 == NULL)
|
if (l_tk_x2 == NULL)
|
||||||
l_tk_x2 = (LDBLE *) PHRQ_malloc((size_t) (count_cells + 2 + stagnant * count_cells) * sizeof(LDBLE));
|
l_tk_x2 = (LDBLE *) PHRQ_malloc(((size_t)count_cells + 2 + (size_t)stagnant * (size_t)count_cells) * sizeof(LDBLE));
|
||||||
if (l_tk_x2 == NULL) malloc_error();
|
if (l_tk_x2 == NULL) malloc_error();
|
||||||
|
|
||||||
if (A == NULL)
|
if (A == NULL)
|
||||||
{
|
{
|
||||||
A = (LDBLE **)PHRQ_malloc((size_t)(count_cells + 2 + stagnant * count_cells) * sizeof(LDBLE *));
|
A = (LDBLE **)PHRQ_malloc(((size_t)count_cells + 2 + (size_t)stagnant * (size_t)count_cells) * sizeof(LDBLE *));
|
||||||
if (A == NULL) malloc_error();
|
if (A == NULL) malloc_error();
|
||||||
for (i = 0; i < count_cells + 2 + stagnant * count_cells; i++)
|
for (i = 0; i < count_cells + 2 + stagnant * count_cells; i++)
|
||||||
{
|
{
|
||||||
if (stagnant)
|
if (stagnant)
|
||||||
A[i] = (LDBLE *)PHRQ_calloc((size_t)(2 * count_cells + 2), sizeof(LDBLE));
|
A[i] = (LDBLE *)PHRQ_calloc((2 * (size_t)count_cells + 2), sizeof(LDBLE));
|
||||||
else
|
else
|
||||||
A[i] = (LDBLE *)PHRQ_malloc((size_t)3 * sizeof(LDBLE));
|
A[i] = (LDBLE *)PHRQ_malloc(3 * sizeof(LDBLE));
|
||||||
if (A[i] == NULL) malloc_error();
|
if (A[i] == NULL) malloc_error();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (LU == NULL)
|
if (LU == NULL)
|
||||||
{
|
{
|
||||||
LU = (LDBLE **)PHRQ_malloc((size_t)(count_cells + 2 + stagnant * count_cells) * sizeof(LDBLE *));
|
LU = (LDBLE **)PHRQ_malloc(((size_t)count_cells + 2 + (size_t)stagnant * (size_t)count_cells) * sizeof(LDBLE *));
|
||||||
if (LU == NULL) malloc_error();
|
if (LU == NULL) malloc_error();
|
||||||
for (i = 0; i < count_cells + 2 + stagnant * count_cells; i++)
|
for (i = 0; i < count_cells + 2 + stagnant * count_cells; i++)
|
||||||
{
|
{
|
||||||
if (stagnant)
|
if (stagnant)
|
||||||
LU[i] = (LDBLE *)PHRQ_calloc((size_t)(2 * count_cells + 2), sizeof(LDBLE));
|
LU[i] = (LDBLE *)PHRQ_calloc((2 * (size_t)count_cells + 2), sizeof(LDBLE));
|
||||||
else
|
else
|
||||||
LU[i] = (LDBLE *)PHRQ_malloc((size_t)3 * sizeof(LDBLE));
|
LU[i] = (LDBLE *)PHRQ_malloc(3 * sizeof(LDBLE));
|
||||||
if (LU[i] == NULL) malloc_error();
|
if (LU[i] == NULL) malloc_error();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (mixf == NULL)
|
if (mixf == NULL)
|
||||||
{
|
{
|
||||||
mixf = (LDBLE **)PHRQ_malloc((size_t)(count_cells + 2) * sizeof(LDBLE *));
|
mixf = (LDBLE **)PHRQ_malloc(((size_t)count_cells + 2) * sizeof(LDBLE *));
|
||||||
if (mixf == NULL) malloc_error();
|
if (mixf == NULL) malloc_error();
|
||||||
for (i = 0; i < count_cells + 2; i++)
|
for (i = 0; i < count_cells + 2; i++)
|
||||||
{
|
{
|
||||||
@ -2257,7 +2261,7 @@ diffuse_implicit(LDBLE DDt, int stagnant)
|
|||||||
{
|
{
|
||||||
if (mixf_stag == NULL)
|
if (mixf_stag == NULL)
|
||||||
{
|
{
|
||||||
mixf_stag = (LDBLE **)PHRQ_malloc((size_t)(count_cells + 2) * sizeof(LDBLE *));
|
mixf_stag = (LDBLE **)PHRQ_malloc(((size_t)count_cells + 2) * sizeof(LDBLE *));
|
||||||
if (mixf_stag == NULL) malloc_error();
|
if (mixf_stag == NULL) malloc_error();
|
||||||
for (i = 0; i < count_cells + 2; i++)
|
for (i = 0; i < count_cells + 2; i++)
|
||||||
{
|
{
|
||||||
@ -2270,16 +2274,16 @@ diffuse_implicit(LDBLE DDt, int stagnant)
|
|||||||
for (i = 0; i < count_cells + 2; i++)
|
for (i = 0; i < count_cells + 2; i++)
|
||||||
{
|
{
|
||||||
if (mixf[i] == NULL)
|
if (mixf[i] == NULL)
|
||||||
mixf[i] = (LDBLE *)PHRQ_malloc((size_t)(comp + 2) * sizeof(LDBLE));
|
mixf[i] = (LDBLE *)PHRQ_malloc(((size_t)comp + 2) * sizeof(LDBLE));
|
||||||
else
|
else
|
||||||
mixf[i] = (LDBLE *)PHRQ_realloc(mixf[i], (size_t)(comp + 2) * sizeof(LDBLE));
|
mixf[i] = (LDBLE *)PHRQ_realloc(mixf[i], ((size_t)comp + 2) * sizeof(LDBLE));
|
||||||
if (mixf[i] == NULL) malloc_error();
|
if (mixf[i] == NULL) malloc_error();
|
||||||
if (stagnant)
|
if (stagnant)
|
||||||
{
|
{
|
||||||
if (mixf_stag[i] == NULL)
|
if (mixf_stag[i] == NULL)
|
||||||
mixf_stag[i] = (LDBLE *)PHRQ_malloc((size_t)(comp + 2) * sizeof(LDBLE));
|
mixf_stag[i] = (LDBLE *)PHRQ_malloc(((size_t)comp + 2) * sizeof(LDBLE));
|
||||||
else
|
else
|
||||||
mixf_stag[i] = (LDBLE *)PHRQ_realloc(mixf_stag[i], (size_t)(comp + 2) * sizeof(LDBLE));
|
mixf_stag[i] = (LDBLE *)PHRQ_realloc(mixf_stag[i], ((size_t)comp + 2) * sizeof(LDBLE));
|
||||||
if (mixf_stag[i] == NULL) malloc_error();
|
if (mixf_stag[i] == NULL) malloc_error();
|
||||||
for (cp = 0; cp < comp; cp++)
|
for (cp = 0; cp < comp; cp++)
|
||||||
mixf_stag[i][cp] = 0;
|
mixf_stag[i][cp] = 0;
|
||||||
@ -2798,7 +2802,7 @@ diffuse_implicit(LDBLE DDt, int stagnant)
|
|||||||
((dV_dcell > 0) && ((cell_data[i].potV + dVc) > cell_data[count_cells + 1].potV)) ||
|
((dV_dcell > 0) && ((cell_data[i].potV + dVc) > cell_data[count_cells + 1].potV)) ||
|
||||||
((dV_dcell < 0) && ((cell_data[i].potV + dVc) < cell_data[count_cells + 1].potV)))
|
((dV_dcell < 0) && ((cell_data[i].potV + dVc) < cell_data[count_cells + 1].potV)))
|
||||||
{
|
{
|
||||||
dVc = (cell_data[count_cells + 1].potV - cell_data[i].potV) / (count_cells + 1 - i);
|
dVc = (cell_data[(size_t)count_cells + 1].potV - cell_data[i].potV) / ((double)count_cells + 1 - (double)i);
|
||||||
}
|
}
|
||||||
cell_data[i + 1].potV = cell_data[i].potV + dVc;
|
cell_data[i + 1].potV = cell_data[i].potV + dVc;
|
||||||
}
|
}
|
||||||
@ -2841,12 +2845,12 @@ diffuse_implicit(LDBLE DDt, int stagnant)
|
|||||||
ct[i].m_s = (struct M_S *) free_check_null(ct[i].m_s);
|
ct[i].m_s = (struct M_S *) free_check_null(ct[i].m_s);
|
||||||
if (ct[i].m_s == NULL)
|
if (ct[i].m_s == NULL)
|
||||||
{
|
{
|
||||||
ct[i].m_s = (struct M_S *) PHRQ_malloc((size_t)(count_m_s + 5) * sizeof(struct M_S));
|
ct[i].m_s = (struct M_S *) PHRQ_malloc(((size_t)count_m_s + 5) * sizeof(struct M_S));
|
||||||
ct[i].m_s_size = count_m_s + 5;
|
ct[i].m_s_size = count_m_s + 5;
|
||||||
}
|
}
|
||||||
else if (count_m_s > ct[i].m_s_size)
|
else if (count_m_s > ct[i].m_s_size)
|
||||||
{
|
{
|
||||||
ct[i].m_s = (struct M_S *) PHRQ_realloc(ct[i].m_s, (size_t)(count_m_s + 5) * sizeof(struct M_S));
|
ct[i].m_s = (struct M_S *) PHRQ_realloc(ct[i].m_s, ((size_t)count_m_s + 5) * sizeof(struct M_S));
|
||||||
ct[i].m_s_size = count_m_s + 5;
|
ct[i].m_s_size = count_m_s + 5;
|
||||||
}
|
}
|
||||||
if (ct[i].m_s == NULL)
|
if (ct[i].m_s == NULL)
|
||||||
|
|||||||
@ -579,7 +579,7 @@ dup_print(const char *ptr, int emphasis)
|
|||||||
return (OK);
|
return (OK);
|
||||||
std::string save_in(ptr);
|
std::string save_in(ptr);
|
||||||
l = (int) strlen(ptr);
|
l = (int) strlen(ptr);
|
||||||
dash = (char *) PHRQ_malloc((size_t) (l + 2) * sizeof(char));
|
dash = (char *) PHRQ_malloc(((size_t)l + 2) * sizeof(char));
|
||||||
if (dash == NULL)
|
if (dash == NULL)
|
||||||
malloc_error();
|
malloc_error();
|
||||||
if (emphasis == TRUE)
|
if (emphasis == TRUE)
|
||||||
@ -1225,7 +1225,7 @@ string_duplicate(const char *token)
|
|||||||
#if !defined(NDEBUG) && defined(WIN32_MEMORY_DEBUG)
|
#if !defined(NDEBUG) && defined(WIN32_MEMORY_DEBUG)
|
||||||
str = (char *) _malloc_dbg((size_t) (l + 1) * sizeof(char), _NORMAL_BLOCK, szFileName, nLine);
|
str = (char *) _malloc_dbg((size_t) (l + 1) * sizeof(char), _NORMAL_BLOCK, szFileName, nLine);
|
||||||
#else
|
#else
|
||||||
str = (char *) PHRQ_malloc((size_t) (l + 1) * sizeof(char));
|
str = (char *) PHRQ_malloc(((size_t)l + 1) * sizeof(char));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (str == NULL)
|
if (str == NULL)
|
||||||
@ -1973,7 +1973,7 @@ string_pad(const char *str, int i)
|
|||||||
max = l;
|
max = l;
|
||||||
if (l < i)
|
if (l < i)
|
||||||
max = i;
|
max = i;
|
||||||
str_ptr = (char *) PHRQ_malloc((size_t) ((max + 1) * sizeof(char)));
|
str_ptr = (char *) PHRQ_malloc((((size_t)max + 1) * sizeof(char)));
|
||||||
if (str_ptr == NULL)
|
if (str_ptr == NULL)
|
||||||
malloc_error();
|
malloc_error();
|
||||||
strcpy(str_ptr, str);
|
strcpy(str_ptr, str);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user