octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Complex vector product failed in CMatrix.cc


From: John W. Eaton
Subject: Re: Complex vector product failed in CMatrix.cc
Date: Tue, 23 Oct 2007 15:01:04 -0400

On 23-Oct-2007, David Bateman wrote:

| Did you mix g77 and gfortran calling conventions? See the discussion on
| zdotu in the thread
| 
| http://www.nabble.com/Using-g77-or-gfortran-tf4671984.html
| 
| In short this is not Octave's problem...

I've checked in the following changes to Octave's configure script to
try to detect incompatible calling conventions when the configure
script runs.  Maybe this will help, or maybe it will just generate a
bunch of "I hit this error, now what?" messages.  But I guess I would
prefer that over people getting incorrect results and thinking that
Octave is worthless because it can't even compute a simple vector
product.

jwe


ChangeLog:

2007-10-23  John W. Eaton  <address@hidden>

        * configure.in: When checking for -lf2c, set F2CLIBS instad of
        FLIBS, then set FLIBS to $F2CLIBS just before printing the summary.
        Check for BLAS library calling convention compatibility.


Index: configure.in
===================================================================
RCS file: /cvs/octave/configure.in,v
retrieving revision 1.582
diff -u -r1.582 configure.in
--- configure.in        17 Oct 2007 19:02:10 -0000      1.582
+++ configure.in        23 Oct 2007 18:57:01 -0000
@@ -795,17 +795,21 @@
       CONFLIB_ARG="-MD"
       ;;
   esac
-  AC_CHECK_LIB(f2c, f_open, FLIBS=-lf2c, FLIBS=, $CONFLIB_ARG)
+  XLIBS="$LIBS"
+  LIBS="-lf2c $LIBS $CONFLIB_ARG"
+  AC_LINK_IFELSE([AC_LANG_CALL([int MAIN__ () { return 1; }], [f_open])],
+                 [F2CLIBS=-lf2c], [F2CLIBS=])
+  LIBS="$XLIBS"
   rm -f $oct_conflib
 
-  if test -z "$FLIBS"; then
-    AC_CHECK_LIB(F77, d_sin, FLIBS=-lF77, FLIBS=)
-    if test -n "$FLIBS"; then
-      AC_CHECK_LIB(I77, f_rew, FLIBS="$FLIBS -lI77", FLIBS=, -lF77)
+  if test -z "$F2CLIBS"; then
+    AC_CHECK_LIB(F77, d_sin, F2CLIBS=-lF77, FLIBS=)
+    if test -n "$F2CLIBS"; then
+      AC_CHECK_LIB(I77, f_rew, F2CLIBS="$F2CLIBS -lI77", F2CLIBS=, -lF77)
     fi
   fi
 
-  if test -z "$FLIBS"; then
+  if test -z "$F2CLIBS"; then
     warn_f2c_no_lib="I found f2c but not libf2c.a, or libF77.a and libI77.a"
     AC_MSG_WARN($warn_f2c_no_lib)
   fi
@@ -853,6 +857,58 @@
 AC_SUBST(BLAS_DIR)
 AC_SUBST(LAPACK_DIR)
 
+dnl I see no clean way to do the following check with autoconf macros,
+dnl hence the big mess.
+
+AC_MSG_CHECKING([BLAS library calling convention compatibility])
+cat << EOF > conftest.f
+      program foo
+      double complex zdotu, zx(10), zy(10), retval
+      integer n, incx, incy
+      n = 10
+      incx = 1
+      incy = 1
+      do 10 i = 1, n
+        zx(i) = dcmplx (i, 0)
+        zy(i) = dcmplx (0, i)
+   10 continue
+      retval = zdotu (n, zx, incx, zy, incy)
+      if (retval .eq. dcmplx (0, 385)) then
+        print *, 'succeeded'
+      else
+        print *, 'failed'
+        print *, retval
+      endif
+      end
+EOF
+XLIBS="$LIBS"
+if $have_fortran_compiler; then
+  LIBS="$BLAS_LIBS $FLIBS $LIBS"
+  AC_LANG_PUSH(Fortran 77)
+  (eval "$ac_compile"; eval "$ac_link") 2>conftest.er1
+  AC_LANG_POP(Fortran 77)
+elif $have_f2c; then
+  LIBS="$BLAS_LIBS $F2CLIBS $LIBS"
+  AC_LANG_PUSH(C)
+  octave_xlate="$F2C $F2CFLAGS < conftest.f > conftest.c"
+  (eval "$octave_xlate")
+  (eval "$ac_compile"; eval "$ac_link") 2>conftest.er1
+  AC_LANG_POP(C)
+fi
+LIBS="$XLIBS"
+case "`./conftest$ac_exeext`" in
+  *succeeded*)
+  AC_MSG_RESULT(yes)
+;;
+  *)
+  AC_MSG_RESULT(no)
+  AC_MSG_WARN([Your BLAS library was apparently compiled with a Fortran])
+  AC_MSG_WARN([compiler that uses a different calling convention from])
+  AC_MSG_WARN([the one used by the selected compiler, $F77.])
+  AC_MSG_ERROR([You must correct this problem before building Octave.])
+;;
+esac
+
 # Check for AMD library
 AMD_LIBS=
 AC_SUBST(AMD_LIBS)
@@ -2000,6 +2056,12 @@
   FORT="$F77 $FFLAGS"
 fi
 
+if $have_fortran_compiler; then
+  true
+elif $have_f2c; then
+  FLIBS="$F2CLIBS"
+fi
+
 AC_MSG_NOTICE([
 
 Octave is now configured for $canonical_host_type

reply via email to

[Prev in Thread] Current Thread [Next in Thread]