      PROGRAM ARRAYARG
      IMPLICIT NONE
      
      INTEGER DIM
      PARAMETER (DIM = 3)
      REAL*8 VECTOR(DIM)
      REAL LENGTH
      
      VECTOR(1) = 0.0
      VECTOR(2) = 3.0
      VECTOR(3) = 4.0
      
      PRINT *, "THE LENGTH OF (", VECTOR, ") IS ", LENGTH(VECTOR, DIM)

      CALL UNITIZE(VECTOR, DIM)
      PRINT *, "AFTER UNITIZE: (", VECTOR, "), THE LENGTH IS ", 
     +LENGTH(VECTOR, DIM)
      
      STOP
      END     
      
      SUBROUTINE UNITIZE(VECTOR, N)
      INTEGER N
      REAL*8 VECTOR(N)
      REAL LENGTH
      
      REAL LEN
      
      LEN = LENGTH(VECTOR, N)
      DO 10 I = 1, N
        VECTOR(I) = VECTOR(I) / LEN
10    CONTINUE

      RETURN
      END
      
      REAL FUNCTION LENGTH(VECTOR, N)
      INTEGER N
      REAL*8 VECTOR(N)
      
      REAL SUM
      
      SUM = 0.0
      DO 10 I = 1, N
        SUM = SUM + VECTOR(I) ** 2
10    CONTINUE

      LENGTH = SQRT(SUM)
      RETURN
      END
      