/adevs

This repository tracks the adevs repository at SourceForge

Primary LanguageC++OtherNOASSERTION

This file contains instructions for building the C++ library, the C++
library with support for OpenModelica, and the Java bindings. Development
versions of this library are available from SourceForge and github.

---- C++ -----
Adevs is implemented primarily as a set of C++ header files,
and for many applications these are sufficient. The rest of
the simulation engine is in the static library file 'libadevs.a'.
To build this library file this, go to the directory called 'src'
and run 'make'. The default options for the compiler should
work if you are using the GNU g++ compiler. For other compilers,
you make set options, build commands, etc. by editing the Makefile.

If you are using Visual Studio and Windows, then to build the
static library do the following: 1) open a command shell, 2) go the
'src' directory, and 3) run the batch file 'build.bat'. This 
creates a static library to link with your simulation applications.
Note that the Windows build script does not include any OpenMP options
and so those must be added to the compiler switches if you want to
use the OpenMP enabled parts of the simulation engine. Note that
the Express versions of Visual Studio don't support OpenMP in any case.

---- C++ with OpenModelica support ----
Adevs may be used as a back-end for the OpenModelica simulation tool
(see www.openmodelica.org). If you want support for OpenModelica,
you need to get and build the OpenModelica compiler. For this purpose
there is a shell script called 'build-omc.sh' in the 'util' directory
of adevs. Executing this script will do the following: 

1) Create a directory called openmodelica. This directory will contain
   everything that the script downloads and compiles.
2) Retrieve and compile rml, smlnj, and mmc.
3) Retrieve and compile a bare-bones version of the OpenModelica compiler.

The OpenModelica compiler is called omc and it is located in
the openmodelica/trunk/build/bin directory. After building omc
you must do the following:

A) Get and install KINSOL from
          http://computation.llnl.gov/casc/sundials/download/download.html
B) Put the omc compiler into your executable PATH. The compiler is
   in the directory openmodelica/trunk/build/bin
C) Edit the Makefile for adevs so that MODELICA_HOME points at your
   OpenModelica source tree (i.e., at openmodelica/trunk) and SUNDIALS_HOME
   points to the directory where you installed KINSOL.
D) Go to the 'src' directory of adevs and run the command
   'make adevs_with_modelica'.

You can test your new Modelica compiler and run-time environment
with the modelica examples in the examples/modelica directory of
adevs.

To run a Modelica model, you will need to link your code with the KINSOL
library, the f2c library (which is available with most linux distros),
and the OpenModelica libgc library (this is located in the directory
openmodelica/trunk/build/lib/omc). It is usually best to link statically
to the f2c library. 

---- Java -----
To build the java bindings for Linux, go the the 'src' directory and  
edit the Makefile so that JAVA_HOME points to your jdk installation.
Then run 'make java_adevs'. This builds the shared library libjava_adevs.so
and the jar-file adevs.jar. To use these put the shared library into 
your LD_LIBRARY_PATH and the jar file into your CLASSPATH.

To build the java bindings For Windows, first make sure that 1) your
JAVA_HOME environment variable points to your jdk installation and
2) that the java compiler is in your executable PATH. Then execute
the batch file src/adevs_jni/build.bat. This creates the jar-file
adevs.jar and DLL-file java_adevs.dll. You can use these by putting
the former into your CLASSPATH and latter into your PATH.

---- Testing -----
There are four sets of test cases that can be run from the
directory 'test'. The first set are for the C++ library without
OpenMP support. These tests are run with 'make check_cpp'.
The parts of the C++ library that use OpenMP can be tested by
executing 'make check_par'.  The java bindings can be tested by
executing 'make check_java'. The test cases for adevs's OpenModelica
support can be run with 'make check_modelica'. Executing 'make check'
runs all of the test cases.

The make.common file contains platform specific settings for
the test scripts. It is setup by default for a GNU/Linux type of
environment. Change as needed for your environment, but if you are
using a more or less typical Linux distribution then the defaults
should work fine.

When testing the Java bindings, be sure your PATH, LD_LIBRARY_PATH,
and CLASSPATH are setup properly before running the Java test
cases. These need to include your DLL (for Windows) and Java binaries,
shared object file (for Linux), and jar file and the '.' directory
respectively.

For OpenMP test cases, you will need to set the maximum number of threads
to at least four (one of the test cases requires at least four threads).

When testing the OpenModelica support, make sure that the omc compiler
is in your executable PATH (see the OpenModelica instructions above).