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.
|
* 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
|
// 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;
|
map<string, string> tmp_paren_vars;
|
||||||
fixNestedParenthesis(model_output, tmp_paren_vars);
|
bool message_printed = false;
|
||||||
fixNestedParenthesis(model_local_vars_output, tmp_paren_vars);
|
fixNestedParenthesis(model_output, tmp_paren_vars, message_printed);
|
||||||
fixNestedParenthesis(jacobian_output, tmp_paren_vars);
|
fixNestedParenthesis(model_local_vars_output, tmp_paren_vars, message_printed);
|
||||||
fixNestedParenthesis(hessian_output, tmp_paren_vars);
|
fixNestedParenthesis(jacobian_output, tmp_paren_vars, message_printed);
|
||||||
fixNestedParenthesis(third_derivatives_output, tmp_paren_vars);
|
fixNestedParenthesis(hessian_output, tmp_paren_vars, message_printed);
|
||||||
|
fixNestedParenthesis(third_derivatives_output, tmp_paren_vars, message_printed);
|
||||||
|
|
||||||
DynamicOutput << "%" << endl
|
DynamicOutput << "%" << endl
|
||||||
<< "% Model equations" << endl
|
<< "% Model equations" << endl
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2003-2016 Dynare Team
|
* Copyright (C) 2003-2017 Dynare Team
|
||||||
*
|
*
|
||||||
* This file is part of Dynare.
|
* This file is part of Dynare.
|
||||||
*
|
*
|
||||||
|
@ -1293,7 +1293,7 @@ ModelTree::writeTemporaryTerms(const temporary_terms_t &tt, const temporary_term
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
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();
|
string str = output.str();
|
||||||
if (!testNestedParenthesis(str))
|
if (!testNestedParenthesis(str))
|
||||||
|
@ -1322,13 +1322,16 @@ ModelTree::fixNestedParenthesis(ostringstream &output, map<string, string> &tmp_
|
||||||
hit_limit = true;
|
hit_limit = true;
|
||||||
|
|
||||||
if (hit_limit && open == 0)
|
if (hit_limit && open == 0)
|
||||||
|
{
|
||||||
|
if (!message_printed)
|
||||||
{
|
{
|
||||||
cerr << "Warning: A .m file created by Dynare will have more than 32 nested parenthesis. Matlab cannot support this. " << endl
|
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
|
<< " 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
|
<< " 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
|
<< " 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;
|
<< " 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 str1 = str.substr(first_open_paren, matching_paren - first_open_paren + 1);
|
||||||
string repstr = "";
|
string repstr = "";
|
||||||
string varname;
|
string varname;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2003-2016 Dynare Team
|
* Copyright (C) 2003-2017 Dynare Team
|
||||||
*
|
*
|
||||||
* This file is part of Dynare.
|
* This file is part of Dynare.
|
||||||
*
|
*
|
||||||
|
@ -191,7 +191,7 @@ protected:
|
||||||
//! Adds informations for simulation in a binary file
|
//! 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;
|
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
|
//! 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
|
//! Tests if string contains more than 32 nested parens, Issue #1201
|
||||||
bool testNestedParenthesis(const string &str) const;
|
bool testNestedParenthesis(const string &str) const;
|
||||||
//! Writes model local variables
|
//! 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.
|
* 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
|
// 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;
|
map<string, string> tmp_paren_vars;
|
||||||
fixNestedParenthesis(model_output, tmp_paren_vars);
|
bool message_printed = false;
|
||||||
fixNestedParenthesis(model_local_vars_output, tmp_paren_vars);
|
fixNestedParenthesis(model_output, tmp_paren_vars, message_printed);
|
||||||
fixNestedParenthesis(jacobian_output, tmp_paren_vars);
|
fixNestedParenthesis(model_local_vars_output, tmp_paren_vars, message_printed);
|
||||||
fixNestedParenthesis(hessian_output, tmp_paren_vars);
|
fixNestedParenthesis(jacobian_output, tmp_paren_vars, message_printed);
|
||||||
fixNestedParenthesis(third_derivatives_output, tmp_paren_vars);
|
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
|
StaticOutput << "residual = zeros( " << equations.size() << ", 1);" << endl << endl
|
||||||
<< "%" << endl
|
<< "%" << endl
|
||||||
|
|
Loading…
Reference in New Issue