Opened 12 years ago

Closed 11 years ago

#2031 closed defect (worksforme)

indexed_assign_real_array fails

Reported by: Christian Schubert Owned by: Martin Sjölund
Priority: high Milestone: 1.9.1
Component: Code Generation Version: trunk
Keywords: code generation for loop Cc: Adrian Pop, Jens Frenkel

Description

Hi,

I have a supposedly simple model which crashes during simulation.
The models intention was to check whether Modelica.Matrices.solve works, but we don't get this far ...

model TestSolve
	Real A[5,5]={{-725/100,-875/100,0,-5,0},{-875/100,-125/10,0,-56/10,8/10},{0,0,-5,24/10,-32/10},{-5,-56/10,24/10,0,0},{0,8/10,-32/10,0,0}};
	Real B[5,7]={{-15/10,0,2,0,-875/100,0,-1762/100},{-3,0,2,0,-125/10,0,-1762/100},{-2,0,0,0,-5,0,0},{0,0,0,0,0,0,6/10},{0,0,0,0,0,0,45/100}};
	Real X1[5,7];
	Real X2[5,7];
	Real XRef[5,7]={{-(32/41),0,0,0,-(80/41),0,-(15/41)},{32/41,0,0,0,80/41,0,117/656},{8/41,0,0,0,20/41,0,-(63/656)},{27/410,0,-(2/5),0,191/164,0,1227497/328000},{303/820,0,-(3/10),0,549/328,0,1939683/656000}};
	Real d1[5,7]=X1-XRef;
	Real d2[5,7]=X2-XRef;
	Real err1=sum(d1.*d1) "Error 1";
	Real err2=sum(d2.*d2) "Error 2";
algorithm
	for i in 1:7 loop
		X1[:,i]:=Modelica.Math.Matrices.solve(A,B[:,i]);
	end for;
	X2 := Modelica.Math.Matrices.solve2(A,B);
end TestSolve;

The problem occurs in eqFunction_134, where it tries to execute the for loop. In there we have the following lines of code

      tmp32 = omc_Modelica_Math_Matrices_solve(tmp30, tmp31);

      create_index_spec(&tmp33, 2, (1), (int*)0, 'W', (0), make_index_array(1, (int) (modelica_integer)$Pi), 'S');
      indexed_assign_real_array(&tmp32.c1, &tmp34, &tmp33);
      copy_real_array_data_mem(&tmp34, &$PX1);

Now, as this is the first usage of tmp34, the function indexed_assign_real_array fails because of the assertion

Assertion failed: base_array_ok(dest), file util/real_array.c, line 320

Attachments (2)

TestSolve.mo (816 bytes ) - added by Christian Schubert 12 years ago.
TestSolve.mos (130 bytes ) - added by Christian Schubert 12 years ago.

Download all attachments as: .zip

Change History (5)

by Christian Schubert, 12 years ago

Attachment: TestSolve.mo added

by Christian Schubert, 12 years ago

Attachment: TestSolve.mos added

comment:1 by Jens Frenkel, 12 years ago

comment:2 by Martin Sjölund, 11 years ago

Milestone: 1.9.01.9.1

Postponed until 1.9.1

comment:3 by Martin Sjölund, 11 years ago

Resolution: worksforme
Status: newclosed
Note: See TracTickets for help on using tickets.