[R-pkg-devel] R_registerRoutines, etc.

Avraham Adler avraham.adler at gmail.com
Mon Apr 24 01:48:07 CEST 2017


On Sun, Apr 23, 2017 at 7:36 PM, Duncan Murdoch
<murdoch.duncan at gmail.com> wrote:
> On 23/04/2017 6:18 PM, Rolf Turner wrote:
[SNIP]
> This is important:  *there is no way to pass a Fortran "LOGICAL" from R to
> Fortran*.
>
> The issue is that different Fortran compilers store LOGICAL in different
> ways.  Some are equivalent to int with 0 for FALSE, all else for TRUE, but
> not all are.  So don't rely on it.
>
> If you need to call a Fortran subroutine that takes a LOGICAL argument, you
> need to write another Fortran subroutine that takes an INTEGER argument.
> Then compute "arg NE 0" (or whatever the Fortran version is for testing not
> equal to zero) and pass that to the original routine.

I went through this very headache over the last few months. Even using
Fortran 2003 ISO C bindings, I ended up having to convert to integers
for Solaris SPARC. I know you are using .Fortran() and not .Call(),
but perhaps you would find this commit of some value
<https://bitbucket.org/aadler/delaporte/commits/709ab65696e61d18585466ac700cf2856dedcb35>,

Good luck!

Avi



More information about the R-package-devel mailing list