[R] Help running a Fortran subroutine from R
chuck at sharpsteen.net
Wed Mar 17 00:44:23 CET 2010
> I need help getting a Fortran DLL successfully returning the correct
> output. The attached fortran source code (filter2d.f) and DLL
> (filter2d.dll) are attached. Also, I attached a text file for which I
> want to apply the filter to (time702.txt).
> Here is what I am doing...
>  TRUE
> Then I pass the parameters according to the order they are specified in
> the filter:
> array <- data.matrix(read.table("time702.txt",header=F))
> array1 <- array
> nx <- 60
> ny <- 120
> halfintx <- 3
> halfinty <- 3
> mask <- matrix(array(rep(1.0,25)),5,5)
> subarray <- matrix(0,5,5)
> subarray1 <- matrix(0,5,5)
> Then I run the Fortran subroutine...
> out <- .Fortran("filter2d",
> The smoothed output is 'array1', which I just passed as 'array' in the
> specification. It can be any matrix, but must be the same dimension as
> 'array', which is given as nx by ny.
> Missing values in time702.txt are denoted by 999.00, and are defined that
> way in the subroutine.
> Can anyone see where I may be doing something wrong? I am not good with
> fortran, as this code was previously written and now I am trying to adapt
> it to R "on the fly".
> Basically, filter2d smooths 'array' by averaging within the window
> halfintx by halfinty.
> Can anyone please help me out or provide some clarification?
You have done a great job of showing us how you set up the call to Fortran-
but you haven't clearly stated what the problem is. As far as I can tell
from your post, "the Fortran DLL is not returning the correct output".
Could you elaborate on what output, if any, you are getting and what output
you were expecting?
Undergraduate-- Environmental Resources Engineering
Humboldt State University
View this message in context: http://n4.nabble.com/Help-running-a-Fortran-subroutine-from-R-tp1595641p1595739.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help