diff --git a/README.md b/README.md index 46c9dcf65..1b0f72c42 100644 --- a/README.md +++ b/README.md @@ -65,7 +65,7 @@ A number of tools and libraries are needed in order to recompile everything. You - The [GNU Compiler Collection](http://gcc.gnu.org/), with gcc, g++ and gfortran (mandatory) - MATLAB (if you want to compile MEX for MATLAB) - [GNU Octave](http://www.octave.org), with the development headers (if you want to compile MEX for Octave) -- [Boost libraries](http://www.boost.org), version 1.36 or later +- [Boost libraries](http://www.boost.org), version 1.36 or later (with the filesystem library compiled) - [Bison](http://www.gnu.org/software/bison/), version 2.5 or later (only if you get the source through Git) - [Flex](http://flex.sourceforge.net/), version 2.5.4 or later (only if you get the source through Git) - [Autoconf](http://www.gnu.org/software/autoconf/), version 2.62 or later (only if you get the source through Git) (see [Installing an updated version of Autoconf in your own directory, in GNU/Linux](http://www.dynare.org/DynareWiki/AutoMake)) @@ -220,7 +220,7 @@ Alternatively, if you want to build everything, manually install the following p - `build-essential` (for gcc, g++ and make) - `gfortran` - `liboctave-dev` (or `octave3.2-headers` on older systems) -- `libboost-graph-dev` +- `libboost-graph-dev` and `libboost-filesystem-dev` - `libgsl-dev` (or `libgsl0-dev` on older systems) - `libmatio-dev` - `libslicot-dev` and `libslicot-pic` diff --git a/doc/dynare.texi b/doc/dynare.texi index e02beae15..1382de4e4 100644 --- a/doc/dynare.texi +++ b/doc/dynare.texi @@ -97,7 +97,7 @@ @c %**end of header @copying -Copyright @copyright{} 1996-2017, Dynare Team. +Copyright @copyright{} 1996-2018, Dynare Team. @quotation Permission is granted to copy, distribute and/or modify this document @@ -778,30 +778,21 @@ file. By default (unless @code{use_dll} option has been given to @table @file -@item @var{FILENAME}.m +@item +@var{FILENAME}/driver.m Contains variable declarations, and computing tasks -@item @var{FILENAME}_dynamic.m +@item +@var{FILENAME}/dynamic.m @vindex M_.lead_lag_incidence Contains the dynamic model equations. Note that Dynare might introduce auxiliary equations and variables (@pxref{Auxiliary variables}). Outputs are the residuals of the dynamic model equations in the order the equations were declared and the Jacobian of the dynamic model equations. For higher order approximations also the Hessian and the third-order derivatives are provided. When computing the Jacobian of the dynamic model, the order of the endogenous variables in the columns is stored in @code{M_.lead_lag_incidence}. The rows of this matrix represent time periods: the first row denotes a lagged (time t-1) variable, the second row a contemporaneous (time t) variable, and the third row a leaded (time t+1) variable. The columns of the matrix represent the endogenous variables in their order of declaration. A zero in the matrix means that this endogenous does not appear in the model in this time period. The value in the @code{M_.lead_lag_incidence} matrix corresponds to the column of that variable in the Jacobian of the dynamic model. Example: Let the second declared variable be @code{c} and the @code{(3,2)} entry of @code{M_.lead_lag_incidence} be @code{15}. Then the @code{15}th column of the Jacobian is the derivative with respect to @code{c(+1)}. -@item @var{FILENAME}_static.m +@item +@var{FILENAME}/static.m Contains the long run static model equations. Note that Dynare might introduce auxiliary equations and variables (@pxref{Auxiliary variables}). Outputs are the residuals of the static model equations in the order the equations were declared and the Jacobian of the static equations. Entry @code{(i,j)} of the Jacobian represents the derivative of the @code{i}th static model equation with respect to the @code{j}th model variable in declaration order. @end table @noindent These files may be looked at to understand errors reported at the simulation stage. -@code{dynare} will then run the computing tasks by executing @file{@var{FILENAME}.m}. - -A few words of warning is warranted here: the filename of the -@file{.mod} file should be chosen in such a way that the generated -@file{.m} files described above do not conflict with @file{.m} files -provided by MATLAB/Octave or by Dynare. Not respecting this rule could -cause crashes or unexpected behaviour. In particular, it means that -the @file{.mod} file cannot be given the name of a MATLAB/Octave or -Dynare command. Under Octave, it also means that the @file{.mod} file -cannot be named @file{test.mod}. +@code{dynare} will then run the computing tasks by executing @file{+@var{FILENAME}/driver.m}. @optionshead @@ -875,16 +866,16 @@ Suppresses all warnings. @item json=parse|transform|compute Causes the preprocessor to output a version of the @file{.mod} file in JSON format. If @code{parse} is passed, the output will be written after the parsing -of the @file{.mod} file to a file called @file{@var{FILENAME}.json}. If +of the @file{.mod} file to a file called @file{@var{FILENAME}/model/json/modfile.json}. If @code{transform} is passed, the JSON output of the transformed model (maximum lead of 1, minimum lag of -1, expectation operators substituted, etc.) will be -written to a file called @file{@var{FILENAME}.json} and the original, -untransformed model will be written in @file{@var{FILENAME}_original.json}. And +written to a file called @file{@var{FILENAME}/model/json/modfile.json} and the original, +untransformed model will be written in @file{@var{FILENAME}/model/json/modfile-original.json}. And if @code{compute} is passed, the output is written after the computing pass. In -this case, the transformed model is written to @file{@var{FILENAME}.json}, the -original model is written to @file{@var{FILENAME}_original.json}, and the -dynamic and static files are written to @file{@var{FILENAME}_dynamic.json} and -@file{@var{FILENAME}_static.json}. +this case, the transformed model is written to @file{@var{FILENAME}/model/json/modfile.json}, the +original model is written to @file{@var{FILENAME}/model/json/model-original.json}, and the +dynamic and static files are written to @file{@var{FILENAME}/model/json/dynamic.json} and +@file{@var{FILENAME}/model/json/static.json}. @item jsonstdout Instead of writing output requested by @ref{json} to files, write to standard @@ -895,8 +886,8 @@ Quit processing once the output requested by @ref{json} has been written. @item jsonderivsimple Print a simplified version (excluding variable name(s) and lag information) of the -static and dynamic files in @file{@var{FILENAME}_static.json} and -@file{@var{FILENAME}_dynamic.json}. +static and dynamic files in @file{@var{FILENAME}/model/json/static.json} and +@file{@var{FILENAME}/model/json/dynamic.json}. @item warn_uninit Display a warning for each variable or parameter which is not @@ -1634,22 +1625,34 @@ model_local_variable GDP_US $GDPUS$; @subsection On-the-fly Model Variable Declaration Endogenous variables, exogenous variables, and parameters can also be declared -inside the model block. To do this, simply follow the symbol name with a -vertical line (@code{|}) and either an @code{e}, an @code{x}, or a -@code{p}. For example, to declare a parameter named @code{alphaa} in the model -block, you could write @code{alphaa|p} directly in an equation where it -appears. Similarly, to declare an endogenous variable @code{c} in the model -block you could write @code{c|e}. These on-the-fly variable declarations do not -have to appear in the first place where this variable is encountered. Note that +inside the model block. You can do this in two different ways: either via the +equation tag or directly in an equation. + +To declare a variable on-the-fly in an equation tag, simply state the type of +variable to be declared (@code{endogenous}, @code{exogenous}, or +@code{parameter} followed by an equal sign and the variable name in single +quotes. Hence, to declare a variable @code{c} as endogenous in an equation tag, +you can type @code{[endogenous='c']}. + +To perform on-the-fly variable declaration in an equtaion, simply follow the +symbol name with a vertical line (@code{|}) and either an @code{e}, an +@code{x}, or a @code{p}. For example, to declare a parameter named +@code{alphaa} in the model block, you could write @code{alphaa|p} directly in +an equation where it appears. Similarly, to declare an endogenous variable +@code{c} in the model block you could write @code{c|e}. Note that in-equation on-the-fly variable declarations must be made on contemporaneous variables. +On-the-fly variable declarations do not have to appear in the first place where +this variable is encountered. + As an example, the following two snippets are equivalent: @emph{Using on-the-fly variable and parameter declaration} @example model; +[endogenous='k',name='law of motion of capital'] k(+1) = i|e + (1-delta|p)*k; -y|e = k|e^alpha|p; +y|e = k^alpha|p; @dots{} end; delta = 0.025; @@ -1664,6 +1667,7 @@ delta = 0.025; alpha = 0.36; @dots{} model; +[name='law of motion of capital'] k(1) = i|e + (1-delta|p)*k; y|e = k|e^alpha|p; @dots{} @@ -3601,7 +3605,7 @@ is described below in more details. See also @file{fs2000.mod} in the @file{examples} directory for an example. The steady state file generated by Dynare will be called -@file{@var{FILENAME}_steadystate2.m}. +@file{+@var{FILENAME}/steadystate.m}. @item You can write the corresponding MATLAB function by hand. If your @@ -10838,8 +10842,8 @@ strings. It is possible to construct macro-expressions which can be assigned to macro-variables or used within a macro-directive. The expressions are -constructed using literals of the four basic types (integers, strings, -arrays of strings, arrays of integers), macro-variables names and +constructed using literals of five basic types (integers, strings, arrays of +strings, arrays of integers, and string functions), macro-variable names, and standard operators. String literals have to be enclosed between @strong{double} quotes @@ -10902,6 +10906,14 @@ getting the length of an array: @code{length} operator (for example: @code{[1,2,3]}) @end itemize +The following operators can be used on string functions: +@itemize +@item +comparison operators: @code{==}, @code{!=} +@item +concatenation of two strings: @code{+} +@end itemize + Macro-expressions can be used at two places: @itemize @item @@ -10957,16 +10969,18 @@ file will be searched for in the folders provided by @ref{-I} and @end deffn @deffn {Macro directive} @@#define @var{MACRO_VARIABLE} = @var{MACRO_EXPRESSION} -Defines a macro-variable. +Defines a macro-variable or macro-function @customhead{Example 1} @example -@@#define x = 5 // Integer -@@#define y = "US" // String -@@#define v = [ 1, 2, 4 ] // Integer array -@@#define w = [ "US", "EA" ] // String array -@@#define z = 3 + v[2] // Equals 5 -@@#define t = ("US" in w) // Equals 1 (true) +@@#define x = 5 // Integer +@@#define y = "US" // String +@@#define v = [ 1, 2, 4 ] // Integer array +@@#define w = [ "US", "EA" ] // String array +@@#define z = 3 + v[2] // Equals 5 +@@#define t = ("US" in w) // Equals 1 (true) +@@#define f(x) = " + @@@{x@} + @@@{y@}" // Defines a function 'f' with argument 'x' + // that returns the string: ' + @@@{x@} + US' @end example @customhead{Example 2} @@ -10974,15 +10988,16 @@ Defines a macro-variable. @example @@#define x = [ "B", "C" ] @@#define i = 2 +@@#define f(x) = " + @@@{x@}" model; - A = @@@{x[i]@}; + A = @@@{x[i] + f("D")@}; end; @end example is strictly equivalent to: @example model; - A = C; + A = C + D; end; @end example diff --git a/matlab/PosteriorIRF.m b/matlab/PosteriorIRF.m index d77eab871..6f6deb913 100644 --- a/matlab/PosteriorIRF.m +++ b/matlab/PosteriorIRF.m @@ -233,16 +233,16 @@ else 'dataset_info',dataset_info); % which files have to be copied to run remotely - NamFileInput(1,:) = {'',[M_.fname '_static.m']}; - NamFileInput(2,:) = {'',[M_.fname '_dynamic.m']}; + NamFileInput(1,:) = {'',[M_.fname '.static.m']}; + NamFileInput(2,:) = {'',[M_.fname '.dynamic.m']}; if M_.set_auxiliary_variables - NamFileInput(3,:) = {'',[M_.fname '_set_auxiliary_variables.m']}; + NamFileInput(3,:) = {'',[M_.fname '.set_auxiliary_variables.m']}; end if options_.steadystate_flag if options_.steadystate_flag == 1 NamFileInput(length(NamFileInput)+1,:)={'',[M_.fname '_steadystate.m']}; else - NamFileInput(length(NamFileInput)+1,:)={'',[M_.fname '_steadystate2.m']}; + NamFileInput(length(NamFileInput)+1,:)={'',[M_.fname '.steadystate.m']}; end end [fout] = masterParallel(options_.parallel, 1, B,NamFileInput,'PosteriorIRF_core1', localVars, globalVars, options_.parallel_info); diff --git a/matlab/backward/backward_model_inversion.m b/matlab/backward/backward_model_inversion.m index d9ed0d0ae..fe4ae5152 100644 --- a/matlab/backward/backward_model_inversion.m +++ b/matlab/backward/backward_model_inversion.m @@ -82,7 +82,7 @@ ModelInversion.x_free_id = freeinnovations_id; ModelInversion.J_id = [ModelInversion.y_free_id ; sum(DynareModel.lead_lag_incidence(:)>0)+ModelInversion.x_free_id]; % Get the name of the dynamic model routines. -model_dynamic = str2func([DynareModel.fname,'_dynamic']); +model_dynamic = str2func([DynareModel.fname,'.dynamic']); model_dtransf = str2func('dynamic_backward_model_for_inversion'); % Initialization of the returned simulations (endogenous variables). diff --git a/matlab/backward/calibrateresiduals.m b/matlab/backward/calibrateresiduals.m index e69148418..3eeb8b82a 100644 --- a/matlab/backward/calibrateresiduals.m +++ b/matlab/backward/calibrateresiduals.m @@ -36,7 +36,7 @@ function [residuals, info] = calibrateresiduals(dbase, info, DynareModel) % along with Dynare. If not, see . % Get function handle for the dynamic model -model_dynamic = str2func([DynareModel.fname,'_dynamic']); +model_dynamic = str2func([DynareModel.fname,'.dynamic']); % Get data for all the endogenous variables. ydata = dbase{info.endonames{:}}.data; diff --git a/matlab/backward/checkdatabase.m b/matlab/backward/checkdatabase.m index e0b7a3b3a..d58f16a7b 100644 --- a/matlab/backward/checkdatabase.m +++ b/matlab/backward/checkdatabase.m @@ -31,7 +31,7 @@ if nargin<3 inversionflag = false; end -set_auxiliary_series = [DynareModel.fname '_dynamic_set_auxiliary_series']; +set_auxiliary_series = [DynareModel.fname '.dynamic_set_auxiliary_series']; if exist([set_auxiliary_series '.m']) dbase = feval(set_auxiliary_series, dbase, DynareModel.params); diff --git a/matlab/backward/simul_backward_model_init.m b/matlab/backward/simul_backward_model_init.m index c32bdbbcd..4ed3a554e 100644 --- a/matlab/backward/simul_backward_model_init.m +++ b/matlab/backward/simul_backward_model_init.m @@ -203,7 +203,7 @@ if nargout>8 idx = 1:DynareModel.endo_nbr; jdx = idx+ny1; % Get the name of the dynamic model routine. - model_dynamic = str2func([DynareModel.fname,'_dynamic']); + model_dynamic = str2func([DynareModel.fname,'.dynamic']); % initialization of vector y. y = NaN(length(idx)+ny1,1); end \ No newline at end of file diff --git a/matlab/block_mfs_steadystate.m b/matlab/block_mfs_steadystate.m index 8cbce053a..a0793e674 100644 --- a/matlab/block_mfs_steadystate.m +++ b/matlab/block_mfs_steadystate.m @@ -21,5 +21,5 @@ function [r, g1] = block_mfs_steadystate(y, b, y_all, exo, params, M) y_all(M.block_structure_stat.block(b).variable) = y; -eval(['[r,g1] = ' M.fname '_static(b, y_all, exo, params);']); +eval(['[r,g1] = ' M.fname '.static(b, y_all, exo, params);']); g1 = full(g1); diff --git a/matlab/default_option_values.m b/matlab/default_option_values.m index 8ed89071b..d5fa2da16 100644 --- a/matlab/default_option_values.m +++ b/matlab/default_option_values.m @@ -77,7 +77,7 @@ options_.threads.local_state_space_iteration_2 = 1; options_.jacobian_flag = 1; % steady state file -if exist([M_.fname '_steadystate2.m'],'file') +if exist(['+' M_.fname '/steadystate.m'],'file') options_.steadystate_flag = 2; elseif exist([M_.fname '_steadystate.m'],'file') options_.steadystate_flag = 1; diff --git a/matlab/discretionary_policy_1.m b/matlab/discretionary_policy_1.m index 7e472585e..a88e2bbaa 100644 --- a/matlab/discretionary_policy_1.m +++ b/matlab/discretionary_policy_1.m @@ -66,7 +66,7 @@ if options_.steadystate_flag [junk,M_.params,info] = evaluate_steady_state_file(oo_.steady_state,[oo_.exo_steady_state; oo_.exo_det_steady_state],M_, ... options_,0); end -[U,Uy,W] = feval([M_.fname,'_objective_static'],zeros(endo_nbr,1),[], M_.params); +[U,Uy,W] = feval([M_.fname,'.objective.static'],zeros(endo_nbr,1),[], M_.params); if any(any(Uy~=0)) non_zero_derivs=find(any(Uy~=0)); for ii=1:length(non_zero_derivs) @@ -94,7 +94,7 @@ if exo_nbr == 0 oo_.exo_steady_state = [] ; end -[junk,jacobia_] = feval([M_.fname '_dynamic'],z, [zeros(size(oo_.exo_simul)) ... +[junk,jacobia_] = feval([M_.fname '.dynamic'],z, [zeros(size(oo_.exo_simul)) ... oo_.exo_det_simul], M_.params, zeros(endo_nbr,1), it_); if any(junk~=0) error(['discretionary_policy: the model must be written in deviation ' ... diff --git a/matlab/dr_block.m b/matlab/dr_block.m index 00b07f796..5dfec5722 100644 --- a/matlab/dr_block.m +++ b/matlab/dr_block.m @@ -73,7 +73,7 @@ end if (options_.bytecode) [chck, zz, data]= bytecode('dynamic','evaluate', z, zx, M_.params, dr.ys, 1, data); else - [r, data] = feval([M_.fname '_dynamic'], options_, M_, oo_, z', zx, M_.params, dr.ys, M_.maximum_lag+1, data); + [r, data] = feval([M_.fname '.dynamic'], options_, M_, oo_, z', zx, M_.params, dr.ys, M_.maximum_lag+1, data); chck = 0; end mexErrCheck('bytecode', chck); diff --git a/matlab/dyn_ramsey_static.m b/matlab/dyn_ramsey_static.m index c6005c48b..c1ef18e05 100644 --- a/matlab/dyn_ramsey_static.m +++ b/matlab/dyn_ramsey_static.m @@ -135,7 +135,7 @@ xx(1:M.orig_endo_nbr) = x(1:M.orig_endo_nbr); %set values of original endogenous if any([M.aux_vars.type] ~= 6) %auxiliary variables other than multipliers needs_set_auxiliary_variables = 1; if M.set_auxiliary_variables - fh = str2func([M.fname '_set_auxiliary_variables']); + fh = str2func([M.fname '.set_auxiliary_variables']); s_a_v_func = @(z) fh(z,... [oo.exo_steady_state,... oo.exo_det_steady_state],... @@ -150,7 +150,7 @@ end % value and Jacobian of objective function ex = zeros(1,M.exo_nbr); -[U,Uy,Uyy] = feval([fname '_objective_static'],x,ex, params); +[U,Uy,Uyy] = feval([fname '.objective.static'],x,ex, params); Uyy = reshape(Uyy,endo_nbr,endo_nbr); % set multipliers and auxiliary variables that @@ -160,7 +160,7 @@ if (options_.bytecode) params, 'evaluate'); fJ = junk.g1; else - [res,fJ] = feval([fname '_static'],xx,[oo.exo_steady_state oo.exo_det_steady_state], ... + [res,fJ] = feval([fname '.static'],xx,[oo.exo_steady_state oo.exo_det_steady_state], ... params); end % index of multipliers and corresponding equations @@ -197,7 +197,7 @@ if (options_.bytecode) [chck, res, junk] = bytecode('static',ys,[oo.exo_steady_state oo.exo_det_steady_state], ... M.params, 'evaluate'); else - res = feval([M.fname '_static'],ys,[oo.exo_steady_state oo.exo_det_steady_state], ... + res = feval([M.fname '.static'],ys,[oo.exo_steady_state oo.exo_det_steady_state], ... M.params); end if norm(res) < options_.solve_tolf diff --git a/matlab/dyn_risky_steadystate_solver.m b/matlab/dyn_risky_steadystate_solver.m index 2325e7ad0..a17e21326 100644 --- a/matlab/dyn_risky_steadystate_solver.m +++ b/matlab/dyn_risky_steadystate_solver.m @@ -160,7 +160,7 @@ end z = repmat(ys,1,3); z = z(iyr0) ; -[resid1,d1,d2] = feval([M.fname '_dynamic'],z,... +[resid1,d1,d2] = feval([M.fname '.dynamic'],z,... [oo.exo_simul ... oo.exo_det_simul], M.params, dr.ys, 2); if ~isreal(d1) || ~isreal(d2) @@ -204,7 +204,7 @@ v_np = pm.v_np; % assumed portfolio dr.ys(v_p) = x; ys0 = dr.ys(v_np); -f_h =str2func([M.fname '_static']); +f_h =str2func([M.fname '.static']); [dr.ys(v_np),info] = csolve(@ds_static_model,ys0,[],1e-10,100,f_h,x,pm.eq_np,v_np,v_p, ... M.endo_nbr,M.exo_nbr,M.params); if info @@ -220,7 +220,7 @@ iyr0 = find(iyv) ; z = repmat(dr.ys,1,3); z = z(iyr0) ; -[resid1,d1,d2] = feval([M.fname '_dynamic'],z,... +[resid1,d1,d2] = feval([M.fname '.dynamic'],z,... [oo.exo_simul ... oo.exo_det_simul], M.params, dr.ys, 2); if ~isreal(d1) || ~isreal(d2) @@ -253,7 +253,7 @@ ys(pm.v_p) = x; z = repmat(ys,1,3); z = z(iyr0) ; -[resid1,d1,d2] = feval([M.fname '_dynamic'],z,... +[resid1,d1,d2] = feval([M.fname '.dynamic'],z,... [oo.exo_simul ... oo.exo_det_simul], M.params, dr.ys, 2); if ~isreal(d1) || ~isreal(d2) @@ -294,7 +294,7 @@ end z = repmat(ys,1,3); z = z(iyr0) ; -[resid1,d1,d2] = feval([M.fname '_dynamic'],z,... +[resid1,d1,d2] = feval([M.fname '.dynamic'],z,... [oo.exo_simul ... oo.exo_det_simul], M.params, dr.ys, 2); @@ -329,7 +329,7 @@ resid = resid1+0.5*(d1(:,i_fwrd_f1)*ghuu(i_fwrd_g,:)+d2(:,i_fwrd_f2)* ... kron(gu1,gu1))*vec(M.Sigma_e); if nargout > 1 - [resid1,d1,d2,d3] = feval([M.fname '_dynamic'],z,... + [resid1,d1,d2,d3] = feval([M.fname '.dynamic'],z,... [oo.exo_simul ... oo.exo_det_simul], M.params, dr.ys, 2); diff --git a/matlab/dynare.m b/matlab/dynare.m index e04d24d79..369c43b9c 100644 --- a/matlab/dynare.m +++ b/matlab/dynare.m @@ -137,7 +137,7 @@ else fnamelength = length(fname) - 4; end -if fnamelength + length('_set_auxiliary_variables') > namelengthmax() +if fnamelength + length('.set_auxiliary_variables') > namelengthmax() error('The name of your MOD file is too long, please shorten it') end @@ -283,4 +283,9 @@ end if ~ isempty(find(abs(fname) == 46)) fname = fname(:,1:find(abs(fname) == 46)-1) ; end -evalin('base',fname) ; + +% We need to clear the driver (and only the driver, because the "clear all" +% within the driver will clean the rest) +clear(['+' fname '/driver']) + +evalin('base',[fname '.driver']) ; diff --git a/matlab/dynare_solve_block_or_bytecode.m b/matlab/dynare_solve_block_or_bytecode.m index 2a1f547b9..c995c93c7 100644 --- a/matlab/dynare_solve_block_or_bytecode.m +++ b/matlab/dynare_solve_block_or_bytecode.m @@ -36,7 +36,7 @@ if options.block && ~options.bytecode ss(M.block_structure_stat.block(b).variable) = y; else n = length(M.block_structure_stat.block(b).variable); - [ss, check] = solve_one_boundary([M.fname '_static_' int2str(b)], ss, exo, ... + [ss, check] = solve_one_boundary([M.fname '.block.static_' int2str(b)], ss, exo, ... params, [], M.block_structure_stat.block(b).variable, n, 1, 0, b, 0, options.simul.maxit, ... options.solve_tolf, ... options.slowc, 0, options.solve_algo, 1, 0, 0,M,options); @@ -46,7 +46,7 @@ if options.block && ~options.bytecode end end end - [r, g1, x] = feval([M.fname '_static'], b, ss, ... + [r, g1, x] = feval([M.fname '.static'], b, ss, ... exo, params); end elseif options.bytecode diff --git a/matlab/ep/euler_equation_error.m b/matlab/ep/euler_equation_error.m index 7496852fb..ea2f6a934 100644 --- a/matlab/ep/euler_equation_error.m +++ b/matlab/ep/euler_equation_error.m @@ -17,7 +17,7 @@ function e = euler_equation_error(y0,x,innovations,M,options,oo,pfm,nodes,weight % You should have received a copy of the GNU General Public License % along with Dynare. If not, see . -dynamic_model = str2func([M.fname '_dynamic']); +dynamic_model = str2func([M.fname '.dynamic']); ep = options.ep; [y1, info_convergence, endogenousvariablespaths] = extended_path_core(ep.periods, ... M.endo_nbr, M.exo_nbr, ... diff --git a/matlab/ep/setup_stochastic_perfect_foresight_model_solver.m b/matlab/ep/setup_stochastic_perfect_foresight_model_solver.m index 732714d4a..55e4d8a82 100644 --- a/matlab/ep/setup_stochastic_perfect_foresight_model_solver.m +++ b/matlab/ep/setup_stochastic_perfect_foresight_model_solver.m @@ -66,7 +66,7 @@ else end pfm.i_cols_j = 1:pfm.nd; pfm.i_upd = pfm.ny+(1:pfm.periods*pfm.ny); -pfm.dynamic_model = str2func([DynareModel.fname,'_dynamic']); +pfm.dynamic_model = str2func([DynareModel.fname,'.dynamic']); pfm.verbose = DynareOptions.ep.verbosity; pfm.maxit_ = DynareOptions.simul.maxit; pfm.tolerance = DynareOptions.dynatol.f; diff --git a/matlab/evaluate_planner_objective.m b/matlab/evaluate_planner_objective.m index d94e15b64..fe65a47d9 100644 --- a/matlab/evaluate_planner_objective.m +++ b/matlab/evaluate_planner_objective.m @@ -49,7 +49,7 @@ gu(dr.order_var,:) = dr.ghu; ys = oo.dr.ys; -[U,Uy,Uyy] = feval([M.fname '_objective_static'],ys,zeros(1,exo_nbr), ... +[U,Uy,Uyy] = feval([M.fname '.objective.static'],ys,zeros(1,exo_nbr), ... M.params); %second order terms Uyy = full(Uyy); diff --git a/matlab/evaluate_static_model.m b/matlab/evaluate_static_model.m index ecf7ebb39..d15005aa2 100644 --- a/matlab/evaluate_static_model.m +++ b/matlab/evaluate_static_model.m @@ -43,7 +43,7 @@ if options.bytecode exo_ss, params, ys, 1); mexErrCheck('bytecode', check1); else - fh_static = str2func([M.fname '_static']); + fh_static = str2func([M.fname '.static']); if options.block residuals = zeros(M.endo_nbr,1); for b = 1:length(M.block_structure_stat.block) diff --git a/matlab/evaluate_steady_state.m b/matlab/evaluate_steady_state.m index 4e67441b7..7b35ffce9 100644 --- a/matlab/evaluate_steady_state.m +++ b/matlab/evaluate_steady_state.m @@ -47,7 +47,7 @@ params = M.params; exo_ss = [oo.exo_steady_state; oo.exo_det_steady_state]; if length(M.aux_vars) > 0 && ~steadystate_flag - h_set_auxiliary_variables = str2func([M.fname '_set_auxiliary_variables']); + h_set_auxiliary_variables = str2func([M.fname '.set_auxiliary_variables']); if M.set_auxiliary_variables ys_init = h_set_auxiliary_variables(ys_init,exo_ss,M.params); end @@ -219,7 +219,7 @@ elseif steadystate_flag elseif (options.bytecode == 0 && options.block == 0) if options.linear == 0 % non linear model - static_model = str2func([M.fname '_static']); + static_model = str2func([M.fname '.static']); [ys,check] = dynare_solve(@static_problem,... ys_init,... options, exo_ss, params,... @@ -247,7 +247,7 @@ elseif (options.bytecode == 0 && options.block == 0) end else % linear model - fh_static = str2func([M.fname '_static']); + fh_static = str2func([M.fname '.static']); [fvec,jacob] = fh_static(ys_init,exo_ss, ... params); @@ -312,12 +312,12 @@ if M.static_and_dynamic_models_differ [chck, r, junk]= bytecode('dynamic','evaluate', z, zx, M.params, ys, 1); mexErrCheck('bytecode', chck); elseif options.block - [r, oo.dr] = feval([M.fname '_dynamic'], z', zx, M.params, ys, M.maximum_lag+1, oo.dr); + [r, oo.dr] = feval([M.fname '.dynamic'], z', zx, M.params, ys, M.maximum_lag+1, oo.dr); else iyv = M.lead_lag_incidence'; iyr0 = find(iyv(:)); xys = z(iyr0); - r = feval([M.fname '_dynamic'], z(iyr0), zx, M.params, ys, M.maximum_lag + 1); + r = feval([M.fname '.dynamic'], z(iyr0), zx, M.params, ys, M.maximum_lag + 1); end % Fail if residual greater than tolerance if max(abs(r)) > options.solve_tolf diff --git a/matlab/evaluate_steady_state_file.m b/matlab/evaluate_steady_state_file.m index be84e6f39..cbb0e63db 100644 --- a/matlab/evaluate_steady_state_file.m +++ b/matlab/evaluate_steady_state_file.m @@ -53,7 +53,7 @@ if options.steadystate_flag == 1 params1 = evalin('base','M_.params'); else % steadystate_flag == 2 % new format - h_steadystate = str2func([fname '_steadystate2']); + h_steadystate = str2func([fname '.steadystate']); [ys,params1,check] = h_steadystate(ys_init, exo_ss, params); end @@ -75,7 +75,7 @@ if M.set_auxiliary_variables % variables only if the model has auxiliary variables. Otherwise % Octave may crash (see https://savannah.gnu.org/bugs/?52568) because % the function does not exist in the path. - h_set_auxiliary_variables = str2func([M.fname '_set_auxiliary_variables']); + h_set_auxiliary_variables = str2func([M.fname '.set_auxiliary_variables']); end if isnan(updated_params_flag) || (updated_params_flag && any(isnan(params(~isnan(params))-params1(~isnan(params))))) %checks if new NaNs were added diff --git a/matlab/ff1_.m b/matlab/ff1_.m index 1ed766d95..22a186fee 100644 --- a/matlab/ff1_.m +++ b/matlab/ff1_.m @@ -33,5 +33,5 @@ global it_ M_ oo_ n1 = size(x,1) - M_.exo_nbr; oo_.exo_simul(it_+M_.maximum_lag-M_.maximum_lag,:) = x(n1+1:end)'; -fh = str2func([M_.fname '_static']); +fh = str2func([M_.fname '.static']); y=feval(fh,x(1:n1),oo_.exo_simul, M_.params); diff --git a/matlab/getH.m b/matlab/getH.m index 3491e6422..1e79d9941 100644 --- a/matlab/getH.m +++ b/matlab/getH.m @@ -124,7 +124,7 @@ end if kronflag==-2 if nargout>5 - [residual, g1, g2 ] = feval([M_.fname,'_dynamic'],yy0, oo_.exo_steady_state', ... + [residual, g1, g2 ] = feval([M_.fname,'.dynamic'],yy0, oo_.exo_steady_state', ... M_.params, oo_.dr.ys, 1); g22 = hessian_sparse('thet2tau',[M_.params(indx)],options_.gstep,estim_params_,M_, oo_, indx,[],-1); H2ss=full(g22(1:M_.endo_nbr,:)); @@ -144,7 +144,7 @@ if kronflag==-2 g22 = gx22; clear gx22; else - [residual, g1 ] = feval([M_.fname,'_dynamic'],yy0, oo_.exo_steady_state', ... + [residual, g1 ] = feval([M_.fname,'.dynamic'],yy0, oo_.exo_steady_state', ... M_.params, oo_.dr.ys, 1); end gp = fjaco('thet2tau',[M_.params(indx)],estim_params_,M_, oo_, indx,[],-1); @@ -154,17 +154,17 @@ if kronflag==-2 else dyssdtheta=zeros(length(oo_.dr.ys),M_.param_nbr); d2yssdtheta=zeros(length(oo_.dr.ys),M_.param_nbr,M_.param_nbr); - [residual, gg1] = feval([M_.fname,'_static'],oo_.dr.ys, oo_.exo_steady_state', M_.params); - df = feval([M_.fname,'_static_params_derivs'],oo_.dr.ys, repmat(oo_.exo_steady_state',[M_.maximum_exo_lag+M_.maximum_exo_lead+1]), ... + [residual, gg1] = feval([M_.fname,'.static'],oo_.dr.ys, oo_.exo_steady_state', M_.params); + df = feval([M_.fname,'.static_params_derivs'],oo_.dr.ys, repmat(oo_.exo_steady_state',[M_.maximum_exo_lag+M_.maximum_exo_lead+1]), ... M_.params); dyssdtheta = -gg1\df; if nargout>5 - [residual, gg1, gg2] = feval([M_.fname,'_static'],oo_.dr.ys, oo_.exo_steady_state', M_.params); - [residual, g1, g2, g3] = feval([M_.fname,'_dynamic'],yy0, oo_.exo_steady_state', ... + [residual, gg1, gg2] = feval([M_.fname,'.static'],oo_.dr.ys, oo_.exo_steady_state', M_.params); + [residual, g1, g2, g3] = feval([M_.fname,'.dynamic'],yy0, oo_.exo_steady_state', ... M_.params, oo_.dr.ys, 1); [nr, nc]=size(gg2); - [df, gpx, d2f] = feval([M_.fname,'_static_params_derivs'],oo_.dr.ys, oo_.exo_steady_state', ... + [df, gpx, d2f] = feval([M_.fname,'.static_params_derivs'],oo_.dr.ys, oo_.exo_steady_state', ... M_.params);%, oo_.dr.ys, 1, dyssdtheta*0, d2yssdtheta); d2f = get_all_resid_2nd_derivs(d2f,length(oo_.dr.ys),M_.param_nbr); if isempty(find(gg2)) @@ -201,13 +201,13 @@ else end end if nargout>5 - [df, gp, d2f, gpp, hp] = feval([M_.fname,'_params_derivs'],yy0, oo_.exo_steady_state', ... + [df, gp, d2f, gpp, hp] = feval([M_.fname,'.dynamic_params_derivs'],yy0, oo_.exo_steady_state', ... M_.params, oo_.dr.ys, 1, dyssdtheta, d2yssdtheta); H2ss = d2yssdtheta(oo_.dr.order_var,indx,indx); else - [df, gp] = feval([M_.fname,'_params_derivs'],yy0, repmat(oo_.exo_steady_state',[M_.maximum_exo_lag+M_.maximum_exo_lead+1,1]), ... + [df, gp] = feval([M_.fname,'.dynamic_params_derivs'],yy0, repmat(oo_.exo_steady_state',[M_.maximum_exo_lag+M_.maximum_exo_lead+1,1]), ... M_.params, oo_.dr.ys, 1, dyssdtheta,d2yssdtheta); - [residual, g1, g2 ] = feval([M_.fname,'_dynamic'],yy0, repmat(oo_.exo_steady_state',[M_.maximum_exo_lag+M_.maximum_exo_lead+1,1]), ... + [residual, g1, g2 ] = feval([M_.fname,'.dynamic'],yy0, repmat(oo_.exo_steady_state',[M_.maximum_exo_lag+M_.maximum_exo_lead+1,1]), ... M_.params, oo_.dr.ys, 1); end diff --git a/matlab/graph_decomp.m b/matlab/graph_decomp.m index 81e971693..7b150a5da 100644 --- a/matlab/graph_decomp.m +++ b/matlab/graph_decomp.m @@ -52,7 +52,7 @@ fig_name_long = opts_decomp.fig_name; use_shock_groups = DynareOptions.plot_shock_decomp.use_shock_groups; screen_shocks = opts_decomp.screen_shocks; -if use_shock_groups | comp_nbr<=18 +if ~isempty(use_shock_groups) || comp_nbr<=18 screen_shocks=0; end if use_shock_groups @@ -189,7 +189,7 @@ for j=1:nvar hold on ht = text(0.3,y1+0.3*height,labels(i,:),'Interpreter','none'); hold on - if interactive & (~isoctave & use_shock_groups) + if interactive && (~isoctave && ~isempty(use_shock_groups)) mydata.fig_name = DynareOptions.plot_shock_decomp.fig_name(2:end); mydata.use_shock_groups = DynareOptions.plot_shock_decomp.use_shock_groups; mydata.shock_group = shock_groups.(shock_ind{i}); diff --git a/matlab/graph_decomp_detail.m b/matlab/graph_decomp_detail.m index 70dc4d640..2605dbac3 100644 --- a/matlab/graph_decomp_detail.m +++ b/matlab/graph_decomp_detail.m @@ -52,7 +52,7 @@ if ~isempty(opts_decomp.type) fig_mode = [fig_mode '_']; end screen_shocks = opts_decomp.screen_shocks; -if DynareOptions.plot_shock_decomp.use_shock_groups | comp_nbr<=18 +if ~isempty(DynareOptions.plot_shock_decomp.use_shock_groups) || comp_nbr<=18 screen_shocks=0; end fig_name_long = opts_decomp.fig_name; @@ -166,7 +166,7 @@ for j=1:nvar ineg=zz<0; hax = subplot(nrow,ncol,i); set(gca,'box','on') hbar = bar(x(2:end),(zz.*ipos)','stacked','FaceColor','flat'); - if ~matlab_ver_less_than('9.3.0') + if ~isoctave && ~matlab_ver_less_than('9.3.0') % make bar obey colormap under MATLAB R2017b for k = 1:2 hbar(k).CData = k; @@ -175,7 +175,7 @@ for j=1:nvar set(hbar,'edgecolor','flat'); hold on, hbar = bar(x(2:end),(zz.*ineg)','stacked','FaceColor','flat'); - if ~matlab_ver_less_than('9.3.0') + if ~isoctave && ~matlab_ver_less_than('9.3.0') % make bar obey colormap under MATLAB R2017b for k = 1:2 hbar(k).CData = k; @@ -191,7 +191,7 @@ for j=1:nvar a0(4)=max(a(4),a0(4)); set(gca,'ylim',a0(3:4)) hold on, h1=plot(x(2:end),z1(end,:),'k-','LineWidth',2); - if interactive & (~isoctave & use_shock_groups) + if interactive && (~isoctave && ~isempty(use_shock_groups)) mydata.fig_name = DynareOptions.plot_shock_decomp.fig_name(2:end); mydata.use_shock_groups = DynareOptions.plot_shock_decomp.use_shock_groups; mydata.shock_group = shock_groups.(shock_ind{ic}); diff --git a/matlab/identification_analysis.m b/matlab/identification_analysis.m index 768bc5b31..bc4d8ad86 100644 --- a/matlab/identification_analysis.m +++ b/matlab/identification_analysis.m @@ -77,7 +77,7 @@ if info(1)==0 oo0=oo_; tau=[oo_.dr.ys(oo_.dr.order_var); vec(A); dyn_vech(B*M_.Sigma_e*B')]; yy0=oo_.dr.ys(I); - [residual, g1 ] = feval([M_.fname,'_dynamic'],yy0, ... + [residual, g1 ] = feval([M_.fname,'.dynamic'],yy0, ... repmat(oo_.exo_steady_state',[M_.maximum_exo_lag+M_.maximum_exo_lead+1]), M_.params, ... oo_.dr.ys, 1); vg1 = [oo_.dr.ys(oo_.dr.order_var); vec(g1)]; diff --git a/matlab/lmmcp/dyn_lmmcp.m b/matlab/lmmcp/dyn_lmmcp.m index 39ed96d89..94af7671d 100644 --- a/matlab/lmmcp/dyn_lmmcp.m +++ b/matlab/lmmcp/dyn_lmmcp.m @@ -54,7 +54,7 @@ i_upd = ny+(1:periods*ny); x = endo_simul(:); -model_dynamic = str2func([M.fname,'_dynamic']); +model_dynamic = str2func([M.fname,'.dynamic']); z = x(find(lead_lag_incidence')); [res,A] = model_dynamic(z, exo_simul, params, steady_state,2); nnzA = nnz(A); diff --git a/matlab/model_diagnostics.m b/matlab/model_diagnostics.m index 21084ead7..e8f5ff81c 100644 --- a/matlab/model_diagnostics.m +++ b/matlab/model_diagnostics.m @@ -115,7 +115,7 @@ for b=1:nb int2str(b)]); end else - [res,jacob]=feval([M.fname '_static'],dr.ys,exo,M.params); + [res,jacob]=feval([M.fname '.static'],dr.ys,exo,M.params); end if any(any(isinf(jacob) | isnan(jacob))) problem_dummy=1; @@ -208,7 +208,7 @@ if ~options.block M.params, dr.ys, 1); jacobia_ = [loc_dr.g1 loc_dr.g1_x loc_dr.g1_xd]; else - [junk,jacobia_] = feval([M.fname '_dynamic'],z(iyr0),exo_simul, ... + [junk,jacobia_] = feval([M.fname '.dynamic'],z(iyr0),exo_simul, ... M.params, dr.ys, it_); end elseif options.order >= 2 @@ -217,7 +217,7 @@ if ~options.block M.params, dr.ys, 1); jacobia_ = [loc_dr.g1 loc_dr.g1_x]; else - [junk,jacobia_,hessian1] = feval([M.fname '_dynamic'],z(iyr0),... + [junk,jacobia_,hessian1] = feval([M.fname '.dynamic'],z(iyr0),... exo_simul, ... M.params, dr.ys, it_); end diff --git a/matlab/occbin/evaluate_model.m b/matlab/occbin/evaluate_model.m index f01d58a08..59172cf09 100644 --- a/matlab/occbin/evaluate_model.m +++ b/matlab/occbin/evaluate_model.m @@ -5,15 +5,15 @@ y = z(find(ll(:))); switch nargout case 1 - r = feval([M.fname '_dynamic'],y,x, ... + r = feval([M.fname '.dynamic'],y,x, ... M.params, ss, 1); case 2 - [r,g1] = feval([M.fname '_dynamic'],y,x, ... + [r,g1] = feval([M.fname '.dynamic'],y,x, ... M.params, ss, 1); case 3 - [r,g1,g2] = feval([M.fname '_dynamic'],y,x, ... + [r,g1,g2] = feval([M.fname '.dynamic'],y,x, ... M.params, ss, 1); case 4 - [r,g1,g2,g3] = feval([M.fname '_dynamic'],y,x, ... + [r,g1,g2,g3] = feval([M.fname '.dynamic'],y,x, ... M.params, ss, 1); end \ No newline at end of file diff --git a/matlab/occbin/get_deriv.m b/matlab/occbin/get_deriv.m index 214b1cf42..1b671c28b 100755 --- a/matlab/occbin/get_deriv.m +++ b/matlab/occbin/get_deriv.m @@ -44,11 +44,11 @@ y = [y;ys_(lea_cols)]; if ismac - eval(['[resid,g1]=',M_.fname,'_dynamic(y,x, M_.params, ys_, it_);']); + eval(['[resid,g1]=',M_.fname,'.dynamic(y,x, M_.params, ys_, it_);']); % Older versions of DYNARE for Mac did not include ys_ in the call structure - %eval(['[resid,g1]=',M_.fname,'_dynamic(y,x, M_.params, it_);']); + %eval(['[resid,g1]=',M_.fname,'.dynamic(y,x, M_.params, it_);']); else - eval(['[resid,g1]=',M_.fname,'_dynamic(y,x, M_.params, ys_, it_);']); + eval(['[resid,g1]=',M_.fname,'.dynamic(y,x, M_.params, ys_, it_);']); end diff --git a/matlab/partial_information/PCL_resol.m b/matlab/partial_information/PCL_resol.m index 8f6bf4239..a9e7fc01b 100644 --- a/matlab/partial_information/PCL_resol.m +++ b/matlab/partial_information/PCL_resol.m @@ -65,7 +65,7 @@ end dr.ys = ys; check1 = 0; % testing for steadystate file -fh = str2func([M_.fname '_static']); +fh = str2func([M_.fname '.static']); if options_.steadystate_flag [dr.ys,check1] = feval([M_.fname '_steadystate'],dr.ys,... [oo_.exo_steady_state; ... diff --git a/matlab/partial_information/add_auxiliary_variables_to_steadystate.m b/matlab/partial_information/add_auxiliary_variables_to_steadystate.m index f90e7f6b0..e1ffe4f19 100644 --- a/matlab/partial_information/add_auxiliary_variables_to_steadystate.m +++ b/matlab/partial_information/add_auxiliary_variables_to_steadystate.m @@ -27,7 +27,7 @@ for i=1:n+1 [exo_steady_state; ... exo_det_steady_state],params); else - res = feval([fname '_static'],ys1,... + res = feval([fname '.static'],ys1,... [exo_steady_state; ... exo_det_steady_state],params); end diff --git a/matlab/partial_information/dr1_PI.m b/matlab/partial_information/dr1_PI.m index a7f82d3c0..b8bf5b36d 100644 --- a/matlab/partial_information/dr1_PI.m +++ b/matlab/partial_information/dr1_PI.m @@ -130,7 +130,7 @@ else z = repmat(dr.ys,1,klen); end z = z(iyr0) ; - [junk,jacobia_] = feval([M_.fname '_dynamic'],z,[oo_.exo_simul ... + [junk,jacobia_] = feval([M_.fname '.dynamic'],z,[oo_.exo_simul ... oo_.exo_det_simul], M_.params, dr.ys, it_); if options_.ACES_solver==1 && (length(sim_ruleids)>0 || length(tct_ruleids)>0 ) diff --git a/matlab/perfect-foresight-models/det_cond_forecast.m b/matlab/perfect-foresight-models/det_cond_forecast.m index a7945cbea..1e4fe53ad 100644 --- a/matlab/perfect-foresight-models/det_cond_forecast.m +++ b/matlab/perfect-foresight-models/det_cond_forecast.m @@ -475,7 +475,7 @@ if pf && ~surprise if (options_.bytecode) [chck, zz, data1]= bytecode('dynamic','evaluate', z, zx, M_.params, oo_.steady_state, k, data1); else - [zz, g1b] = feval([M_.fname '_dynamic'], z', zx, M_.params, oo_.steady_state, k); + [zz, g1b] = feval([M_.fname '.dynamic'], z', zx, M_.params, oo_.steady_state, k); data1.g1_x = g1b(:,end - M_.exo_nbr + 1:end); data1.g1 = g1b(:,1 : end - M_.exo_nbr); chck = 0; @@ -747,7 +747,7 @@ else if (options_.bytecode) [chck, zz, data1]= bytecode('dynamic','evaluate', z, zx, M_.params, oo_.steady_state, k, data1); else - [zz, g1b] = feval([M_.fname '_dynamic'], z', zx, M_.params, oo_.steady_state, k); + [zz, g1b] = feval([M_.fname '.dynamic'], z', zx, M_.params, oo_.steady_state, k); data1.g1_x = g1b(:,end - M_.exo_nbr + 1:end); data1.g1 = g1b(:,1 : end - M_.exo_nbr); chck = 0; diff --git a/matlab/perfect-foresight-models/linear_approximation_accuracy.m b/matlab/perfect-foresight-models/linear_approximation_accuracy.m index 289997176..691ca19b3 100644 --- a/matlab/perfect-foresight-models/linear_approximation_accuracy.m +++ b/matlab/perfect-foresight-models/linear_approximation_accuracy.m @@ -39,7 +39,7 @@ params = M_.params; endo_simul = oo_.endo_simul; exo_simul = oo_.exo_simul; -model_dynamic = str2func([M_.fname,'_dynamic']); +model_dynamic = str2func([M_.fname,'.dynamic']); residuals = zeros(ny,periods); diff --git a/matlab/perfect-foresight-models/perfect_foresight_simulation.m b/matlab/perfect-foresight-models/perfect_foresight_simulation.m index 15f1b8b76..568e9de24 100644 --- a/matlab/perfect-foresight-models/perfect_foresight_simulation.m +++ b/matlab/perfect-foresight-models/perfect_foresight_simulation.m @@ -41,7 +41,7 @@ persistent lead_lag_incidence dynamic_model ny nyp nyf nrs nrc iyf iyp isp is is if ~nargin && isempty(iflag)% Initialization of the persistent variables. lead_lag_incidence = M_.lead_lag_incidence; - dynamic_model = [M_.fname '_dynamic']; + dynamic_model = [M_.fname '.dynamic']; ny = size(oo_.endo_simul,1); nyp = nnz(lead_lag_incidence(1,:));% number of lagged variables. nyf = nnz(lead_lag_incidence(3,:));% number of leaded variables. diff --git a/matlab/perfect-foresight-models/perfect_foresight_solver.m b/matlab/perfect-foresight-models/perfect_foresight_solver.m index 64e77a8fc..c770a630a 100644 --- a/matlab/perfect-foresight-models/perfect_foresight_solver.m +++ b/matlab/perfect-foresight-models/perfect_foresight_solver.m @@ -40,7 +40,7 @@ end options_.scalv= 1; if options_.debug - model_static = str2func([M_.fname,'_static']); + model_static = str2func([M_.fname,'.static']); for ii=1:size(oo_.exo_simul,1) [residual(:,ii)] = model_static(oo_.steady_state, oo_.exo_simul(ii,:),M_.params); end @@ -183,7 +183,7 @@ if ~isreal(oo_.endo_simul(:)) %can only happen without bytecode illi = illi(:,2:3); [i_cols_J1,junk,i_cols_1] = find(illi(:)); i_cols_T = nonzeros(M_.lead_lag_incidence(1:2,:)'); - residuals = perfect_foresight_problem(yy(:),str2func([M_.fname '_dynamic']), y0, yT, ... + residuals = perfect_foresight_problem(yy(:),str2func([M_.fname '.dynamic']), y0, yT, ... oo_.exo_simul,M_.params,oo_.steady_state, ... M_.maximum_lag,options_.periods,M_.endo_nbr,i_cols, ... i_cols_J1, i_cols_1, i_cols_T, i_cols_j, ... diff --git a/matlab/perfect-foresight-models/perfect_foresight_solver_core.m b/matlab/perfect-foresight-models/perfect_foresight_solver_core.m index 272cd3833..e20c9faf6 100644 --- a/matlab/perfect-foresight-models/perfect_foresight_solver_core.m +++ b/matlab/perfect-foresight-models/perfect_foresight_solver_core.m @@ -58,7 +58,7 @@ if options_.block mexErrCheck('bytecode', info); end else - oo_ = feval([M_.fname '_dynamic'], options_, M_, oo_); + oo_ = feval([M_.fname '.dynamic'], options_, M_, oo_); end else if options_.bytecode @@ -134,7 +134,7 @@ if nargout>1 if options_.bytecode [chck, residuals, junk]= bytecode('dynamic','evaluate', oo_.endo_simul, oo_.exo_simul, M_.params, oo_.steady_state, 1); else - residuals = perfect_foresight_problem(yy(:),str2func([M_.fname '_dynamic']), y0, yT, ... + residuals = perfect_foresight_problem(yy(:),str2func([M_.fname '.dynamic']), y0, yT, ... oo_.exo_simul,M_.params,oo_.steady_state, ... M_.maximum_lag,options_.periods,M_.endo_nbr,i_cols, ... i_cols_J1, i_cols_1, i_cols_T, i_cols_j, ... diff --git a/matlab/perfect-foresight-models/private/initialize_stacked_problem.m b/matlab/perfect-foresight-models/private/initialize_stacked_problem.m index 0f14b2367..1a8f61838 100644 --- a/matlab/perfect-foresight-models/private/initialize_stacked_problem.m +++ b/matlab/perfect-foresight-models/private/initialize_stacked_problem.m @@ -75,4 +75,4 @@ illi = M.lead_lag_incidence'; illi = illi(:,2:3); [i_cols_J1, junk,i_cols_1] = find(illi(:)); i_cols_T = nonzeros(M.lead_lag_incidence(1:2,:)'); -dynamicmodel = str2func([M.fname,'_dynamic']); \ No newline at end of file +dynamicmodel = str2func([M.fname,'.dynamic']); \ No newline at end of file diff --git a/matlab/perfect-foresight-models/private/simulation_core.m b/matlab/perfect-foresight-models/private/simulation_core.m index 0c944c2a6..61f6693a4 100644 --- a/matlab/perfect-foresight-models/private/simulation_core.m +++ b/matlab/perfect-foresight-models/private/simulation_core.m @@ -43,7 +43,7 @@ if options_.block mexErrCheck('bytecode', info); end else - oo_ = feval([M_.fname '_dynamic'], options_, M_, oo_); + oo_ = feval([M_.fname '.dynamic'], options_, M_, oo_); end else if options_.bytecode @@ -110,7 +110,7 @@ if nargout>1 if options_.bytecode [chck, residuals, junk]= bytecode('dynamic','evaluate', oo_.endo_simul, oo_.exo_simul, M_.params, oo_.steady_state, 1); else - residuals = perfect_foresight_problem(yy(:),str2func([M_.fname '_dynamic']), y0, yT, ... + residuals = perfect_foresight_problem(yy(:),str2func([M_.fname '.dynamic']), y0, yT, ... oo_.exo_simul,M_.params,oo_.steady_state, ... M_.maximum_lag,options_.periods,M_.endo_nbr,i_cols, ... i_cols_J1, i_cols_1, i_cols_T, i_cols_j, ... diff --git a/matlab/perfect-foresight-models/sim1.m b/matlab/perfect-foresight-models/sim1.m index 9adf2e9b1..243f076fc 100644 --- a/matlab/perfect-foresight-models/sim1.m +++ b/matlab/perfect-foresight-models/sim1.m @@ -76,7 +76,7 @@ if verbose skipline() end -model_dynamic = str2func([M.fname,'_dynamic']); +model_dynamic = str2func([M.fname,'.dynamic']); z = Y(find(lead_lag_incidence')); [d1,jacobian] = model_dynamic(z, exogenousvariables, params, steadystate,maximum_lag+1); diff --git a/matlab/perfect-foresight-models/sim1_lbj.m b/matlab/perfect-foresight-models/sim1_lbj.m index a9b585907..f46adf370 100644 --- a/matlab/perfect-foresight-models/sim1_lbj.m +++ b/matlab/perfect-foresight-models/sim1_lbj.m @@ -48,7 +48,7 @@ isf1 = [nyp+ny+1:nyf+nyp+ny+1]; stop = false; iz = [1:ny+nyp+nyf]; -dynamicmodel = sprintf('%s_dynamic', M.fname); +dynamicmodel = sprintf('%s.dynamic', M.fname); verbose = options.verbosity; diff --git a/matlab/perfect-foresight-models/sim1_linear.m b/matlab/perfect-foresight-models/sim1_linear.m index 1f64e55c7..3fa40bf41 100644 --- a/matlab/perfect-foresight-models/sim1_linear.m +++ b/matlab/perfect-foresight-models/sim1_linear.m @@ -107,7 +107,7 @@ if verbose skipline() end -dynamicmodel = str2func([M.fname,'_dynamic']); +dynamicmodel = str2func([M.fname,'.dynamic']); z = steadystate_y([ip; ic; in]); x = repmat(transpose(steadystate_x), 1+M.maximum_exo_lag+M.maximum_exo_lead, 1); diff --git a/matlab/perfect-foresight-models/sim1_purely_backward.m b/matlab/perfect-foresight-models/sim1_purely_backward.m index a2ec8db13..91e76bf45 100644 --- a/matlab/perfect-foresight-models/sim1_purely_backward.m +++ b/matlab/perfect-foresight-models/sim1_purely_backward.m @@ -34,7 +34,7 @@ if ny0 ~= M.endo_nbr error('All endogenous variables must appear at the current period!') end -dynamicmodel = str2func([M.fname,'_dynamic']); +dynamicmodel = str2func([M.fname,'.dynamic']); info.status = 1; diff --git a/matlab/perfect-foresight-models/sim1_purely_forward.m b/matlab/perfect-foresight-models/sim1_purely_forward.m index 31cd12b77..256d64727 100644 --- a/matlab/perfect-foresight-models/sim1_purely_forward.m +++ b/matlab/perfect-foresight-models/sim1_purely_forward.m @@ -25,7 +25,7 @@ if ny0 ~= M.endo_nbr error('All endogenous variables must appear at the current period!') end -dynamicmodel = str2func([M.fname,'_dynamic']); +dynamicmodel = str2func([M.fname,'.dynamic']); info.status = 1; diff --git a/matlab/posterior_sampler.m b/matlab/posterior_sampler.m index ea19c320d..62e8ccfe6 100644 --- a/matlab/posterior_sampler.m +++ b/matlab/posterior_sampler.m @@ -125,16 +125,16 @@ else % Global variables for parallel routines. globalVars = struct(); % which files have to be copied to run remotely - NamFileInput(1,:) = {'',[ModelName '_static.m']}; - NamFileInput(2,:) = {'',[ModelName '_dynamic.m']}; + NamFileInput(1,:) = {'',[ModelName '.static.m']}; + NamFileInput(2,:) = {'',[ModelName '.dynamic.m']}; if M_.set_auxiliary_variables - NamFileInput(3,:) = {'',[M_.fname '_set_auxiliary_variables.m']}; + NamFileInput(3,:) = {'',[M_.fname '.set_auxiliary_variables.m']}; end if options_.steadystate_flag if options_.steadystate_flag == 1 NamFileInput(length(NamFileInput)+1,:)={'',[M_.fname '_steadystate.m']}; else - NamFileInput(length(NamFileInput)+1,:)={'',[M_.fname '_steadystate2.m']}; + NamFileInput(length(NamFileInput)+1,:)={'',[M_.fname '.steadystate.m']}; end end if (options_.load_mh_file~=0) && any(fline>1) diff --git a/matlab/prior_posterior_statistics.m b/matlab/prior_posterior_statistics.m index 501d26e35..2c5bd93a5 100644 --- a/matlab/prior_posterior_statistics.m +++ b/matlab/prior_posterior_statistics.m @@ -292,16 +292,16 @@ else 'estim_params_', estim_params_, ... 'oo_', oo_); % which files have to be copied to run remotely - NamFileInput(1,:) = {'',[M_.fname '_static.m']}; - NamFileInput(2,:) = {'',[M_.fname '_dynamic.m']}; + NamFileInput(1,:) = {'',[M_.fname '.static.m']}; + NamFileInput(2,:) = {'',[M_.fname '.dynamic.m']}; if M.set_auxiliary_variables - NamFileInput(3,:) = {'',[M_.fname '_set_auxiliary_variables.m']}; + NamFileInput(3,:) = {'',[M_.fname '.set_auxiliary_variables.m']}; end if options_.steadystate_flag if options_.steadystate_flag == 1 NamFileInput(length(NamFileInput)+1,:)={'',[M_.fname '_steadystate.m']}; else - NamFileInput(length(NamFileInput)+1,:)={'',[M_.fname '_steadystate2.m']}; + NamFileInput(length(NamFileInput)+1,:)={'',[M_.fname '.steadystate.m']}; end end [fout] = masterParallel(options_.parallel, 1, B,NamFileInput,'prior_posterior_statistics_core', localVars,globalVars, options_.parallel_info); diff --git a/matlab/resid.m b/matlab/resid.m index 4b6e3721b..716c9c5b3 100644 --- a/matlab/resid.m +++ b/matlab/resid.m @@ -70,7 +70,7 @@ end if options_.block && ~options_.bytecode z = zeros(M_.endo_nbr,1); for i = 1:length(M_.block_structure_stat.block) - [r, g, yy, var_indx] = feval([M_.fname '_static'],... + [r, g, yy, var_indx] = feval([M_.fname '.static'],... i,... oo_.steady_state,... [oo_.exo_steady_state; ... @@ -82,7 +82,7 @@ elseif options_.bytecode [check, z] = bytecode('evaluate','static'); mexErrCheck('bytecode', check); else - z = feval([M_.fname '_static'],... + z = feval([M_.fname '.static'],... oo_.steady_state,... [oo_.exo_steady_state; ... oo_.exo_det_steady_state], M_.params); diff --git a/matlab/restricted_steadystate.m b/matlab/restricted_steadystate.m index d68299281..7ef100293 100644 --- a/matlab/restricted_steadystate.m +++ b/matlab/restricted_steadystate.m @@ -25,7 +25,7 @@ ss = oo_.steady_state; ss(indx) = y; -eval(['[R,G] = ' M_.fname '_static(ss, x, M_.params);']); +eval(['[R,G] = ' M_.fname '.static(ss, x, M_.params);']); sR = R(inde); sG = G(inde,indx); \ No newline at end of file diff --git a/matlab/stochastic_solvers.m b/matlab/stochastic_solvers.m index 587641023..a3004899a 100644 --- a/matlab/stochastic_solvers.m +++ b/matlab/stochastic_solvers.m @@ -115,7 +115,7 @@ if local_order == 1 M_.params, dr.ys, 1); jacobia_ = [loc_dr.g1 loc_dr.g1_x loc_dr.g1_xd]; else - [junk,jacobia_] = feval([M_.fname '_dynamic'],z(iyr0),exo_simul, ... + [junk,jacobia_] = feval([M_.fname '.dynamic'],z(iyr0),exo_simul, ... M_.params, dr.ys, it_); end elseif local_order == 2 @@ -124,7 +124,7 @@ elseif local_order == 2 M_.params, dr.ys, 1); jacobia_ = [loc_dr.g1 loc_dr.g1_x]; else - [junk,jacobia_,hessian1] = feval([M_.fname '_dynamic'],z(iyr0),... + [junk,jacobia_,hessian1] = feval([M_.fname '.dynamic'],z(iyr0),... exo_simul, ... M_.params, dr.ys, it_); end diff --git a/matlab/thet2tau.m b/matlab/thet2tau.m index 965934e3d..742f85b59 100644 --- a/matlab/thet2tau.m +++ b/matlab/thet2tau.m @@ -50,7 +50,7 @@ if flagmoments==0 elseif flagmoments==-1 [I,J]=find(M_.lead_lag_incidence'); yy0=oo_.dr.ys(I); - [residual, g1] = feval([M_.fname,'_dynamic'],yy0, oo_.exo_steady_state', ... + [residual, g1] = feval([M_.fname,'.dynamic'],yy0, oo_.exo_steady_state', ... M_.params, oo_.dr.ys, 1); tau=[oo_.dr.ys(oo_.dr.order_var); g1(:)]; diff --git a/matlab/utilities/general/dyn_mex.m b/matlab/utilities/general/dyn_mex.m index ec682aebb..f20f1fb0a 100644 --- a/matlab/utilities/general/dyn_mex.m +++ b/matlab/utilities/general/dyn_mex.m @@ -32,8 +32,8 @@ function dyn_mex(win_compiler,basename,force) % You should have received a copy of the GNU General Public License % along with Dynare. If not, see . -Dc = dir([basename '_dynamic.c']); -Dmex = dir([basename '_dynamic.' mexext]); +Dc = dir([basename '/mode/src/dynamic.c']); +Dmex = dir(['+' basename '/model/dynamic.' mexext]); % compile only if date of C file is greater than date of mex file % and force is not True @@ -50,19 +50,19 @@ if ~exist('OCTAVE_VERSION') if strcmp(win_compiler,'msvc') % MATLAB/Windows + Microsoft Visual C++ % Add /TP flag as fix for #1227 - eval(['mex -O LINKFLAGS="$LINKFLAGS /export:Dynamic" COMPFLAGS="/TP" ' basename '_dynamic.c ' basename '_dynamic_mex.c']) - eval(['mex -O LINKFLAGS="$LINKFLAGS /export:Static" COMPFLAGS="/TP" ' basename '_static.c ' basename '_static_mex.c']) + eval(['mex -O LINKFLAGS="$LINKFLAGS /export:Dynamic" COMPFLAGS="/TP" ' basename '/model/src/dynamic.c ' basename '/model/src/dynamic_mex.c -output +' basename '/dynamic']) + eval(['mex -O LINKFLAGS="$LINKFLAGS /export:Static" COMPFLAGS="/TP" ' basename '/model/src/static.c ' basename '/model/src/static_mex.c -output +' basename '/static']) elseif strcmp(win_compiler,'mingw') - eval(['mex -O LINKFLAGS="$LINKFLAGS /export:Dynamic" ' basename '_dynamic.c ' basename '_dynamic_mex.c']) - eval(['mex -O LINKFLAGS="$LINKFLAGS /export:Static" ' basename '_static.c ' basename '_static_mex.c']) + eval(['mex -O LINKFLAGS="$LINKFLAGS /export:Dynamic" ' basename '/model/src/dynamic.c ' basename '/model/src/dynamic_mex.c -output +' basename '/dynamic']) + eval(['mex -O LINKFLAGS="$LINKFLAGS /export:Static" ' basename '/model/src/static.c ' basename '/model/src/static_mex.c -output +' basename '/static']) elseif strcmp(win_compiler,'cygwin') %legacy support for Cygwin with mexopts.bat % MATLAB/Windows + Cygwin g++ eval(['mex -O PRELINK_CMDS1="echo EXPORTS > mex.def & echo ' ... 'mexFunction >> mex.def & echo Dynamic >> mex.def" ' ... - basename '_dynamic.c ' basename '_dynamic_mex.c']) + basename '/model/src/dynamic.c ' basename '/model/src/dynamic_mex.c -output +' basename '/dynamic']) eval(['mex -O PRELINK_CMDS1="echo EXPORTS > mex.def & echo ' ... 'mexFunction >> mex.def & echo Dynamic >> mex.def" ' ... - basename '_static.c ' basename '_static_mex.c']) + basename '/model/src/static.c ' basename '/model/src/static_mex.c -output +' basename '/static']) else error(['When using the USE_DLL option, you must give either ' ... '''cygwin'', ''mingw'' or ''msvc'' option to the ''dynare'' command']) @@ -71,15 +71,15 @@ if ~exist('OCTAVE_VERSION') % MATLAB/Linux if matlab_ver_less_than('8.3') eval(['mex -O LDFLAGS=''-pthread -shared -Wl,--no-undefined'' ' ... - basename '_dynamic.c ' basename '_dynamic_mex.c']) + basename '/model/src/dynamic.c ' basename '/model/src/dynamic_mex.c -output +' basename '/dynamic']) eval(['mex -O LDFLAGS=''-pthread -shared -Wl,--no-undefined'' ' ... - basename '_static.c ' basename '_static_mex.c']) + basename '/model/src/static.c ' basename '/model/src/static_mex.c -output +' basename '/static']) elseif matlab_ver_less_than('9.1') - eval(['mex -O LINKEXPORT='''' ' basename '_dynamic.c ' basename '_dynamic_mex.c']) - eval(['mex -O LINKEXPORT='''' ' basename '_static.c ' basename '_static_mex.c']) + eval(['mex -O LINKEXPORT='''' ' basename '/model/src/dynamic.c ' basename '/model/src/dynamic_mex.c -output +' basename '/dynamic']) + eval(['mex -O LINKEXPORT='''' ' basename '/model/src/static.c ' basename '/model/src/static_mex.c -output +' basename '/static']) else - eval(['mex -O LINKEXPORTVER='''' ' basename '_dynamic.c ' basename '_dynamic_mex.c']) - eval(['mex -O LINKEXPORTVER='''' ' basename '_static.c ' basename '_static_mex.c']) + eval(['mex -O LINKEXPORTVER='''' ' basename '/model/src/dynamic.c ' basename '/model/src/dynamic_mex.c -output +' basename '/dynamic']) + eval(['mex -O LINKEXPORTVER='''' ' basename '/model/src/static.c ' basename '/model/src/static_mex.c -output +' basename '/static']) end elseif ismac % MATLAB/MacOS @@ -87,30 +87,30 @@ if ~exist('OCTAVE_VERSION') eval(['mex -O LDFLAGS=''-Wl,-twolevel_namespace -undefined ' ... 'error -arch $ARCHS -Wl,-syslibroot,$SDKROOT ' ... '-mmacosx-version-min=$MACOSX_DEPLOYMENT_TARGET -bundle'' ' ... - basename '_dynamic.c ' basename '_dynamic_mex.c']) + basename '/model/src/dynamic.c ' basename '/model/src/dynamic_mex.c -output +' basename '/dynamic']) eval(['mex -O LDFLAGS=''-Wl,-twolevel_namespace -undefined ' ... 'error -arch $ARCHS -Wl,-syslibroot,$SDKROOT ' ... '-mmacosx-version-min=$MACOSX_DEPLOYMENT_TARGET -bundle'' ' ... - basename '_static.c ' basename '_static_mex.c']) + basename '/model/src/static.c ' basename '/model/src/static_mex.c -output +' basename '/static']) elseif matlab_ver_less_than('8.3') eval(['mex -O LDFLAGS=''-Wl,-twolevel_namespace -undefined ' ... 'error -arch $ARCHS -Wl,-syslibroot,$MW_SDKROOT ' ... '-mmacosx-version-min=$MACOSX_DEPLOYMENT_TARGET -bundle'' ' ... - basename '_dynamic.c ' basename '_dynamic_mex.c']) + basename '/model/src/dynamic.c ' basename '/model/src/dynamic_mex.c -output +' basename '/dynamic']) eval(['mex -O LDFLAGS=''-Wl,-twolevel_namespace -undefined ' ... 'error -arch $ARCHS -Wl,-syslibroot,$MW_SDKROOT ' ... '-mmacosx-version-min=$MACOSX_DEPLOYMENT_TARGET -bundle'' ' ... - basename '_static.c ' basename '_static_mex.c']) + basename '/model/src/static.c ' basename '/model/src/static_mex.c -output +' basename '/static']) elseif matlab_ver_less_than('9.1') - eval(['mex -O LINKEXPORT='''' ' basename '_dynamic.c ' basename '_dynamic_mex.c']) - eval(['mex -O LINKEXPORT='''' ' basename '_static.c ' basename '_static_mex.c']) + eval(['mex -O LINKEXPORT='''' ' basename '/model/src/dynamic.c ' basename '/model/src/dynamic_mex.c -output +' basename '/dynamic']) + eval(['mex -O LINKEXPORT='''' ' basename '/model/src/static.c ' basename '/model/src/static_mex.c -output +' basename '/static']) else - eval(['mex -O LINKEXPORT='''' LINKEXPORTVER='''' ' basename '_dynamic.c ' basename '_dynamic_mex.c']) - eval(['mex -O LINKEXPORT='''' LINKEXPORTVER='''' ' basename '_static.c ' basename '_static_mex.c']) + eval(['mex -O LINKEXPORT='''' LINKEXPORTVER='''' ' basename '/model/src/dynamic.c ' basename '/model/src/dynamic_mex.c -output +' basename '/dynamic']) + eval(['mex -O LINKEXPORT='''' LINKEXPORTVER='''' ' basename '/model/src/static.c ' basename '/model/src/static_mex.c -output +' basename '/static']) end end else % Octave - eval(['mex ' basename '_dynamic.c ' basename '_dynamic_mex.c']) - eval(['mex ' basename '_static.c ' basename '_static_mex.c']) + eval(['mex ' basename '/model/src/dynamic.c ' basename '/model/src/dynamic_mex.c -o +' basename '/dynamic']) + eval(['mex ' basename '/model/src/static.c ' basename '/model/src/static_mex.c -o +' basename '/static']) end diff --git a/mex/build/matlab/configure.ac b/mex/build/matlab/configure.ac index 40e93d6f8..ef87b0fdb 100644 --- a/mex/build/matlab/configure.ac +++ b/mex/build/matlab/configure.ac @@ -48,9 +48,6 @@ case ${host_os} in AC_MSG_WARN([not run from MATLAB, because it cannot load the Cygwin DLL.]) AC_MSG_WARN([This is probably not what you want. Consider using a MinGW cross-compiler.]) ;; - *darwin13*) - CXXFLAGS="$CXXFLAGS -std=c++11" - ;; esac CFLAGS="$CFLAGS -Wall -Wno-parentheses" @@ -76,6 +73,9 @@ case ${host_os} in # Also see CFLAGS="$CFLAGS -include stdint.h -Dchar16_t=uint_least16_t" ;; + *darwin*) + CXXFLAGS="$CXXFLAGS -stdlib=libc++" + ;; esac AX_PTHREAD diff --git a/mex/sources/bytecode/Interpreter.cc b/mex/sources/bytecode/Interpreter.cc index 1c36f5a86..bb986cff8 100644 --- a/mex/sources/bytecode/Interpreter.cc +++ b/mex/sources/bytecode/Interpreter.cc @@ -577,9 +577,9 @@ void Interpreter::ReadCodeFile(string file_name, CodeLoad &code) { if (steady_state) - file_name += "_static"; + file_name += "/model/bytecode/static"; else - file_name += "_dynamic"; + file_name += "/model/bytecode/dynamic"; //First read and store in memory the code code_liste = code.get_op_code(file_name); @@ -587,7 +587,7 @@ Interpreter::ReadCodeFile(string file_name, CodeLoad &code) if (!code_liste.size()) { ostringstream tmp; - tmp << " in compute_blocks, " << file_name.c_str() << " cannot be opened\n"; + tmp << " in compute_blocks, " << file_name << ".cod cannot be opened\n"; throw FatalExceptionHandling(tmp.str()); } if (block >= (int) code.get_block_number()) diff --git a/mex/sources/bytecode/SparseMatrix.cc b/mex/sources/bytecode/SparseMatrix.cc index 1ef1239a6..2e4feb90c 100644 --- a/mex/sources/bytecode/SparseMatrix.cc +++ b/mex/sources/bytecode/SparseMatrix.cc @@ -524,23 +524,22 @@ dynSparseMatrix::Read_SparseMatrix(string file_name, const int Size, int periods { unsigned int eq, var; int lag; - filename = file_name; mem_mngr.fixe_file_name(file_name); /*mexPrintf("steady_state=%d, size=%d, solve_algo=%d, stack_solve_algo=%d, two_boundaries=%d\n",steady_state, Size, solve_algo, stack_solve_algo, two_boundaries); mexEvalString("drawnow;");*/ if (!SaveCode.is_open()) { if (steady_state) - SaveCode.open((file_name + "_static.bin").c_str(), ios::in | ios::binary); + SaveCode.open(file_name + "/model/bytecode/static.bin", ios::in | ios::binary); else - SaveCode.open((file_name + "_dynamic.bin").c_str(), ios::in | ios::binary); + SaveCode.open(file_name + "/model/bytecode/dynamic.bin", ios::in | ios::binary); if (!SaveCode.is_open()) { ostringstream tmp; if (steady_state) - tmp << " in Read_SparseMatrix, " << file_name << "_static.bin cannot be opened\n"; + tmp << " in Read_SparseMatrix, " << file_name << "/model/bytecode/static.bin cannot be opened\n"; else - tmp << " in Read_SparseMatrix, " << file_name << "_dynamic.bin cannot be opened\n"; + tmp << " in Read_SparseMatrix, " << file_name << "/model/bytecode/dynamic.bin cannot be opened\n"; throw FatalExceptionHandling(tmp.str()); } } diff --git a/mex/sources/k_order_perturbation/dynamic_dll.cc b/mex/sources/k_order_perturbation/dynamic_dll.cc index bd816262e..707fb6bfe 100644 --- a/mex/sources/k_order_perturbation/dynamic_dll.cc +++ b/mex/sources/k_order_perturbation/dynamic_dll.cc @@ -27,7 +27,7 @@ DynamicModelDLL::DynamicModelDLL(const string &modName) throw (DynareException) #if !defined(__CYGWIN32__) && !defined(_WIN32) fName = "./"; #endif - fName += modName + "_dynamic" + MEXEXT; + fName += "+" + modName + "/dynamic" + MEXEXT; try { diff --git a/mex/sources/k_order_perturbation/dynamic_m.cc b/mex/sources/k_order_perturbation/dynamic_m.cc index eb5fc69fd..7fe252cfd 100644 --- a/mex/sources/k_order_perturbation/dynamic_m.cc +++ b/mex/sources/k_order_perturbation/dynamic_m.cc @@ -20,7 +20,7 @@ #include "dynamic_m.hh" DynamicModelMFile::DynamicModelMFile(const string &modName) throw (DynareException) : - DynamicMFilename(modName + "_dynamic") + DynamicMFilename(modName + ".dynamic") { } diff --git a/mex/sources/k_order_perturbation/k_order_perturbation.cc b/mex/sources/k_order_perturbation/k_order_perturbation.cc index 1159b810b..1e6a88cc0 100644 --- a/mex/sources/k_order_perturbation/k_order_perturbation.cc +++ b/mex/sources/k_order_perturbation/k_order_perturbation.cc @@ -293,7 +293,7 @@ extern "C" { ++ii; } - if (kOrder == 3 && nlhs > 4) + if (kOrder == 3 && nlhs > 5) { const FGSContainer *derivs = app.get_rule_ders(); const std::string fieldnames[] = {"gy", "gu", "gyy", "gyu", "guu", "gss", diff --git a/preprocessor b/preprocessor index a2b19cbff..7baee7312 160000 --- a/preprocessor +++ b/preprocessor @@ -1 +1 @@ -Subproject commit a2b19cbffff9612aea4d255fd7c6df0591087da8 +Subproject commit 7baee7312614a32d00a051f0ce5246f66be0796b diff --git a/tests/Makefile.am b/tests/Makefile.am index ccbeb24ed..92d4a95ca 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -936,15 +936,6 @@ clean-local: $(patsubst %.trs, %.json, $(O_TRS_FILES)) \ $(patsubst %.trs, %.json, $(O_XFAIL_TRS_FILES)) - rm -f $(patsubst %.mod, %.m, $(MODFILES)) \ - $(patsubst %.mod, %_static.*, $(MODFILES)) \ - $(patsubst %.mod, %_static_*.m, $(MODFILES)) \ - $(patsubst %.mod, %_objective_static.m, $(MODFILES)) \ - $(patsubst %.mod, %_set_auxiliary_variables.m, $(MODFILES)) \ - $(patsubst %.mod, %_steadystate2.m, $(MODFILES)) \ - $(patsubst %.mod, %_dynamic.*, $(MODFILES)) \ - $(patsubst %.mod, %_dynamic_*.m, $(MODFILES)) - rm -f $(patsubst %.mod, %_results.mat, $(MODFILES)) \ $(patsubst %.mod, %_mode.mat, $(MODFILES)) \ $(patsubst %.mod, %_mh_mode.mat, $(MODFILES)) \ @@ -956,6 +947,8 @@ clean-local: rm -rf $(patsubst %.mod, %, $(MODFILES)) + rm -rf $(foreach mod, $(MODFILES), $(dir $(mod))+$(basename $(notdir $(mod)))) + rm -f $(patsubst %.mod, %*.pdf, $(MODFILES)) \ $(patsubst %.mod, %*.eps, $(MODFILES)) \ $(patsubst %.mod, %*.fig, $(MODFILES)) @@ -1014,4 +1007,3 @@ clean-local: find . -name "*.aux" -type f -delete find . -name "*.log" -type f -delete find . -name "*.eps" -type f -delete - find . -name "*.json" -type f -delete diff --git a/tests/block_bytecode/run_ls2003.m b/tests/block_bytecode/run_ls2003.m index f0c11d31f..d59d64cd2 100644 --- a/tests/block_bytecode/run_ls2003.m +++ b/tests/block_bytecode/run_ls2003.m @@ -17,12 +17,7 @@ function run_ls2003(block, bytecode, solve_algo, stack_solve_algo) % You should have received a copy of the GNU General Public License % along with Dynare. If not, see . -% Workaround for a strange race condition under Octave -if exist('ls2003_tmp.m') == 2 - delete('ls2003_tmp.m') -end - -disp(['TEST: ls2003 (block=' num2str(block) ', bytecode=' ... + disp(['TEST: ls2003 (block=' num2str(block) ', bytecode=' ... num2str(bytecode) ', solve_algo=' num2str(solve_algo) ... ', stack_solve_algo=' num2str(stack_solve_algo) ')...']); fid = fopen('ls2003_tmp.mod', 'w'); diff --git a/tests/dynare-command-options/ramst.mod b/tests/dynare-command-options/ramst.mod index d15baca5a..aa5cecb46 100644 --- a/tests/dynare-command-options/ramst.mod +++ b/tests/dynare-command-options/ramst.mod @@ -38,6 +38,6 @@ perfect_foresight_solver; rplot c; rplot k; -if ~exist('./ramst.json', 'file') || exist('./ramst.log', 'file') +if ~exist('./ramst/model/json/modfile.json', 'file') || exist('./ramst.log', 'file') error('The dynare command did not honor the options provided in the mod file!') end diff --git a/tests/ep/rbcii.mod b/tests/ep/rbcii.mod index a51c01a8f..3073d2680 100644 --- a/tests/ep/rbcii.mod +++ b/tests/ep/rbcii.mod @@ -56,7 +56,7 @@ end; // Write analytical steady state file (without globals) options_.steadystate_flag = 2; -copyfile('rbcii_steady_state.m','rbcii_steadystate2.m'); +copyfile('rbcii_steady_state.m','+rbcii/steadystate.m'); @#if extended_path_version diff --git a/tests/example1.mod b/tests/example1.mod index 90e039904..54b0ffa9c 100644 --- a/tests/example1.mod +++ b/tests/example1.mod @@ -1,5 +1,5 @@ // Example 1 from Collard's guide to Dynare -var y, c, k, a, h, b; +var y, k, a, h, b; varexo e, u; verbatim; @@ -22,6 +22,7 @@ theta = 2.95; phi = 0.1; model; +[endogenous='c',name='law of motion of capital'] c*theta*h^(1+psi)=(1-alpha)*y; k = beta*(((exp(b)*c)/(exp(b(+1))*c(+1))) *(exp(b(+1))*alpha*y(+1)+(1-delta)*k)); diff --git a/tests/example1_on_the_fly.mod b/tests/example1_on_the_fly.mod index 7e40f384b..fd0786eda 100644 --- a/tests/example1_on_the_fly.mod +++ b/tests/example1_on_the_fly.mod @@ -1,10 +1,24 @@ -// Example 1 from Collard's guide to Dynare +// --+ options: nostrict +-- +/* +** In the following example, the types (exogenous variable, endogenous variable, parameter) of the objects appearing in the model are declared +** on the fly in the equations. With the nostrict option, an object is by default an exogenous variable (if the type of an object is not declared +** in one of the equations, it will be interpreted as an exogenous variable). Without the nostrict option, Dynare will raise an error if the model +** contains untyped objects. +** +** An object followed by |e is an endogenous variable, +** |x is an exogenous variable, +** |p is a parameter. +** +** Example. If the first equation (consumption/leisure arbitrage) is removed from the following model block, then h (hours) +** will be interpreted as an exogenous variable. +*/ + model; -c|e*theta|p*h|e^(1+psi|p)=(1-alpha)*y; +c*theta|p*h|e^(1+psi|p)=(1-alpha)*y; k|e = beta|p*(((exp(b)*c)/(exp(b(+1))*c(+1))) *(exp(b(+1))*alpha|p*y(+1)+(1-delta)*k)); y|e = exp(a)*(k(-1)^alpha)*(h^(1-alpha)); -k = exp(b)*(y-c)+(1-delta|p)*k(-1); +k = exp(b)*(y-c|e)+(1-delta|p)*k(-1); a|e = rho|p*a(-1)+tau*b(-1) + e|x; b|e = tau|p*a(-1)+rho*b(-1) + u|x; end; diff --git a/tests/lmmcp/sw_newton.mod b/tests/lmmcp/sw_newton.mod index 074fd8258..f40297e0f 100644 --- a/tests/lmmcp/sw_newton.mod +++ b/tests/lmmcp/sw_newton.mod @@ -69,11 +69,11 @@ end; simul(periods=1000); -newton_solution_is_wrong = abs(evaluate_max_dynamic_residual(str2func('sw_newton_dynamic'), oo_.endo_simul, oo_.exo_simul, M_.params, oo_.steady_state, 1000, size(oo_.endo_simul, 1), 1, M_.lead_lag_incidence))>options_.dynatol.f; +newton_solution_is_wrong = abs(evaluate_max_dynamic_residual(str2func('sw_newton.dynamic'), oo_.endo_simul, oo_.exo_simul, M_.params, oo_.steady_state, 1000, size(oo_.endo_simul, 1), 1, M_.lead_lag_incidence))>options_.dynatol.f; lmmcp = load('sw_lmmcp_results'); -lmmcp_solution_is_wrong = abs(evaluate_max_dynamic_residual(str2func('sw_newton_dynamic'), lmmcp.oo_.endo_simul, lmmcp.oo_.exo_simul, M_.params, oo_.steady_state, 1000, size(oo_.endo_simul, 1), 1, M_.lead_lag_incidence))>options_.dynatol.f; +lmmcp_solution_is_wrong = abs(evaluate_max_dynamic_residual(str2func('sw_newton.dynamic'), lmmcp.oo_.endo_simul, lmmcp.oo_.exo_simul, M_.params, oo_.steady_state, 1000, size(oo_.endo_simul, 1), 1, M_.lead_lag_incidence))>options_.dynatol.f; solutions_are_different = max(max(abs(lmmcp.oo_.endo_simul-oo_.endo_simul)))>options_.dynatol.x; diff --git a/windows/README.txt b/windows/README.txt index c4b67a297..886fca456 100644 --- a/windows/README.txt +++ b/windows/README.txt @@ -57,7 +57,7 @@ Using Dynare with Octave Dynare also works on top of GNU Octave, a free clone of MATLAB (R) (see ). -This version of Dynare is compiled for Octave 4.2.1 (MinGW, 32bit and 64bit), and may not work +This version of Dynare is compiled for Octave 4.4.0 (MinGW, 32bit and 64bit), and may not work with other versions of Octave. The recommended version of Octave can be downloaded at: diff --git a/windows/dynare.nsi b/windows/dynare.nsi index e282af120..a468186e2 100644 --- a/windows/dynare.nsi +++ b/windows/dynare.nsi @@ -110,14 +110,14 @@ SectionEnd SectionGroupEnd -SectionGroup "MEX files for OCTAVE" +SectionGroup "MEX files for Octave" -Section "MEX files for Octave 4.2.1 (MinGW, 64bit)" +Section "MEX files for Octave 4.4.0 (MinGW, 64bit)" SetOutPath $INSTDIR\mex\octave File ..\mex\octave\* SectionEnd -Section "MEX files for Octave 4.2.1 (MinGW, 32bit)" +Section "MEX files for Octave 4.4.0 (MinGW, 32bit)" SetOutPath $INSTDIR\mex\octave32 File ..\mex\octave32\* SectionEnd