From ae76a8f842f320e48478edaa031c5fed7135e49a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= <sebastien.villemot@ens.fr>
Date: Wed, 22 Jun 2011 11:34:25 +0200
Subject: [PATCH] Preprocessor: fix crash when no computational task is
 required

---
 preprocessor/DynamicModel.cc | 2 ++
 preprocessor/ModFile.cc      | 2 --
 preprocessor/StaticModel.cc  | 2 ++
 3 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/preprocessor/DynamicModel.cc b/preprocessor/DynamicModel.cc
index 896fa47cbf..186dbbd0cf 100644
--- a/preprocessor/DynamicModel.cc
+++ b/preprocessor/DynamicModel.cc
@@ -2683,6 +2683,8 @@ DynamicModel::computingPass(bool jacobianExo, bool hessian, bool thirdDerivative
 {
   assert(jacobianExo || !(hessian || thirdDerivatives || paramsDerivatives));
 
+  initializeVariablesAndEquations();
+  
   // Prepare for derivation
   computeDerivIDs();
 
diff --git a/preprocessor/ModFile.cc b/preprocessor/ModFile.cc
index 33c964ca07..e21e46e217 100644
--- a/preprocessor/ModFile.cc
+++ b/preprocessor/ModFile.cc
@@ -358,7 +358,6 @@ ModFile::computingPass(bool no_tmp_terms)
       dynamic_model.toStatic(static_model);
       if (!no_static)
         {
-          static_model.initializeVariablesAndEquations();
           if (mod_file_struct.stoch_simul_present
               || mod_file_struct.estimation_present || mod_file_struct.osr_present
               || mod_file_struct.ramsey_policy_present || mod_file_struct.identification_present)
@@ -371,7 +370,6 @@ ModFile::computingPass(bool no_tmp_terms)
           || mod_file_struct.estimation_present || mod_file_struct.osr_present
           || mod_file_struct.ramsey_policy_present || mod_file_struct.identification_present)
         {
-          dynamic_model.initializeVariablesAndEquations();
           if (mod_file_struct.simul_present)
             dynamic_model.computingPass(true, false, false, false, global_eval_context, no_tmp_terms, block, use_dll, byte_code);
           else
diff --git a/preprocessor/StaticModel.cc b/preprocessor/StaticModel.cc
index 2488a3cdd9..b6fcb571a3 100644
--- a/preprocessor/StaticModel.cc
+++ b/preprocessor/StaticModel.cc
@@ -1065,6 +1065,8 @@ StaticModel::collect_first_order_derivatives_endogenous()
 void
 StaticModel::computingPass(const eval_context_t &eval_context, bool no_tmp_terms, bool hessian, bool block, bool bytecode)
 {
+  initializeVariablesAndEquations();
+
   // Compute derivatives w.r. to all endogenous, and possibly exogenous and exogenous deterministic
   set<int> vars;
 
-- 
GitLab