SUBROUTINE PPRH2MAD(&
 & KPROMA,KIDIA,KFDIA,PRHMAX,PRHMIN,&
 & PAPF5,PQ5,PT5,&
 & PAPF,PQ,PT,&
 & PRH25,PES5,&
 & PRH2)  

!**** *PPRH2MAD* - ADJOINT OF THE TANGENT LINEAR
!                  OF RELATIVE HUMIDITY AT 2 METERS

!     PURPOSE
!     -------

!**   INTERFACE
!     ---------
!       *CALL* *PRH2MAD(
!     C               KPROMA,KIDIA,KFDIA,NFLEVG,
!     I               ZPRESF5(1,NFLEVG),ZQF5(1,NFLEVG),ZTF5(1,NFLEVG),
!     O               ZPRESF(1,NFLEVG),ZQF(1,NFLEVG),ZTF(1,NFLEVG),
!     I               PRH2)

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

!        KPROMA                    - HORIZONTAL DIMENSION.             (INPUT-C)
!        KIDIA                     - INDEX OF START POINT              (INPUT-C)
!        KFDIA                     - INDEX OF END   POINT              (INPUT-C)
!        PRHMAX               - MAXIMUM RELATIVE HUMIDITY              (INPUT-C)
!        PRHMIN               - MINIMUM RELATIVE HUMIDITY              (INPUT-C)
!        PAPF(KPROMA)              - FULL PRESSURE  ON THE LOWER
!                                    LEVEL                             (INPUT)
!        PQ(KPROMA)                - SPECIFIC HUMIDITY ON THE LOWER
!                                    LEVEL.                            (INPUT)
!        PT(KPROMA)                - TEMPERATURE ON THE LOWER LEVEL    (INPUT)

!        PRH2(KPROMA)              - PERTUTBATION OF 2 M RELATIVE
!                                    HUMIDITY                          (OUTPUT)

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

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

!     EXTERNALS.
!     ----------
!        *GPRHAD*

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

!     AUTHOR.
!     -------
!        CARLA CARDINALI *ECMWF*

!     MODIFICATIONS.
!     --------------
!        ORIGINAL   : 92-05-22
!        L. Isaksen : 96-02-20  NFLEV --> NFLEVG
!        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)    :: KPROMA 
INTEGER(KIND=JPIM),INTENT(IN)    :: KIDIA 
INTEGER(KIND=JPIM),INTENT(IN)    :: KFDIA 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PRHMAX 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PRHMIN 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PAPF5(KPROMA) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PQ5(KPROMA) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PT5(KPROMA) 
REAL(KIND=JPRB)   ,INTENT(INOUT) :: PAPF(KPROMA) 
REAL(KIND=JPRB)   ,INTENT(INOUT) :: PQ(KPROMA) 
REAL(KIND=JPRB)   ,INTENT(INOUT) :: PT(KPROMA) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PRH25(KPROMA) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PES5(KPROMA) 
REAL(KIND=JPRB)   ,INTENT(INOUT) :: PRH2(KPROMA) 
REAL(KIND=JPRB) :: ZES(KPROMA)
INTEGER(KIND=JPIM) :: JL

REAL(KIND=JPRB) :: ZEPHUM
REAL(KIND=JPRB) :: ZHOOK_HANDLE

#include "gprhad.intfb.h"

!*    1.   CONSTANT DEFINITIONS
!          --------------------

!     1.1    ZEPHUM IS A MINIMUM THRESHOLD FOR THE
!            RELATIVE HUMIDITY IN THE SURFACE LAYER
!            (TO PREVENT UNREALISTIC DEW POINT TEMPERATURE)

IF (LHOOK) CALL DR_HOOK('PPRH2MAD',0,ZHOOK_HANDLE)
ZEPHUM=5.E-2_JPRB

!*    1.2   COMPUTE THE ADJOINT OF THE TANGENT LINEAR OF RELATIVE HUMIDITY

DO JL=KIDIA,KFDIA
  IF(PRH25(JL) > ZEPHUM) THEN
    PRH2(JL)=PRH2(JL)
  ELSE
    PRH2(JL)=0.0_JPRB
  ENDIF
  ZES(JL)=0.0_JPRB
ENDDO

CALL GPRHAD(.TRUE.,KPROMA,KIDIA,KFDIA, 1 ,PRHMAX,PRHMIN,&
 & PQ,PT,PAPF,&
 & ZES,PRH2,&
 & PES5,PAPF5,PQ5,PT5)  

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

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