MODULE SURWN_MOD
CONTAINS
SUBROUTINE SURWN (KSIL,PTSTAND,PXP,PRSUN)

USE PARKIND1  ,ONLY : JPIM     ,JPRB
USE YOMHOOK   ,ONLY : LHOOK,   DR_HOOK

USE YOS_DIM   , ONLY : NTILES,NMONTH
USE YOS_LW    , ONLY : XP,TSTAND,NSIL
USE YOS_SW    , ONLY : RALBICE_AR ,RALBICE_AN,RSUN,RWEIGHT, &
&                      ICEALB_SPECWEIGHT
USE YOS_RAD   , ONLY : NTSW,NSW,LE4ALB
USE ABORT_SURF_MOD, ONLY : ABORT_SURF

#ifdef DOC
!**** *SURWN*   - INITIALIZE COMMON YOESW

!     PURPOSE.
!     --------
!           INITIALIZE YOESW, THE COMMON THAT CONTAINS COEFFICIENTS
!           NEEDED TO RUN THE SHORTWAVE RADIATION SUBROUTINES

!**   INTERFACE.
!     ----------
!        *CALL* *SUSW

!        EXPLICIT ARGUMENTS :
!        --------------------

!      Input arguments
!    KSIL          :
!    PTSTAND       :
!    PXP           :
!    PRSUN         :

!     METHOD.
!     -------
!        SEE DOCUMENTATION

!     EXTERNALS.
!     ----------

!     REFERENCE.
!     ----------
!        ECMWF RESEARCH DEPARTMENT DOCUMENTATION OF THE IFS

!     AUTHOR.
!     -------
!        JEAN-JACQUES MORCRETTE *ECMWF*

!     MODIFICATIONS.
!     --------------
!        ORIGINAL : 88-12-15
!        97-04-16 JJ Morcrette  2 and 4 interval spectral resolution
!        00-10-24 JJ Morcrette  sea-ice albedo revisited
!        00-12-14 JJ Morcrette 
!               and Ph.Dubuisson B.Bonnel 6 spectral interval resolution
!        01-04-17 Ph.Dubuisson, B.Bonnel, JJ.Morcrette 6 sp.int.resolu'n
!        01-06-28 B.Bonnel, JJ.Morcrette, Ph.Dubuisson  Rayleigh (2/4/6)
!        01-11-05 Ph.Dubuisson, JJMorcrette (new 2 intervals for TL/AD)
!         03-10-01 J.F. Estrade *ECMWF*  move in surf vob
!        M.Hamrud      01-Oct-2003 CY28 Cleaning
!        JJMorcrette       20060530 MODIS Albedo
!        E.Dutra/G.Balsamo 20070501 add lake tile
!     ------------------------------------------------------------------
#endif

IMPLICIT NONE

! Declaration of arguments
INTEGER(KIND=JPIM), INTENT(IN) :: KSIL
REAL(KIND=JPRB)   , INTENT(IN) :: PTSTAND 
REAL(KIND=JPRB)   , INTENT(IN) :: PXP(6,6) 
REAL(KIND=JPRB)   , INTENT(IN) :: PRSUN(:)

INTEGER(KIND=JPIM) :: IM,JM,JW,JT,I,J

REAL(KIND=JPRB) :: ZSUN2(2)
REAL(KIND=JPRB) :: ZSUN4(4),ZSUN6(6)
REAL(KIND=JPRB), ALLOCATABLE :: ZTWEIGHT(:)
REAL(KIND=JPRB), ALLOCATABLE :: ZWEIGHT2(:,:), ZWEIGHN2(:,:), ZWEIGH2(:,:)
REAL(KIND=JPRB), ALLOCATABLE :: ZWEIGHT4(:,:), ZWEIGHN4(:,:), ZWEIGH4(:,:)
REAL(KIND=JPRB), ALLOCATABLE :: ZWEIGHT6(:,:), ZWEIGHN6(:,:), ZWEIGH6(:,:)
REAL(KIND=JPRB), ALLOCATABLE :: ZALBICE2(:,:)
REAL(KIND=JPRB), ALLOCATABLE :: ZALBICE4(:,:)
REAL(KIND=JPRB), ALLOCATABLE :: ZALBICE6(:,:)
REAL(KIND=JPRB) :: ZHOOK_HANDLE

! ALLOCATE 

IF (LHOOK) CALL DR_HOOK('SURWN_MOD:SURWN',0,ZHOOK_HANDLE)
IF(.NOT. ALLOCATED(RALBICE_AR)) ALLOCATE(RALBICE_AR(NMONTH,NTSW))
IF(.NOT. ALLOCATED(RALBICE_AN)) ALLOCATE(RALBICE_AN(NMONTH,NTSW))
IF(.NOT. ALLOCATED(RWEIGHT))    ALLOCATE(RWEIGHT(NTSW,NTILES))
ALLOCATE(ZTWEIGHT(NTILES))
ALLOCATE(ZWEIGH2(2,NTILES))
ALLOCATE(ZWEIGH4(4,NTILES))
ALLOCATE(ZWEIGH6(6,NTILES))
ALLOCATE(ZWEIGHT2(2,NTILES))
ALLOCATE(ZWEIGHT4(4,NTILES))
ALLOCATE(ZWEIGHT6(6,NTILES))
ALLOCATE(ZWEIGHN2(2,NTILES))
ALLOCATE(ZWEIGHN4(4,NTILES))
ALLOCATE(ZWEIGHN6(6,NTILES))
ALLOCATE(ZALBICE2(NMONTH,2))
ALLOCATE(ZALBICE4(NMONTH,4))
ALLOCATE(ZALBICE6(NMONTH,6))

IF(.NOT. ALLOCATED(ICEALB_SPECWEIGHT)) ALLOCATE(ICEALB_SPECWEIGHT(NTSW))

! LW constants

NSIL=KSIL
TSTAND=PTSTAND
DO I=1,6
  DO J=1,6
    XP(J,I)=PXP(J,I)
  ENDDO
ENDDO

!=====================================================================
!*  For sea ice, monthly values are based on Ebert and Curry, 1993, Table 2.

!*  For sea ice, monthly values are based on Ebert and Curry, 1993, Table 2.
!   We take dry snow albedo as the representative value for non-summer
!   months, and bare sea-ice as the representative value for summer
!   months. The values for Antarctic are shifted six-months.

!- 2-spectral intervals

!*  Sea ice surf. albedo for 0.25-0.69 micron (snow covered; Ebert and Curry, 1993)
ZALBICE2(1:NMONTH,1) = (/0.975_JPRB,0.975_JPRB,0.975_JPRB,0.975_JPRB,&
 & 0.975_JPRB,0.876_JPRB,0.778_JPRB,0.778_JPRB,&
 & 0.975_JPRB,0.975_JPRB,0.975_JPRB,0.975_JPRB/)  
!*  Sea ice surf. albedo for 0.69-4.00 microns (snow covered; Ebert and Curry, 1993)
!ZALBICE2(1:NMONTH,2) = (/0.664_JPRB,0.664_JPRB,0.664_JPRB,0.664_JPRB,&
!                    &0.664_JPRB,0.476_JPRB,0.288_JPRB,0.288_JPRB,&
!                    &0.664_JPRB,0.664_JPRB,0.664_JPRB,0.664_JPRB/)
ZALBICE2(1:NMONTH,2) = (/0.587_JPRB,0.587_JPRB,0.587_JPRB,0.587_JPRB,&
 & 0.587_JPRB,0.438_JPRB,0.288_JPRB,0.288_JPRB,&
 & 0.587_JPRB,0.587_JPRB,0.587_JPRB,0.587_JPRB/)  
                      
!- 4-spectral intervals

!*  Sea ice surf. albedo for 0.25-0.69 micron (snow covered; Ebert and Curry, 1993)
ZALBICE4(1:NMONTH,1) = (/0.975_JPRB,0.975_JPRB,0.975_JPRB,0.975_JPRB,&
 & 0.975_JPRB,0.876_JPRB,0.778_JPRB,0.778_JPRB,&
 & 0.975_JPRB,0.975_JPRB,0.975_JPRB,0.975_JPRB/)  
!*  Sea ice surf. albedo for 0.69-1.19 micron (snow covered; Ebert and Curry, 1993)
ZALBICE4(1:NMONTH,2) = (/0.832_JPRB,0.832_JPRB,0.832_JPRB,0.832_JPRB,&
 & 0.832_JPRB,0.638_JPRB,0.443_JPRB,0.443_JPRB,&
 & 0.832_JPRB,0.832_JPRB,0.832_JPRB,0.832_JPRB/)  
!*  Sea ice surf. albedo for 1.19-2.38 micron (snow covered; Ebert and Curry, 1993)
ZALBICE4(1:NMONTH,3) = (/0.250_JPRB,0.250_JPRB,0.250_JPRB,0.250_JPRB,&
 & 0.250_JPRB,0.153_JPRB,0.055_JPRB,0.055_JPRB,&
 & 0.250_JPRB,0.250_JPRB,0.250_JPRB,0.250_JPRB/)  
!*  Sea ice surf. albedo for 2.38-4.00 microns (snow covered; Ebert and Curry, 1993)
ZALBICE4(1:NMONTH,4) = (/0.025_JPRB,0.025_JPRB,0.025_JPRB,0.025_JPRB,&
 & 0.025_JPRB,0.030_JPRB,0.036_JPRB,0.036_JPRB,&
 & 0.025_JPRB,0.025_JPRB,0.025_JPRB,0.025_JPRB/)  
                      
!- 6-spectral intervals

!*  Sea ice surf. albedo for 0.185-0.25 micron (snow covered; Ebert and Curry, 1993)
ZALBICE6(1:NMONTH,1) = (/0.975_JPRB,0.975_JPRB,0.975_JPRB,0.975_JPRB,&
 & 0.975_JPRB,0.876_JPRB,0.778_JPRB,0.778_JPRB,&
 & 0.975_JPRB,0.975_JPRB,0.975_JPRB,0.975_JPRB/)  
!*  Sea ice surf. albedo for 0.25-0.44 micron (snow covered; Ebert and Curry, 1993)
ZALBICE6(1:NMONTH,2) = (/0.975_JPRB,0.975_JPRB,0.975_JPRB,0.975_JPRB,&
 & 0.975_JPRB,0.876_JPRB,0.778_JPRB,0.778_JPRB,&
 & 0.975_JPRB,0.975_JPRB,0.975_JPRB,0.975_JPRB/)  
!*  Sea ice surf. albedo for 0.44-0.69 micron (snow covered; Ebert and Curry, 1993)
ZALBICE6(1:NMONTH,3) = (/0.975_JPRB,0.975_JPRB,0.975_JPRB,0.975_JPRB,&
 & 0.975_JPRB,0.876_JPRB,0.778_JPRB,0.778_JPRB,&
 & 0.975_JPRB,0.975_JPRB,0.975_JPRB,0.975_JPRB/)  
!*  Sea ice surf. albedo for 0.69-1.19 micron (snow covered; Ebert and Curry, 1993)
ZALBICE6(1:NMONTH,4) = (/0.832_JPRB,0.832_JPRB,0.832_JPRB,0.832_JPRB,&
 & 0.832_JPRB,0.638_JPRB,0.443_JPRB,0.443_JPRB,&
 & 0.832_JPRB,0.832_JPRB,0.832_JPRB,0.832_JPRB/)  
!*  Sea ice surf. albedo for 1.19-2.38 micron (snow covered; Ebert and Curry, 1993)
ZALBICE6(1:NMONTH,5) = (/0.250_JPRB,0.250_JPRB,0.250_JPRB,0.250_JPRB,&
 & 0.250_JPRB,0.153_JPRB,0.055_JPRB,0.055_JPRB,&
 & 0.250_JPRB,0.250_JPRB,0.250_JPRB,0.250_JPRB/)  
!*  Sea ice surf. albedo for 2.38-4.00 microns (snow covered; Ebert and Curry, 1993)
ZALBICE6(1:NMONTH,6) = (/0.025_JPRB,0.025_JPRB,0.025_JPRB,0.025_JPRB,&
 & 0.025_JPRB,0.030_JPRB,0.036_JPRB,0.036_JPRB,&
 & 0.025_JPRB,0.025_JPRB,0.025_JPRB,0.025_JPRB/)  

!     ----------------------------------------------------------------
!=====================================================================
!     ----------------------------------------------------------------

!*    2.3   WEIGHTS FOR SPECTRAL SURFACE ALBEDO
!           Water
!           Sea-Ice (Ebert, Curry, 1993)
!           Wet skin
!           Low vegetation (snow free) (BR, 1982)
!           Snow on low vegetation (Warren, 1982)
!           High vegetation (snow free) (BR, 1982)
!           Snow under high vegetation  (Warren, 1982)
!           Bare soil (Briegleb & Ramanathan, 1982)

IF (NTILES >= 1) ZWEIGHT2(:,1)= (/ 1._JPRB, 1._JPRB /)
IF (NTILES >= 2) ZWEIGHT2(:,2)= (/ 1._JPRB, 1._JPRB /)
IF (NTILES >= 3) ZWEIGHT2(:,3)= (/ 1._JPRB, 1._JPRB /)
IF (NTILES >= 4) ZWEIGHT2(:,4)= (/ 1._JPRB, 3._JPRB /)
IF (NTILES >= 5) ZWEIGHT2(:,5)= (/ 0.920_JPRB, 0.537_JPRB /)
IF (NTILES >= 6) ZWEIGHT2(:,6)= (/ 1._JPRB, 3._JPRB /)
IF (NTILES >= 7) ZWEIGHT2(:,7)= (/ 0.860_JPRB, 0.432_JPRB /)
IF (NTILES >= 8) ZWEIGHT2(:,8)= (/ 1._JPRB, 2._JPRB /)
IF (NTILES >= 9) ZWEIGHT2(:,9)= (/ 1._JPRB, 1._JPRB /) 


IF (NTILES >= 1) ZWEIGHT4(:,1)= (/ 1._JPRB, 1._JPRB, 1._JPRB, 1._JPRB /)
IF (NTILES >= 2) ZWEIGHT4(:,2)= (/ 1._JPRB, 1._JPRB, 1._JPRB, 1._JPRB /)
IF (NTILES >= 3) ZWEIGHT4(:,3)= (/ 1._JPRB, 1._JPRB, 1._JPRB, 1._JPRB /)
IF (NTILES >= 4) ZWEIGHT4(:,4)= (/ 1._JPRB, 4._JPRB, 2._JPRB, 1._JPRB /)
IF (NTILES >= 5) ZWEIGHT4(:,5)= (/ 0.920_JPRB, 0.798_JPRB , 0.159_JPRB, 0.010_JPRB /)
IF (NTILES >= 6) ZWEIGHT4(:,6)= (/ 1._JPRB, 4._JPRB, 2._JPRB, 1._JPRB /)
IF (NTILES >= 7) ZWEIGHT4(:,7)= (/ 0.860_JPRB, 0.664_JPRB , 0.092_JPRB, 0.010_JPRB /)
IF (NTILES >= 8) ZWEIGHT4(:,8)= (/ 1._JPRB, 2._JPRB, 2._JPRB, 1._JPRB /)
IF (NTILES >= 9) ZWEIGHT4(:,9)= (/ 1._JPRB, 1._JPRB, 1._JPRB, 1._JPRB /) 

IF (NTILES >= 1) ZWEIGHT6(:,1)= (/ 1._JPRB, 1._JPRB, 1._JPRB, 1._JPRB, 1._JPRB, 1._JPRB /)
IF (NTILES >= 2) ZWEIGHT6(:,2)= (/ 1._JPRB, 1._JPRB, 1._JPRB, 1._JPRB, 1._JPRB, 1._JPRB /)
IF (NTILES >= 3) ZWEIGHT6(:,3)= (/ 1._JPRB, 1._JPRB, 1._JPRB, 1._JPRB, 1._JPRB, 1._JPRB /)
IF (NTILES >= 4) ZWEIGHT6(:,4)= (/ 1._JPRB, 1._JPRB, 1._JPRB, 4._JPRB, 2._JPRB, 1._JPRB /)
IF (NTILES >= 5) ZWEIGHT6(:,5)= (/ 0.920_JPRB, 0.920_JPRB, 0.920_JPRB, 0.798_JPRB , 0.159_JPRB,0.010_JPRB /)
IF (NTILES >= 6) ZWEIGHT6(:,6)= (/ 1._JPRB, 1._JPRB, 1._JPRB, 4._JPRB, 2._JPRB, 1._JPRB /)
IF (NTILES >= 7) ZWEIGHT6(:,7)= (/ 0.860_JPRB, 0.860_JPRB, 0.860_JPRB, 0.664_JPRB , 0.092_JPRB,0.010_JPRB /)
IF (NTILES >= 8) ZWEIGHT6(:,8)= (/ 1._JPRB, 1._JPRB, 1._JPRB, 2._JPRB, 2._JPRB, 1._JPRB /)
IF (NTILES >= 9) ZWEIGHT6(:,9)= (/ 1._JPRB, 1._JPRB, 1._JPRB, 1._JPRB, 1._JPRB, 1._JPRB /) 

! MODIS Albedo

IF (NTILES >= 1) ZWEIGHN2(:,1)= (/ 1._JPRB, 1._JPRB /)
IF (NTILES >= 2) ZWEIGHN2(:,2)= (/ 1._JPRB, 1._JPRB /)
IF (NTILES >= 3) ZWEIGHN2(:,3)= (/ 1._JPRB, 1._JPRB /)
IF (NTILES >= 4) ZWEIGHN2(:,4)= (/ 1._JPRB, 1._JPRB /)
IF (NTILES >= 5) ZWEIGHN2(:,5)= (/ 0.920_JPRB, 0.537_JPRB /)
IF (NTILES >= 6) ZWEIGHN2(:,6)= (/ 1._JPRB, 1._JPRB /)
IF (NTILES >= 7) ZWEIGHN2(:,7)= (/ 0.860_JPRB, 0.432_JPRB /)
IF (NTILES >= 8) ZWEIGHN2(:,8)= (/ 1._JPRB, 1._JPRB /)
IF (NTILES >= 9) ZWEIGHN2(:,9)= (/ 1._JPRB, 1._JPRB /) 

IF (NTILES >= 1) ZWEIGHN4(:,1)= (/ 1._JPRB, 1._JPRB, 1._JPRB, 1._JPRB /)
IF (NTILES >= 2) ZWEIGHN4(:,2)= (/ 1._JPRB, 1._JPRB, 1._JPRB, 1._JPRB /)
IF (NTILES >= 3) ZWEIGHN4(:,3)= (/ 1._JPRB, 1._JPRB, 1._JPRB, 1._JPRB /)
IF (NTILES >= 4) ZWEIGHN4(:,4)= (/ 1._JPRB, 1._JPRB, 1._JPRB, 1._JPRB /)
IF (NTILES >= 5) ZWEIGHN4(:,5)= (/ 0.920_JPRB, 0.798_JPRB , 0.159_JPRB, 0.010_JPRB /)
IF (NTILES >= 6) ZWEIGHN4(:,6)= (/ 1._JPRB, 1._JPRB, 1._JPRB, 1._JPRB /)
IF (NTILES >= 7) ZWEIGHN4(:,7)= (/ 0.860_JPRB, 0.664_JPRB , 0.092_JPRB, 0.010_JPRB /)
IF (NTILES >= 8) ZWEIGHN4(:,8)= (/ 1._JPRB, 1._JPRB, 1._JPRB, 1._JPRB /)
IF (NTILES >= 9) ZWEIGHN4(:,9)= (/ 1._JPRB, 1._JPRB, 1._JPRB, 1._JPRB /)  

IF (NTILES >= 1) ZWEIGHN6(:,1)= (/ 1._JPRB, 1._JPRB, 1._JPRB, 1._JPRB, 1._JPRB, 1._JPRB /)
IF (NTILES >= 2) ZWEIGHN6(:,2)= (/ 1._JPRB, 1._JPRB, 1._JPRB, 1._JPRB, 1._JPRB, 1._JPRB /)
IF (NTILES >= 3) ZWEIGHN6(:,3)= (/ 1._JPRB, 1._JPRB, 1._JPRB, 1._JPRB, 1._JPRB, 1._JPRB /)
IF (NTILES >= 4) ZWEIGHN6(:,4)= (/ 1._JPRB, 1._JPRB, 1._JPRB, 1._JPRB, 1._JPRB, 1._JPRB /)
IF (NTILES >= 5) ZWEIGHN6(:,5)= (/ 0.920_JPRB, 0.920_JPRB, 0.920_JPRB, 0.798_JPRB , 0.159_JPRB,0.010_JPRB /)
IF (NTILES >= 6) ZWEIGHN6(:,6)= (/ 1._JPRB, 1._JPRB, 1._JPRB, 1._JPRB, 1._JPRB, 1._JPRB /)
IF (NTILES >= 7) ZWEIGHN6(:,7)= (/ 0.860_JPRB, 0.860_JPRB, 0.860_JPRB, 0.664_JPRB , 0.092_JPRB,0.010_JPRB /)
IF (NTILES >= 8) ZWEIGHN6(:,8)= (/ 1._JPRB, 1._JPRB, 1._JPRB, 1._JPRB, 1._JPRB, 1._JPRB /)
IF (NTILES >= 9) ZWEIGHN6(:,9)= (/ 1._JPRB, 1._JPRB, 1._JPRB, 1._JPRB, 1._JPRB, 1._JPRB /) 

!     ----------------------------------------------------------------

IF(.NOT.ALLOCATED(RSUN)) ALLOCATE(RSUN(NTSW))

DO JT=1,NTILES
  ZTWEIGHT(JT)=0.0_JPRB
ENDDO

DO JW=1,NSW
  RSUN(JW)=PRSUN(JW)
ENDDO

IF (NSW == 2) THEN

  DO JW=1,NSW
    DO JT=1,NTILES
      IF (LE4ALB) THEN
        ZWEIGH2(JW,JT)=ZWEIGHN2(JW,JT)
      ELSE
        ZWEIGH2(JW,JT)=ZWEIGHT2(JW,JT)
      ENDIF
      ZTWEIGHT(JT)=ZTWEIGHT(JT)+ZWEIGH2(JW,JT)*RSUN(JW)
    ENDDO
  ENDDO

  DO JW=1,NSW
    DO JT=1,NTILES
      RWEIGHT(JW,JT)=ZWEIGH2(JW,JT)/ZTWEIGHT(JT)
    ENDDO

    DO JM=1,NMONTH
      IM=MOD(JM+5,NMONTH)+1
      RALBICE_AR(IM,JW)=ZALBICE2(IM,JW)
      RALBICE_AN(JM,JW)=RALBICE_AR(IM,JW)
    ENDDO
  ENDDO

ELSEIF (NSW == 4) THEN

  DO JW=1,NSW
    DO JT=1,NTILES
      IF (LE4ALB) THEN
        ZWEIGH4(JW,JT)=ZWEIGHN4(JW,JT)
      ELSE
        ZWEIGH4(JW,JT)=ZWEIGHT4(JW,JT)
      ENDIF
      ZTWEIGHT(JT)=ZTWEIGHT(JT)+ZWEIGH4(JW,JT)*RSUN(JW)
    ENDDO
  ENDDO

  DO JW=1,NSW
    DO JT=1,NTILES
      RWEIGHT(JW,JT)=ZWEIGH4(JW,JT)/ZTWEIGHT(JT)
    ENDDO

    DO JM=1,NMONTH
      IM=MOD(JM+5,NMONTH)+1
      RALBICE_AR(IM,JW)=ZALBICE4(IM,JW)
      RALBICE_AN(JM,JW)=RALBICE_AR(IM,JW)
    ENDDO
  ENDDO

ELSEIF (NSW == 6) THEN

  DO JW=1,NSW
    DO JT=1,NTILES
      IF (LE4ALB) THEN
        ZWEIGH6(JW,JT)=ZWEIGHN6(JW,JT)
      ELSE
        ZWEIGH6(JW,JT)=ZWEIGHT6(JW,JT)
      ENDIF
      ZTWEIGHT(JT)=ZTWEIGHT(JT)+ZWEIGH6(JW,JT)*RSUN(JW)
    ENDDO
  ENDDO

  DO JW=1,NSW
    DO JT=1,NTILES
      RWEIGHT(JW,JT)=ZWEIGH6(JW,JT)/ZTWEIGHT(JT)
    ENDDO

    DO JM=1,NMONTH
      IM=MOD(JM+5,NMONTH)+1
      RALBICE_AR(IM,JW)=ZALBICE6(IM,JW)
      RALBICE_AN(JM,JW)=RALBICE_AR(IM,JW)
    ENDDO
  ENDDO

ELSE
  CALL ABORT_SURF('SURWN: WRONG NUMBER OF SW INTERVALS')
ENDIF

! Spectral weights for the mapping of the NEMO broadband albedo
! to IFS albedo in spectral bands. Note that this is currently
! only implemented for NSW=6.
IF ( NSW == 6 ) THEN
  ICEALB_SPECWEIGHT=(/1.12114_JPRB,1.12463_JPRB,1.12561_JPRB,1.08982_JPRB,0.67650_JPRB,0.14922_JPRB/)
ELSE
  CALL ABORT_SURF('SURWN: WRONG NUMBER OF SW INTERVALS FOR ICEALB_SPECWEIGHT')
ENDIF

DEALLOCATE(ZTWEIGHT)
DEALLOCATE(ZWEIGH2)
DEALLOCATE(ZWEIGH4)
DEALLOCATE(ZWEIGH6)
DEALLOCATE(ZWEIGHT2)
DEALLOCATE(ZWEIGHT4)
DEALLOCATE(ZWEIGHT6)
DEALLOCATE(ZWEIGHN2)
DEALLOCATE(ZWEIGHN4)
DEALLOCATE(ZWEIGHN6)
DEALLOCATE(ZALBICE2)
DEALLOCATE(ZALBICE4)
DEALLOCATE(ZALBICE6)
IF (LHOOK) CALL DR_HOOK('SURWN_MOD:SURWN',1,ZHOOK_HANDLE)

END SUBROUTINE SURWN
END MODULE SURWN_MOD
