!+ Function to give the value of the weighting function.
!
! Method:
!	An appropriate function is called to evaluate depending
!	on the weighting function chosen.
!
! Current Owner of Code: J. M. Edwards
!
! History:
!	 Version 	   Date	  		Comment
!   
!	 1.0		   12-04-95		First Version under RCS
!						(J. M. Edwards)
!
! Description of Code:
!   FORTRAN 77 with extensions listed in documentation. 
!
!- ---------------------------------------------------------------------
      FUNCTION FUNC_WEIGHT(I_WEIGHT, L_WAVE_NUMBER
     &   , N_SOLAR_POINTS, SOLAR_WAVELENGTH, SOLAR_IRRAD, T
     &   , POINT)
!
!
!
      IMPLICIT NONE
!
!
!     INCLUDE HEADER FILES.
      INCLUDE 'incl/dimensions_pp.ucf'
      INCLUDE 'incl/weighting.pcf'
!
!     DUMMY ARGUMENTS
!
      REAL*8	!, INTENT(OUT)
     &     FUNC_WEIGHT
!             RETURNED WEIGHTING FUNCTION
      INTEGER	!, INTENT(IN)
     &     I_WEIGHT
!             WEIGHTING FLAG
     &   , N_SOLAR_POINTS
!             NUMBER OF POINTS IN SOLAR SPECTRUM
      LOGICAL	!, INTENT(IN)
     &     L_WAVE_NUMBER
!             FLAG INVERSE WAVELENGTH
      REAL*8	!, INTENT(IN)
     &     T
!             TEMPERATURE
     &   , SOLAR_WAVELENGTH(NPD_SOLAR_POINTS)
!             WAVELENGTHS OF SOLAR SPECTRUM
     &   , SOLAR_IRRAD(NPD_SOLAR_POINTS)
!             SOLAR INTENSITIES	
     &   , POINT
!             EVALUATION POINT
!
!     LOCAL VARIABLES
      REAL*8
     &     LAMBDA
!             WAVELENGTH
!
!     FUNCTIONS CALLED:
      REAL*8
     &     PLANCK
!             PLANCKIAN FUNCTION
     &   , D_PLANCK
!             DERIVED PLANCKIAN FUNCTION
     &   , SOLAR_INTENSITY
!             SOLAR SPECTRAL FUNCTION
      EXTERNAL
     &     PLANCK, D_PLANCK, SOLAR_INTENSITY
!
!
!
!     INVERT LAMBDA IF WAVENUMBERS ARE USED AS ABSCISSAE.
      IF (L_WAVE_NUMBER) THEN
         LAMBDA=1.0D+00/POINT
      ELSE
         LAMBDA=POINT
      ENDIF
!
      IF (I_WEIGHT.EQ.IP_WEIGHT_PLANCK) THEN
         FUNC_WEIGHT=PLANCK(T, LAMBDA)
      ELSE IF (I_WEIGHT.EQ.IP_WEIGHT_DPLANCK) THEN
         FUNC_WEIGHT=D_PLANCK(T, LAMBDA)
      ELSE IF (I_WEIGHT.EQ.IP_WEIGHT_SOLAR) THEN
         FUNC_WEIGHT=SOLAR_INTENSITY(LAMBDA
     &      , N_SOLAR_POINTS, SOLAR_WAVELENGTH, SOLAR_IRRAD)
      ELSE IF (I_WEIGHT.EQ.IP_WEIGHT_UNIFORM) THEN
         FUNC_WEIGHT=1.0D+00
      ENDIF
!
      IF (L_WAVE_NUMBER) THEN
         FUNC_WEIGHT=FUNC_WEIGHT*LAMBDA*LAMBDA
      ENDIF

!
      RETURN
      END
