Opened 4 years ago

Closed 3 years ago

#6205 closed defect (fixed)

Problem with code generation involving records in Buildings

Reported by: Francesco Casella Owned by: Mahder Alemseged Gebremedhin
Priority: critical Milestone: 1.18.0
Component: Code Generation Version:
Keywords: Cc: Michael Wetter

Description (last modified by Francesco Casella)

Please check Buildings.Fluid.Geothermal.Borefields.BaseClasses.HeatTransfer.Validation.Analytic_20Years. The following error is issued during C compilation

Buildings_7.0.0_Buildings.Fluid.Geothermal.Borefields.BaseClasses.HeatTransfer.Validation.Analytic_20Years.c:2442:137: error: passing 'integer_array' (aka 'struct base_array_s') to parameter of incompatible type 'int'
    data->localData[0]->realVars[243] /* groTemRes.delTBor0 DISCRETE */ = mul_real_scalar_product((*real_array_element_addr1(&tmp10, 1, tmp12)), (*real_array_element_addr1(&tmp13, 1, tmp15)));
                                                                                                                                        ^~~~~

Change History (8)

comment:1 by Francesco Casella, 4 years ago

Milestone: 1.17.01.18.0

comment:2 by Mahder Alemseged Gebremedhin, 4 years ago

Status: newaccepted

comment:3 by Mahder Alemseged Gebremedhin, 4 years ago

My guess is that these are most probably NF problems.

I will try to localize the issues and we can pass them to Per. He usually fixes them quite easily.

comment:4 by Francesco Casella, 4 years ago

Description: modified (diff)

comment:5 by Francesco Casella, 4 years ago

The only term I can recognize in the broken C code is groTemRes.delTBor0, I guess this could help pinpointing what goes wrong with the NF. Unfortunately the OF breaks very early with this model, so we don't have an easy comparison term.

@mahge930, if you manage to do this in your spare time, it would be much appreciated :)

comment:6 by Francesco Casella, 4 years ago

Cc: Michael Wetter added

comment:7 by Per Östlund, 4 years ago

Here's an example that gives the same error:

function f
  input Integer sz;
  input Real x[sz];
  input Real y[sz];
  input Integer i;
  output Real z;
algorithm
  z := x[1:i] * y[1:i];
  annotation(Inline = true); 
end f;

model M
  Real x[3] = {time, time, time};
  Real y[3] = {time, time, time};
  Real z;
  Integer i = integer(time);
algorithm
  when time > 0 then
    z := f(3, x, y, i);
  end when;
end M;

The error occurs with both the new and the old frontend, so I don't think it's a frontend issue. The issue seems to occur because the function is inlined, leading to an assignment that the backend can't scalarize and which the code generation doesn't seem to handle correctly.

comment:8 by Francesco Casella, 3 years ago

Resolution: fixed
Status: acceptedclosed

The problem was fixed by mahge930's fixes reported here. These broke most PowerSystems models, but this was also fixed later, see report.

The model cited in the original description now fails at runtime because of a singular matrix, but this is most likely due to some other issue.

Thanks Mahder!

Note: See TracTickets for help on using tickets.