C
C     ..................................................................
C
C        SUBROUTINE ORDER
C
C        PURPOSE
C           CONSTRUCT FROM A LARGER MATRIX OF CORRELATION COEFFICIENTS
C           A SUBSET MATRIX OF INTERCORRELATIONS AMONG INDEPENDENT
C           VARIABLES AND A VECTOR OF INTERCORRELATIONS OF INDEPENDENT
C           VARIABLES WITH DEPENDENT VARIABLE.  THIS SUBROUTINE IS
C           NORMALLY USED IN THE PERFORMANCE OF MULTIPLE AND POLYNOMIAL
C           REGRESSION ANALYSES.
C
C        USAGE
C           CALL ORDER (M,R,NDEP,K,ISAVE,RX,RY)
C
C        DESCRIPTION OF PARAMETERS
C           M     - NUMBER OF VARIABLES AND ORDER OF MATRIX R.
C           R     - INPUT MATRIX CONTAINING CORRELATION COEFFICIENTS.
C                   THIS SUBROUTINE EXPECTS ONLY UPPER TRIANGULAR
C                   PORTION OF THE SYMMETRIC MATRIX TO BE STORED (BY
C                   COLUMN) IN R.  (STORAGE MODE OF 1)
C           NDEP  - THE SUBSCRIPT NUMBER OF THE DEPENDENT VARIABLE.
C           K     - NUMBER OF INDEPENDENT VARIABLES TO BE INCLUDED
C                   IN THE FORTHCOMING REGRESSION. K MUST BE GREATER
C                   THAN OR EQUAL TO 1.
C           ISAVE - INPUT VECTOR OF LENGTH K+1 CONTAINING, IN ASCENDING
C                   ORDER, THE SUBSCRIPT NUMBERS OF K INDEPENDENT
C                   VARIABLES TO BE INCLUDED IN THE FORTHCOMING REGRES-
C                   SION.
C                   UPON RETURNING TO THE CALLING ROUTINE, THIS VECTOR
C                   CONTAINS, IN ADDITION, THE SUBSCRIPT NUMBER OF
C                   THE DEPENDENT VARIABLE IN K+1 POSITION.
C           RX    - OUTPUT MATRIX (K X K) CONTAINING INTERCORRELATIONS
C                   AMONG INDEPENDENT VARIABLES TO BE USED IN FORTH-
C                   COMING REGRESSION.
C           RY    - OUTPUT VECTOR OF LENGTH K CONTAINING INTERCORRELA-
C                   TIONS OF INDEPENDENT VARIABLES WITH DEPENDENT
C                   VARIABLES.
C
C        REMARKS
C           NONE
C
C        SUBROUTINES AND FUNCTION SUBPROGRAMS REQUIRED
C           NONE
C
C        METHOD
C           FROM THE SUBSCRIPT NUMBERS OF THE VARIABLES TO BE INCLUDED
C           IN THE FORTHCOMING REGRESSION, THE SUBROUTINE CONSTRUCTS THE
C           MATRIX RX AND THE VECTOR RY.
C
C     ..................................................................
C
      SUBROUTINE ORDER (M,R,NDEP,K,ISAVE,RX,RY)
      DIMENSION R(1),ISAVE(1),RX(1),RY(1)
C
C        ...............................................................
C
C        IF A DOUBLE PRECISION VERSION OF THIS ROUTINE IS DESIRED, THE
C        C IN COLUMN 1 SHOULD BE REMOVED FROM THE DOUBLE PRECISION
C        STATEMENT WHICH FOLLOWS.
C
C     DOUBLE PRECISION R,RX,RY
C
C        THE C MUST ALSO BE REMOVED FROM DOUBLE PRECISION STATEMENTS
C        APPEARING IN OTHER ROUTINES USED IN CONJUNCTION WITH THIS
C        ROUTINE.
C
C        ...............................................................
C
C     COPY INTERCORRELATIONS OF INDEPENDENT VARIABLES
C     WITH DEPENDENT VARIABLE
C
      MM=0
      DO 130 J=1,K
      L2=ISAVE(J)
      IF(NDEP-L2) 122, 123, 123
  122 L=NDEP+(L2*L2-L2)/2
      GO TO 125
  123 L=L2+(NDEP*NDEP-NDEP)/2
  125 RY(J)=R(L)
C
C     COPY A SUBSET MATRIX OF INTERCORRELATIONS AMONG
C     INDEPENDENT VARIABLES
C
      DO 130 I=1,K
      L1=ISAVE(I)
      IF(L1-L2) 127, 128, 128
  127 L=L1+(L2*L2-L2)/2
      GO TO 129
  128 L=L2+(L1*L1-L1)/2
  129 MM=MM+1
  130 RX(MM)=R(L)
C
C     PLACE THE SUBSCRIPT NUMBER OF THE DEPENDENT
C     VARIABLE IN ISAVE(K+1)
C
      ISAVE(K+1)=NDEP
      RETURN
      END
