next up previous contents
Next: Expressions and Assignment Up: Data Objects Previous: Constants (Parameters)

 

Initialisation

Variables can be given initial values:

    REAL             :: x, y =1.0D5
    INTEGER          :: i = 5, j = 100
    CHARACTER(LEN=5) :: light = 'Amber' 
    CHARACTER(LEN=9) :: gumboot = 'Wellie' 
    LOGICAL  :: on = .TRUE., off = .FALSE.
    REAL, PARAMETER :: pi = 3.141592
    REAL, PARAMETER :: radius = 3.5 
    REAL :: circum = 2 * pi * radius

gumboot will be padded, to the right, with blanks.

In general, intrinsic functions cannot be used in initialisation expressions, the following can be: REPEAT, RESHAPE, SELECTED_INT_KIND, SELECTED_REAL_KIND, TRANSFER, TRIM, LBOUND, UBOUND, SHAPE, SIZE, KIND, LEN, BIT_SIZE and numeric inquiry intrinsics, for, example, HUGE, TINY, EPSILON.

For more information, click here gif

Now try this question gif


next up previous contents
Next: Expressions and Assignment Up: Data Objects Previous: Constants (Parameters)

©University of Liverpool, 1997
Wed May 28 23:37:18 BST 1997
Not for commercial use.