From 8baec1e0ec5e06df5e14a96467fe520f5eb6f374 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Adjemian=20=28Charybdis=29?=
 <stepan@adjemian.eu>
Date: Thu, 19 Dec 2019 22:43:52 +0100
Subject: [PATCH] Allow k order estimation.

Automatically switch to k_order_solver if order>2. Use old mex file if
order==2 (since it seems unexpectedly significantly faster than
local_state_space_iteration_k, and because it can deal with pruning).
---
 src/ComputingTasks.cc | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/src/ComputingTasks.cc b/src/ComputingTasks.cc
index b5bdab69..3522f192 100644
--- a/src/ComputingTasks.cc
+++ b/src/ComputingTasks.cc
@@ -1142,8 +1142,7 @@ EstimationStatement::checkPass(ModFileStructure &mod_file_struct, WarningConsoli
 
       if (order > 2)
         {
-          cerr << "ERROR: order > 2 is not supported in estimation" << endl;
-          exit(EXIT_FAILURE);
+          mod_file_struct.k_order_solver = true;
         }
 
       mod_file_struct.order_option = max(mod_file_struct.order_option, order);
@@ -1213,8 +1212,12 @@ EstimationStatement::writeOutput(ostream &output, const string &basename, bool m
   if (auto it = options_list.num_options.find("order");
       it == options_list.num_options.end())
     output << "options_.order = 1;" << endl;
-  else if (stoi(it->second) == 2)
-    output << "options_.particle.status = true;" << endl;
+  else if (stoi(it->second) >= 2)
+    {
+      output << "options_.particle.status = true;" << endl;
+      if (stoi(it->second) > 2)
+        output << "options_.k_order_solver = 1;" << endl;
+    }
 
   // Do not check for the steady state in diffuse filter mode (#400)
   if (auto it = options_list.num_options.find("diffuse_filter");
-- 
GitLab