      SUBROUTINE RELHUM2(RH,T,Q,SH,PS,ES,NLEV,MILEV,IL1,IL2,ILG)
C 
C     * JAN 30/89 - M.LAZARE. ICE-PHASE PARAMETERS PASSED FROM SPWCONH
C     *                       COMMON BLOCK EPSICE. IN-LINE FUNCTION 
C     *                       ESTEFF USED TO EVALUATE ES(T) FOR 
C     *                       ICE/WATER PHASES, WITH ICE PHASE INITIATING 
C     *                       AT 0 DEG LINEARLY TO COMPLETE 
C     *                       COMPLETE ICE-PHASE AT -15 DEG (LIKE OLD). 
C     * M.LAZARE. AUG 24/88. - SAME AS RELHUM EXCEPT SH IS GRID SLICE.
C     * M.LAZARE. AUG 09/88. - ORIGINAL VERSION RELHUM. 
C 
C     * COMPUTES A GRID SLICE OF RELATIVE HUMIDITY FOR USE IN THE 
C     * GCM AND ASSOCIATED DIAGNOSTICS. 
C     * THE RELATIVE HUMIDITY IS CALCULATED FOR BOTH THE WATER AND ICE
C     * PHASES AND SOME ASSUMPTION IS MADE TO DISTINGUISH BETWEEN 
C     * THEM, BASED ON TEMPERATURE AND TYPE OF PHYSICAL PROCESS 
C     * ACTIVE. 
C     * CURRENTLY, WATER PHASE IS USED EXCEPT BELOW -40 DEG C AND 
C     * ABOVE LARGE-SCALE CONVECTIVE AREAS. 
C     * ALL GRID SLICES ARE OF SIZE (ILG,NLEV). 
C     * IT IS ASSUMED THAT THE SUBROUTINE SPWCONH HAS BEEN CALLED 
C     * AT SOME PREVIOUS POINT IN THE CALLING PROGRAM SO THAT THE 
C     * VALUES IN THE COMMON BLOCK EPS HAVE BEEN ESTABLISHED. 
C 
C     * INPUT ARRAYS: 
C             T   : GRID SLICE OF TEMPERATURE (DEG K).
C             Q   : GRID SLICE OF SPECIFIC HUMIDITY (KG/KG).
C             SH  : GRID SLICE OF HALF-LEVEL SIGMA VALUES.
C             PS  : GRID FIELD OF AMBIENT SURFACE PRESSURE (PA) 
C             ES  : WORK FIELD OF SATURATION VAPOUR PRESSURE. 
C 
C     * OUTPUT ARRAY: 
C             RH  : GRID SLICE OF RELATIVE HUMIDITY.
C 
C 
      IMPLICIT REAL (A-H,O-Z),
     +INTEGER (I-N)
      REAL RH(ILG,MILEV),T(ILG,MILEV),Q(ILG,MILEV),SH(ILG,MILEV)
      REAL PS(ILG),ES(ILG)
C 
      COMMON/EPS/A,B,EPS1,EPS2
      COMMON/EPSICE/AICE,BICE,TICE,QMIN 
      COMMON /HTCP/ T1S,T2S,AI,BI,AW,BW,SLP 
C 
C-----------------------------------------------------------------------
C     * STATEMENT FUNCTION DEFINITIONS. 
  
      ESW(TTT)    = EXP(A-B/TTT)
      ESI(TTT)    = EXP(AICE-BICE/TTT)
      ESTEFF(TTT) = MERGE( ESW(TTT),
     1              MERGE( ESI(TTT),
     2                     SLP*((TTT-T2S)*ESW(TTT)+(T1S-TTT)*ESI(TTT)), 
     3                     TTT.LE.T2S), 
     4                     TTT.GE.T1S)
C-----------------------------------------------------------------------
C-----------------------------------------------------------------------
      DO 200 L=1,NLEV 
         DO 100 IL=IL1,IL2
            ES(IL)=ESTEFF(T(IL,L))
            PMBH=SH(IL,L)*PS(IL)*0.01E0
            QS=EPS1*ES(IL)/(PMBH-EPS2*ES(IL)) 
            RH(IL,L)=MIN((MAX(Q(IL,L),QMIN))/QS,1.E0) 
  100    CONTINUE 
  200 CONTINUE
C 
      RETURN
      END 
