Closed JPL-BELG closed 10 months ago
I was unable to reproduce this error. Attached is the input file I used to test for it, a modified version of Net1.inp with reservoir node 9 re-named to 12345678901234567890 and specified as the trace node. The toolkit code I used is as follows:
#include <stdio.h>
#include "epanet2_2.h"
int main()
{
EN_Project ph;
int errCode, qualType, traceNode;
char traceNodeID[EN_MAXID + 1];
printf("EPANET Trace Test\n");
EN_createproject(&ph);
errCode = EN_open(ph, "net1-mod.inp", "net1-mod.rpt", "");
printf("\nEN_open returns error code = %d\n", errCode);
if (!errCode)
{
EN_getqualtype(ph, &qualType, &traceNode);
EN_getnodeid(ph, traceNode, traceNodeID);
printf("Trace node ID = %s\n", traceNodeID);
}
EN_close(ph);
EN_deleteproject(ph);
return 0;
}
The result from running this code is:
EPANET Trace Test
EN_open returns error code = 0
Trace node ID = 12345678901234567890
Thanks @LRossman. The issue should come from my side. I take a deeper look on my own code and come back.
It seems that the issue could come from the INP file, line QUALITY TRACE 12345678901234567890
In my INP file, I put only one blank character (space) between QUALITY and TRACE. If I put 12 blank characters between the two words, it seems to works with different long node IDs. If I use the "Net1-mod.inp" file you attached with only one blank between "Quality" and "Trace", the problem occurs.
Thanks to confirm the diagnostic.
I accidently close the issue and not sure to be able to reopen it...
In the "Net1-mod.inp" file I created to test for the trace node ID bug I failed to rename node 9 in the [COORDINATES] section to 12345678901234567890. If you use v2.2 of the Toolkit this will result in an "Undefined node" error when it reads that line of the file. But the test I ran was with the dev
branch (v2.3) of the Toolkit, where errors in the [COORDINATES] section are now simply ignored since they don't affect the engine computations. I went back and ran my test code against v2.2 of the Toolkit with a corrected "Net1-mod.inp" file and got the same result as before -- there was no problem in using a trace node with a long ID name.
@JPL-BELG can you share your input file that is causing the problem.
I noticed that the coordinates were missing and added them with epanet stand-alone. I also test the file with the dev branch (v2.3) of the Toolkit (recompiled). Here attached the file: Net1-mod_JPL01a.inp with the followng line in the [OPTIONS] section: Quality Trace 12345678901234567890 (no blank character at the beginning and only one blank between tokens). I ran the type of same code as you (see below) with (i) the INP file you attached (Net1-mod.inp) and with (ii) Net1-mod_JPL01a.inp I attached.
Results are as follows:
Data file : C:\Data\DelphiXE7\RESODO\Essai\QualLongName\Net1-mod.inp
Error code : 0
Data file : C:\Data\DelphiXE7\RESODO\Essai\QualLongName\Net1-mod_JPL01a.inp
Error code : 200
For the Net1-mod_JPL01a.inp file, here is the report file.
Page 1 Mon Sep 11 16:02:11 2023
******************************************************************
* E P A N E T *
* Hydraulic and Water Quality *
* Analysis for Pipe Networks *
* Version 2.3 *
******************************************************************
Error 212: undefined trace node 567890 in [OPTIONS] section:
Quality Trace 12345678901234567890
Error 200: one or more errors in input file
as you can see, I use de v2.3 of the Toolkit. Notice that I use Pascal Delphi together with "epanet2.pas". Here is the code:
procedure TForm1.BBExecuteClick(Sender: TObject);
{
}
var
Code: Integer;
sPath: String;
sReportFile: String;
begin
sPath:=ExtractFilePath(DataFile);
sReportFile:=sPath+'Report.rpt';
Code:=ENopen( PANSIChar(ANSIString(DataFile)),
PANSIChar(ANSIString(sReportFile)),
'');
MInfo.Lines.Add('Error code : '+IntToStr(Code));
MInfo.Lines.Add('');
ENclose();
end;
When adding enough blank characters between "Quality" and "Trace", it is OK.
@JPL-BELG I have confirmed the bug by copying your "Quality Trace 12345678901234567890" line into my Net1-mod.inp file, where there are now just single spaces between tokens, and running it through my test C code (so it's not just a Delphi issue). I will work on fixing it and report back. Thanks for reporting it.
The bug has been fixed (see PR #750). It was caused by some unnecessary code that was overwriting the tokens parsed from the QUALITY TRACE nodeID
line.
Thank you @LRossman. I re-compiled the dll v2.3 and it works fine.
I encounter a problem when using the Toolkit with a quality tracing run (section [OPTIONS], line “QUALITY TRACE”). When the node ID in the INP file is longer than 13 characters, I receive an error message.
Example : -) if trace node ID is 1234567890123 (13 characters) : everything is OK -) if trace node ID is 12345678901234567890 (20 characters) in the INP file, an error is reported in the report file as follows:
INP file [OPTIONS] ... QUALITY TRACE 12345678901234567890
Report file Error 212: undefined trace node 567890 in [OPTIONS] section: QUALITY TRACE 12345678901234567890 Error 200: one or more errors in input file
This occurs only with the toolkit not with EPANET.
Thanks for your opinion.