---------- Forwarded message ---------- From: Charlie Sharpsteen <[email protected]> Date: Wed, Sep 23, 2009 at 8:47 AM Subject: Re: [R] Fortran vs R To: Paul Simonin <[email protected]> Cc: [email protected]
On Wed, Sep 23, 2009 at 8:13 AM, Paul Simonin <[email protected]> wrote: > Hello R users, > I have a basic "computer programing" question. I am a student currently > taking a course that uses Fortran as the main programming language, but the > instructors are open to students using any language they are familiar with. > I have used R previously, and am wondering if there is any benefit to my > learning Fortran, or whether I should stick with R for this class. Any > advice? Are there clear benefits to using Fortran, or things Fortran can do > that R cannot? > Thank you very much for any thoughts! > Sincerely, > Paul S. > > Hello Paul, Like you, I learned Fortran as my first programming language. After a few years and a few more languages I can say that the answer to this question depends largely on what you think you may be doing with your programming skills. I will shamelessly use myself as an example- I am studying Environmental Resources Engineering. One of the biggest reasons we are taught Fortran is because the overwhelming percentage of software that solves problems in our field of concern is written in Fortran. Most importantly, many models produced by the US government-- such as the groundwater models maintained by the USGS-- are written in Fortran. The language used to write government models is significant because the soundness of those computer programs is legally defensible in court. Generally speaking, Fortran is used to write models of physical systems such as the flow of water (HEC-RAS), movement of contaminants in air (CARMA), development of tidal currents (ADCIRC) and propagation of ocean waves (SWAN). This is because Fortran is very matrix-oriented and very fast at what it does. Many, many toolkits for performing computations in linear algebra are written in Fortran. Bottom line on Fortran's area of use: if you think you will be using your programming skills to implement numerical solutions to things such as Partial Differential Equations, then Fortran could be a very valuable investment. As far as Fortran vs. R is concerned-- the two compliment each other very well. R is very flexible and can be enhanced with just about any bell or whistle you could possible want-- but being a scripting language, it can run into performance issues-- especially during large loops. Fortran is a very, very, straightforward language because it does not have many "bells and whistles" to speak of-- it does one thing and one thing best and that is to crunch absurdly large amounts of numbers as fast as it possibly can. Fortran also happens to be one of the compiled languages that R is designed to work with, it is amazing how easy it is to add Fortran routines to an R package and then load and use them from within R. I usually write my numerical computations in Fortran, load them as an R package and then: - Use R to feed Fortran simulations with random numbers drawn from different distributions (Monte Carlo Analysis). - Use R to perform statistical analysis on the results of Fortran simulations. - Use R to aggregate, format and graph the results of Fortran simulations. So, the decision on what languages to learn depends very much on what problems you think will require your programming skills. R and Fortran compliment each other extremely well-- so learning Fortran may be a wise investment. Hope this helps! -Charlie [[alternative HTML version deleted]] ______________________________________________ [email protected] 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.

