Chapter 7
Code Optimization
©
National Instruments Corporation
7-7
the buffer
_R_P
and the initialization code are optimized away. Instead, the
buffer
R_P
(parameter array), states, derivatives, and
info
structures are
initialized directly in the declaration portion. After these structures are
modified by computations, the initial values are lost, and the application
cannot be restarted again.
Example 7-4
Sample Segment of Code with Restart Capability Optimized Away
void subsys_1(U, Y)
struct _Sys_ExtIn *U;
struct _Subsys_1_out *Y;
{
/***** States Array. *****/
static struct _Subsys_1_states ss_1_states[2] = {{0.0, 0.0}, {0.0, 0.0}};
/***** Current and Next States Pointers. *****/
static struct _Subsys_1_states *X = &ss_1_states[0];
static struct _Subsys_1_states *XD = &ss_1_states[1];
static struct _Subsys_1_states *XTMP;
static RT_INTEGER iinfo[4] = {0, 1, 1, 1};
static RT_INTEGER INIT = 1;
const RT_DURATION TSAMP = 0.1;
/***** Parameters. *****/
static RT_FLOAT R_P[8] = {-1.0, 1.0, 1.5, 2.0, -1.0, 1.0, 1.25, 1.4};
/***** Local Block Outputs. *****/
RT_FLOAT proc_2_1;
RT_FLOAT proc_14_1;
RT_FLOAT proc_12_1;
/***** Algorithmic Local Variables. *****/
RT_INTEGER ilower;
RT_INTEGER iupper;
RT_FLOAT uval;
RT_INTEGER k;
RT_FLOAT alpha;
..
..