2008-05-16 10:18:37 +02:00
|
|
|
function dynareroot = dynare_config(path_to_dynare)
|
2008-08-01 14:40:33 +02:00
|
|
|
%function dynareroot = dynare_config(path_to_dynare)
|
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
|
|
|
|
%
|
|
|
|
% OUTPUTS
|
|
|
|
% none
|
|
|
|
%
|
|
|
|
% SPECIAL REQUIREMENTS
|
|
|
|
% none
|
2008-08-01 14:40:33 +02:00
|
|
|
|
2009-04-24 18:08:27 +02:00
|
|
|
% Copyright (C) 2001-2009 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/>.
|
|
|
|
|
2008-05-16 10:18:37 +02:00
|
|
|
if nargin
|
|
|
|
addpath(path_to_dynare);
|
|
|
|
end
|
2009-07-03 12:36:11 +02:00
|
|
|
dynareroot = strrep(which('dynare'),'dynare.m','');
|
2008-06-24 20:20:48 +02:00
|
|
|
|
2008-09-09 23:47:13 +02:00
|
|
|
addpath([dynareroot '/distributions/'])
|
2008-10-20 16:46:00 +02:00
|
|
|
addpath([dynareroot '/kalman/'])
|
2008-10-16 23:15:07 +02:00
|
|
|
addpath([dynareroot '/kalman/likelihood'])
|
2010-03-23 18:17:15 +01:00
|
|
|
addpath([dynareroot '/kalman/smoother'])
|
2009-04-24 18:08:27 +02:00
|
|
|
addpath([dynareroot '/AIM/'])
|
2010-03-23 11:09:59 +01:00
|
|
|
addpath([dynareroot '/partial_information/'])
|
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
|
|
|
|
|
|
|
|
if ~exist('OCTAVE_VERSION')
|
|
|
|
% Replacements for rows() and columns() (inexistent under MATLAB)
|
|
|
|
addpath([dynareroot '/missing/rows_columns'])
|
2009-09-24 10:34:57 +02:00
|
|
|
% Replacement for vec() (inexistent under MATLAB)
|
|
|
|
addpath([dynareroot '/missing/vec'])
|
2009-04-24 18:08:27 +02:00
|
|
|
if isempty(ver('stats'))
|
|
|
|
% Replacements for functions of the stats toolbox
|
2009-07-03 12:20:42 +02:00
|
|
|
addpath([dynareroot '/missing/stats/'])
|
2009-04-24 18:08:27 +02:00
|
|
|
end
|
2008-07-28 11:46:07 +02:00
|
|
|
end
|
|
|
|
|
2009-07-03 12:20:42 +02:00
|
|
|
% ordeig() was introducted in MATLAB 7.0.1, and doesn't exist in Octave
|
|
|
|
if exist('OCTAVE_VERSION') || matlab_ver_less_than('7.0.1')
|
|
|
|
addpath([dynareroot '/missing/ordeig'])
|
|
|
|
end
|
|
|
|
|
2010-02-17 18:15:37 +01:00
|
|
|
% rcond() and bicgstable() were introduced in Octave 3.2.0
|
2009-07-03 12:20:42 +02:00
|
|
|
if exist('OCTAVE_VERSION') && octave_ver_less_than('3.2.0')
|
|
|
|
addpath([dynareroot '/missing/rcond'])
|
2010-02-17 18:15:37 +01:00
|
|
|
addpath([dynareroot '/missing/bicgstab'])
|
2009-07-03 12:20:42 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
% orschur() is missing in Octave; we don't have a real replacement;
|
|
|
|
% the one we provide just exits with an error message
|
|
|
|
if exist('OCTAVE_VERSION')
|
|
|
|
addpath([dynareroot '/missing/ordschur'])
|
|
|
|
end
|
|
|
|
|
2010-02-19 00:17:54 +01:00
|
|
|
% bsxfun is missing in old versions of matlab (octave?)
|
|
|
|
if ~exist('OCTAVE_VERSION') && matlab_ver_less_than('7.4')
|
|
|
|
addpath([dynareroot '/missing/bsxfun'])
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2009-04-24 18:08:27 +02:00
|
|
|
% Add path to MEX files
|
2008-06-24 20:20:48 +02:00
|
|
|
if exist('OCTAVE_VERSION')
|
2009-11-04 11:56:37 +01:00
|
|
|
addpath([dynareroot '../mex/octave/']);
|
2008-05-16 10:18:37 +02:00
|
|
|
else
|
2009-11-04 11:56:37 +01:00
|
|
|
% Add win32 specific paths for Dynare Windows package
|
|
|
|
if strcmp(computer, 'PCWIN')
|
|
|
|
if matlab_ver_less_than('7.5')
|
2009-11-17 20:01:59 +01:00
|
|
|
mexpath = [dynareroot '../mex/matlab/win32-6.5-7.4'];
|
2009-11-04 11:56:37 +01:00
|
|
|
if exist(mexpath, 'dir')
|
|
|
|
addpath(mexpath)
|
|
|
|
end
|
|
|
|
else
|
2010-03-10 18:44:46 +01:00
|
|
|
mexpath = [dynareroot '../mex/matlab/win32-7.5-7.10'];
|
2009-11-04 11:56:37 +01:00
|
|
|
if exist(mexpath, 'dir')
|
|
|
|
addpath(mexpath)
|
|
|
|
end
|
|
|
|
end
|
2008-06-24 20:20:48 +02:00
|
|
|
end
|
2009-11-04 11:56:37 +01:00
|
|
|
|
|
|
|
% Add win64 specific paths for Dynare Windows package
|
|
|
|
if strcmp(computer, 'PCWIN64')
|
2009-11-23 16:16:43 +01:00
|
|
|
if matlab_ver_less_than('7.3')
|
|
|
|
mexpath = [dynareroot '../mex/matlab/win64-7.2'];
|
|
|
|
if exist(mexpath, 'dir')
|
|
|
|
addpath(mexpath)
|
|
|
|
end
|
|
|
|
elseif matlab_ver_less_than('7.5')
|
|
|
|
mexpath = [dynareroot '../mex/matlab/win64-7.3-7.4'];
|
2009-11-04 11:56:37 +01:00
|
|
|
if exist(mexpath, 'dir')
|
|
|
|
addpath(mexpath)
|
|
|
|
end
|
|
|
|
elseif matlab_ver_less_than('7.8')
|
|
|
|
mexpath = [dynareroot '../mex/matlab/win64-7.5-7.7'];
|
|
|
|
if exist(mexpath, 'dir')
|
|
|
|
addpath(mexpath)
|
|
|
|
end
|
|
|
|
else
|
2010-03-10 18:44:46 +01:00
|
|
|
mexpath = [dynareroot '../mex/matlab/win64-7.8-7.10'];
|
2009-11-04 11:56:37 +01:00
|
|
|
if exist(mexpath, 'dir')
|
|
|
|
addpath(mexpath)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
% Add generic MATLAB path (with higher priority than the previous ones)
|
|
|
|
addpath([dynareroot '../mex/matlab/']);
|
2008-05-16 10:18:37 +02:00
|
|
|
end
|
2009-03-11 15:57:34 +01:00
|
|
|
|
2008-05-16 10:18:37 +02:00
|
|
|
%% Set mex routine names
|
|
|
|
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'};
|
|
|
|
number_of_mex_files = size(mex_status,1);
|
|
|
|
%% 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.
|
|
|
|
matlab_path = path;
|
2009-04-03 13:01:55 +02:00
|
|
|
test = strfind(matlab_path,[dynareroot 'threads/single']);
|
|
|
|
if length(test)
|
|
|
|
rmpath([dynareroot 'threads/single']);
|
|
|
|
matlab_path = path;
|
|
|
|
end
|
|
|
|
test = strfind(matlab_path,[dynareroot 'threads/multi']);
|
|
|
|
if length(test)
|
|
|
|
rmpath([dynareroot 'threads/multi']);
|
|
|
|
matlab_path = path;
|
|
|
|
end
|
2008-05-16 10:18:37 +02:00
|
|
|
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
|
2009-04-03 13:01:55 +02:00
|
|
|
%% Test if multithread mex files are available.
|
|
|
|
if exist('isopenmp')==3
|
|
|
|
addpath([dynareroot '/threads/multi/'])
|
|
|
|
number_of_threads = set_dynare_threads();
|
|
|
|
multithread_flag = number_of_threads-1;
|
|
|
|
else
|
|
|
|
addpath([dynareroot '/threads/single/'])
|
|
|
|
multithread_flag = 0;
|
|
|
|
end
|
2008-05-16 10:18:37 +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.
|
|
|
|
disp(' ')
|
|
|
|
disp('Configuring Dynare ...')
|
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
|
2009-04-03 13:01:55 +02:00
|
|
|
if multithread_flag && ( strcmpi(mex_status(i,1),'sparse_hessian_times_B_kronecker_C') || ...
|
|
|
|
strcmpi(mex_status(i,1),'A_times_B_kronecker_C') )
|
2009-03-11 15:57:34 +01:00
|
|
|
message = [ '[mex][multithread version, ' int2str(multithread_flag+1) ' threads are used] ' ];
|
|
|
|
else
|
|
|
|
message = '[mex] ';
|
|
|
|
end
|
2008-05-16 10:18:37 +02:00
|
|
|
end
|
|
|
|
disp([ message mex_status{i,3} '.' ])
|
|
|
|
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
|
2009-12-16 18:17:34 +01:00
|
|
|
if ~multithread_flag
|
|
|
|
message = '[mex] ';
|
|
|
|
else
|
|
|
|
message = [ '[mex][multithread version, ' int2str(multithread_flag+1) ' threads are used] ' ];
|
|
|
|
end
|
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
|
2009-09-02 16:40:54 +02:00
|
|
|
disp([ message 'Bytecode evaluation.' ])
|
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
|
2009-11-06 13:03:19 +01:00
|
|
|
disp([ message 'k-order perturbation solver.' ])
|
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
|
|
|
|
disp([ message 'k-order solution simulation.' ])
|
|
|
|
|
|
|
|
disp(' ')
|