User`s guide
Before You Start
A list of Simulink examples appears.
3 Click Custom Code and H and Coded Blocks using the S-function
API.
The associated Simulink demos page opens.
4 Click Open this model.
S-function examples are displayed.
5 Double-click the Fortran S-functions block.
Fortran S-functions and associated templates appear.
Prerequisites
You must have xPC Target Version 1.3 or later to use Fortran for xPC Target
applications. The xPC Target product supports the Fortran compiler(s) listed
here:
http://www.mathworks.com/support/compilers/current_rele ase/
Steps to I ncorporate Fortran in the Simulink Software
for xPC Target
This topic lists the general steps to incorporate Fortran code into an xP C
Target application. Detailed command s follow in th e accompan y in g exampl es.
1 Using the Fortran compiler, compile the Fortran code (subroutines ( *.f)).
You will n eed to specify particular compiler options.
2 W rite a Simuli nk C-MEX wrap per S-function. This wrapper S-function
calls one or more of the Fortran subroutines in the compiled Fortran object
code from step 1.
3 Use the mex function to compile this C-MEX S-function using a Visual
C/C++ compiler. Define several Fortran run-time libraries to be linked in.
This step creates the Simulink S-function MEX-file.
13-3