Commit b5727e06 authored by ferhat's avatar ferhat
Browse files

Adds location indications in error message of "bytecode" + minor correction...

Adds location indications in error message of "bytecode" + minor correction (string passed as &string).

git-svn-id: https://www.dynare.org/svn/dynare/trunk@3374 ac1d8469-bf42-47a9-8791-bf33cf982152
parent 0efd5b16
...@@ -55,6 +55,49 @@ Interpreter::Interpreter(double *params_arg, double *y_arg, double *ya_arg, doub ...@@ -55,6 +55,49 @@ Interpreter::Interpreter(double *params_arg, double *y_arg, double *ya_arg, doub
minimal_solving_periods = minimal_solving_periods_arg; minimal_solving_periods = minimal_solving_periods_arg;
} }
string
Interpreter::error_location()
{
string tmp;
mxArray *M_;
double * P;
int R, C;
M_ = mexGetVariable("global", "M_");
stringstream Error_loc("in ");
switch(EQN_type)
{
case TemporaryTerm:
if (EQN_block_number>1)
Error_loc << "temporary term " << EQN_equation+1 << " in block " << EQN_block+1;
else
Error_loc << "temporary term " << EQN_equation+1;
break;
case ModelEquation:
if (EQN_block_number>1)
Error_loc << "equation " << EQN_equation+1 << " in block " << EQN_block+1;
else
Error_loc << "equation " << EQN_equation+1;
break;
case FirstEndoDerivative:
if (EQN_block_number>1)
Error_loc << "first order derivative " << EQN_equation+1 << " in block " << EQN_block+1 << " with respect to endogenous variable ";
else
Error_loc << "first order derivative " << EQN_equation+1 << " with respect to endogenous variable ";
R = mxGetN(mxGetFieldByNumber(M_, 0, mxGetFieldNumber(M_, "endo_names")));
C = mxGetM(mxGetFieldByNumber(M_, 0, mxGetFieldNumber(M_, "endo_names")));
P = (double*)mxGetPr(mxGetFieldByNumber(M_, 0, mxGetFieldNumber(M_, "endo_names")));
if(EQN_dvar1<R)
{
for(int i = 0; i < C; i++)
Error_loc << (char*)int(floor(P[EQN_dvar1*C+i]));
}
break;
default:
break;
}
return(Error_loc.str());
}
double double
Interpreter::pow1(double a, double b) Interpreter::pow1(double a, double b)
{ {
...@@ -63,7 +106,7 @@ Interpreter::pow1(double a, double b) ...@@ -63,7 +106,7 @@ Interpreter::pow1(double a, double b)
{ {
if (a < 0 && error_not_printed) if (a < 0 && error_not_printed)
{ {
mexPrintf("Error: X^a with X=%5.15f\n", a); mexPrintf("--------------------------------------\n Error: X^a with X=%5.15f\n in %s\n--------------------------------------\n", a,error_location().c_str());
error_not_printed = false; error_not_printed = false;
r = 0.0000000000000000000000001; r = 0.0000000000000000000000001;
} }
...@@ -82,7 +125,7 @@ Interpreter::log1(double a) ...@@ -82,7 +125,7 @@ Interpreter::log1(double a)
{ {
if (a <= 0 && error_not_printed) if (a <= 0 && error_not_printed)
{ {
mexPrintf("Error: log(X) with X=%5.15f\n", a); mexPrintf("--------------------------------------\n Error: log(X) with X=%5.15f\n in %s\n--------------------------------------\n", a,error_location().c_str());
error_not_printed = false; error_not_printed = false;
} }
res1 = NAN; res1 = NAN;
...@@ -100,10 +143,114 @@ Interpreter::compute_block_time(int Per_u_, bool evaluate, int block_num) ...@@ -100,10 +143,114 @@ Interpreter::compute_block_time(int Per_u_, bool evaluate, int block_num)
double v1, v2; double v1, v2;
bool go_on = true; bool go_on = true;
double ll; double ll;
EQN_block = block_num;
while (go_on) while (go_on)
{ {
switch (it_code->first) switch (it_code->first)
{ {
case FNUMEXPR:
switch (((FNUMEXPR_ *) it_code->second)->get_expression_type())
{
case TemporaryTerm:
EQN_type = TemporaryTerm;
EQN_equation = ((FNUMEXPR_ *) it_code->second)->get_equation();
break;
case ModelEquation:
EQN_type = ModelEquation;
EQN_equation = ((FNUMEXPR_ *) it_code->second)->get_equation();
break;
case FirstEndoDerivative:
EQN_type = FirstEndoDerivative;
EQN_equation = ((FNUMEXPR_ *) it_code->second)->get_equation();
EQN_dvar1 = ((FNUMEXPR_ *) it_code->second)->get_dvariable1();
EQN_lag1 = ((FNUMEXPR_ *) it_code->second)->get_lag1();
break;
case FirstExoDerivative:
EQN_type = FirstExoDerivative;
EQN_equation = ((FNUMEXPR_ *) it_code->second)->get_equation();
EQN_dvar1 = ((FNUMEXPR_ *) it_code->second)->get_dvariable1();
EQN_lag1 = ((FNUMEXPR_ *) it_code->second)->get_lag1();
break;
case FirstExodetDerivative:
EQN_type = FirstExodetDerivative;
EQN_equation = ((FNUMEXPR_ *) it_code->second)->get_equation();
EQN_dvar1 = ((FNUMEXPR_ *) it_code->second)->get_dvariable1();
EQN_lag1 = ((FNUMEXPR_ *) it_code->second)->get_lag1();
break;
case FirstParamDerivative:
EQN_type = FirstParamDerivative;
EQN_equation = ((FNUMEXPR_ *) it_code->second)->get_equation();
EQN_dvar1 = ((FNUMEXPR_ *) it_code->second)->get_dvariable1();
break;
case SecondEndoDerivative:
EQN_type = FirstEndoDerivative;
EQN_equation = ((FNUMEXPR_ *) it_code->second)->get_equation();
EQN_dvar1 = ((FNUMEXPR_ *) it_code->second)->get_dvariable1();
EQN_lag1 = ((FNUMEXPR_ *) it_code->second)->get_lag1();
EQN_dvar2 = ((FNUMEXPR_ *) it_code->second)->get_dvariable2();
EQN_lag2 = ((FNUMEXPR_ *) it_code->second)->get_lag2();
break;
case SecondExoDerivative:
EQN_type = FirstExoDerivative;
EQN_equation = ((FNUMEXPR_ *) it_code->second)->get_equation();
EQN_dvar1 = ((FNUMEXPR_ *) it_code->second)->get_dvariable1();
EQN_lag1 = ((FNUMEXPR_ *) it_code->second)->get_lag1();
EQN_dvar2 = ((FNUMEXPR_ *) it_code->second)->get_dvariable2();
EQN_lag2 = ((FNUMEXPR_ *) it_code->second)->get_lag2();
break;
case SecondExodetDerivative:
EQN_type = FirstExodetDerivative;
EQN_equation = ((FNUMEXPR_ *) it_code->second)->get_equation();
EQN_dvar1 = ((FNUMEXPR_ *) it_code->second)->get_dvariable1();
EQN_lag1 = ((FNUMEXPR_ *) it_code->second)->get_lag1();
EQN_dvar2 = ((FNUMEXPR_ *) it_code->second)->get_dvariable2();
EQN_lag2 = ((FNUMEXPR_ *) it_code->second)->get_lag2();
break;
case SecondParamDerivative:
EQN_type = FirstParamDerivative;
EQN_equation = ((FNUMEXPR_ *) it_code->second)->get_equation();
EQN_dvar1 = ((FNUMEXPR_ *) it_code->second)->get_dvariable1();
EQN_dvar2 = ((FNUMEXPR_ *) it_code->second)->get_dvariable2();
break;
case ThirdEndoDerivative:
EQN_type = FirstEndoDerivative;
EQN_equation = ((FNUMEXPR_ *) it_code->second)->get_equation();
EQN_dvar1 = ((FNUMEXPR_ *) it_code->second)->get_dvariable1();
EQN_lag1 = ((FNUMEXPR_ *) it_code->second)->get_lag1();
EQN_dvar2 = ((FNUMEXPR_ *) it_code->second)->get_dvariable2();
EQN_lag2 = ((FNUMEXPR_ *) it_code->second)->get_lag2();
EQN_dvar3 = ((FNUMEXPR_ *) it_code->second)->get_dvariable3();
EQN_lag3 = ((FNUMEXPR_ *) it_code->second)->get_lag3();
break;
case ThirdExoDerivative:
EQN_type = FirstExoDerivative;
EQN_equation = ((FNUMEXPR_ *) it_code->second)->get_equation();
EQN_dvar1 = ((FNUMEXPR_ *) it_code->second)->get_dvariable1();
EQN_lag1 = ((FNUMEXPR_ *) it_code->second)->get_lag1();
EQN_dvar2 = ((FNUMEXPR_ *) it_code->second)->get_dvariable2();
EQN_lag2 = ((FNUMEXPR_ *) it_code->second)->get_lag2();
EQN_dvar3 = ((FNUMEXPR_ *) it_code->second)->get_dvariable3();
EQN_lag3 = ((FNUMEXPR_ *) it_code->second)->get_lag3();
break;
case ThirdExodetDerivative:
EQN_type = FirstExodetDerivative;
EQN_equation = ((FNUMEXPR_ *) it_code->second)->get_equation();
EQN_dvar1 = ((FNUMEXPR_ *) it_code->second)->get_dvariable1();
EQN_lag1 = ((FNUMEXPR_ *) it_code->second)->get_lag1();
EQN_dvar2 = ((FNUMEXPR_ *) it_code->second)->get_dvariable2();
EQN_lag2 = ((FNUMEXPR_ *) it_code->second)->get_lag2();
EQN_dvar3 = ((FNUMEXPR_ *) it_code->second)->get_dvariable3();
EQN_lag3 = ((FNUMEXPR_ *) it_code->second)->get_lag3();
break;
case ThirdParamDerivative:
EQN_type = FirstParamDerivative;
EQN_equation = ((FNUMEXPR_ *) it_code->second)->get_equation();
EQN_dvar1 = ((FNUMEXPR_ *) it_code->second)->get_dvariable1();
EQN_dvar2 = ((FNUMEXPR_ *) it_code->second)->get_dvariable2();
EQN_dvar3 = ((FNUMEXPR_ *) it_code->second)->get_dvariable3();
break;
}
break;
case FLDV: case FLDV:
//load a variable in the processor //load a variable in the processor
switch (((FLDV_ *) it_code->second)->get_type()) switch (((FLDV_ *) it_code->second)->get_type())
...@@ -1391,6 +1538,7 @@ Interpreter::compute_blocks(string file_name, string bin_basename, bool steady_s ...@@ -1391,6 +1538,7 @@ Interpreter::compute_blocks(string file_name, string bin_basename, bool steady_s
CodeLoad code; CodeLoad code;
//First read and store in memory the code //First read and store in memory the code
code_liste = code.get_op_code(file_name); code_liste = code.get_op_code(file_name);
EQN_block_number = code.get_block_number();
if (!code_liste.size()) if (!code_liste.size())
{ {
mexPrintf("%s.cod Cannot be opened\n", file_name.c_str()); mexPrintf("%s.cod Cannot be opened\n", file_name.c_str());
......
...@@ -46,9 +46,15 @@ typedef vector<pair<Tags, void * > >::const_iterator it_code_type; ...@@ -46,9 +46,15 @@ typedef vector<pair<Tags, void * > >::const_iterator it_code_type;
class Interpreter : SparseMatrix class Interpreter : SparseMatrix
{ {
protected: private:
ExpressionType EQN_type;
unsigned int EQN_equation, EQN_block, EQN_block_number;
unsigned int EQN_dvar1, EQN_dvar2, EQN_dvar3;
int EQN_lag1, EQN_lag2, EQN_lag3;
protected:
double pow1(double a, double b); double pow1(double a, double b);
double log1(double a); double log1(double a);
string error_location();
void compute_block_time(int Per_u_, bool evaluate, int block_num); void compute_block_time(int Per_u_, bool evaluate, int block_num);
void evaluate_a_block(const int size, const int type, string bin_basename, bool steady_state, int block_num, void evaluate_a_block(const int size, const int type, string bin_basename, bool steady_state, int block_num,
const bool is_linear = false, const int symbol_table_endo_nbr = 0, const int Block_List_Max_Lag = 0, const int Block_List_Max_Lead = 0, const int u_count_int = 0); const bool is_linear = false, const int symbol_table_endo_nbr = 0, const int Block_List_Max_Lag = 0, const int Block_List_Max_Lead = 0, const int u_count_int = 0);
......
...@@ -94,7 +94,9 @@ enum Tags ...@@ -94,7 +94,9 @@ enum Tags
FENDEQU, //!< Defines the last equation of the block. For block that has to be solved, the derivatives appear just after this flag - 19 FENDEQU, //!< Defines the last equation of the block. For block that has to be solved, the derivatives appear just after this flag - 19
FEND, //!< Defines the end of the model code - 1A FEND, //!< Defines the end of the model code - 1A
FOK //!< Used for debugging purpose - 1B FOK, //!< Used for debugging purpose - 1B
FNUMEXPR //!< Store the expression type and references
}; };
...@@ -140,6 +142,24 @@ enum SymbolType ...@@ -140,6 +142,24 @@ enum SymbolType
eUnknownFunction = 12 //!< Function unknown to the preprocessor eUnknownFunction = 12 //!< Function unknown to the preprocessor
}; };
enum ExpressionType
{
TemporaryTerm,
ModelEquation,
FirstEndoDerivative,
FirstExoDerivative,
FirstExodetDerivative,
FirstParamDerivative,
SecondEndoDerivative,
SecondExoDerivative,
SecondExodetDerivative,
SecondParamDerivative,
ThirdEndoDerivative,
ThirdExoDerivative,
ThirdExodetDerivative,
ThirdParamDerivative
};
enum UnaryOpcode enum UnaryOpcode
{ {
oUminus, oUminus,
...@@ -731,6 +751,115 @@ public: ...@@ -731,6 +751,115 @@ public:
}; };
}; };
class FNUMEXPR_ : public TagWithOneArgument<ExpressionType>
{
private:
unsigned int equation;
uint16_t dvariable1, dvariable2, dvariable3;
int8_t lag1, lag2, lag3;
public:
inline FNUMEXPR_() : TagWithOneArgument<ExpressionType>::TagWithOneArgument(FNUMEXPR)
{
};
inline FNUMEXPR_(const ExpressionType expression_type, unsigned int equation_arg) : TagWithOneArgument<ExpressionType>::TagWithOneArgument(FNUMEXPR, expression_type),
dvariable1(0), dvariable2(0), dvariable3(0), lag1(0), lag2(0), lag3(0)
{
equation = equation_arg;
};
inline FNUMEXPR_(const ExpressionType expression_type, unsigned int equation_arg, unsigned int dvariable1_arg) : TagWithOneArgument<ExpressionType>::TagWithOneArgument(FNUMEXPR, expression_type),
dvariable2(0), dvariable3(0), lag1(0), lag2(0), lag3(0)
{
equation = equation_arg;
dvariable1 = dvariable1_arg;
};
inline FNUMEXPR_(const ExpressionType expression_type, unsigned int equation_arg, unsigned int dvariable1_arg, int lag1_arg) : TagWithOneArgument<ExpressionType>::TagWithOneArgument(FNUMEXPR, expression_type),
dvariable2(0), dvariable3(0), lag2(0), lag3(0)
{
equation = equation_arg;
dvariable1 = dvariable1_arg;
lag1 = lag1_arg;
};
inline FNUMEXPR_(const ExpressionType expression_type, unsigned int equation_arg, unsigned int dvariable1_arg, unsigned int dvariable2_arg) : TagWithOneArgument<ExpressionType>::TagWithOneArgument(FNUMEXPR, expression_type),
dvariable3(0), lag1(0), lag2(0), lag3(0)
{
equation = equation_arg;
dvariable1 = dvariable1_arg;
dvariable2 = dvariable2_arg;
};
inline FNUMEXPR_(const ExpressionType expression_type, unsigned int equation_arg, unsigned int dvariable1_arg, int lag1_arg, unsigned int dvariable2_arg, int lag2_arg) : TagWithOneArgument<ExpressionType>::TagWithOneArgument(FNUMEXPR, expression_type),
dvariable3(0), lag3(0)
{
equation = equation_arg;
dvariable1 = dvariable1_arg;
lag1 = lag1_arg;
dvariable2 = dvariable2_arg;
lag2 = lag2_arg;
};
inline FNUMEXPR_(const ExpressionType expression_type, unsigned int equation_arg, unsigned int dvariable1_arg, unsigned int dvariable2_arg, unsigned int dvariable3_arg) : TagWithOneArgument<ExpressionType>::TagWithOneArgument(FNUMEXPR, expression_type),
lag1(0), lag2(0), lag3(0)
{
equation = equation_arg;
dvariable1 = dvariable1_arg;
dvariable2 = dvariable2_arg;
dvariable3 = dvariable3_arg;
};
inline FNUMEXPR_(const ExpressionType expression_type, unsigned int equation_arg, unsigned int dvariable1_arg, int lag1_arg, unsigned int dvariable2_arg, int lag2_arg, unsigned int dvariable3_arg, int lag3_arg) : TagWithOneArgument<ExpressionType>::TagWithOneArgument(FNUMEXPR, expression_type)
{
equation = equation_arg;
dvariable1 = dvariable1_arg;
lag1 = lag1_arg;
dvariable2 = dvariable2_arg;
lag2 = lag2_arg;
dvariable3 = dvariable3_arg;
lag3 = lag3_arg;
};
inline ExpressionType
get_expression_type()
{
return arg1;
}
inline unsigned int
get_equation()
{
return equation;
};
inline unsigned int
get_dvariable1()
{
return dvariable1;
};
inline int
get_lag1()
{
return lag1;
};
inline unsigned int
get_dvariable2()
{
return dvariable2;
};
inline int
get_lag2()
{
return lag2;
};
inline unsigned int
get_dvariable3()
{
return dvariable3;
};
inline int
get_lag3()
{
return lag3;
};
inline void
write(ostream &CompileCode)
{
CompileCode.write(reinterpret_cast<char *>(this), sizeof(FNUMEXPR_));
};
};
class FBEGINBLOCK_ class FBEGINBLOCK_
{ {
private: private:
...@@ -856,8 +985,14 @@ class CodeLoad ...@@ -856,8 +985,14 @@ class CodeLoad
{ {
private: private:
uint8_t *code; uint8_t *code;
unsigned int nb_blocks;
public: public:
inline unsigned int
get_block_number()
{
return nb_blocks;
};
inline void * inline void *
get_current_code() get_current_code()
{ {
...@@ -880,6 +1015,7 @@ public: ...@@ -880,6 +1015,7 @@ public:
CompiledCode.seekg(0); CompiledCode.seekg(0);
CompiledCode.read(reinterpret_cast<char *>(code), Code_Size); CompiledCode.read(reinterpret_cast<char *>(code), Code_Size);
CompiledCode.close(); CompiledCode.close();
nb_blocks = 0;
bool done = false; bool done = false;
while (!done) while (!done)
{ {
...@@ -935,6 +1071,13 @@ public: ...@@ -935,6 +1071,13 @@ public:
tags_liste.push_back(make_pair(FDIMST, code)); tags_liste.push_back(make_pair(FDIMST, code));
code += sizeof(FDIMST_); code += sizeof(FDIMST_);
break; break;
case FNUMEXPR:
# ifdef DEBUGL
mexPrintf("FNUMEXPR\n");
# endif
tags_liste.push_back(make_pair(FNUMEXPR, code));
code += sizeof(FNUMEXPR_);
break;
case FLDC: case FLDC:
# ifdef DEBUGL # ifdef DEBUGL
mexPrintf("FLDC\n"); mexPrintf("FLDC\n");
...@@ -1085,6 +1228,7 @@ public: ...@@ -1085,6 +1228,7 @@ public:
code = fbegin_block->load(code); code = fbegin_block->load(code);
tags_liste.push_back(make_pair(FBEGINBLOCK, fbegin_block)); tags_liste.push_back(make_pair(FBEGINBLOCK, fbegin_block));
nb_blocks++;
} }
break; break;
default: default:
......
...@@ -56,7 +56,7 @@ DynamicModel::AddVariable(int symb_id, int lag) ...@@ -56,7 +56,7 @@ DynamicModel::AddVariable(int symb_id, int lag)
} }
void void
DynamicModel::compileDerivative(ofstream &code_file, int eq, int symb_id, int lag, map_idx_type &map_idx) const DynamicModel::compileDerivative(ofstream &code_file, int eq, int symb_id, int lag, const map_idx_type &map_idx) const
{ {
first_derivatives_type::const_iterator it = first_derivatives.find(make_pair(eq, getDerivID(symbol_table.getID(eEndogenous, symb_id), lag))); first_derivatives_type::const_iterator it = first_derivatives.find(make_pair(eq, getDerivID(symbol_table.getID(eEndogenous, symb_id), lag)));
if (it != first_derivatives.end()) if (it != first_derivatives.end())
...@@ -69,7 +69,7 @@ DynamicModel::compileDerivative(ofstream &code_file, int eq, int symb_id, int la ...@@ -69,7 +69,7 @@ DynamicModel::compileDerivative(ofstream &code_file, int eq, int symb_id, int la
} }
void void
DynamicModel::compileChainRuleDerivative(ofstream &code_file, int eqr, int varr, int lag, map_idx_type &map_idx) const DynamicModel::compileChainRuleDerivative(ofstream &code_file, int eqr, int varr, int lag, const map_idx_type &map_idx) const
{ {
map<pair<int, pair<int, int> >, NodeID>::const_iterator it = first_chain_rule_derivatives.find(make_pair(eqr, make_pair(varr, lag))); map<pair<int, pair<int, int> >, NodeID>::const_iterator it = first_chain_rule_derivatives.find(make_pair(eqr, make_pair(varr, lag)));
if (it != first_chain_rule_derivatives.end()) if (it != first_chain_rule_derivatives.end())
...@@ -729,7 +729,7 @@ DynamicModel::writeModelEquationsOrdered_M(const string &dynamic_basename) const ...@@ -729,7 +729,7 @@ DynamicModel::writeModelEquationsOrdered_M(const string &dynamic_basename) const
} }
void void
DynamicModel::writeModelEquationsCode(const string file_name, const string bin_basename, map_idx_type map_idx) const DynamicModel::writeModelEquationsCode(string &file_name, const string &bin_basename, const map_idx_type &map_idx) const
{ {
ostringstream tmp_output; ostringstream tmp_output;
ofstream code_file; ofstream code_file;
...@@ -796,6 +796,8 @@ DynamicModel::writeModelEquationsCode(const string file_name, const string bin_b ...@@ -796,6 +796,8 @@ DynamicModel::writeModelEquationsCode(const string file_name, const string bin_b
int symb = getSymbIDByDerivID(deriv_id); int symb = getSymbIDByDerivID(deriv_id);
unsigned int var = symbol_table.getTypeSpecificID(symb); unsigned int var = symbol_table.getTypeSpecificID(symb);
int lag = getLagByDerivID(deriv_id); int lag = getLagByDerivID(deriv_id);
FNUMEXPR_ fnumexpr(FirstEndoDerivative, eq, var, lag);
fnumexpr.write(code_file);
if (!derivatives[eq].size()) if (!derivatives[eq].size())
derivatives[eq].clear(); derivatives[eq].clear();
derivatives[eq].push_back(make_pair(make_pair(var, lag), count_u)); derivatives[eq].push_back(make_pair(make_pair(var, lag), count_u));
...@@ -840,7 +842,7 @@ DynamicModel::writeModelEquationsCode(const string file_name, const string bin_b ...@@ -840,7 +842,7 @@ DynamicModel::writeModelEquationsCode(const string file_name, const string bin_b
void void
DynamicModel::writeModelEquationsCode_Block(const string file_name, const string bin_basename, map_idx_type map_idx) const DynamicModel::writeModelEquationsCode_Block(string &file_name, const string &bin_basename, const map_idx_type &map_idx) const
{ {
struct Uff_l struct Uff_l
{ {
...@@ -925,6 +927,8 @@ DynamicModel::writeModelEquationsCode_Block(const string file_name, const string ...@@ -925,6 +927,8 @@ DynamicModel::writeModelEquationsCode_Block(const string file_name, const string
for (temporary_terms_type::const_iterator it = v_temporary_terms[block][i].begin(); for (temporary_terms_type::const_iterator it = v_temporary_terms[block][i].begin();
it != v_temporary_terms[block][i].end(); it++) it != v_temporary_terms[block][i].end(); it++)
{ {
FNUMEXPR_ fnumexpr(TemporaryTerm, (int)(map_idx.find((*it)->idx)->second));
fnumexpr.write(code_file);
(*it)->compile(code_file, false, tt2, map_idx, true, false); (*it)->compile(code_file, false, tt2, map_idx, true, false);
FSTPT_ fstpt((int)(map_idx.find((*it)->idx)->second)); FSTPT_ fstpt((int)(map_idx.find((*it)->idx)->second));
fstpt.write(code_file); fstpt.write(code_file);
...@@ -957,6 +961,10 @@ DynamicModel::writeModelEquationsCode_Block(const string file_name, const string ...@@ -957,6 +961,10 @@ DynamicModel::writeModelEquationsCode_Block(const string file_name, const string
case EVALUATE_BACKWARD: case EVALUATE_BACKWARD:
case EVALUATE_FORWARD: case EVALUATE_FORWARD:
equ_type = getBlockEquationType(block, i); equ_type = getBlockEquationType(block, i);
{
FNUMEXPR_ fnumexpr(ModelEquation, getBlockEquationID(block, i));
fnumexpr.write(code_file);
}
if (equ_type == E_EVALUATE) if (equ_type == E_EVALUATE)
{ {
eq_node = (BinaryOpNode *) getBlockEquationNodeID(block, i); eq_node = (BinaryOpNode *) getBlockEquationNodeID(block, i);
...@@ -987,6 +995,8 @@ DynamicModel::writeModelEquationsCode_Block(const string file_name, const string ...@@ -987,6 +995,8 @@ DynamicModel::writeModelEquationsCode_Block(const string file_name, const string
goto end; goto end;
default: default:
end: end:
FNUMEXPR_ fnumexpr(ModelEquation, getBlockEquationID(block, i));
fnumexpr.write(code_file);
eq_node = (BinaryOpNode *) getBlockEquationNodeID(block, i); eq_node = (BinaryOpNode *) getBlockEquationNodeID(block, i);
lhs = eq_node->get_arg1(); lhs = eq_node->get_arg1();
rhs = eq_node->get_arg2(); rhs = eq_node->get_arg2();
...@@ -1009,6 +1019,10 @@ DynamicModel::writeModelEquationsCode_Block(const string file_name, const string ...@@ -1009,6 +1019,10 @@ DynamicModel::writeModelEquationsCode_Block(const string file_name, const string
{ {
case SOLVE_BACKWARD_SIMPLE: case SOLVE_BACKWARD_SIMPLE:
case SOLVE_FORWARD_SIMPLE: case SOLVE_FORWARD_SIMPLE:
{
FNUMEXPR_ fnumexpr(FirstEndoDerivative, getBlockEquationID(block, i), getBlockVariableID(block, 0), 0);
fnumexpr.write(code_file);
}
compileDerivative(code_file, getBlockEquationID(block, 0), getBlockVariableID(block, 0), 0, map_idx); compileDerivative(code_file, getBlockEquationID(block, 0), getBlockVariableID(block, 0), 0, map_idx);
{ {
FSTPG_ fstpg(0); FSTPG_ fstpg(0);
...@@ -1044,6 +1058,8 @@ DynamicModel::writeModelEquationsCode_Block(const string file_name, const string ...@@ -1044,6 +1058,8 @@ DynamicModel::writeModelEquationsCode_Block(const string file_name, const string
Uf[eqr].Ufl->u = count_u; Uf[eqr].Ufl->u = count_u;