        SUBROUTINE CDPBAS (
*
*  inputs
*
     :                  A, SIG, ORDER, NPMAX, ORTHO,
*
*  outputs
*
     :                  COEFF, ERMTRX)
*
*  Module number:
*
*  Module name:
*
*  Keyphrase:
*  ----------
*  convert from orthogonal polynomial basis to 1, X, X**2,...
*
*  Description:
*  ------------
*  maximum order is 20
*
*  FORTRAN name: CDPBAS.FOR
*
*  Keywords of accessed files and tables:
*  --------------------------------------
*  Name                         I/O     Description / Comments
*       None
*
*  Subroutines Called:
*  -------------------
*  CDBS:
*       None
*  SDAS:
*       None
*  Others:
*       None
*
*  History:
*  --------
*  Version      Date        Author          Description
*     1       12-01-87     J.-C. HSU        design and coding
*
*-------------------------------------------------------------------------------
*
*== input:
*                                       --order of polynomial
        INTEGER                 ORDER,
*                                       --maximum order of polynomial
     :                          NPMAX
*                                       --orthogonal polynomial coefficients
*                                       --and their standard deviations
        DOUBLE PRECISION        A(0:NPMAX), SIG(0:NPMAX),
*                                       --orthogonal polynomial construct
     :                          ORTHO(0:NPMAX, 0:NPMAX)
*
*== output:
*                                       --regular polynomial coefficients and
*                                       --their error matrix
        DOUBLE PRECISION        COEFF(0:NPMAX), ERMTRX(0:NPMAX, 0:NPMAX)
*
*== local:
*                                       --work area
        DOUBLE PRECISION        D(0:20, 0:20)
*                                       --loop index
        INTEGER                 I, J, L, M, J0
*
*------------------------------------------------------------------------------
*
*  first calculate coefficients
*
        DO 10 I = 0, ORDER
            COEFF(I) = A(I)
   10   CONTINUE
*
        DO 30 I = ORDER, 1, -1
            DO 20 L = I-1, 0, -1
                COEFF(L) = COEFF(L) + COEFF(I) * ORTHO(L, I)
   20       CONTINUE
   30   CONTINUE
*
*  now calculate error matrix
*
        DO 50 I = 0, ORDER
            DO 40 J = 0, ORDER
                D(I, J) = 0.D0
                IF (I .EQ. J) D(I, J) = 1.D0
   40       CONTINUE
   50   CONTINUE
*
        DO 80 J0 = ORDER, 1, -1
            DO 70 I = J0-1, 0, -1
                DO 60 J = I+1, ORDER
                    D(I, J) = D(I, J) + ORTHO(I, J0) * D(J0, J)
   60           CONTINUE
   70       CONTINUE
   80   CONTINUE
*
        DO 110 L = 0, ORDER
            DO 100 M = 0, ORDER
                ERMTRX(L, M) = 0.D0
                DO 90 I = MAX(L, M), ORDER
                    ERMTRX(L, M) = ERMTRX(L, M) + D(L, I) * D(M, I)
     :                                  * SIG(I) ** 2
   90           CONTINUE
  100       CONTINUE
  110   CONTINUE
*
        RETURN
        END
