From 18e952145078b8b7743d4032b314beeaa18981c6 Mon Sep 17 00:00:00 2001 From: Houtan Bastani <houtan@dynare.org> Date: Mon, 27 Apr 2015 11:50:25 +0200 Subject: [PATCH] preprocessor: add dirname option to estimation. closes #910 --- doc/dynare.texi | 5 +++++ matlab/dynare_estimation.m | 2 +- matlab/global_initialization.m | 1 + preprocessor/DynareBison.yy | 4 +++- preprocessor/DynareFlex.ll | 1 + tests/pi2004/ireland.mod | 2 +- 6 files changed, 12 insertions(+), 3 deletions(-) diff --git a/doc/dynare.texi b/doc/dynare.texi index 8d5a09c2a1..39178a0efd 100644 --- a/doc/dynare.texi +++ b/doc/dynare.texi @@ -4671,6 +4671,11 @@ a @uref{http://www.java.com/download,Java Runtime Environment}). Note that the base name (ie without extension) of the datafile has to be different from the base name of the model file. +@item dirname = @var{FILENAME} +Directory in which to store @code{estimation} output. To pass a +subdirectory of a directory, you must quote the argument. Default: +@code{<mod_file>} + @item xls_sheet = @var{NAME} @anchor{xls_sheet} The name of the sheet with the data in an Excel file diff --git a/matlab/dynare_estimation.m b/matlab/dynare_estimation.m index 80e91c0417..7bb49f3803 100644 --- a/matlab/dynare_estimation.m +++ b/matlab/dynare_estimation.m @@ -56,7 +56,7 @@ nnobs = length(nobs); horizon = options_.forecast; if nargin<2 || ~exist(dname) || isempty(dname) - dname = M_.fname; + dname = options_.dirname; end M_.dname = dname; diff --git a/matlab/global_initialization.m b/matlab/global_initialization.m index 4ec37b459c..230661dc1c 100644 --- a/matlab/global_initialization.m +++ b/matlab/global_initialization.m @@ -33,6 +33,7 @@ global oo_ M_ options_ estim_params_ bayestopt_ estimation_info ex0_ ys0_ estim_params_ = []; bayestopt_ = []; options_.datafile = ''; +options_.dirname = M_.fname; options_.dataset = []; options_.verbosity = 1; options_.terminal_condition = 0; diff --git a/preprocessor/DynareBison.yy b/preprocessor/DynareBison.yy index 6c76d41617..b7288da93a 100644 --- a/preprocessor/DynareBison.yy +++ b/preprocessor/DynareBison.yy @@ -92,7 +92,7 @@ class ParsingDriver; %token CONSIDER_ALL_ENDOGENOUS CONSIDER_ONLY_OBSERVED %token DATAFILE FILE SERIES DOUBLING DR_CYCLE_REDUCTION_TOL DR_LOGARITHMIC_REDUCTION_TOL DR_LOGARITHMIC_REDUCTION_MAXITER DR_ALGO DROP DSAMPLE DYNASAVE DYNATYPE CALIBRATION DIFFERENTIATE_FORWARD_VARS %token END ENDVAL EQUAL ESTIMATION ESTIMATED_PARAMS ESTIMATED_PARAMS_BOUNDS ESTIMATED_PARAMS_INIT EXTENDED_PATH ENDOGENOUS_PRIOR -%token FILENAME FILTER_STEP_AHEAD FILTERED_VARS FIRST_OBS LAST_OBS SET_TIME +%token FILENAME DIRNAME FILTER_STEP_AHEAD FILTERED_VARS FIRST_OBS LAST_OBS SET_TIME %token <string_val> FLOAT_NUMBER DATES %token DEFAULT FIXED_POINT OPT_ALGO %token FORECAST K_ORDER_SOLVER INSTRUMENTS SHIFT MEAN STDEV VARIANCE MODE INTERVAL SHAPE DOMAINN @@ -1712,6 +1712,7 @@ estimation_options : o_datafile | o_filter_algorithm | o_proposal_approximation | o_distribution_approximation + | o_dirname ; list_optim_option : QUOTED_STRING COMMA QUOTED_STRING @@ -2546,6 +2547,7 @@ o_qz_zero_threshold : QZ_ZERO_THRESHOLD EQUAL non_negative_number { driver.optio o_file : FILE EQUAL filename { driver.option_str("file", $3); }; o_series : SERIES EQUAL symbol { driver.option_str("series", $3); }; o_datafile : DATAFILE EQUAL filename { driver.option_str("datafile", $3); }; +o_dirname : DIRNAME EQUAL filename { driver.option_str("dirname", $3); }; o_nobs : NOBS EQUAL vec_int { driver.option_vec_int("nobs", $3); } | NOBS EQUAL vec_int_number diff --git a/preprocessor/DynareFlex.ll b/preprocessor/DynareFlex.ll index 0e7a31c162..4428dd37d2 100644 --- a/preprocessor/DynareFlex.ll +++ b/preprocessor/DynareFlex.ll @@ -236,6 +236,7 @@ DATE -?[0-9]+([YyAa]|[Mm]([1-9]|1[0-2])|[Qq][1-4]|[Ww]([1-9]{1}|[1-4][0-9]|5[0-2 <DYNARE_STATEMENT>dates {dates_parens_nb=0; BEGIN DATES_STATEMENT; yylval->string_val = new string("dates");} <DYNARE_STATEMENT>file {return token::FILE;} <DYNARE_STATEMENT>datafile {return token::DATAFILE;} +<DYNARE_STATEMENT>dirname {return token::DIRNAME;} <DYNARE_STATEMENT>nobs {return token::NOBS;} <DYNARE_STATEMENT>last_obs {return token::LAST_OBS;} <DYNARE_STATEMENT>first_obs {return token::FIRST_OBS;} diff --git a/tests/pi2004/ireland.mod b/tests/pi2004/ireland.mod index ea17baad31..4c6552bdec 100644 --- a/tests/pi2004/ireland.mod +++ b/tests/pi2004/ireland.mod @@ -87,4 +87,4 @@ oy (log(eta)); oc (log(eta)); end; -estimation(datafile=idata,mode_compute=1,nograph); \ No newline at end of file +estimation(datafile=idata,mode_compute=1,nograph,dirname='MYDIR/mysubdir'); \ No newline at end of file -- GitLab