diff --git a/doc/dynare.texi b/doc/dynare.texi index f108c7457b5b6ced30e72521752946e9c77573cf..40f2687dcdc80a0ddf54bc9e8b4c60bf62730323 100644 --- a/doc/dynare.texi +++ b/doc/dynare.texi @@ -2689,6 +2689,16 @@ Contains the eigenvalues of the model, as computed by the @code{check} command. @end defvr + +@deffn Command model_diagnostics ; + +This command performs various sanity checks on the model, and prints a +message if a problem is detected (missing variables at current period, +invalid steady state, singular Jacobian of static model). + +@end deffn + + @deffn Command model_info ; @deffnx Command model_info (@var{OPTIONS}@dots{}); diff --git a/preprocessor/ComputingTasks.cc b/preprocessor/ComputingTasks.cc index 4fe107823a4c616badcdb37c37114e2572cbec1e..f01bec395af672704d4c2007d5072757b6c22906 100644 --- a/preprocessor/ComputingTasks.cc +++ b/preprocessor/ComputingTasks.cc @@ -2410,3 +2410,13 @@ ExtendedPathStatement::writeOutput(ostream &output, const string &basename) cons << ") ];" << endl << "oo_.exo_simul = oo_.ep.shocks;" << endl; } + +ModelDiagnosticsStatement::ModelDiagnosticsStatement() +{ +} + +void +ModelDiagnosticsStatement::writeOutput(ostream &output, const string &basename) const +{ + output << "model_diagnostics(M_,options_,oo_);" << endl; +} diff --git a/preprocessor/ComputingTasks.hh b/preprocessor/ComputingTasks.hh index 5a75ea55bcbb54a31753a1c16d6961c736235bdb..926e082d2106f126551f396d0da247a0cb87f231 100644 --- a/preprocessor/ComputingTasks.hh +++ b/preprocessor/ComputingTasks.hh @@ -805,4 +805,11 @@ public: virtual void writeOutput(ostream &output, const string &basename) const; }; +class ModelDiagnosticsStatement : public Statement +{ +public: + ModelDiagnosticsStatement(); + virtual void writeOutput(ostream &output, const string &basename) const; +}; + #endif diff --git a/preprocessor/DynareBison.yy b/preprocessor/DynareBison.yy index 7437560dedea6c86d0b201cade4f40e2128cc45b..b0937c20e5d7b1275f09ca37d73baa686c2dc064 100644 --- a/preprocessor/DynareBison.yy +++ b/preprocessor/DynareBison.yy @@ -113,7 +113,7 @@ class ParsingDriver; %token LYAPUNOV_FIXED_POINT_TOL LYAPUNOV_DOUBLING_TOL LYAPUNOV_SQUARE_ROOT_SOLVER_TOL MARKOWITZ MARGINAL_DENSITY MAX MAXIT %token MFS MH_DROP MH_INIT_SCALE MH_JSCALE MH_MODE MH_NBLOCKS MH_REPLIC MH_RECOVER MIN MINIMAL_SOLVING_PERIODS SOLVE_MAXIT %token MODE_CHECK MODE_COMPUTE MODE_FILE MODEL MODEL_COMPARISON MODEL_INFO MSHOCKS ABS SIGN -%token MODIFIEDHARMONICMEAN MOMENTS_VARENDO DIFFUSE_FILTER SUB_DRAWS +%token MODEL_DIAGNOSTICS MODIFIEDHARMONICMEAN MOMENTS_VARENDO DIFFUSE_FILTER SUB_DRAWS %token <string_val> NAME %token NAN_CONSTANT NO_STATIC NOBS NOCONSTANT NODISPLAY NOCORR NODIAGNOSTIC NOFUNCTIONS %token NOGRAPH NOMOMENTS NOPRINT NORMAL_PDF @@ -270,6 +270,7 @@ statement : parameters | ms_variance_decomposition | calib_smoother | extended_path + | model_diagnostics ; dsample : DSAMPLE INT_NUMBER ';' @@ -2177,6 +2178,10 @@ extended_path_option : o_periods | o_solver_periods ; +model_diagnostics : MODEL_DIAGNOSTICS ';' + { driver.model_diagnostics(); } + ; + o_dr_algo : DR_ALGO EQUAL INT_NUMBER { if (*$3 == string("0")) driver.warning("dr_algo option is now deprecated, and may be removed in a future version of Dynare"); diff --git a/preprocessor/DynareFlex.ll b/preprocessor/DynareFlex.ll index eba4ff972f4b009ccb999cc2896fbd1abd6425f1..3c8b40a9bc78220ff2de0a66ac450e9b2a8049ec 100644 --- a/preprocessor/DynareFlex.ll +++ b/preprocessor/DynareFlex.ll @@ -157,6 +157,7 @@ string eofbuff; <INITIAL>external_function {BEGIN DYNARE_STATEMENT; return token::EXTERNAL_FUNCTION;} /* End of a Dynare statement */ <INITIAL>calib_smoother { BEGIN DYNARE_STATEMENT; return token::CALIB_SMOOTHER; } +<INITIAL>model_diagnostics {BEGIN DYNARE_STATEMENT; return token::MODEL_DIAGNOSTICS;} <DYNARE_STATEMENT>; { if (!sigma_e) diff --git a/preprocessor/ParsingDriver.cc b/preprocessor/ParsingDriver.cc index ee72245f6f53fdaf9d6f10e02ba2804d5638dc05..e4e36f909cc1e728807ef18c3426ec1cae653387 100644 --- a/preprocessor/ParsingDriver.cc +++ b/preprocessor/ParsingDriver.cc @@ -2493,3 +2493,8 @@ ParsingDriver::process_graph_format_option() graph_formats.clear(); } +void +ParsingDriver::model_diagnostics() +{ + mod_file->addStatement(new ModelDiagnosticsStatement()); +} diff --git a/preprocessor/ParsingDriver.hh b/preprocessor/ParsingDriver.hh index 203ab6c8b27963d31e6fcfc1939428a6281c6940..30ae85a40887c7e271b0fdd4c29692aaa4be27de 100644 --- a/preprocessor/ParsingDriver.hh +++ b/preprocessor/ParsingDriver.hh @@ -634,6 +634,8 @@ public: void add_graph_format(const string &name); //! Add the graph_format option to the OptionsList structure void process_graph_format_option(); + //! Model diagnostics + void model_diagnostics(); }; #endif // ! PARSING_DRIVER_HH