initialize_dseries_toolbox.m 3.28 KB
Newer Older
1
function initialize_dseries_toolbox()
2

3
% Copyright (C) 2015-2018 Dynare Team
Stéphane Adjemian's avatar
Stéphane Adjemian committed
4
5
6
7
8
9
10
11
12
13
14
15
16
17
%
% 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/>.

18
% Check that the dates module is available.
19
20
21
try
    initialize_dates_toolbox;
catch
22
    error('Missing dependency: dates module is not available.')
23
24
25
26
27
end

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

28
29
30
% Check that the x13 binary is available
nox13 = false;
if isunix()
31
    if system('which x13as') && ~(exist([dseries_src_root '../externals/x13/linux/64/x13as'], 'file') && exist([dseries_src_root '../externals/x13/linux/32/x13as'], 'file'))
32
33
34
        nox13 = true;
    end
elseif ismac()
35
    if ~exist([dseries_src_root '../externals/x13/osx/64/x13as'], 'file')
36
37
38
        nox13 = true;
    end
elseif ispc()
39
    if ~(exist([dseries_src_root '../externals/x13/windows/64/x13as.exe'], 'file') && exist([dseries_src_root '../externals/x13/windows/32/x13as.exe'], 'file'))
40
41
42
43
44
45
        nox13 = true;
    end
else
    error('Unsupported platform.')
end
if nox13
46
    warning('X13 binary is not available.\nIf you are under Debian or Ubuntu, you can install it through your package manager, with ''apt install x13as''.\nOtherwise, you can install it manually by running\nthe function installx13() available in:\n\n\t%s\n', [dseries_src_root(1:end-4), 'externals' filesep() 'x13']);
47
48
end

49
50
51
52
53
54
55
56
57
% Set the subfolders to be added in the path.
p = {'/read'; ...
     '/utilities/is'; ...
     '/utilities/str'; ...
     '/utilities/insert'; ...
     '/utilities/file'; ...
     '/utilities/from'; ...
     '/utilities/print'; ...
     '/utilities/variables'; ...
58
59
     '/utilities/cumulate'; ...
     '/utilities/struct'};
60

61
62
63
64
65
% Add /utilities/x13' if x13 binary is available.
if ~nox13
    p{end+1} = '/utilities/x13';
end

66
67
% Add missing routines if dynare is not in the path
if ~exist('demean','file')
68
    p{end+1} = '/utilities/missing/demean';
69
70
71
end

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

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

Stéphane Adjemian's avatar
Stéphane Adjemian committed
79
if ~exist('get_file_extension','file')
80
    p{end+1} = '/utilities/missing/get_file_extension';
Stéphane Adjemian's avatar
Stéphane Adjemian committed
81
82
end

Stéphane Adjemian's avatar
Stéphane Adjemian committed
83
if isoctave && ~exist('user_has_octave_forge_package','file')
84
    p{end+1} = '/utilities/missing/user_has_octave_forge_package';
85
end
86
87

if ~exist('get_cells_id','file')
88
    p{end+1} = '/utilities/missing/get_cells_id';
89
90
end

91
if ~exist('randomstring','file')
92
    p{end+1} = '/utilities/missing/randomstring';
93
94
end

95
96
97
98
if ~exist('one_sided_hp_filter','file')
    p{end+1} = '/utilities/missing/one_sided_hp_filter';
end

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

assignin('caller', 'dseries_src_root', dseries_src_root);