changeset 25047:1fe6002f68a7 stable

update arpack checks for F77_INT vs octave_idx_type changes * acinclude.m4 (OCTAVE_CHECK_LIB_ARPACK_OK_1): Update prototypes for Fortran functions. Define and use F77_INT in test code.
author John W. Eaton <jwe@octave.org>
date Thu, 29 Mar 2018 11:15:04 -0400
parents a4c687fec320
children d298a0734d85
files m4/acinclude.m4
diffstat 1 files changed, 39 insertions(+), 35 deletions(-) [+]
line wrap: on
line diff
--- a/m4/acinclude.m4	Wed Mar 28 14:38:43 2018 -0700
+++ b/m4/acinclude.m4	Thu Mar 29 11:15:04 2018 -0400
@@ -835,7 +835,9 @@
 dnl allocated arrays in Fortran does not?
 dnl
 dnl FIXME: it would be nice to avoid the duplication of F77 macros
-dnl and typedefs here and in the f77-fcn.h header file.
+dnl and typedefs here and in the f77-fcn.h header file.  Also, the
+dnl definition of the character handling macros are not right for
+dnl all systems (but should work on most modern systems in use today).
 dnl
 AC_DEFUN([OCTAVE_CHECK_LIB_ARPACK_OK_1], [
   AC_CACHE_CHECK([whether the arpack library works],
@@ -847,7 +849,6 @@
 
 #include <stdint.h>
 
-typedef OCTAVE_IDX_TYPE octave_idx_type;
 typedef int F77_RET_T;
 
 #define F77_CHAR_ARG2(x, l) x
@@ -858,46 +859,49 @@
 #define F77_CONST_CHAR_ARG_DECL const char *
 #define F77_CHAR_ARG_LEN_DECL , long
 
+#define F77_INT $OCTAVE_F77_INT_TYPE
+#define F77_DBLE double
+
 extern "C"
 {
   F77_RET_T
-  F77_FUNC (dnaupd, DNAUPD) (octave_idx_type&,
+  F77_FUNC (dnaupd, DNAUPD) (F77_INT&,
                              F77_CONST_CHAR_ARG_DECL,
-                             const octave_idx_type&,
+                             const F77_INT&,
                              F77_CONST_CHAR_ARG_DECL,
-                             octave_idx_type&, const double&,
-                             double*, const octave_idx_type&, double*,
-                             const octave_idx_type&, octave_idx_type*,
-                             octave_idx_type*, double*, double*,
-                             const octave_idx_type&, octave_idx_type&
+                             F77_INT&, const F77_DBLE&,
+                             F77_DBLE*, const F77_INT&, F77_DBLE*,
+                             const F77_INT&, F77_INT*,
+                             F77_INT*, F77_DBLE*, F77_DBLE*,
+                             const F77_INT&, F77_INT&
                              F77_CHAR_ARG_LEN_DECL
                              F77_CHAR_ARG_LEN_DECL);
 
   F77_RET_T
-  F77_FUNC (dneupd, DNEUPD) (const octave_idx_type&,
+  F77_FUNC (dneupd, DNEUPD) (const F77_INT&,
                              F77_CONST_CHAR_ARG_DECL,
-                             octave_idx_type*, double*, double*,
-                             double*, const octave_idx_type&, const double&,
-                             const double&, double*,
+                             F77_INT*, F77_DBLE*, F77_DBLE*,
+                             F77_DBLE*, const F77_INT&, const F77_DBLE&,
+                             const F77_DBLE&, F77_DBLE*,
                              F77_CONST_CHAR_ARG_DECL,
-                             const octave_idx_type&,
+                             const F77_INT&,
                              F77_CONST_CHAR_ARG_DECL,
-                             octave_idx_type&, const double&, double*,
-                             const octave_idx_type&, double*,
-                             const octave_idx_type&, octave_idx_type*,
-                             octave_idx_type*, double*, double*,
-                             const octave_idx_type&, octave_idx_type&
+                             F77_INT&, const F77_DBLE&, F77_DBLE*,
+                             const F77_INT&, F77_DBLE*,
+                             const F77_INT&, F77_INT*,
+                             F77_INT*, F77_DBLE*, F77_DBLE*,
+                             const F77_INT&, F77_INT&
                              F77_CHAR_ARG_LEN_DECL
                              F77_CHAR_ARG_LEN_DECL
                              F77_CHAR_ARG_LEN_DECL);
 
   F77_RET_T
   F77_FUNC (dgemv, DGEMV) (F77_CONST_CHAR_ARG_DECL,
-                           const octave_idx_type&, const octave_idx_type&,
-                           const double&, const double*,
-                           const octave_idx_type&, const double*,
-                           const octave_idx_type&, const double&, double*,
-                           const octave_idx_type&
+                           const F77_INT&, const F77_INT&,
+                           const F77_DBLE&, const F77_DBLE*,
+                           const F77_INT&, const F77_DBLE*,
+                           const F77_INT&, const F77_DBLE&,
+                           F77_DBLE*, const F77_INT&
                            F77_CHAR_ARG_LEN_DECL);
 }
 
@@ -907,7 +911,7 @@
   // Based on function EigsRealNonSymmetricMatrix from liboctave/eigs-base.cc.
 
   // Problem matrix.  See bug #31479.
-  octave_idx_type n = 4;
+  F77_INT n = 4;
   double *m = new double [n * n];
   m[0] = 1, m[4] = 0, m[8]  = 0, m[12] = -1;
   m[1] = 0, m[5] = 1, m[9]  = 0, m[13] =  0;
@@ -921,7 +925,7 @@
   resid[2] = 0.150143;
   resid[3] = 0.868067;
 
-  octave_idx_type *ip = new octave_idx_type [11];
+  F77_INT *ip = new F77_INT [11];
 
   ip[0] = 1;   // ishift
   ip[1] = 0;   // ip[1] not referenced
@@ -935,18 +939,18 @@
   ip[9] = 0;
   ip[10] = 0;
 
-  octave_idx_type *ipntr = new octave_idx_type [14];
+  F77_INT *ipntr = new F77_INT [14];
 
-  octave_idx_type k = 1;
-  octave_idx_type p = 3;
-  octave_idx_type lwork = 3 * p * (p + 2);
+  F77_INT k = 1;
+  F77_INT p = 3;
+  F77_INT lwork = 3 * p * (p + 2);
 
   double *v = new double [n * (p + 1)];
   double *workl = new double [lwork + 1];
   double *workd = new double [3 * n + 1];
 
-  octave_idx_type ido = 0;
-  octave_idx_type info = 0;
+  F77_INT ido = 0;
+  F77_INT info = 0;
 
   double tol = DBL_EPSILON;
 
@@ -978,17 +982,17 @@
     }
   while (1);
 
-  octave_idx_type *sel = new octave_idx_type [p];
+  F77_INT *sel = new F77_INT [p];
 
   // In Octave, the dimensions of dr and di are k+1, but k+2 avoids segfault
   double *dr = new double [k + 1];
   double *di = new double [k + 1];
   double *workev = new double [3 * p];
 
-  for (octave_idx_type i = 0; i < k + 1; i++)
+  for (F77_INT i = 0; i < k + 1; i++)
     dr[i] = di[i] = 0.0;
 
-  octave_idx_type rvec = 1;
+  F77_INT rvec = 1;
 
   double sigmar = 0.0;
   double sigmai = 0.0;