Removed clear all for Matlab>=R2015b.

By default, Dynare clears the globals and functions containing
persistent variables. The behaviour of Dynare is not changed with
Matlab<R2015b or Octave.
time-shift
Stéphane Adjemian (Charybdis) 2015-09-30 22:52:48 +02:00
parent 03b92c6387
commit e52ce43569
2 changed files with 13 additions and 3 deletions

View File

@ -733,8 +733,13 @@ cannot be named @file{test.mod}.
@item noclearall
By default, @code{dynare} will issue a @code{clear all} command to
MATLAB or Octave, thereby deleting all workspace variables; this option
instructs @code{dynare} not to clear the workspace
MATLAB (<R2015b) or Octave, thereby deleting all workspace variables and
functions; this option instructs @code{dynare} not to clear the
workspace. Note that starting with Matlab 2015b @code{dynare} only
deletes the global variables and the functions using persistent
variables, in order to benefit from the JIT (Just In Time)
compilation. In this case the option instructs @code{dynare} not to
clear the globals and functions.
@item onlyclearglobals
By default, @code{dynare} will issue a @code{clear all} command to

View File

@ -575,7 +575,12 @@ ModFile::writeOutputFiles(const string &basename, bool clear_all, bool clear_glo
mOutputFile << "warning off" << endl; // This will be executed *after* function warning_config()
if (clear_all)
mOutputFile << "clear all" << endl;
mOutputFile << "if isoctave || matlab_ver_less_than('8.6')" << endl
<< " clear all" << endl
<< "else" << endl
<< " clearvars -global" << endl
<< " clear_persistent_variables(fileparts(which('dynare')))" << endl
<< "end" << endl;
else if (clear_global)
mOutputFile << "clear M_ options_ oo_ estim_params_ bayestopt_ dataset_;" << endl;