I am having trouble handling reals in Fortran, which I use together with R. The following code is written in Fortran:
Subroutine realtest(lol)
implicit none
Real
Try using double precision
instead of real
; the following works for me:
! realtest.f90
!
subroutine realtest(x)
implicit none
double precision, intent(inout) :: x
x = 10.0
end subroutine realtest
From R,
dyn.load("realtest.so")
res <- .Fortran("realtest", x = as.double(1.2))
res
# $x
# [1] 10
You should declare lol
as real*8
since R uses double-precision floating-point number.