File: dynare_config.m

package info (click to toggle)
dynare 4.4.3-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 41,312 kB
  • ctags: 15,840
  • sloc: cpp: 77,029; ansic: 29,056; pascal: 13,241; sh: 4,811; objc: 3,061; yacc: 3,013; makefile: 1,476; lex: 1,258; python: 162; lisp: 54; xml: 8
file content (293 lines) | stat: -rw-r--r-- 8,926 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
function dynareroot = dynare_config(path_to_dynare,verbose)
%function dynareroot = dynare_config(path_to_dynare)
% 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.
% Also adds other directories to the path.
%
% INPUTS
%   none
%
% OUTPUTS
%   none
%
% SPECIAL REQUIREMENTS
%   none

% Copyright (C) 2001-2013 Dynare Team
%
% 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/>.

if nargin && ~isempty(path_to_dynare)
    addpath(path_to_dynare);
end
dynareroot = '/usr/lib/dynare/matlab/';

origin = pwd();
cd([dynareroot '/..'])

if ~nargin || nargin==1
    verbose = 1;
end


addpath([dynareroot '/distributions/'])
addpath([dynareroot '/kalman/'])
addpath([dynareroot '/kalman/likelihood'])
addpath([dynareroot '/AIM/'])
addpath([dynareroot '/partial_information/'])
addpath([dynareroot '/ms-sbvar/'])
addpath([dynareroot '/ms-sbvar/identification/'])
addpath([dynareroot '../contrib/ms-sbvar/TZcode/MatlabFiles/'])
addpath([dynareroot '/parallel/'])
addpath([dynareroot '/particle/'])
addpath([dynareroot '/gsa/'])
addpath([dynareroot '/ep/'])
addpath([dynareroot '/utilities/doc/'])
addpath([dynareroot '/utilities/tests/'])
addpath([dynareroot '/utilities/dates/'])
addpath([dynareroot '/utilities/dseries/'])
addpath([dynareroot '/utilities/dataset/'])
addpath([dynareroot '/utilities/general/'])
addpath([dynareroot '/reports/'])

% For functions that exist only under some Octave versions
% or some MATLAB versions, and for which we provide some replacement functions

if ~isoctave
    % Replacements for rows(), columns() and issquare() (inexistent under MATLAB)
    addpath([dynareroot '/missing/rows_columns'])
    addpath([dynareroot '/missing/issquare'])
    % Replacement for vec() (inexistent under MATLAB)
    addpath([dynareroot '/missing/vec'])
    if ~user_has_matlab_license('statistics_toolbox')
        % Replacements for functions of the stats toolbox
        addpath([dynareroot '/missing/stats/'])
    end
end

% ordeig() doesn't exist in Octave
if isoctave
    addpath([dynareroot '/missing/ordeig'])
end

% bsxfun is missing in old versions of MATLAB (and exists in Octave)
if ~isoctave && matlab_ver_less_than('7.4')
    addpath([dynareroot '/missing/bsxfun'])
end

% ilu is missing in old versions of MATLAB and in Octave
if isoctave || matlab_ver_less_than('7.4')
    addpath([dynareroot '/missing/ilu'])
end

% strjoin is missing in older versions of MATLAB and in Octave < 3.8
if (isoctave && octave_ver_less_than('3.8')) || ...
        (~isoctave && matlab_ver_less_than('8.1'))
    addpath([dynareroot '/missing/strjoin'])
end

% nanmean is in Octave Forge Statistics package and in MATLAB Statistics
% toolbox
if (isoctave && ~user_has_octave_forge_package('statistics')) ...
    || (~isoctave && ~user_has_matlab_license('statistics_toolbox'))
    addpath([dynareroot '/missing/nanmean'])
end

% Add path to MEX files
if isoctave
    addpath([dynareroot '../mex/octave/']);
else
    % Add win32 specific paths for Dynare Windows package
    if strcmp(computer, 'PCWIN')
        if matlab_ver_less_than('7.5')
            mexpath = [dynareroot '../mex/matlab/win32-7.3-7.4'];
            if exist(mexpath, 'dir')
                addpath(mexpath)
            end
        else
            mexpath = [dynareroot '../mex/matlab/win32-7.5-8.3'];
            if exist(mexpath, 'dir')
                addpath(mexpath)
            end
        end
    end

    % Add win64 specific paths for Dynare Windows package
    if strcmp(computer, 'PCWIN64')
        if matlab_ver_less_than('7.5')
            mexpath = [dynareroot '../mex/matlab/win64-7.3-7.4'];
            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
            mexpath = [dynareroot '../mex/matlab/win64-7.8-8.3'];
            if exist(mexpath, 'dir')
                addpath(mexpath)
            end
        end
    end

    if strcmp(computer, 'MACI')
        if matlab_ver_less_than('7.5')
            mexpath = [dynareroot '../mex/matlab/osx32-7.4'];
            if exist(mexpath, 'dir')
                addpath(mexpath)
            end
        else
            mexpath = [dynareroot '../mex/matlab/osx32-7.5-7.11'];
            if exist(mexpath, 'dir')
                addpath(mexpath)
            end
        end
    end

    if strcmp(computer, 'MACI64')
        mexpath = [dynareroot '../mex/matlab/osx64'];
        if exist(mexpath, 'dir')
            addpath(mexpath)
        end
    end

    % Add generic MATLAB path (with higher priority than the previous ones)
    addpath([dynareroot '../mex/matlab/']);
end

% matlab2tikz
if strncmp(computer, 'GLNX', 4) || ~isempty(regexpi(computer, '.*linux.*', 'once'))
    if exist('matlab2tikz.m') == 0 && exist('/usr/share/matlab2tikz/matlab2tikz.m') == 2
        addpath('/usr/share/matlab2tikz');
    end
elseif strncmp(computer, 'MACI', 4) || ~isempty(regexpi(computer, '.*apple.*', 'once'))
    if exist([dynareroot '../contrib/matlab2tikz/matlab2tikz.m']) == 2
        addpath([dynareroot '../contrib/matlab2tikz']);
    elseif exist('/usr/local/share/matlab2tikz/matlab2tikz.m') == 2
        addpath('/usr/local/share/matlab2tikz');
    end
else
    if exist([dynareroot '../contrib/matlab2tikz/matlab2tikz.m']) == 2
        addpath([dynareroot '../contrib/matlab2tikz']);
    end
end

%% Set mex routine names
mex_status = cell(1,3);
mex_status(1,1) = {'mjdgges'};
mex_status(1,2) = {'qz'};
mex_status(1,3) = {'Generalized QZ'};
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'};
mex_status(5,1) = {'local_state_space_iteration_2'};
mex_status(5,2) = {'particle/local_state_space_iteration'};
mex_status(5,3) = {'Local state space iteration (second order)'};
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;
for i=1:number_of_mex_files
    test = strfind(matlab_path,[dynareroot mex_status{i,2}]);
    action = length(test);
    if action
        rmpath([dynareroot mex_status{i,2}]);
        matlab_path = path;
    end
end
%% 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.
if verbose
    skipline()
    disp('Configuring Dynare ...')
end

for i=1:number_of_mex_files
    test = (exist(mex_status{i,1},'file') == 3);
    if ~test
        addpath([dynareroot mex_status{i,2}]);
        message = '[m]   ';
    else
        message = '[mex] ';
    end
    if verbose
        disp([ message mex_status{i,3} '.' ])
    end
end

% Test if bytecode DLL is present
if exist('bytecode', 'file') == 3
    message = '[mex] ';
else
    message = '[no]  ';
end
if verbose
    disp([ message 'Bytecode evaluation.' ])
end

% Test if k-order perturbation DLL is present
if exist('k_order_perturbation', 'file') == 3
    message = '[mex] ';
else
    message = '[no]  ';
end
if verbose
    disp([ message 'k-order perturbation solver.' ])
end

% Test if dynare_simul_ DLL is present
if exist('dynare_simul_', 'file') == 3
    message = '[mex] ';
else
    message = '[no]  ';
end
if verbose
    disp([ message 'k-order solution simulation.' ])
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).' ])
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.' ])
    skipline()
end

cd(origin);