      SUBROUTINE ORTHOS (AU, MA, AA, NA, AR)
C     ******************************************************************
C     FORTRAN SUBROUTINE FOR ORTHONORMAL POLYNOMIAL SYNTHESIS
C     ******************************************************************
C     AU = COORDINATE ARGUMENTS    (N ARRAY)
C     MA = NUMBER OF COLUMNS       (M)
C     AA = MATRIX OF POLYNOMIALS   (NXM ARRAY)
C     NA = NUMBER OF ROWS          (N)
C     AR = RECURRENCE COEFFICIENTS (2*M-2 ARRAY)
C
      DIMENSION AU(1), AA(1), AR(2)
  001 SN=NA
      RN=SQRT(SN)
      DO 002 I=1,NA
      AA(I)=1.0/RN
  002 CONTINUE
      IF(MA.EQ.1)RETURN
  003 SM=0.0
      DO 004 I=1,NA
      SM=SM+AU(I)
  004 CONTINUE
      AR(2)=SM/SN
      SM=0.0
      L=NA
      DO 005 I=1,NA
      L=L+1
      AA(L)=AU(I)-AR(2)
      SM=SM+AA(L)*AA(L)
  005 CONTINUE
      RM=SQRT(SM)
      L=NA
      DO 006 I=1,NA
      L=L+1
      AA(L)=AA(L)/RM
  006 CONTINUE
      SM=0.0
      L=NA
      DO 007 I=1,NA
      L=L+1
      SM=SM+AU(I)*AA(L)
  007 CONTINUE
      AR(1)=SM/RN
      IF(MA.EQ.2)RETURN
  008 DO 013 M=3,MA
      SM=0.0
      K=(M-2)*NA
      DO 009 I=1,NA
      K=K+1
      SM=SM+AU(I)*AA(K)*AA(K)
  009 CONTINUE
      AR(2*M-2)=SM
      SM=0.0
      J=(M-3)*NA
      DO 010 I=1,NA
      J=J+1
      K=J+NA
      L=K+NA
      AA(L)=AU(I)*AA(K)-AR(2*M-2)*AA(K)-AR(2*M-5)*AA(J)
      SM=SM+AA(L)*AA(L)
  010 CONTINUE
      RM=SQRT(SM)
      L=(M-1)*NA
      DO 011 I=1,NA
      L=L+1
      AA(L)=AA(L)/RM
  011 CONTINUE
      SM=0.0
      K=(M-2)*NA
      DO 012 I=1,NA
      K=K+1
      L=K+NA
      SM=SM+AU(I)*AA(K)*AA(L)
  012 CONTINUE
      AR(2*M-3)=SM
  013 CONTINUE
      RETURN
      END
