SUBROUTINE LWPRCLAIR &
 & (K_IR1,K_IR2,KIDIA,KFDIA,KLON,K_NCOU,K_NBNEURMAX,K_NBR, &
 & K_NBNEUR,P_WNELN,PYNXN1T, &
 & PSORTIENO1,PSORTIENO2 )  

!**** *LWPRCLAIR*   - COMPUTATION FOR LW RADIATION
!                         (CLEAR SKY)

!     PURPOSE.
!     --------  

!**   INTERFACE.
!     ----------

!        *LWPRCLAIR* IS CALLED FROM LWINTERF

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

!     INPUT PARAMETERS (REAL):

! PYNXN1T : (KLON,0:NBNEURMAX,0:NCOU)

!     OUTPUT PARAMETERS (REAL):

! PSORTIENO1 : (KLON,NBNEURMAX)
! PSORTIENO2 : (KLON,NBNEURMAX)

!        IMPLICIT ARGUMENTS :   NONE
!        --------------------

!     METHOD.
!     -------

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

!     REFERENCE.
!     ----------

!     AUTHORS.
!     --------
!        F. CHEVALLIER          *ECMWF*

!     MODIFICATIONS.
!     --------------
!        ORIGINAL : 99-05
!        M.Hamrud      01-Oct-2003 CY28 Cleaning
!-----------------------------------------------------------------------
       
USE PARKIND1  ,ONLY : JPIM     ,JPRB
USE YOMHOOK   ,ONLY : LHOOK,   DR_HOOK

IMPLICIT NONE

INTEGER(KIND=JPIM),INTENT(IN)    :: KLON 
INTEGER(KIND=JPIM),INTENT(IN)    :: K_NCOU 
INTEGER(KIND=JPIM),INTENT(IN)    :: K_NBNEURMAX 
INTEGER(KIND=JPIM),INTENT(IN)    :: K_NBR 
INTEGER(KIND=JPIM),INTENT(IN)    :: K_IR1 
INTEGER(KIND=JPIM),INTENT(IN)    :: K_IR2 
INTEGER(KIND=JPIM),INTENT(IN)    :: KIDIA 
INTEGER(KIND=JPIM),INTENT(IN)    :: KFDIA 
INTEGER(KIND=JPIM),INTENT(IN)    :: K_NBNEUR(0:K_NCOU,K_NBR) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: P_WNELN(0:K_NBNEURMAX,K_NBNEURMAX,K_NCOU,K_NBR) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PYNXN1T(KLON,0:K_NBNEURMAX,0:K_NCOU) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PSORTIENO1(KLON,K_NBNEURMAX) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PSORTIENO2(KLON,K_NBNEURMAX) 
!-------------------------------------------------------------------

!*       0.1   ARGUMENTS
!              ---------

REAL(KIND=JPRB) :: ZYNXN1(KLON,0:K_NBNEURMAX)

INTEGER(KIND=JPIM) :: ILN,IATM,ILEN
REAL(KIND=JPRB) :: ZHOOK_HANDLE

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

!*         1.     INITIALIZATION.
!                 ---------------

IF (LHOOK) CALL DR_HOOK('LWPRCLAIR',0,ZHOOK_HANDLE)

ILEN=KFDIA-KIDIA+1

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

!*         2.

!-- ir1 flux montants
!-- ir2 flux descendants

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

!*         3.

ZYNXN1=1.0_JPRB

CALL DGEMM('N','N',ILEN,K_NBNEUR(1,K_IR1),K_NBNEUR(0,K_IR1)+1, &
     & 1.0_JPRB,PYNXN1T(KIDIA,0,0),KLON, &
     &      P_WNELN(0,1,1,K_IR1),K_NBNEURMAX+1, & 
     & 0.0_JPRB,ZYNXN1(KIDIA,1),KLON)

DO ILN=1,K_NBNEUR(1,K_IR1)
  DO IATM = KIDIA,KFDIA
    ZYNXN1(IATM,ILN)=TANH(ZYNXN1(IATM,ILN))
  ENDDO
ENDDO

CALL DGEMM('N','N',ILEN,K_NBNEUR(2,K_IR1),K_NBNEUR(1,K_IR1)+1, &
     & 1.0_JPRB,ZYNXN1(KIDIA,0),KLON, &
     &      P_WNELN(0,1,2,K_IR1),K_NBNEURMAX+1, & 
     & 0.0_JPRB,PSORTIENO1(KIDIA,1),KLON)

ZYNXN1=1.0_JPRB

CALL DGEMM('N','N',ILEN,K_NBNEUR(1,K_IR1),K_NBNEUR(0,K_IR1)+1, &
     & 1.0_JPRB,PYNXN1T(KIDIA,0,0),KLON, &
     &      P_WNELN(0,1,1,K_IR2),K_NBNEURMAX+1, & 
     & 0.0_JPRB,ZYNXN1(KIDIA,1),KLON)

DO ILN=1,K_NBNEUR(1,K_IR1)
  DO IATM = KIDIA,KFDIA
    ZYNXN1(IATM,ILN)=TANH(ZYNXN1(IATM,ILN))
  ENDDO
ENDDO

CALL DGEMM('N','N',ILEN,K_NBNEUR(2,K_IR1),K_NBNEUR(1,K_IR1)+1, &
     & 1.0_JPRB,ZYNXN1(KIDIA,0),KLON, &
     &      P_WNELN(0,1,2,K_IR2),K_NBNEURMAX+1, & 
     & 0.0_JPRB,PSORTIENO2(KIDIA,1),KLON)

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

IF (LHOOK) CALL DR_HOOK('LWPRCLAIR',1,ZHOOK_HANDLE)
END SUBROUTINE LWPRCLAIR
