diff --git a/matlab/dynare_config.m b/matlab/dynare_config.m index 2922941fdb441045d43c882098914cb25b3d3d54..90958fd00a8f11e380c1f6d179719c9e65024f44 100644 --- a/matlab/dynare_config.m +++ b/matlab/dynare_config.m @@ -15,7 +15,7 @@ function dynareroot = dynare_config(path_to_dynare,verbose) % SPECIAL REQUIREMENTS % none -% Copyright (C) 2001-2011 Dynare Team +% Copyright (C) 2001-2012 Dynare Team % % This file is part of Dynare. % @@ -70,8 +70,7 @@ if ~exist('OCTAVE_VERSION') addpath([dynareroot '/missing/rows_columns']) % Replacement for vec() (inexistent under MATLAB) addpath([dynareroot '/missing/vec']) - [has_statistics_toolbox junk] = license('checkout','statistics_toolbox'); - if ~has_statistics_toolbox + if ~user_has_matlab_license('statistics_toolbox') % Replacements for functions of the stats toolbox addpath([dynareroot '/missing/stats/']) end @@ -101,8 +100,7 @@ if exist('OCTAVE_VERSION') addpath([dynareroot '/missing/nanmean']) end else - [has_statistics_toolbox junk] = license('checkout','statistics_toolbox'); - if ~has_statistics_toolbox + if ~user_has_matlab_license('statistics_toolbox') addpath([dynareroot '/missing/nanmean']) end end diff --git a/matlab/dynare_solve.m b/matlab/dynare_solve.m index 2f8ad9f591275809b4645bb83ca51931390b4e21..11310e984ea3d0a8dc9b6011b429915d67c7814f 100644 --- a/matlab/dynare_solve.m +++ b/matlab/dynare_solve.m @@ -16,7 +16,7 @@ function [x,info] = dynare_solve(func,x,jacobian_flag,varargin) % SPECIAL REQUIREMENTS % none -% Copyright (C) 2001-2011 Dynare Team +% Copyright (C) 2001-2012 Dynare Team % % This file is part of Dynare. % @@ -39,8 +39,7 @@ options_ = set_default_option(options_,'solve_algo',2); info = 0; if options_.solve_algo == 0 if ~exist('OCTAVE_VERSION') - [has_optimization_toolbox junk] = license('checkout','optimization_toolbox'); - if ~has_optimization_toolbox + if ~user_has_matlab_license('optimization_toolbox') error('You can''t use solve_algo=0 since you don''t have MATLAB''s Optimization Toolbox') end end diff --git a/matlab/solve_one_boundary.m b/matlab/solve_one_boundary.m index 19aa5fcad4e827bd3278a00064f5651254a0535e..8ae660889da51e0721be20eb46eb58a0b5611e8f 100644 --- a/matlab/solve_one_boundary.m +++ b/matlab/solve_one_boundary.m @@ -55,7 +55,7 @@ function [y, info] = solve_one_boundary(fname, y, x, params, steady_state, ... % none. % -% Copyright (C) 1996-2011 Dynare Team +% Copyright (C) 1996-2012 Dynare Team % % This file is part of Dynare. % @@ -225,8 +225,7 @@ for it_=start:incr:finish disp('steady: fsolve'); end if ~exist('OCTAVE_VERSION') - [has_optimization_toolbox junk] = license('checkout','optimization_toolbox'); - if ~has_optimization_toolbox + if ~user_has_matlab_license('optimization_toolbox') error('SOLVE_ONE_BOUNDARY: you can''t use solve_algo=0 since you don''t have MATLAB''s Optimization Toolbox') end end diff --git a/matlab/user_has_matlab_license.m b/matlab/user_has_matlab_license.m new file mode 100644 index 0000000000000000000000000000000000000000..3caf35002fd3530f35e165df5f018b2c4e165b51 --- /dev/null +++ b/matlab/user_has_matlab_license.m @@ -0,0 +1,36 @@ +function [hasLicense] = user_has_matlab_license(toolbox) +%[hasLicense] = user_has_matlab_license(toolbox) +% checks for license using the appropriate function call +% +% INPUTS +% toolbox: string for toolbox name +% +% OUTPUTS +% hasLicense: bool indicating whether or not the user has the license +% +% SPECIAL REQUIREMENTS +% none + +% Copyright (C) 2012 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 matlab_ver_less_than('7.12') + hasLicense = license('test', toolbox); +else + [hasLicense ~] = license('checkout',toolbox); +end +end diff --git a/tests/run_test_matlab.m b/tests/run_test_matlab.m index cd8263c90af145621b8060f86cb846994db876e1..c5a8c0755abc6cd710c7213a0424fcfc204a4b77 100644 --- a/tests/run_test_matlab.m +++ b/tests/run_test_matlab.m @@ -1,4 +1,4 @@ -% Copyright (C) 2011 Dynare Team +% Copyright (C) 2011-2012 Dynare Team % % This file is part of Dynare. % @@ -71,7 +71,7 @@ end failedBlock = {}; num_block_tests = 0; cd([top_test_dir '/block_bytecode']); -[has_optimization_toolbox junk] = license('checkout','optimization_toolbox'); +has_optimization_toolbox = user_has_matlab_license('optimization_toolbox'); for blockFlag = 0:1 for bytecodeFlag = 0:1 default_solve_algo = 2;