diff --git a/src/ModelEquationBlock.cc b/src/ModelEquationBlock.cc index 720b37ba2c03a7d75e228f0cbae1cd8dde02fa7d..d4c5121c5758988f37f620fb190d7209876b166f 100644 --- a/src/ModelEquationBlock.cc +++ b/src/ModelEquationBlock.cc @@ -399,15 +399,21 @@ Epilogue::writeStaticEpilogueFile(const string & basename) const for (const auto & [symb_id, expr] : static_def_table) { // Rewrite external function TEF term for every equation as argument values could have been changed - // in between two calls to the same function; + // in between two calls to the same function; deriv_node_temp_terms_t tef_terms; temporary_terms_t temporary_terms; temporary_terms_idxs_t temporary_terms_idxs; + output << endl; if (expr->containsExternalFunction()) expr->writeExternalFunctionOutput(output, ExprNodeOutputType::matlabDseries, temporary_terms, temporary_terms_idxs, tef_terms); - output << "ds." << symbol_table.getName(symb_id) << " = "; + output << "epilogue_static_tmp_term = "; expr->writeOutput(output, ExprNodeOutputType::matlabDseries, temporary_terms, temporary_terms_idxs, tef_terms); - output << ";" << endl; + output << ";" << endl + << "if isdseries(epilogue_static_tmp_term)" << endl + << " ds." << symbol_table.getName(symb_id) << " = epilogue_static_tmp_term;" << endl + << "else" << endl + << " ds." << symbol_table.getName(symb_id) << " = dseries(ones(ds.nobs,1)*epilogue_static_tmp_term, ds.firstdate, '" << symbol_table.getName(symb_id) << "');" << endl + << "end" << endl; } output << "end" << endl; output.close();