[R] Underscores and Fortran code

Prof Brian Ripley
Fri, 12 Oct 2001 14:21:36 -0000

On Fri, 12 Oct 2001, Duncan Murdoch wrote:

> On Thu, 11 Oct 2001 16:48:12 -0400, you wrote in message
> <15302.1420.571215.515265 at minke.stat.ufl.edu>:
>
> >Any suggestions are welcome.  Am I missing anything?
>
> A 5th suggestion:  you can change the R code.  In the Windows version
> 1.3.1, I get these results:
>
> Just like you, an error with the real name:
>
>  > .Fortran("dog_dog", as.double(x), as.double(y),
as.double(z))
>  Error in .Fortran("dog_dog", as.double(x), as.double(y),
> as.double(z)) :
>          C/Fortran function name not in load table
>
> But add an extra underscore to the call and things are fine:
>
>  > .Fortran("dog_dog_", as.double(x), as.double(y),
as.double(z))
>  [[1]]
>  [1] 2
>
>  [[2]]
>  [1] 3
>
>  [[3]]
>  [1] 5
>
> It seems like a fairly easy workaround to just append an extra
> underscore to names when the compiler is doing this funny name
> mangling.

BTW, _ is not valid in an ISO Fortran 77 name, so this is all about
compiler-specific extensions.  On Solaris f77 does not add, g77 does.

We could make .Fortran do this automatically ....   (I mean try
dog_dog_ then dog_dog__)   However F77_CALL etc would still be
wrong, and I am inclined to suggest we do adopt -fno-second-underscore
with g77.  Or advise people to use standard-conforming Fortran 77 ....


--
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272860 (secr)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595