Opened 7 years ago
Closed 7 years ago
#4878 closed defect (fixed)
Issue with parameter arrays with zero elements in the NF
Reported by: | Francesco Casella | Owned by: | Per Östlund |
---|---|---|---|
Priority: | high | Milestone: | 2.0.0 |
Component: | New Instantiation | Version: | |
Keywords: | Cc: |
Description
Please check Modelica.Blocks.Examples.Filter. The following errors are reported:
Modelica_3.2.2_Modelica.Blocks.Examples.Filter_06inz.c Modelica_3.2.2_Modelica.Blocks.Examples.Filter_06inz.c:267:49: error: use of undeclared identifier '$PCriticalDamping$Pa' real_array_create(&tmp2, ((modelica_real*)&((&$PCriticalDamping$Pa)[calc_base_index_dims_subs(1, 0, ((modelica_integer) 1))])), 1, 0); ^ Modelica_3.2.2_Modelica.Blocks.Examples.Filter_06inz.c:268:49: error: use of undeclared identifier '$PCriticalDamping$Pb' real_array_create(&tmp3, ((modelica_real*)&((&$PCriticalDamping$Pb)[calc_base_index_dims_subs(1, 0, ((modelica_integer) 1))])), 1, 0); ^ Modelica_3.2.2_Modelica.Blocks.Examples.Filter_06inz.c:269:49: error: use of undeclared identifier '$PCriticalDamping$Pku' real_array_create(&tmp4, ((modelica_real*)&((&$PCriticalDamping$Pku)[calc_base_index_dims_subs(1, 0, ((modelica_integer) 1))])), 1, 0); ^ Modelica_3.2.2_Modelica.Blocks.Examples.Filter_06inz.c:271:49: error: use of undeclared identifier '$PCriticalDamping$Pc0' real_array_create(&tmp6, ((modelica_real*)&((&$PCriticalDamping$Pc0)[calc_base_index_dims_subs(1, 0, ((modelica_integer) 1))])), 1, 0); ^ Modelica_3.2.2_Modelica.Blocks.Examples.Filter_06inz.c:272:49: error: use of undeclared identifier '$PCriticalDamping$Pc1' real_array_create(&tmp7, ((modelica_real*)&((&$PCriticalDamping$Pc1)[calc_base_index_dims_subs(1, 0, ((modelica_integer) 1))])), 1, 0);
It turns out that a, b, ku, c0, c1
are parameters array whose dimensions should be zero because of these declarations:
parameter Integer nc0 = if analogFilter == Modelica.Blocks.Types.AnalogFilter.CriticalDamping then 0 else integer(order/2); parameter Integer na = if filterType == Modelica.Blocks.Types.FilterType.BandPass or filterType == Modelica.Blocks.Types.FilterType.BandStop then order else if analogFilter == Modelica.Blocks.Types.AnalogFilter.CriticalDamping then 0 else integer(order/2);
Something goes wrong there, so these parameters survive the FE and get somehow passed to the code generation phase. Unfortunately at the moment I cannot flatten the model myself to check what exactly is the issue.
Change History (3)
comment:1 by , 7 years ago
comment:2 by , 7 years ago
I think the old frontend dealt with this by changing zero-length arrays to empty expressions on lhs and an empty array on the rhs (which is sort of bad because it doesn't store the sizes of the dimensions, so size(e,2)
might return 0 instead of the actual size).
comment:3 by , 7 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Fixed in bd4083a, along with a few other issues (like constant evaluation of expontentation doing division instead) that should make the model simulate now.
From the flat model:
So another victim of the missing function evaluation. The parameter arrays are otherwise not showing up in the flat model except for this equation.