 MODULE YOMEMIS

 USE PARKIND1  ,ONLY : JPIM     ,JPRB

 USE PARCMA  , ONLY : JPMXTOCH
 USE YOMTVRAD, ONLY : MXSENSOR

 IMPLICIT NONE
 
 SAVE

!! Variables defining the mode to be used for the land
!! surface emissivity calculations. 
!! LATLAS ==> Use emissivity atlas
!! LDYN   ==> Dynamically retrieve emissivities 
!! LSKIN  ==> Use emissivity atlas and dynamically calculate Ts
!! By default, all modes are false

!! F. Karbou 2006
!! N. Bormann, bugfix 2007
!! W. Bell, Add windsat, Feb 2009
!! Q. Lu, add Fy3a mwts, mwhs, mwri, Mar 2009

 LOGICAL :: LATLAS_AMSU
 LOGICAL :: LDYN_AMSU
 LOGICAL :: LSKIN_AMSU
 LOGICAL :: LATLAS_SSMI
 LOGICAL :: LDYN_SSMI
 LOGICAL :: LSKIN_SSMI
 LOGICAL :: LATLAS_SSMIS
 LOGICAL :: LDYN_SSMIS
 LOGICAL :: LSKIN_SSMIS
 LOGICAL :: LATLAS_TMI
 LOGICAL :: LDYN_TMI
 LOGICAL :: LSKIN_TMI
 LOGICAL :: LATLAS_AMSRE
 LOGICAL :: LDYN_AMSRE
 LOGICAL :: LSKIN_AMSRE
 LOGICAL :: LATLAS_MWTS
 LOGICAL :: LDYN_MWTS
 LOGICAL :: LSKIN_MWTS
 LOGICAL :: LATLAS_MWHS
 LOGICAL :: LDYN_MWHS
 LOGICAL :: LSKIN_MWHS
 LOGICAL :: LATLAS_MWRI
 LOGICAL :: LDYN_MWRI
 LOGICAL :: LSKIN_MWRI
 LOGICAL :: LATLAS_WINDSAT
 LOGICAL :: LDYN_WINDSAT
 LOGICAL :: LSKIN_WINDSAT
 LOGICAL :: LICE_AMSU
 LOGICAL :: LICE_SSMI
 LOGICAL :: LICE_SSMIS
 LOGICAL :: LICE_TMI
 LOGICAL :: LICE_AMSRE
 LOGICAL :: LICE_WINDSAT
 LOGICAL :: LDYN_EMIS(0:MXSENSOR)
 LOGICAL :: LDYN_TSKIN(0:MXSENSOR)
 LOGICAL :: LATLAS_EMIS(0:MXSENSOR)
 LOGICAL :: LDYN_ICE(0:MXSENSOR)

 INTEGER(KIND=JPIM) :: MEMIS_CHAN(0:MXSENSOR,JPMXTOCH)
! Channel used for skin temperature retrieval 
 INTEGER(KIND=JPIM) :: MTSKIN_CHAN(0:MXSENSOR)

! Threshold used for land/sea discrimination
 REAL(KIND=JPRB), PARAMETER  :: RLSTH=0.5_JPRB

 
! Emissivity from an atlas
! - low angles (an1) and high angles (an2)
! the parameters should be updated in case the emissivity atlases change

 INTEGER(KIND=JPIM) , PARAMETER :: TOT_EM_AN1 = 352207
 REAL(KIND=JPRB) ,ALLOCATABLE   :: DATA_EMIS_AN1(:,:)

 INTEGER(KIND=JPIM) , PARAMETER :: TOT_EM_AN2 = 352207
 REAL(KIND=JPRB) ,ALLOCATABLE   :: DATA_EMIS_AN2(:,:)

 INTEGER(KIND=JPIM) , PARAMETER :: TOT_EM_SSMIS = 186198
!REAL(KIND=JPRB) ,DIMENSION(20,TOT_EM_SSMIS)   ::  ATLAS_SSMIS
 REAL(KIND=JPRB) ,ALLOCATABLE   :: ATLAS_SSMIS(:,:)

 INTEGER(KIND=JPIM) , PARAMETER :: TOT_EM_SSMI = 322156
 REAL(KIND=JPRB) ,ALLOCATABLE   :: ATLAS_SSMI(:,:)


! Table of coefficients for the parameterisation 

 INTEGER(KIND=JPIM) , PARAMETER :: TOT_PAR = 72
 REAL(KIND=JPRB) ,DIMENSION(8,TOT_PAR)   ::  DATA_MODEL
 INTEGER(KIND=JPIM) , PARAMETER :: CONST_PAR = 15
! The constant is needed in the emissivity parameterisation
! REAL(KIND=JPRB) ,DIMENSION(6)   ::  MW_COEF23, MW_COEF50, MW_COEF89


END MODULE YOMEMIS
