11 ms·
Why Fortran is a scientific powerhouse
- amelius 4y ago> languages like Julia are attempting to unseat it Isn't it CUDA that is taking this role?
- krastanov 4y agoCUDA is great for big dense matrices, which is incredibly important. But there is a lot more to scientific computing than big dense matrices. Also, CUDA is low-level a library by one vendor for one class of hardware. Not a language. Languages serious about scientific computing already have multiple interfaces for CUDA at various level of abstraction.
- plegresl 4y agoThere is a Fortran version of CUDA: https://developer.nvidia.com/cuda-fortran https://developer.nvidia.com/cuda-fortran
- amelius 4y agoThere is cuSparse for sparse matrices: https://docs.nvidia.com/cuda/cusparse/ https://docs.nvidia.com/cuda/cusparse/
- pjmlp 4y agoOne of the reasons why CUDA won over OpenCL is because it is polyglot.
- anlunx 4y agoWhat are some example workloads in scientific computing that are not suitable for CUDA?
- ChrisRackauckas 4y agoAnything that's not linear algebra
- adgjlsfhk1 4y agosolving small and medium sized differential equations, most monte-carlo algorithms
- j_m_b 4y agoIt's also big in molecular dynamic and quantum molecular simulations. Think protein folding, protein engineering, small molecule drug discovery.
- dalke 4y agoI've worked in small molecule drug discovery for about 25 years and have only used one Fortran program directly, DGEOM95. And that was in the late 1990s. Otherwise, it's mostly C, C++, and Python, with a smattering of other languages, at least in the areas I work in. Back in the mid-1990s, we decided to use C++ for NAMD because none of us knew FORTRAN that well, it was a greenfield project, and the previous in-house MD codes were in C.
- morvita 4y agoI did a PhD and Post-doc in computational chemistry (focusing on quantum chemical simulations) in the late 2000s/early 2010s and nearly all the software I used was written partially or wholly in Fortran including Gaussian, Q-Chem, Quantum Espresso, and NWChem. Most of the professors I worked with only knew Fortran and had no interest in learning C/C++. The one exception was a professor who was in the process of porting her group's in-house molecular mechanics software from Fortran to C/C++ (don't remember which) so they could get it running on GPUs easily. I think one of the driving factors in this is that, as other people in this thread have discussed, most of the people writing this software are not software developers and have no interest in being software developers. The scientists trained in the 60s/70s/80s learned Fortran, who then founded their own research groups and taught their students Fortran, who are now running their own groups using Fortran because it's what they know. Some folks use Python for data analysis after their simulations run, but even that was rare 10 years ago.
- dalke 4y agoAgreed! Those quantum mechanics people do love Fortran. I talked a bit with Schrödinger (the company) around 1997 about a job in molecular visualization, and decided I didn't want to be the lone non-Fortran developer in a company. I'll add another factor to your consideration. Quantum chemistry is mathematically and numerically more challenging than molecular dynamics, and requires a more advanced understanding of chemistry than MD does of chemistry or physics. I suspect this makes MD codes easier to implement, and more open to multi-disciplinary development, than QC codes. This thought comes from my experience. My PI at Illinois was Klaus Schulten, who was a postdoc in Karplus's lab at Harvard. Karplus's group developed CHARMM, written in Fortan. Our lab also used Axel Brunger's X-PLOR, another Fortran code. I know we had a source license to X-PLOR. If the factor you described were the dominate one, we should have been a Fortran shop. Yet in the late 1980s/early 1990s (before my time) there were grad students in the group writing their own MD codes, one in C and another in Occam. (Occam was developed for writing parallel algorithms on a transputer. The transputer was seen as the future of parallel computing. The grad students before me built their own hardware around the transputer.) My generation then developed NAMD using C++. The primary author, Mark Nelson, who had been maintaining one of the older codes, and was annoyed with it. He was grad student from CS (or EE?), with software industry experience before going to grad school. Two other grad students - Bill Humphrey and I - were in physics but had undergrad CS training. Plus, the group itself was multidisciplinary, with Laxmikant Kale's group in the CS department, who developed the Charm++ language. (Also, we collaborated with John Board's group from the EE department at Duke, to use their multipole package for long-distance electrostatics; that was in C or C++.) Which means in our group alone there were at least three locally-developed MD codes. Each one targeted a different way of handling parallelism. This was possible because the core MD engine is pretty simple. Adding different integration types, and parameterizing the force field, and developing faster approximate methods to handle hydrogen dynamics, and other aspects of MD are not so simple, but the core is still something many undergrads could write. While QM codes require a more specialized knowledge that I certainly never learned, and which isn't easy to pick up by non-chemists, leading to a more isolated development culture passed on in the way you describe.
- whatshisface 4y agoThe way funding works in science means nobody can develop a scientific language that's better than Fortran and interoperable with it. Slicing off small amounts of researcher time to improve a decades-old solution is the only way things can be done.
- deleted 4y ago[deleted]
- leephillips 4y agoJulia is better than Fortran and interoperable with it (in the sense that it’s easy to call Fortran from within Julia).
- TheRealKing 4y agoFortran is better than Julia and interoperable with Julia and any language. Any language as of today is better than Julia. Currently, Julia is a collection of nerd lies and false promises. Look at the recent Julia Discourse post "What is the status of AutoDiff in Julia"? Then read how gloriously the top response describes the situation. Read a few lines more, and you realize there is yet to be a single AutoDiff tool that works effectively and flawlessly in Julia. "Deny the weakness until we fix it" is a typical speaking pattern among JuliaComputing leaders. There is a good reason for it. JuliaComputing is a for-profit company. They have to find a way to return the stakeholders' million-dollar investments. The easiest way for them is to take a Machiavellian approach rather than being realistic, honest, and fair. I know the nerd culture very well. I am familiar with their denial of their weaknesses and flaws, and their nightmares of being the runner-up. I work with them daily. And JuliaComputing staff is a nerd community from head to tail. For a longer list of Julia's flaws that JuliaComputing pushes under the rug, see https://yuri.is/not-julia/ https://yuri.is/not-julia/ Regarding fairness and honesty, JuliaComputing staff are responsible for >99% of web posts (including HackerNews) that speak highly of Julia and bash any other language, particularly C++, Fortran, MATLAB, Python, R, Rust.
- cbkeller 4y ago
- hprotagonist 4y agobecause it goes brrrrrr really well on numerical problems, and because there's 60 years of bugfixes in the libraries. that's more than enough for staying power.
- gumby 4y ago> P.S. Fortran often appears on those “outdated languages” lists, but the lists are often compiled by people who have little or no clue about anything to do with computing, let alone programming languages. So true!
- BeetleB 4y agoFrom my time in academia, there are two reasons: 1. It's fast. 2. It's tolerant of poor programmers. Regarding item 2: People who want to specialize in scientific computing intentionally avoid becoming good programmers. Most of them are not in CS, but in some other engineering or in science. They want to focus on their discipline (e.g. climate science as this example gives). They don't care about code quality, or even SW practices (e.g. when I was in grad school a little over a decade ago, I couldn't get a single one of my colleagues to use version control - and some of them had codebases in the tens of thousands of lines). They are not judged by the quality of their code, but by the results their code produces. They don't show their code in their papers, but the plots/tables. So they'll use the language that puts up the least barriers, and is performant. Hence, Fortran. (Incidentally, many of them don't care about reproducibility. They'll modify their large codebase, spit out some results, publish them, and then add new features, and will never check if the modified codebase will continue to give the same results for the same inputs). All the other reasons in the article? Insignificant factors. Edit: Note that I'm not saying that if you code in Fortran you're a poor programmer or use poor practices. And I'm sure there are good Fortran code bases around.
- TillE 4y agoI was toying with the idea of getting into computational chemistry about 15 years ago, as a rare person with a strong background in both CS and chemistry. The main reason I didn't was because grad school didn't sound like much fun, but the prospect of working with a bunch of lousy code wasn't encouraging either.
- mrazomor 4y ago> They are not judged by the quality of their code, but by the results their code produces. How much are software engineers judged by the code quality? And how much by the end results (shipped features/projects)? There's a large gap between good code quality (i.e. keep the soft. engs. happy) and passable maintenance (i.e. features and bugfixes are not terribly late -- keep the execs/business happy). When it comes to Fortran, I wish it long life. It found a great fit and does its job well. Numerical math has many peculiarities. I'm happy we have stable libraries for it. Long live Fortran!
- warinukraine 4y agoAre there any more informed folks in here that would like to discuss how "having an ISO standard" would improve Julia?
- dinero_rojo 4y agoYeah, I was also wondering about that. My understanding is that ISO standards were necessary in the past to somewhat ensure that multiple implementations of the same language would be compatible with each other, Julia doesn't really seem to have that issue today. Would be very interested to hear of any other benefits.
- ryanobjc 4y agoISO standards for programming languages have been essentially totally obsoleted for new languages. Open source is the reason: previously you'd only have proprietary implementations, so you'd need a standard to ensure they were compatible. Now the standard for rust, python, etc IS the default implementation. Bug for bug compatibility and all that.
- pjmlp 4y agoExcept there are fields where standards do matter, hence why Ferrocene is helping such effort for Rust.
- adgjlsfhk1 4y agoIt would be great! We'd only be able to improve the language every 3 years and you would have to pay a few thousand dollars to make a pull request!
- Moissanite 4y agoJulia is too "trendy" in certain circles (finance bros) for a lot of scientific computing types to take it seriously and invest a lot of time into it. There are the same sort of community brigading problems that people complain about Rust for, but without the balancing effect of "this language is considered the future by many giant companies who actually have some motivation for being cautious with their choices". I first heard about Julia in about 2012, and while visibility has grown massively, I haven't seen anyone putting it into production or widespread use in any company or academic group except for where you have someone who wants to be an "influencer" trying their luck.
- pantsforbirds 4y agoPersonally I think it's because it's the easiest language to write fast code with for vector calculations. It's extremely easy to work with Fortran array processing and you don't have to worry about pointer aliasing and promising the compiler you won't do it like you do with C. Fortran makes it extremely easy to convert scientific calculations into array or vector based code that is about as optimized as the best C would be, but requiring much less domain knowledge. The downside is Fortran really sucks to work with if you need data structures that aren't array based. I'd much rather do non numeric, or work that needs more abstract data structures in C or C++.
- jononomo 4y agoThe best software engineer I ever worked with, whom I'll call Steve, ended up working in Fortran after we parted ways. He had a Ph.D. from Harvard in Computer Science and we met at a research lab at Harvard Medical School. Interestingly, both of Steve's parents as well as his uncle were professors of Computer Science at top schools. By the time he was 18 years old Steve had a dozen years of programming experience under his belt On one occasion he was on a team that was collaborating with a team from MIT that had contributed some software to the project that Steve disapproved of. So, one weekend, Steve entirely re-wrote the software that the MIT team had contributed. Unfortunately, this turned out to be a firing offense because he had humiliated the collaborators. (One thing to note about Steve is that he was on the spectrum -- as smart as they come, but not good at reading social and political situations.) Steve was not out of a job for long, however -- he was fired in the morning and by that afternoon he had accepted a job with a proprietary trading desk on Wall Street (he had a connection). His salary at least doubled. A year after that incident Steve called me up and asked me to come down and join him at the prop trading desk, so I did. We had a good ride until the 2008 financial crisis and then our entire division (several prop trading desks) was fired on Jan 2nd, 2009. It was difficult to get a job on Wall Street in early 2009 because everyone was laying people off and going belly up. But Steve immediately landed a $400,000/year job with an options trading house. When we were catching up over coffee a few months later he mentioned to me that one of his projects was designing a trading system that needed to solve 500,000 differential equations per second. I just wished him luck and thanked God that I had moved into coaching the LSAT instead. Unfortunately, Steve only lasted about 18 months at the options trading house -- he had a disagreement with another engineer about the best way to implement parallel processing for a certain situation and Steve was not one to give an inch when he thought he was right. So he got fired. The conclusion that Steve drew from this was that he never again wanted to work with someone who did not have a Ph.D., so he moved to a division of NASA that was doing research on how to model the melting of glaciers, and which is apparently a space that is full of people with Ph.Ds. It turns out that Fortran is the best tool for modeling glaciers, so Steve ended up doing heavy mathematical programming in Fortran. As far as I know, this is what he is still working on. Of course, Steve transitioned a couple of years ago and he (she?) now goes by Jessica.
- deleted 4y ago
- trollerator23 4y agoEw
- college_physics 4y agoWell, if people are serious about fortran as an ongoing idiom (and why not, the points made in the post are quite valid) they should seriously think about the community aspect. Development is increasingly a collective endeavour and frequently open source affair (and should definetely be so for publicly funded science) but fortran is still in the world of Von Neumann level geniouses punching algorithms on cards...
- marmetio 4y agoThe natural niche that Fortran has found for itself is largely closed-source, non-collaborative. Same with Ada. The tools continue to be developed because companies spend enough money on them. They don't really need an open community to survive, and the community doesn't really need most of what these tools offer either. I don't expect anything to change unless there's money to be made in doing so.
- college_physics 4y agoAgree that this the present situation, just speculating about possible future paths that might see fortran become relevant to more people > the community doesn't really need most of what these tools offer either not so sure about that. speaking only about the python universe I could see fortran being an easier alternative to C/C++ for implementing compute intensive stuff and python being the user friendly layer. about the money: it would be no different than other open source computing stacks, so yes, no cigar. the main reason to add another option is potential productivity gains if one could enable more science oriented developers to develop performant libraries.
- deleted 4y ago[deleted]
- marmetio 4y agoYour example about being an alternative to C/C++ for Python-wrapped libraries is a good one. In fact, that's already mostly how Fortran is used - wrapped. That future is here already, and it looks the way it currently does. > if people are serious about fortran as an ongoing idiom > Development is increasingly a collective endeavour and frequently open source affair I disagree with the premise that these two things are linked. Fortran is alive and well in the closed-source corporate world, and it will continue that way indefinitely. It's used by scientists and engineers, not developers, so it's unaffected by changes in the development world. I think it's cool that people want Fortran to find a broader audience, and I think it would help, but it's not necessary for it to continue being used.
- machina_ex_deus 4y agoHere's the real reason: they are all copying code from each other. Tons of tons of code. Literally all climate global circulation models share a lot of code. If the author had actually seen how crap the climate models look, maybe he'll realize the argument is actually backwards and climate models are bad. I've tried code reviewing some of these models just to get an idea of how reliable they are. My mind was blown by the extremely poor quality of the code combined with literally no redundancy between different models in some parts. If some code written in 1990 just made a slight mistake, nearly all climate models would have the same bias. And I did find some distributing surface level inaccuracies, such as constants being taken from very old inaccurate measurements in the 1980s physics books (at least according to the comment), some constants being very low precision compared to the accuracy required (some constants with only 2 decimals of precision), and some things that aren't constant at all and should depend on temperature/pressure/CO2 levels/height. And these are important in a system that actually spends huge efforts to model factors with much weaker impact.
- chmaynard 4y ago> Here's the real reason: they are all copying code from each other. Right, code reuse is dangerous and something to be avoided. From now on, let's write everything from scratch.
- LoganDark 4y agoIf we reuse code, we risk missing a potential time investment!
- d4mi3n 4y agoI don't think this reflects the OP's concern: It's not that code-reuse is bad in and of itself, it's that the code being reused is being reused without maintenance or review.
- chmaynard 4y agoGood point. For example, I'm sure no trained professional would ever copy code from StackOverflow.
- lowbloodsugar 4y agoI looked at the reference to back the claim “Fortran is faster than C in some cases” and didn’t find a benchmark where Fortran was faster than C. A big complaint about C was optimization failures from pointer aliasing, but that was fixed a decade ago.
- mkoubaa 4y agoCompilers still emit non vectorized code if there's a chance pointers are aliased, this is not fixed at all
- int_19h 4y agoI think OP means "restrict". If you put that on every pointer by default, that would be the equivalent of what FORTRAN does. Do modern C compilers still assume aliasing in that case?
- pjmlp 4y agoThe problem with restrict, like everything in C, is that it is expected that developers know what they are doing. Use by mistake the same variable in separate restrict declarations, and UB dameons will be summoned.
- int_19h 4y agoI was under the impression that inadvertently causing aliasing via by-ref arguments in Fortran is also effectively UB, and any diagnostics that compilers might produce are best-effort and will not catch non-trivial cases.
- lmm 4y agoProbably the real difference is that Fortran compiler culture is to do the right thing for UB rather than screwing over the programmer.
- jjtheblunt 4y agoFortran has nearing 50 years of history being studied as to parallelization optimizations, as a testbed for compiler optimizations in general. This link shows an excerpt of this parallelization/optimization work for Fortran (Do scroll down...it's amazing). https://dblp.org/pid/59/1867.html https://dblp.org/pid/59/1867.html
- fuzzfactor 4y ago>Why Fortran is a scientific powerhouse This is by design. I don't know how Fortran is any more, I didn't get as far as Fortran 77 since it wasn't 1977 yet. But students seemed to hate the old Format statements to get your printouts with. Properly done, a few lines of code could output reams of concise tabular data, but you had to be careful you didn't print out reams of gibberish instead. Those mainframe printers could chew through kilos of paper. OTOH, for a single page report, a customized printout of meaningful consolidated, summarized data, it could basically take up a whole page of Format statements and even more print statements in the code. A *whole* page. And there was no such thing as What-You-See-Is-What-You-Get for printing, it was what you expect is what you hope to get. Now it's the modern day in the chem lab, and with 10GB of modern scientific software on top of Windows, which requires a high-end desktop for this, I have not stopped wanting to print. And my data is cloud-ready like never before. But I have no use for that. After my data has lived a full life, it will go to heaven by itself. Seems like it could also expose my data to hell. What about my printout? "Low-code" derivative of Microsoft's Report Definition Language. You've got a template and a GUI and you can even move blocks around. What you see is even less of what you get. There are two main features not shared by Fortran: 1. You will *always* need some kind of iteration before you arrive at your final page format. 2. The code generated is *pages and pages* of XML to get a single printed page. If I had something as performant as Fortran Format statements it sure would have saved a lot of time.