!+ Function to calculate residual in coalbedo 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_SS_ALBEDO_RESIDUAL(N_DATA, I_FIT_TYPE, N_PARAMETER
     &   , VOL_FRACTION, RADIUS_EFFECTIVE
     &   , SS_ALBEDO, 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_SS_ALBEDO_RESIDUAL
!             RESIDUAL IN ALBEDO
      REAL*8	!, INTENT(IN)
     &     SS_ALBEDO(N_DATA)
!             ACTUAL S. S. ALBEDOS
     &   , VOL_FRACTION(N_DATA)
!             VOLUME FRACTION OF ABSORBER
     &   , RADIUS_EFFECTIVE(N_DATA)
!             EFFECTIVE RADIUS OF PARTICLES
     &   , PARM(N_PARAMETER)
!             FITTING PARAMETERS
!
!     LOCAL VARIBALES
      INTEGER
     &     I
!             LOOP VARIABLE
      REAL*8
     &     OMEGA_FIT
!             FITTED ALBEDO
!
!
      ICE_SS_ALBEDO_RESIDUAL=0.0D+00
      IF (I_FIT_TYPE.EQ.IP_SLINGO_SCHRECKER_ICE) THEN
         DO I=1, N_DATA
            ICE_SS_ALBEDO_RESIDUAL=ICE_SS_ALBEDO_RESIDUAL
     &         +(SS_ALBEDO(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
            OMEGA_FIT=0.5D+00+(PARM(1)*RADIUS_EFFECTIVE(I)+3.0D+00)
     &         /(6.0D+00*(PARM(1)*RADIUS_EFFECTIVE(I)+1.0D+00)**3)
            ICE_SS_ALBEDO_RESIDUAL=ICE_SS_ALBEDO_RESIDUAL
     &         +(SS_ALBEDO(I)-OMEGA_FIT)**2
         ENDDO
      ENDIF
!
      ICE_SS_ALBEDO_RESIDUAL=ICE_SS_ALBEDO_RESIDUAL/DBLE(N_DATA)
!
!
      RETURN
      END
