From 270f8d7b1d9fb401087e277f0824097ec9f87a4e Mon Sep 17 00:00:00 2001
From: sebastien <sebastien@ac1d8469-bf42-47a9-8791-bf33cf982152>
Date: Wed, 9 Dec 2009 11:50:58 +0000
Subject: [PATCH] k-order: * in the preprocessor, fail if k_order_solver given
 without use_dll * updated the reference manual, in particular w.r. to the new
 wiki page on MEX compilation under Windows

git-svn-id: https://www.dynare.org/svn/dynare/trunk@3216 ac1d8469-bf42-47a9-8791-bf33cf982152
---
 ComputingTasks.cc | 18 ++++++++++++++++++
 ModFile.cc        |  6 ++++++
 ModFile.hh        |  4 ++--
 Statement.cc      |  3 ++-
 Statement.hh      |  2 ++
 5 files changed, 30 insertions(+), 3 deletions(-)

diff --git a/ComputingTasks.cc b/ComputingTasks.cc
index dcf3b6eb..acdd5a92 100644
--- a/ComputingTasks.cc
+++ b/ComputingTasks.cc
@@ -118,6 +118,12 @@ StochSimulStatement::checkPass(ModFileStructure &mod_file_struct)
   it = options_list.num_options.find("partial_information");
   if (it != options_list.num_options.end() && it->second == "1")
     mod_file_struct.partial_information = true;
+
+  // Option k_order_solver (implicit when order >= 3)
+  it = options_list.num_options.find("k_order_solver");
+  if ((it != options_list.num_options.end() && it->second == "1")
+      || mod_file_struct.order_option >= 3)
+    mod_file_struct.k_order_solver = true;
 }
 
 void
@@ -174,6 +180,12 @@ RamseyPolicyStatement::checkPass(ModFileStructure &mod_file_struct)
   it = options_list.num_options.find("partial_information");
   if (it != options_list.num_options.end() && it->second == "1")
     mod_file_struct.partial_information = true;
+
+  // Option k_order_solver (implicit when order >= 3)
+  it = options_list.num_options.find("k_order_solver");
+  if ((it != options_list.num_options.end() && it->second == "1")
+      || mod_file_struct.order_option >= 3)
+    mod_file_struct.k_order_solver = true;
 }
 
 void
@@ -730,6 +742,12 @@ OsrStatement::checkPass(ModFileStructure &mod_file_struct)
   it = options_list.num_options.find("partial_information");
   if (it != options_list.num_options.end() && it->second == "1")
     mod_file_struct.partial_information = true;
+
+  // Option k_order_solver (implicit when order >= 3)
+  it = options_list.num_options.find("k_order_solver");
+  if ((it != options_list.num_options.end() && it->second == "1")
+      || mod_file_struct.order_option >= 3)
+    mod_file_struct.k_order_solver = true;
 }
 
 void
diff --git a/ModFile.cc b/ModFile.cc
index 341d9b03..e3349675 100644
--- a/ModFile.cc
+++ b/ModFile.cc
@@ -118,6 +118,12 @@ ModFile::checkPass()
       exit(EXIT_FAILURE);
     }
 
+  if (mod_file_struct.k_order_solver && !use_dll)
+    {
+      cerr << "ERROR: When using option 'k_order_solver' (which is implicit if order >= 3), you must specify option 'use_dll' on the 'model' block" << endl;
+      exit(EXIT_FAILURE);
+    }
+
   if (use_dll && (block || byte_code))
     {
       cerr << "ERROR: In 'model' block, 'use_dll' option is not compatible with 'block' or 'bytecode'" << endl;
diff --git a/ModFile.hh b/ModFile.hh
index 9c735b55..118b8504 100644
--- a/ModFile.hh
+++ b/ModFile.hh
@@ -57,10 +57,10 @@ public:
   //! Is the model block decomposed?
   bool block;
 
-  //! Is the model stored in baytecode format (byte_code=true) or in a M-file (byte_code=false)
+  //! Is the model stored in bytecode format (byte_code=true) or in a M-file (byte_code=false)
   bool byte_code;
 
-  //! Deprecated option use_dll
+  //! Is the model stored in a MEX file ? (option "use_dll" of "model")
   bool use_dll;
 
   //! Global evaluation context
diff --git a/Statement.cc b/Statement.cc
index ccd1549e..3f16dc1e 100644
--- a/Statement.cc
+++ b/Statement.cc
@@ -31,7 +31,8 @@ ModFileStructure::ModFileStructure() :
   svar_identification_present(false),
   identification_present(false),
   partial_information(false),
-  shocks_present(false)
+  shocks_present(false),
+  k_order_solver(false)
 {
 }
 
diff --git a/Statement.hh b/Statement.hh
index 55844d42..277731ed 100644
--- a/Statement.hh
+++ b/Statement.hh
@@ -59,6 +59,8 @@ public:
   //! Whether a shocks or mshocks block is present
   /*! Used for the workaround for trac ticket #35 */
   bool shocks_present;
+  //! Whether the "k_order_solver" option is used (explictly, or implicitly if order >= 3)
+  bool k_order_solver;
 };
 
 class Statement
-- 
GitLab