diff --git a/DynamicModel.cc b/DynamicModel.cc index 266987d5..fc5164ef 100644 --- a/DynamicModel.cc +++ b/DynamicModel.cc @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2016 Dynare Team + * Copyright (C) 2003-2017 Dynare Team * * This file is part of Dynare. * @@ -2345,11 +2345,12 @@ DynamicModel::writeDynamicModel(ostream &DynamicOutput, bool use_dll, bool julia { // Check that we don't have more than 32 nested parenthesis because Matlab does not suppor this. See Issue #1201 map tmp_paren_vars; - fixNestedParenthesis(model_output, tmp_paren_vars); - fixNestedParenthesis(model_local_vars_output, tmp_paren_vars); - fixNestedParenthesis(jacobian_output, tmp_paren_vars); - fixNestedParenthesis(hessian_output, tmp_paren_vars); - fixNestedParenthesis(third_derivatives_output, tmp_paren_vars); + bool message_printed = false; + fixNestedParenthesis(model_output, tmp_paren_vars, message_printed); + fixNestedParenthesis(model_local_vars_output, tmp_paren_vars, message_printed); + fixNestedParenthesis(jacobian_output, tmp_paren_vars, message_printed); + fixNestedParenthesis(hessian_output, tmp_paren_vars, message_printed); + fixNestedParenthesis(third_derivatives_output, tmp_paren_vars, message_printed); DynamicOutput << "%" << endl << "% Model equations" << endl diff --git a/ModelTree.cc b/ModelTree.cc index a1c4f6a8..70db28e0 100644 --- a/ModelTree.cc +++ b/ModelTree.cc @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2016 Dynare Team + * Copyright (C) 2003-2017 Dynare Team * * This file is part of Dynare. * @@ -1293,7 +1293,7 @@ ModelTree::writeTemporaryTerms(const temporary_terms_t &tt, const temporary_term } void -ModelTree::fixNestedParenthesis(ostringstream &output, map &tmp_paren_vars) const +ModelTree::fixNestedParenthesis(ostringstream &output, map &tmp_paren_vars, bool &message_printed) const { string str = output.str(); if (!testNestedParenthesis(str)) @@ -1323,12 +1323,15 @@ ModelTree::fixNestedParenthesis(ostringstream &output, map &tmp_ if (hit_limit && open == 0) { - cerr << "Warning: A .m file created by Dynare will have more than 32 nested parenthesis. Matlab cannot support this. " << endl - << " We are going to modify, albeit inefficiently, this output to have fewer than 32 nested parenthesis. " << endl - << " It would hence behoove you to use the use_dll option of the model block to circumnavigate this problem." << endl - << " If you have not yet set up a compiler on your system, see the Matlab documentation for doing so." << endl - << " For Windows, see: https://www.mathworks.com/help/matlab/matlab_external/install-mingw-support-package.html" << endl << endl; - + if (!message_printed) + { + cerr << "Warning: A .m file created by Dynare will have more than 32 nested parenthesis. Matlab cannot support this. " << endl + << " We are going to modify, albeit inefficiently, this output to have fewer than 32 nested parenthesis. " << endl + << " It would hence behoove you to use the use_dll option of the model block to circumnavigate this problem." << endl + << " If you have not yet set up a compiler on your system, see the Matlab documentation for doing so." << endl + << " For Windows, see: https://www.mathworks.com/help/matlab/matlab_external/install-mingw-support-package.html" << endl << endl; + message_printed = true; + } string str1 = str.substr(first_open_paren, matching_paren - first_open_paren + 1); string repstr = ""; string varname; diff --git a/ModelTree.hh b/ModelTree.hh index db014bc2..9b28fce4 100644 --- a/ModelTree.hh +++ b/ModelTree.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2016 Dynare Team + * Copyright (C) 2003-2017 Dynare Team * * This file is part of Dynare. * @@ -191,7 +191,7 @@ protected: //! Adds informations for simulation in a binary file void Write_Inf_To_Bin_File(const string &basename, int &u_count_int, bool &file_open, bool is_two_boundaries, int block_mfs) const; //! Fixes output when there are more than 32 nested parens, Issue #1201 - void fixNestedParenthesis(ostringstream &output, map &tmp_paren_vars) const; + void fixNestedParenthesis(ostringstream &output, map &tmp_paren_vars, bool &message_printed) const; //! Tests if string contains more than 32 nested parens, Issue #1201 bool testNestedParenthesis(const string &str) const; //! Writes model local variables diff --git a/StaticModel.cc b/StaticModel.cc index 0428d082..f02ef83c 100644 --- a/StaticModel.cc +++ b/StaticModel.cc @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2016 Dynare Team + * Copyright (C) 2003-2017 Dynare Team * * This file is part of Dynare. * @@ -1400,11 +1400,12 @@ StaticModel::writeStaticModel(ostream &StaticOutput, bool use_dll, bool julia) c { // Check that we don't have more than 32 nested parenthesis because Matlab does not suppor this. See Issue #1201 map tmp_paren_vars; - fixNestedParenthesis(model_output, tmp_paren_vars); - fixNestedParenthesis(model_local_vars_output, tmp_paren_vars); - fixNestedParenthesis(jacobian_output, tmp_paren_vars); - fixNestedParenthesis(hessian_output, tmp_paren_vars); - fixNestedParenthesis(third_derivatives_output, tmp_paren_vars); + bool message_printed = false; + fixNestedParenthesis(model_output, tmp_paren_vars, message_printed); + fixNestedParenthesis(model_local_vars_output, tmp_paren_vars, message_printed); + fixNestedParenthesis(jacobian_output, tmp_paren_vars, message_printed); + fixNestedParenthesis(hessian_output, tmp_paren_vars, message_printed); + fixNestedParenthesis(third_derivatives_output, tmp_paren_vars, message_printed); StaticOutput << "residual = zeros( " << equations.size() << ", 1);" << endl << endl << "%" << endl