next up previous contents
Next: The order in which Up: A short summary of Previous: The structure of a   Contents


Data types, variables and declarations

Names of variables in FORTRAN consist of letters and numbers, the first symbol must be a letter. N.B.: FORTRAN is case insensitive, i.e. FORTRAN does not see the difference between small letters and capitals. The variables unew, Unew, UNEW are all the same for FORTRAN!
FORTRAN knows the following types: integer, real, double precision, complex, complex * 16 and logical plus some more types which are not important here.
Although FORTRAN does not formally require explicit declaration of all variables, it is strongly recommended for the exercises. You can ask the compiler to check if a variable is explicitly declared by including the following statement in your program, before all other declarations:
      implicit none
This has to be done in all subprograms too. All real variables in the example programs are declared as double precision, all complex variables (if any) as complex * 16. This way, every real number has about 16 decimals.
A variable of the type logical is the same as a variable of the type Boolean in Pascal. It can only have the values .true. or .false..
Typical examples of declarations are:
      implicit none
      integer i, loop, index
      double precision alpha, beta, gamma
      complex * 16 c1, c2
Arrays are declared by giving explicitly the dimensions in the declaration. If no lower index is given the value 1 (one) is assumed. The index range boundaries can only be integers or integer expressions.
Examples:
      implicit none
      integer i(1:100), j(-3:1,1:2), k(100)
      double precision alpha(200,30), beta(-7:-5,1:9,10)
      complex * 16 c1(8), c2(5,4)
In FORTRAN a constant is a number of type real or integer, or the logical value .true. of .false. or a text. A text is a string of characters between apostrophes, for instance 'text'.
A real number is indicated by a point, for instance: 3.1415 or an exponent, for instance 3.1415e0 of 3.1415d0. When there is no exponent, or the exponent is E, the constant is single precision (about 7 decimals). If D is used as exponent then the constant has double precision (16 decimals). Examples: 1d-3 (=$10^{-3}$),
4.1d7 (=$4.1 * 10^7$).
A number without a points is an integer. Example: 1014


Arrays are used as follows:

   x=a(i)
   b=g(i,j)+c(i)

next up previous contents
Next: The order in which Up: A short summary of Previous: The structure of a   Contents
Mathieu Pourquie 2001-02-28