Commit 7408714e authored by MichelJuillard's avatar MichelJuillard
Browse files

added dname as argument to CheckPath function and changed all calls to

this function. Suppressed use of globals in CheckPath.
parent d0e458eb
function DirectoryName = CheckPath(type)
function DirectoryName = CheckPath(type,dname)
% Creates the subfolder "./M_.dname/type" if it does not exist yet.
%
% INPUTS
% type [string] Name of the subfolder.
% type [string] Name of the subfolder.
% dname [string] Name of the directory
%
% OUTPUTS
% none.
......@@ -27,14 +28,12 @@ function DirectoryName = CheckPath(type)
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
global M_
DirectoryName = [ dname '/' type ];
DirectoryName = [ M_.dname '/' type ];
if ~isdir(M_.dname)
if ~isdir(dname)
% Make sure there isn't a file with the same name, see trac ticket #47
delete(M_.dname)
mkdir('.', M_.dname);
delete(dname)
mkdir('.', dname);
end
if ~isdir(DirectoryName)
......
......@@ -33,7 +33,7 @@ function CutSample(M_, options_, estim_params_)
npar = estim_params_.np+estim_params_.nvn+estim_params_.ncx+estim_params_.ncn+estim_params_.nvx;
DirectoryName = CheckPath('metropolis');
DirectoryName = CheckPath('metropolis',M_.dname);
file = dir([ DirectoryName ,filesep, M_.fname '_mh_history.mat']);
files = dir([ DirectoryName ,filesep, M_.fname '_mh*.mat' ]);
if ~length(files)
......
......@@ -39,7 +39,7 @@ nblck = options_.mh_nblck;
iline = FirstLine;
linee = 1;
DirectoryName = CheckPath('metropolis');
DirectoryName = CheckPath('metropolis',M_.dname);
if nblck>1 && nargin<6
Draws = zeros(NumberOfDraws*nblck,1);
......
......@@ -45,8 +45,8 @@ ncn = estim_params_.ncn;
np = estim_params_.np ;
nx = nvx+nvn+ncx+ncn+np;
DirectoryName = CheckPath('metropolis');
OutputDirectoryName = CheckPath('Output');
DirectoryName = CheckPath('metropolis',M_.dname);
OutputDirectoryName = CheckPath('Output',M_.dname);
load([ DirectoryName '/' M_.fname '_mh_history'])
FirstMhFile = record.KeepedDraws.FirstMhFile;
......
......@@ -33,8 +33,8 @@ function McMCDiagnostics(options_, estim_params_, M_)
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
DirectoryName = CheckPath('Output');
MhDirectoryName = CheckPath('metropolis');
DirectoryName = CheckPath('Output',M_.dname);
MhDirectoryName = CheckPath('metropolis',M_.dname);
TeX = options_.TeX;
nblck = options_.mh_nblck;
......
......@@ -56,7 +56,7 @@ if whoiam
Parallel=myinputs.Parallel;
end
if ~exist('MhDirectoryName'),
MhDirectoryName = CheckPath('metropolis');
MhDirectoryName = CheckPath('metropolis',M_.dname);
end
ALPHA = 0.2; % increase too much with the number of simulations.
......
......@@ -33,7 +33,7 @@ function oo_ = PlotPosteriorDistributions(estim_params_, M_, options_, bayestopt
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
OutputDirectoryName = CheckPath('Output');
OutputDirectoryName = CheckPath('Output',M_.dname);
TeX = options_.TeX;
nblck = options_.mh_nblck;
......
......@@ -55,8 +55,8 @@ i_last_obs = gend+(1-M_.maximum_endo_lag:0);
horizon = options_.forecast;
maxlag = M_.maximum_endo_lag;
%%
CheckPath('Plots/');
DirectoryName = CheckPath('metropolis');
CheckPath('Plots/',M_.dname);
DirectoryName = CheckPath('metropolis',M_.dname);
load([ DirectoryName '/' M_.fname '_mh_history.mat'])
FirstMhFile = record.KeepedDraws.FirstMhFile;
FirstLine = record.KeepedDraws.FirstLine;
......
......@@ -76,17 +76,17 @@ else
MAX_nirfs_dsgevar = 0;
end
DirectoryName = CheckPath('Output');
DirectoryName = CheckPath('Output',M_.dname);
if strcmpi(type,'posterior')
MhDirectoryName = CheckPath('metropolis');
MhDirectoryName = CheckPath('metropolis',M_.dname);
elseif strcmpi(type,'gsa')
if options_.opt_gsa.pprior
MhDirectoryName = CheckPath(['GSA' filesep 'prior']);
MhDirectoryName = CheckPath(['GSA' filesep 'prior'],M_.dname);
else
MhDirectoryName = CheckPath(['GSA' filesep 'mc']);
MhDirectoryName = CheckPath(['GSA' filesep 'mc'],M_.dname);
end
else
MhDirectoryName = CheckPath('prior');
MhDirectoryName = CheckPath('prior',M_.dname);
end
delete([MhDirectoryName filesep M_.fname '_IRF_DSGEs*.mat']);
delete([MhDirectoryName filesep M_.fname '_IRF_BVARDSGEs*.mat']);
......@@ -95,7 +95,7 @@ if strcmpi(type,'posterior')
TotalNumberOfMhDraws = sum(record.MhDraws(:,1));
NumberOfDraws = TotalNumberOfMhDraws-floor(options_.mh_drop*TotalNumberOfMhDraws);
elseif strcmpi(type,'gsa')
RootDirectoryName = CheckPath('gsa');
RootDirectoryName = CheckPath('gsa',M_.dname);
if options_.opt_gsa.pprior
load([ RootDirectoryName filesep M_.fname '_prior.mat'],'lpmat0','lpmat','istable')
else
......
......@@ -84,15 +84,15 @@ end
% MhDirectoryName = myinputs.MhDirectoryName;
if strcmpi(type,'posterior')
MhDirectoryName = CheckPath('metropolis');
MhDirectoryName = CheckPath('metropolis',M_.dname);
elseif strcmpi(type,'gsa')
if options_.opt_gsa.pprior
MhDirectoryName = CheckPath(['gsa' filesep 'prior']);
MhDirectoryName = CheckPath(['gsa' filesep 'prior'],M_.dname);
else
MhDirectoryName = CheckPath(['gsa' filesep 'mc']);
MhDirectoryName = CheckPath(['gsa' filesep 'mc'],M_.dname);
end
else
MhDirectoryName = CheckPath('prior');
MhDirectoryName = CheckPath('prior',M_.dname);
end
RemoteFlag = 0;
......
......@@ -69,7 +69,7 @@ end
% To save the figures where the function is computed!
DirectoryName = CheckPath('Output');
DirectoryName = CheckPath('Output',M_.dname);
RemoteFlag = 0;
if whoiam,
......
......@@ -45,22 +45,22 @@ function ReshapeMatFiles(type, type2)
global M_ options_
if nargin==1,
MhDirectoryName = [ CheckPath('metropolis') filesep ];
MhDirectoryName = [ CheckPath('metropolis',M_.dname) filesep ];
else
if strcmpi(type2,'posterior')
MhDirectoryName = [CheckPath('metropolis') filesep ];
MhDirectoryName = [CheckPath('metropolis',M_.dname) filesep ];
elseif strcmpi(type2,'gsa')
if options_.opt_gsa.morris==1,
MhDirectoryName = [CheckPath('gsa/screen') filesep ];
MhDirectoryName = [CheckPath('gsa/screen',M_.dname) filesep ];
elseif options_.opt_gsa.morris==2,
MhDirectoryName = [CheckPath('gsa/identif') filesep ];
MhDirectoryName = [CheckPath('gsa/identif',M_.dname) filesep ];
elseif options_.opt_gsa.pprior
MhDirectoryName = [CheckPath(['gsa' filesep 'prior']) filesep ];
MhDirectoryName = [CheckPath(['gsa' filesep 'prior'],M_.dname) filesep ];
else
MhDirectoryName = [CheckPath(['gsa' filesep 'mc']) filesep ];
MhDirectoryName = [CheckPath(['gsa' filesep 'mc'],M_.dname) filesep ];
end
else
MhDirectoryName = [CheckPath('prior') filesep ];
MhDirectoryName = [CheckPath('prior',M_.dname) filesep ];
end
end
switch type
......
......@@ -68,7 +68,7 @@ switch type
otherwise
disp(['This feature is not yet implemented!'])
end
CheckPath('prior/moments');
CheckPath('prior/moments',M_.dname);
pdfinfo = dir([ M_.dname '/prior/' generic_prior_data_file_name '*']);
if isempty(pdfinfo)
info = 4;
......
......@@ -42,7 +42,7 @@ n = estim_params_.np + ...
estim_params_.nvx;
nblck = options_.mh_nblck;
MhDirectoryName = CheckPath('metropolis');
MhDirectoryName = CheckPath('metropolis',M_.dname);
load([ MhDirectoryName '/' M_.fname '_mh_history.mat'])
FirstMhFile = record.KeepedDraws.FirstMhFile;
......
......@@ -40,7 +40,7 @@ if strcmpi(type,'posterior')
posterior = 1;
elseif strcmpi(type,'prior')
DrawsFiles = dir([M_.dname '/prior/draws/' type '_draws*' ]);
CheckPath('prior/moments');
CheckPath('prior/moments',M_.dname);
posterior = 0;
else
disp('dsge_simulated_theoretical_conditional_variance_decomposition:: Unknown type!')
......
......@@ -40,7 +40,7 @@ if strcmpi(type,'posterior')
posterior = 1;
elseif strcmpi(type,'prior')
DrawsFiles = dir([M_.dname '/prior/draws/' type '_draws*' ]);
CheckPath('prior/moments');
CheckPath('prior/moments',M_.dname);
posterior = 0;
else
disp('dsge_simulated_theoretical_correlation:: Unknown type!');
......
......@@ -40,7 +40,7 @@ if strcmpi(type,'posterior')
posterior = 1;
elseif strcmpi(type,'prior')
DrawsFiles = dir([M_.dname '/prior/draws/' type '_draws*' ]);
CheckPath('prior/moments');
CheckPath('prior/moments',M_.dname);
posterior = 0;
else
disp('dsge_simulated_theoretical_covariance:: Unknown type!')
......
......@@ -41,7 +41,7 @@ if strcmpi(type,'posterior')
posterior = 1;
elseif strcmpi(type,'prior')
DrawsFiles = dir([M_.dname '/prior/draws/' type '_draws*' ]);
CheckPath('prior/moments');
CheckPath('prior/moments',M_.dname);
posterior = 0;
else
disp('dsge_simulated_theoretical_variance_decomposition:: Unknown type!')
......
......@@ -567,7 +567,7 @@ elseif ~any(bayestopt_.pshape > 0) && options_.mh_posterior_mode_estimation
end
OutputDirectoryName = CheckPath('Output');
OutputDirectoryName = CheckPath('Output',M_.dname);
if any(bayestopt_.pshape > 0) && options_.TeX %% Bayesian estimation (posterior mode) Latex output
if np
......
......@@ -158,7 +158,7 @@ if ~(exist('sylvester3mr','file')==2),
addpath([dynareroot 'gensylv'])
end
IdentifDirectoryName = CheckPath('identification');
IdentifDirectoryName = CheckPath('identification',M_.dname);
if prior_exist,
indx = [];
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment