
C LAST UPDATE:
C+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
C
C*************************
C**     LSM_ANORM       **
C*************************
C
C **** LSM SERVICE ROUTINE ONLY ****
C      
       DOUBLE PRECISION FUNCTION LSM_ANORM(KNORM, ALAM, IERR)
C
      INCLUDE 'implicit_none.finc'
C
C Purpose:  Return the wavelength normalisation factor
C
C Author:  Steffi Arzt, John Campbell, July 1997
C
C Arguments:
C
      INTEGER KNORM
      INTEGER IERR
      REAL ALAM
C
C Parameters:
C
C     KNORM  (R)    No. of wavelength range
C     ALAM   (R)    Wavelength of reflection
C     IERR   (W)    Error flag =0 OK
C                              =1 invalid range or out of range
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_CHEB_1D_VAL
C
C====== LOCALS:
C
      INTEGER J
      INTEGER KERR
      DOUBLE PRECISION AL
      DOUBLE PRECISION CC(POLCOEFFS)
      DOUBLE PRECISION ALMIN
      DOUBLE PRECISION ALMAX

C
C-------------------------------------------------------------------------------
C 
      IERR = 0
      IF (KNORM.LE.0) THEN
         LSM_ANORM = 0.0D0
         IERR = 1
         RETURN 
      END IF
      AL = ALAM
      DO 20 J = 1, NNORM(KNORM)
         CC(J) = SCP(NCSCP(6)+(KNORM-1)*POLCOEFFS+J)
20    CONTINUE 
C  
C====== Normalisation factor 
C 
      ALMIN = NORMLAMMIN(KNORM)
      ALMAX = NORMLAMMAX(KNORM) 
      LSM_ANORM = LSM_CHEB_1D_VAL(ALMIN, ALMAX, CC, NNORM(KNORM)-1, 
     +                            AL, KERR)
      IF (KERR.NE.0) THEN
         LSM_ANORM = 0.0D0
         IERR = 1
         RETURN 
      END IF
      END
