In the earlier posts, we have provided the details on how to get started with FORTRAN77 and install a FORTRAN compiler with an editor. Knowledge of dimension and parameter statements leads us one step ahead.
This statement declares the dimensions and rank of arrays in a program. For example, the code below is a dimension statement. Here, variable A has been assigned 2 dimensions with the first dimension holding 5 variables and the second one holding 6 variables.
Dimension statement used in conjunction with Type specification statement assigns same dimension to all the elements.
REAL DIMENSION(5,6) :: a,b,c
However, if in any case, one does not know the dimension of the array beforehand, it becomes very difficult. FORTRAN 77 does not support dynamic memory locations. An updated version of FORTRAN, i.e, FORTRAN 90 provides a memory allocation option that makes the procedure very simple.
Parameter statement assigns a symbolic name to the constant. Many times we have to use same constant (let’s say= 3.1415..) again and again. Constant value is lengthy and frustrating to type it multiple times. Therefore, we assign a symbolic name to it (such as PI to 3.1415..). These statements help to reduce the number of typos in the program. Syntax for the parameter statement is :
PARAMETER (name = constant, ... , name = constant)
These are placed after the type specification statements. For example see:
PROGRAM CIRCLE REAL R, AREA, PI PARAMETER (PI=3.14159)
In the above code, parameter statement assigns symbolic name PI to 3.14159. Parameter statements can be used in conjunction with type specification commands in same line of the program.
REAL, PARAMETER :: E = 2.71828, PI = 3.141592
The word PARAMETER follows type specification command. separated by a comma. After this, two semicolons are introduced which are followed by the expression assigning symbolic name to the constant. One must remember that symbolic name is not a variable, it is just an alias of the value it indicates.
Do not define symbolic names more than once in a program. Once defined for a particular constant, it can not represent anything else in that program. Place these commands before the executable commands only.