!OPTIONS XOPT(NOEVAL)
SUBROUTINE LWTT15 (KIDIA,KFDIA,KLON, PGA,PGB,PUU, PTT)

!**** *LWTT15* - LONGWAVE TRANSMISSION FUNCTIONS
!****            FROZEN VERSION (CYCLE 15) OF LWTT

!     PURPOSE.
!     --------
!           THIS ROUTINE COMPUTES THE TRANSMISSION FUNCTIONS FOR ALL THE
!     ABSORBERS (H2O, UNIFORMLY MIXED GASES, AND O3) IN ALL SIX SPECTRAL
!     INTERVALS.

!**   INTERFACE.
!     ----------
!          *LWTT15* IS CALLED FROM *LWVN15*, *LWVD15*, *LWVB15*

!        EXPLICIT ARGUMENTS :
!        --------------------
!     ==== INPUTS ===
! KND    :                     ; WEIGHTING INDEX
! PUU    : (KLON,NUA15)         ; ABSORBER AMOUNTS
!     ==== OUTPUTS ===
! PTT    : (KLON,NTRA15)        ; TRANSMISSION FUNCTIONS

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

!     METHOD.
!     -------

!          1. TRANSMISSION FUNCTION BY H2O AND UNIFORMLY MIXED GASES ARE
!     COMPUTED USING PADE APPROXIMANTS AND HORNER'S ALGORITHM.
!          2. TRANSMISSION BY O3 IS EVALUATED WITH MALKMUS'S BAND MODEL.
!          3. TRANSMISSION BY H2O CONTINUUM AND AEROSOLS FOLLOW AN
!     A SIMPLE EXPONENTIAL DECREASE WITH ABSORBER AMOUNT.

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

!          NONE

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

!        SEE RADIATION'S PART OF THE MODEL'S DOCUMENTATION AND
!        ECMWF RESEARCH DEPARTMENT DOCUMENTATION OF THE IFS

!     AUTHOR.
!     -------
!        96-11: Ph. Dandin. Meteo-France
!        ORIGINAL : 88-12-15 BY JEAN-JACQUES MORCRETTE  *ECMWF*

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

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

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

USE YOMLW15  , ONLY : NTRA15   ,NUA15    ,O1H15    ,O2H15    ,RPIALF015

IMPLICIT NONE

INTEGER(KIND=JPIM),INTENT(IN)    :: KLON 
INTEGER(KIND=JPIM),INTENT(IN)    :: KIDIA 
INTEGER(KIND=JPIM),INTENT(IN)    :: KFDIA 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PGA(KLON,8,2) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PGB(KLON,8,2) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PUU(KLON,NUA15) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PTT(KLON,NTRA15) 
!     ------------------------------------------------------------------

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

INTEGER(KIND=JPIM) :: JA, JL

REAL(KIND=JPRB) :: ZA11, ZA12, ZAERCN, ZEU, ZEU10, ZEU11, ZEU12,&
 & ZEU13, ZODH41, ZODH42, ZODN21, ZODN22, ZPU, &
 & ZPU10, ZPU11, ZPU12, ZPU13, ZSQ1, ZSQ2, ZSQH41, &
 & ZSQH42, ZSQN21, ZSQN22, ZTO1, ZTO2, ZTTF11, &
 & ZTTF12, ZUU11, ZUU12, ZUXY, ZVXY, ZX, ZXCH4, &
 & ZXD, ZXN, ZXN2O, ZY, ZYCH4, ZYN2O, ZZ  
REAL(KIND=JPRB) :: ZHOOK_HANDLE

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

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

!     REAL ZXN(KLON,8),ZXD(KLON,8),ZZ(KLON,8)
!     ------------------------------------------------------------------
!DIR$ VFUNCTION SQRTHF

!*         1.     HORNER'S ALGORITHM FOR H2O AND CO2 TRANSMISSION
!                 -----------------------------------------------

IF (LHOOK) CALL DR_HOOK('LWTT15',0,ZHOOK_HANDLE)
DO JA = 1 , 8
  DO JL = KIDIA,KFDIA
    ZZ      =SQRT(PUU(JL,JA))
!     ZXD(JL,1)=PGB( JL, 1,1) + ZZ(JL, 1)*(PGB( JL, 1,2) + ZZ(JL, 1))
!     ZXN(JL,1)=PGA( JL, 1,1) + ZZ(JL, 1)*(PGA( JL, 1,2) )
!     PTT(JL,1)=ZXN(JL,1)/ZXD(JL,1)
    ZXD      =PGB( JL,JA,1) + ZZ       *(PGB( JL,JA,2) + ZZ       )
    ZXN      =PGA( JL,JA,1) + ZZ       *(PGA( JL,JA,2) )
    PTT(JL,JA)=ZXN      /ZXD
  ENDDO
ENDDO

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

!*         2.     CONTINUUM, OZONE AND AEROSOL TRANSMISSION FUNCTIONS
!                 ---------------------------------------------------

DO JL = KIDIA,KFDIA
  PTT(JL, 9) = PTT(JL, 8)

!-  CONTINUUM ABSORPTION: E- AND P-TYPE

  ZPU   = 0.002_JPRB * PUU(JL,10)
  ZPU10 = 112._JPRB * ZPU
  ZPU11 = 6.25_JPRB * ZPU
  ZPU12 = 5.00_JPRB * ZPU
  ZPU13 = 80.0_JPRB * ZPU
  ZEU   =  PUU(JL,11)
  ZEU10 =  12._JPRB * ZEU
  ZEU11 = 6.25_JPRB * ZEU
  ZEU12 = 5.00_JPRB * ZEU
  ZEU13 = 80.0_JPRB * ZEU

!-  OZONE ABSORPTION

  ZX = PUU(JL,12)
  ZY = PUU(JL,13)
  ZUXY = 4._JPRB * ZX * ZX / (RPIALF015 * ZY)
  ZSQ1 = SQRT(1.0_JPRB + O1H15 * ZUXY ) - 1.0_JPRB
  ZSQ2 = SQRT(1.0_JPRB + O2H15 * ZUXY ) - 1.0_JPRB
  ZVXY = RPIALF015 * ZY / (2.0_JPRB * ZX)
  ZAERCN = PUU(JL,17) + ZEU12 + ZPU12
  ZTO1 = EXP( - ZVXY * ZSQ1 - ZAERCN )
  ZTO2 = EXP( - ZVXY * ZSQ2 - ZAERCN )

!-- TRACE GASES (CH4, N2O, CFC-11, CFC-12)

!* CH4 IN INTERVAL 800-970 + 1110-1250 CM-1

!     NEXOTIC=1
!     IF (NEXOTIC.EQ.1) THEN
  ZXCH4 = PUU(JL,19)
  ZYCH4 = PUU(JL,20)
  ZUXY = 4._JPRB * ZXCH4*ZXCH4/(0.103_JPRB*ZYCH4)
  ZSQH41 = SQRT(1.0_JPRB + 33.7_JPRB * ZUXY) - 1.0_JPRB
  ZVXY = 0.103_JPRB * ZYCH4 / (2.0_JPRB * ZXCH4)
  ZODH41 = ZVXY * ZSQH41

!* N2O IN INTERVAL 800-970 + 1110-1250 CM-1

  ZXN2O = PUU(JL,21)
  ZYN2O = PUU(JL,22)
  ZUXY = 4._JPRB * ZXN2O*ZXN2O/(0.416_JPRB*ZYN2O)
  ZSQN21 = SQRT(1.0_JPRB + 21.3_JPRB * ZUXY) - 1.0_JPRB
  ZVXY = 0.416_JPRB * ZYN2O / (2.0_JPRB * ZXN2O)
  ZODN21 = ZVXY * ZSQN21

!* CH4 IN INTERVAL 1250-1450 + 1880-2820 CM-1

  ZUXY = 4._JPRB * ZXCH4*ZXCH4/(0.113_JPRB*ZYCH4)
  ZSQH42 = SQRT(1.0_JPRB + 400._JPRB * ZUXY) - 1.0_JPRB
  ZVXY = 0.113_JPRB * ZYCH4 / (2.0_JPRB * ZXCH4)
  ZODH42 = ZVXY * ZSQH42

!* N2O IN INTERVAL 1250-1450 + 1880-2820 CM-1

  ZUXY = 4._JPRB * ZXN2O*ZXN2O/(0.197_JPRB*ZYN2O)
  ZSQN22 = SQRT(1.0_JPRB + 2000._JPRB * ZUXY) - 1.0_JPRB
  ZVXY = 0.197_JPRB * ZYN2O / (2.0_JPRB * ZXN2O)
  ZODN22 = ZVXY * ZSQN22

!* CFC-11 IN INTERVAL 800-970 + 1110-1250 CM-1

  ZA11 = 2.0_JPRB * PUU(JL,23) * 4.404E+05_JPRB
  ZTTF11 = 1.0_JPRB - ZA11 * 0.003225_JPRB

!* CFC-12 IN INTERVAL 800-970 + 1110-1250 CM-1

  ZA12 = 2.0_JPRB * PUU(JL,24) * 6.7435E+05_JPRB
  ZTTF12 = 1.0_JPRB - ZA12 * 0.003225_JPRB

  ZUU11 = - PUU(JL,15) - ZEU10 - ZPU10
  ZUU12 = - PUU(JL,16) - ZEU11 - ZPU11 - ZODH41 - ZODN21
  PTT(JL,10) = EXP( - PUU(JL,14) )
  PTT(JL,11) = EXP( ZUU11 )
  PTT(JL,12) = EXP( ZUU12 ) * ZTTF11 * ZTTF12
  PTT(JL,13) = 0.7554_JPRB * ZTO1 + 0.2446_JPRB * ZTO2
  PTT(JL,14) = PTT(JL,10) * EXP( - ZEU13 - ZPU13 )
  PTT(JL,15) = EXP ( - PUU(JL,14) - ZODH42 - ZODN22 )
ENDDO

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