when >32 nested parens encountered in matlab, print error message once per file in which such a situation occurred. #1201
parent
07ea12dc18
commit
a14fdd204f
|
@ -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<string, string> 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
|
||||
|
|
19
ModelTree.cc
19
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<string, string> &tmp_paren_vars) const
|
||||
ModelTree::fixNestedParenthesis(ostringstream &output, map<string, string> &tmp_paren_vars, bool &message_printed) const
|
||||
{
|
||||
string str = output.str();
|
||||
if (!testNestedParenthesis(str))
|
||||
|
@ -1323,12 +1323,15 @@ ModelTree::fixNestedParenthesis(ostringstream &output, map<string, string> &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;
|
||||
|
|
|
@ -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<string, string> &tmp_paren_vars) const;
|
||||
void fixNestedParenthesis(ostringstream &output, map<string, string> &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
|
||||
|
|
|
@ -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<string, string> 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
|
||||
|
|
Loading…
Reference in New Issue