User`s guide

13 Incorporating Fortran Code into the xPC Ta rget™ Environment
svml_dis p.lib
3 From a DOS prompt, change folder to the working folder and create the
object file. For example:
ifort /fpp /Qprec /c /nologo /MT /fixed /iface:cref -Ox sfun_atmos_sub.F
Your next task is to create a wrapper S-function. See “Creating a C-MEX
Wrapper S-Function ” on page 13-8 .
Creating a C-MEX Wrapper S-Function
This topic describes how to create a C-MEX w rapper S-function for the
Fortran code in
sfun_atmos_sub.f. This function is a level 2 S-function. It
incorporates existing Fortran code into a Simulink S-function block and lets
you execute Fortran code from the Simulink software. Before you start,
Ensure that you have compiled your Fortran code. See “Compiling Fortran
Files” on page 13-7.
Be familiar with writing Simulink S-functions. In particular, read
“Creating Fortran S-Functions” in the Developing S-Functions guide.
Note the “Creating Level-2 Fortran S-Functions” section. This section
lists guidelines for creating Fortran level 2 S-functi ons, includ in g calling
conventions.
Refer to “S-Function Callback M ethods Alphabetical List” in the
Developing S-Functions guide. The Simulink software invokes these
methods when simulating a model with S-functions.
Refer to the “S-Function SimStruct Functions Alphabetical List” in the
Developing S-Functions guide fo r detailed descriptions of the functio ns that
access the fields of an S-function’s simulation data structure (
SimStruct).
S-function callback methods use these functions to store and retrieve
information abou t an S- fu n ction.
The following procedure outlines the steps to create a C-MEX wrapper
S-function to work with
sfun_atmos_sub.f.Itusesthetemplatefile
sfuntmpl_gate_fortran.c.
13-8