next up previous contents
Next: Allocatable Arrays Up: Arrays Previous: The RESHAPE Intrinsic Function

 

Array Constructors in Initialisation Statements

Arrays can be initialised

    INTEGER, DIMENSION(4) :: solution = (/2,3,4,5/)
    CHARACTER(LEN=*), DIMENSION(3) :: &
             lights = (/'RED  ','BLUE ','GREEN'/)

In the second statement all strings must be same length.

Named array constants may also be created:

    INTEGER, DIMENSION(3), PARAMETER :: &
             Unit_vec = (/1,1,1/)
    REAL, DIMENSION(3,3), PARAMETER :: &
             unit_matrix = &
                RESHAPE((/1,0,0,0,1,0,0,0,1/),(/3,3/))

For more information, click here gif

Now try this question gif


next up previous contents
Next: Allocatable Arrays Up: Arrays Previous: The RESHAPE Intrinsic Function

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