
C LAST UPDATE:
C+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
C
C*****************************
C**     LSM_CHEB_1D_VAL     **
C*****************************
C
C **** LSM SERVICE ROUTINE ONLY ****
C
       REAL FUNCTION LSM_CHEB_1D_VAL (XMIN, XMAX, CC, N, X, IERR)
C
       INCLUDE 'implicit_none.finc'
C
C Purpose: Evaluate Chebyshev function value
C
C Author:  Steffi Arzt, John Campbell, July 1997
C
C Arguments:
C
       DOUBLE PRECISION XMIN
       DOUBLE PRECISION XMAX
       DOUBLE PRECISION CC(*)
       DOUBLE PRECISION X
       INTEGER IERR

C Parameters:
C  XMIN      (R)    Minimum 'x' used in polynomials calculation
C  XMAX      (R)    Maximum 'x' used in polynomials calcualtion
C  CC        (R)    The Chebyshev polynomial coefficients                           		   C(0) ... C(N).
C  N         (R)    Polynomial order in 'x' direction
C  X         (R)    The value of 'x' at which the function is to be evaluated
C  IERR      (W)    Error flag =0 OK, 
C                   =1 x outside range XMIN to XMAX
C                   =2 polynomial order N outside range of routine 
C                   (value of 0.0 returned if IERR.NE.0)
C
C
C====== PARAMETERS:
C
      INCLUDE 'limits.finc'
C
C====== GLOBALS:
C
      INCLUDE 'scp.finc'
      INCLUDE 'scps_counters.finc'
      INCLUDE 'other_scale.finc'
C
C====== FUNCTION TYPES:
C
      REAL LSM_CHEBVAL
C
C====== LOCALS:
C
      INTEGER I
      INTEGER N
      DOUBLE PRECISION CI(POLCOEFFS+1)
 
C
C-------------------------------------------------------------------------------
C
      IERR = 0
      LSM_CHEB_1D_VAL = 0.0
      IF (N.GT.POLCOEFFS) THEN
         IERR = 2
         RETURN
      END IF
      IF (((X-XMIN)*(X-XMAX)).GT.0.0) THEN
         IERR = 1
         RETURN
      END IF
      DO 100 I = 0, N
            CI(I+1) = CC(I+1)
 100  CONTINUE
      LSM_CHEB_1D_VAL = LSM_CHEBVAL (XMIN, XMAX, CI, N+1, X)
      RETURN
      END
