FORTRAN Reference Manual

Language Elements
FORTRAN Reference Manual528615-001
2-14
Variables
You can use Hollerith constants to represent character data. You might need to use
Hollerith data if you are working with pre-FORTRAN 77 programs. For additional
details, see Appendix H, Hollerith Constants and Punch Card Codes.
Variables
A variable names a storage location whose contents can change during program
execution. You identify a variable by a symbolic name.
You can use a declaration statement to declare explicitly the data type of a variable.
For example:
INTEGER*8 employee
REAL balance, tax
DOUBLE PRECISION tonnage (12, 365)
If the variable is type character, you must specify its length when you declare its type.
For example:
CHARACTER name*15, address*20, city*10, state*4, zip*9
The preceding CHARACTER declaration creates five variables whose lengths are 15,
20, 10, 4, and 9 bytes respectively. FORTRAN allocates one byte of storage for
CHARACTER variables that do not include a length specification.
The range, precision, and storage allocation for variables is the same as for constants.
Arrays
An array is a sequence of elements of the same type, identified by one symbolic name.
Dimensioning an Array
A FORTRAN array has a minimum of one dimension and a maximum of seven
dimensions. You can specify the dimensions of an array using a DIMENSION,
COMMON, RECORD, or type declaration statement. When you declare an array, you
must also declare its dimensions in the following form:
array-name ( d [ , d ]... )
array-name is the name of the array and d specifies the bounds of an array
dimension and takes the form:
[ lower : ] upper
lower specifies the lower bound of the dimension. The lower bound can be zero,
negative, or positive. If you do not specify a lower bound, the compiler uses 1 as the
lower bound.
upper specifies the upper bound of the dimension. The upper bound can be zero,
negative, or positive. The upper bound must be greater than or equal to the lower