[R] DLLs and the Floating Point Control Word.

Duncan Murdoch dmurdoch at pair.com
Mon Feb 23 15:47:16 CET 2004


On Mon, 23 Feb 2004 13:37:21 +0000, "Steve Roberts"
<steve.roberts at man.ac.uk> wrote :

>Greetings. 
>
>One for the developers I guess...  I am having problems in using a 
>(non-recommended) Fortran compiler (Salford ftn95 Windoze), and 
>the crashes do seem to be associated with the ftn95-dervived DLL 
>changing the Floating Point Control Word. The compiler people are 
>suggesting (and I paraphrase!) that if R minds what the FPCW is it 
>is up to R to make sure it is the value it wants and R should 
>check/reset on returning from the DLL call. 

I doubt if the FPCW would be enough to cause a crash, but there are
other assumptions R makes that would cause a crash if they were
violated.  In particular, if your compiler sometimes messes up some of
the other registers that are assumed to be preserved, then there would
be trouble.

These kind of crashes are hard to diagnose, because they need someone
familiar with both R and the compiler in question at a very low level.
If the Salford people aren't willing to help with it, then you should
probably look for a different compiler.

>There seems to me to 
>be some logic in this position - if only to make life easier for those 
>of us who don't really know what a FPCW is! Having to add 
>unintelligable code to reset the FPCW at the end of each fortran 
>routine is inelegant. It probably isn't as easy as it sounds  - I guess 
>there are multi-platform issues? Is this a sensible suggestion to 
>add to the wish list?

Most compilers can produce libraries that are compliant with R's
needs, so this would be a pretty low priority.  If you know someone
who wants to write the code, and it doesn't impact on compliant users,
I'd be willing to take a look.  

Duncan Murdoch




More information about the R-help mailing list