SUBROUTINE EMIS_IR(PLS,PTS,PSN,PWS,PEM)

!     PURPOSE.
!     -------
!     Routine called by RAD1CEMIS to compute IR surface emissivity 
!     for various surface conditions

!     INTERFACE.
!     ---------
!     call emis_ir(PLS,PTS,PSN,PWS,PEM)

!     ARGUMENTS
!     ---------
!     PLS - input model land/sea flag
!     PTS - input model skin temperature
!     PSN - input model snow cover
!     PWS - input model soil moisture
!     PEM - output infrared surface emissivity        

!     EXTERNALS
!     ---------
!     * none * all routines self contained here

!     AUTHOR
!     ------
!     Tony McNally - March 1998

!     MODIFICATIONS
!     -------------
!     Christina Ko"pken - Nov 2000 : use of RTTOV-6 regression for IR emis
!                                    calculations also for VTPR sensor 
!     Christina Ko"pken -30/10/2001: add regression for GOES 8-12 IR emis
!     Christina Ko"pken - Nov 2002 : add regression coefs for MET 1-4
!     Matthew Szyndel   - Oct 2003 : add regression coefs for MET 8 and redesign
!     Matthew Szyndel   - Mar 2005 : add regression coefs for MET 9, MTSAT-1R and FY-2C
!        M.Hamrud      01-Oct-2003 CY28 Cleaning
!     Niels Bormann     - Mar 2009 : Tidying: Use SSIREM (ISEM) in RTTOV


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

USE YOMDIMO   , ONLY : NMXTCH
USE YOMLUN    , ONLY : NULERR

IMPLICIT NONE

REAL(KIND=JPRB)   ,INTENT(IN)    :: PLS 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PTS 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PSN 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PWS 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PEM(NMXTCH) 


REAL(KIND=JPRB) :: ZHOOK_HANDLE

#include "abor1.intfb.h"

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

!-----------------------------------------------------------------------
!     0.1 Pre-compute surface wind speed , set default emissivity
!     -----------------------------------------------------------
IF (LHOOK) CALL DR_HOOK('EMIS_IR',0,ZHOOK_HANDLE)

PEM(:)=0.99_JPRB

!     *** VARIOUS CONDITIONS NOW FOLLOW FOR EMISSIVITY ESTIMATION ***
!     ===============================================================

!     1.0 Ice free open sea or mixed ice  
!     ==================================
IF(NINT(PLS) == 0.AND.PTS >= 265.0_JPRB) THEN

  ! Activate SSIREM (ISEM) inside RTTOV
  PEM(:) = -1.0_JPRB

  IF (LHOOK) CALL DR_HOOK('EMIS_IR',1,ZHOOK_HANDLE)
  RETURN
ENDIF

!     2.0 Sea ice
!     ===========

!     2.1 Exposed sea ice
!     -------------------
IF(NINT(PLS) == 0.AND.PTS < 265.0_JPRB.AND.PSN <= 0.0_JPRB) THEN
!      PRINT*,'FOUND EXPOSED SEA ICE',PLS,PTS,PSN,PWS
  PEM(:)=1.00_JPRB
  IF (LHOOK) CALL DR_HOOK('EMIS_IR',1,ZHOOK_HANDLE)
  RETURN
ENDIF

!     2.2 Sea ice with snow cover
!     ---------------------------
IF(NINT(PLS) == 0.AND.PTS < 271.0_JPRB.AND.PSN > 0.0_JPRB) THEN
  PEM(:)=1.00_JPRB
!      PRINT*,'FOUND SEA ICE WITH SNOW COVER',PLS,PTS,PSN,PWS
  IF (LHOOK) CALL DR_HOOK('EMIS_IR',1,ZHOOK_HANDLE)
  RETURN
ENDIF

!     3.0 Land
!     ========

!     3.1 Exposed dry land
!     --------------------
IF(NINT(PLS) == 1.AND.PSN <= 0.0_JPRB.AND.PWS <= 10.0_JPRB) THEN
!      PRINT*,'FOUND EXPOSED DRY LAND',PLS,PTS,PSN,PWS
  PEM(:)=0.93_JPRB
  IF (LHOOK) CALL DR_HOOK('EMIS_IR',1,ZHOOK_HANDLE)
  RETURN
ENDIF

!     3.2 Exposed moist land or light snow cover
!     ------------------------------------------
IF(NINT(PLS) == 1.AND.PSN <= 20.0_JPRB.AND.PWS > 10.0_JPRB) THEN
!      PRINT*,'FOUND EXPOSED MOIST LAND',PLS,PTS,PSN,PWS
  PEM(:)=1.00_JPRB
  IF (LHOOK) CALL DR_HOOK('EMIS_IR',1,ZHOOK_HANDLE)
  RETURN
ENDIF

!     3.3 Land with deep snow cover
!     -----------------------------
IF(NINT(PLS) == 1.AND.PSN > 20.0_JPRB.AND.PSN <= 80.0_JPRB) THEN
  IF(PTS <= 265.0_JPRB) THEN
!       PRINT*,'FOUND LAND WITH LIGHT SNOW COVER',PLS,PTS,PSN,PWS
    PEM(:)=1.00_JPRB
    IF (LHOOK) CALL DR_HOOK('EMIS_IR',1,ZHOOK_HANDLE)
    RETURN
  ELSE
    PEM(:)=1.00_JPRB !revert to moist land value
    IF (LHOOK) CALL DR_HOOK('EMIS_IR',1,ZHOOK_HANDLE)
    RETURN
  ENDIF
ENDIF

!     3.4 Land with very deep snow cover
!     ----------------------------------
IF(NINT(PLS) == 1.AND.PSN > 80.0_JPRB) THEN
  IF(PTS <= 265.0_JPRB) THEN
!       PRINT*,'FOUND LAND WITH DEEP SNOW COVER',PLS,PTS,PSN,PWS
    PEM(:)=1.00_JPRB
    IF (LHOOK) CALL DR_HOOK('EMIS_IR',1,ZHOOK_HANDLE)
    RETURN
  ELSE
    PEM(:)=1.00_JPRB !revert to moist land value
    IF (LHOOK) CALL DR_HOOK('EMIS_IR',1,ZHOOK_HANDLE)
    RETURN
  ENDIF
ENDIF

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