From ff06b9ad1071aa08a30d85b2c63e836fe6000cf0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= <sebastien@dynare.org>
Date: Wed, 15 Sep 2021 18:35:30 +0200
Subject: [PATCH] More Octave compatibility fixes

---
 matlab/dynare_estimation_1.m     | 7 ++++++-
 tests/estimation/example_nls.mod | 8 +++++++-
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/matlab/dynare_estimation_1.m b/matlab/dynare_estimation_1.m
index 311f283bee..32160ad58e 100644
--- a/matlab/dynare_estimation_1.m
+++ b/matlab/dynare_estimation_1.m
@@ -12,7 +12,7 @@ function dynare_estimation_1(var_list_,dname)
 % SPECIAL REQUIREMENTS
 %   none
 
-% Copyright (C) 2003-2018 Dynare Team
+% Copyright (C) 2003-2021 Dynare Team
 %
 % This file is part of Dynare.
 %
@@ -32,6 +32,11 @@ function dynare_estimation_1(var_list_,dname)
 global M_ options_ oo_ estim_params_ bayestopt_ dataset_ dataset_info
 
 if ~exist([M_.dname filesep 'Output'],'dir')
+    if isoctave && ~exist(M_.dname)
+        % See https://savannah.gnu.org/bugs/index.php?61166
+        % This workaround is needed for recursive estimation.
+        mkdir(M_.dname)
+    end
     mkdir(M_.dname,'Output');
 end
 
diff --git a/tests/estimation/example_nls.mod b/tests/estimation/example_nls.mod
index 1dfd401b81..4a77b09ef7 100644
--- a/tests/estimation/example_nls.mod
+++ b/tests/estimation/example_nls.mod
@@ -58,4 +58,10 @@ eparams.beta = 1;
 
 simulations.ey = dseries(NaN); // Reset residuals of the equation to NaN.
 
-estimate.nls('eq4y', eparams, simulations, dates('3Y'):simulations.dates(end));
+if ~isoctave
+    % Under Octave, estimate.nls (provided by matlab/+estimate/nls.m) is not
+    % accessible because there is a function which has the same name as the
+    % +estimate package, namely matlab/cli/estimate.m. This is a known Octave
+    % bug (https://savannah.gnu.org/bugs/?func=detailitem&item_id=46889).
+    estimate.nls('eq4y', eparams, simulations, dates('3Y'):simulations.dates(end));
+end
-- 
GitLab