From dfcd381d203c427621e498690117c7c7383ea412 Mon Sep 17 00:00:00 2001
From: Houtan Bastani <houtan@dynare.org>
Date: Thu, 12 Dec 2019 14:45:49 +0100
Subject: [PATCH] epilogue: fix bug with external functions in `epilogue` block

issue #36
---
 src/ExprNode.cc           |  1 +
 src/ModelEquationBlock.cc | 11 -----------
 2 files changed, 1 insertion(+), 11 deletions(-)

diff --git a/src/ExprNode.cc b/src/ExprNode.cc
index e4da0249..31690247 100644
--- a/src/ExprNode.cc
+++ b/src/ExprNode.cc
@@ -7698,6 +7698,7 @@ ExternalFunctionNode::writeOutput(ostream &output, ExprNodeOutputType output_typ
 {
   if (output_type == ExprNodeOutputType::matlabOutsideModel || output_type == ExprNodeOutputType::steadyStateFile
       || output_type == ExprNodeOutputType::juliaSteadyStateFile
+      || output_type == ExprNodeOutputType::epilogueFile
       || isLatexOutput(output_type))
     {
       string name = isLatexOutput(output_type) ? datatree.symbol_table.getTeXName(symb_id)
diff --git a/src/ModelEquationBlock.cc b/src/ModelEquationBlock.cc
index 9107b1b4..07cc7880 100644
--- a/src/ModelEquationBlock.cc
+++ b/src/ModelEquationBlock.cc
@@ -398,17 +398,6 @@ Epilogue::writeEpilogueFile(const string & basename, bool dynamic_file) const
   deriv_node_temp_terms_t tef_terms;
   temporary_terms_t temporary_terms;
   temporary_terms_idxs_t temporary_terms_idxs;
-  for (const auto & [symb_id, expr] : dynamic_def_table)
-    {
-      if (expr->containsExternalFunction())
-        if (dynamic_file)
-          expr->writeExternalFunctionOutput(output, ExprNodeOutputType::epilogueFile, temporary_terms, temporary_terms_idxs, tef_terms);
-        else
-          static_def_table.at(def_table_idx).second->writeExternalFunctionOutput(output, ExprNodeOutputType::epilogueFile, temporary_terms, temporary_terms_idxs, tef_terms);
-      def_table_idx++;
-    }
-  output << endl;
-  def_table_idx = 0;
   for (const auto & [symb_id, expr] : dynamic_def_table)
     {
       int max_lag = expr->maxLagWithDiffsExpanded();
-- 
GitLab