Generate Extern

Generate C++

The Generate C++ option on the toolbar starts the process of generating all files needed to run a simulation independent of the MLDesigner GUI. The simulation will, however, not run externally unless MLDesigner is installed on the machine where you execute the system; a result of the dynamic linking mechanism.

All files are written to "TargetDirectory"/"LibraryName"/"SystemName", where "TargetDirectory" means the content of the equally named property of the Simulation Properties, which is set to $MLD_USER/SYSTEMS per default. Here is a list of the files which are generated from MLD.

Note that "SystemName" stands for the according system name, for example, "butterfly".

Generated files




Script for compiling with a lockfile mechanism, to avoid parallel compilation of the same architecture.


Script used my MLDesigner to start distributed external simulations, do not use it.


parameter file


Source code to construct and execute the system.


Initialization functions for external tools (e.g., PTcl/PTk, Tcl/Tk)




Object files of the user primitives.

Before the system can be executed, it must be compiled. In the directory where the files are stored type make, or better, start the script ending with "-build". If compilation is successful, the directory contains serveral more files listed below.

Note that $MLDARCH means the output of "mldarch" on your site.

Additional files after compilation




Script for starting the simulation.


Simulation binary file.


Object file generated from SystemName.cpp


Object file generated from ExternAppInit.cpp

As you can see, now there is a file called "SystemName". To give the simulation a try, you can start it by typing "./SystemName". If your system uses X, Tk, Qt or similar primitives, you have to start the simulation with "./SystemName -x", which is the common case. If you are unsure about this, use -x in every case. The file with the extension .param is parsed when the simulation is executed. This file can be edited manually and the simulation can be rerun independent of the MLDesigner GUI. The simulation parameters for each simulation run are stored in a file with the extension .param.* where * indicates a unique simulation number.

Generate PTcl

The Generate PTcl option on the toolbar opens a dialog where you can create a location to save the .ptcl file in. It is possible to create a new directory and/or change the default name of the ptcl file.

The two files *.params and *.ptcl are generated in the specified location. The *.params file contains the default settings for all visible parameters (parameters that are visible in the Simulation Properties window). After every simulation a *.params.* file is created containing the settings for the simulation. The filename is extended by a unique number indicating the simulation number. This feature means it is possible to execute a number of simulations with different settings while keeping a record of the parameter settings for each simulation. It makes sense to save the results of each simulation with the name extended by the simulation number.

Simulate PTcl

Parameter Values

The .params file can contain a list of numbers separated by semicolons or can be a list of numbers defined using the following syntax:

for -1.0 to 1.0 step 0.1

which would be equivalent to a list of numbers separated by semicolons such as

-1.0; -0.90; -0.80; 1.0.

These values represent the initial particle value per iteration of the relevant Parameter Set. A typical file of a simulation with three parameter sets looks like this:

        GlobalSeed : 1234567890
        Parameter1 : for -.10 to 1.0 step 0.1
        RunLength  : 1000

        GlobalSeed : 1234567890
        Parameter1 : for 2 to 10 step 2
        RunLength  : 1000

        GlobalSeed : 1234567890
        Parameter1 : 3; 30; 300
        RunLength  : 1000

It is not possible to create new parameters by editing the file: it is only possible to edit the values of parameters in the .params file.

Execution on other platforms

It is possible to execute systems designed under one operating system such as Linux on another operating system such as Windows®, but only if the system DOES NOT contain user-defined primitives.

User-defined primitives that are compiled for external simulation on one system will not be compatible with another operating system. If the system contains user defined primitives they are exported to the $MLD/SYSTEMS directory as object files (.o). The primitive itself is not exported. The simulation can only run if the user-defined primitive has been compiled on the machine where you want to execute the system.

To do this, export the system using the Export Library feature available via the context menu in the Tree View window. For more information on exporting libraries see Export Libraries.

Environment Variables

External files are sensitive to MLDesigner environmental variable settings. Changes to the default settings, if made incorrectly, could lead to unsuccessful compilation of external systems.

The environment variables SIM_SYSTEM and SIM_EXTERN are set to the URL of the simulated system and the directory where the code of the external simulation is generated (specified by the Target Parameter property in the Simulation Properties window).