- Index
- » Usage and Applications
- » OpenModelica Usage and Applications
- » How to set OM working directory for...
How to set OM working directory for commandline use
How to set OM working directory for commandline use
I tried to run a simple *.mo file from commandline using omc but the simulation outputs are thrown to the temp folder than my working directory where the myTest.mo file is located. Can anyone advise me how to set that.
Re: How to set OM working directory for commandline use
Hi,
This should not happen. By default omc stores everything in the current directory where it is ran.
You can do a mos script:
Code:
// -start script
cd(); // display the current directory
loadFile("YourModel.mo"); getErrorString();
simulate(YourModel, stopTime=2); getErrorString();
// -- end script
cmdline> /path/to/omc script.mos
The generated YourModel_res.mat file should be in the current directory where you ran omc.
You might have just ran .mo files (which do nothing, just displays the flatten code) or generates code with +s.
And then you searched the temp directory and found .mat files made via OMEdit.
Cheers,
Adrian Pop/
- adrpo
- 885 Posts
Re: How to set OM working directory for commandline use
odrpo, thanks. This time outputs are sent to the omc bin\ folder instead of the working directory at e:\OM\Tests\. . My be something is wrong with the file path declarations in the script
Here is what I have:
mo path : E:\OM\Tests\cmlTest.mo
mos path: E:\OM\Tests\cmlScript.mo
cmlScript.mos file content:
// -start script
cd(); // display the current directory
loadFile("e:\OM\Tests\cmlTest.mo"); getErrorString();
simulate(cmlTest, stopTime=2); getErrorString();
// -- end script
When I run commandline, everything is thrown to bin\ of omc.
What I have done is this:
path/to/omc e:\OM\Tests\cmlScript.mos . On windows console, I have to provide the full path of the mos file to generate the output. otherwise, it couldn't find the file
Re: How to set OM working directory for commandline use
So it doesn't work if you cd e:/OM/Tests/ and then run path/to/omc cmlScript.mos?
- sjoelund.se
- 1700 Posts
Re: How to set OM working directory for commandline use
I did the following in the cmlScript.mos but it failed to process
// -start script
cd(e:/OM/Tests/);
loadFile("cmlTest.mo"); getErrorString();
simulate(cmlTest, stopTime=2); getErrorString();
// -- end script
It appears working if I put the mos in a batchfile
AMong the files generated, I see one file 'Output' which is empty. Why is that?
Re: How to set OM working directory for commandline use
Hi,
You need to do this:
1. have both cmlScript.mos and cmlTest.mo in E:\OM\Tests\
2. run from command line:
> e:
> cd E:\OM\Tests
E:\OM\Tests> C:\OpenModelica1.9.0\bin\omc.exe cmlScript.mos
This will generate all the files in E:\OM\Tests
Note, you will need to change cd(e:/OM/Tests/); in cmlScript.mos to cd(). Empty cd() just displays the current directory, does not change it.
The cd("path") command takes a string, so if you want to change directory via cd in your script you would need to do it like cd("e:/OM/Tests/");
output.log is the result of the running of the generated cmlTest.exe for simulation. If is empty then is OK, there were no errors during simulation.
Cheers,
Adrian Pop/
- adrpo
- 885 Posts
Re: How to set OM working directory for commandline use
adrpo, excuse me for initiating this thread. The above mos and command line instructions work for a simple text based model. How about if the mo file is a package containing several models and if we want to run a specific experiment?
Re: How to set OM working directory for commandline use
Hi,
In you script:
loadFile("path/to/Library/package.mo"); getErrorString();
simulate(Library.Path.To.Your.Model); getErrorString();
Should do it.
Cheers,
Adrian Pop/
- adrpo
- 885 Posts
- Index
- » Usage and Applications
- » OpenModelica Usage and Applications
- » How to set OM working directory for...