Writing S-Functions    

Chapter 6
Creating Fortran S-Functions


The following sections explain how to use the Fortran programming language to create S-functions.

Introduction
Overview of approaches to writing Fortran S-functions.
Creating Level 1 Fortran S-Functions
Describes a purely Fortran approach to creating an S-function.
Creating Level 2 Fortran S-Functions
Describes a hybrid C/Fortran approach to writing an S-function that enables creation of more capable blocks.
Porting Legacy Code
How to wrap an S-function around existing Fortran code.

Introduction

There are two main strategies to executing Fortran code from Simulink. One is from a level 1 Fortran-MEX (F-MEX) S-function, the other is from a level 2 gateway S-function written in C. Each has its advantages and both can be incorporated into code generated by the Real-Time Workshop.


  Building C++ S-Functions Level 1 Versus Level 2 S-Functions