next up previous contents
Next: Masked Assignment - Where Up: Input of Arrays Previous: Input of Arrays

 

Array I/O Example

For example,

    INTEGER :: i
    INTEGER, DIMENSION(1:3,1:3) :: a
    a = RESHAPE((/1,2,3,4,5,6,7,8,9/),(/3,3/))
    PRINT*, 'Array element    =',a(3,2)
    PRINT*, 'Array section    =',a(:,1)
    PRINT*, 'Sub-array        =',a(:2,:2)
    PRINT*, 'Whole Array      =',a
    PRINT*, 'Array Transposed =',TRANSPOSE(a)
    DO i = 1, 3
     PRINT*, 'Row ',i,'     = ',a(i,:)
    END DO
    END

produces on the screen,

    Array element    = 6
    Array section    = 1 2 3
    Sub-array        = 1 2 4 5
    Whole Array      = 1 2 3 4 5 6 7 8 9
    Array Transposed = 1 4 7 2 5 8 3 6 9
    Row 1            = 1 4 7
    Row 2            = 2 5 8
    Row 3            = 3 6 9


next up previous contents
Next: Masked Assignment - Where Up: Input of Arrays Previous: Input of Arrays

Adam Marshall ©University of Liverpool, 1996
Fri Dec 6 15:03:35 GMT 1996
Not for commercial use.