!+ Function to calculate 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. 
!
!- ---------------------------------------------------------------------
      FUNCTION ICE_ASYMMETRY_RESIDUAL(N_DATA, I_FIT_TYPE, N_PARAMETER
     &   , VOL_FRACTION, RADIUS_EFFECTIVE
     &   , ASYMMETRY, PARM)
!
!
      IMPLICIT NONE
!
!
!     INCLUDE HEADER FILES.
      INCLUDE 'incl/ice_cloud_parametrization.pcf'
!
!     DUMMY ARGUMENTS
      INTEGER	!, INTENT(IN)
     &     N_DATA
!             NUMBER OF DATA POINTS
     &   , I_FIT_TYPE
!             TYPE OF FIT TO BE USED
     &   , N_PARAMETER
!             NUMBER OF PARAMETERS
      REAL*8	!, INTENT(OUT)
     &     ICE_ASYMMETRY_RESIDUAL
!             FITTED SCATTERING
      REAL*8	!, INTENT(IN)
     &     ASYMMETRY(N_DATA)
!             ACTUAL ASYMMETRIES
     &   , VOL_FRACTION(N_DATA)
!             VOLUME FRACTION OF ABSORBER
     &   , RADIUS_EFFECTIVE(N_DATA)
!             EFFECTIVE RADIUS OF PARTICLES
     &   , PARM(N_PARAMETER)
!             FITTING PARAMETERS
!
!     LOCAL VARIABLES
      INTEGER
     &     I
!             LOOP VARIABLE
!
!
      ICE_ASYMMETRY_RESIDUAL=0.0D+00
      IF (I_FIT_TYPE.EQ.IP_SLINGO_SCHRECKER_ICE) THEN
         DO I=1, N_DATA
            ICE_ASYMMETRY_RESIDUAL=ICE_ASYMMETRY_RESIDUAL
     &         +(ASYMMETRY(I)-(PARM(1)
     &         +PARM(2)*RADIUS_EFFECTIVE(I)))**2
         ENDDO
      ELSE IF (I_FIT_TYPE.EQ.IP_CIRRUS_ADT) THEN
         DO I=1, N_DATA
            ICE_ASYMMETRY_RESIDUAL=ICE_ASYMMETRY_RESIDUAL
     &         +(ASYMMETRY(I)-PARM(1))**2
         ENDDO
      ENDIF
!
      ICE_ASYMMETRY_RESIDUAL=ICE_ASYMMETRY_RESIDUAL/DBLE(N_DATA)
!
!
      RETURN
      END
