initialize_dseries_toolbox.m 2.67 KB
Newer Older
Stéphane Adjemian's avatar
Stéphane Adjemian committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
% Copyright (C) 2015-2017 Dynare Team
%
% This code 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 dseries submodule 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/>.

16
% Check that the dates module is available.
17
18
19
try
    initialize_dates_toolbox;
catch
20
21
22
23
24
25
26
27
    urlwrite('https://github.com/DynareTeam/dates/archive/master.zip','master.zip');
    warning('off','MATLAB:MKDIR:DirectoryExists')
    mkdir('../externals')
    warning('on','MATLAB:MKDIR:DirectoryExists')
    unzip('master.zip','../externals')
    delete('master.zip')
    addpath([pwd() '/../externals/dates-master/src'])
    initialize_dates_toolbox;
28
29
30
31
32
end

% Get the path to the dseries toolbox.
dseries_src_root = strrep(which('initialize_dseries_toolbox'),'initialize_dseries_toolbox.m','');

33
34
35
36
37
38
39
40
41
42
% Set the subfolders to be added in the path.
p = {'/read'; ...
     '/utilities/is'; ...
     '/utilities/str'; ...
     '/utilities/x13'; ...
     '/utilities/insert'; ...
     '/utilities/file'; ...
     '/utilities/from'; ...
     '/utilities/print'; ...
     '/utilities/variables'; ...
43
44
     '/utilities/cumulate'; ...
     '/utilities/struct'};
45
46
47

% Add missing routines if dynare is not in the path
if ~exist('demean','file')
48
    p{end+1} = '/utilities/missing/demean';
49
50
51
end

if ~exist('ndim','file')
52
    p{end+1} = '/utilities/missing/ndim';
53
54
55
end

if ~exist('sample_hp_filter','file')
56
    p{end+1} = '/utilities/missing/sample_hp_filter';
Stéphane Adjemian's avatar
Stéphane Adjemian committed
57
58
end

Stéphane Adjemian's avatar
Stéphane Adjemian committed
59
if ~exist('get_file_extension','file')
60
    p{end+1} = '/utilities/missing/get_file_extension';
Stéphane Adjemian's avatar
Stéphane Adjemian committed
61
62
end

Stéphane Adjemian's avatar
Stéphane Adjemian committed
63
if isoctave && ~exist('user_has_octave_forge_package','file')
64
    p{end+1} = '/utilities/missing/user_has_octave_forge_package';
65
end
66
67

if ~exist('get_cells_id','file')
68
    p{end+1} = '/utilities/missing/get_cells_id';
69
70
end

71
if ~exist('randomstring','file')
72
    p{end+1} = '/utilities/missing/randomstring';
73
74
end

75
76
77
78
if ~exist('one_sided_hp_filter','file')
    p{end+1} = '/utilities/missing/one_sided_hp_filter';
end

79
80
% Install X13 binaries
opath = pwd();
81
82
83
84
85
86
87
try
    cd([dseries_src_root '/../externals/x13'])
    installx13();
catch
    warning('X13 is not available!')
    p(strmatch('/utilities/x13', p, 'exact')) = [];
end
88
89
90
91
92
cd(opath);

% Set path
P = cellfun(@(c)[dseries_src_root(1:end-1) c], p, 'uni', false);
addpath(P{:});