diff --git a/DynareMain.cc b/DynareMain.cc index 14f31d5a665d20e72d2bdedd3040664545289413..c5c23657481465f405fdfcd7a54e8fd441ece78f 100644 --- a/DynareMain.cc +++ b/DynareMain.cc @@ -34,12 +34,12 @@ using namespace std; Splitting main() in two parts was necessary because ParsingDriver.h and MacroDriver.h can't be included simultaneously (because of Bison limitations). */ -void main2(stringstream &in, string &basename, bool debug, bool clear_all, bool no_tmp_terms); +void main2(stringstream &in, string &basename, bool debug, bool clear_all, bool no_tmp_terms, bool warn_uninit); void usage() { - cerr << "Dynare usage: dynare mod_file [debug] [noclearall] [savemacro[=macro_file]] [onlymacro] [nolinemacro] [notmpterms]" << endl; + cerr << "Dynare usage: dynare mod_file [debug] [noclearall] [savemacro[=macro_file]] [onlymacro] [nolinemacro] [notmpterms] [warn_uninit]" << endl; exit(EXIT_FAILURE); } @@ -59,6 +59,7 @@ main(int argc, char** argv) bool no_tmp_terms = false; bool only_macro = false; bool no_line_macro = false; + bool warn_uninit = false; // Parse options for (int arg = 2; arg < argc; arg++) @@ -86,6 +87,8 @@ main(int argc, char** argv) no_line_macro = true; else if (!strcmp(argv[arg], "notmpterms")) no_tmp_terms = true; + else if (!strcmp(argv[arg], "warn_uninit")) + warn_uninit = true; else { cerr << "Unknown option: " << argv[arg] << endl; @@ -125,7 +128,7 @@ main(int argc, char** argv) return EXIT_SUCCESS; // Do the rest - main2(macro_output, basename, debug, clear_all, no_tmp_terms); + main2(macro_output, basename, debug, clear_all, no_tmp_terms, warn_uninit); return EXIT_SUCCESS; } diff --git a/DynareMain2.cc b/DynareMain2.cc index 15049213b7aef6c01e98c7e49ac158cd6a6e3e55..b6dc438dd07ef64738ebad1b09f787ec715aa4ce 100644 --- a/DynareMain2.cc +++ b/DynareMain2.cc @@ -25,7 +25,8 @@ using namespace std; #include "ModFile.hh" void -main2(stringstream &in, string &basename, bool debug, bool clear_all, bool no_tmp_terms) +main2(stringstream &in, string &basename, bool debug, bool clear_all, bool no_tmp_terms, + bool warn_uninit) { ParsingDriver p; @@ -39,7 +40,7 @@ main2(stringstream &in, string &basename, bool debug, bool clear_all, bool no_tm mod_file->transformPass(); // Evaluate parameters initialization, initval, endval and pounds - mod_file->evalAllExpressions(); + mod_file->evalAllExpressions(warn_uninit); // Do computations mod_file->computingPass(no_tmp_terms); diff --git a/ModFile.cc b/ModFile.cc index d31030be542dbf6f2aa57de212996cc100fc900c..c9ac4e540d4d3260ed6c3ead9e744eae24dd8c99 100644 --- a/ModFile.cc +++ b/ModFile.cc @@ -40,7 +40,7 @@ ModFile::~ModFile() } void -ModFile::evalAllExpressions() +ModFile::evalAllExpressions(bool warn_uninit) { cout << "Evaluating expressions..."; @@ -73,7 +73,8 @@ ModFile::evalAllExpressions() || type == eParameter || type == eModelLocalVariable) && global_eval_context.find(id) == global_eval_context.end()) { - cerr << "WARNING: can't find a numeric initial value for " << symbol_table.getName(id) << ", using zero" << endl; + if (warn_uninit) + cerr << "WARNING: can't find a numeric initial value for " << symbol_table.getName(id) << ", using zero" << endl; global_eval_context[id] = 0; } } diff --git a/ModFile.hh b/ModFile.hh index 6a7f3baaba197504690ffce98b7ba0066708fbc1..9c735b55a7256478bfc740c126a2b260c0c6b40b 100644 --- a/ModFile.hh +++ b/ModFile.hh @@ -77,7 +77,8 @@ public: //! Add a statement void addStatement(Statement *st); //! Evaluate all the statements - void evalAllExpressions(); + /*! \param warn_uninit Should a warning be displayed for uninitialized endogenous/exogenous/parameters ? */ + void evalAllExpressions(bool warn_uninit); //! Do some checking and fills mod_file_struct /*! \todo add check for number of equations and endogenous if ramsey_policy is present */ void checkPass();