Merge pull request #441 from OpenWaterAnalytics/lrossman-dev17
Bug fixes
This commit is contained in:
17
src/epanet.c
17
src/epanet.c
@@ -7,7 +7,7 @@
|
|||||||
Authors: see AUTHORS
|
Authors: see AUTHORS
|
||||||
Copyright: see AUTHORS
|
Copyright: see AUTHORS
|
||||||
License: see LICENSE
|
License: see LICENSE
|
||||||
Last Updated: 03/17/2019
|
Last Updated: 04/02/2019
|
||||||
******************************************************************************
|
******************************************************************************
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -1589,13 +1589,20 @@ int DLLEXPORT EN_setqualtype(EN_Project p, int qualType, char *chemName,
|
|||||||
Quality *qual = &p->quality;
|
Quality *qual = &p->quality;
|
||||||
|
|
||||||
double *Ucf = p->Ucf;
|
double *Ucf = p->Ucf;
|
||||||
int i;
|
int i, oldQualFlag, traceNodeIndex;
|
||||||
double ccf = 1.0;
|
double ccf = 1.0;
|
||||||
|
|
||||||
if (!p->Openflag) return 102;
|
if (!p->Openflag) return 102;
|
||||||
if (qual->OpenQflag) return 262;
|
if (qual->OpenQflag) return 262;
|
||||||
if (qualType < EN_NONE || qualType > EN_TRACE) return 251;
|
if (qualType < NONE || qualType > TRACE) return 251;
|
||||||
qual->Qualflag = (char)qualType;
|
if (qualType == TRACE)
|
||||||
|
{
|
||||||
|
traceNodeIndex = findnode(net, traceNode);
|
||||||
|
if (traceNodeIndex == 0) return 212;
|
||||||
|
}
|
||||||
|
|
||||||
|
oldQualFlag = qual->Qualflag;
|
||||||
|
qual->Qualflag = qualType;
|
||||||
qual->Ctol *= Ucf[QUALITY];
|
qual->Ctol *= Ucf[QUALITY];
|
||||||
if (qual->Qualflag == CHEM) // Chemical analysis
|
if (qual->Qualflag == CHEM) // Chemical analysis
|
||||||
{
|
{
|
||||||
@@ -1623,7 +1630,7 @@ int DLLEXPORT EN_setqualtype(EN_Project p, int qualType, char *chemName,
|
|||||||
|
|
||||||
// When changing from CHEM to AGE or TRACE, nodes initial quality
|
// When changing from CHEM to AGE or TRACE, nodes initial quality
|
||||||
// values must be returned to their original ones
|
// values must be returned to their original ones
|
||||||
if ((qual->Qualflag == AGE || qual->Qualflag == TRACE) & (Ucf[QUALITY] != 1))
|
if ((qual->Qualflag == AGE || qual->Qualflag == TRACE) && oldQualFlag == CHEM)
|
||||||
{
|
{
|
||||||
for (i = 1; i <= p->network.Nnodes; i++)
|
for (i = 1; i <= p->network.Nnodes; i++)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ Description: saves network data to an EPANET formatted text file
|
|||||||
Authors: see AUTHORS
|
Authors: see AUTHORS
|
||||||
Copyright: see AUTHORS
|
Copyright: see AUTHORS
|
||||||
License: see LICENSE
|
License: see LICENSE
|
||||||
Last Updated: 03/17/2019
|
Last Updated: 04/02/2019
|
||||||
******************************************************************************
|
******************************************************************************
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -542,7 +542,7 @@ int saveinpfile(Project *pr, const char *fname)
|
|||||||
|
|
||||||
if (qual->Climit > 0.0)
|
if (qual->Climit > 0.0)
|
||||||
{
|
{
|
||||||
fprintf(f, "\n LIMITING POTENTIAL %-.6f", qual->Climit);
|
fprintf(f, "\n LIMITING POTENTIAL %-.6f", qual->Climit * pr->Ucf[QUALITY]);
|
||||||
}
|
}
|
||||||
if (qual->Rfactor != MISSING && qual->Rfactor != 0.0)
|
if (qual->Rfactor != MISSING && qual->Rfactor != 0.0)
|
||||||
{
|
{
|
||||||
@@ -797,8 +797,7 @@ int saveinpfile(Project *pr, const char *fname)
|
|||||||
saveauxdata(pr, f);
|
saveauxdata(pr, f);
|
||||||
|
|
||||||
// Close the new input file
|
// Close the new input file
|
||||||
fprintf(f, "\n");
|
fprintf(f, "\n%s\n", s_END);
|
||||||
fprintf(f, s_END);
|
|
||||||
fclose(f);
|
fclose(f);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ Description: reads and interprets network data from an EPANET input file
|
|||||||
Authors: see AUTHORS
|
Authors: see AUTHORS
|
||||||
Copyright: see AUTHORS
|
Copyright: see AUTHORS
|
||||||
License: see LICENSE
|
License: see LICENSE
|
||||||
Last Updated: 03/17/2019
|
Last Updated: 04/02/2019
|
||||||
******************************************************************************
|
******************************************************************************
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -860,6 +860,12 @@ int gettokens(char *s, char** Tok, int maxToks, char *comment)
|
|||||||
while (len > 0 && n < MAXTOKS)
|
while (len > 0 && n < MAXTOKS)
|
||||||
{
|
{
|
||||||
m = (int)strcspn(s,SEPSTR); // Find token length
|
m = (int)strcspn(s,SEPSTR); // Find token length
|
||||||
|
if (m == len) // s is last token
|
||||||
|
{
|
||||||
|
Tok[n] = s;
|
||||||
|
n++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
len -= m+1; // Update length of s
|
len -= m+1; // Update length of s
|
||||||
if (m == 0) s++; // No token found
|
if (m == 0) s++; // No token found
|
||||||
else
|
else
|
||||||
|
|||||||
Reference in New Issue
Block a user