Re: [Rd] Calling FORTRAN function from R issue?

From: Berend Hasselman <bhh_at_xs4all.nl>
Date: Tue, 06 Mar 2012 13:06:34 +0100

On 06-03-2012, at 12:56, Berwin A Turlach wrote:

> G'day Berend,
>
> [..]

>> I tried calling zdotc  through an intermediate Fortran routine hoping
>> it would solve your problem.

> [...]
>> Above C routine changed to

> [...]
>> The fortran subroutine is
>> 
>> <code>
>>      subroutine callzdotc(retval,n, zx, incx, zy, incy)
>>      integer n, incx, incy
>>      double complex retval, zx(*), zy(*)
>>      external double complex zdotc
>> 
>>      retval = zdotc(n, zx, incx, zy, incy)
>> 
>>      return
>>      end
>> </code>
>> 
>> Made a shared object with
>> 
>> R CMD SHLIB --output=dozdot.so callzdotc.f czdot.c 
>> 
>> and ran
>> 
>> dyn.load("dozdot.so")
>> .C("testzdotc")
>> 
>> with the result 0.0, 0.0

>
> Same here.
>
> Once I change the line
>
> external double complex zdotc
>
> in your fortran subroutine to
>
> double complex zdotc
>
> everything works fine and I get as result 14.0, 0.0.
>
> It is long time ago that I was taught (and studied) the FORTRAN 77
> standard. But flipping through some books from that time I thing I
> have some inkling on what is going on. The "external" statement is not
> needed here (seems to be used in the sense that C is using the
> "external" statement).

Thanks.
I should have tried that too.

This implies that Dominick's original issue can be avoided by using an intermediate Fortran routine.

But I would really like to hear from an Rexpert why you shouldn't/can't use external here in the Fortran.

Berend



R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Tue 06 Mar 2012 - 12:08:37 GMT

This quarter's messages: by month, or sorted: [ by date ] [ by thread ] [ by subject ] [ by author ]

All messages

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 06 Mar 2012 - 14:10:24 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.

list of date sections of archive