SUBROUTINE M7_EMI_CAR &
  &( KIDIA, KFDIA, KLON , &
  &  PCI  , PGELAM,PGEMU, PLSM , PWIND, &
  &  PBCBF, PBCFF, PBCGF, POMBF, POMFF, POMGF, & 
  &  PFLXM7 & 
  &)

!*** * M7_EMI_CAR* - SOURCE TERMS FOR ORGANIC AND BLACK CARBON AEROSOLS

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

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

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

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

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

USE YO_AERO_M7  ,ONLY : nm7aer, rcarbon_nh, rcarbon_sh, rom2oc &
  &                   , rm2n_bcki_ff, rm2n_bcki_bb, rm2n_ocki_ff, rm2n_ocki_bb &
  &                   , rm2n_ocks_bb, rm2n_ocki_bg, rm2n_ocks_bg               & 
  &                   , rbb_wsoc_perc, rbge_wsoc_perc 
USE YO_AERO_TRAC,ONLY : idt_mbcki, idt_mocki, idt_mocks & 
  &                   , idt_nki  , idt_nks
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)    :: PBCBF(KLON), PBCFF(KLON), PBCGF(KLON), POMBF(KLON), POMFF(KLON), POMGF(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), ZBCGF(KLON), ZOMGF(KLON)
REAL(KIND=JPRB) :: ZGLAT(KLON) , ZGLON(KLON)
REAL(KIND=JPRB) :: ZCARBSEAS   , ZDEGRAD    , ZLOCALTIM

REAL(KIND=JPRB) :: ZHOOK_HANDLE
!-----------------------------------------------------------------------
IF (LHOOK) CALL DR_HOOK('M7_EMI_CAR',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
  IF (ZGLAT(JL) > 0._JPRB) THEN
    ZCARBSEAS=RCARBON_NH(IMON)
  ELSE
    ZCARBSEAS=RCARBON_SH
  ENDIF
ENDDO
IF (.NOT.LAERODIU) THEN
  ZDIURN(KIDIA:KFDIA)=1.0_JPRB
ENDIF

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

DO JL=KIDIA,KFDIA
  IF (PBCGF(JL) < 0._JPRB) THEN
    ZBCGF(JL) = -PBCGF(JL)
  ELSE
    ZBCGF(JL) = PBCGF(JL)
  ENDIF 
  IF (POMGF(JL) < 0._JPRB) THEN
    ZOMGF(JL) = -POMGF(JL)
  ELSE
    ZOMGF(JL) = POMGF(JL)
  ENDIF

!*      1.1   BLACK CARBON
!             ------------

!-- Black carbon: Anthropogenic: fossil fuel

  PFLXM7(JL,idt_mbcki) = PBCFF(JL) * ZCARBSEAS
  PFLXM7(JL,idt_nki)   = PFLXM7(JL,idt_nki)   + PBCFF(JL) * ZCARBSEAS * rm2n_bcki_ff

!-- Black carbon: Add biomass burning and GFED contribution

  PFLXM7(JL,idt_mbcki) = PFLXM7(JL,idt_mbcki) + PBCBF(JL)*ZDIURN(JL) + ZBCGF(JL)
  PFLXM7(JL,idt_nki)   = PFLXM7(JL,idt_nki)   +(PBCBF(JL)*ZDIURN(JL) + ZBCGF(JL)) * rm2n_bcki_bb


!*      1.2   ORGANIC CARBON
!             --------------
 
!-- Organic carbon: Anthropogenic: fossil fuel

  PFLXM7(JL,idt_mocki) = POMFF(JL) * ZCARBSEAS * ROM2OC
  PFLXM7(JL,idt_nki)   = PFLXM7(JL,idt_nki)   + POMFF(JL) * ZCARBSEAS * ROM2OC * rm2n_ocki_ff


!-- Organic carbon: Add biomass burning and GFED contribution: Insoluble contribution

  PFLXM7(JL,idt_mocki) = PFLXM7(JL,idt_mocki) +(POMBF(JL)*ZDIURN(JL) + ZOMGF(JL)) * ROM2OC * (1._JPRB-rbb_wsoc_perc)
  PFLXM7(JL,idt_nki)   = PFLXM7(JL,idt_nki)   +(POMBF(JL)*ZDIURN(JL) + ZOMGF(JL)) * ROM2OC * (1._JPRB-rbb_wsoc_perc) * rm2n_ocki_bb

!-- Organic carbon: Add biomass burning and GFED contribution: Soluble contribution

  PFLXM7(JL,idt_mocks) = PFLXM7(JL,idt_mocks) + ZOMGF(JL) * ROM2OC * rbb_wsoc_perc
  PFLXM7(JL,idt_nks)   = PFLXM7(JL,idt_nks)   + ZOMGF(JL) * ROM2OC * rbb_wsoc_perc * rm2n_ocks_bb


!-- Organic carbon: Add biogenic contribution: Insoluble contribution

  PFLXM7(JL,idt_mocki) = PFLXM7(JL,idt_mocki) + POMBF(JL)*ZDIURN(JL) * ROM2OC * (1._JPRB-rbge_wsoc_perc)
  PFLXM7(JL,idt_nki)   = PFLXM7(JL,idt_nki)   + POMBF(JL)*ZDIURN(JL) * ROM2OC * (1._JPRB-rbge_wsoc_perc) * rm2n_ocki_bg

!-- Organic carbon: Add biogenic contribution: Soluble contribution

  PFLXM7(JL,idt_mocks) = PFLXM7(JL,idt_mocks) + POMBF(JL)*ZDIURN(JL) * ROM2OC * rbge_wsoc_perc
  PFLXM7(JL,idt_nks)   = PFLXM7(JL,idt_nks)   + POMBF(JL)*ZDIURN(JL) * ROM2OC * rbge_wsoc_perc * rm2n_ocks_bg

!- 
ENDDO



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