[R] Trouble returning 2D array into R from Fortran
bhh at xs4all.nl
Sat Oct 20 21:29:08 CEST 2012
Look at my comments in between your post.
On 20-10-2012, at 19:18, paulfjbrowne <paulfj.browne at gmail.com> wrote:
> I will look into using inline, but since the Fortran code is several thousand
> lines long & is comprised of multiple subroutines, compiling it into a
> shared object & dynamically loading it into R is probably the easier
You misread my "see inline".
I did not mean look at the inline package.
I meant that my comments were inline (I try never to top post).
> I have also noticed a strange numerical problem when calling the routine
> from within R as opposed to in its native Fortran. For example, for the same
> set of input parameters, R will output;
> (0.0315031507927081, 0.220339391742628)
> Whereas the Fortran code internally outputs;
> (0.0350479965640488472, 0.22220883087569138)
> All variables are defined in the Fortran code as double, and are passed in
> as double in the .Fortran call in R. I am a bit puzzled at the discrepancy
> between the two calls' output.
Without further information and code, it is impossible to give any kind of sensible advice.
In the Fortran code you could try to check the input arguments.
Are you sure that from R you are passing exactly the same values as "in its native Fortran".
> View this message in context: http://r.789695.n4.nabble.com/Trouble-returning-2D-array-into-R-from-Fortran-tp4646862p4646874.html
> Sent from the R help mailing list archive at Nabble.com.
> R-help at r-project.org mailing list
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help