
:FORTRAN Concepts |
2.2.2 Constants and Variables
The value of a constant does not change from one execution of a program to the next. The value of a variable, on the other hand, is subject to change during pro- gram execution or between runnings of the program. For example, in the statement
C=A**2+B
the '2' is constant, whereas A, B, and C are variable and may change as the result of an earlier calculation or value assignment.
A constant appears as its actual value. A variable has a symbolic name that can be
K
XYZ
B52
ERROR8
STEP3
Every constant and variable has a data type and length associated with it. Arithmetic constants and variables also have an associated number base.
2.2.2.1Data Types. Arithmetic constants and variables are of type integer or real (sometimes called 'fixed point' and 'floating point').
An integer constant is written without a decimal point and can be preceded by a '+' or
4.2E3 (4.2 X 103 .or 4200)
4.2E+3 (same as above)
The internal representation, the precision, and the range of real values conforms to the
An integer variable name begins with one of the alphabetic characters'!' through
'N.Variables' beginning with an alphabetic character other than I, J, K, L, M, or N are assumed to be type real. This implicit naming convention can be circumvented using Type statements, however (see section 3.1).
Constants and variables can also be of type logical or type character.
Logical data may have only the values 'true' or 'false.' The possible forms of a logical constant are:
.TRUE.