diff --git a/matlab/dynare.m b/matlab/dynare.m index aea60ea5e..27a1fe742 100644 --- a/matlab/dynare.m +++ b/matlab/dynare.m @@ -64,7 +64,11 @@ more off % sets default format for save() command if isoctave - default_save_options('-mat') + if octave_ver_less_than('3.8') + default_save_options('-mat') + else + save_default_options('-mat') + end end if nargin < 1 diff --git a/matlab/dynare_config.m b/matlab/dynare_config.m index d52edad9f..4405c12e8 100644 --- a/matlab/dynare_config.m +++ b/matlab/dynare_config.m @@ -94,8 +94,9 @@ if isoctave || matlab_ver_less_than('7.4') addpath([dynareroot '/missing/ilu']) end -% strjoin is missing in older versions of MATLAB and in Octave -if isoctave || matlab_ver_less_than('8.1') +% strjoin is missing in older versions of MATLAB and in Octave < 3.8 +if (isoctave && octave_ver_less_than('3.8')) || ... + (~isoctave && matlab_ver_less_than('8.1')) addpath([dynareroot '/missing/strjoin']) end diff --git a/mex/build/octave/Makefile.am b/mex/build/octave/Makefile.am index 3b88c5910..ad816373a 100644 --- a/mex/build/octave/Makefile.am +++ b/mex/build/octave/Makefile.am @@ -2,7 +2,11 @@ ACLOCAL_AMFLAGS = -I ../../../m4 # libdynare++ must come before gensylv, k_order_perturbation, dynare_simul_ if DO_SOMETHING -SUBDIRS = mjdgges kronecker bytecode libdynare++ gensylv qzcomplex ordschur block_kalman_filter sobol local_state_space_iterations linsolve +SUBDIRS = mjdgges kronecker bytecode libdynare++ gensylv qzcomplex ordschur block_kalman_filter sobol local_state_space_iterations + +if COMPILE_LINSOLVE +SUBDIRS += linsolve +endif if HAVE_MATIO SUBDIRS += k_order_perturbation dynare_simul_ diff --git a/mex/build/octave/configure.ac b/mex/build/octave/configure.ac index 92526cb5c..db82b4fd2 100755 --- a/mex/build/octave/configure.ac +++ b/mex/build/octave/configure.ac @@ -31,8 +31,13 @@ if test "x$MKOCTFILE" != "x"; then FFLAGS=`$MKOCTFILE -p FFLAGS` CXXFLAGS=`$MKOCTFILE -p CXXFLAGS` LDFLAGS="`$MKOCTFILE -p LFLAGS` `$MKOCTFILE -p LDFLAGS`" + OCTAVE_VERSION=`$MKOCTFILE -v 2>&1 | sed 's/mkoctfile, version //'` + AX_COMPARE_VERSION([$OCTAVE_VERSION], [lt], [3.6], [AC_MSG_ERROR([Your Octave is too old, please upgrade to version 3.6 at least.])]) + AX_COMPARE_VERSION([$OCTAVE_VERSION], [ge], [3.8], [OCTAVE38=yes]) fi +AM_CONDITIONAL([COMPILE_LINSOLVE], [test "$OCTAVE38" != "yes"]) + CFLAGS="$CFLAGS -Wall -Wno-parentheses" FFLAGS="$FFLAGS -Wall" CXXFLAGS="$CXXFLAGS -Wall -Wno-parentheses" @@ -110,6 +115,12 @@ else BUILD_MS_SBVAR_MEX_OCTAVE="no (missing GSL or MatIO library)" fi +if test -n "$MKOCTFILE" -a "$OCTAVE38" != "yes"; then + BUILD_LINSOLVE_OCTAVE="yes" +else + BUILD_LINSOLVE_OCTAVE="no (Octave >= 3.8)" +fi + AC_ARG_ENABLE([openmp], AS_HELP_STRING([--enable-openmp], [use OpenMP for parallelization of some MEX files]), [ if test "x$enable_openmp" = "xyes"; then CPPFLAGS="$CPPFLAGS -DUSE_OMP" @@ -127,6 +138,7 @@ Binaries (with "make"): MS-SBVAR MEX files for Octave: $BUILD_MS_SBVAR_MEX_OCTAVE Kalman Steady State MEX file for Octave: $BUILD_KALMAN_STEADY_STATE_OCTAVE Estimation, k-order and dynare_simul MEX for Octave: $BUILD_ESTIMATION_KORDER_DYNSIMUL_MEX_OCTAVE + Linsolve for Octave: $BUILD_LINSOLVE_OCTAVE ]) diff --git a/mex/sources/bytecode/ErrorHandling.hh b/mex/sources/bytecode/ErrorHandling.hh index 2a28c3dce..6e2024a37 100644 --- a/mex/sources/bytecode/ErrorHandling.hh +++ b/mex/sources/bytecode/ErrorHandling.hh @@ -267,9 +267,6 @@ struct s_plan #ifdef MATLAB_MEX_FILE extern "C" bool utIsInterruptPending(); -#else -#include -#include #endif #ifdef _MSC_VER @@ -575,9 +572,7 @@ public: while (go_on) { -#ifdef OCTAVE_MEX_FILE - OCTAVE_QUIT; -#else +#ifdef MATLAB_MEX_FILE if ( utIsInterruptPending() ) throw UserExceptionHandling(); #endif diff --git a/mex/sources/bytecode/Evaluate.cc b/mex/sources/bytecode/Evaluate.cc index 89b79ef87..76aec3b1b 100644 --- a/mex/sources/bytecode/Evaluate.cc +++ b/mex/sources/bytecode/Evaluate.cc @@ -24,9 +24,6 @@ #ifdef MATLAB_MEX_FILE extern "C" bool utIsInterruptPending(); -#else -#include -#include #endif Evaluate::Evaluate() @@ -139,9 +136,7 @@ Evaluate::compute_block_time(const int Per_u_, const bool evaluate, /*const int jacob_exo_det = mxGetPr(jacobian_det_exo_block[block_num]); } } -#ifdef OCTAVE_MEX_FILE - OCTAVE_QUIT; -#else +#ifdef MATLAB_MEX_FILE if ( utIsInterruptPending() ) throw UserExceptionHandling(); #endif diff --git a/mex/sources/bytecode/SparseMatrix.cc b/mex/sources/bytecode/SparseMatrix.cc index 70226a798..9cc45e454 100644 --- a/mex/sources/bytecode/SparseMatrix.cc +++ b/mex/sources/bytecode/SparseMatrix.cc @@ -5139,9 +5139,7 @@ dynSparseMatrix::Solve_ByteCode_Symbolic_Sparse_GaussianElimination(int Size, bo { /*clock_t time11 = clock(); mexPrintf("t=%d, record = %d\n",t, record);*/ -#ifdef OCTAVE_MEX_FILE - OCTAVE_QUIT; -#else +#ifdef MATLAB_MEX_FILE if ( utIsInterruptPending() ) throw UserExceptionHandling(); #endif