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
  • » Buliwyf
  • » Profile

Posts

Posts

Jan-17-13 16:23:08
In OM1.9.0 Beta 2 a when initial()-section is evaluated twice

I have this model:

Code:

model myModel

equation
  when initial() then
    Modelica.Utilities.Streams.print("hello");
  end when;
end myModel;

If I simulate this with OpenModelica 1.9.0 Beta2 in OMShell I get this:

OMShell 1.1 Copyright Open Source Modelica Consortium (OSMC) 2002-2012
Distributed under OMSC-PL and GPL, see www.openmodelica.org

Connected to OpenModelica 1.9.0 Beta2 (r13495)
To get help on using OMShell and OpenModelica, type "help()" and press enter.

>> clear(); loadModel(Modelica,{"3.2.1"}); cd("C:/test"); loadFile("myModel.mo"); simulate(myModel)
true
true
"C:/test"
true
record SimulationResult
    resultFile = "C:/test/myModel_res.mat",
    simulationOptions = "startTime = 0.0, stopTime = 1.0, numberOfIntervals = 500, tolerance = 1e-06, method = 'dassl', fileNamePrefix = 'myModel', storeInTemp = false, noClean = false, options = '', outputFormat = 'mat', variableFilter = '.*', measureTime = false, cflags = '', simflags = ''",
    messages = "hellohello",
    timeFrontend = 0.48506047147699,
    timeBackend = 0.00381008109982807,
    timeSimCode = 0.0024721147429428,
    timeTemplates = 0.0157765793427199,
    timeCompile = 1.36685796517343,
    timeSimulation = 0.0236075452097846,
    timeTotal = 1.89762297291522
end SimulationResult;


As you can see the string "hello" was printed twice.

And this is my problem. I used the when initial() section for initialization of 3D tables very similar to the combiTable models in the MSL. And this causes an error because I need to initialize each table once and only once.

I tested the same code in Dymola 2013 FD01 and a similar code in OpenModelica 1.8.1. Both do the when initial() section only once.

Is something wrong in OpenModelica 1.9.0 Beta2 ?

Jan-15-13 11:01:11
Get compile errors when external C code contains ModelicaMessages

I tested both, with an environment variable and with the cflags=... command. Both work. Yeah!
Thank you very much.

Jan-15-13 10:07:49
Get compile errors when external C code contains ModelicaMessages

I use OpenModelica 1.8.1. OMShell says: "Warning: Requested package Modelica of version 3.2, but this package was already loaded with version 3.1. You might experience problems if these versions are incompatible."
I understand this as confirmation that I use Modelica 3.1, which was always fine for me (until now).
The 'LibraryDirectory' keyword is new in Modelica 3.2 and it seems as if my OpenModelica 1.8.1 installation ignores the 'LibraryDirectory' command. I tried an absolute path 'LibraryDirectory="C:/dir1/dir2"' as well as a 'modelica://' path. Both did not work. Is it possible?

Then I switched from 'loadModel(Modelica)' to 'loadModel(Modelica,{"3.2"})' . The message disappears. But OpenModelica still just looks in the default path. Do I have to install Modelica 1.9.0?

Jan-14-13 10:42:12
Get compile errors when external C code contains ModelicaMessages

Ok. If I really need two files, it is no major problem. Although I have Dymola and OpenModelica under Windows....

But it only works, if I copy the mylib.lib and the libmylib.a file to the directories the tools like. OpenModelica seems to like the libmylib.a file in lib/omc directory, while Dymola likes another directory for the mylib.lib file. I don't think it is a good idea to copy my file libmylib.a into the OpenModelica program directory in lib/omc. So I'm confused now about the paths the files to place. Is there a solution for this?

Jan-14-13 09:46:03
Get compile errors when external C code contains ModelicaMessages

YES, it works!
I have this file lib/omc/libModelicaExternalC.a and it works if I put "ModelicaExternalC" at the end of the Library list.
I always thought that OpenModelica uses the given library filename as it is. But OpenModelica also searches for lib<name>.a files, right?

I also want my model to run with Dymola. ModelicaExternalC works in Dymola too, because there is the file bin/lib/ModelicaExternalC.lib. Dymola seems to append always ".lib" automatically. Because of this I copied my own (gcc compiled) mylib.o file and renamed the copy into mylib.o.lib.
Isn't there a Modelica code working for Dymola AND OpenModelica without having the lib file twice (.o and .o.lib)?

Jan-11-13 18:07:33
Get compile errors when external C code contains ModelicaMessages

I have the same problem as pmeijer had in May.

I specified Library={"ModelicaExternalC", "mylib.o"} in my function in addition to my own mylib.o, but with no effect.
I still get the message "undefined reference to `ModelicaError'". In my OpenModelica directory a 'ModelicaExternalC' file does not exist, so which library should be included here?

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