2017-10-10 10:05:59 +02:00
|
|
|
function dynareroot = dynare_config(path_to_dynare, verbose)
|
|
|
|
|
2008-05-16 10:18:37 +02:00
|
|
|
% This function tests the existence of valid mex files (for qz
|
|
|
|
% decomposition, solution to sylvester equation and kronecker
|
|
|
|
% products...) and, if needed, add paths to the matlab versions
|
|
|
|
% of these routines.
|
2008-08-04 15:33:57 +02:00
|
|
|
% Also adds other directories to the path.
|
2008-05-16 10:18:37 +02:00
|
|
|
%
|
|
|
|
% INPUTS
|
|
|
|
% none
|
2011-08-11 15:10:57 +02:00
|
|
|
%
|
2008-05-16 10:18:37 +02:00
|
|
|
% OUTPUTS
|
|
|
|
% none
|
2011-08-11 15:10:57 +02:00
|
|
|
%
|
2008-05-16 10:18:37 +02:00
|
|
|
% SPECIAL REQUIREMENTS
|
|
|
|
% none
|
2008-08-01 14:40:33 +02:00
|
|
|
|
2017-10-10 10:05:59 +02:00
|
|
|
% Copyright (C) 2001-2018 Dynare Team
|
2008-08-01 14:40:33 +02:00
|
|
|
%
|
|
|
|
% This file is part of Dynare.
|
|
|
|
%
|
|
|
|
% Dynare is free software: you can redistribute it and/or modify
|
|
|
|
% it under the terms of the GNU General Public License as published by
|
|
|
|
% the Free Software Foundation, either version 3 of the License, or
|
|
|
|
% (at your option) any later version.
|
|
|
|
%
|
|
|
|
% Dynare is distributed in the hope that it will be useful,
|
|
|
|
% but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
% GNU General Public License for more details.
|
|
|
|
%
|
|
|
|
% You should have received a copy of the GNU General Public License
|
|
|
|
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
2011-07-26 11:07:27 +02:00
|
|
|
if nargin && ~isempty(path_to_dynare)
|
2008-05-16 10:18:37 +02:00
|
|
|
addpath(path_to_dynare);
|
|
|
|
end
|
2015-03-30 14:54:14 +02:00
|
|
|
|
2009-07-03 12:36:11 +02:00
|
|
|
dynareroot = strrep(which('dynare'),'dynare.m','');
|
2008-06-24 20:20:48 +02:00
|
|
|
|
2011-12-21 18:31:29 +01:00
|
|
|
origin = pwd();
|
|
|
|
cd([dynareroot '/..'])
|
|
|
|
|
2011-08-11 15:10:57 +02:00
|
|
|
if ~nargin || nargin==1
|
2011-07-26 11:07:27 +02:00
|
|
|
verbose = 1;
|
|
|
|
end
|
|
|
|
|
2016-06-16 23:55:07 +02:00
|
|
|
p = {'/distributions/' ; ...
|
|
|
|
'/kalman/' ; ...
|
|
|
|
'/kalman/likelihood' ; ...
|
|
|
|
'/AIM/' ; ...
|
|
|
|
'/partial_information/' ; ...
|
|
|
|
'/perfect-foresight-models/' ; ...
|
|
|
|
'/ms-sbvar/' ; ...
|
|
|
|
'/ms-sbvar/identification/' ; ...
|
|
|
|
'/../contrib/ms-sbvar/TZcode/MatlabFiles/' ; ...
|
2017-06-22 16:34:52 +02:00
|
|
|
'/../contrib/jsonlab/' ; ...
|
2016-06-16 23:55:07 +02:00
|
|
|
'/parallel/' ; ...
|
|
|
|
'/particles/src' ; ...
|
|
|
|
'/gsa/' ; ...
|
|
|
|
'/ep/' ; ...
|
2017-05-18 10:46:08 +02:00
|
|
|
'/backward/' ; ...
|
|
|
|
'/convergence_diagnostics/' ; ...
|
2016-06-16 23:55:07 +02:00
|
|
|
'/cli/' ; ...
|
|
|
|
'/lmmcp/' ; ...
|
|
|
|
'/optimization/' ; ...
|
|
|
|
'/modules/dates/src/' ; ...
|
|
|
|
'/modules/dseries/src/' ; ...
|
|
|
|
'/utilities/doc/' ; ...
|
|
|
|
'/utilities/tests/src/' ; ...
|
|
|
|
'/utilities/dataset/' ; ...
|
|
|
|
'/utilities/general/' ; ...
|
2017-01-06 11:09:04 +01:00
|
|
|
'/utilities/graphics/' ; ...
|
2016-06-16 23:55:07 +02:00
|
|
|
'/modules/reporting/src/' ; ...
|
|
|
|
'/modules/reporting/macros/'};
|
2008-10-13 20:54:42 +02:00
|
|
|
|
2009-07-03 12:20:42 +02:00
|
|
|
% For functions that exist only under some Octave versions
|
|
|
|
% or some MATLAB versions, and for which we provide some replacement functions
|
|
|
|
|
2018-06-05 19:46:09 +02:00
|
|
|
% Replacements for rows(), columns(), vec() and issquare() (inexistent under MATLAB)
|
2013-11-04 10:54:45 +01:00
|
|
|
if ~isoctave
|
2016-06-16 23:55:07 +02:00
|
|
|
p{end+1} = '/missing/rows_columns';
|
|
|
|
p{end+1} = '/missing/issquare';
|
|
|
|
p{end+1} = '/missing/vec';
|
2008-07-28 11:46:07 +02:00
|
|
|
end
|
|
|
|
|
2012-09-18 11:54:40 +02:00
|
|
|
% ordeig() doesn't exist in Octave
|
2013-11-04 10:54:45 +01:00
|
|
|
if isoctave
|
2016-06-16 23:55:07 +02:00
|
|
|
p{end+1} = '/missing/ordeig';
|
2009-07-03 12:20:42 +02:00
|
|
|
end
|
|
|
|
|
2018-06-05 17:14:41 +02:00
|
|
|
% corrcoef with two outputs is missing in Octave < 4.4 (ticket #796)
|
|
|
|
if isoctave && octave_ver_less_than('4.4') && ~user_has_octave_forge_package('nan')
|
2016-06-16 23:55:07 +02:00
|
|
|
p{end+1} = '/missing/corrcoef';
|
2014-11-24 16:06:05 +01:00
|
|
|
end
|
|
|
|
|
2011-09-27 16:59:21 +02:00
|
|
|
% nanmean is in Octave Forge Statistics package and in MATLAB Statistics
|
|
|
|
% toolbox
|
2013-11-04 10:54:45 +01:00
|
|
|
if (isoctave && ~user_has_octave_forge_package('statistics')) ...
|
2017-05-16 15:10:20 +02:00
|
|
|
|| (~isoctave && ~user_has_matlab_license('statistics_toolbox'))
|
2016-06-16 23:55:07 +02:00
|
|
|
p{end+1} = '/missing/nanmean';
|
2011-09-27 16:59:21 +02:00
|
|
|
end
|
2010-02-19 00:17:54 +01:00
|
|
|
|
2018-06-05 19:46:09 +02:00
|
|
|
% Replacements for functions of the MATLAB statistics toolbox
|
|
|
|
% These functions were part of Octave < 4.4, they are now in the statistics Forge package
|
|
|
|
if (isoctave && ~octave_ver_less_than('4.4') && ~user_has_octave_forge_package('statistics')) ...
|
|
|
|
|| (~isoctave && ~user_has_matlab_license('statistics_toolbox'))
|
|
|
|
p{end+1} = '/missing/stats/';
|
2018-06-06 13:02:42 +02:00
|
|
|
if ~isoctave
|
|
|
|
p{end+1} = '/missing/stats-matlab/';
|
|
|
|
end
|
2018-06-05 19:46:09 +02:00
|
|
|
end
|
|
|
|
|
2017-03-22 15:20:13 +01:00
|
|
|
% Check if struct2array is available.
|
|
|
|
if ~exist('struct2array')
|
|
|
|
p{end+1} = '/missing/struct2array';
|
|
|
|
end
|
|
|
|
|
2017-10-10 13:33:32 +02:00
|
|
|
% isfile is missing in Octave and Matlab<R2017b
|
|
|
|
if isoctave || matlab_ver_less_than('9.3')
|
|
|
|
p{end+1} = '/missing/isfile';
|
|
|
|
end
|
|
|
|
|
2018-03-12 21:24:38 +01:00
|
|
|
% strsplit is missing in Matlab<R2013a
|
|
|
|
if ~isoctave && matlab_ver_less_than('8.1')
|
|
|
|
p{end+1} = '/missing/strsplit';
|
|
|
|
end
|
|
|
|
|
2018-11-13 16:59:27 +01:00
|
|
|
% isrow, iscolumn and ismatrix are missing in Matlab<R2010b
|
2018-05-30 17:42:55 +02:00
|
|
|
if ~isoctave && matlab_ver_less_than('7.11')
|
2018-11-13 16:59:27 +01:00
|
|
|
p{end+1} = '/missing/is-row-column-matrix';
|
2018-05-30 17:42:55 +02:00
|
|
|
end
|
|
|
|
|
2016-06-17 21:59:29 +02:00
|
|
|
P = cellfun(@(c)[dynareroot(1:end-1) c], p, 'uni',false);
|
2016-06-16 23:55:07 +02:00
|
|
|
|
2016-06-17 21:59:29 +02:00
|
|
|
% Get mex files folder(s)
|
|
|
|
mexpaths = add_path_to_mex_files(dynareroot, false);
|
2016-06-16 23:55:07 +02:00
|
|
|
|
2016-06-17 21:59:29 +02:00
|
|
|
% Add mex files folder(s)
|
|
|
|
P(end+1:end+length(mexpaths)) = mexpaths;
|
|
|
|
|
|
|
|
% Set matlab's path
|
2016-06-16 23:55:07 +02:00
|
|
|
addpath(P{:});
|
2009-03-11 15:57:34 +01:00
|
|
|
|
2016-06-17 21:59:29 +02:00
|
|
|
% Set mex routine names
|
2008-05-16 10:18:37 +02:00
|
|
|
mex_status = cell(1,3);
|
|
|
|
mex_status(1,1) = {'mjdgges'};
|
|
|
|
mex_status(1,2) = {'qz'};
|
2008-05-16 10:22:46 +02:00
|
|
|
mex_status(1,3) = {'Generalized QZ'};
|
2008-05-16 10:18:37 +02:00
|
|
|
mex_status(2,1) = {'gensylv'};
|
|
|
|
mex_status(2,2) = {'gensylv'};
|
|
|
|
mex_status(2,3) = {'Sylvester equation solution'};
|
|
|
|
mex_status(3,1) = {'A_times_B_kronecker_C'};
|
|
|
|
mex_status(3,2) = {'kronecker'};
|
|
|
|
mex_status(3,3) = {'Kronecker products'};
|
|
|
|
mex_status(4,1) = {'sparse_hessian_times_B_kronecker_C'};
|
|
|
|
mex_status(4,2) = {'kronecker'};
|
|
|
|
mex_status(4,3) = {'Sparse kronecker products'};
|
2012-02-28 08:43:28 +01:00
|
|
|
mex_status(5,1) = {'local_state_space_iteration_2'};
|
2014-11-13 15:53:26 +01:00
|
|
|
mex_status(5,2) = {'reduced_form_models/local_state_space_iteration_2'};
|
2012-06-15 15:09:39 +02:00
|
|
|
mex_status(5,3) = {'Local state space iteration (second order)'};
|
2008-05-16 10:18:37 +02:00
|
|
|
number_of_mex_files = size(mex_status,1);
|
2016-06-17 21:59:29 +02:00
|
|
|
|
|
|
|
% Remove some directories from matlab's path. This is necessary if the user has
|
|
|
|
% added dynare_v4/matlab with the subfolders. Matlab has to ignore these
|
|
|
|
% subfolders if valid mex files exist.
|
2008-05-16 10:18:37 +02:00
|
|
|
matlab_path = path;
|
|
|
|
for i=1:number_of_mex_files
|
2008-05-16 10:22:46 +02:00
|
|
|
test = strfind(matlab_path,[dynareroot mex_status{i,2}]);
|
2008-05-16 10:18:37 +02:00
|
|
|
action = length(test);
|
2008-05-16 10:22:46 +02:00
|
|
|
if action
|
2008-05-16 10:18:37 +02:00
|
|
|
rmpath([dynareroot mex_status{i,2}]);
|
|
|
|
matlab_path = path;
|
|
|
|
end
|
|
|
|
end
|
2016-06-17 21:59:29 +02:00
|
|
|
|
|
|
|
% Test if valid mex files are available, if a mex file is not available
|
|
|
|
% a matlab version of the routine is included in the path.
|
2011-07-26 11:07:27 +02:00
|
|
|
if verbose
|
2013-07-10 17:12:34 +02:00
|
|
|
skipline()
|
2011-07-26 11:07:27 +02:00
|
|
|
disp('Configuring Dynare ...')
|
|
|
|
end
|
2009-04-29 13:35:05 +02:00
|
|
|
|
2008-05-16 10:18:37 +02:00
|
|
|
for i=1:number_of_mex_files
|
2009-06-21 11:20:03 +02:00
|
|
|
test = (exist(mex_status{i,1},'file') == 3);
|
2008-05-16 10:18:37 +02:00
|
|
|
if ~test
|
|
|
|
addpath([dynareroot mex_status{i,2}]);
|
|
|
|
message = '[m] ';
|
|
|
|
else
|
2010-09-27 15:54:54 +02:00
|
|
|
message = '[mex] ';
|
2008-05-16 10:18:37 +02:00
|
|
|
end
|
2011-07-26 11:07:27 +02:00
|
|
|
if verbose
|
|
|
|
disp([ message mex_status{i,3} '.' ])
|
|
|
|
end
|
2008-05-16 10:18:37 +02:00
|
|
|
end
|
2008-10-13 17:20:43 +02:00
|
|
|
|
2009-09-02 16:40:54 +02:00
|
|
|
% Test if bytecode DLL is present
|
2009-12-17 15:20:14 +01:00
|
|
|
if exist('bytecode', 'file') == 3
|
2010-09-27 15:54:54 +02:00
|
|
|
message = '[mex] ';
|
2008-10-13 17:20:43 +02:00
|
|
|
else
|
2009-12-16 18:17:34 +01:00
|
|
|
message = '[no] ';
|
2008-10-13 17:20:43 +02:00
|
|
|
end
|
2011-07-26 11:07:27 +02:00
|
|
|
if verbose
|
|
|
|
disp([ message 'Bytecode evaluation.' ])
|
|
|
|
end
|
2008-10-13 17:20:43 +02:00
|
|
|
|
2009-09-23 15:14:05 +02:00
|
|
|
% Test if k-order perturbation DLL is present
|
2009-12-17 15:20:14 +01:00
|
|
|
if exist('k_order_perturbation', 'file') == 3
|
2009-12-16 18:17:34 +01:00
|
|
|
message = '[mex] ';
|
2009-09-23 15:14:05 +02:00
|
|
|
else
|
2009-12-16 18:17:34 +01:00
|
|
|
message = '[no] ';
|
2009-09-23 15:14:05 +02:00
|
|
|
end
|
2011-07-26 11:07:27 +02:00
|
|
|
if verbose
|
|
|
|
disp([ message 'k-order perturbation solver.' ])
|
|
|
|
end
|
2009-09-23 15:14:05 +02:00
|
|
|
|
2009-11-06 13:03:19 +01:00
|
|
|
% Test if dynare_simul_ DLL is present
|
2009-12-17 15:20:14 +01:00
|
|
|
if exist('dynare_simul_', 'file') == 3
|
2009-12-16 18:17:34 +01:00
|
|
|
message = '[mex] ';
|
2009-11-06 13:03:19 +01:00
|
|
|
else
|
2009-12-16 18:17:34 +01:00
|
|
|
message = '[no] ';
|
2009-11-06 13:03:19 +01:00
|
|
|
end
|
2011-07-26 11:07:27 +02:00
|
|
|
if verbose
|
|
|
|
disp([ message 'k-order solution simulation.' ])
|
2011-12-21 18:23:15 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
% Test if qmc_sequence DLL is present
|
|
|
|
if exist('qmc_sequence', 'file') == 3
|
|
|
|
message = '[mex] ';
|
|
|
|
else
|
|
|
|
message = '[no] ';
|
|
|
|
end
|
|
|
|
if verbose
|
|
|
|
disp([ message 'Quasi Monte-Carlo sequence (Sobol).' ])
|
2012-06-15 16:36:22 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
% Test if MS-SBVAR DLL is present
|
|
|
|
if exist('ms_sbvar_command_line', 'file') == 3
|
|
|
|
message = '[mex] ';
|
|
|
|
else
|
|
|
|
message = '[no] ';
|
|
|
|
end
|
|
|
|
if verbose
|
|
|
|
disp([ message 'Markov Switching SBVAR.' ])
|
2013-07-10 17:12:34 +02:00
|
|
|
skipline()
|
2011-07-26 11:07:27 +02:00
|
|
|
end
|
2011-12-21 18:31:29 +01:00
|
|
|
|
2015-06-24 19:02:42 +02:00
|
|
|
% Initialization of the dates and dseries classes (recursive).
|
|
|
|
initialize_dseries_toolbox;
|
2014-05-14 12:36:06 +02:00
|
|
|
|
2018-03-12 21:24:38 +01:00
|
|
|
cd(origin);
|