!+ Function to calculate the derivative of the scaling function.
!
! Method:
!	Straightforward.
!
! 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_SCALE_DERIVATIVE(I, P_FNC, T_FNC
     &   , I_SCALE_FUNCTION, SCALE_VECTOR)
!
!
!
      IMPLICIT NONE
!
!
!     INCLUDE HEADER FILES.
      INCLUDE 'incl/dimensions_spec.ucf'
      INCLUDE 'incl/scale_fnc.pcf'
!
!     DUMMY ARGUMENTS
      INTEGER	!, INTENT(OUT)
     &     I
!             PARAMETER INDEX
     &   , I_SCALE_FUNCTION
!             TYPE OF SCALING FUNCTION
      REAL*8	!, INTENT(OUT)
     &     FUNC_SCALE_DERIVATIVE
!             VALUE OF SCALING FUNCTION
      REAL*8	!, INTENT(IN)
     &     P_FNC
!             FUNCTION OF PRESSURE
     &   , T_FNC
!             FUNCTION OF TEMPERATURE
     &   , SCALE_VECTOR(NPD_SCALE_VARIABLE)
!             SCALING PARAMETERS
     &   , V1
!             TEMPORARY VARIABLE
     &   , V2
!             TEMPORARY VARIABLE
     &   , V3
!             TEMPORARY VARIABLE
!
!
!
      IF (I_SCALE_FUNCTION.EQ.IP_SCALE_POWER_LAW) THEN
         IF (I.EQ.1) THEN
            FUNC_SCALE_DERIVATIVE=P_FNC
     &         *EXP(SCALE_VECTOR(1)*P_FNC
     &         +SCALE_VECTOR(2)*T_FNC)
         ELSE IF (I.EQ.2) THEN
            FUNC_SCALE_DERIVATIVE=T_FNC
     &         *EXP(SCALE_VECTOR(1)*P_FNC
     &         +SCALE_VECTOR(2)*T_FNC)
         ENDIF
      ELSE IF (I_SCALE_FUNCTION.EQ.IP_SCALE_POWER_QUAD) THEN
         IF (I.EQ.1) THEN
            FUNC_SCALE_DERIVATIVE=P_FNC
     &         *EXP(SCALE_VECTOR(1)*P_FNC)
     &         *(1.0D+00+SCALE_VECTOR(2)*T_FNC
     &         +SCALE_VECTOR(3)*T_FNC*T_FNC)
         ELSE IF (I.EQ.2) THEN
            FUNC_SCALE_DERIVATIVE=T_FNC*EXP(SCALE_VECTOR(1)*P_FNC)
         ELSE IF (I.EQ.3) THEN
            FUNC_SCALE_DERIVATIVE=T_FNC*T_FNC*EXP(SCALE_VECTOR(1)
     &         *P_FNC)
         ENDIF
      ELSE IF (I_SCALE_FUNCTION.EQ.IP_SCALE_DOPPLER_QUAD) THEN
         V1=EXP(SCALE_VECTOR(2))
         V2=LOG((P_FNC+V1)/(1.0D+00+V1))
         V3=(1.0D+00+SCALE_VECTOR(3)*T_FNC
     &      +SCALE_VECTOR(4)*T_FNC*T_FNC)
         IF (I.EQ.1) THEN
            FUNC_SCALE_DERIVATIVE=V2*EXP(SCALE_VECTOR(1)*V2)*V3
         ELSE IF (I.EQ.2) THEN
            FUNC_SCALE_DERIVATIVE=SCALE_VECTOR(1)*((1.0D+00-P_FNC)
     &         /(1.0D+00+V1)**2)*V1*EXP((SCALE_VECTOR(1)-1.0D+00)*V2)
     &         *V3
         ELSE IF (I.EQ.3) THEN
            FUNC_SCALE_DERIVATIVE=T_FNC*EXP(SCALE_VECTOR(1)*V2)
         ELSE IF (I.EQ.4) THEN
            FUNC_SCALE_DERIVATIVE=T_FNC*T_FNC*EXP(SCALE_VECTOR(1)*V2)
         ENDIF
      ENDIF
!
!
      RETURN
      END
