Physicists usually try to minimize the amount of coding they do, therefore, if legacy code exists they will use it. Given the long history of Fortran, it is no surprise that a large amount of legacy code in physics is written in Fortran. The question we really should be asking is “why do physics professors continue to advise their students to use Fortran rather than C++?” Fortran has legacy code So, altogether, C++ is just as fast as Fortran and often a bit faster. The results vary somewhat depending on whether one compares a single core or quad core machine with Fortran lagging a bit more behind C++ on the quad core. The benchmarks where Fortran is much slower than C++ involve processes where most of the time is spent reading and writing data, for which Fortran is known to be slow. However, the two benchmarks where Fortran wins (n-body simulation and calculation of spectra) are the most physics-y. Interestingly, C++ beats Fortran on all but two of the benchmarks, although they are fairly close on most. Python is unsuited for heavy numerical computation but highly suited for many other things. Note that Python, which is the darling of computer scientists, is usually about 100 times slower, but that is the nature of interpreted code. On most of the benchmarks, Fortran and C++ are the fastest. But is it the fastest? The website allows for a comparison of several benchmarks between C and Fortran. It is often said that the reason Fortran is still used is that it is fast. Fortran has through many revisions, the most well known are the 66, 77, 90, 95, 03, and 08 standards. FORTRAN was often programed with punch cards, as is not-so-fondly recalled by Prof. Early Fortran (designated in allcaps as FORTRAN) was, by modern standards hellish, but it was incredible leap forward from previous programming, which was done in assembly. The original specification for Fortran was written in 1954. Computer scientists should (and do) consider the continued dominance of Fortran in numerical computing as a challenge.īefore digging in I feel obligated to discuss a bit of history, since when many hear “Fortran” they immediately think of punch cards and code with line numbers. What I would like to explain is why Fortran is still used, and show that it is not merely because physicists are ‘behind the time’ (although this is sometimes true – about a year ago I saw a physics student working on a Fortran 77 code, and both the student and adviser were unaware of Fortran 90). I am not advocating that physics majors learn Fortran - since most physics majors will end up in research, their time may be better invested in learning C++ (or just sticking with Matlab/Octave/Python). What I would like to do in this article is explain why Fortran is still a useful language. The heavy use of Fortran by physicists often confounds computer scientists and other outsiders who tend to view Fortran as a historical anachronism. Coarrays started as an extension of Fortran 95 and were incorporated into Fortran 2008 standard. Modern Fortran also has a feature called ‘ coarrays‘ which puts parallelization features directly into the language. So basically, if you want fast code that an run on many processors, you are limited to these two options. The popular Open MPI libraries for parallelizing code were developed for these two languages. In the field of high performance computing (HPC), of which large scale numerical simulation is a subset, there are only two languages in use today - C++ and “modern Fortran” (Fortran 90/95/03/08). SIESTA), large scale climate models, etc. Flash), large scale molecular dynamics, electronic structure calculation codes (cf. for things like the astrophysical modeling of stars and galaxies, hydrodynamics codes (cf. However, Fortran is still a dominant language for the large scale simulation of physical systems, ie. “I don’t know what the programming language of the year 2000 will look like, but I know it will be called FORTRAN.” – Charles Anthony Richard Hoare, circa 1982įortran is rarely used today in industry - one ranking ranks it behind 29 other languages.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |