User`s guide

Step-by-Step Example of Fortran and xPC Targetâ„¢
ssSetOutputPortWidth(S, 1, 3); /* pressure */
ssSetOutputPortWidth(S, 2, 3); /* density */
#if de fined(MATLAB_MEX_FILE)
EXIT_POINT:
#endif
return;
}
10 Use the mdlInitializeSamp leTimes callback to specif y th e sample rates
at which this S-function operates.
static void mdlInitializeSampleTimes(SimStruct *S)
{
ssSetSampleTime(S, 0, INHERITED_SAMPLE_TIME);
ssSetOffsetTime(S, 0, 0.0);
ssSetModelReferenceSampleTimeDefaultInheritance(S);
}
11 Use the mdlOutp uts callback to compute the signals that this block emits.
static void mdlOutputs(SimStruct *S, int_T tid)
{
double *alt = (double *) ssGetInputPortSignal(S,0);
double *T = (double *) ssGetOutputPortRealSignal(S,0);
double *P = (double *) ssGetOutputPortRealSignal(S,1);
double *rho = (double *) ssGetOutputPortRealSignal(S,2);
int w = ssGetInputPortWidth( S,0);
int k;
float falt, fsigma, fdelta, ftheta;
for (k=0; k<w; k++) {
/* set the input value */
falt = (float) alt[k];
/* call the Fortran routine using pass-by-reference */
atmos_(&falt, &fsigma, &fdelta, &ftheta);
/* format the outputs using the reference parameters */
T[k] = mxGetScalar(T0(S)) * (double) ftheta;
13-11