@@ -12,7 +12,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include "epanet2.h"
|
#include "epanet2.h"
|
||||||
|
|
||||||
void writeConsole(char *s)
|
void writeConsole(char *s)
|
||||||
|
|||||||
43
src/epanet.c
43
src/epanet.c
@@ -11,17 +11,12 @@
|
|||||||
******************************************************************************
|
******************************************************************************
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef _DEBUG
|
|
||||||
#define _CRTDBG_MAP_ALLOC
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <crtdbg.h>
|
|
||||||
#else
|
|
||||||
#include <stdlib.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#ifndef __APPLE__
|
||||||
|
#include <malloc.h>
|
||||||
|
#endif
|
||||||
#include <float.h>
|
#include <float.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
@@ -221,24 +216,26 @@ int DLLEXPORT EN_open(EN_Project p, const char *inpFile, const char *rptFile,
|
|||||||
ERRCODE(netsize(p));
|
ERRCODE(netsize(p));
|
||||||
ERRCODE(allocdata(p));
|
ERRCODE(allocdata(p));
|
||||||
|
|
||||||
if (!errcode) {
|
// Read input data
|
||||||
// Read input data
|
ERRCODE(getdata(p));
|
||||||
ERRCODE(getdata(p));
|
|
||||||
|
|
||||||
// Close input file
|
// Close input file
|
||||||
if (p->parser.InFile != NULL) {
|
if (p->parser.InFile != NULL)
|
||||||
|
{
|
||||||
fclose(p->parser.InFile);
|
fclose(p->parser.InFile);
|
||||||
p->parser.InFile = NULL;
|
p->parser.InFile = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Free temporary linked lists used for Patterns & Curves
|
// Free temporary linked lists used for Patterns & Curves
|
||||||
freeTmplist(p->parser.Patlist);
|
freeTmplist(p->parser.Patlist);
|
||||||
freeTmplist(p->parser.Curvelist);
|
freeTmplist(p->parser.Curvelist);
|
||||||
|
|
||||||
// If using previously saved hydraulics file then open it
|
// If using previously saved hydraulics file then open it
|
||||||
if (p->outfile.Hydflag == USE) ERRCODE(openhydfile(p));
|
if (p->outfile.Hydflag == USE) ERRCODE(openhydfile(p));
|
||||||
|
|
||||||
// Write input summary to report file
|
// Write input summary to report file
|
||||||
|
if (!errcode)
|
||||||
|
{
|
||||||
if (p->report.Summaryflag) writesummary(p);
|
if (p->report.Summaryflag) writesummary(p);
|
||||||
writetime(p, FMT104);
|
writetime(p, FMT104);
|
||||||
p->Openflag = TRUE;
|
p->Openflag = TRUE;
|
||||||
@@ -282,7 +279,7 @@ int DLLEXPORT EN_getcomment(EN_Project p, int object, int index, char *comment)
|
|||||||
/*----------------------------------------------------------------
|
/*----------------------------------------------------------------
|
||||||
** Input: object = a type of object (see EN_ObjectType)
|
** Input: object = a type of object (see EN_ObjectType)
|
||||||
** index = the object's index
|
** index = the object's index
|
||||||
** Output: comment = the object's descriptive comment
|
** Output: comment = the object's descriptive comment
|
||||||
** Returns: error code
|
** Returns: error code
|
||||||
** Purpose: Retrieves an object's descriptive comment
|
** Purpose: Retrieves an object's descriptive comment
|
||||||
**----------------------------------------------------------------
|
**----------------------------------------------------------------
|
||||||
@@ -843,7 +840,7 @@ int DLLEXPORT EN_closeQ(EN_Project p)
|
|||||||
if (!p->Openflag) return 102;
|
if (!p->Openflag) return 102;
|
||||||
closequal(p);
|
closequal(p);
|
||||||
p->quality.OpenQflag = FALSE;
|
p->quality.OpenQflag = FALSE;
|
||||||
closeoutfile(p);
|
closeoutfile(p);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,15 +10,11 @@
|
|||||||
Last Updated: 03/17/2019
|
Last Updated: 03/17/2019
|
||||||
******************************************************************************
|
******************************************************************************
|
||||||
*/
|
*/
|
||||||
|
#ifndef __APPLE__
|
||||||
#ifdef _DEBUG
|
#include <malloc.h>
|
||||||
#define _CRTDBG_MAP_ALLOC
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <crtdbg.h>
|
|
||||||
#else
|
#else
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ typedef struct {
|
|||||||
Project *project;
|
Project *project;
|
||||||
error_handle_t *error;
|
error_handle_t *error;
|
||||||
}handle_t;
|
}handle_t;
|
||||||
|
|
||||||
// Extern functions
|
// Extern functions
|
||||||
extern char *geterrmsg(int, char *);
|
extern char *geterrmsg(int, char *);
|
||||||
// Local functions
|
// Local functions
|
||||||
|
|||||||
@@ -11,9 +11,12 @@
|
|||||||
******************************************************************************
|
******************************************************************************
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifndef __APPLE__
|
||||||
|
#include <malloc.h>
|
||||||
|
#else
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#endif
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "hash.h"
|
#include "hash.h"
|
||||||
|
|
||||||
#define HASHTABLEMAXSIZE 128000
|
#define HASHTABLEMAXSIZE 128000
|
||||||
|
|||||||
@@ -11,9 +11,13 @@
|
|||||||
******************************************************************************
|
******************************************************************************
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#ifndef __APPLE__
|
||||||
|
#include <malloc.h>
|
||||||
|
#else
|
||||||
|
#include <stdlib.h>
|
||||||
|
#endif
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
|
|||||||
@@ -11,9 +11,13 @@
|
|||||||
******************************************************************************
|
******************************************************************************
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#ifndef __APPLE__
|
||||||
|
#include <malloc.h>
|
||||||
|
#else
|
||||||
|
#include <stdlib.h>
|
||||||
|
#endif
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
|
|||||||
@@ -12,9 +12,13 @@
|
|||||||
******************************************************************************
|
******************************************************************************
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#ifndef __APPLE__
|
||||||
|
#include <malloc.h>
|
||||||
|
#else
|
||||||
|
#include <stdlib.h>
|
||||||
|
#endif
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ Last Updated: 11/27/2018
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
#include "funcs.h"
|
#include "funcs.h"
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,11 @@ Last Updated: 03/17/2019
|
|||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#ifndef __APPLE__
|
||||||
|
#include <malloc.h>
|
||||||
|
#else
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#endif
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
|
|||||||
28
src/input1.c
28
src/input1.c
@@ -3,30 +3,26 @@
|
|||||||
Project: OWA EPANET
|
Project: OWA EPANET
|
||||||
Version: 2.2
|
Version: 2.2
|
||||||
Module: input1.c
|
Module: input1.c
|
||||||
Description: retrieves network data from an EPANET input file
|
Description: retrieves 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: 03/17/2019
|
||||||
******************************************************************************
|
******************************************************************************
|
||||||
*/
|
*/
|
||||||
#ifdef _DEBUG
|
|
||||||
#define _CRTDBG_MAP_ALLOC
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <crtdbg.h>
|
|
||||||
#else
|
|
||||||
#include <stdlib.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <math.h>
|
#ifndef __APPLE__
|
||||||
|
#include <malloc.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
#include "funcs.h"
|
#include "funcs.h"
|
||||||
#include "hash.h"
|
#include "hash.h"
|
||||||
#include "text.h"
|
#include "text.h"
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
// Default values
|
// Default values
|
||||||
#define MAXITER 200 // Default max. # hydraulic iterations
|
#define MAXITER 200 // Default max. # hydraulic iterations
|
||||||
@@ -60,7 +56,7 @@ int getdata(Project *pr)
|
|||||||
int errcode = 0;
|
int errcode = 0;
|
||||||
|
|
||||||
// Assign default data values & reporting options
|
// Assign default data values & reporting options
|
||||||
setdefaults(pr);
|
setdefaults(pr);
|
||||||
initreport(&pr->report);
|
initreport(&pr->report);
|
||||||
|
|
||||||
// Read in network data
|
// Read in network data
|
||||||
@@ -106,7 +102,7 @@ void setdefaults(Project *pr)
|
|||||||
parser->Pressflag = PSI; // Pressure units are psi
|
parser->Pressflag = PSI; // Pressure units are psi
|
||||||
out->Hydflag = SCRATCH; // No external hydraulics file
|
out->Hydflag = SCRATCH; // No external hydraulics file
|
||||||
rpt->Tstatflag = SERIES; // Generate time series output
|
rpt->Tstatflag = SERIES; // Generate time series output
|
||||||
|
|
||||||
hyd->Formflag = HW; // Use Hazen-Williams formula
|
hyd->Formflag = HW; // Use Hazen-Williams formula
|
||||||
hyd->Htol = HTOL; // Default head tolerance
|
hyd->Htol = HTOL; // Default head tolerance
|
||||||
hyd->Qtol = QTOL; // Default flow tolerance
|
hyd->Qtol = QTOL; // Default flow tolerance
|
||||||
@@ -357,7 +353,7 @@ int inittanks(Project *pr)
|
|||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
Network *net = &pr->network;
|
Network *net = &pr->network;
|
||||||
|
|
||||||
int i, j, n = 0;
|
int i, j, n = 0;
|
||||||
double a;
|
double a;
|
||||||
int errcode = 0, levelerr;
|
int errcode = 0, levelerr;
|
||||||
@@ -550,7 +546,7 @@ void convertunits(Project *pr)
|
|||||||
Slink *link;
|
Slink *link;
|
||||||
Spump *pump;
|
Spump *pump;
|
||||||
Scontrol *control;
|
Scontrol *control;
|
||||||
|
|
||||||
// Convert nodal elevations & initial WQ
|
// Convert nodal elevations & initial WQ
|
||||||
// (WQ source units are converted in QUALITY.C
|
// (WQ source units are converted in QUALITY.C
|
||||||
for (i = 1; i <= net->Nnodes; i++)
|
for (i = 1; i <= net->Nnodes; i++)
|
||||||
@@ -648,7 +644,7 @@ void convertunits(Project *pr)
|
|||||||
pump->H0 /= pr->Ucf[HEAD];
|
pump->H0 /= pr->Ucf[HEAD];
|
||||||
pump->R *= (pow(pr->Ucf[FLOW], pump->N) / pr->Ucf[HEAD]);
|
pump->R *= (pow(pr->Ucf[FLOW], pump->N) / pr->Ucf[HEAD]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convert flow range & max. head units
|
// Convert flow range & max. head units
|
||||||
pump->Q0 /= pr->Ucf[FLOW];
|
pump->Q0 /= pr->Ucf[FLOW];
|
||||||
pump->Qmax /= pr->Ucf[FLOW];
|
pump->Qmax /= pr->Ucf[FLOW];
|
||||||
@@ -657,7 +653,7 @@ void convertunits(Project *pr)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// For flow control valves, convert flow setting
|
// For flow control valves, convert flow setting
|
||||||
// while for other valves convert pressure setting
|
// while for other valves convert pressure setting
|
||||||
link->Diam /= pr->Ucf[DIAM];
|
link->Diam /= pr->Ucf[DIAM];
|
||||||
link->Km = 0.02517 * link->Km / SQR(link->Diam) / SQR(link->Diam);
|
link->Km = 0.02517 * link->Km / SQR(link->Diam) / SQR(link->Diam);
|
||||||
|
|||||||
63
src/input2.c
63
src/input2.c
@@ -10,16 +10,13 @@ License: see LICENSE
|
|||||||
Last Updated: 03/17/2019
|
Last Updated: 03/17/2019
|
||||||
******************************************************************************
|
******************************************************************************
|
||||||
*/
|
*/
|
||||||
#ifdef _DEBUG
|
|
||||||
#define _CRTDBG_MAP_ALLOC
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <crtdbg.h>
|
|
||||||
#else
|
|
||||||
#include <stdlib.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#ifndef __APPLE__
|
||||||
|
#include <malloc.h>
|
||||||
|
#endif
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
@@ -59,7 +56,7 @@ int netsize(Project *pr)
|
|||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
Parser *parser = &pr->parser;
|
Parser *parser = &pr->parser;
|
||||||
|
|
||||||
char line[MAXLINE + 1]; // Line from input data file
|
char line[MAXLINE + 1]; // Line from input data file
|
||||||
char *tok; // First token of line
|
char *tok; // First token of line
|
||||||
int sect, newsect; // Input data sections
|
int sect, newsect; // Input data sections
|
||||||
@@ -150,7 +147,7 @@ int readdata(Project *pr)
|
|||||||
inperr, errsum; // Error code & total error count
|
inperr, errsum; // Error code & total error count
|
||||||
|
|
||||||
// Allocate input buffer
|
// Allocate input buffer
|
||||||
parser->X = (double *)calloc(MAXTOKS + 1, sizeof(double));
|
parser->X = (double *)calloc(MAXTOKS, sizeof(double));
|
||||||
ERRCODE(MEMCHECK(parser->X));
|
ERRCODE(MEMCHECK(parser->X));
|
||||||
if (errcode) return errcode;
|
if (errcode) return errcode;
|
||||||
|
|
||||||
@@ -178,7 +175,7 @@ int readdata(Project *pr)
|
|||||||
while (fgets(line, MAXLINE, parser->InFile) != NULL)
|
while (fgets(line, MAXLINE, parser->InFile) != NULL)
|
||||||
{
|
{
|
||||||
// Make copy of line and scan for tokens
|
// Make copy of line and scan for tokens
|
||||||
strncpy(wline, line, MAXLINE);
|
strcpy(wline, line);
|
||||||
parser->Ntokens = gettokens(wline, parser->Tok, MAXTOKS, parser->Comment);
|
parser->Ntokens = gettokens(wline, parser->Tok, MAXTOKS, parser->Comment);
|
||||||
|
|
||||||
// Skip blank lines and those filled with a comment
|
// Skip blank lines and those filled with a comment
|
||||||
@@ -249,10 +246,10 @@ int readdata(Project *pr)
|
|||||||
// Stop if reach end of file or max. error count
|
// Stop if reach end of file or max. error count
|
||||||
if (errsum == MAXERRS) break;
|
if (errsum == MAXERRS) break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for errors
|
// Check for errors
|
||||||
if (errsum > 0) errcode = 200;
|
if (errsum > 0) errcode = 200;
|
||||||
|
|
||||||
// Check for unlinked nodes
|
// Check for unlinked nodes
|
||||||
if (!errcode) errcode = unlinked(pr);
|
if (!errcode) errcode = unlinked(pr);
|
||||||
|
|
||||||
@@ -400,7 +397,7 @@ int updatepumpparams(Project *pr, int pumpindex)
|
|||||||
curve->Type = PUMP_CURVE;
|
curve->Type = PUMP_CURVE;
|
||||||
npts = curve->Npts;
|
npts = curve->Npts;
|
||||||
|
|
||||||
// Generic power function curve
|
// Generic power function curve
|
||||||
if (npts == 1)
|
if (npts == 1)
|
||||||
{
|
{
|
||||||
pump->Ptype = POWER_FUNC;
|
pump->Ptype = POWER_FUNC;
|
||||||
@@ -410,7 +407,7 @@ int updatepumpparams(Project *pr, int pumpindex)
|
|||||||
q2 = 2.0 * q1;
|
q2 = 2.0 * q1;
|
||||||
h2 = 0.0;
|
h2 = 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3 point curve with shutoff head
|
// 3 point curve with shutoff head
|
||||||
else if (npts == 3 && curve->X[0] == 0.0)
|
else if (npts == 3 && curve->X[0] == 0.0)
|
||||||
{
|
{
|
||||||
@@ -421,7 +418,7 @@ int updatepumpparams(Project *pr, int pumpindex)
|
|||||||
q2 = curve->X[2];
|
q2 = curve->X[2];
|
||||||
h2 = curve->Y[2];
|
h2 = curve->Y[2];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Custom pump curve
|
// Custom pump curve
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -434,7 +431,7 @@ int updatepumpparams(Project *pr, int pumpindex)
|
|||||||
pump->Q0 = (curve->X[0] + pump->Qmax) / 2.0;
|
pump->Q0 = (curve->X[0] + pump->Qmax) / 2.0;
|
||||||
pump->Hmax = curve->Y[0];
|
pump->Hmax = curve->Y[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Compute shape factors & limits of power function curves
|
// Compute shape factors & limits of power function curves
|
||||||
if (pump->Ptype == POWER_FUNC)
|
if (pump->Ptype == POWER_FUNC)
|
||||||
{
|
{
|
||||||
@@ -464,7 +461,7 @@ int addnodeID(Network *net, int n, char *id)
|
|||||||
**--------------------------------------------------------------
|
**--------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
if (findnode(net,id)) return 0;
|
if (findnode(net,id)) return 0;
|
||||||
strncpy(net->Node[n].ID, id, MAXID);
|
strncpy(net->Node[n].ID, id, MAXID);
|
||||||
hashtable_insert(net->NodeHashTable, net->Node[n].ID, n);
|
hashtable_insert(net->NodeHashTable, net->Node[n].ID, n);
|
||||||
return 1;
|
return 1;
|
||||||
@@ -590,7 +587,7 @@ int unlinked(Project *pr)
|
|||||||
Network *net = &pr->network;
|
Network *net = &pr->network;
|
||||||
int *marked;
|
int *marked;
|
||||||
int i, err, errcode;
|
int i, err, errcode;
|
||||||
|
|
||||||
errcode = 0;
|
errcode = 0;
|
||||||
err = 0;
|
err = 0;
|
||||||
|
|
||||||
@@ -599,19 +596,19 @@ int unlinked(Project *pr)
|
|||||||
ERRCODE(MEMCHECK(marked));
|
ERRCODE(MEMCHECK(marked));
|
||||||
if (errcode) return errcode;
|
if (errcode) return errcode;
|
||||||
memset(marked, 0, (net->Nnodes + 1) * sizeof(int));
|
memset(marked, 0, (net->Nnodes + 1) * sizeof(int));
|
||||||
|
|
||||||
// Mark end nodes of each link
|
// Mark end nodes of each link
|
||||||
for (i = 1; i <= net->Nlinks; i++)
|
for (i = 1; i <= net->Nlinks; i++)
|
||||||
{
|
{
|
||||||
marked[net->Link[i].N1]++;
|
marked[net->Link[i].N1]++;
|
||||||
marked[net->Link[i].N2]++;
|
marked[net->Link[i].N2]++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check each junction
|
// Check each junction
|
||||||
for (i = 1; i <= net->Njuncs; i++)
|
for (i = 1; i <= net->Njuncs; i++)
|
||||||
{
|
{
|
||||||
// If not marked then error
|
// If not marked then error
|
||||||
if (marked[i] == 0)
|
if (marked[i] == 0)
|
||||||
{
|
{
|
||||||
err++;
|
err++;
|
||||||
sprintf(pr->Msg, "Error 233: %s %s", geterrmsg(233, pr->Msg), net->Node[i].ID);
|
sprintf(pr->Msg, "Error 233: %s %s", geterrmsg(233, pr->Msg), net->Node[i].ID);
|
||||||
@@ -641,7 +638,7 @@ int getpatterns(Project *pr)
|
|||||||
SFloatlist *f;
|
SFloatlist *f;
|
||||||
STmplist *tmppattern;
|
STmplist *tmppattern;
|
||||||
Spattern *pattern;
|
Spattern *pattern;
|
||||||
|
|
||||||
// Start at head of the list of patterns
|
// Start at head of the list of patterns
|
||||||
tmppattern = parser->Patlist;
|
tmppattern = parser->Patlist;
|
||||||
|
|
||||||
@@ -699,7 +696,7 @@ int getcurves(Project *pr)
|
|||||||
{
|
{
|
||||||
Network *net = &pr->network;
|
Network *net = &pr->network;
|
||||||
Parser *parser = &pr->parser;
|
Parser *parser = &pr->parser;
|
||||||
|
|
||||||
int i, j;
|
int i, j;
|
||||||
double x;
|
double x;
|
||||||
char errmsg[MAXMSG+1];
|
char errmsg[MAXMSG+1];
|
||||||
@@ -830,14 +827,14 @@ int gettokens(char *s, char** Tok, int maxToks, char *comment)
|
|||||||
int m, n;
|
int m, n;
|
||||||
size_t len;
|
size_t len;
|
||||||
char *c, *c2;
|
char *c, *c2;
|
||||||
|
|
||||||
// clear comment
|
// clear comment
|
||||||
comment[0] = '\0';
|
comment[0] = '\0';
|
||||||
|
|
||||||
// Begin with no tokens
|
// Begin with no tokens
|
||||||
for (n=0; n<maxToks; n++) Tok[n] = NULL;
|
for (n=0; n<maxToks; n++) Tok[n] = NULL;
|
||||||
n = 0;
|
n = 0;
|
||||||
|
|
||||||
// Truncate s at start of comment
|
// Truncate s at start of comment
|
||||||
c = strchr(s,';');
|
c = strchr(s,';');
|
||||||
if (c)
|
if (c)
|
||||||
@@ -858,7 +855,7 @@ int gettokens(char *s, char** Tok, int maxToks, char *comment)
|
|||||||
*c = '\0';
|
*c = '\0';
|
||||||
}
|
}
|
||||||
len = (int)strlen(s);
|
len = (int)strlen(s);
|
||||||
|
|
||||||
// Scan s for tokens until nothing left
|
// Scan s for tokens until nothing left
|
||||||
while (len > 0 && n < MAXTOKS)
|
while (len > 0 && n < MAXTOKS)
|
||||||
{
|
{
|
||||||
@@ -871,7 +868,7 @@ int gettokens(char *s, char** Tok, int maxToks, char *comment)
|
|||||||
{
|
{
|
||||||
s++; // Start token after quote
|
s++; // Start token after quote
|
||||||
m = (int)strcspn(s,"\"\n\r"); // Find end quote (or EOL)
|
m = (int)strcspn(s,"\"\n\r"); // Find end quote (or EOL)
|
||||||
}
|
}
|
||||||
s[m] = '\0'; // Null-terminate the token
|
s[m] = '\0'; // Null-terminate the token
|
||||||
Tok[n] = s; // Save pointer to token
|
Tok[n] = s; // Save pointer to token
|
||||||
n++; // Update token count
|
n++; // Update token count
|
||||||
@@ -879,7 +876,7 @@ int gettokens(char *s, char** Tok, int maxToks, char *comment)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
double hour(char *time, char *units)
|
double hour(char *time, char *units)
|
||||||
/*
|
/*
|
||||||
@@ -917,7 +914,7 @@ double hour(char *time, char *units)
|
|||||||
if (match(units, w_DAYS)) return (y[0] * 24.0);
|
if (match(units, w_DAYS)) return (y[0] * 24.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convert hh:mm:ss format to decimal hours
|
// Convert hh:mm:ss format to decimal hours
|
||||||
if (n > 1) y[0] = y[0] + y[1] / 60.0 + y[2] / 3600.0;
|
if (n > 1) y[0] = y[0] + y[1] / 60.0 + y[2] / 3600.0;
|
||||||
|
|
||||||
// If am/pm attached then adjust hour accordingly
|
// If am/pm attached then adjust hour accordingly
|
||||||
@@ -936,7 +933,7 @@ double hour(char *time, char *units)
|
|||||||
else return (y[0] + 12.0);
|
else return (y[0] + 12.0);
|
||||||
}
|
}
|
||||||
return -1.0;
|
return -1.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int getfloat(char *s, double *y)
|
int getfloat(char *s, double *y)
|
||||||
/*
|
/*
|
||||||
@@ -982,14 +979,14 @@ void inperrmsg(Project *pr, int err, int sect, char *line)
|
|||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
Parser *parser = &pr->parser;
|
Parser *parser = &pr->parser;
|
||||||
|
|
||||||
char errStr[MAXMSG + 1] = "";
|
char errStr[MAXMSG + 1] = "";
|
||||||
char tok[MAXMSG + 1];
|
char tok[MAXMSG + 1];
|
||||||
|
|
||||||
// Get token associated with input error
|
// Get token associated with input error
|
||||||
if (parser->ErrTok >= 0) strcpy(tok, parser->Tok[parser->ErrTok]);
|
if (parser->ErrTok >= 0) strcpy(tok, parser->Tok[parser->ErrTok]);
|
||||||
else strcpy(tok, "");
|
else strcpy(tok, "");
|
||||||
|
|
||||||
// write error message to report file
|
// write error message to report file
|
||||||
sprintf(pr->Msg, "Error %d: %s %s in %s section:",
|
sprintf(pr->Msg, "Error %d: %s %s in %s section:",
|
||||||
err, geterrmsg(err, errStr), tok, SectTxt[sect]);
|
err, geterrmsg(err, errStr), tok, SectTxt[sect]);
|
||||||
|
|||||||
11
src/input3.c
11
src/input3.c
@@ -10,16 +10,13 @@ License: see LICENSE
|
|||||||
Last Updated: 03/17/2019
|
Last Updated: 03/17/2019
|
||||||
******************************************************************************
|
******************************************************************************
|
||||||
*/
|
*/
|
||||||
#ifdef _DEBUG
|
|
||||||
#define _CRTDBG_MAP_ALLOC
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <crtdbg.h>
|
|
||||||
#else
|
|
||||||
#include <stdlib.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#ifndef __APPLE__
|
||||||
|
#include <malloc.h>
|
||||||
|
#endif
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
|
|||||||
@@ -15,7 +15,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#ifndef __APPLE__
|
||||||
|
#include <malloc.h>
|
||||||
|
#endif
|
||||||
#include "mempool.h"
|
#include "mempool.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -11,9 +11,13 @@ Last Updated: 11/27/2018
|
|||||||
******************************************************************************
|
******************************************************************************
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#ifndef __APPLE__
|
||||||
|
#include <malloc.h>
|
||||||
|
#else
|
||||||
|
#include <stdlib.h>
|
||||||
|
#endif
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
|
|||||||
@@ -11,18 +11,14 @@
|
|||||||
******************************************************************************
|
******************************************************************************
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef _DEBUG
|
#include <stdio.h>
|
||||||
#define _CRTDBG_MAP_ALLOC
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#ifndef __APPLE__
|
||||||
#include <crtdbg.h>
|
#include <malloc.h>
|
||||||
#else
|
#else
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
|
|
||||||
//*** For the Windows SDK _tempnam function ***//
|
//*** For the Windows SDK _tempnam function ***//
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|||||||
@@ -11,9 +11,13 @@ Last Updated: 11/27/2018
|
|||||||
******************************************************************************
|
******************************************************************************
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#ifndef __APPLE__
|
||||||
|
#include <malloc.h>
|
||||||
|
#else
|
||||||
|
#include <stdlib.h>
|
||||||
|
#endif
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
#include "mempool.h"
|
#include "mempool.h"
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ Last Updated: 11/27/2018
|
|||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
|
|
||||||
// Exported functions
|
// Exported functions
|
||||||
|
|||||||
@@ -11,10 +11,13 @@ Last Updated: 11/27/2018
|
|||||||
******************************************************************************
|
******************************************************************************
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#ifndef __APPLE__
|
||||||
|
#include <malloc.h>
|
||||||
|
#else
|
||||||
|
#include <stdlib.h>
|
||||||
|
#endif
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
#include "mempool.h"
|
#include "mempool.h"
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
|
|
||||||
|
|||||||
@@ -11,10 +11,13 @@
|
|||||||
******************************************************************************
|
******************************************************************************
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#ifndef __APPLE__
|
||||||
|
#include <malloc.h>
|
||||||
|
#else
|
||||||
|
#include <stdlib.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#define snprintf _snprintf
|
#define snprintf _snprintf
|
||||||
|
|||||||
@@ -11,9 +11,13 @@
|
|||||||
******************************************************************************
|
******************************************************************************
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#ifndef __APPLE__
|
||||||
|
#include <malloc.h>
|
||||||
|
#else
|
||||||
|
#include <stdlib.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
#include "funcs.h"
|
#include "funcs.h"
|
||||||
|
|||||||
@@ -18,11 +18,16 @@
|
|||||||
linsolve() -- called from netsolve() in HYDRAUL.C
|
linsolve() -- called from netsolve() in HYDRAUL.C
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#ifndef __APPLE__
|
||||||
|
#include <malloc.h>
|
||||||
|
#else
|
||||||
|
#include <stdlib.h>
|
||||||
|
#endif
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
|
||||||
#include <time.h> //For optional timer macros
|
#include <time.h> //For optional timer macros
|
||||||
|
|
||||||
#include "text.h"
|
#include "text.h"
|
||||||
|
|||||||
@@ -14,10 +14,8 @@
|
|||||||
#ifndef TYPES_H
|
#ifndef TYPES_H
|
||||||
#define TYPES_H
|
#define TYPES_H
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
#include "hash.h"
|
#include "hash.h"
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
-------------------------------------------
|
-------------------------------------------
|
||||||
|
|||||||
@@ -10,7 +10,13 @@
|
|||||||
// US EPA - ORD/NRMRL
|
// US EPA - ORD/NRMRL
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
//#ifdef _WIN32
|
||||||
|
//#define _CRTDBG_MAP_ALLOC
|
||||||
|
//#include <stdlib.h>
|
||||||
|
//#include <crtdbg.h>
|
||||||
|
//#else
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
//#endif
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "errormanager.h"
|
#include "errormanager.h"
|
||||||
|
|||||||
@@ -19,19 +19,18 @@ endif(UNIX)
|
|||||||
set(toolkit_test_srcs
|
set(toolkit_test_srcs
|
||||||
test_toolkit.cpp
|
test_toolkit.cpp
|
||||||
test_project.cpp
|
test_project.cpp
|
||||||
# test_hydraulics.cpp
|
test_hydraulics.cpp
|
||||||
# test_quality.cpp
|
test_quality.cpp
|
||||||
# test_report.cpp
|
test_report.cpp
|
||||||
# test_analysis.cpp
|
test_analysis.cpp
|
||||||
# test_node.cpp
|
test_node.cpp
|
||||||
# test_demand.cpp
|
test_demand.cpp
|
||||||
# test_link.cpp
|
test_link.cpp
|
||||||
# test_pump.cpp
|
# test_pump.cpp
|
||||||
# test_pattern.cpp
|
test_pattern.cpp
|
||||||
# test_curve.cpp
|
test_curve.cpp
|
||||||
# test_control.cpp
|
test_control.cpp
|
||||||
# test_net_builder.cpp
|
test_net_builder.cpp)
|
||||||
)
|
|
||||||
|
|
||||||
add_executable(test_toolkit ${toolkit_test_srcs})
|
add_executable(test_toolkit ${toolkit_test_srcs})
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
******************************************************************************
|
******************************************************************************
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
//#define BOOST_ALL_DYN_LINK
|
||||||
#include <boost/test/unit_test.hpp>
|
#include <boost/test/unit_test.hpp>
|
||||||
|
|
||||||
#include "test_toolkit.hpp"
|
#include "test_toolkit.hpp"
|
||||||
|
|||||||
@@ -56,47 +56,35 @@ BOOST_AUTO_TEST_CASE(test_save)
|
|||||||
{
|
{
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
EN_Project ph = NULL;
|
EN_Project ph_save;
|
||||||
|
|
||||||
error = EN_createproject(&ph);
|
EN_createproject(&ph_save);
|
||||||
BOOST_REQUIRE(error == 0);
|
error = EN_open(ph_save, DATA_PATH_NET1, DATA_PATH_RPT, DATA_PATH_OUT);
|
||||||
|
|
||||||
error = EN_open(ph, DATA_PATH_NET1, DATA_PATH_RPT, DATA_PATH_OUT);
|
|
||||||
BOOST_REQUIRE(error == 0);
|
BOOST_REQUIRE(error == 0);
|
||||||
|
|
||||||
error = EN_saveinpfile(ph, DATA_PATH_TMP);
|
error = EN_saveinpfile(ph_save, "test_reopen.inp");
|
||||||
BOOST_REQUIRE(error == 0);
|
BOOST_REQUIRE(error == 0);
|
||||||
|
|
||||||
BOOST_CHECK(boost::filesystem::exists(DATA_PATH_TMP) == true);
|
BOOST_CHECK(boost::filesystem::exists("test_reopen.inp") == true);
|
||||||
|
|
||||||
error = EN_close(ph);
|
error = EN_close(ph_save);
|
||||||
BOOST_REQUIRE(error == 0);
|
BOOST_REQUIRE(error == 0);
|
||||||
|
EN_deleteproject(&ph_save);
|
||||||
error = EN_deleteproject(&ph);
|
|
||||||
BOOST_REQUIRE(error == 0);
|
|
||||||
|
|
||||||
BOOST_CHECK(ph == NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(test_reopen, * boost::unit_test::depends_on("test_project/test_save"))
|
BOOST_AUTO_TEST_CASE(test_reopen, * boost::unit_test::depends_on("test_project/test_save"))
|
||||||
{
|
{
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
EN_Project ph = NULL;
|
EN_Project ph_reopen;
|
||||||
|
|
||||||
error = EN_createproject(&ph);
|
EN_createproject(&ph_reopen);
|
||||||
BOOST_REQUIRE(error == 0);
|
error = EN_open(ph_reopen, "test_reopen.inp", DATA_PATH_RPT, DATA_PATH_OUT);
|
||||||
|
BOOST_REQUIRE(error == 0);
|
||||||
|
|
||||||
error = EN_open(ph, DATA_PATH_TMP, DATA_PATH_RPT, DATA_PATH_OUT);
|
error = EN_close(ph_reopen);
|
||||||
BOOST_REQUIRE(error == 0);
|
BOOST_REQUIRE(error == 0);
|
||||||
|
EN_deleteproject(&ph_reopen);
|
||||||
error = EN_close(ph);
|
|
||||||
BOOST_REQUIRE(error == 0);
|
|
||||||
|
|
||||||
EN_deleteproject(&ph);
|
|
||||||
BOOST_REQUIRE(error == 0);
|
|
||||||
|
|
||||||
BOOST_CHECK(ph == NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(test_run)
|
BOOST_AUTO_TEST_CASE(test_run)
|
||||||
|
|||||||
@@ -14,12 +14,6 @@
|
|||||||
#ifndef TEST_TOOLKIT_HPP
|
#ifndef TEST_TOOLKIT_HPP
|
||||||
#define TEST_TOOLKIT_HPP
|
#define TEST_TOOLKIT_HPP
|
||||||
|
|
||||||
// MSVC ONLY
|
|
||||||
#ifdef _DEBUG
|
|
||||||
#define _CRTDBG_MAP_ALLOC
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <crtdbg.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "epanet2_2.h"
|
#include "epanet2_2.h"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user