Search This Blog

Monday, 3 November 2014

FORTRAN

As computing became established throughout the 1950s, the need for a language that could express operations in a more “human-readable” language began to be acutely felt. In a high-level language, programmers define variables and write statements and expressions to manipulate them. The programmer is no longer concerned with specifying the detailed storage and retrieval of binary data in the com-puter, and is freed to think about program structure and the proper implementation of algorithms.

Fortran (FORmula TRANslator) was the first widely used high-level programming language. It was developed by a project begun in 1954 by a team under the leadership of IBM researcher John Backus. The goal of the project was to create a language that would allow mathematicians, sci-entists, and engineers to express calculations in something close to the traditional notation. At the same time, a com-piler would have to be carefully designed so that it would produce executable machine code that would be nearly as efficient as the code that would have been created through the more tedious process of using assembly languages. (See compiler and assembler.)

The first version of the language, Fortran I, became available as a compiler for IBM mainframes in 1957. An improved (and further debugged version) soon followed. Fortran IV (1963) expanded the number of supported data types, added “common” data storage, and included the DATA statement, which made it easier to load literal numeric values into variables. This mature version of For-tran was widely embraced by scientists and engineers, who created immense libraries of code for dealing with calcula-tions commonly needed for their work.


By the 1970s, the structured programming movement was well under way. This school of programming emphasized dividing programs into self-contained procedures into which data would be passed, processed, and returned. The use of unconditional branches (GOTO statements) as was common in Fortran was now discouraged. A new version of the language, Fortran 77 (or F77), incorporated many of the new structural features. The next version, Fortran 90 (F90), added support for recursion, an important technique for coding certain kinds of problems (see recursion). Math-ematics libraries were also modernized. FORTRAN 2003 contains a number of new features, including support for modern programming structures (see object-oriented programming) and the ability to interface smoothly with programs written in the C language. A relatively minor fur-ther revision has the tentative name FORTRAN 2008.

Sample Program

The following simple example illustrates some features of a traditional FORTRAN program:

INTEGER INTARRAY(10)

INTEGER ITEMS, COUNTER, SUM, AVG SUM = 0

READ *, ITEMS

DO 10 COUNTER = 1, ITEMS READ *, INTARRAY(COUNTER)

SUM = SUM + INTARRAY(COUNTER) 10 CONTINUE

AVG = SUM / ITEMS

PRINT ‘SUM OF ITEMS IS: ’, SUM PRINT ‘AVERAGE IS: ’, AVG

STOP

END

The program creates an array holding up to ten integers (see array). The first number it reads is the number of items to be added up. It stores this in the variable ITEMS. A DO loop statement then repeats the following two statements once for each number from 1 to the total number of items. Each time the two statements are executed, COUNTER is increased by 1. The statements read the next number from the array and add it to the running total in SUM. Finally, the average is calculated and the sum and average are printed.


Like its contemporary, COBOL, Fortran is viewed by many modern programmers as a rather clumsy and anach-ronistic language (because of its use of line number refer-ences, for example). However, there is a tremendous legacy of tested, reliable Fortran code and powerful math libraries. (For example, a Fortran program can call library routines to quickly get the sum or cross-product of any array or matrix.) These features ensure that Fortran has continuing appeal and utility to users who are more concerned with getting fast and accurate results than with the niceties of programming style.


No comments:

Post a Comment