!*******************************************************************************
SUBROUTINE RRTM_TAUMOL10 (KIDIA,KFDIA,KLEV,P_TAU,&
 & P_TAUAERL,P_FAC00,P_FAC01,P_FAC10,P_FAC11,K_JP,K_JT,K_JT1,&
 & P_COLH2O,K_LAYTROP,PFRAC)  

!     BAND 10:  1390-1480 cm-1 (low - H2O; high - H2O)

! Modifications
!        M.Hamrud      01-Oct-2003 CY28 Cleaning

!     D Salmond   2000-05-15 speed-up
!     JJMorcrette 2000-05-17 speed-up
!        NEC           25-Oct-2007 Optimisations

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

USE PARRRTM  , ONLY : JPLAY  ,JPBAND ,JPGPT  ,NG10   ,NGS9
USE YOERRTWN , ONLY : NSPA   ,NSPB
USE YOERRTA10, ONLY : ABSA   ,ABSB   ,FRACREFA, FRACREFB

!  Input
!#include "yoeratm.h"

!      REAL TAUAER(JPLAY)

IMPLICIT NONE

!  Output
INTEGER(KIND=JPIM),INTENT(IN)    :: KIDIA
INTEGER(KIND=JPIM),INTENT(IN)    :: KFDIA
INTEGER(KIND=JPIM),INTENT(IN)    :: KLEV 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: P_TAU(KIDIA:KFDIA,JPGPT,JPLAY) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: P_TAUAERL(KIDIA:KFDIA,JPLAY,JPBAND) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: P_FAC00(KIDIA:KFDIA,JPLAY) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: P_FAC01(KIDIA:KFDIA,JPLAY) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: P_FAC10(KIDIA:KFDIA,JPLAY) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: P_FAC11(KIDIA:KFDIA,JPLAY) 
INTEGER(KIND=JPIM),INTENT(IN)    :: K_JP(KIDIA:KFDIA,JPLAY) 
INTEGER(KIND=JPIM),INTENT(IN)    :: K_JT(KIDIA:KFDIA,JPLAY) 
INTEGER(KIND=JPIM),INTENT(IN)    :: K_JT1(KIDIA:KFDIA,JPLAY) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: P_COLH2O(KIDIA:KFDIA,JPLAY) 
INTEGER(KIND=JPIM),INTENT(IN)    :: K_LAYTROP(KIDIA:KFDIA) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PFRAC(KIDIA:KFDIA,JPGPT,JPLAY) 
!- from AER
!- from INTFAC      
!- from INTIND
!- from PROFDATA             
!- from SP             
INTEGER(KIND=JPIM) :: IND0(JPLAY),IND1(JPLAY)

INTEGER(KIND=JPIM) :: JG, JLAY
INTEGER(KIND=JPIM) :: JLON
REAL(KIND=JPRB) :: ZHOOK_HANDLE

!      EQUIVALENCE (TAUAERL(1,10),TAUAER)

!     Compute the optical depth by interpolating in ln(pressure) and 
!     temperature.  

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

DO JLAY = 1, KLEV
  DO JLON = KIDIA, KFDIA
    IF (JLAY <= K_LAYTROP(JLON)) THEN
      IND0(JLAY) = ((K_JP(JLON,JLAY)-1)*5+(K_JT(JLON,JLAY)-1))*NSPA(10) + 1
      IND1(JLAY) = (K_JP(JLON,JLAY)*5+(K_JT1(JLON,JLAY)-1))*NSPA(10) + 1

!-- DS_000515
!CDIR UNROLL=NG10
      DO JG = 1, NG10
!-- DS_000515
        P_TAU(JLON,NGS9+JG,JLAY) = P_COLH2O(JLON,JLAY) *&
         & (P_FAC00(JLON,JLAY) * ABSA(IND0(JLAY)  ,JG) +&
         & P_FAC10(JLON,JLAY) * ABSA(IND0(JLAY)+1,JG) +&
         & P_FAC01(JLON,JLAY) * ABSA(IND1(JLAY)  ,JG) +&
         & P_FAC11(JLON,JLAY) * ABSA(IND1(JLAY)+1,JG)) &
         & + P_TAUAERL(JLON,JLAY,10)  
        PFRAC(JLON,NGS9+JG,JLAY) = FRACREFA(JG)
      ENDDO
    ENDIF

    IF (JLAY > K_LAYTROP(JLON)) THEN
      IND0(JLAY) = ((K_JP(JLON,JLAY)-13)*5+(K_JT(JLON,JLAY)-1))*NSPB(10) + 1
      IND1(JLAY) = ((K_JP(JLON,JLAY)-12)*5+(K_JT1(JLON,JLAY)-1))*NSPB(10) + 1

!-- JJM_000517
!CDIR UNROLL=NG10
      DO JG = 1, NG10
!-- JJM_000517
        P_TAU(JLON,NGS9+JG,JLAY) = P_COLH2O(JLON,JLAY) *&
         & (P_FAC00(JLON,JLAY) * ABSB(IND0(JLAY)  ,JG) +&
         & P_FAC10(JLON,JLAY) * ABSB(IND0(JLAY)+1,JG) +&
         & P_FAC01(JLON,JLAY) * ABSB(IND1(JLAY)  ,JG) +&
         & P_FAC11(JLON,JLAY) * ABSB(IND1(JLAY)+1,JG)) &
         & + P_TAUAERL(JLON,JLAY,10)  
        PFRAC(JLON,NGS9+JG,JLAY) = FRACREFB(JG)
      ENDDO
    ENDIF
  ENDDO
ENDDO

IF (LHOOK) CALL DR_HOOK('RRTM_TAUMOL10',1,ZHOOK_HANDLE)

END SUBROUTINE RRTM_TAUMOL10
