Information Technology Reference
In-Depth Information
Another important feature of FORTRAN was that it introduced a data structure
called an array that was especially useful for scientific computations. An array
is a group of logically related elements stored in an ordered arrangement in the
computer's memory. Individual elements in the array may be located using one
or more indexes. The dimension of an array is the number of indexes needed to
find an element. For example, a list is a one-dimensional array, and a block of
data could be a two- or three-dimensional array. An instruction called a dimension
statement instructs the compiler to assign storage space for each array and gives it
a symbolic name and dimension specifications. For example, a one-dimensional
array of numbers called a vector may be specified by the dimension statement
VEC(10) or a three-dimensional field of values by MAGFLD(64, 64, 64).
Modern programming languages have improved on the minimal specifi-
cation of data types in FORTRAN. Many languages today employ strong typing -
strict enforcement of type rules with no exceptions. Checking that a large,
complex software system correctly uses appropriate data types greatly reduces
the number of bugs in the resulting code.
For efficiency reasons, the development of FORTRAN was closely aligned
to the hardware architecture of the computer. Thus FORTRAN assignment state-
ments , instructions that assign values to the variables, are actually descriptions
of how the data moves in the machine. In FORTRAN, assignment statements
are written using the “equal” sign, but these statements do not mean mathe-
matical equality. Consider the assignment statement
+ ( )
A
=
2.
B C
*
In FORTRAN, this statement means, “Replace the value at address A by the
result of the calculation 2.0*(B+C).” Similarly, the odd-looking statement
J
=+1
means, “Read the value from address J, add 1 to this value, and then store the
result at the same address.”
The original FORTRAN specification provided three kinds of control state-
ments , instructions that switch the computer from automatically reading the
next line of code to reading a different one:
The DO statement was used to allow the program to perform a
loop , a
sequence of instructions that repeats either a specified number of times
or until a particular condition is met.
The IF statement was employed for
branches , instructions that tell the
computer to go to some other part of the program, depending on the
result of some test.
The GO TO statement was used to direct the computer to jump to a spe-
cific numbered statement.
Forms of the basic do loop and if statement constructs are available in most
modern programming languages. We can write the general form of these con-
trol statements in pseudocode , an informal, high-level description of a program
that is intended to be read by humans. A computer could not directly execute
Search WWH ::




Custom Search