#3261 closed defect (fixed)
Cannot override array variables
Reported by: | Owned by: | Adrian Pop | |
---|---|---|---|
Priority: | high | Milestone: | 1.9.3 |
Component: | Run-time | Version: | trunk |
Keywords: | Cc: |
Description
The command line option -override and -overrideFile do not allow overrides of array variables. This is because the override string is tokenized by ",", which also catches the array dimension separator. This happens at simulation_input_xml.cpp:838.
The same problem happens with the -output option in solver_main.c:773. Could this happen anywhere else?
A quick fix would be to use a different separator character that would never exist in a variable name such as ";" and thereby avoid this issue.
Here is an example that reproduces the problem:
model overrideBug parameter Real[2,2] A = {{1,2},{3,4}}; Real[2] x(start={1,2}); Real[2] y; equation y = der(x); der(y) = A * x; end overrideBug;
Output:
./overrideBug.exe -override A[1,1]=0 stdout | warning | simulation_input_xml.cpp: override variable name not found in model: 1] stdout | warning | simulation_input_xml.cpp: override variable name not found in model: A[1
Change History (9)
comment:1 by , 10 years ago
comment:3 by , 10 years ago
Milestone: | Future → 1.9.3 |
---|---|
Owner: | changed from | to
Status: | new → accepted |
Yeah. We should change this to ignore "," inside [ ]
:
char *p = strtok(overrideStr, ",");
I'll see what I can do.
comment:6 by , 10 years ago
What do you mean? I don't get it.
The command line outputs should be parsed by the external program that reads them :)
comment:7 by , 10 years ago
The -output flag won't dump the value of an array variable. For example,
./overrideBug.exe -output x[1],A[1,1] time=1,x[1]=4.846927041353899
does not dump out A[1,1] due to a similar tokenizing bug at solver_main.c:773.
Ouch, I didn't think of that. We can either fix this as you suggest using ";" as separator or we make the parsing of variables a bit more clever.