User`s guide

Introduction
11-3
5 Double-click the Fortran S-functions block.
A library of Fortran S-functions and associated templates appears. This
library also contains a README block. This file contains the same
information as that contained in “Creating Fortran S-Functions” in the
writing S-Functions documentation. In that chapter, the sections “Creating
Level 2 Fortran S-Functions” and “Porting Legacy Code” are most applicable
to xPC Target.
Prerequisites
You must have the following to use Fortran for xPC Target applications:
xPC Target Version 1.3 or later
Compaq Visual Fortran Compiler Version 6.5 or later
Steps to Incorporate Fortran in Simulink for xPC
Target
This section lists the general steps to incorporate Fortran code into an xPC
Target application. Detailed commands follow in the accompanying examples:
1 Using the Fortran compiler, compile the Fortran code (subroutines (*.f)).
You will need to specify particular compiler options.
2 Write a C-MEX wrapper S-function for Simulink. 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 DLL.
4 Run a simulation C-MEX file with Simulink to validate the compiled
Fortran code and wrapper S-function.
5 Copy relevant Fortran run-time libraries to the application build directory
for the xPC Target application build.