On 23/04/17 09:44, Dirk Eddelbuettel wrote:

On 23 April 2017 at 09:25, Rolf Turner wrote:

<SNIP>

| However I found a posting by Ege Rubak on this topic which sent me by a
| slightly roundabout route to a posting by Dirk Eddelbuttel

There is a transcribed Umlaut in there:  Eddelbuettel (ie 'ue' not 'u')

Arrgggghhh! Sorry 'bout that. I'm usually fairly careful about getting people's names right, since I am myself annoyed by being called "Rolph" or "Ralph" or "Ralf" or "Ross" (!!!).

<SNIP>

| (1) I found that having an R function with the same name as that of a
| routine (Fortran subroutine in this case) that it called, causes all
| sorts of chaos.  I had a function "binsrt" that called a Fortran
| subroutine named "binsrt" and a function "mnnd" that called a Fortran
| subroutine named "mnnd".  This induced several fairly mysterious
| warnings.  I resolved the issue by renaming the R functions "binsrtR"
| and "mnndR" respectively, so as to eliminate the name conflict.
|
| Would this be the recommended procedure, or is there a cleverer way to
| eliminate the problem?

That has hit me too, and I also found the error message less than perfectly
clear.  It all makes sense in the large sense -- we now register functions,
and R and compiled code (C++ for me, Fortran for you) "compete" for unique
identifiers.

The "official" way in Writing R Extensions fixes this by automagically
prefixing functions called via .Call() with a "c_" prefix.  You can turn that
on in the NAMESPACE file as further argument to useDynLib().  I am not (yet?)
doing this in all packages, and I "spied" on one recent update of a package
by an R Core member that didn;t either.  When in Rome ...

The foregoing "official" way would seem to apply to functions called by ".Call" (which I never use; it is way over my head). What about functions called by ".Fortran()" or ".C()"?

<SNIP>

|     (b) For the sake of completeness, how *does* one replace the "void *"
|         constructions with "actual types" in a correct manner?
|
|          Example:  In my init.c file I currently have (as produced by
|          package_native_routine_registration_skeleton()) :
|
| > extern void F77_NAME(mnnd)(void *, void *, void *, void *, void *);
|
|          The code in mnnd.f reads:
|
| > subroutine mnnd(x,y,n,dminbig,dminav)
| > implicit double precision(a-h,o-z)
| > .....
|
|          I.e. the "actual types are "double precision",
|          "double precision", "integer", "double precision",
|          "double precision".
|
|          So in this case I should (?) replace
|
| > extern void F77_NAME(mnnd)(void *, void *, void *, void *, void *);
|
|          by .... what?  Can anyone tell me?

No idea. I don't deal in Fortran. C++ is more than enough fun for me ;-)

Well, C++ is too much for me. I find Fortran generally very easy. Be that as it were, are there any Fortran users out there who can answer my question, above?

Thanks Dirk.

cheers,

Rolf

--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

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

Reply via email to