Main Content

S-Functions in Normal Mode Referenced Models

Note

For additional information, see Model Reference Requirements and Limitations.

When a C S-function appears in a referenced model that executes in Normal mode, successful execution is impossible if all of the following are true:

  • The S-function has both an mdlProcessParameters function and an mdlStart function.

  • The mdlProcessParameters function depends on the mdlStart function.

  • The referenced model calls mdlProcessParameters before calling mdlStart.

Execution fails because mdlProcessParameters has dependency requirements that mdlStart has not satisfied. Automated analysis cannot guard against all possible causes of such failure: you must check your code manually and verify that mdlProcessParameters is not in any way dependent on mdlStart being called first. Examples of such dependency include:

  • Allocating memory in mdlStart and using that memory in mdlProcessParameters. This is often done using ssSetUserData and ssGetUserData.

  • Initializing any DWork or any global memory in mdlStart and reading the values in mdlProcessParameters.

To remind you to check for any such dependency problems, an error message appears by default for any S-function that is used in a Normal mode referenced model and contains both an mdlProcessParameters function and an mdlStart function. The error message does not mean that any dependency problems exist, but only that they might exist.

If you get such an error message, check for any problematic dependencies in the S-function, and recode as needed to eliminate them. When no such dependencies exist, you can safely suppress the error message and use the S-function in a Normal mode referenced model. To certify that the S-function is compliant, and the message is therefore unnecessary, include the following statement in mdlInitializeSizes:

ssSetModelReferenceNormalModeSupport (S, MDL_START_AND_MDL_PROCESS_PARAMS_OK);

For information about referenced models, see Model Reference Basics.

Supporting the Use of Multiple Instances of Referenced Models That Are in Normal Mode

You may need to modify S-functions that are used by a model so that the S-functions work with multiple instances of referenced models in Normal mode. The S-functions must indicate explicitly that they support multiple exec instances.

  • For C S-functions, use ssSupportsMultipleExecInstances(s, true).

  • For MATLAB® file S-functions, use blockSupportMultipleExecInstances = true.

The limitations for using S-functions with multiple instances of referenced models in Normal mode are the same as the limitations that apply to using S-functions with For Each Subsystem block.

See Also

| | |

Related Topics