initialize_dseries_class.m 4.02 KB
Newer Older
1
function initialize_dseries_class()
2

3
% Copyright (C) 2015-2019 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
% Get the path to the dseries toolbox.
19
dseries_src_root = strrep(which('initialize_dseries_class'),'initialize_dseries_class.m','');
20

21 22
% Check that the x13 binary is available
nox13 = false;
23 24
if ismac()
    if ~exist([dseries_src_root '../externals/x13/osx/64/x13as'], 'file')
25 26
        nox13 = true;
    end
27 28 29
elseif isunix()
    [status, ~] = system('which x13as');
    if status && ~(exist([dseries_src_root '../externals/x13/linux/64/x13as'], 'file') && exist([dseries_src_root '../externals/x13/linux/32/x13as'], 'file'))
30 31 32
        nox13 = true;
    end
elseif ispc()
33
    if ~(exist([dseries_src_root '../externals/x13/windows/64/x13as.exe'], 'file') && exist([dseries_src_root '../externals/x13/windows/32/x13as.exe'], 'file'))
34 35 36 37 38 39
        nox13 = true;
    end
else
    error('Unsupported platform.')
end
if nox13
40
    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']);
41 42
end

43
% Set the subfolders to be added in the path.
44 45 46 47 48 49 50 51 52 53 54 55
p = {'read'; ...
     'utilities/is'; ...
     'utilities/op'; ...
     'utilities/convert'; ...
     'utilities/str'; ...
     'utilities/insert'; ...
     'utilities/file'; ...
     'utilities/from'; ...
     'utilities/print'; ...
     'utilities/variables'; ...
     'utilities/cumulate'; ...
     'utilities/struct'};
56

57 58
% Add /utilities/x13' if x13 binary is available.
if ~nox13
59
    p{end+1} = 'utilities/x13';
60 61
end

62
% Add missing routines if dynare is not in the path
63 64 65 66 67
if ~exist('isint','file')
    p{end+1} = 'utilities/missing/isint';
end

if ~exist('isoctave','file')
68
    p{end+1} = 'utilities/missing/isoctave';
69 70 71 72 73 74 75 76 77 78
end

if ~exist('shiftS','file')
    p{end+1} = 'utilities/missing/shiftS';
end

if ~exist('matlab_ver_less_than','file')
    p{end+1} = 'utilities/missing/matlab_ver_less_than';
end

79
if ~exist('demean','file')
80
    p{end+1} = 'utilities/missing/demean';
81 82 83
end

if ~exist('ndim','file')
84 85 86
    p{end+1} = 'utilities/missing/ndim';
end

87
if ~exist('OCTAVE_VERSION') && (~exist('rows','file') || ~exist('columns','file'))
88
    p{end+1} = 'utilities/missing/dims';
89 90 91
end

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

Stéphane Adjemian's avatar
Stéphane Adjemian committed
95
if ~exist('get_file_extension','file')
96
    p{end+1} = 'utilities/missing/get_file_extension';
Stéphane Adjemian's avatar
Stéphane Adjemian committed
97 98
end

99
if exist('OCTAVE_VERSION') && ~exist('user_has_octave_forge_package','file')
100
    p{end+1} = 'utilities/missing/user_has_octave_forge_package';
101
end
102 103

if ~exist('get_cells_id','file')
104
    p{end+1} = 'utilities/missing/get_cells_id';
105 106
end

107
if ~exist('randomstring','file')
108
    p{end+1} = 'utilities/missing/randomstring';
109 110
end

111
if ~exist('one_sided_hp_filter','file')
112
    p{end+1} = 'utilities/missing/one_sided_hp_filter';
113 114
end

115 116 117 118 119 120 121 122 123 124 125 126
if ~exist('ismatrix','file')
    p{end+1} = 'utilities/missing/ismatrix';
end

if ~exist('isrow','file')
    p{end+1} = 'utilities/missing/isrow';
end

if ~exist('iscolumn','file')
    p{end+1} = 'utilities/missing/iscolumn';
end

127 128 129 130 131 132 133 134
if ~exist('strsplit','file')
    p{end+1} = 'utilities/missing/strsplit';
end

if ~exist('strjoin','file')
    p{end+1} = 'utilities/missing/strjoin';
end

135
% Set path
136
P = cellfun(@(c)[dseries_src_root c], p, 'uni', false);
137 138
addpath(P{:});

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