SUBROUTINE LWTL &
 & ( KIDIA, KFDIA , KLON   , KLEV  , KMODE, KTOPC,&
 & PCCO2  , PVIEW , &
 & PCLFR5, PCLDLD5, PCLDLU5,&
 & PDP5  , PDT05  , PEMIS5 , PEMIW5,&
 & PPMB5 , PQOF5  , PTL5   ,&
 & PAER5 , PTAVE5 , PWV5  ,&
 & PEMIT5, PFLUX5 , PFLUC5 ,&
 & PCLFR , PCLDLD , PCLDLU ,&
 & PDP   , PDT0   , PEMIS  , PEMIW ,&
 & PPMB  , PQOF   , PTL    ,&
 & PAER  , PTAVE  , PWV   ,&
 & PEMIT , PFLUX  , PFLUC  &
 & )

!**** *LWTL*   - ORGANIZES THE LONGWAVE CALCULATIONS
!                      (tangent linear)

!     PURPOSE.
!     --------
!           COMPUTES LONGWAVE FLUXES 

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

!        *LWTL* IS CALLED FROM *RADLSWTL*

!        EXPLICIT ARGUMENTS :
!        --------------------
!     ==== INPUTS ===
!  Trajectory  Perturbation  Description                         Dimension
!  PCCO2       ---           CONCENTRATION IN CO2 (PA/PA)
!  PVIEW       ---           COSECANT OF VIEWING ANGLE           (KLON)
!  PAER5       PAER          OPTICAL THICKNESS OF THE AEROSOLS   (KLON,6,KLEV)
!  PCLFR5      PCLFR         CLOUD FRACTIONAL COVER              (KLON,KLEV)
!  PCLDLD5     PCLDLD        DOWNWARD EFFECTIVE CLOUD FRACTION   (KLON,KLEV)
!  PCLDLU5     PCLDLU        UPWARD EFFECTIVE CLOUD FRACTION     (KLON,KLEV)
!  PDP5        PDP           LAYER PRESSURE THICKNESS            (KLON,KLEV)
!  PDT05       PDT0          SURFACE TEMPERATURE DISCONTINUITY   (KLON)
!  PEMIS5      PEMIS         SURFACE LW EMISSIVITY               (KLON)
!  PEMIW5      PEMIW         SURFACE LW WINDOW EMISSIVITY        (KLON)
!  PPMB5       PPMB          HALF LEVEL PRESSURE                 (KLON,KLEV+1)
!  PQOF5       PQOF          CONCENTRATION IN OZONE (PA/PA)      (KLON,KLEV)
!  PTAVE5      PTAVE         TEMPERATURE                         (KLON,KLEV)
!  PTL5        PTL           HALF LEVEL TEMPERATURE              (KLON,KLEV+1)
!  PWV5        PWV           SPECIFIC HUMIDITY  (PA/PA)          (KLON,KLEV)

!     ==== OUTPUTS ===
!  Trajectory  Perturbation  Description                         Dimension
!  PEMIT5      PEMIT         SURFACE TOTAL LW EMISSIVITY         (KLON)
!  PFLUX5      PFLUX         RADIATIVE FLUXES :                  (KLON,2,KLEV)
!                     1  ==>  UPWARD   FLUX TOTAL
!                     2  ==>  DOWNWARD FLUX TOTAL
!  PFLUC5      PFLUC         RADIATIVE FLUXES CLEAR SKY:         (KLON,2,KLEV)
!                     1  ==>  UPWARD   FLUX TOTAL
!                     2  ==>  DOWNWARD FLUX TOTAL

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

!     METHOD.
!     -------

!          1. COMPUTES THE PRESSURE AND TEMPERATURE WEIGHTED AMOUNTS OF
!     ABSORBERS.
!          2. COMPUTES THE PLANCK FUNCTIONS ON THE INTERFACES AND THE
!     GRADIENT OF PLANCK FUNCTIONS IN THE LAYERS.
!          3. PERFORMS THE VERTICAL INTEGRATION DISTINGUISHING THE CON-
!     TRIBUTIONS OF THE ADJACENT AND DISTANT LAYERS AND THOSE FROM THE
!     BOUNDARIES.
!          4. COMPUTES THE CLEAR-SKY DOWNWARD AND UPWARD EMISSIVITIES.
!          5. INTRODUCES THE EFFECTS OF THE CLOUDS ON THE FLUXES.

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

!          *LWUTL*, *LWBVTL*, *LWCTL*

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

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

!     AUTHOR.
!     -------
!        M. Janiskova  *ECMWF*       01-Feb-2006

!     MODIFICATIONS.
!     --------------

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

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

USE YOELW    , ONLY : NUA
IMPLICIT NONE

INTEGER(KIND=JPIM),INTENT(IN)    :: KLON 
INTEGER(KIND=JPIM),INTENT(IN)    :: KLEV 
INTEGER(KIND=JPIM),INTENT(IN)    :: KIDIA 
INTEGER(KIND=JPIM),INTENT(IN)    :: KFDIA 
INTEGER(KIND=JPIM),INTENT(IN)    :: KMODE 
INTEGER(KIND=JPIM),INTENT(IN)    :: KTOPC
REAL(KIND=JPRB)   ,INTENT(IN)    :: PCCO2
REAL(KIND=JPRB)   ,INTENT(IN)    :: PVIEW(KLON) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PCLFR5(KLON,KLEV)
REAL(KIND=JPRB)   ,INTENT(IN)    :: PCLDLD5(KLON,KLEV)
REAL(KIND=JPRB)   ,INTENT(IN)    :: PCLDLU5(KLON,KLEV)
REAL(KIND=JPRB)   ,INTENT(IN)    :: PDP5(KLON,KLEV)
REAL(KIND=JPRB)   ,INTENT(IN)    :: PDT05(KLON)
REAL(KIND=JPRB)   ,INTENT(IN)    :: PEMIS5(KLON)
REAL(KIND=JPRB)   ,INTENT(IN)    :: PEMIW5(KLON)
REAL(KIND=JPRB)   ,INTENT(IN)    :: PPMB5(KLON,KLEV+1)
REAL(KIND=JPRB)   ,INTENT(IN)    :: PQOF5(KLON,KLEV)
REAL(KIND=JPRB)   ,INTENT(IN)    :: PTL5(KLON,KLEV+1)
REAL(KIND=JPRB)   ,INTENT(IN)    :: PAER5(KLON,6,KLEV)
REAL(KIND=JPRB)   ,INTENT(IN)    :: PTAVE5(KLON,KLEV)
REAL(KIND=JPRB)   ,INTENT(IN)    :: PWV5(KLON,KLEV)
REAL(KIND=JPRB)   ,INTENT(INOUT) :: PEMIT5(KLON)
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PFLUX5(KLON,2,KLEV+1)
REAL(KIND=JPRB)   ,INTENT(INOUT) :: PFLUC5(KLON,2,KLEV+1)
REAL(KIND=JPRB)   ,INTENT(IN)    :: PCLFR(KLON,KLEV)
REAL(KIND=JPRB)   ,INTENT(IN)    :: PCLDLD(KLON,KLEV) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PCLDLU(KLON,KLEV) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PDP(KLON,KLEV) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PDT0(KLON) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PEMIS(KLON) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PEMIW(KLON) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PPMB(KLON,KLEV+1) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PQOF(KLON,KLEV) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PTL(KLON,KLEV+1) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PAER(KLON,6,KLEV) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PTAVE(KLON,KLEV) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PWV(KLON,KLEV) 
REAL(KIND=JPRB)   ,INTENT(INOUT) :: PEMIT(KLON) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PFLUX(KLON,2,KLEV+1) 
REAL(KIND=JPRB)   ,INTENT(INOUT) :: PFLUC(KLON,2,KLEV+1)

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

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

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

REAL(KIND=JPRB) :: ZABCU(KLON,NUA,3*KLEV+1)
REAL(KIND=JPRB) :: ZBINT(KLON,KLEV+1), ZBSUI(KLON)
REAL(KIND=JPRB) :: ZCNTRB(KLON,KLEV+1,KLEV+1) 
REAL(KIND=JPRB) :: ZABCU5(KLON,NUA,3*KLEV+1)
REAL(KIND=JPRB) :: ZBINT5(KLON,KLEV+1), ZBSUI5(KLON)
REAL(KIND=JPRB) :: ZCNTRB5(KLON,KLEV+1,KLEV+1)  

REAL(KIND=JPRB) :: ZHOOK_HANDLE

#include "lwbvtl.intfb.h"
#include "lwctl.intfb.h"
#include "lwutl.intfb.h"

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

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

!100  CONTINUE

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

!*         1.1   COMPUTES ABSORBER AMOUNTS
!                -------------------------

IF (LHOOK) CALL DR_HOOK('LWTL',0,ZHOOK_HANDLE)
CALL LWUTL &
 & (  KIDIA, KFDIA, KLON, KLEV,&
 & PVIEW , PCCO2, PAER5 , PDP5 , PPMB5, PQOF5 , PTAVE5, PWV5,&
 & ZABCU5, &
 & PAER  , PDP  , PPMB  , PQOF , PTAVE, PWV   ,&
 & ZABCU &
 & )  

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

!*         2.    COMPUTES PLANCK FUNCTIONS
!                -------------------------
!                PERFORMS THE VERTICAL INTEGRATION
!                ---------------------------------

CALL LWBVTL &
 & ( KIDIA, KFDIA , KLON  , KLEV  , KMODE ,&
 & PDT05  , PEMIS5, PEMIW5, PTL5  , PTAVE5,&
 & PEMIT5 , PFLUC5, &
 & ZABCU5 , ZBINT5, ZBSUI5, ZCNTRB5 ,&
 & PDT0   , PEMIS , PEMIW , PTL   , PTAVE,&
 & PEMIT  , PFLUC ,&
 & ZABCU  , ZBINT , ZBSUI , ZCNTRB &
 & )  

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

!*         4.    INTRODUCES THE EFFECTS OF CLOUDS
!                --------------------------------

!IF (KTOPC > 1) THEN

CALL LWCTL &
 & ( KIDIA , KFDIA , KLON   , KLEV, KTOPC,&
 & ZBINT5  , ZBSUI5, PCLFR5 , PCLDLD5, PCLDLU5,&
 & ZCNTRB5 , PEMIT5, PFLUC5 ,&
 & PFLUX5  , &
 & ZBINT   , ZBSUI , PCLFR  , PCLDLD , PCLDLU ,&
 & ZCNTRB  , PEMIT , PFLUC  ,&
 & PFLUX   &
 & )

!ENDIF

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

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