User`s guide
11 xPC Target and Fortran
11-10
Invoking the mex command includes the following steps:
1 Compile the wrapper C file sfun_atmos.c. Be sure to link in the following:
- Compiled wrapper file:
sfun_atmos.obj
- Compiled Fortran code: sfun_atmos_sub.obj
- Necessary Fortran run-time libraries to resolve external function
references and the Fortran run-time environment
2 Type
mex -v LINKFLAGS#"$LINKFLAGS dformd.lib dfconsol.lib
dfport.lib" sfun_atmos.c sfun_atmos_sub.obj
Ensure that this whole command is all on one line. This command compiles
and links the
sfun_atmos_sub.c file. It creates the sfun_atmos.dll file in
the same directory.
Note If this command generates a conflict error with libc, you might need to
add the option
/NODEFAULTLIB:libc.lib to the command. For example, mex
-v /NODEFAULTLIB:libc.lib LINKFLAGS#"$LINKFLAGS dformd.lib
dfconsol.lib dfport.lib" sfun_atmos.c sfun_atmos_sub.obj.
Your next task is to validate the Fortran code and wrapper S-function. See
“Validating the Fortran Code and Wrapper S-Function” on page 11-10.
Validating the Fortran Code and Wrapper
S-Function
Validate the generated DLL, sfun_atmos.dll. Bind the S-function DLL to an
S-function block found in the Simulink block library. You can mask the
S-function block like any other S-function block to give it a specific dialog box.
This section assumes that you have compiled and linked a wrapper S-function.
See “Compiling and Linking the Wrapper S-Function” on page 11-9.
The Atmosphere model example has a Simulink model associated with it.