Intel fortran-80 manual Constants and Variables

Models: fortran-80

1 130
Download 130 pages 742 b
Page 16
Image 16
2.2.2 Constants and Variables

:FORTRAN Concepts

FORTRAN-SO

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 1-6 alphanumeric characters. The first character must be alphabetic. Thus, all of the following are valid variable names:

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 '-' sign (0, 123, - 34, + 5). A '+' is assumed if no sign is present. Real constants include a decimal point and optional sign (5., .5,0.5, .0005). An integer exponent preceded by an 'E' may follow a real constant and, in this case, the real constant ne.ed not have a decimal point (4E3). Again, the exponent may be signed.

4.2E3 (4.2 X 103 .or 4200)

4.2E+3 (same as above)

4.2E-3 (4.2 x 10- 3 or .0042)

The internal representation, the precision, and the range of real values conforms to the floating-point conventions established for the particular processor being used. See section F.l.

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.

.FALSE.

2-4

Page 16
Image 16
Intel fortran-80 manual Constants and Variables