One of the common applications of sensitivity analysis is in generating derivative information for dynamically-constrained optimization when using a reduced-space approach. Depending on the optimization method used, several solutions of the underlying ODE system may be required in between evaluations of the sensitivities (for example when using a line search). To turn off sensitivity calculations (without deallocating any sensitivity-related memory or resetting any of the optional inputs, so that sensitivties can later be reactivated) it is most efficient to use CVodeSensToggleOff.
The example code cvsfwdswitchx (a modification of the CVODES example cvsfwddenx), listed below, demonstrates this.
Recall that sensitivity calculations are enabled by CVodeSensMalloc and CVodeSensReInit and are disabled by CVodeSensFree (after calling this one, they can be re-enabled *only* by calling CVodeSensMalloc) and CVodeSensToggleOff.