Added the possibility to dynare the dynare command options in the mod file.
parent
b5275edaa1
commit
63d6dfccf4
|
@ -744,8 +744,10 @@ by the @code{dynare} command.
|
|||
@descriptionhead
|
||||
|
||||
This command launches Dynare and executes the instructions included in
|
||||
@file{@var{FILENAME}.mod}. This user-supplied file contains the model
|
||||
and the processing instructions, as described in @ref{The Model file}.
|
||||
@file{@var{FILENAME}.mod}. This user-supplied file contains the model and the
|
||||
processing instructions, as described in @ref{The Model file}. The options,
|
||||
listed below, can be passed on the command line, following the name of the
|
||||
@file{.mod} file or in the first line of the @file{.mod} file itself (see below).
|
||||
|
||||
@code{dynare} begins by launching the preprocessor on the @file{.mod}
|
||||
file. By default (unless @code{use_dll} option has been given to
|
||||
|
@ -978,6 +980,16 @@ Tells Dynare to compute the equation cross references, writing them to the
|
|||
output @file{.m} file.
|
||||
@end table
|
||||
|
||||
These options can be passed to the preprocessor by listing them after the name
|
||||
of the @code{.mod} file. They can alternatively be defined in the first line of
|
||||
the @file{.mod} file, this avoids typing them on the command line each time a
|
||||
@file{.mod} file is to be run. This line must be a Dynare comment (@emph{ie}
|
||||
must begin with @code{//}) and the options must be comma separated between
|
||||
@code{--+ options:} and @code{+--}. As in the command line, if an option admits
|
||||
a value the equal symbol must not be surrounded by spaces. For instance
|
||||
@code{json = compute} is not correct, and should be written
|
||||
@code{json=compute}.
|
||||
|
||||
@outputhead
|
||||
|
||||
Depending on the computing tasks requested in the @file{.mod} file,
|
||||
|
@ -997,6 +1009,13 @@ dynare ramst
|
|||
dynare ramst.mod savemacro
|
||||
@end example
|
||||
|
||||
Alternatively the options can be specified in the first line of @file{ramst.mod}:
|
||||
|
||||
@example
|
||||
// --+ options: savemacro, json=compute +--
|
||||
@end example
|
||||
|
||||
|
||||
@end deffn
|
||||
|
||||
The output of Dynare is left into three main variables in the
|
||||
|
|
|
@ -183,6 +183,27 @@ else
|
|||
disp('Using 64-bit preprocessor');
|
||||
end
|
||||
|
||||
% Read options from the first line in mod/dyn file.
|
||||
fid = fopen(fname, 'r');
|
||||
firstline = fgetl(fid);
|
||||
fclose(fid);
|
||||
if isequal(regexp(firstline, '\s*\/\/'), 1)
|
||||
% First line is commented.
|
||||
firstline = regexprep(firstline, '\s*\/\/', '');
|
||||
if ~isempty(regexp(firstline, '(^\s+\-\-\+\s+options:)')) % Commented line begins with --+ options:
|
||||
if ~isempty(regexp(firstline, '(\s+\+\-\-\s*$)')) % Commented line ends with +--
|
||||
dynoption = strsplit(firstline, {'--+', '+--', 'options:', ' ', ','});
|
||||
dynoption(find(cellfun( @(x) isempty(x), dynoption))) = [];
|
||||
if isequal(nargin, 1)
|
||||
varargin = dynoption;
|
||||
else
|
||||
varargin = union(varargin, dynoption);
|
||||
end
|
||||
varargin
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
command = ['"' dynareroot 'preprocessor' arch_ext filesep 'dynare_m" ' fname] ;
|
||||
for i=1:length(varargin)
|
||||
command = [command ' ' varargin{i}];
|
||||
|
|
|
@ -339,7 +339,8 @@ MODFILES = \
|
|||
observation_trends_and_prefiltering/calib_smoother/Tr_no_prefil_f_obs_loglin_cal_smoother.mod \
|
||||
observation_trends_and_prefiltering/calib_smoother/Tr_prefilter_loglin_calib_smoother.mod \
|
||||
observation_trends_and_prefiltering/calib_smoother/Tr_prefil_f_obs_loglin_cal_smoother.mod \
|
||||
observation_trends_and_prefiltering/ML/Trend_no_prefilter_selected_var.mod
|
||||
observation_trends_and_prefiltering/ML/Trend_no_prefilter_selected_var.mod \
|
||||
dynare-command-options/ramst.mod
|
||||
|
||||
PARTICLEFILES = \
|
||||
particle/dsge_base2.mod \
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
// --+ options: json=compute, notmpterms, nolog +--
|
||||
|
||||
var c k;
|
||||
varexo x;
|
||||
|
||||
parameters alph gam delt bet aa;
|
||||
alph=0.5;
|
||||
gam=0.5;
|
||||
delt=0.02;
|
||||
bet=0.05;
|
||||
aa=0.5;
|
||||
|
||||
|
||||
model;
|
||||
c + k - aa*x*k(-1)^alph - (1-delt)*k(-1);
|
||||
c^(-gam) - (1+bet)^(-1)*(aa*alph*x(+1)*k^(alph-1) + 1 - delt)*c(+1)^(-gam);
|
||||
end;
|
||||
|
||||
initval;
|
||||
x = 1;
|
||||
k = ((delt+bet)/(1.0*aa*alph))^(1/(alph-1));
|
||||
c = aa*k^alph-delt*k;
|
||||
end;
|
||||
|
||||
steady;
|
||||
|
||||
check;
|
||||
|
||||
shocks;
|
||||
var x;
|
||||
periods 1;
|
||||
values 1.2;
|
||||
end;
|
||||
|
||||
perfect_foresight_setup(periods=200);
|
||||
perfect_foresight_solver;
|
||||
|
||||
rplot c;
|
||||
rplot k;
|
||||
|
||||
if ~exist('ramst.json') || exist('ramst.log')
|
||||
error('dynare command did not honour the options provided in the mod file!')
|
||||
end
|
Loading…
Reference in New Issue