SUBROUTINE M7_EMI_SO2 &
  &( KIDIA, KFDIA, KLON , &
  &  PCI  , PGELAM,PGEMU, PLSM , PWIND, &
  &  PSO2L, PSO2H, PSOGF, & 
  &  PFLXM7 & 
  &)

!*** * M7_EMI_SO2* - SOURCE TERMS FOR SULPHUR DIOXIDE

!**   INTERFACE.
!     ----------
!          *M7_EMI_SO2* IS CALLED FROM *  *.

!     AUTHOR.
!     -------
!       H. Feichter, MPI 20020802
!       P. Stier   , MPI 20020601

!     MODIFICATIONS.
!     --------------
!        FROM original M7 *so2_emissions*
!        JJMorcrette 20100106 Rewritten for the ECMWF IFS

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

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

USE YO_AERO_M7  ,ONLY : nm7aer
USE YO_AERO_TRAC,ONLY : idt_so2 
USE YOMCST    ,ONLY : RPI, RDAY
USE YOMRIP    ,ONLY : RHGMT
USE YOM_YGFL  ,ONLY : LAERODIU

IMPLICIT NONE

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

!*       0.1   ARGUMENTS
!              ---------

INTEGER(KIND=JPIM),INTENT(IN)    :: KLON 
INTEGER(KIND=JPIM),INTENT(IN)    :: KIDIA 
INTEGER(KIND=JPIM),INTENT(IN)    :: KFDIA 

REAL(KIND=JPRB)   ,INTENT(IN)    :: PCI(KLON), PGELAM(KLON), PGEMU(KLON), PLSM(KLON), PWIND(KLON) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PSO2L(KLON), PSO2H(KLON), PSOGF(KLON)

REAL(KIND=JPRB)   ,INTENT(INOUT) :: PFLXM7(KLON,nm7aer)


!*       0.5   LOCAL VARIABLES
!              ---------------

INTEGER(KIND=JPIM) :: IMON
INTEGER(KIND=JPIM) :: JL

REAL(KIND=JPRB) :: ZDIURN(KLON), ZGLAT(KLON), ZGLON(KLON), ZSOGF(KLON)
REAL(KIND=JPRB) :: ZDEGRAD     , ZLOCALTIM

REAL(KIND=JPRB) :: ZHOOK_HANDLE
!-----------------------------------------------------------------------
IF (LHOOK) CALL DR_HOOK('M7_EMI_SO2',0,ZHOOK_HANDLE)

ZDEGRAD=180._JPRB/RPI

!-- for development
  IMON=4
!------------------

DO JL=KIDIA,KFDIA
  ZGLON(JL)=PGELAM(JL)*ZDEGRAD
  ZGLAT(JL)=ASIN(PGEMU(JL))*ZDEGRAD
  ZLOCALTIM =RHGMT + ZGLON(JL)/360._JPRB*RDAY
  ZDIURN(JL)=COS( ((ZLOCALTIM-54000._JPRB)/RDAY) * 2._JPRB*RPI)+1._JPRB
ENDDO
IF (.NOT.LAERODIU) THEN
  ZDIURN(KIDIA:KFDIA)=1.0_JPRB
ENDIF

!*     1.    Apply the emissions
!            -------------------

DO JL=KIDIA,KFDIA
  IF (PSOGF(JL) < 0._JPRB) THEN
    ZSOGF(JL) = -PSOGF(JL)
  ELSE
    ZSOGF(JL) = PSOGF(JL)
  ENDIF 

!*      1.1   SULPHUR DIOXIDE
!             ---------------

!-- Biomass burning (from GFED) and low-level anthropogenic emissions 

  PFLXM7(JL,idt_so2) = PSOGF(JL) + PSO2L(JL)*ZDIURN(JL)

!-- to be consistent with GEMS-AER high-level emission are also introduced at the surface
!-- SHOULD BE CHANGED

  PFLXM7(JL,idt_so2) = PFLXM7(JL,idt_so2) + PSO2H(JL)

!- 
ENDDO

!-----------------------------------------------------------------------
IF (LHOOK) CALL DR_HOOK('M7_EMI_SO2',1,ZHOOK_HANDLE)
END SUBROUTINE M7_EMI_SO2
