﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc
4549	Zero size string array	Christian Kral <dr.christian.kral@…>	Willi Braun	"When investigating #4524, I stumbled into a problem with zero size string variables of functions. Please consider the following example:

{{{
package TestString
  function zeroSize
    input Real matrix[:, :] ""Matrix"";
    input String[:,:] header = fill("""", 0, size(matrix, 2)) ""String matrix"";
  algorithm
    Modelica.Utilities.Streams.print(""Size of matrix: "" + String(size(matrix, 1)) + "" x "" + String(size(matrix, 2)));
    Modelica.Utilities.Streams.print(""Size of header: "" + String(size(header, 1)) + "" x "" + String(size(header, 2)));
    if size(matrix,2)<>size(header,2) then
      Modelica.Utilities.Streams.error(""zeroSize: number of columns of matrix (""+String(size(matrix,2))+"") and header (""+String(size(header,2))+"") do not match"");
    end if;
  end zeroSize;

  model TestZeroSize
  parameter Real M[2,2] = [1,2;3,4];
  algorithm 
    when initial() then
      // zeroSize({{1,2},{3,4}});
      zeroSize(M);
    end when;
  end TestZeroSize;
end TestString;
}}}

In this example the function {{{zeroSize}}} has the two input variables, {{{matrix}}} and {{{header}}}. Variable {{{header}}} is assigned with a default input: a string zero rows and two columns. The function here just serves as dummy function, logging the dimensions of the two arrays {{{matrix}}} and {{{header}}} and cause an error, in case their number of rows were different.

In the test model {{{TestString}}} the function {{{zeroSize}}} is tested. When simulating the modell, the following error is triggered:

{{{
stdout | error | <p>Simulation process failed. Exited with code 255.</p>
stdout | info | <p>Size of matrix: 2 x 2<br>

stdout | info | <p>Size of header: 0 x 0<br>

assert | debug | <p>zeroSize: number of columns of matrix (2) and header (0) do not match</p>
assert | info | <p>simulation terminated by an assertion at initialization</p>
}}}

So apparently the number of columns is not determined correctly in the function call. Now change the test model to:

{{{
    zeroSize({{1,2},{3,4}});
    // zeroSize(M);
}}}

an re-run the simulation test model: everything works fine with no complaints..."	defect	assigned	high	Future	Run-time				Jan Kokert Adrian Pop
