本文是Then and Nowin ourSeries Library
Fortran最初是IBM的“数学公式翻译系统”。它是由John Backus领导的团队设计的,并针对从物理学到天气预测的计算密集型应用程序。最初编程Die Hards认为,最佳性能需要在汇编器中进行编码。C ++可能是当今选择的编程语言,但Fortran在高性能计算(HPC)应用程序中仍然很受欢迎。最新的Fortran编译器和标准可能会改变您对Fortran是历史文物还是有效工具的想法。
Fortran几乎和我一样古老,如果在Fortran IV,拳头卡,Goto的和线号仍然存在时,我遇到了。我仍然记得三线数字以小于,相等和大于结果结尾的三路算法IF语句。用数字和格式引用文件,并且在整个卡片甲板上撒了数据语句。
In my distant past I wrote a FORTRAN development system in BASIC because the only computer we had access to ran BASIC and we really wanted to try FORTRAN. The BASIC system had a remote terminal with paper tape while the FORTRAN system was only available via punch cards that were shipped out daily. Imagine a two day debug turn around.
Fortran的初始版本只有32个语句。这包括频率语句,这暗示了新的“优化”编译器以改进语句性能。这是C的Pragma声明的先驱。IF语句映射到IBM 704分支指令。这与当时与硬件中功能相匹配的C/C ++自动收入/减少支持。
FORTRAN has progressed significantly since then. There have been numerous FORTRAN versions and specifications including:
- FORTRAN
- Fortran II
- Fortran III
- FORTRAN 1401
- Fortran IV
- FORTRAN 66
- FORTRAN 77 - ANSI X3J3/90.4
- Fortran 90- ISO/IEC标准1539:1991
- Fortran 95
- Fortran 2003
- FORTRAN 2008 - ISO/IEC 1539-1:2010
Along the way things like three-way, arithmetic IF statement gave way to the more contemporary IF/THEN/ELSE/END IF construct. Recursion is now supported. Initially recursion was not an option. That actually made my job easier when I put together that FORTRAN simulator. Looping was improved as have data types. There is even support now for object oriented programming. Variable length strings were not added until FORTRAN 95.
Dynamic memory allocation showed up in Fortran 90 along with pointers. Programmers got a taste for modules, operater overloading, structures and structre looping constructs. A portable specification for numerical precision kept FORTRAN at the forefront of numerical calculation.
标识符夹有31个字符,并且输入现在是免费的。最初,在80列中布置了Fortran Punch卡,并带有领先的线数。许多人会记得终端屏幕,即80个字符的24行。
在Fortran 90中删除了许多功能,包括分配/Goto Still,Fortran经常赶上其他新兴语言。
Fortran 2003was a major revision. It provided interoperability with C and included object-oriented programming support (Fig. 1) such as type extension, inheritance, polymorphism and abstract data types. Subroutines could now be polymorphic based on their argument types like Ada and C++.
类型shape integer :: color逻辑::填充integer :: x integer :: y end类型形状类型,扩展(shape):: retectAngle integer ::长度integer :: length integer :: width typer typer typer type矩形类型,扩展(retectangle):: toveed_rectangleinteger ::重量端类型the type type_rectangle subroutine sampe(sh)类(shape),intent(in):: sh select type(sh)类是(矩形)stop stop'我们有一个矩形'类是(wateed_retectangle)stop'加权_Rectangle“类默认停止”我们有其他东西'end end end subroutine示例
图1. Fortran 2003添加了带有继承的对象类定义
IEEE浮点支持现在是标准配置。添加了挥发性属性以及一系列数据操作增强功能。异步文件传输和流支持将Fortran带入了新的千年中。
FORTRAN 2008 was approved in 2010. Compared to FORTRAN 2003, it is a minor upgrade. Objects can now be declared within a BLOCK construct and storage layout can be forced with the CONTIGUOUS attribute. Recursive allocatable objects means that FORTRAN can now handle arbitrary linked structures. It addresses issues such as deep copying and memory leaks. It adds submodules (Fig. 2) and support for Coarray Fortran (CAF). Submodules are very handy in large applications and for sharing code.
module points type :: point real :: x,y end type point interface real function point_dist (a,b) import :: point type(point), intent(in) :: a,b end function point_dist end interface end module points submodule (points) points_a contains real function point_dist (a,b) type(point), intent(in) :: a,b point_dist = sqrt((a%x-b%x)**2+(a%y-b%y)**2) end function point_dist end submodule points_a
Figure 2. Submodule example from "The new features of Fortran 2008" by John Reid, JKR Associates, UK
CAF programs can be replicated and executed asynchronously. The FORTRAN array syntax has been extended to handle coarrays.
与Fortran的早期版本相比,Fortran 2008看起来像是一种完全不同的语言。另一方面,它在C ++和ADA中发现了许多熟悉或类似的构造和语法。
FORTRAN 2008 will probably not be used by the average embedded developer or an iPhone and Android app developer. On the other hand, it will be used by everyone from physicists to those crafting military applications.