Add check that prevents datafile from having same name as mod-file

Otherwise, the generated m-file might be called as the datafile, leading to infinite loops. The check cannot be moved to makedataset because M_.fname is not available there.
time-shift
Johannes Pfeifer 2014-08-21 13:18:38 +02:00 committed by Stéphane Adjemian (Charybdis)
parent 27d54758be
commit 41d1533086
1 changed files with 7 additions and 0 deletions

View File

@ -458,6 +458,13 @@ k = find(isnan(bayestopt_.jscale));
bayestopt_.jscale(k) = options_.mh_jscale;
% Build the dataset
if ~isempty(options_.datafile)
[pathstr,name,ext] = fileparts(options_.datafile);
if strcmp(name,M_.fname)
error('Data-file and mod-file are not allowed to have the same name. Please change the name of the data file.')
end
end
[dataset_, dataset_info, newdatainterfaceflag] = makedataset(options_, options_.dsge_var*options_.dsge_varlag, gsa_flag);
% Set options_.nobs if needed