[Rd] fortan common block
Barry Rowlingson
b.rowlingson at lancaster.ac.uk
Sun May 8 09:43:31 CEST 2011
On Fri, May 6, 2011 at 4:04 PM, Paul Gilbert
<pgilbert at bank-banque-canada.ca> wrote:
> Is it possible in R to call a fortran routine that sets variables in a common block and expect the values to persist when a call is made from R to a second routine that uses the common block?
>
> If not (as I suspect), is it possible to use a common block in a group of routines that are used together, for as long the routines do not return to R?
Simple test seems to confirm it. Here's some 'tran with a setter and a getter:
comchk.f:
subroutine bar(n)
common /c/ i
i=n
end
subroutine geti(j)
common /c/ i
j = i
end
R CMD SHLIB comchk.f
> dyn.load("comchk.so")
> .Fortran("bar",as.integer(9))
[[1]]
[1] 9
> .Fortran("geti",as.integer(-1))
[[1]]
[1] 9
Barry
More information about the R-devel
mailing list