Compiling and linking in dynamic mode

The createUserDll.com (Unix) or createUserDll.cmd (Windows) script, located in the exe folder of the main tmg directory, compiles the user written subroutines. It generates a Dynamic-Link Library named tmgopen.dll on Windows, tmgopen.sl on HP and tmgopen.so on other Unix/Linux platforms that are automatically loaded and used by the thermal solver.

The main advantage of using dynamic mode is flexibility in the choice of compiler, although it does add some minor limitations on the flexibility of the user code. Also, there are available free compilers and development environment.

To use this method you have to:

  • Define DOUBLE PRECISION T, TIME, DT in your user written subroutine.
  • Place the following Card 9 - PARAM Parameter Card - Optional in the input file PARAM USERDLL or activate the ACTIVATE USER DLL SCHEME advanced parameter in the solution.
Note:

Only thermal solver subroutines documented in the Thermal Solver Reference Manual can be called.

The following example shows dynamic mode with Intel Visual Fortran.

  1. The following software must be installed:
    • Microsoft Visual Studio / Standard Edition or Express Edition
    • Intel Visual Fortran 9 or 10
  2. Setup the installation path for the above software in the first section of the createUserDll.cmd file that is located in the exe directory under your tmg installation directory.
  3. To instruct thermal solver to use the Intel Visual Fortran Compiler, do one of the following:
    1. Add the ACTIVATE USER DLL SCHEME advanced parameter.
    2. Include in the input file Card 9 - PARAM Parameter Card - Optional parameter USERDLL.

      User subroutine is added as usual in the UI as an include file, and is compiled at run time and linked against a dll-wrapper library; tmgopen.dll is created in the running directory and loaded automatically by the Analyzer module.

  4. Use double precision for the temperature array, time and time step: DOUBLEPRECISION T, TIME, DT.

To run .dll file on the machine with no compiler

You can manually create tmgopen.dll by placing all the source code in a file called USER1.f. From a command shell, make the directory containing USER1.f the current directory, then run a local command script createUserDll.cmd or the one found in the tmg\exe directory of the tmg installation.

To run on the machine with no compiler, you should have a dll named tmgopen_user.dll that you place in your run directory. The application will skip compiling and linking the user written subroutine and use tmgopen_user.dll instead. The input file must still contain the PARAM USERDLL entry and a user written routine in Card 10 - User-Written Subroutines USER1 and USERF - Optional of the tmg input file. It is the presence of this code that triggers the use of the external DLL. This can be any valid code, including a minimal USER1 routine that does nothing.