Opened 8 years ago
Closed 3 years ago
#4239 closed defect (fixed)
Errors in compilation of AdvancedNoise.Examples.TimeBasedNoise
Reported by: | Adrian Pop | Owned by: | Lennart Ochel |
---|---|---|---|
Priority: | high | Milestone: | 1.19.0 |
Component: | Backend | Version: | |
Keywords: | AdvancedNoise | Cc: |
Description
See also:
https://www.openmodelica.org/forum/default-topic/2091-advancednoise
I tried model AdvancedNoise.Examples.TimeBasedNoise
and got errors such as:
AdvancedNoise.Examples.TimeBasedNoise.c: In function 'AdvancedNoise_Examples_TimeBasedNoise_eqFunction_13': AdvancedNoise.Examples.TimeBasedNoise.c:315:32: error: '$PnBuffer' undeclared (first use in this function) switch((((modelica_integer)$PnBuffer == ((modelica_integer) 1))?((modelica_integer) 1):((modelica_integer) 1) + (_event_integer(DIVISION_SIM(data->localData[0]->timeValue - data->localData[0]->realVars[4] /* timeBasedNoise._bufferStartTime DISCRETE */,data->simulationInfo->realParameter[2] /* timeBasedNoise._samplePeriod PARAM */,"timeBasedNoise.samplePeriod",equationIndexes), ((modelica_integer) 0), data))))
Seems to be an issue with inlining of function:
function AdvancedNoise.Sources.TimeBasedNoise$timeBasedNoise.interpolation.interpolate "Inline before index reduction" "Constant interpolation in a buffer of random values" input Real[:] buffer "Buffer of random numbers"; input Real offset "Offset from buffer start (0..size(buffer)-1"; input Real samplePeriod = 1.0 "The sample period of the noise buffer"; output Real y "Interpolated value at position offset"; protected Integer nBuffer = size(buffer, 1) "Size of the buffer"; algorithm y := buffer[if nBuffer == 1 then 1 else 1 + integer(offset)]; end AdvancedNoise.Sources.TimeBasedNoise$timeBasedNoise.interpolation.interpolate;
in equation
timeBasedNoise.y = if not timeBasedNoise.generateNoise or time < timeBasedNoise.startTime then timeBasedNoise.y_off else AdvancedNoise.Sources.TimeBasedNoise$timeBasedNoise.interpolation.interpolate({timeBasedNoise.buffer[1], timeBasedNoise.buffer[2]}, (time - timeBasedNoise.bufferStartTime) / timeBasedNoise.samplePeriod + /*Real*/(timeBasedNoise.nPast), timeBasedNoise.samplePeriod);
as it produces this C code:
switch((((modelica_integer)$PnBuffer == ((modelica_integer) 1))?((modelica_integer) 1):((modelica_integer) 1) + (_event_integer(DIVISION_SIM(data->localData[0]->timeValue - data->localData[0]->realVars[4] /* timeBasedNoise._bufferStartTime DISCRETE */,data->simulationInfo->realParameter[2] /* timeBasedNoise._samplePeriod PARAM */,"timeBasedNoise.samplePeriod",equationIndexes), ((modelica_integer) 0), data))))
where $PnBuffer
is not declared at all.
Change History (9)
comment:1 by , 8 years ago
Keywords: | AdvancedNoise added |
---|---|
Milestone: | Future → 1.12.0 |
Status: | new → accepted |
comment:2 by , 8 years ago
comment:3 by , 7 years ago
Milestone: | 1.12.0 → 1.13.0 |
---|
Milestone moved to 1.13.0 due to 1.12.0 already being released.
comment:5 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:7 by , 4 years ago
Milestone: | 1.17.0 → 1.18.0 |
---|
Retargeted to 1.18.0 because of 1.17.0 timed release.
comment:9 by , 3 years ago
Milestone: | → 1.19.0 |
---|---|
Resolution: | → fixed |
Status: | accepted → closed |
TimeBasedNoise
seems to be working fine now according to the library testing.
I can confirm that the issue is connected to function inlining.
One can disable inlining of functions as a workaround using the following omc-flag:
-d=-inlineFunctions
.