octave-maintainers
[Top][All Lists]
Advanced

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

libcruft/blas-xtra/cmatm3.f & f2c fortran calling convention bug?


From: Jarno Rajahalme
Subject: libcruft/blas-xtra/cmatm3.f & f2c fortran calling convention bug?
Date: Sat, 10 Apr 2010 23:27:33 -0700

libcruft/blas-xtra/cmatm3.f calls blas function cdotu. If f2c calling 
convention is used, the function needs to be declared as complex, so that the 
compiler knows to pass the return value as the (implicit) first argument. If 
complex declaration is missing when using -ff2c, the call will cause a 
segmentation fault.

It seems that the cmatm3.f has a typo, as it declares:

      complex cdot,one,zero
      parameter (one = 1e0, zero = 0e0)
      external cdotu,cgemv,cgemm

and later uses:

            c(1,i) = cdotu(k,a(1,i),1,b(1,i),1)

The symbol "cdot" is not used at all.

The only place where cmatm3 is used is in dot.cc. I do not have a working 
octave built with -f2c calling convention, so I can't see if the unit tests 
fail.

 I verified this with the following sample code:

      program main

      complex cdot,ac(1),bc(1),wc
      external cdotu

      ac(1) = cmplx(1e0,1e0)
      bc(1) = cmplx(1e0,2e0)
      wc = cdotu(1,ac,1,bc,1)
      PRINT *,ac(1)*bc(1),"==",wc

      end

$ gfortran -ff2c main.f -lblas
$ ./a.out
Segmentation fault
$ 

Adding u to "cdot" on the complex declaration line will make this work.

  Jarno


reply via email to

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