Target Language Compiler    

Inlining Fortran (F-MEX) S-Functions

The capabilities of Fortran MEX S-functions can be fully inlined using a TLC block target file. With a simple F MEX S-function version of the ubiquitous "timestwo" function, this interface can be illustrated. Here is the sample Fortran S-function code:

Copy the above code into file ftimestwo.for in a convenient working directory.

Putting this into an S-function block in a simple model will illustrate the interface for inlining the S-function. Once your Fortran MEX environment is set up, prepare the code for use by compiling the S-function in a working directory along with the file simulink.for from matlabroot/simulink/src/. This is done with the mex command at the MATLAB command prompt:

And now reference this block from a simple Simulink model set with a fixed step solver and the grt target.

The TLC code needed to inline this block is a modified form of the now familiar timestwo.tlc. In your working directory, create a file named ftimestwo.tlc and put this code into it.

Now you can generate code for the ftimestwo Fortran MEX S-function. The resulting code fragment specific to ftimestwo is


  Inlining M-File S-Functions TLC Coding Conventions