!*
!     ------------------------------------------------------------------
#ifdef DOC
!     ADJOINT OF LINEAR OF THERMODYNAMICAL FUNCTIONS .

!     Pressure of water vapour at saturation
!        INPUT : PESARG = GRADIENT WITH RESPECT TO ES
!                PLQ    = GRADIENT OF (LATENT HEAT * QV)
!                PTARE5 = TRAJECTORY TEMPERATURE
!                PALFAAD= ADJOINT OF ALFA OPERATOR
!        OUTPUT:          EPS*GRADIENT WITH RESPECT TO TEMPERATURE
#endif
REAL(KIND=JPRB) :: FESW,FESI,FESIAD,FESWAD,FALFAAD,FOEEWMAD,FOEEWMOAD
REAL(KIND=JPRB) :: FESICUAD,FESWCUAD
REAL(KIND=JPRB) :: FOEALFAAD,FOEALFCUAD,FOELHMCUAD,FOEEWMCUAD,FOELHMAD
REAL(KIND=JPRB) :: PTAREA,PESAREA,PTARE5,PALFAAD,PALFAW,PLQ

FESW(PTAREA) = R2ES * EXP(R3LES*(PTAREA-RTT)/(PTAREA-R4LES))
FESI(PTAREA) = R2ES * EXP(R3IES*(PTAREA-RTT)/(PTAREA-R4IES))

FESIAD(PESAREA,PTARE5) = R3IES*(RTT-R4IES)/(PTARE5-R4IES)**2 *&
                      &FESI(PTARE5) *(1.0_JPRB-FOEALFA(PTARE5))*PESAREA
FESWAD(PESAREA,PTARE5) = R3LES*(RTT-R4LES)/(PTARE5-R4LES)**2 *&
                      &FESW(PTARE5) * FOEALFA(PTARE5)*PESAREA

FALFAAD(PTARE5) = (FESW(PTARE5)-FESI(PTARE5))

FOEEWMAD(PESAREA,PTARE5,PALFAAD) = FESIAD(PESAREA,PTARE5) +&
                        &FESWAD(PESAREA,PTARE5) +&
                        &FALFAAD(PTARE5)*PALFAAD

FOEEWMOAD(PESAREA,PTARE5) = R3LES*(RTT-R4LES)/(PTARE5-R4LES)**2 *&
                      &FESW(PTARE5) * PESAREA

FOEALFAAD(PALFAW,PTARE5) = (0.5_JPRB+SIGN(0.5_JPRB,PTARE5-RTICE)) &
              & * (0.5_JPRB-SIGN(0.5_JPRB,PTARE5-RTWAT)) &
              & * 2.0_JPRB*(PTARE5-RTICE)*PALFAW/(RTWAT-RTICE)**2

FOELHMAD(PLQ,PTARE5) = FOEALFAAD(PLQ,PTARE5)*(RLVTT-RLSTT)

FESICUAD(PESAREA,PTARE5) = R3IES*(RTT-R4IES)/(PTARE5-R4IES)**2 *&
                    &FESI(PTARE5) *(1.0_JPRB-FOEALFCU(PTARE5))*PESAREA
FESWCUAD(PESAREA,PTARE5) = R3LES*(RTT-R4LES)/(PTARE5-R4LES)**2 *&
                    &FESW(PTARE5) * FOEALFCU(PTARE5)*PESAREA

FOEALFCUAD(PALFAW,PTARE5) = (0.5_JPRB+SIGN(0.5_JPRB,PTARE5-RTICECU)) &
              & * (0.5_JPRB-SIGN(0.5_JPRB,PTARE5-RTWAT)) &
              & * 2.0_JPRB*(PTARE5-RTICECU)*PALFAW*(RTWAT_RTICECU_R)**2

FOEEWMCUAD(PESAREA,PTARE5,PALFAAD) = FESICUAD(PESAREA,PTARE5) +&
                        &FESWCUAD(PESAREA,PTARE5) +&
                        &FALFAAD(PTARE5)*PALFAAD

FOELHMCUAD(PLQ,PTARE5) = FOEALFCUAD(PLQ,PTARE5)*(RLVTT-RLSTT)

