Hello r-devel,

When compiling Fortran code containing BLAS functions and calling it using
dyn.load, I am getting incorrect results. A small example with which I can
reproduce the problem is below.
I am running on OSX Mavericks (upgraded R, Xcode, etc per instructions on
this list), but I do not think it is related since the check on my
"blupsurv" package on r-forge seems to be showing similar behavior, and the
problem predates Mavericks. The package used to build and check without
errors when I originally put it on r-forge. Would appreciate suggestions.

Thanks,
Emmanuel

Example: this program creates two double vectors, takes the dot product
with ddot, and prints the result:

test.f:
      subroutine testddot(n,x,y)
      integer i,n
      double precision x,y,d1(n),d2(n)
      do 100 i=1,n
        d1(i)=x
        d2(i)=y
 100  continue
      print *,ddot(n,d1,1,d2,1)
      end

Compiling
R CMD SHLIB test.f

Running:
> dyn.load("test.so")
> test<-.Fortran("testddot",as.integer(3),as.double(1),as.double(1.2))
 -1.0737418E+08

The result should be 3.6, not -1.07e8. Most other inputs give incorrect
results too.

Here is my session info. I upgraded to the latest devel to see if it would
fix the problem.

> sessionInfo()
R Under development (unstable) (2014-01-10 r64727)
Platform: x86_64-apple-darwin10.8.0 (64-bit)

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

        [[alternative HTML version deleted]]

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

Reply via email to