Overview

An IMLPlus program can call external user-defined functions written using the Fortran programming language. Because external user-defined functions are always executed on the client Windows PC, a Fortran function must be compiled and linked for use with the Microsoft Windows operating system before it can be called by IMLPlus. Specifically, the Fortran function must be packaged within, and exported from, a Dynamic-Link Library (DLL). To call the Fortran function, an IMLPlus program uses the DllFunction class.

There are three steps to calling a Fortran function from an IMLPlus program:

  1. Package the Fortran function within, and export it from, a DLL.
  2. Write a wrapper module to encapsulate the IMLPlus programming statements necessary to use the DllFunction class to call the Fortran function.
  3. Call the wrapper module from the main program.

To demonstrate each of these steps, the following topics present an example of packaging a Fortran function within a DLL and then calling it from an IMLPlus program:

Packaging a Fortran Function within a DLL

Writing a Wrapper Module to Call the Fortran Function

Calling the Wrapper Module from the Main Program

The example function multiplies a vector by a scalar and returns the product vector. Mathematically, it computes y = c x where x is a vector and c is a scalar.