A variable is represented by a symbolic name which is associated with a particular place in the memory of your computer. The value of the variable is the value currently stored in that location and this value can be changed by assigning a new value to the variable.

Prior to using a particular variable, you have to specify its *data type* or, for those of you
who are more rigorous, *declare the variable*. It means that you assign a specific standard
type to this variable, which in turn tells your computer to allocate a sufficient amount of space
for storage of this data. This declaration of variables occurs after the statement `program`

,
`subroutine`

or `function`

(the last two subprograms will be explained later) and
typically has the following form:

integer number, val real resultIn this example,

`integer`

and `real`

are data types and `number`

, `val`

,
`result`

are symbolic names of three variables. It should be clear that the first two variables
are declared to contain integral numbers, whereas the last one will store a real number. You can
always assign a data type to more than one variable in one line, provided that the variables are
separated by commas.
Fortran provides several standard data types which are frequently used in F77 codes. A very short
compilation of the most useful ones is given below. You can see that each variable occupies a
different space in the memory of your computer. For the beginning you will often use two data types,
`integer`

and `real`

, the former of which is commonly used for counting loops and the
latter contains the values used in your calculations.

symbolic name | size | description |

`logical` |
1 bit | stores either logical 0 (`.false.` ) or logical 1 (`.true.` ) |

`byte` |
1 byte | integral numbers from -128 to 127 |

`integer` |
4 bytes | integral numbers from to |

`real` |
4 bytes | real numbers approx. between and |

`double precision` |
8 bytes | real numbers approx. between and |

`complex` |
2 4 bytes | two `real` numbers, real and imaginary part |

`double complex` |
2 8 bytes | two `double precision` numbers, real and imaginary part |

`character` |
1 byte | one alphanumeric character |

`character*N` |
N bytes | `N` alphanumeric characters |

A common task is to declare an array which can store a vector (1N, N1), matrix (MN) or a higher-dimensional array (MNP). This can be done for any numerical data type by simply declaring:

integer vect(5) real mat(4,10), tmat(2,5,9)The variable

`vect`

is a vector of 5 components of type `integer`

indexed from
`vect(1)`

to `vect(5)`

, `mat`

represents a matrix of `real`

numbers with 4 rows
and 10 columns and `tmat`

is a three-dimensional array in which each element is of type
`real`

. The elements of the lastly-mentioned array can be accessed accordingly,
e.g. `tmat(1,3,7)`

.

2004-09-27