FORTRAN 77 supports six data types:
Numerical data in FORTRAN 77 can be represented in one of four types.
INTEGER is any signed number that has no fractional part
and no decimal point.
INTEGER numbers are also referred to as
fixed point numbers. The other three numerical types are
called floating point numbers. A
is a signed number with a decimal point.
Very large or very small numbers are often represented in scientific notation. In this notation, a number is represented as
±b × 10±n
where b is a number between 1 and 10 and n is the appropriate power of ten. FORTRAN 77 offers a similar representation called exponential notation:
In this case, the mantissa m is a number between 0.1 and 1.0 and p is again the appropriate power of ten.
|0.000135||1.35 × 10-4||0.135E-03|
|-246.8||-2.468 × 102||-0.2468E+03|
|235700000000000000000.0||2.357 × 1020||0.2357E+21|
A number stored in a computer is limited in magnitude and precision. The
limits depend on the particular computer. Thus, a
has only a certain number of significant digits. If more significant digits
are required for a calculation, then
DOUBLE PRECISION numbers
must be used. A
DOUBLE PRECISION constant is written in
the same exponential form as a single precision
except with a
D instead of an
E separating the
mantissa from the exponent.
In practice, most computers use 32 bits to store
REAL numbers. This means that an
limited to numbers between -2,147,483,648 and +2,147,483,647 (a sign bit and
31 magnitude bits). If the IEEE standard is used, then a
REAL number will have about seven decimal digits and be within
the magnitude range of 10-38 to 10+38.
DOUBLE PRECISION numbers usually have at least twice the
number of significant decimal digits and a magnitude range of
10-308 to 10+308.
Complex numbers are common in many fields of science and engineering so
it is not surprising that FORTRAN 77 offers a
type. The complex number a+ib where i is the
imaginary unit (square root of -1) is represented in
FORTRAN 77 as
themselves are single precision
REAL numbers. There are no
double precision complex numbers available in FORTRAN 77.
The other two data types deal with non-numerical information. A
LOGICAL value is either
.FALSE. (note the full stops!) whilst a
value can contain any combination of characters from the FORTRAN 77
character set. In fact, on most computers, a
can contain any combination of printable characters. A
constant is any set of characters enclosed in apostrophes. If an apostrophe
is needed as part of the string, then two apostrophes (not a double quote)
||a character string||18|
The type of any constant, variable or array used in a FORTRAN 77 program
must be specified either implicitly or explicitly. In
implicit typing, all constants, variables and arrays
beginning with the letters I, J, K, L, M, or N are automatically taken to be
INTEGER. Constants, variables and arrays beginning with
all other letters are assumed to be
REAL. Thus, with implicit
typing, the variable
REAL whilst the
KOUNT is an
INTEGER. Implicit typing
can be overridden with explicit type declaration. To explicitly declare a
constant, variable or array to be of a given type, simply put a statement
of the form
where type is one of the six data types and the name-list is a list of the names of the constants, variables or arrays of the chosen type separated by commas.
COMPLEX FALL,TRIP DOUBLE PRECISION BIGJMP INTEGER A,AA,AAA LOGICAL DECIDE REAL BOUND,JUMP,LEAP
at the beginning of a program unit define the variables named
TRIP to be of type
BIGJMP to be
AAA to be
DECIDE to be
LEAP to be
CHARACTER declarations are a little more subtle in that they
require prior knowledge of the length of the string that will be stored
CHARACTER variable. The syntax for a
CHARACTER variable is
where all of the variables in the variable-list are m characters long. Some or all of these characters may be blank. It is also possible to use one declaration statement to specify several variables of different lengths:
CHARACTER variable1*m1, variable2*m2, …, variablen*mn
In this case, the first variable is of length m1, the second variable is of length m2 and so on.
CHARACTER*3 CONST,GREEK CHARACTER CATLOG*10,NAME*20
at the beginning of a program unit define
GREEK to be
CHARACTER variables of length 3 whilst
CATLOG is of length 10 and
NAME is of length 20.
variables and arrays have implicit types, it is possible to assign defaults
for all data types through the use of the
The syntax for this statement is
IMPLICIT type1 (range1), type2 (range2), …, typen (rangen)
Explicit type declarations override implicit type declarations.
A program that has only
DOUBLE PRECISION variables might
contain the statement
IMPLICIT DOUBLE PRECISION(A-Z)
at the beginning.
Because of the declarations
IMPLICIT COMPLEX(A-C),DOUBLE PRECISION(D),INTEGER(E-Z) LOGICAL HELP
all variables beginning with the letters A through C are of type
COMPLEX, all variables beginning with the letter D are of
DOUBLE PRECISION, and everything else is an
INTEGER. The explicit type declaration that
HELP is of type
LOGICAL overrides the