model_terminate

Termination entry point in generated code for Simulink model

Syntax

void model_terminate(void)

Calling Interfaces

The calling interface generated for this function also differs depending on the setting of model configuration parameter Code interface packaging (Simulink Coder):

  • C++ class (default for C++ language) — Generated function is encapsulated into a C++ class method. Required model data is encapsulated into C++ class attributes.

  • Nonreusable function (default for C language) — Generated function passes (void). Model data structures are statically allocated, global, and accessed directly in the model code.

  • Reusable function — Generated function passes the real-time model data structure, by reference, as an input argument. The real-time model data structure is exported with the model.h header file.

    For an ERT-based model, you can use model configuration parameter Pass root-level I/O as to control how root-level input and output arguments are passed to the function. They can be included in the real-time model data structure, passed as individual arguments, or passed as references to an input structure and an output structure.

Description

The generated model_terminate function contains the termination code for a Simulink® model and should be called as part of system shutdown.

When model_terminate is called, blocks that have a terminate function execute their terminate code. If logging is enabled, model_terminate ends data logging.

Calle the model_terminate function once.

For an ERT-based model, the code generator produces the model_terminate function for a model when model configuration parameter Terminate function required is selected (the default). If your application runs indefinitely, you do not need the model_terminate function. To suppress the function, clear model configuration parameter Terminate function required.

Introduced before R2006a