[R] behaviour of .Fortran in terms of "double precision" and "real" datatype

From: Sebastian Eiser <sebastian_at_phy.duke.edu>
Date: Tue, 29 Apr 2008 18:52:39 -0400

Hello R-world!

This is my first post to the R list, so I feel that I need to say thanks to the community (I'm using R now for 5 months)!

I'd greatly appreciate if somebody could explain some odd behavior of ".Fortran" to me. Let's assume a primitive Fortran subroutine


      subroutine bar(y, v)
      double precision y
      real v

      y = 1.455523
      v = 3.2


after $ R CMD SHLIB barfoo.f (uses gfortran & gcc), I switch to R-2.6.2 R> dynload("barfoo.so")
R> .Fortran("bar", y=as.double(3), v=as.real(2.1))

[1] 1.455523


[1] 2.099999

the double value of y changes according to the programme, but the v value is not being updated (besides an error is made).

The reason why I"m interested is because I want to run an elaborate Fortran programme within a MCMC in R. All arguments for the programme are 'real'. Could somebody explain to me what's going on? Also, feel free to try that on your machine.

thanks very much in advance,

        [[alternative HTML version deleted]]

R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Wed 30 Apr 2008 - 01:45:35 GMT

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 Wed 30 Apr 2008 - 02:30:32 GMT.

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

list of date sections of archive