diff --git a/matlab/estimation/dynare_estimation_1.m b/matlab/estimation/dynare_estimation_1.m index a2e9ffd8c100a8ce8a4180369dde10be3eeba310..6e2bd2bee0d2b881644be389f367d46fb99acd8e 100644 --- a/matlab/estimation/dynare_estimation_1.m +++ b/matlab/estimation/dynare_estimation_1.m @@ -167,8 +167,7 @@ end try oo_ = initial_estimation_checks(objective_function,xparam1,dataset_,dataset_info,M_,estim_params_,options_,bayestopt_,bounds,oo_); -catch % if check fails, provide info on using calibration if present - e = lasterror(); +catch e % if check fails, provide info on using calibration if present if estim_params_.full_calibration_detected %calibrated model present and no explicit starting values skipline(1); fprintf('ESTIMATION_CHECKS: There was an error in computing the likelihood for initial parameter values.\n') diff --git a/matlab/estimation/dynare_estimation_init.m b/matlab/estimation/dynare_estimation_init.m index 13c1c9e8328ec63c1e0fd124b7b2fbd2f421279f..f025548f5b6468ab5d8cc4c5e31e15dfde22dbb5 100644 --- a/matlab/estimation/dynare_estimation_init.m +++ b/matlab/estimation/dynare_estimation_init.m @@ -30,7 +30,7 @@ function [dataset_, dataset_info, xparam1, hh, M_, options_, oo_, estim_params_, % SPECIAL REQUIREMENTS % none -% Copyright © 2003-2023 Dynare Team +% Copyright © 2003-2024 Dynare Team % % This file is part of Dynare. % @@ -204,8 +204,7 @@ if ~isempty(estim_params_) && ~(all(strcmp(fieldnames(estim_params_),'full_calib if options_.use_calibration_initialization try check_prior_bounds(xparam1,bounds,M_,estim_params_,options_,bayestopt_) - catch - e = lasterror(); + catch e fprintf('Cannot use parameter values from calibration as they violate the prior bounds.') rethrow(e); end diff --git a/matlab/parallel/fParallel.m b/matlab/parallel/fParallel.m index 54dec1cc6cbbbb10f81fc8d66096b5332bbec9e8..0ff7db9de975c5f1580585acd570c16cd4efdc29 100644 --- a/matlab/parallel/fParallel.m +++ b/matlab/parallel/fParallel.m @@ -18,7 +18,7 @@ function fParallel(fblck,nblck,whoiam,ThisMatlab,fname) % OUTPUTS % None % -% Copyright © 2006-2017 Dynare Team +% Copyright © 2006-2024 Dynare Team % % This file is part of Dynare. % @@ -92,8 +92,7 @@ try end disp(['fParallel ',int2str(whoiam),' completed.']) -catch - theerror = lasterror; +catch theerror if strfind(theerror.message,'Master asked to break the job') fOutputVar.message = theerror; save([ fname,'_output_',int2str(whoiam),'.mat'],'fOutputVar' ) diff --git a/matlab/parallel/slaveParallel.m b/matlab/parallel/slaveParallel.m index 1d094e6f0408360c6b8ccf928fd1c17d5a8d00fa..8d463fee71f0d7279ef9c74bef1df292d462a41c 100644 --- a/matlab/parallel/slaveParallel.m +++ b/matlab/parallel/slaveParallel.m @@ -15,7 +15,7 @@ function slaveParallel(whoiam,ThisMatlab) % OUTPUTS % None -% Copyright © 2006-2017 Dynare Team +% Copyright © 2006-2024 Dynare Team % % This file is part of Dynare. % @@ -143,8 +143,7 @@ while (etime(clock,t0)<1200 && ~isempty(fslave)) || ~isempty(dir(['stayalive',in disp(['Job ',fname,' on CPU ',int2str(whoiam),' completed.']); t0 =clock; % Re-set waiting time of 20 mins - catch - theerror = lasterror; + catch theerror if strfind(theerror.message,'Master asked to break the job') disp(['Job ',fname,' on CPU ',int2str(whoiam),' broken from master.']); fOutputVar.message = theerror; @@ -152,7 +151,7 @@ while (etime(clock,t0)<1200 && ~isempty(fslave)) || ~isempty(dir(['stayalive',in delete(['P_',fname,'_',int2str(whoiam),'End.txt']); else disp(['Job ',fname,' on CPU ',int2str(whoiam),' crashed.']); - fOutputVar.error = lasterror; + fOutputVar.error = theerror; save([ fname,'_output_',int2str(whoiam),'.mat'],'fOutputVar' ); waitbarString = fOutputVar.error.message; if Parallel(ThisMatlab).Local diff --git a/matlab/stochastic_solver/AIM_first_order_solver.m b/matlab/stochastic_solver/AIM_first_order_solver.m index 067d554a35ba2617f79b2f03491b18fff597795f..cc664655a6720329865c88aa3127b3daa6d0bdaa 100644 --- a/matlab/stochastic_solver/AIM_first_order_solver.m +++ b/matlab/stochastic_solver/AIM_first_order_solver.m @@ -100,10 +100,9 @@ uprbnd = 1 + 1.e-6; %allow unit roots try % try to run AIM [bb, rts, ~, ~, ~, ~, aimcode] = SPAmalg(g1(:, 1:3*M_.endo_nbr), neq, 1, 1, condn, uprbnd); -catch - err = lasterror; +catch err disp(['Dynare AIM Solver error:' sprintf('%s; ID:%s',err.message, err.identifier)]); - rethrow(lasterror); + rethrow(err); end if aimcode==1 %if OK dr.ghx = bb(dr.order_var, dr.order_var(M_.nstatic+(1:M_.nspred))); diff --git a/matlab/utilities/tests b/matlab/utilities/tests index c5ce7645386c6d2e42a018957e245caa3dc05fde..b484b6e625a8dbca209afb884af2125a0368775c 160000 --- a/matlab/utilities/tests +++ b/matlab/utilities/tests @@ -1 +1 @@ -Subproject commit c5ce7645386c6d2e42a018957e245caa3dc05fde +Subproject commit b484b6e625a8dbca209afb884af2125a0368775c