[R] Trouble returning 2D array into R from Fortran

2012-10-20 Thread paulfjbrowne
Hello, I have been trying to use a collection of Fortran subroutines to return a 2D array of calculated values to my R code, calling a Fortran wrapper subroutine from R. I've done this successfully before with C & C++ code. The Fortran wrapper subroutine which is to be called by R takes a set of

Re: [R] Trouble returning 2D array into R from Fortran

2012-10-20 Thread paulfjbrowne
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 solution. I have also noticed a strange numerical problem when calling the routi

Re: [R] Trouble returning 2D array into R from Fortran

2012-10-22 Thread paulfjbrowne
I haven't determined the root cause of the numerical accuracy bug yet (I haven't determined a way to compare the values used when the code is run from R as opposed to from a Fortran test), but I did have another issue with retrieving the matrix from the Fortran code that I hoped you might be able t

Re: [R] Trouble returning 2D array into R from Fortran

2012-10-23 Thread paulfjbrowne
Yes, I had stripped out the Fortran from the geta subroutine downwards because is wasn't very important in returning a test output matrix. I think that I should make explicit what problem I believe I am seeing in what I have coded, and what form of the output matrix I would prefer. When I run th

Re: [R] Trouble returning 2D array into R from Fortran

2012-10-23 Thread paulfjbrowne
Thank you for your help. In any case, I eventually realized that I had reversed the Fortran/R column major order in the Fortran, which is why elements were returned incorrectly. As you point out, I did not run into memory access issues because of the self-similar array sizes. -- View this messa

Re: [R] optim & .C / Crashing on run

2012-11-04 Thread paulfjbrowne
Playing around with alternate optimzers, I've found that both nlminb & the nls.lm Levenberg-Marquadt optimizer in minpack.lm both work with my objective function without crashing, and minimize the function as I'd expect them to. Using optim for amoeba sampling would be nice, but I think I'll just