为什么Fortran用于科学计算? [英] Why is fortran used for scientific computing?

查看:161
本文介绍了为什么Fortran用于科学计算?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我读过Fortran仍被大量用于科学计算。对于已经在Fortran中大量投资的代码,这对我来说很有意义。



但是,是否有理由将Fortran用于其他现代语言的新项目?与说更流行的语言(C ++,Java,Python,Ruby等)相比,Fortran中的语言设计决策是否更适合科学计算?例如,是否有Fortran的特定语言功能,可能允许编译器中的数值优化比我提到的其他语言高得多?

> Fortran无论好坏,都是专门为科学数值计算设计的唯一主要语言。它的数组处理是很好的,在整个数组和片上都有简洁的数组操作,可以与matlab或numpy进行比较,但超级快。该语言经过精心设计,使得意外编写慢代码非常困难 - 指针受限于这样一种方式,即便可能存在别名(作为标准示例),它也很明显 - 因此优化程序可以在您的城市码。目前的版本有像coarray fortran这样的东西,并且在语言中使用了并发和写入,允许分布式内存和共享内存并行,以及向量化。

Fortran的缺点主要是其中一个上升的另一面提到; Fortran历史悠久。上行:大量图书馆。缺点:历史行李吨数。

如果您不得不进行大量的数字处理,Fortran仍然是首选之一,这就是为什么许多最复杂的模拟写在世界各地超级计算中心的代码。但是,编写一个网页浏览器当然是一种可怕的,可怕的语言。它为每个任务提供工具。


I've read that Fortran is still heavily used for scientific computing. For code already heavily invested in Fortran this makes sense to me.

But is there a reason to use Fortran over other modern languages for a new project? Are there language design decisions in Fortran that makes it much more suitable for scientific computing compared to say the more popular languages (C++, Java, Python, Ruby, etc.)? For example, are there specific language features of Fortran that maybe allow numeric optimization in compilers to a much higher degree compared to other languages I mentioned?

解决方案

Fortran is, for better or worse, the only major language out there specifically designed for scientific numerical computing. It's array handling is nice, with succinct array operations on both whole arrays and on slices, comparable with matlab or numpy but super fast. The language is carefully designed to make it very difficult to accidentally write slow code -- pointers are restricted in such a way that it's immediately obvious if there might be aliasing, as the standard example -- and so the optimizer can go to town on your code. Current incarnations have things like coarray fortran, and do concurrent and forall built into the language, allowing distributed memory and shared memory parallelism, and vectorization.

The downsides of Fortran are mainly the flip side of one of the upsides mentioned; Fortran has a huge long history. Upside: tonnes of great libraries. Downsides: tonnes of historical baggage.

If you have to do a lot of number crunching, Fortran remains one of the top choices, which is why many of the most sophisticated simulation codes run at supercomputing centres around the world are written in it. But of course it would be a terrible, terrible, language to write a web browser in. To each task its tool.

这篇关于为什么Fortran用于科学计算?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆