Archived OpenModelica forums. Posting is disabled.

Alternative forums include GitHub discussions or StackOverflow (make sure to read the Stack Overflow rules; you need to have well-formed questions)


Forgot password? | Forgot username? | Register
  • Index
  • » Users
  • » Clements
  • » Profile

Posts

Posts

Jan-02-15 10:06:14
Category: Programming

I am an OpenModelica newbie.

I have been trying to use the DESLib library for modelling Poisson processes. However, I have been usable to use the DESLib.RandomLib library. I have some test code below that seems to reproduce the bug for g := DESLib.RandomLib.CMRG.CreateStream().

record RngStream "RNGStream"
  Real seed[6];
end RngStream;

function CheckSeed "CheckSeed - are all seeds non-negative?"
  input Real seed[6];
  output Boolean valid;
algorithm
  valid := true;
  for i in 1:6 loop
    if seed[i]<0 then
      valid := false;
    end if;
  end for;
end CheckSeed;

function CreateStream "CreateStream"
  output RngStream g;
algorithm
  for i in 1:6 loop
    g.seed[i] := 12345;
  end for;
  CheckSeed(g.seed); // commenting out this line lets simulate(Test) run
end CreateStream;

model Test "Test - call CreateStream"
  RngStream g;
algorithm
  when initial() then
    g := CreateStream();
  end when;
end Test; // simulate(Test) FAILS

Running the script "loadModel(Modelica); loadFile("test.mo"); simulate(Test)" under OMShell gives:

Error: Error building simulator. Build log: clang   -fPIC     -I"/usr/include/omc/c" -I. -DOPENMODELICA_XML_FROM_FILE_AT_RUNTIME  -c -o Test.o Test.c
clang   -fPIC     -I"/usr/include/omc/c" -I. -DOPENMODELICA_XML_FROM_FILE_AT_RUNTIME  -c -o Test_functions.o Test_functions.c
Test_functions.c:43:45: error: assigning to 'real_array' (aka 'struct base_array_s') from incompatible type 'double'
      (&_g._seed)[(modelica_integer)_i - 1] = 12345.0;
                                            ^ ~~~~~~~

Any help with this would be apprecated. Note that I am running OpenModelica 1.9.1 (r22929) (RML version) under OMShell 1.1 on Linux using the standard Linux installation process.

Kindly, Mark.

  • Index
  • » Users
  • » Clements
  • » Profile
You are here: