Opened 7 years ago
Last modified 3 years ago
#4749 assigned defect
Error: variable wea.lat not found in scope (...) while flattening model
Reported by: | Owned by: | Martin Sjölund | |
---|---|---|---|
Priority: | high | Milestone: | |
Component: | *unknown* | Version: | v1.13.0-dev-nightly |
Keywords: | Cc: | ali.shirazi@… |
Description
We have a bug here arising from use of the latest nightly version of omc --version = "OpenModelica 1.13.0~dev-614-g4bf4d98". Previously our code gave no error, but since updating, we have an error relating to a Parameter value, initialised in a submodel, not being available in the parent model.
The code which causes problems is visible here:
https://github.com/SolarTherm/SolarTherm/blob/alberto-merge/examples/TroughWagner.mo
That model in turn includes this one:
https://github.com/SolarTherm/SolarTherm/blob/alberto-merge/SolarTherm/Systems/GenericSystem.mo
In that model, you can see that 'wea' is instantiated and then immediately we refer to 'wea.lat', which currently results in the following compiler output:
[2] 17:36:27 Translation Notification [SolarTherm.Models.Sources.Weather.WeatherSource: 15:2-15:49]: Moving binding to initial equation section and setting fixed attribute of wea.meta.name to false. [3] 17:36:27 Translation Notification [SolarTherm.Models.Sources.Weather.WeatherSource: 15:2-15:49]: Moving binding to initial equation section and setting fixed attribute of wea.meta.lat to false. [4] 17:36:27 Translation Notification [SolarTherm.Models.Sources.Weather.WeatherSource: 15:2-15:49]: Moving binding to initial equation section and setting fixed attribute of wea.meta.lon to false. [5] 17:36:27 Translation Notification [SolarTherm.Models.Sources.Weather.WeatherSource: 15:2-15:49]: Moving binding to initial equation section and setting fixed attribute of wea.meta.elev to false. [6] 17:36:27 Translation Notification [SolarTherm.Models.Sources.Weather.WeatherSource: 15:2-15:49]: Moving binding to initial equation section and setting fixed attribute of wea.meta.tzone to false. [7] 17:36:27 Translation Notification [SolarTherm.Models.Sources.Weather.WeatherSource: 15:2-15:49]: Moving binding to initial equation section and setting fixed attribute of wea.meta.tstart to false. [8] 17:36:27 Translation Error [SolarTherm.Systems.GenericSystem: 120:19-120:67]: Variable wea.lat not found in scope SolarTherm.Models.CSP.CRS.HeliostatsField.SteeredCL$CL. [9] 17:36:27 Translation Error Error occurred while flattening model TroughWagner
The error is that 'wea.lat' is not found in scope. This seems to closely relate to other issues we've been having recently with Parameters being set in submodels, so we think some regression has happened here.
For example, see this related bug:
https://trac.openmodelica.org/OpenModelica/ticket/4710
Also please note that the "Translation Notification" given above is new -- we never used to see this Notification before -- and seems likely to be related to this problem. Note in particular that the value wea.meta.lat is clearly understood by the compiler, but that the reassignment of wea.meta.lat to Parameter wea.lat in WeatherSource line 6, is not working, since the compiler doesn't then recognise that 'wea.lat' exists.
Change History (9)
comment:1 by , 7 years ago
comment:2 by , 7 years ago
Milestone: | Future → 1.13.0 |
---|---|
Owner: | changed from | to
Status: | new → assigned |
follow-up: 4 comment:3 by , 6 years ago
I have the same problem on 1.13 and it did not occur in 1.12
comment:4 by , 6 years ago
a correction: most likely it had occured in 1.12 as well, actually, but when I was using that version, I found a workaround and since have migrated over to 1.13 in search for a solution for other bugs
it's important that the bug relates (at least in my case) to:
a) arrays of initially undefined length
b) records
so I hav:
- record A having Integer n;
- record B having A and an array Real[:];
- model M having A and an array Real[a.n] and
- model Test initializing M with an instance of A -- which
1) shows above error,
2) if I specify a placeholder default value of a fixed size, then it complains with type checking if I do not specify the array arg to constructor
3) if I specify array size in B as a.n then again, that nasty error
comment:6 by , 5 years ago
Milestone: | 1.14.0 → 1.16.0 |
---|
Releasing 1.14.0 which is stable and has many improvements w.r.t. 1.13.2. This issue is rescheduled to 1.16.0
comment:8 by , 4 years ago
Milestone: | 1.17.0 → 1.18.0 |
---|
Retargeted to 1.18.0 because of 1.17.0 timed release.
Further to the bug report above I think it's useful to note that our online testing of SolarTherm, which is using Ubuntu 14.04 is still working perfectly with the stable branch of OM.
I checked your package repository, and I found that the Ubuntu 14.04 packages have not been updated since 2015. So whatever version you considered as stable back then is working fine with these issues with Parameter seeting. The newer stable versions have problems. I can see that on 16.04 and 17.10 your stable packages are both up-to-date and are OM version 1.12.0~3-g9389f90, and this version has the same issue as the nightly builds. The error message is the same, but there are less Notification messages:
So, hopefully this extra bit of information helps with finding the regression.