I'm going to try my hand at converting some Fortran programs to R. Does anyone know of any good articles giving hints at such tasks? I will post a selective summary of my gleanings. Cheers, Murray -- Dr Murray Jorgensen http://www.stats.waikato.ac.nz/Staff/maj.html Department of Statistics, University of Waikato, Hamilton, New Zealand Email: maj at waikato.ac.nz Fax 7 838 4155 Phone +64 7 838 4773 wk Home +64 7 825 0441 Mobile 021 0200 8350
I did a quick search for interfacing R and Fortran. Found this past information. Hope it helps. :D http://r.789695.n4.nabble.com/Conerned-about-Interfacing-R-with-Fortran-td887428.html As for your actual requirement to do the "convertion", I guess there'd not exist any quick ways. You have to be both familiar with R and the other language to make the rewrite work. 2011/1/5 Murray Jorgensen <maj@stats.waikato.ac.nz>> I'm going to try my hand at converting some Fortran programs to R. Does > anyone know of any good articles giving hints at such tasks? I will post a > selective summary of my gleanings. > > Cheers, Murray > -- > Dr Murray Jorgensen http://www.stats.waikato.ac.nz/Staff/maj.html > Department of Statistics, University of Waikato, Hamilton, New Zealand > Email: maj@waikato.ac.nz Fax 7 838 4155 > Phone +64 7 838 4773 wk Home +64 7 825 0441 Mobile 021 0200 8350 > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >[[alternative HTML version deleted]]
Hi Murray, at first I thought you meant compiling existing Fortran or C++ for use in R with .Fortran() and so on, but do you mean literal conversion from Fortran to just pure R code? I'm assuming pure R code for the rest of this: I've tried with some fairly simple C++ and C code, and that's been fairly easy - there are a lot of details you can ignore and just try to figure out the algorithm. It's nice if you have running software so you can compare outputs, but I did once eventually figure out some Pascal code from an old text book - it had enough actual example data printed in the book that allowed me eventually to figure it out. There were people around me who had once compiled Pascal, but it didn't sound like it was going to be much fun. Sometimes C and C++ chunks can be copied over directly and used with very few changes, but it will just depend. Good luck, and I would just jump in the deep end and send in questions if you get stuck. Cheers, Mike. On Wed, Jan 5, 2011 at 11:02 AM, Murray Jorgensen <maj at stats.waikato.ac.nz> wrote:> I'm going to try my hand at converting some Fortran programs to R. Does > anyone know of any good articles giving hints at such tasks? I will post a > selective summary of my gleanings. > > Cheers, ?Murray > -- > Dr Murray Jorgensen ? ? ?http://www.stats.waikato.ac.nz/Staff/maj.html > Department of Statistics, University of Waikato, Hamilton, New Zealand > Email: maj at waikato.ac.nz ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?Fax 7 838 4155 > Phone ?+64 7 838 4773 wk ? ?Home +64 7 825 0441 ? Mobile 021 0200 8350 > -- > R-downunder at stat.auckland.ac.nz > http://www.stat.auckland.ac.nz/r-downunder > > To unsubscribe send an email to R-downunder-unsubscribe at stat.auckland.ac.nz >-- Michael Sumner Institute for Marine and Antarctic Studies, University of Tasmania Hobart, Australia e-mail: mdsumner at gmail.com
> Murray Jorgensen <maj at stats.waikato.ac.nz> wrote: > > I'm going to try my hand at converting some Fortran programs to R. Does > anyone know of any good articles giving hints at such tasks? I will post > a selective summary of my gleanings.Presuming you don't mean .Fortran(), I have gone both ways. Aside from the obvious fact that a single R vectorized command can replace either just a loop or an entire Fortran subroutine, I don't have any deep insights. I simply did a line-by-line translation to R, confirmed the code still worked, then looked for simple optimizations/refactorings. If you have a lot of code to port, and are hinting you would like an automated tool, I think you are out of luck ;) There is a Fortran to Lisp translator (f2cl), but I think the resulting code will not get you a lot closer (it is aimed at compilation). Cheers, David Duffy. -- | David Duffy (MBBS PhD) ,-_|\ | email: davidD at qimr.edu.au ph: INT+61+7+3362-0217 fax: -0101 / * | Epidemiology Unit, Queensland Institute of Medical Research \_,-._/ | 300 Herston Rd, Brisbane, Queensland 4029, Australia GPG 4D0B994A v
On Tue, Jan 4, 2011 at 4:02 PM, Murray Jorgensen <maj at stats.waikato.ac.nz> wrote:> I'm going to try my hand at converting some Fortran programs to R. Does > anyone know of any good articles giving hints at such tasks? I will post a > selective summary of my gleanings.If the code uses functions/subroutines, keep in mind that Fortran passes arguments by reference, whereas R passes arguments by value. Peter