Symbolic constants, oddly known as parameters in Fortran, can easily be set up either in an attributed declaration or in a PARAMETER statement (it is recommended that the attributed form be used):
INTEGER price_of_fags ! F77 style - not recommended PARAMETER (price_of_fags = 252) ! F77 style - not recommended REAL, PARAMETER :: pi = 3.14159 ! F90 style
CHARACTER constants can assume their length from the associated literal (LEN=*), they can also be declared to be fixed length:
CHARACTER(LEN=*), PARAMETER :: son = 'bart', dad = "Homer"
Parameters should be used:
The variable is forced to be unchanged throughout the program. If any statement tries to change the value an error will result.
Symbolic names are easier to understand than a meaningless number.
The value of the constant can be adjusted throughout the program by changing 1 line.
Return to corresponding overview page