User`s guide
13 Incorporating Fortran Code into the xPC Ta rget™ Environment
P[k] = mxGetScalar(P0(S)) * (double) fdelta;
rho[k] = mxGetScalar(R0(S)) * (double) fsigma;
}
}
12 Use the mdlTerminate callback to perform any actions required at
termination of the simulation. Even if you do not have any operations here,
you must include a stub for this callback.
static void mdlTerminate(SimStruct *S)
{
}
13 In the file, read the commented documentation for the following callbacks:
•
mdlInitalizeConditions — Initializes the state vectors of this
S-function.
•
mdlStart — Initializes the state vectors of this S-function. This function
is called once at the start of the model e xecution.
•
mdlUpdate — Updates the states of a block.
These are optional callbacks that you can define for later projects. You do
not need to specify these callbacks for this example.
14 Delete or comment out the code for these callbacks.
15 Save the file under another name. For example, save this file as
sfun_atmos.c. Do not overwrite the template file.
16 Copy the file sfun_atmos.c into y our Fortran working folder, for e xample,
xpc_fortran_test.
Your next task is to compile and link the wrapper S-function. See “Compiling
and Linking the Wrapper S-Function” on page 13-12.
Compiling and Linking the Wrapper S-Function
This topic describes how to create (compile and link) a C-MEX S-function from
the
sfun_atmos.c file. Before you start, ensure that the f ollowing files are in
the working folder,
xpc_fortran_test. You should have copied these files
when you performed the steps in “Compiling Fortran Files” on page 13-7.
13-12