From 04a238376d16417797b8fd4b8e1f7deacbe60f2b Mon Sep 17 00:00:00 2001
From: MichelJuillard <michel.juillard@mjui.fr>
Date: Sun, 20 Nov 2022 09:30:14 +0100
Subject: [PATCH] remove module in Julia files

---
 src/DynamicModel.hh       | 22 +++-------------------
 src/ModelEquationBlock.cc |  7 ++-----
 src/StaticModel.hh        | 18 ++----------------
 3 files changed, 7 insertions(+), 40 deletions(-)

diff --git a/src/DynamicModel.hh b/src/DynamicModel.hh
index c5db1000..2ea1598d 100644
--- a/src/DynamicModel.hh
+++ b/src/DynamicModel.hh
@@ -959,44 +959,28 @@ DynamicModel::writeParamsDerivativesFile(const string &basename) const
                        << "end" << endl;
     }
   else
-    paramsDerivsFile << "module " << basename << "DynamicParamsDerivs" << endl
-                     << "#" << endl
-                     << "# NB: this file was automatically generated by Dynare" << endl
+    paramsDerivsFile << "# NB: this file was automatically generated by Dynare" << endl
                      << "#     from " << basename << ".mod" << endl
                      << "#" << endl
-                     << "export params_derivs" << endl << endl
-                     << "function params_derivs(y, x, paramssteady_state, it_, "
+                     << "function params_derivs(y, x, paramssteady_state, "
                      << "ss_param_deriv, ss_param_2nd_deriv)" << endl
 		     << "@inbounds begin" << endl
                      << tt_output.str()
-		     << "end" << endl
                      << "rp = zeros(" << equations.size() << ", "
                      << symbol_table.param_nbr() << ");" << endl
-		     << "@inbounds begin" << endl
                      << rp_output.str()
-		     << "end" << endl
                      << "gp = zeros(" << equations.size() << ", " << getJacobianColsNbr(false) << ", " << symbol_table.param_nbr() << ");" << endl
-		     << "@inbounds begin" << endl
                      << gp_output.str()
-		     << "end" << endl
                      << "rpp = zeros(" << params_derivatives.at({ 0, 2 }).size() << ",4);" << endl
-		     << "@inbounds begin" << endl
                      << rpp_output.str()
-		     << "end" << endl
                      << "gpp = zeros(" << params_derivatives.at({ 1, 2 }).size() << ",5);" << endl
-		     << "@inbounds begin" << endl
                      << gpp_output.str()
-		     << "end" << endl
                      << "hp = zeros(" << params_derivatives.at({ 2, 1 }).size() << ",5);" << endl
-		     << "@inbounds begin" << endl
                      << hp_output.str()
-		     << "end" << endl
                      << "g3p = zeros(" << params_derivatives.at({ 3, 1 }).size() << ",6);" << endl
-		     << "@inbounds begin" << endl
                      << g3p_output.str()
 		     << "end" << endl
-                     << "(rp, gp, rpp, gpp, hp, g3p)" << endl
-                     << "end" << endl
+                     << "return (rp, gp, rpp, gpp, hp, g3p)" << endl
                      << "end" << endl;
 
   paramsDerivsFile.close();
diff --git a/src/ModelEquationBlock.cc b/src/ModelEquationBlock.cc
index 745fb6da..ef78b7d9 100644
--- a/src/ModelEquationBlock.cc
+++ b/src/ModelEquationBlock.cc
@@ -221,12 +221,9 @@ SteadyStateModel::writeSteadyStateFile(const string &basename, bool julia) const
            << "% Steady state generated by Dynare preprocessor" << endl
            << "    info = 0;" << endl;
   else
-    output << "module " << basename << "SteadyState2" << endl
-           << "#" << endl
-           << "# NB: this file was automatically generated by Dynare" << endl
+    output << "# NB: this file was automatically generated by Dynare" << endl
            << "#     from " << basename << ".mod" << endl
            << "#" << endl
-           << "export steady_state!" << endl << endl
            << "function steady_state!(ys_::Vector{<: Real}, exo_::Vector{<: Real}, "
            << "params::Vector{<: Real})" << endl
 	   << "@inbounds begin" << endl;
@@ -257,7 +254,7 @@ SteadyStateModel::writeSteadyStateFile(const string &basename, bool julia) const
 
   output << "end" << endl;
   if (julia)
-    output << "end" << endl << "end" << endl;
+    output << "end" << endl;
 
   if (julia)
     writeToFileIfModified(output, filesystem::path{basename} / "model" / "julia" / "SteadyState2.jl");
diff --git a/src/StaticModel.hh b/src/StaticModel.hh
index 6ec94ac4..52fdc638 100644
--- a/src/StaticModel.hh
+++ b/src/StaticModel.hh
@@ -294,40 +294,26 @@ StaticModel::writeParamsDerivativesFile(const string &basename) const
                        << "end" << endl;
     }
   else
-    paramsDerivsFile << "module " << basename << "StaticParamsDerivs" << endl
-                     << "#" << endl
-                     << "# NB: this file was automatically generated by Dynare" << endl
+    paramsDerivsFile << "# NB: this file was automatically generated by Dynare" << endl
                      << "#     from " << basename << ".mod" << endl
                      << "#" << endl
-                     << "export params_derivs" << endl << endl
                      << "function params_derivs(y, x, params)" << endl
 		     << "@inbounds begin" << endl
                      << tt_output.str()
-		     << "end" << endl
                      << "rp = zeros(" << equations.size() << ", "
                      << symbol_table.param_nbr() << ");" << endl
-		     << "@inbounds begin" << endl
                      << rp_output.str()
-		     << "end" << endl
                      << "gp = zeros(" << equations.size() << ", " << symbol_table.endo_nbr() << ", "
                      << symbol_table.param_nbr() << ");" << endl
-		     << "@inbounds begin" << endl
                      << gp_output.str()
-		     << "end" << endl
                      << "rpp = zeros(" << params_derivatives.at({ 0, 2 }).size() << ",4);" << endl
-		     << "@inbounds begin" << endl
                      << rpp_output.str()
-		     << "end" << endl
                      << "gpp = zeros(" << params_derivatives.at({ 1, 2 }).size() << ",5);" << endl
-		     << "@inbounds begin" << endl
                      << gpp_output.str()
-		     << "end" << endl
                      << "hp = zeros(" << params_derivatives.at({ 2, 1 }).size() << ",5);" << endl
-		     << "@inbounds begin" << endl
                      << hp_output.str()
 		     << "end" << endl
-                     << "(rp, gp, rpp, gpp, hp)" << endl
-                     << "end" << endl
+                     << "return (rp, gp, rpp, gpp, hp)" << endl
                      << "end" << endl;
 
   paramsDerivsFile.close();
-- 
GitLab