!+ Subroutine to calculate gradient of residual in asymmetry of ice.
!
! 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.
!
!- ---------------------------------------------------------------------
      SUBROUTINE ICE_ASYMMETRY_GRADIENT(N_DATA, I_FIT_TYPE, N_PARAMETER
     &   , VOL_FRACTION, RADIUS_EFFECTIVE
     &   , ASYMMETRY, PARM
     &   , GRADIENT)
!
!
      IMPLICIT NONE
!
!
!     INCLUDE HEADER FILES.
      INCLUDE 'incl/dimensions_spec.ucf'
      INCLUDE 'incl/ice_cloud_parametrization.pcf'
!
!     DUMMY VARIABLES
      INTEGER 	!, INTENT(IN)
     &     N_DATA
!             NUMBER OF DATA POINTS
     &   , I_FIT_TYPE
!             TYPE OF FIT REQUIRED
     &   , N_PARAMETER
!             NUMBER OF PARAMETERS
      REAL*8	!, INTENT(IN)
     &     ASYMMETRY(N_DATA)
!             ACTUAL ASYMMETRIES
     &   , VOL_FRACTION(N_DATA)
!             VOLUME FRACTION RADIUS
     &   , RADIUS_EFFECTIVE(N_DATA)
!             EFFECTIVE RADIUS
     &   , PARM(N_PARAMETER)
!             FITTING PARAMETERS
      REAL*8	!, INTENT(OUT)
     &     GRADIENT(NPD_CLOUD_PARAMETER)
!             GRADIENT OF SCATTERING
!
!     LOCAL VARIABLES.
      INTEGER
     &     I
!             LOOP VARIABLE
!
!
!     INITIALIZE THE GRADIENT TO ZERO.
      DO I=1, N_PARAMETER
         GRADIENT(I)=0.0D+00
      ENDDO
!
!     SET NON-ZERO TERMS FOR DIFFERENT SCHEMES.
      IF (I_FIT_TYPE.EQ.IP_SLINGO_SCHRECKER_ICE) THEN
         DO I=1, N_DATA
            GRADIENT(1)=GRADIENT(1)-2.0D+00*(ASYMMETRY(I)
     &         -(PARM(1)+PARM(2)*RADIUS_EFFECTIVE(I)))
            GRADIENT(2)=GRADIENT(2)-2.0D+00*(ASYMMETRY(I)
     &         -(PARM(1)+PARM(2)*RADIUS_EFFECTIVE(I)))
     &         *RADIUS_EFFECTIVE(I)
         ENDDO
      ELSE IF (I_FIT_TYPE.EQ.IP_CIRRUS_ADT) THEN
         DO I=1, N_DATA
            GRADIENT(1)=GRADIENT(1)-2.0D+00*(ASYMMETRY(I)
     &         -PARM(1))
         ENDDO
      ENDIF
!
!     NORMALIZE THE GRADIENT.
      DO I=1, N_PARAMETER
         GRADIENT(I)=GRADIENT(I)/DBLE(N_DATA)
      ENDDO
!
!
      RETURN
      END
