      SUBROUTINE MCMCSTEPSP(PAR,PROB,NPROB,IFAIL)

      IMPLICIT NONE

      INTEGER I,IFAIL,M1FLAG,M2FLAG,M3FLAG,MHDFLAG,MHUFLAG
      INTEGER AKFLAG,ALFLAG,OMGFLAG,MAFLAG,MOFLAG
      INTEGER NTOT,IDUM,TOTMIN,TOTMAX,NMAX,NPROB
      INTEGER MCFLAG,NSUSY,NGUT,NMES
      PARAMETER (NSUSY=14,NGUT=21,NMES=20)

      DOUBLE PRECISION PAR(*),PROB(*),P,RAN2,XDUM,PP
      DOUBLE PRECISION FTSUSY(NSUSY+2),FTGUT(NGUT+2),FTMES(NMES+2)
      DOUBLE PRECISION SMASS(3),PMASS(2),CMASS,SCOMP(3,3),PCOMP(2,2)
      DOUBLE PRECISION MGL,MCHA(2),U(2,2),V(2,2),MNEU(5),NEU(5,5)
      DOUBLE PRECISION M0,M12,A0,MUR,MUL,MDR,MDL,MLR,MLL,MNL
      DOUBLE PRECISION MST1,MST2,MSB1,MSB2,MSL1,MSL2,MSNT
      DOUBLE PRECISION CST,CSB,CSL,MSMU1,MSMU2,MSNM,CSMU
      DOUBLE PRECISION RMST1,RMST2,S2T,RMSB1,RMSB2,S2B,XT,XB
      DOUBLE PRECISION M1INP,M2INP,M3INP,MHDINP,MHUINP,ALINP,AKINP
      DOUBLE PRECISION XIFINP,XISINP,MUPINP,MSPINP,MSINP,M3HINP
      DOUBLE PRECISION MHmin,MHmax,chi2max,chi2gam,chi2bb,chi2zz
      DOUBLE PRECISION M0CEN,M0DEV,M12CEN,M12DEV,TBCEN,TBDEV,A0CEN
      DOUBLE PRECISION A0DEV,M1CEN,M1DEV,M2CEN,M2DEV,M3CEN,M3DEV
      DOUBLE PRECISION MHDCEN,MHDDEV,MHUCEN,MHUDEV,MSCEN,MSDEV,LCEN
      DOUBLE PRECISION LDEV,KCEN,KDEV,ALCEN,ALDEV,AKCEN,AKDEV,MUCEN
      DOUBLE PRECISION MUDEV,XIFCEN,XIFDEV,XISCEN,XISDEV,MUPCEN
      DOUBLE PRECISION MUPDEV,MSPCEN,MSPDEV,M3HCEN,M3HDEV,XCEN,XDEV,X
      DOUBLE PRECISION M0MIN,M12MIN,TBMIN,A0MIN,M1MIN,M2MIN,M3MIN
      DOUBLE PRECISION MHDMIN,MHUMIN,MSMIN,LMIN,KMIN,ALMIN,AKMIN
      DOUBLE PRECISION MUMIN,XIFMIN,XISMIN,MUPMIN,MSPMIN,M3HMIN
      DOUBLE PRECISION M1GUT,M2GUT,M3GUT,ALGUT,AKGUT,ATGUT,ABGUT
      DOUBLE PRECISION ATAUGUT,AMUGUT,MHUGUT,MHDGUT,MSGUT,MQ3GUT,MU3GUT
      DOUBLE PRECISION MD3GUT,MQGUT,MUGUT,MDGUT,ML3GUT,ME3GUT,MLGUT
      DOUBLE PRECISION MEGUT,XIFGUT,XISGUT,MUPGUT,MSPGUT,M3HGUT,DELMB
      DOUBLE PRECISION Q2,Q2MEM,DELMEM,XIFMEM,XISMEM,MUMEM,MDMEM,MSMEM
      DOUBLE PRECISION PARMEM(25)

      COMMON/SOFTGUT/M0,M12,A0
      COMMON/GUTPAR/M1GUT,M2GUT,M3GUT,ALGUT,AKGUT,ATGUT,ABGUT,
     . ATAUGUT,AMUGUT,MHUGUT,MHDGUT,MSGUT,MQ3GUT,MU3GUT,
     . MD3GUT,MQGUT,MUGUT,MDGUT,ML3GUT,ME3GUT,MLGUT,MEGUT
      COMMON/GUTEXT/XIFGUT,XISGUT,MUPGUT,MSPGUT,M3HGUT
      COMMON/RENSCALE/Q2
      COMMON/DELMB/DELMB
      COMMON/MEM/Q2MEM,DELMEM,XIFMEM,XISMEM,MUMEM,MDMEM,MSMEM,PARMEM
      COMMON/INPPAR/M1INP,M2INP,M3INP,MHDINP,MHUINP,ALINP,AKINP,
     . XIFINP,XISINP,MUPINP,MSPINP,MSINP,M3HINP
      COMMON/HIGGSPEC/SMASS,SCOMP,PMASS,PCOMP,CMASS
      COMMON/SUSYSPEC/MGL,MCHA,U,V,MNEU,NEU
      COMMON/SFSPEC/MUR,MUL,MDR,MDL,MLR,MLL,MNL,
     . MST1,MST2,MSB1,MSB2,MSL1,MSL2,MSNT,
     . CST,CSB,CSL,MSMU1,MSMU2,MSNM,CSMU
      COMMON/RADCOR/RMST1,RMST2,S2T,RMSB1,RMSB2,S2B,XT,XB
      COMMON/HIGGSFIT/MHmin,MHmax,chi2max,chi2gam,chi2bb,chi2zz
      COMMON/MCMCPAR/M0CEN,M0DEV,M12CEN,M12DEV,TBCEN,TBDEV,A0CEN,
     . A0DEV,M1CEN,M1DEV,M2CEN,M2DEV,M3CEN,M3DEV,MHDCEN,MHDDEV,
     . MHUCEN,MHUDEV,MSCEN,MSDEV,LCEN,LDEV,KCEN,KDEV,ALCEN,ALDEV,
     . AKCEN,AKDEV,MUCEN,MUDEV,XIFCEN,XIFDEV,XISCEN,XISDEV,MUPCEN,
     . MUPDEV,MSPCEN,MSPDEV,M3HCEN,M3HDEV,XCEN,XDEV,X,
     . M0MIN,M12MIN,TBMIN,A0MIN,M1MIN,M2MIN,M3MIN,
     . MHDMIN,MHUMIN,MSMIN,LMIN,KMIN,ALMIN,AKMIN,
     . MUMIN,XIFMIN,XISMIN,MUPMIN,MSPMIN,M3HMIN
      COMMON/FINETUN/FTSUSY,FTGUT,FTMES
      COMMON/SCANFLAGS/M1FLAG,M2FLAG,M3FLAG,MHDFLAG,MHUFLAG,
     . AKFLAG,ALFLAG
      COMMON/FLAGS/OMGFLAG,MAFLAG,MOFLAG
      COMMON/MCFLAG/MCFLAG
      COMMON/STEPS/NTOT,IDUM,TOTMIN,TOTMAX,NMAX

      X=0d0

      IF(IFAIL.EQ.9.OR.IFAIL.GE.11)THEN
       X=1d40
      ENDIF

      IF(IFAIL.EQ.1.OR.IFAIL.EQ.3.OR.IFAIL.EQ.5.OR.IFAIL.EQ.7)THEN
       X=X+(2d0-SMASS(1))*1d20
      ENDIF
      IF(IFAIL.EQ.2.OR.IFAIL.EQ.3.OR.IFAIL.EQ.6.OR.IFAIL.EQ.7)THEN
       X=X+(2d0-PMASS(1))*1d20
      ENDIF
      IF(IFAIL.EQ.4.OR.IFAIL.EQ.5.OR.IFAIL.EQ.6.OR.IFAIL.EQ.7)THEN
       X=X+(2d0-CMASS)*1d20
      ENDIF

      IF(IFAIL.EQ.8)THEN
       X=MIN(X,RMST1)
       X=MIN(X,RMSB1)
       X=MIN(X,MST1)
       X=MIN(X,MST2)
       X=MIN(X,MSB1)
       X=MIN(X,MSB2)
       X=MIN(X,MUL)
       X=MIN(X,MUR)
       X=MIN(X,MDL)
       X=MIN(X,MDR)
       X=MIN(X,MSL1)
       X=MIN(X,MSNT)
       X=MIN(X,MSMU1)
       X=MIN(X,MSNM)
       X=MIN(X,MLR)
       X=MIN(X,MLL)
       X=MIN(X,MNL)
       X=(1d0-X)*1d20
      ENDIF

      IF(IFAIL.EQ.10)THEN
       DO I=1,NPROB
	X=X+DABS(PROB(I))
c	IF(I.NE.30)X=X+DABS(PROB(I))
       ENDDO
       IF(X.NE.0d0)X=(1d0+X)*1d10
c       IF(X.NE.0d0)X=(1d0+X)*1d15
c       IF(PROB(30).NE.0d0)THEN
c        X=X+(1d0+DABS(PROB(30)))*1d10
c       ENDIF
      ENDIF

      IF(MCFLAG.EQ.1)THEN
       IF(FTGUT(NGUT+1).GT.1d3)THEN
        X=X+(FTGUT(NGUT+1)/1d3)*1d5
       ENDIF
      ELSEIF(MCFLAG.EQ.2)THEN
       X=X+FTGUT(NGUT+1)
      ELSEIF(MCFLAG.EQ.3)THEN
       IF(DABS(MNEU(1)).GT.1d1)THEN
        X=X+(DABS(MNEU(1))/1d1)*1d5
       ENDIF
      ELSEIF(MCFLAG.EQ.4)THEN
       IF(DABS(MNEU(1)).GT.1d1)THEN
        X=X+(DABS(MNEU(1))/1d1)*1d5
       ENDIF
       IF(FTGUT(NGUT+1).GT.1d3)THEN
        X=X+(FTGUT(NGUT+1)/1d3)*1d5
       ENDIF
      ELSEIF(MCFLAG.EQ.5)THEN
       IF(DABS(MNEU(1)).GT.1d1)THEN
        X=X+(DABS(MNEU(1))/1d1)*1d5
       ENDIF
       X=X+FTGUT(NGUT+1)
      ELSEIF(MCFLAG.EQ.6)THEN
       X=X+DABS(MNEU(1))
      ELSEIF(MCFLAG.EQ.7)THEN
       X=X+DABS(MNEU(1))
       IF(FTGUT(NGUT+1).GT.1d3)THEN
        X=X+(FTGUT(NGUT+1)/1d3)*1d5
       ENDIF
      ELSEIF(MCFLAG.EQ.8)THEN
       X=X+DABS(MNEU(1))
       X=X+FTGUT(NGUT+1)
      ENDIF
      X=X+1d0

      PP=(X-XCEN)/(.28d0*XDEV*MIN(X,XCEN))
      PP=MAX(PP,-8d0*DLOG(10d0))
      PP=MIN(PP,8d0*DLOG(10d0))
      P=1d0/(1d0+DEXP(PP))
      XDUM=RAN2(IDUM)
!      WRITE(0,*)"X",XCEN,X
!      WRITE(0,*)"P",P,XDUM
      IF(P.GE.XDUM)THEN
!       WRITE(0,*)"OK",IFAIL
       XCEN=X
       M0CEN=M0
       M12CEN=M12
       A0CEN=A0
       TBCEN=PAR(3)
       LCEN=PAR(1)
       IF(ALFLAG.EQ.1)THEN
        ALCEN=ALINP
       ENDIF
       IF(AKFLAG.EQ.1)THEN
        AKCEN=AKINP
       ENDIF
       IF(M1FLAG.EQ.1)THEN
        M1CEN=M1INP
       ENDIF
       IF(M2FLAG.EQ.1)THEN
        M2CEN=M2INP
       ENDIF
       IF(M3FLAG.EQ.1)THEN
        M3CEN=M3INP
       ENDIF
       IF(MAFLAG.EQ.-1 .OR. MAFLAG.EQ.-2)THEN
        XIFCEN=XIFINP
       ELSE
        KCEN=PAR(2)
       ENDIF
       IF(MAFLAG.EQ.-1 .OR. MAFLAG.EQ.-3)THEN
        XISCEN=XISINP
       ELSE
        MSCEN=MSINP
       ENDIF
       IF(MAFLAG.EQ.-5)THEN
        MUCEN=PAR(4)
        KCEN=PAR(2)
        XIFCEN=XIFINP
        XISCEN=XISINP
       ELSE
        IF(MHDFLAG.EQ.1)THEN
         MHDCEN=MHDINP
        ENDIF
        IF(MHUFLAG.EQ.1)THEN
         MHUCEN=MHUINP
        ENDIF
       ENDIF
       MUPINP=MUPCEN
       MSPINP=MSPCEN
       M3HINP=M3HCEN
       Q2MEM=Q2
       DELMEM=DELMB
       XIFMEM=XIFGUT
       XISMEM=XISGUT
       MUMEM=MHUGUT
       MDMEM=MDGUT
       MSMEM=MSGUT
       DO I=1,25
        PARMEM(I)=PAR(I)
       ENDDO
!      ELSE
!       WRITE(0,*)"NO",IFAIL
      ENDIF
!      WRITE(0,*)""
!      WRITE(0,*)""

      END


C           SUBROUTINE FIT1
      SUBROUTINE FIT1
      REAL MFSTOP
      LOGICAL PREVER
      COMMON /SNTCP/G,AJ,PRPC,ICASE,PREVER,MFSTOP,JUMP,LOPIN,ISCASE,
     1KN,GAMF,IP,SCRIT,PTRN,ISECT,KSTG,WTOL,RHOTOL,PRTOL,TRLOOP,LSTG,
     2LBRC,IBRC,ICHOKE,ISORR,CHOKE,PT0PS1(6,8),PTRS2(6,8),TRDIAG,SC,RC,
     3DELPR,PASS,IPC,LOPC,ISS
C
      COMMON/GEBE/DRBARR,DRBARS,E1,E2,E3,E4,E5,E6,HBRRH,HBRSH,IAFE
     1,IALF,IBT2,ICPR,ICPS,ISR2,ISTR,ISTS,L,R1,R3,R4,R5,
     2TALF,WGT0(8),WT(7),HBARS,HBARR,I
C
      COMMON /SINIT/H1(6,8),H2(6,8),DP0(6,8),DP1(6,8),DP1A(6,8),DP2(6,8)
     1,DP2A(6,8),CSALF1(6,8),ALF1(6,8),CSBET2(6,8),BET2(6,8),RADSD(6,8),
     2RADRD(6,8),ANN1(6,8),ANN2(6,8),ANN2A(6,8),ANN1A(6,8),U1A(6,8),
     3U2(6,8),ANN0(6,8),PT0(6,8),TT0(6,8),ALPHA0(6,8),PTP(6,8)
C
      COMMON /SINPUT/
     1PTPS,PTIN,TTIN,WAIR,FAIR,DELC,DELL,DELA,AACS,VCTD,STG,SECT,EXPN,
     2EXPP,EXPRE,RG,RPM,PAF,SLI,STGCH,ENDJOB,XNAME(20),TITLE(20),
     3PCNH(6),GAM(6,8),DR(6,8),DT(6,8),RWG(6,8),ALPHAS(6,8),ALPHA1(6,8),
     4ETARS(6,8),ETAS(6,8),CFS(6,8),ANDO(6,8),BETA1(6,8),BETA2(6,8),ETAR
     5R(6,8),ETAR(6,8),CFR(6,8),TFR(6,8),ANDOR(6,8),OMEGAS(6,8),AS0(6,8)
     6,ASMP0(6,8),ACMN0(6,8),A1(6,8),A2(6,8),A3(6,8),A4(6,8),A5(6,8),A6(
     76,8),OMEGAR(6,8),BSIA(6,8),BSMPIA(6,8),BCMNIA(6,8),B1(6,8),B2(6,8)
     8,B3(6,8),B4(6,8),B5(6,8),B6(6,8),SESTHI(8),RERTHI(8)
     9,fairx(5,8),wairx(5,8),rg1(8),rg1a(8),rg2(8),rg2a(8)
C
      REAL M0
      COMMON /SSTA01/CP0(8),w0(6),               PS0(6,8),V0(6,8),TS0(6,
     18),VU0(6,8),VZ0(6,8),RHOS0(6,8),PS1(6,8),WGT1(8),TA1(8),WG1(6,8),
     2            DPDR1(6,8),SI(6,8),  CP1(8),PHI1(6,8),TS1(6,8),V1(6,8)
     3,RHOS1(6,8),ALF1E(6,8),VU1(6,8),VZ1(6,8),M0(6,8)
C
      REAL MR1A
      COMMON /SSTA1A/VU1A(6,8),WG1A(6,8),WGT1A(8),VZ1A(6,8),  CP1A(8),
     1PS1A(6,8),RU1A(6,8),R1A(6,8),BET1A(6,8),RI(6,8),TTR1A(6,8),PTR1A(6
     2,8),MR1A(6,8)
C
      COMMON /SSTA2/V2(6,8),TTR2(6,8),PTR2(6,8),WG2(6,8),WGT2(8),TA2(8),
     1           PS2(6,8),PHI2(6,8)
C
      REAL MR2,M2     ,MF2
      COMMON /SFLOW2/TS2(6,8),CP2(8),R2(6,8),RHOS2(6,8),BET2E(6,8),RU2(6
     1,8),VU2(6,8),DPDR2(6,8),VZ2(6,8),MR2(6,8),MF2(6,8),M2(6,8)
C
      REAL M2A,MF2A
      COMMON /SSTA2A/WG2A(6,8),WGT2A(8),VU2A(6,8),VZ2A(6,8),PS2A(6,8),
     1ALF2A(6,8),TT2A(6,8),PT2A(6,8),TTBAR(8),PTBAR(8),STT0(8),SPT0(8),
     2M2A(6,8),MF2A(6,8),CP2A(8),V2A(6,8),TS2A(6,8),TAS(8),PAS(8),GAMS(8
     3),CPO(8),DELHVD(6,8)
C
      COMMON /SOVRAL/DELHT(6,8),DELHTI(6,8),DELHSI(6,8),DEHATI(6,8),
     1ETATT(6,8),ETATS(6,8),ETATAT(6,8),delhtu(6,8)
C
      COMMON /BDINST/
     1IFMI01(4),IFMI02(4),IFMI03(4),IFMI04(4),IFMI05(4),IFMI06(4),
     2IFMI07(4),IFMI08(4),IFMI09(4),IFMI10(4),IFMI11(4),IFMI12(4),
     3IFMI13(4),IFMI14(4),IFMI15(4),IFMI16(4),IFMI17(4),IFMI18(4),
     4IFMI19(4),IFMI20(4),IFMI21(4),IFMI22(4),IFMI23(4),IFMI24(4),
     5IFMI25(4),IFMI26(4),IFMI27(4),IFMI28(4),IFMI29(4),IFMI30(4),
     6IFMI31(4),IFMI32(4),IFMI33(4),IFMI34(4),IFMI35(4),IFMI36(4),
     7IFMI37(4),IFMI38(4),IFMI39(4),IFMI40(4),IFMI41(4),IFMI42(4),
     8IFMI43(4),IFMI44(4),IFMI45(4),IFMI46(4),IFMI47(4),IFMI48(4),
     9IFMI49(4),IFMI50(4),IFMI51(4),IFMI52(4),IFMI53(4),IFMI54(4),
     1IFMI55(4),IFMI56(4),IFMI57(4),IFMI58(4),IFMI59(4),IFMI60(4),
     2IFMI61(4)
C
C    added name to COMMON BLOCK  ...  C1FIT1
C
C     COMMON    STDP0(7),STTT0(7),STPT0(7),STALF(7)
      COMMON /C1FIT1/   STDP0(7),STTT0(7),STPT0(7),STALF(7)
     1,STSI(7),STV0(7),STVU0(7),STVZ0(7),STTS0(7),
     2STPS0(7),STDEN0(7),STM0(7),STDP1(7),STTT1(7),
     3STALFE(7),STDELA(7),STV1(7),STVU1(7),STVZ1(7),
     4STTS1(7),STPS1(7),STDEN1(7),STM1(7),ZWIINC(7),
     5CPS(7),STDP1A(7),STTTR1(7),STPTR1(7),STBET1(7),
     6STRI(7),STR1A(7),STRU1A(7),STMR1A(7),STU1A(7),
     7STDP2(7),STBET2(7),SDBETA(7),SR2(7),SRU2(7),
     8SMR2(7),SU2(7),RX(7),STDELH(7),STPSI(7),
     9SETATT(7),SETATS(7),SETAAT(7),RZWINC(7),CPR(7),
     1STDP2A(7),STPT2(7),STTT2(7),STV2(7),STVU2(7),
     2STALF2(7),STMF2(7),STVZ2(7),STTS2(7),STPS2(7),
     3STDEN2(7),STM2(7),lj,jj,K
C    added name to COMMON BLOCK  ...  C2FIT1
C
C     COMMON   DBARS(7),FTANS(7),FAXS(7),DBARR(7),
      COMMON   /C2FIT1/ DBARS(7),FTANS(7),FAXS(7),DBARR(7),
     1FTANR(7),FAXR(7)
c     COMMON RES(6),DALF(6),DSTS(6),DALFE(6),DCPS(6),DSTR(6),
      COMMON RES(8),DALF(6),DSTS(6),DALFE(6),DCPS(6),DSTR(6),
     *DBT2(6),DCPR(6),DSR2(6)
      COMMON/TPT1/PT1(6),TT1(6,8)
      COMMON/DESOPT/RVU1(6,8),RVU2(6,8),WG,EPR
C
      DIMENSION IFMI1(4,61),Y(7,61)
      EQUIVALENCE (IFMI1(1,1),IFMI01(1)),(Y(1,1),STDP0(1))
C
C
C
      I=1
      L=1
      KF=ISECT-1
      CALL BESFIT(ISECT,DP0(1,K),ALPHA0(1,K),KF,DALF,RES)
      IALF=KF+1
      KF=ISECT-1
      CALL BESFIT(ISECT,DP0(1,K),   SI (1,K),KF,DSTS,RES)
      ISTS=KF+1
      KF=ISECT-1
      CALL BESFIT(ISECT,DP1(1,K),ALF1E (1,K),KF,DALFE,RES)
      IAFE=KF+1
      KF=ISECT-1
      CALL BESFIT(ISECT,DP1(1,K),ETAS(1,K),KF,DCPS,RES)
      ICPS=KF+1
      KF=ISECT-1
      CALL BESFIT(ISECT,DP1A(1,K),RI    (1,K),KF,DSTR ,RES)
      ISTR=KF+1
      KF=ISECT-1
      CALL BESFIT(ISECT,DP2 (1,K),BET2E   (1,K),KF,DBT2 ,RES)
      IBT2=KF+1
      KF=ISECT-1
      CALL BESFIT(ISECT,DP2(1,K),ETAR(1,K),KF,DCPR,RES)
      ICPR=KF+1
      KF=ISECT-1
      CALL BESFIT(ISECT,DP2 (1,K),R2      (1,K),KF,DSR2 ,RES)
      ISR2=KF+1
      IF(ISECT.EQ.4)L3=5
      STDP0(1)=DR(1,K)
      R1=DP0(I,K)/DR(I,K)
      STDP1(1)=DR(2,K)
      R2(1,1)=DP1(I,K)/DR(2,K)
      STDP1A(1)=DR(3,K)
      R3=DP1A(I,K)/DR(3,K)
      STDP2(L)=DR(4,K)
      R4=DP2(1,K)/DR(4,K)
      STDP2A(L)=DR(5,K)
      R5=DP2A(I,K)/DR(5,K)
      RETURN
      END


MODULE module_emissions_driver
   IMPLICIT NONE
CONTAINS
    subroutine emissions_driver(id,ktau,dtstep,DX, &
         adapt_step_flag,curr_secs, &
         plumerisefire_frq,stepfirepl, &
         bioemdt,stepbioe, &
         config_flags,gmt,julday,alt,t_phy,moist,p8w,t8w,u_phy, &
         v_phy,vvel,e_bio,p_phy,chem,rho_phy,dz8w,ne_area,emis_ant, &
         emis_vol,tsk,erod,g,emis_seas,emis_dust,tracer, &
         ebu, ebu_in,mean_fct_agtf,mean_fct_agef, &
         mean_fct_agsv,mean_fct_aggr,firesize_agtf,firesize_agef, &
         firesize_agsv,firesize_aggr, &
         u10,v10,ivgtyp,isltyp,gsw,vegfra,rmol,ust,znt,dms_0, &
         erup_beg,erup_end, &
         xland,xlat,xlong,z_at_w,z,smois,dustin,seasin, &
         sebio_iso,sebio_oli,sebio_api,sebio_lim,sebio_xyl, &
         sebio_hc3,sebio_ete,sebio_olt,sebio_ket,sebio_ald, &
         sebio_hcho,sebio_eth,sebio_ora2,sebio_co,sebio_nr, &
         sebio_sesq,sebio_mbo, &
         noag_grow,noag_nongrow,nononag,slai, &
         ebio_iso,ebio_oli,ebio_api,ebio_lim,ebio_xyl, &
         ebio_hc3,ebio_ete,ebio_olt,ebio_ket,ebio_ald, &
         ebio_hcho,ebio_eth,ebio_ora2,ebio_co,ebio_nr,ebio_no, &
         ebio_sesq, ebio_mbo, &
         ebio_c10h16,ebio_tol,ebio_bigalk,ebio_ch3oh,ebio_acet, &
         ebio_nh3,ebio_no2,ebio_c2h5oh,ebio_ch3cooh,ebio_mek, &
         ebio_bigene,ebio_c2h6,ebio_c2h4,ebio_c3h6,ebio_c3h8,ebio_so2, &
         ebio_dms, &
         ebio_alk3, ebio_alk4, ebio_alk5, ebio_ole1, ebio_ole2, &
         ebio_aro1, ebio_aro2, ebio_ccho, ebio_meoh, &
         ebio_ethene, ebio_hcooh, ebio_terp, ebio_bald, &
         ebio_cco_oh, ebio_rco_oh, &
         clayfrac,sandfrac,dust_alpha,dust_gamma,dust_smtune, &
         snowh,zs, &
         ebio_c5h8,ebio_apinene,ebio_bpinene,ebio_toluene, &
         ebio_ch3cho,ebio_ch3co2h,ebio_tbut2ene,ebio_c2h5cho, &
         ebio_nc4h10, &
         T2,swdown, &
         nmegan,EFmegan, &
         msebio_isop, &
         mlai, &
         pftp_bt, pftp_nt, pftp_sb, pftp_hb, &
         mtsa, &
         mswdown, &
         mebio_isop, mebio_apin, mebio_bpin, mebio_bcar, &
         mebio_acet, mebio_mbo, mebio_no, &
         current_month, &
         ht, refl_10cm, &
         ic_flashrate, cg_flashrate, &
         cldfra_cup, htop, &
         emis_aircraft, &
         vprm_in,rad_vprm,lambda_vprm,alpha_vprm,resp_vprm, &
         xtime,tslb,wet_in,rainc,rainnc,potevp,sfcevp,lu_index, &
         biomt_par,emit_par,ebio_co2oce,eghg_bio, &
         ids,ide, jds,jde, kds,kde, &
         ims,ime, jms,jme, kms,kme, &
         its,ite, jts,jte, kts,kte )
  USE module_configure
  USE module_state_description
  USE module_data_radm2
  USE module_data_sorgam, only : mw_so4_aer,anthfac,factnumn,factnuma,factnumc
  USE module_model_constants, only : mwdry
  USE module_emissions_anthropogenics
  USE module_bioemi_simple
  USE module_bioemi_beis314
  USE module_bioemi_megan2
  USE module_aerosols_sorgam, only: sorgam_addemiss
  USE module_cbmz_addemiss
  USE gocart_dust
  USE gocart_dust_afwa
  USE gocart_seasalt
  USE module_dms_emis
  USE module_mosaic_dmsemis
  USE module_mosaic_addemiss
  USE module_add_emis_cptec
  USE module_add_emiss_burn
  USE module_plumerise1
  USE module_aerosols_soa_vbs, only: soa_vbs_addemiss
  USE module_ghg_fluxes
  USE module_lightning_nox_driver
  USE module_cam_mam_addemiss, only: cam_mam_addemiss
  IMPLICIT NONE
   TYPE(grid_config_rec_type), INTENT(IN ) :: config_flags
   INTEGER, INTENT(IN ) :: id,julday, ne_area, &
                                  ids,ide, jds,jde, kds,kde, &
                                  ims,ime, jms,jme, kms,kme, &
                                  its,ite, jts,jte, kts,kte
   INTEGER, INTENT(IN ) :: &
                                  ktau,stepbioe,stepfirepl
   REAL, DIMENSION( ims:ime, kms:kme, jms:jme, num_moist ), &
         INTENT(IN ) :: moist
   REAL, DIMENSION( ims:ime, kms:kme, jms:jme, num_chem ), &
         INTENT(INOUT ) :: chem
   REAL, DIMENSION( ims:ime, kms:kme, jms:jme, num_tracer ), &
         INTENT(INOUT ) :: tracer
   REAL, DIMENSION( ims:ime, kms:kme, jms:jme, num_ebu ), &
         INTENT(INOUT ) :: ebu
   REAL, DIMENSION( ims:ime, 1, jms:jme, num_ebu_in ), &
         INTENT(INOUT ) :: ebu_in
   REAL, DIMENSION( ims:ime, jms:jme, ne_area ), &
         INTENT(INOUT ) :: e_bio
   REAL, DIMENSION( ims:ime, 1:config_flags%kemit, jms:jme,num_emis_ant),&
         INTENT(IN ) :: &
         emis_ant
   REAL, DIMENSION( ims:ime, kms:kme, jms:jme,num_emis_vol), &
         INTENT(INOUT ) :: &
         emis_vol
   REAL, DIMENSION( ims:ime, jms:jme),&
         INTENT(IN ) :: &
         dms_0,tsk,erup_beg,erup_end
   REAL, DIMENSION( ims:ime, jms:jme,3),&
         INTENT(IN ) :: &
         erod
   REAL, DIMENSION( ims:ime, jms:jme,5),&
         INTENT(INOUT ) :: &
         dustin,seasin
   REAL, DIMENSION( ims:ime, 1, jms:jme,num_emis_dust), &
         OPTIONAL, INTENT(INOUT ) :: &
         emis_dust
   REAL, DIMENSION( ims:ime, 1, jms:jme,num_emis_seas), &
         OPTIONAL, &
         INTENT(INOUT ) :: &
         emis_seas
   REAL, DIMENSION( ims:ime, jms:jme ), &
         OPTIONAL, &
         INTENT(IN ) :: &
           mean_fct_agtf,mean_fct_agef, &
           mean_fct_agsv,mean_fct_aggr,firesize_agtf,firesize_agef, &
           firesize_agsv,firesize_aggr
   REAL, DIMENSION( ims:ime , kms:kme , jms:jme ) , &
          INTENT(IN ) :: &
                                                        alt, &
                                                      t_phy, &
                                                      p_phy, &
                                                      dz8w, &
                                              t8w,p8w,z_at_w , z , &
                                              u_phy,v_phy,vvel,rho_phy
   INTEGER,DIMENSION( ims:ime , jms:jme ) , &
          INTENT(IN ) :: &
                                                     ivgtyp, &
                                                     isltyp
   REAL, DIMENSION( ims:ime , jms:jme ) , &
          INTENT(IN ) :: &
                                                     u10, &
                                                     v10, &
                                                     gsw, &
                                                  vegfra, &
                                                     rmol, &
                                                     ust, &
                                                     xland, &
                                                     xlat, &
                                                     xlong, &
                                                     znt, &
                                                     rainc, &
                                                     rainnc, &
                                                     potevp, &
                                                     sfcevp, &
                                                     lu_index
   REAL, DIMENSION( ims:ime , jms:jme ) , &
         OPTIONAL, &
         INTENT(IN ) :: &
                                                     clayfrac, &
                                                     sandfrac, &
                                                     snowh
   REAL, INTENT(IN ) :: dust_alpha, &
                                                     dust_gamma, &
                                                     dust_smtune
  REAL, DIMENSION( config_flags%num_soil_layers ) , &
      INTENT(IN ) :: zs
  REAL, DIMENSION( ims:ime, config_flags%num_soil_layers, jms:jme ) , &
      INTENT(INOUT ) :: smois, tslb
   REAL, DIMENSION( ims:ime , jms:jme ) , &
         OPTIONAL, &
          INTENT(INOUT ) :: &
               sebio_iso,sebio_oli,sebio_api,sebio_lim,sebio_xyl, &
               sebio_hc3,sebio_ete,sebio_olt,sebio_ket,sebio_ald, &
               sebio_hcho,sebio_eth,sebio_ora2,sebio_co,sebio_nr, &
               sebio_sesq,sebio_mbo, &
               noag_grow,noag_nongrow,nononag,slai, &
               ebio_iso,ebio_oli,ebio_api,ebio_lim,ebio_xyl, &
               ebio_hc3,ebio_ete,ebio_olt,ebio_ket,ebio_ald, &
               ebio_hcho,ebio_eth,ebio_ora2,ebio_co,ebio_nr,ebio_no, &
               ebio_sesq,ebio_mbo, &
               ebio_c10h16,ebio_tol,ebio_bigalk, ebio_ch3oh,ebio_acet, &
               ebio_nh3,ebio_no2,ebio_c2h5oh,ebio_ch3cooh,ebio_mek, &
               ebio_bigene,ebio_c2h6,ebio_c2h4,ebio_c3h6,ebio_c3h8, &
               ebio_so2,ebio_dms, ebio_co2oce , &
               ebio_alk3, ebio_alk4, ebio_alk5, ebio_ole1, ebio_ole2, &
               ebio_aro1, ebio_aro2, ebio_ccho, ebio_meoh, &
               ebio_ethene, ebio_hcooh, ebio_terp, ebio_bald, &
               ebio_cco_oh, ebio_rco_oh, &
               ebio_c5h8,ebio_apinene,ebio_bpinene,ebio_toluene, &
               ebio_ch3cho,ebio_ch3co2h,ebio_tbut2ene,ebio_c2h5cho, &
               ebio_nc4h10
   integer, intent(in ) :: nmegan
   real, dimension (ims:ime, jms:jme , nmegan) , &
         OPTIONAL, &
        intent(inout) :: &
        EFmegan
   real, dimension (ims:ime, jms:jme ) , &
         OPTIONAL, &
        intent(in) :: &
        msebio_isop, &
        pftp_bt, pftp_nt, pftp_sb, pftp_hb
   real, dimension (ims:ime, jms:jme, 12 ) , &
         OPTIONAL, &
        intent(in) :: &
        mlai, mtsa, mswdown
   real, dimension (ims:ime, jms:jme ) , &
         OPTIONAL, &
        intent(inout) :: &
        mebio_isop, mebio_apin, mebio_bpin, mebio_bcar, &
        mebio_acet, mebio_mbo, mebio_no
   real, dimension (ims:ime, jms:jme ) , &
        intent(in) :: &
        T2, swdown
   integer, intent(in) :: current_month
      REAL(KIND=8), INTENT(IN ) :: &
           curr_secs
      REAL :: gmtp,gmtm
      integer :: curr_hours,ivolcano
      Integer :: endhr,endmin,beghr,begmin,ko,kk4,kl,k_initial,k_final
      real :: emiss_ash_mass,emiss_ash_height,so2_mass,vert_mass_dist(kts:kte)
      real :: eh
      real :: area,x1,percen_mass_umbrel,base_umbrel,ashz_above_vent
      REAL, INTENT(IN ) :: &
           bioemdt, dtstep, dx, gmt, g
      INTEGER, INTENT(IN ) :: &
           plumerisefire_frq
      LOGICAL, INTENT(IN ) :: &
           adapt_step_flag
      REAL, DIMENSION( ims:ime, 1:config_flags%kemit_aircraft, jms:jme,num_emis_aircraft), &
            OPTIONAL, INTENT(IN ) :: emis_aircraft
      REAL, DIMENSION(ims:ime, 8, jms:jme, num_vprm_in), INTENT(IN) :: vprm_in
      REAL, DIMENSION(ims:ime, 1,jms:jme, num_eghg_bio), INTENT(INOUT ) :: eghg_bio
      REAL, DIMENSION(8) :: rad_vprm,lambda_vprm,alpha_vprm,resp_vprm
      REAL, DIMENSION(14), INTENT(IN) :: biomt_par, emit_par
      REAL, DIMENSION(ims:ime,1,jms:jme,num_wet_in), INTENT(IN) :: wet_in
      REAL, INTENT(IN) :: xtime
     REAL, DIMENSION( ims:ime, jms:jme ), INTENT(IN ) :: ht, ic_flashrate, cg_flashrate
     REAL, DIMENSION( ims:ime, kms:kme, jms:jme ), INTENT(IN ) :: refl_10cm
     REAL, DIMENSION( ims:ime, kms:kme, jms:jme ), INTENT(IN ) :: cldfra_cup
     REAL, DIMENSION( ims:ime, jms:jme ), INTENT(IN ) :: htop
      INTEGER :: begday,endday,i, j, k, ksub, dust_emiss_active, seasalt_emiss_active,emiss_ash_hgt
      REAL :: conv,conv3,conv4,oconv3,oconv4
      CHARACTER (LEN=80) :: message
      LOGICAL :: do_bioemiss, do_plumerisefire,do_ex_volcanoe
       percen_mass_umbrel=.75
       base_umbrel=.25
      ivolcano=0
      area=dx*dx
      dust_emiss_active = 0
      seasalt_emiss_active = 0
      if(config_flags%dust_opt >= 2 )dust_emiss_active = 1
      if(config_flags%seas_opt == 2 )seasalt_emiss_active = 1
      if(config_flags%seas_opt == 3 )seasalt_emiss_active = 3
      if(config_flags%seas_opt == 4 )seasalt_emiss_active = 4
      gmtp=curr_secs/3600.
      curr_hours=curr_secs/3600.
      gmtp=mod(gmt+gmtp,24.)
      gmtm=mod(gmtp,60.)
      if(config_flags%emiss_opt_vol == 1 .or. config_flags%emiss_opt_vol == 2)then
         do_ex_volcanoe = .false.
      emiss_ash_height = config_flags%emiss_ash_hgt
      if(emiss_ash_height.gt. 1.)then
      write(message,'(" ADJUSTED ASH HEIGHT: ",2f15.3)') emiss_ash_height, area
      CALL WRF_DEBUG (15,message)
      do j=jts,jte
      do i=its,ite
        if(erup_end(i,j).gt.0)then
        so2_mass=1.5e4*3600.*1.e9/64./area
        eh=2600.*(emiss_ash_height*.0005)**4.1494
        emiss_ash_mass=eh*1.e9/area
        ashz_above_vent=emiss_ash_height + z_at_w(i,kts,j)
      write(message,'("Found and adjusted active volcano at j,kts,kpe = ",3i8)') j,kts,kte
      call wrf_message (message)
        do k=kte-1,kts,-1
           if(z_at_w(i,k,j) < ashz_above_vent)then
             k_final=k+1
             exit
           endif
        enddo
        do k=kte-1,kts,-1
          if(z_at_w(i,k,j) < (1.-base_umbrel)*ashz_above_vent)then
             k_initial=k
             exit
           endif
        enddo
        vert_mass_dist=0.
          kk4 = k_final-k_initial+2
          do ko=1,kk4-1
              kl=ko+k_initial-1
              vert_mass_dist(kl) = 6.*percen_mass_umbrel* float(ko) &
                           /float(kk4)**2 * (1. - float(ko)/float(kk4))
          enddo
          if(sum(vert_mass_dist(kts:kte)) .ne. percen_mass_umbrel) then
            x1= ( percen_mass_umbrel- sum(vert_mass_dist(kts:kte)) ) &
                 /float(k_final-k_initial+1)
              do ko=k_initial,k_final
                vert_mass_dist(ko) = vert_mass_dist(ko)+ x1
              enddo
          endif
          do ko=1,k_initial-1
             vert_mass_dist(ko)=float(ko)/float(k_initial-1)
          enddo
          x1=sum(vert_mass_dist(1:k_initial-1))
          do ko=1,k_initial-1
              vert_mass_dist(ko)=(1.-percen_mass_umbrel)*vert_mass_dist(ko)/x1
          enddo
          do ko=1,k_final
            emis_vol(i,ko,j,p_e_vash1)=.22*vert_mass_dist(ko)*emiss_ash_mass
            emis_vol(i,ko,j,p_e_vash2)=.05*vert_mass_dist(ko)*emiss_ash_mass
            emis_vol(i,ko,j,p_e_vash3)=.4*vert_mass_dist(ko)*emiss_ash_mass
            emis_vol(i,ko,j,p_e_vash4)=.05*vert_mass_dist(ko)*emiss_ash_mass
            emis_vol(i,ko,j,p_e_vash5)=.245*vert_mass_dist(ko)*emiss_ash_mass
            emis_vol(i,ko,j,p_e_vash6)=.12*vert_mass_dist(ko)*emiss_ash_mass
            emis_vol(i,ko,j,p_e_vash7)=.11*vert_mass_dist(ko)*emiss_ash_mass
            emis_vol(i,ko,j,p_e_vash8)=.08*vert_mass_dist(ko)*emiss_ash_mass
            emis_vol(i,ko,j,p_e_vash9)=.05*vert_mass_dist(ko)*emiss_ash_mass
            emis_vol(i,ko,j,p_e_vash10)=.035*vert_mass_dist(ko)*emiss_ash_mass
            if(config_flags%emiss_opt_vol == 2)emis_vol(i,ko,j,p_e_vso2)=vert_mass_dist(ko)*so2_mass
          enddo
          do ko=k_final+1,kte
           emis_vol(i,ko,j,p_e_vash1)=0.
           emis_vol(i,ko,j,p_e_vash2)=0.
           emis_vol(i,ko,j,p_e_vash3)=0.
           emis_vol(i,ko,j,p_e_vash4)=0.
           emis_vol(i,ko,j,p_e_vash5)=0.
           emis_vol(i,ko,j,p_e_vash6)=0.
           emis_vol(i,ko,j,p_e_vash7)=0.
           emis_vol(i,ko,j,p_e_vash8)=0.
           emis_vol(i,ko,j,p_e_vash9)=0.
           emis_vol(i,ko,j,p_e_vash10)=0.
           if(config_flags%emiss_opt_vol == 2)emis_vol(i,ko,j,p_e_vso2)=0.
         enddo
      endif
      enddo
      enddo
     else
     endif
      do j=jts,jte
      do i=its,ite
         ivolcano = 0
        if(erup_end(i,j).le.0)cycle
         begday=int(erup_beg(i,j)/1000.)-1
         beghr=int(erup_beg(i,j))-(begday+1)*1000
         begmin=00.
         endhr=beghr+int(erup_end(i,j)/60.)
         endday=int(begday+endhr/24)-1
         endmin=00.
         ivolcano = 1
         if(julday.le.begday .or. julday.ge.endday)then
            if( julday.lt.begday)then
                 write(message,'("before volcano stuff at julday = ",i8)') julday
                 call wrf_debug(15,message)
                 ivolcano=0
            elseif(julday.eq.begday)then
               if(beghr.gt.int(gmtp))then
                 write(message,'("before volcano stuff at gmtp = ",i8)') int(gmtp)
                 call wrf_debug(15,message)
                 ivolcano=0
               elseif(beghr.eq.int(gmtp))then
                  if(begmin.gt.gmtm)then
                     write(message,'("before volcano stuff at gmtp,begmin = ",2i8)') int(gmtp),int(begmin)
                     call wrf_debug(15,message)
                     ivolcano=0
                  endif
               endif
            endif
            if( julday.gt.endday)then
                 write(message,'("after volcano stuff at julday = ",i8)') julday
                 call wrf_debug(15,message)
                 ivolcano=0
            elseif(julday.eq.endday)then
               if(endhr.lt.int(gmtp))then
                 write(message,'("after volcano stuff at gmtp = ",i8)') int(gmtp)
                 call wrf_debug(15,message)
                 ivolcano=0
               elseif(endhr.eq.int(gmtp))then
                  if(endmin.lt.gmtm)then
                     write(message,'("after volcano stuff at gmtm,endmin = ",2i8)') int(gmtm),int(endmin)
                     call wrf_debug(15,message)
                     ivolcano=0
                  endif
               endif
            endif
         endif
      volc_select: SELECT CASE(config_flags%chem_opt)
      CASE (GOCART_SIMPLE,MOZCART_KPP,GOCARTRADM2,GOCARTRACM_KPP,GOCARTRADM2_KPP)
        CALL wrf_debug(15,'Adding volcanic emissions')
                  do k=kts,kte
                    conv = 4.828e-4/rho_phy(i,k,j)*dtstep/(dz8w(i,k,j)*60.)
                    chem(i,k,j,p_so2) = chem(i,k,j,p_so2) &
                     +emis_vol(i,k,j,p_e_vso2)*conv
                  enddo
               do k=kts,kte
                conv=float(ivolcano)*alt(i,k,j)*dtstep/dz8w(i,k,j)
                chem(i,k,j,p_p25)=chem(i,k,j,p_p25)+.5*emis_vol(i,k,j,p_e_vash10)*conv
                chem(i,k,j,p_p10)=chem(i,k,j,p_p10) &
                                 +.5*emis_vol(i,k,j,p_e_vash10)*conv &
                                 +emis_vol(i,k,j,p_e_vash9)*conv &
                                 +.5*emis_vol(i,k,j,p_e_vash8)*conv
               enddo
      CASE (RADM2SORG,RADM2SORG_AQ,RADM2SORG_KPP,RACMSORG_KPP,RACMSORG_AQ,RACM_ESRLSORG_KPP, &
            RACMSORG_AQCHEM_KPP,RACM_ESRLSORG_AQCHEM_KPP)
                  do k=kts,kte
                    conv = float(ivolcano)*4.828e-4/rho_phy(i,k,j)*dtstep/(dz8w(i,k,j)*60.)
                    chem(i,k,j,p_so2) = chem(i,k,j,p_so2) &
                     +emis_vol(i,k,j,p_e_vso2)*conv
                    conv=alt(i,k,j)*dtstep/dz8w(i,k,j)
                    chem(i,k,j,p_p25i) = chem(i,k,j,p_p25i) &
                     +.25*emis_vol(i,k,j,p_e_vash10)*conv
                    chem(i,k,j,p_nu0) = chem(i,k,j,p_nu0) &
                     +.25*anthfac*factnumn*emis_vol(i,k,j,p_e_vash10)*conv
                    chem(i,k,j,p_ac0) = chem(i,k,j,p_ac0) &
                     +.75*anthfac*factnuma*emis_vol(i,k,j,p_e_vash10)*conv
                    chem(i,k,j,p_p25j) = chem(i,k,j,p_p25j) &
                     +.75*emis_vol(i,k,j,p_e_vash10)*conv
                    chem(i,k,j,p_antha) = chem(i,k,j,p_antha) &
                     +emis_vol(i,k,j,p_e_vash9)*conv
                    chem(i,k,j,p_corn) = chem(i,k,j,p_corn) &
                     +anthfac*factnumc*emis_vol(i,k,j,p_e_vash9)*conv
                  enddo
      CASE (CHEM_VOLC)
              CALL wrf_debug(15,'Adding volcanic emissions to case chem_volc')
               do k=kts,kte
                 conv = float(ivolcano)*4.828e-4/rho_phy(i,k,j)*dtstep/(dz8w(i,k,j)*60.)
                 chem(i,k,j,p_so2) = chem(i,k,j,p_so2) &
                  +emis_vol(i,k,j,p_e_vso2)*conv
               enddo
               do k=kts,kte
                conv=float(ivolcano)*alt(i,k,j)*dtstep/dz8w(i,k,j)
                chem(i,k,j,p_vash_1)=chem(i,k,j,p_vash_1)+emis_vol(i,k,j,p_e_vash1)*conv
                chem(i,k,j,p_vash_2)=chem(i,k,j,p_vash_2)+emis_vol(i,k,j,p_e_vash2)*conv
                chem(i,k,j,p_vash_3)=chem(i,k,j,p_vash_3)+emis_vol(i,k,j,p_e_vash3)*conv
                chem(i,k,j,p_vash_4)=chem(i,k,j,p_vash_4)+emis_vol(i,k,j,p_e_vash4)*conv
                chem(i,k,j,p_vash_5)=chem(i,k,j,p_vash_5)+emis_vol(i,k,j,p_e_vash5)*conv
                chem(i,k,j,p_vash_6)=chem(i,k,j,p_vash_6)+emis_vol(i,k,j,p_e_vash6)*conv
                chem(i,k,j,p_vash_7)=chem(i,k,j,p_vash_7)+emis_vol(i,k,j,p_e_vash7)*conv
                chem(i,k,j,p_vash_8)=chem(i,k,j,p_vash_8)+emis_vol(i,k,j,p_e_vash8)*conv
                chem(i,k,j,p_vash_9)=chem(i,k,j,p_vash_9)+emis_vol(i,k,j,p_e_vash9)*conv
                chem(i,k,j,p_vash_10)=chem(i,k,j,p_vash_10)+emis_vol(i,k,j,p_e_vash10)*conv
               enddo
      CASE (CHEM_VOLC_4BIN)
               CALL wrf_debug(15,'Adding volcanic emissions to case chem_volc_4bin')
               do k=kts,kte
                conv=float(ivolcano)*alt(i,k,j)*dtstep/dz8w(i,k,j)
                chem(i,k,j,p_vash_7)=chem(i,k,j,p_vash_7)+emis_vol(i,k,j,p_e_vash7)*conv
                chem(i,k,j,p_vash_8)=chem(i,k,j,p_vash_8)+emis_vol(i,k,j,p_e_vash8)*conv
                chem(i,k,j,p_vash_9)=chem(i,k,j,p_vash_9)+emis_vol(i,k,j,p_e_vash9)*conv
                chem(i,k,j,p_vash_10)=chem(i,k,j,p_vash_10)+emis_vol(i,k,j,p_e_vash10)*conv
               enddo
      CASE (CHEM_VASH)
               CALL wrf_debug(15,'Adding volcanic emissions to case chem_volc')
               do k=kts,kte
                conv=float(ivolcano)*alt(i,k,j)*dtstep/dz8w(i,k,j)
                chem(i,k,j,p_vash_1)=chem(i,k,j,p_vash_1)+emis_vol(i,k,j,p_e_vash1)*conv
                chem(i,k,j,p_vash_2)=chem(i,k,j,p_vash_2)+emis_vol(i,k,j,p_e_vash2)*conv
                chem(i,k,j,p_vash_3)=chem(i,k,j,p_vash_3)+emis_vol(i,k,j,p_e_vash3)*conv
                chem(i,k,j,p_vash_4)=chem(i,k,j,p_vash_4)+emis_vol(i,k,j,p_e_vash4)*conv
                chem(i,k,j,p_vash_5)=chem(i,k,j,p_vash_5)+emis_vol(i,k,j,p_e_vash5)*conv
                chem(i,k,j,p_vash_6)=chem(i,k,j,p_vash_6)+emis_vol(i,k,j,p_e_vash6)*conv
                chem(i,k,j,p_vash_7)=chem(i,k,j,p_vash_7)+emis_vol(i,k,j,p_e_vash7)*conv
                chem(i,k,j,p_vash_8)=chem(i,k,j,p_vash_8)+emis_vol(i,k,j,p_e_vash8)*conv
                chem(i,k,j,p_vash_9)=chem(i,k,j,p_vash_9)+emis_vol(i,k,j,p_e_vash9)*conv
                chem(i,k,j,p_vash_10)=chem(i,k,j,p_vash_10)+emis_vol(i,k,j,p_e_vash10)*conv
               enddo
      CASE DEFAULT
      END SELECT volc_select
      enddo
      enddo
      ENDIF
      do_plumerisefire = .false.
      IF ( config_flags%biomass_burn_opt == BIOMASSB_MOZC .OR. &
           config_flags%biomass_burn_opt == BIOMASSB_MOZ .OR. &
           config_flags%biomass_burn_opt == BIOMASSB_SAPRC .OR. &
           config_flags%biomass_burn_opt == BIOMASSB_GHG .OR. &
           config_flags%biomass_burn_opt == BIOMASSB ) then
        IF ( ktau==1 ) then
           do_plumerisefire = .true.
        ELSE IF ( adapt_step_flag ) THEN
           IF ( (plumerisefire_frq<=0) .or. &
                ( curr_secs+real(dtstep,8)+0.01 >= &
                ( INT( curr_secs/real(plumerisefire_frq*60.,8)+1,8 )*real(plumerisefire_frq*60.,8) ) ) &
                ) then
              do_plumerisefire = .true.
           ENDIF
        ELSE IF ( (MOD(ktau,stepfirepl)==0) .or. (stepfirepl==1) ) THEN
           do_plumerisefire = .true.
        ENDIF
      ENDIF
      do_bioemiss = .false.
      IF ( ktau==1 ) then
         do_bioemiss = .true.
      ELSE IF ( adapt_step_flag ) THEN
         IF ( (bioemdt<=0) .or. &
              ( curr_secs+real(dtstep,8)+0.01 >= &
              ( INT( curr_secs/real(bioemdt*60.,8)+1,8 )*real(bioemdt*60.,8) ) ) &
              ) then
            do_bioemiss = .true.
         ENDIF
      ELSE IF ( (MOD(ktau,stepbioe)==0) .or. (stepbioe==1) ) THEN
         do_bioemiss = .true.
      ENDIF
       if( do_plumerisefire )then
          CALL wrf_debug(15,'fire emissions: calling biomassb')
          write(0,*)ktau,stepfirepl
          call plumerise_driver (id,ktau,dtstep, &
           ebu,ebu_in, &
           mean_fct_agtf,mean_fct_agef,mean_fct_agsv,mean_fct_aggr, &
           firesize_agtf,firesize_agef,firesize_agsv,firesize_aggr, &
           config_flags, t_phy,moist, &
           rho_phy,vvel,u_phy,v_phy,p_phy, &
           emis_ant,z_at_w,z,config_flags%scale_fire_emiss, &
           ids,ide, jds,jde, kds,kde, &
           ims,ime, jms,jme, kms,kme, &
           its,ite, jts,jte, kts,kte )
        endif
      tracer_select: SELECT CASE(config_flags%tracer_opt)
      CASE (TRACER_SMOKE,TRACER_TEST2)
          CALL wrf_debug(15,'tracer fire emissions: calling biomassb, only CO')
       call add_emis_burn(id,dtstep,ktau,dz8w,rho_phy,tracer,&
            julday,gmt,xlat,xlong,t_phy,p_phy, &
            alt, &
            ebu,0,config_flags%tracer_opt,config_flags%biomass_burn_opt, &
            num_tracer,ids,ide, jds,jde, kds,kde, &
            ims,ime, jms,jme, kms,kme, &
            its,ite, jts,jte, kts,kte )
      CASE DEFAULT
        CALL wrf_debug(15,'No tracer option selected')
      END SELECT tracer_select
      seasalt_select: SELECT CASE(config_flags%seas_opt)
      CASE (SEASGOCART)
        CALL wrf_debug(15,'Gocart sea salt emissions')
         call gocart_seasalt_driver(ktau,dtstep,config_flags,julday,alt,t_phy,moist,u_phy, &
         v_phy,chem,rho_phy,dz8w,u10,v10,p8w,z_at_w, &
         xland,xlat,xlong,dx,g,emis_seas, seasin,&
         ids,ide, jds,jde, kds,kde, &
         ims,ime, jms,jme, kms,kme, &
         its,ite, jts,jte, kts,kte )
      CASE DEFAULT
        if(seasalt_emiss_active.eq.1) then
           CALL wrf_debug(15,'MOSAIC or SORGAM sea salt emissions')
        elseif(seasalt_emiss_active.eq.3) then
           CALL wrf_debug(15,'MOSAIC sea salt emissions (Fuentes et al) - low activity')
        elseif(seasalt_emiss_active.eq.4) then
           CALL wrf_debug(15,'MOSAIC sea salt emissions (Fuentes et al) - high activity')
        else
           CALL wrf_debug(15,'no sea salt emissions')
        end if
      END SELECT seasalt_select
      dust_select: SELECT CASE(config_flags%dust_opt)
      CASE (DUSTGOCART)
        CALL wrf_debug(15,'Gocart dust emissions')
        call gocart_dust_driver(ktau,dtstep,config_flags,julday,alt,t_phy,moist,u_phy, &
         v_phy,chem,rho_phy,dz8w,smois,u10,v10,p8w,erod,dustin, &
         ivgtyp,isltyp,vegfra,xland,xlat,xlong,gsw,dx,g,emis_dust, &
         ids,ide, jds,jde, kds,kde, &
         ims,ime, jms,jme, kms,kme, &
         its,ite, jts,jte, kts,kte )
      CASE (DUSTGOCARTAFWA)
        CALL wrf_debug(15,'AFWA modified Gocart dust emissions')
        call gocart_dust_afwa_driver(ktau,dtstep,config_flags,julday,alt,t_phy,moist,u_phy, &
         v_phy,chem,rho_phy,dz8w,smois,u10,v10,p8w,erod,dustin,snowh,zs, &
         ivgtyp,isltyp,vegfra,xland,xlat,xlong,gsw,dx,g,emis_dust, &
         ust,znt,clayfrac,sandfrac,dust_alpha,dust_gamma,dust_smtune, &
         ids,ide, jds,jde, kds,kde, &
         ims,ime, jms,jme, kms,kme, &
         its,ite, jts,jte, kts,kte )
      CASE DEFAULT
        if(dust_emiss_active.eq.1) then
            CALL wrf_debug(15,'MOSAIC or SORGAM dust emissions')
        else
             CALL wrf_debug(15,'no dust emissions')
        end if
      END SELECT dust_select
      dms_select: SELECT CASE(config_flags%dmsemis_opt)
      CASE (DMSGOCART)
        CALL wrf_debug(15,'Gocart dms emissions')
        call gocart_dmsemis(dtstep,config_flags,alt,t_phy,u_phy, &
         v_phy,chem,rho_phy,dz8w,u10,v10,p8w,dms_0,tsk, &
         ivgtyp,isltyp,xland,dx,g, &
         ids,ide, jds,jde, kds,kde, &
         ims,ime, jms,jme, kms,kme, &
         its,ite, jts,jte, kts,kte )
      CASE (DMSMOSAIC)
        CALL wrf_debug(15,'MOSAIC dms emissions')
        call mosaic_dmsemis( id, dtstep, dz8w, config_flags, &
         u_phy, v_phy, rho_phy, chem,emis_ant,alt, &
         u10, v10, xland, tsk, &
         ids,ide, jds,jde, kds,kde, &
         ims,ime, jms,jme, kms,kme, &
         its,ite, jts,jte, kts,kte )
      CASE DEFAULT
        CALL wrf_debug(15,'no dms emissions')
      END SELECT dms_select
    ksub=0
    fire_select: SELECT CASE(config_flags%biomass_burn_opt)
     CASE (BIOMASSB,BIOMASSB_MOZC,BIOMASSB_MOZ,BIOMASSB_SAPRC,BIOMASSB_GHG)
       CALL wrf_debug(15,'fire emissions: adding biomassb emissions')
       call add_emis_burn(id,dtstep,ktau,dz8w,rho_phy,chem,&
            julday,gmt,xlat,xlong,t_phy,p_phy, &
            alt, &
            ebu,config_flags%chem_opt,0,config_flags%biomass_burn_opt, &
            num_chem,ids,ide, jds,jde, kds,kde, &
            ims,ime, jms,jme, kms,kme, &
            its,ite, jts,jte, kts,kte )
     CASE DEFAULT
       CALL wrf_debug(15,'no biomass burning')
    END SELECT fire_select
    bioem_select: SELECT CASE(config_flags%bio_emiss_opt)
     CASE (GUNTHER1)
       if(ktau.eq.1.or.mod(ktau,stepbioe).eq.0)then
          CALL wrf_debug(15,'biogenic emissions: calling Gunther1')
          call bio_emissions(id,ktau,dtstep,DX,config_flags, &
               gmt,julday,t_phy,moist,p8w,t8w, &
               e_bio,p_phy,chem,rho_phy,dz8w,ne_area, &
               ivgtyp,gsw,vegfra,rmol,ust,znt,xlat,xlong,z_at_w, &
               ids,ide, jds,jde, kds,kde, &
               ims,ime, jms,jme, kms,kme, &
               its,ite, jts,jte, kts,kte )
       endif
     CASE (BEIS314)
       if( do_bioemiss ) then
         beis314_check_mechanism_ok: SELECT CASE(config_flags%chem_opt)
            CASE (RADM2, RADM2_KPP, RADM2SORG, RADM2SORG_AQ, RADM2SORG_AQCHEM, RADM2SORG_KPP, &
                  RACM_KPP, RACMPM_KPP, RACM_MIM_KPP, RACMSORG_AQ,RACMSORG_AQCHEM_KPP, &
                  RACM_ESRLSORG_AQCHEM_KPP, RACMSORG_KPP,RACM_ESRLSORG_KPP, RACM_SOA_VBS_KPP, &
                  CBM4_KPP, NMHC9_KPP, GOCARTRACM_KPP,GOCARTRADM2,GOCARTRADM2_KPP)
            CASE DEFAULT
               CALL wrf_error_fatal3("<stdin>",807,&
                  "emissions_driver: beis3.1.4 biogenic emis. implemented for RADM2 & RACM only")
         END SELECT beis314_check_mechanism_ok
         CALL wrf_debug(15,'biogenic emissions: calling beis3.1.4')
         call bio_emissions_beis314(id,config_flags,ktau,curr_secs, &
               dtstep,julday,gmt,xlat,xlong,t_phy,p_phy,gsw, &
               sebio_iso,sebio_oli,sebio_api,sebio_lim,sebio_xyl, &
               sebio_hc3,sebio_ete,sebio_olt,sebio_ket,sebio_ald, &
               sebio_hcho,sebio_eth,sebio_ora2,sebio_co,sebio_nr, &
               sebio_sesq,sebio_mbo, &
               noag_grow,noag_nongrow,nononag,slai, &
               ebio_iso,ebio_oli,ebio_api,ebio_lim,ebio_xyl, &
               ebio_hc3,ebio_ete,ebio_olt,ebio_ket,ebio_ald, &
               ebio_hcho,ebio_eth,ebio_ora2,ebio_co,ebio_nr,ebio_no, &
               ebio_sesq,ebio_mbo, &
               ids,ide, jds,jde, kds,kde, &
               ims,ime, jms,jme, kms,kme, &
               its,ite, jts,jte, kts,kte )
       endif
     CASE (MEGAN2)
       if(ktau.eq.1.or.mod(ktau,stepbioe).eq.0)then
         CALL wrf_debug(15,'biogenic emissions: calling megan v2.04')
         call bio_emissions_megan2(id,config_flags,ktau,dtstep, &
               curr_secs,julday,gmt,xlat,xlong,p_phy,rho_phy,dz8w, &
               chem,ne_area, &
               current_month, &
               T2,swdown, &
               nmegan, EFmegan, msebio_isop, &
               mlai, &
               pftp_bt, pftp_nt, pftp_sb, pftp_hb, &
               mtsa, &
               mswdown, &
               mebio_isop, mebio_apin, mebio_bpin, mebio_bcar, &
               mebio_acet, mebio_mbo, mebio_no, &
               ebio_iso,ebio_oli,ebio_api,ebio_lim, &
               ebio_hc3,ebio_ete,ebio_olt,ebio_ket,ebio_ald, &
               ebio_hcho,ebio_eth,ebio_ora2,ebio_co,ebio_no, &
               ebio_c10h16,ebio_tol,ebio_bigalk, ebio_ch3oh,ebio_acet, &
               ebio_nh3,ebio_no2,ebio_c2h5oh,ebio_ch3cooh,ebio_mek, &
               ebio_bigene,ebio_c2h6,ebio_c2h4,ebio_c3h6,ebio_c3h8,ebio_so2, &
               ebio_dms, &
               ebio_c5h8,ebio_apinene,ebio_bpinene,ebio_toluene, &
               ebio_ch3cho,ebio_ch3co2h,ebio_tbut2ene,ebio_c2h5cho, &
               ebio_nc4h10, &
               ebio_sesq, ebio_mbo, &
               ebio_alk3, ebio_alk4, ebio_alk5, ebio_ole1, ebio_ole2, &
               ebio_aro1, ebio_aro2, ebio_ccho, ebio_meoh, &
               ebio_ethene, ebio_hcooh, ebio_terp, ebio_bald, &
               ebio_cco_oh, ebio_rco_oh, &
               e_bio, &
               ids,ide, jds,jde, kds,kde, &
               ims,ime, jms,jme, kms,kme, &
               its,ite, jts,jte, kts,kte )
       endif
     CASE DEFAULT
       if( do_bioemiss ) &
            e_bio(its:ite,jts:jte,1:ne_area) = 0.
    END SELECT bioem_select
    gas_addemiss_select: SELECT CASE(config_flags%chem_opt)
    CASE (RADM2, RADM2_KPP, RADM2SORG, RADM2SORG_AQ, RADM2SORG_AQCHEM, RADM2SORG_KPP, &
          RACM_KPP, RACMPM_KPP, RACM_MIM_KPP, RACMSORG_AQ, RACMSORG_AQCHEM_KPP, RACM_ESRLSORG_AQCHEM_KPP, RACMSORG_KPP, &
          RACM_SOA_VBS_KPP, RACM_ESRLSORG_KPP, MOZART_KPP, MOZCART_KPP, MOZART_MOSAIC_4BIN_VBS0_KPP, CRIMECH_KPP, &
          CRI_MOSAIC_8BIN_AQ_KPP, CRI_MOSAIC_4BIN_AQ_KPP )
       IF(config_flags%emiss_inpt_opt /= 3 ) then
       IF(config_flags%kemit .GT. kte-ksub) THEN
         k=config_flags%kemit
         write(message,'(" WARNING: EMISSIONS_DRIVER: KEMIT > KTE ",3i6)') kme,kte-ksub,k
         CALL WRF_MESSAGE (message)
       ENDIF
       call wrf_debug(15,'emissions_driver calling add_anthropogenics')
       call add_anthropogenics(id,dtstep,dz8w,config_flags,rho_phy,alt, &
            chem, emis_ant,emis_aircraft, &
            ids,ide, jds,jde, kds,kde, &
            ims,ime, jms,jme, kms,kme, &
            its,ite, jts,jte, kts,kte )
       call wrf_debug(15,'emissions_driver calling add_biogenics')
       call add_biogenics(id,dtstep,dz8w,config_flags, rho_phy,chem, &
            e_bio,ne_area, &
            ebio_iso,ebio_oli,ebio_api,ebio_lim,ebio_xyl, &
            ebio_hc3,ebio_ete,ebio_olt,ebio_ket,ebio_ald, &
            ebio_hcho,ebio_eth,ebio_ora2,ebio_co,ebio_nr,ebio_no, &
            ebio_sesq,ebio_mbo, &
            ids,ide, jds,jde, kds,kde, &
            ims,ime, jms,jme, kms,kme, &
            its,ite, jts,jte, kts,kte )
       end if
    IF(config_flags%emiss_opt == 10 ) then
       do j=jts,jte
          do i=its,ite
             do k=kts,min(config_flags%kemit,kte-ksub)
                conv = 4.828e-4/rho_phy(i,k,j)*dtstep/(dz8w(i,k,j)*60.)
                chem(i,k,j,p_voca) = chem(i,k,j,p_voca) &
                     +emis_ant(i,k,j,p_e_co_a)*conv*0.08*28./250.
                chem(i,k,j,p_vocbb) = chem(i,k,j,p_vocbb) &
                     +emis_ant(i,k,j,p_e_co_bb)*conv*0.08*28./250.
             end do
          end do
       end do
     endif
    CASE (CBMZ, CBMZ_BB, CBMZ_BB_KPP, CBMZ_MOSAIC_4BIN, CBMZ_MOSAIC_8BIN, &
          CBMZ_MOSAIC_4BIN_AQ, CBMZ_MOSAIC_8BIN_AQ, &
          CBMZSORG, CBMZSORG_AQ, CBMZ_MOSAIC_DMS_4BIN, CBMZ_MOSAIC_DMS_8BIN, &
          CBMZ_SORGAM_KPP,CBMZ_MOSAIC_KPP, CBMZ_MOSAIC_8BIN_VBS9_KPP,CBMZ_MOSAIC_4BIN_VBS9_KPP,&
          CBMZ_MOSAIC_DMS_4BIN_AQ, CBMZ_MOSAIC_DMS_8BIN_AQ, &
          CBMZ_CAM_MAM3_NOAQ, CBMZ_CAM_MAM3_AQ, CBMZ_CAM_MAM7_NOAQ, CBMZ_CAM_MAM7_AQ)
       IF(config_flags%kemit .GT. kte-ksub) THEN
          message = ' EMISSIONS_DRIVER: KEMIT > KME '
          CALL wrf_error_fatal3("<stdin>",945,&
message)
       ENDIF
       call wrf_debug(15,'emissions_driver calling cbmz_addemiss_anthro')
       call cbmz_addemiss_anthro( id, dtstep, dz8w, config_flags, &
            rho_phy, chem, &
            emis_ant,alt,ids,ide, jds,jde, kds,kde, &
            ims,ime, jms,jme, kms,kme, &
            its,ite, jts,jte, kts,kte )
       call wrf_debug(15,'emissions_driver calling cbmz_addemiss_bio')
       call add_biogenics(id,dtstep,dz8w,config_flags, rho_phy,chem, &
            e_bio,ne_area, &
            ebio_iso,ebio_oli,ebio_api,ebio_lim,ebio_xyl, &
            ebio_hc3,ebio_ete,ebio_olt,ebio_ket,ebio_ald, &
            ebio_hcho,ebio_eth,ebio_ora2,ebio_co,ebio_nr,ebio_no, &
            ebio_sesq,ebio_mbo, &
            ids,ide, jds,jde, kds,kde, &
            ims,ime, jms,jme, kms,kme, &
            its,ite, jts,jte, kts,kte )
    CASE (CHEM_TRACER)
       do j=jts,jte
          do i=its,ite
             do k=kts,min(config_flags%kemit,kte-ksub)
                conv = 4.828e-4/rho_phy(i,k,j)*dtstep/(dz8w(i,k,j)*60.)
                chem(i,k,j,p_so2) = chem(i,k,j,p_so2) &
                     +emis_ant(i,k,j,p_e_so2)*conv
                chem(i,k,j,p_co) = chem(i,k,j,p_co) &
                     +emis_ant(i,k,j,p_e_co)*conv
                chem(i,k,j,p_no) = chem(i,k,j,p_no) &
                     +emis_ant(i,k,j,p_e_co)*conv
                chem(i,k,j,p_ald) = chem(i,k,j,p_ald) &
                     +emis_ant(i,k,j,p_e_co)*conv
                chem(i,k,j,p_hcho) = chem(i,k,j,p_hcho) &
                     +emis_ant(i,k,j,p_e_co)*conv
                chem(i,k,j,p_ora2) = chem(i,k,j,p_ora2) &
                     +emis_ant(i,k,j,p_e_co)*conv
             end do
          end do
       end do
   CASE (CHEM_TRACE2)
       do j=jts,jte
          do i=its,ite
             do k=kts,min(config_flags%kemit,kte-ksub)
                conv = 4.828e-4/rho_phy(i,k,j)*dtstep/(dz8w(i,k,j)*60.)
                IF(emis_ant(i,k,j,p_e_no).eq.1.0) &
                chem(i,k,j,p_tracer_1) = chem(i,k,j,p_tracer_1) &
                     +emis_ant(i,k,j,p_e_co)*conv
                IF(emis_ant(i,k,j,p_e_no).eq.2.0) &
                chem(i,k,j,p_tracer_2) = chem(i,k,j,p_tracer_2) &
                     +emis_ant(i,k,j,p_e_co)*conv
                IF(emis_ant(i,k,j,p_e_no).eq.3.0) &
                chem(i,k,j,p_tracer_3) = chem(i,k,j,p_tracer_3) &
                     +emis_ant(i,k,j,p_e_co)*conv
                IF(emis_ant(i,k,j,p_e_no).eq.4.0) &
                chem(i,k,j,p_tracer_4) = chem(i,k,j,p_tracer_4) &
                     +emis_ant(i,k,j,p_e_co)*conv
                IF(emis_ant(i,k,j,p_e_no).eq.5.0) &
                chem(i,k,j,p_tracer_5) = chem(i,k,j,p_tracer_5) &
                     +emis_ant(i,k,j,p_e_co)*conv
                IF(emis_ant(i,k,j,p_e_no).eq.6.0) &
                chem(i,k,j,p_tracer_6) = chem(i,k,j,p_tracer_6) &
                     +emis_ant(i,k,j,p_e_co)*conv
                IF(emis_ant(i,k,j,p_e_no).eq.7.0) &
                chem(i,k,j,p_tracer_7) = chem(i,k,j,p_tracer_7) &
                     +emis_ant(i,k,j,p_e_co)*conv
                IF(emis_ant(i,k,j,p_e_no).eq.8.0) &
                chem(i,k,j,p_tracer_8) = chem(i,k,j,p_tracer_8) &
                     +emis_ant(i,k,j,p_e_co)*conv
                IF(emis_ant(i,k,j,p_e_no).eq.9.0) &
                chem(i,k,j,p_tracer_9) = chem(i,k,j,p_tracer_9) &
                     +emis_ant(i,k,j,p_e_co)*conv
                IF(emis_ant(i,k,j,p_e_no).eq.10.0) &
                chem(i,k,j,p_tracer_10) = chem(i,k,j,p_tracer_10) &
                     +emis_ant(i,k,j,p_e_co)*conv
                IF(emis_ant(i,k,j,p_e_no).eq.11.0) &
                chem(i,k,j,p_tracer_11) = chem(i,k,j,p_tracer_11) &
                     +emis_ant(i,k,j,p_e_co)*conv
                IF(emis_ant(i,k,j,p_e_no).eq.12.0) &
                chem(i,k,j,p_tracer_12) = chem(i,k,j,p_tracer_12) &
                     +emis_ant(i,k,j,p_e_co)*conv
                IF(emis_ant(i,k,j,p_e_no).eq.13.0) &
                chem(i,k,j,p_tracer_13) = chem(i,k,j,p_tracer_13) &
                     +emis_ant(i,k,j,p_e_co)*conv
                IF(emis_ant(i,k,j,p_e_no).eq.14.0) &
                chem(i,k,j,p_tracer_14) = chem(i,k,j,p_tracer_14) &
                     +emis_ant(i,k,j,p_e_co)*conv
                IF(emis_ant(i,k,j,p_e_no).eq.15.0) &
                chem(i,k,j,p_tracer_15) = chem(i,k,j,p_tracer_15) &
                     +emis_ant(i,k,j,p_e_co)*conv
                IF(emis_ant(i,k,j,p_e_no).eq.16.0) &
                chem(i,k,j,p_tracer_16) = chem(i,k,j,p_tracer_16) &
                     +emis_ant(i,k,j,p_e_co)*conv
                IF(emis_ant(i,k,j,p_e_no).eq.17.0) &
                chem(i,k,j,p_tracer_17) = chem(i,k,j,p_tracer_17) &
                     +emis_ant(i,k,j,p_e_co)*conv
                IF(emis_ant(i,k,j,p_e_no).eq.18.0) &
                chem(i,k,j,p_tracer_18) = chem(i,k,j,p_tracer_18) &
                     +emis_ant(i,k,j,p_e_co)*conv
                IF(emis_ant(i,k,j,p_e_no).eq.19.0) &
                chem(i,k,j,p_tracer_19) = chem(i,k,j,p_tracer_19) &
                     +emis_ant(i,k,j,p_e_co)*conv
                IF(emis_ant(i,k,j,p_e_no).eq.20.0) &
                chem(i,k,j,p_tracer_20) = chem(i,k,j,p_tracer_20) &
                     +emis_ant(i,k,j,p_e_co)*conv
                chem(i,k,j,p_tracer_ens) = chem(i,k,j,p_tracer_ens) &
                     +emis_ant(i,k,j,p_e_co)*conv
             end do
          end do
       end do
    CASE(CO2_TRACER,GHG_TRACER)
   CALL VPRM( ids,ide, jds,jde, &
                         ims,ime, jms,jme, &
                         its,ite, jts,jte, &
                         vprm_in,rad_vprm,lambda_vprm, &
                         alpha_vprm,resp_vprm, &
                         T2,swdown, &
                         eghg_bio )
   if (p_ch4_bio .GT. 1) then
   CALL KAPLAN( ids,ide, jds,jde, &
                         ims,ime, jms,jme, &
                         its,ite, jts,jte, &
                         xtime, tslb, smois, wet_in, &
                         isltyp,tsk,eghg_bio, &
                         config_flags%num_soil_layers,config_flags%wpeat, &
                         config_flags%wflood )
   CALL SOILUPTAKE( ids,ide, jds,jde, &
                         ims,ime, jms,jme, &
                         its,ite, jts,jte, &
                         smois, isltyp, eghg_bio, &
                         rainc, rainnc, &
                         potevp, sfcevp, lu_index, T2, xtime, &
                         config_flags%num_soil_layers, wet_in )
   CALL termite( ids,ide, jds,jde, &
                         ims,ime, jms,jme, &
                         its,ite, jts,jte, &
                         xtime,eghg_bio,ivgtyp, &
                         biomt_par,emit_par )
   end if
   IF (config_flags%emiss_inpt_opt==16) THEN
      CALL add_ghg_fluxes( ids,ide, jds,jde, kds,kde, &
                            ims,ime, jms,jme, kms,kme, &
                            its,ite, jts,jte, kts,kte, &
                            dtstep,dz8w,config_flags,rho_phy, &
                            chem,emis_ant,eghg_bio,ebio_co2oce )
   END IF
    CASE (SAPRC99_KPP)
     if(config_flags%emiss_opt == 13 ) then
       do j=jts,jte
          do i=its,ite
             do k=kts,min(config_flags%kemit,kte-ksub)
                conv = 4.828e-4/rho_phy(i,k,j)*dtstep/(dz8w(i,k,j)*60.)
                chem(i,k,j,p_so2) = chem(i,k,j,p_so2) &
                     +emis_ant(i,k,j,p_e_so2)*conv
                chem(i,k,j,p_c2h6) = chem(i,k,j,p_c2h6) &
                     +emis_ant(i,k,j,p_e_c2h6)*conv
                chem(i,k,j,p_c3h8) = chem(i,k,j,p_c3h8) &
                     +emis_ant(i,k,j,p_e_c3h8)*conv
                chem(i,k,j,p_c2h2) = chem(i,k,j,p_c2h2) &
                     +emis_ant(i,k,j,p_e_c2h2)*conv
                chem(i,k,j,p_alk3) = chem(i,k,j,p_alk3) &
                     +emis_ant(i,k,j,p_e_alk3)*conv
                chem(i,k,j,p_alk4) = chem(i,k,j,p_alk4) &
                     +emis_ant(i,k,j,p_e_alk4)*conv
                chem(i,k,j,p_alk5) = chem(i,k,j,p_alk5) &
                     +emis_ant(i,k,j,p_e_alk5)*conv
                chem(i,k,j,p_ethene) = chem(i,k,j,p_ethene) &
                     +emis_ant(i,k,j,p_e_ethene)*conv
                chem(i,k,j,p_c3h6) = chem(i,k,j,p_c3h6) &
                     +emis_ant(i,k,j,p_e_c3h6)*conv
                chem(i,k,j,p_ole1) = chem(i,k,j,p_ole1) &
                     +emis_ant(i,k,j,p_e_ole1)*conv
                chem(i,k,j,p_ole2) = chem(i,k,j,p_ole2) &
                     +emis_ant(i,k,j,p_e_ole2)*conv
                chem(i,k,j,p_aro1) = chem(i,k,j,p_aro1) &
                     +emis_ant(i,k,j,p_e_aro1)*conv
                chem(i,k,j,p_aro2) = chem(i,k,j,p_aro2) &
                     +emis_ant(i,k,j,p_e_aro2)*conv
                chem(i,k,j,p_hcho) = chem(i,k,j,p_hcho) &
                     +emis_ant(i,k,j,p_e_hcho)*conv
                chem(i,k,j,p_ccho) = chem(i,k,j,p_ccho) &
                     +emis_ant(i,k,j,p_e_ccho)*conv
                chem(i,k,j,p_rcho) = chem(i,k,j,p_rcho) &
                     +emis_ant(i,k,j,p_e_rcho)*conv
                chem(i,k,j,p_acet) = chem(i,k,j,p_acet) &
                     +emis_ant(i,k,j,p_e_acet)*conv
                chem(i,k,j,p_mek) = chem(i,k,j,p_mek) &
                     +emis_ant(i,k,j,p_e_mek)*conv
                chem(i,k,j,p_isoprene) = chem(i,k,j,p_isoprene) &
                     +emis_ant(i,k,j,p_e_isoprene)*conv
                chem(i,k,j,p_terp) = chem(i,k,j,p_terp) &
                     +emis_ant(i,k,j,p_e_terp)*conv
                chem(i,k,j,p_sesq) = chem(i,k,j,p_sesq) &
                     +emis_ant(i,k,j,p_e_sesq)*conv
                chem(i,k,j,p_co) = chem(i,k,j,p_co) &
                     +emis_ant(i,k,j,p_e_co)*conv
                chem(i,k,j,p_no) = chem(i,k,j,p_no) &
                     +emis_ant(i,k,j,p_e_no)*conv
                chem(i,k,j,p_no2) = chem(i,k,j,p_no2) &
                     +emis_ant(i,k,j,p_e_no2)*conv
                chem(i,k,j,p_phen) = chem(i,k,j,p_phen) &
                     +emis_ant(i,k,j,p_e_phen)*conv
                chem(i,k,j,p_cres) = chem(i,k,j,p_cres) &
                     +emis_ant(i,k,j,p_e_cres)*conv
                chem(i,k,j,p_meoh) = chem(i,k,j,p_meoh) &
                     +emis_ant(i,k,j,p_e_meoh)*conv
                chem(i,k,j,p_gly) = chem(i,k,j,p_gly) &
                     +emis_ant(i,k,j,p_e_gly)*conv
                chem(i,k,j,p_mgly) = chem(i,k,j,p_mgly) &
                     +emis_ant(i,k,j,p_e_mgly)*conv
                chem(i,k,j,p_bacl) = chem(i,k,j,p_bacl) &
                     +emis_ant(i,k,j,p_e_bacl)*conv
                chem(i,k,j,p_isoprod) = chem(i,k,j,p_isoprod) &
                     +emis_ant(i,k,j,p_e_isoprod)*conv
                chem(i,k,j,p_methacro) = chem(i,k,j,p_methacro) &
                     +emis_ant(i,k,j,p_e_methacro)*conv
                chem(i,k,j,p_mvk) = chem(i,k,j,p_mvk) &
                     +emis_ant(i,k,j,p_e_mvk)*conv
                chem(i,k,j,p_prod2) = chem(i,k,j,p_prod2) &
                     +emis_ant(i,k,j,p_e_prod2)*conv
                chem(i,k,j,p_ch4) = chem(i,k,j,p_ch4) &
                     +emis_ant(i,k,j,p_e_ch4)*conv
                chem(i,k,j,p_bald) = chem(i,k,j,p_bald) &
                     +emis_ant(i,k,j,p_e_bald)*conv
                chem(i,k,j,p_hcooh) = chem(i,k,j,p_hcooh) &
                     +emis_ant(i,k,j,p_e_hcooh)*conv
                chem(i,k,j,p_cco_oh) = chem(i,k,j,p_cco_oh) &
                     +emis_ant(i,k,j,p_e_cco_oh)*conv
                chem(i,k,j,p_rco_oh) = chem(i,k,j,p_rco_oh) &
                     +emis_ant(i,k,j,p_e_rco_oh)*conv
             end do
          end do
       end do
      else
       do j=jts,jte
          do i=its,ite
             do k=kts,min(config_flags%kemit,kte-ksub)
                conv = 4.828e-4/rho_phy(i,k,j)*dtstep/(dz8w(i,k,j)*60.)
                chem(i,k,j,p_so2) = chem(i,k,j,p_so2) &
                     +emis_ant(i,k,j,p_e_so2)*conv
                chem(i,k,j,p_co) = chem(i,k,j,p_co) &
                     +emis_ant(i,k,j,p_e_co)*conv
                chem(i,k,j,p_no) = chem(i,k,j,p_no) &
                     +emis_ant(i,k,j,p_e_no)*conv
                chem(i,k,j,p_hcho) = chem(i,k,j,p_hcho) &
                     +emis_ant(i,k,j,p_e_hcho)*conv
             end do
          end do
       end do
      endif
CASE (SAPRC99_MOSAIC_4BIN_VBS9_KPP)
     if(config_flags%emiss_opt == 13 ) then
       do j=jts,jte
          do i=its,ite
             do k=kts,min(config_flags%kemit,kte-ksub)
                conv = 4.828e-4/rho_phy(i,k,j)*dtstep/(dz8w(i,k,j)*60.)
                conv3 = (dtstep/dz8w(i,k,j))*alt(i,k,j)*28/250*1e-3
                conv4= (dtstep/dz8w(i,k,j))*alt(i,k,j)*28/226*1e-3
                oconv3= (dtstep/dz8w(i,k,j))*alt(i,k,j)*28/283*1e-3*4.5
                oconv4=(dtstep/dz8w(i,k,j))*alt(i,k,j)*28/226*1e-3*0.9
                chem(i,k,j,p_so2) = chem(i,k,j,p_so2) &
                     +emis_ant(i,k,j,p_e_so2)*conv
                chem(i,k,j,p_c2h6) = chem(i,k,j,p_c2h6) &
                     +emis_ant(i,k,j,p_e_c2h6)*conv
                chem(i,k,j,p_c3h8) = chem(i,k,j,p_c3h8) &
                     +emis_ant(i,k,j,p_e_c3h8)*conv
                chem(i,k,j,p_c2h2) = chem(i,k,j,p_c2h2) &
                     +emis_ant(i,k,j,p_e_c2h2)*conv
                chem(i,k,j,p_alk3) = chem(i,k,j,p_alk3) &
                     +emis_ant(i,k,j,p_e_alk3)*conv
                chem(i,k,j,p_alk4) = chem(i,k,j,p_alk4) &
                     +emis_ant(i,k,j,p_e_alk4)*conv
                chem(i,k,j,p_alk5) = chem(i,k,j,p_alk5) &
                     +emis_ant(i,k,j,p_e_alk5)*conv
                chem(i,k,j,p_ethene) = chem(i,k,j,p_ethene) &
                     +emis_ant(i,k,j,p_e_ethene)*conv
                chem(i,k,j,p_c3h6) = chem(i,k,j,p_c3h6) &
                     +emis_ant(i,k,j,p_e_c3h6)*conv
                chem(i,k,j,p_ole1) = chem(i,k,j,p_ole1) &
                     +emis_ant(i,k,j,p_e_ole1)*conv
                chem(i,k,j,p_ole2) = chem(i,k,j,p_ole2) &
                     +emis_ant(i,k,j,p_e_ole2)*conv
                chem(i,k,j,p_aro1) = chem(i,k,j,p_aro1) &
                     +emis_ant(i,k,j,p_e_aro1)*conv
                chem(i,k,j,p_aro2) = chem(i,k,j,p_aro2) &
                     +emis_ant(i,k,j,p_e_aro2)*conv
                chem(i,k,j,p_hcho) = chem(i,k,j,p_hcho) &
                     +emis_ant(i,k,j,p_e_hcho)*conv
                chem(i,k,j,p_ccho) = chem(i,k,j,p_ccho) &
                     +emis_ant(i,k,j,p_e_ccho)*conv
                chem(i,k,j,p_rcho) = chem(i,k,j,p_rcho) &
                     +emis_ant(i,k,j,p_e_rcho)*conv
                chem(i,k,j,p_acet) = chem(i,k,j,p_acet) &
                     +emis_ant(i,k,j,p_e_acet)*conv
                chem(i,k,j,p_mek) = chem(i,k,j,p_mek) &
                     +emis_ant(i,k,j,p_e_mek)*conv
                chem(i,k,j,p_isoprene) = chem(i,k,j,p_isoprene) &
                     +emis_ant(i,k,j,p_e_isoprene)*conv
                chem(i,k,j,p_terp) = chem(i,k,j,p_terp) &
                     +emis_ant(i,k,j,p_e_terp)*conv
                chem(i,k,j,p_sesq) = chem(i,k,j,p_sesq) &
                     +emis_ant(i,k,j,p_e_sesq)*conv
                chem(i,k,j,p_co) = chem(i,k,j,p_co) &
                     +emis_ant(i,k,j,p_e_co)*conv
                chem(i,k,j,p_no) = chem(i,k,j,p_no) &
                     +emis_ant(i,k,j,p_e_no)*conv
                chem(i,k,j,p_no2) = chem(i,k,j,p_no2) &
                     +emis_ant(i,k,j,p_e_no2)*conv
                chem(i,k,j,p_phen) = chem(i,k,j,p_phen) &
                     +emis_ant(i,k,j,p_e_phen)*conv
                chem(i,k,j,p_cres) = chem(i,k,j,p_cres) &
                     +emis_ant(i,k,j,p_e_cres)*conv
                chem(i,k,j,p_meoh) = chem(i,k,j,p_meoh) &
                     +emis_ant(i,k,j,p_e_meoh)*conv
                chem(i,k,j,p_gly) = chem(i,k,j,p_gly) &
                     +emis_ant(i,k,j,p_e_gly)*conv
                chem(i,k,j,p_mgly) = chem(i,k,j,p_mgly) &
                     +emis_ant(i,k,j,p_e_mgly)*conv
                chem(i,k,j,p_bacl) = chem(i,k,j,p_bacl) &
                     +emis_ant(i,k,j,p_e_bacl)*conv
                chem(i,k,j,p_isoprod) = chem(i,k,j,p_isoprod) &
                     +emis_ant(i,k,j,p_e_isoprod)*conv
                chem(i,k,j,p_methacro) = chem(i,k,j,p_methacro) &
                     +emis_ant(i,k,j,p_e_methacro)*conv
                chem(i,k,j,p_mvk) = chem(i,k,j,p_mvk) &
                     +emis_ant(i,k,j,p_e_mvk)*conv
                chem(i,k,j,p_prod2) = chem(i,k,j,p_prod2) &
                     +emis_ant(i,k,j,p_e_prod2)*conv
                chem(i,k,j,p_ch4) = chem(i,k,j,p_ch4) &
                     +emis_ant(i,k,j,p_e_ch4)*conv
                chem(i,k,j,p_bald) = chem(i,k,j,p_bald) &
                     +emis_ant(i,k,j,p_e_bald)*conv
                chem(i,k,j,p_hcooh) = chem(i,k,j,p_hcooh) &
                     +emis_ant(i,k,j,p_e_hcooh)*conv
                chem(i,k,j,p_cco_oh) = chem(i,k,j,p_cco_oh) &
                     +emis_ant(i,k,j,p_e_cco_oh)*conv
                chem(i,k,j,p_rco_oh) = chem(i,k,j,p_rco_oh) &
                     +emis_ant(i,k,j,p_e_rco_oh)*conv
                chem(i,k,j,p_nh3) = chem(i,k,j,p_nh3) &
                     +emis_ant(i,k,j,p_e_nh3)*conv
        chem(i,k,j,p_pcg1_b_c) = chem(i,k,j,p_pcg1_b_c) &
        +(emis_ant(i,k,j,p_e_orgi_bb)/1.57+emis_ant(i,k,j,p_e_orgj_bb)/1.57)*conv3*0.105
        chem(i,k,j,p_pcg2_b_c) = chem(i,k,j,p_pcg2_b_c) &
        +(emis_ant(i,k,j,p_e_orgi_bb)/1.57+emis_ant(i,k,j,p_e_orgj_bb)/1.57)*conv3*0.211
        chem(i,k,j,p_pcg3_b_c) = chem(i,k,j,p_pcg3_b_c) &
        +(emis_ant(i,k,j,p_e_orgi_bb)/1.57+emis_ant(i,k,j,p_e_orgj_bb)/1.57)*conv3*0.316
        chem(i,k,j,p_pcg4_b_c) = chem(i,k,j,p_pcg4_b_c) &
        +(emis_ant(i,k,j,p_e_orgi_bb)/1.57+emis_ant(i,k,j,p_e_orgj_bb)/1.57)*conv3*0.491
        chem(i,k,j,p_pcg5_b_c) = chem(i,k,j,p_pcg5_b_c) &
        +(emis_ant(i,k,j,p_e_orgi_bb)/1.57+emis_ant(i,k,j,p_e_orgj_bb)/1.57)*conv3*0.632
        chem(i,k,j,p_pcg6_b_c) = chem(i,k,j,p_pcg6_b_c) &
        +(emis_ant(i,k,j,p_e_orgi_bb)/1.57+emis_ant(i,k,j,p_e_orgj_bb)/1.57)*conv3*1.053
        chem(i,k,j,p_pcg7_b_c) = chem(i,k,j,p_pcg7_b_c) &
        +(emis_ant(i,k,j,p_e_orgi_bb)/1.57+emis_ant(i,k,j,p_e_orgj_bb)/1.57)*conv3*1.404
        chem(i,k,j,p_pcg8_b_c) = chem(i,k,j,p_pcg8_b_c) &
        +(emis_ant(i,k,j,p_e_orgi_bb)/1.57+emis_ant(i,k,j,p_e_orgj_bb)/1.57)*conv3*1.755
        chem(i,k,j,p_pcg9_b_c) = chem(i,k,j,p_pcg9_b_c) &
        +(emis_ant(i,k,j,p_e_orgi_bb)/1.57+emis_ant(i,k,j,p_e_orgj_bb)/1.57)*conv3*2.808
        chem(i,k,j,p_pcg1_f_c) = chem(i,k,j,p_pcg1_f_c) &
        +(emis_ant(i,k,j,p_e_orgi_a)*2/1.25+emis_ant(i,k,j,p_e_orgj_a)*2/1.25)*conv3*0.269
        chem(i,k,j,p_pcg2_f_c) = chem(i,k,j,p_pcg2_f_c) &
        +(emis_ant(i,k,j,p_e_orgi_a)*2/1.25+emis_ant(i,k,j,p_e_orgj_a)*2/1.25)*conv3*0.199
        chem(i,k,j,p_pcg3_f_c) = chem(i,k,j,p_pcg3_f_c) &
        +(emis_ant(i,k,j,p_e_orgi_a)*2/1.25+emis_ant(i,k,j,p_e_orgj_a)*2/1.25)*conv3*0.304
        chem(i,k,j,p_pcg4_f_c) = chem(i,k,j,p_pcg4_f_c) &
        +(emis_ant(i,k,j,p_e_orgi_a)*2/1.25+emis_ant(i,k,j,p_e_orgj_a)*2/1.25)*conv3*0.468
        chem(i,k,j,p_pcg5_f_c) = chem(i,k,j,p_pcg5_f_c) &
        +(emis_ant(i,k,j,p_e_orgi_a)*2/1.25+emis_ant(i,k,j,p_e_orgj_a)*2/1.25)*conv3*0.597
        chem(i,k,j,p_pcg6_f_c) = chem(i,k,j,p_pcg6_f_c) &
        +(emis_ant(i,k,j,p_e_orgi_a)*2/1.25+emis_ant(i,k,j,p_e_orgj_a)*2/1.25)*conv3*1.006
        chem(i,k,j,p_pcg7_f_c) = chem(i,k,j,p_pcg7_f_c) &
        +(emis_ant(i,k,j,p_e_orgi_a)*2/1.25+emis_ant(i,k,j,p_e_orgj_a)*2/1.25)*conv3*1.369
        chem(i,k,j,p_pcg8_f_c) = chem(i,k,j,p_pcg8_f_c) &
        +(emis_ant(i,k,j,p_e_orgi_a)*2/1.25+emis_ant(i,k,j,p_e_orgj_a)*2/1.25)*conv3*1.755
        chem(i,k,j,p_pcg9_f_c) = chem(i,k,j,p_pcg9_f_c) &
        +(emis_ant(i,k,j,p_e_orgi_a)*2/1.25+emis_ant(i,k,j,p_e_orgj_a)*2/1.25)*conv3*2.808
        chem(i,k,j,p_pcg1_b_o) = chem(i,k,j,p_pcg1_b_o) &
        +(emis_ant(i,k,j,p_e_orgi_bb)/1.57+emis_ant(i,k,j,p_e_orgj_bb)/1.57)*conv3*0.036
        chem(i,k,j,p_pcg2_b_o) = chem(i,k,j,p_pcg2_b_o) &
        +(emis_ant(i,k,j,p_e_orgi_bb)/1.57+emis_ant(i,k,j,p_e_orgj_bb)/1.57)*conv3*0.072
        chem(i,k,j,p_pcg3_b_o) = chem(i,k,j,p_pcg3_b_o) &
        +(emis_ant(i,k,j,p_e_orgi_bb)/1.57+emis_ant(i,k,j,p_e_orgj_bb)/1.57)*conv3*0.108
        chem(i,k,j,p_pcg4_b_o) = chem(i,k,j,p_pcg4_b_o) &
        +(emis_ant(i,k,j,p_e_orgi_bb)/1.57+emis_ant(i,k,j,p_e_orgj_bb)/1.57)*conv3*0.168
        chem(i,k,j,p_pcg5_b_o) = chem(i,k,j,p_pcg5_b_o) &
        +(emis_ant(i,k,j,p_e_orgi_bb)/1.57+emis_ant(i,k,j,p_e_orgj_bb)/1.57)*conv3*0.216
        chem(i,k,j,p_pcg6_b_o) = chem(i,k,j,p_pcg6_b_o) &
        +(emis_ant(i,k,j,p_e_orgi_bb)/1.57+emis_ant(i,k,j,p_e_orgj_bb)/1.57)*conv3*0.36
        chem(i,k,j,p_pcg7_b_o) = chem(i,k,j,p_pcg7_b_o) &
        +(emis_ant(i,k,j,p_e_orgi_bb)/1.57+emis_ant(i,k,j,p_e_orgj_bb)/1.57)*conv3*0.48
        chem(i,k,j,p_pcg8_b_o) = chem(i,k,j,p_pcg8_b_o) &
        +(emis_ant(i,k,j,p_e_orgi_bb)/1.57+emis_ant(i,k,j,p_e_orgj_bb)/1.57)*conv3*0.6
        chem(i,k,j,p_pcg9_b_o) = chem(i,k,j,p_pcg9_b_o) &
        +(emis_ant(i,k,j,p_e_orgi_bb)/1.57+emis_ant(i,k,j,p_e_orgj_bb)/1.57)*conv3*0.96
        chem(i,k,j,p_pcg1_f_o) = chem(i,k,j,p_pcg1_f_o) &
        +(emis_ant(i,k,j,p_e_orgi_a)*2/1.25+emis_ant(i,k,j,p_e_orgj_a)*2/1.25)*conv3*0.0184
        chem(i,k,j,p_pcg2_f_o) = chem(i,k,j,p_pcg2_f_o) &
        +(emis_ant(i,k,j,p_e_orgi_a)*2/1.25+emis_ant(i,k,j,p_e_orgj_a)*2/1.25)*conv3*0.0136
        chem(i,k,j,p_pcg3_f_o) = chem(i,k,j,p_pcg3_f_o) &
        +(emis_ant(i,k,j,p_e_orgi_a)*2/1.25+emis_ant(i,k,j,p_e_orgj_a)*2/1.25)*conv3*0.0208
        chem(i,k,j,p_pcg4_f_o) = chem(i,k,j,p_pcg4_f_o) &
        +(emis_ant(i,k,j,p_e_orgi_a)*2/1.25+emis_ant(i,k,j,p_e_orgj_a)*2/1.25)*conv3*0.032
        chem(i,k,j,p_pcg5_f_o) = chem(i,k,j,p_pcg5_f_o) &
        +(emis_ant(i,k,j,p_e_orgi_a)*2/1.25+emis_ant(i,k,j,p_e_orgj_a)*2/1.25)*conv3*0.0408
        chem(i,k,j,p_pcg6_f_o) = chem(i,k,j,p_pcg6_f_o) &
        +(emis_ant(i,k,j,p_e_orgi_a)*2/1.25+emis_ant(i,k,j,p_e_orgj_a)*2/1.25)*conv3*0.0688
        chem(i,k,j,p_pcg7_f_o) = chem(i,k,j,p_pcg7_f_o) &
        +(emis_ant(i,k,j,p_e_orgi_a)*2/1.25+emis_ant(i,k,j,p_e_orgj_a)*2/1.25)*conv3*0.0936
        chem(i,k,j,p_pcg8_f_o) = chem(i,k,j,p_pcg8_f_o) &
        +(emis_ant(i,k,j,p_e_orgi_a)*2/1.25+emis_ant(i,k,j,p_e_orgj_a)*2/1.25)*conv3*0.12
        chem(i,k,j,p_pcg9_f_o) = chem(i,k,j,p_pcg9_f_o) &
        +(emis_ant(i,k,j,p_e_orgi_a)*2/1.25+emis_ant(i,k,j,p_e_orgj_a)*2/1.25)*conv3*0.192
             end do
          end do
       end do
      else
       do j=jts,jte
          do i=its,ite
             do k=kts,min(config_flags%kemit,kte-ksub)
                conv = 4.828e-4/rho_phy(i,k,j)*dtstep/(dz8w(i,k,j)*60.)
                chem(i,k,j,p_so2) = chem(i,k,j,p_so2) &
                     +emis_ant(i,k,j,p_e_so2)*conv
                chem(i,k,j,p_co) = chem(i,k,j,p_co) &
                     +emis_ant(i,k,j,p_e_co)*conv
                chem(i,k,j,p_no) = chem(i,k,j,p_no) &
                     +emis_ant(i,k,j,p_e_co)*conv
                chem(i,k,j,p_hcho) = chem(i,k,j,p_hcho) &
                     +emis_ant(i,k,j,p_e_hcho)*conv
             end do
          end do
       end do
      endif
      call add_biogenics(id,dtstep,dz8w,config_flags, rho_phy,chem, &
            e_bio,ne_area, &
            ebio_iso,ebio_oli,ebio_api,ebio_lim,ebio_xyl, &
            ebio_hc3,ebio_ete,ebio_olt,ebio_ket,ebio_ald, &
            ebio_hcho,ebio_eth,ebio_ora2,ebio_co,ebio_nr,ebio_no, &
            ebio_sesq,ebio_mbo, &
            ids,ide, jds,jde, kds,kde, &
            ims,ime, jms,jme, kms,kme, &
            its,ite, jts,jte, kts,kte )
    CASE (CBMZ_MOSAIC_4BIN_VBS2_KPP)
     if(config_flags%emiss_opt == 3 ) then
       IF(config_flags%kemit .GT. kte-ksub) THEN
          message = ' EMISSIONS_DRIVER: KEMIT > KME '
          CALL wrf_error_fatal3("<stdin>",1435,&
message)
       ENDIF
       call wrf_debug(15,'emissions_driver calling cbmz_addemiss_anthro')
       call cbmz_addemiss_anthro( id, dtstep, dz8w, config_flags, &
            rho_phy, chem, &
            emis_ant,alt,ids,ide, jds,jde, kds,kde, &
            ims,ime, jms,jme, kms,kme, &
            its,ite, jts,jte, kts,kte )
       call wrf_debug(15,'emissions_driver calling cbmz_addemiss_bio')
       if ( config_flags%bio_emiss_opt .ne. megan2 ) then
          call add_biogenics(id,dtstep,dz8w,config_flags, rho_phy,chem, &
               e_bio,ne_area, &
               ebio_iso,ebio_oli,ebio_api,ebio_lim,ebio_xyl, &
               ebio_hc3,ebio_ete,ebio_olt,ebio_ket,ebio_ald, &
               ebio_hcho,ebio_eth,ebio_ora2,ebio_co,ebio_nr,ebio_no, &
               ebio_sesq,ebio_mbo, &
               ids,ide, jds,jde, kds,kde, &
               ims,ime, jms,jme, kms,kme, &
               its,ite, jts,jte, kts,kte )
       endif
       do j=jts,jte
          do i=its,ite
             do k=kts,min(config_flags%kemit,kte-ksub)
                conv = 4.828e-4/rho_phy(i,k,j)*dtstep/(dz8w(i,k,j)*60.)
                conv3 = (dtstep/dz8w(i,k,j))*alt(i,k,j)*28/250*1e-3
                conv4= (dtstep/dz8w(i,k,j))*alt(i,k,j)*28/226*1e-3
                oconv3= (dtstep/dz8w(i,k,j))*alt(i,k,j)*28/283*1e-3*4.5
                oconv4=(dtstep/dz8w(i,k,j))*alt(i,k,j)*28/226*1e-3*0.9
        chem(i,k,j,p_pcg1_b_c) = chem(i,k,j,p_pcg1_b_c) &
        +(emis_ant(i,k,j,p_e_orgi_bb)/1.57+emis_ant(i,k,j,p_e_orgj_bb)/1.57)*conv3*1.17
        chem(i,k,j,p_pcg2_b_c) = chem(i,k,j,p_pcg2_b_c) &
        +(emis_ant(i,k,j,p_e_orgi_bb)/1.57+emis_ant(i,k,j,p_e_orgj_bb)/1.57)*conv3*7.605
        chem(i,k,j,p_pcg1_f_c) = chem(i,k,j,p_pcg1_f_c) &
        +(emis_ant(i,k,j,p_e_orgi_a)/1.25+emis_ant(i,k,j,p_e_orgj_a)/1.25)*conv3*1.17
        chem(i,k,j,p_pcg2_f_c) = chem(i,k,j,p_pcg2_f_c) &
        +(emis_ant(i,k,j,p_e_orgi_a)/1.25+emis_ant(i,k,j,p_e_orgj_a)/1.25)*conv3*7.605
        chem(i,k,j,p_pcg1_b_o) = chem(i,k,j,p_pcg1_b_o) &
        +(emis_ant(i,k,j,p_e_orgi_bb)/1.57+emis_ant(i,k,j,p_e_orgj_bb)/1.57)*conv3*0.40
        chem(i,k,j,p_pcg2_b_o) = chem(i,k,j,p_pcg2_b_o) &
        +(emis_ant(i,k,j,p_e_orgi_bb)/1.57+emis_ant(i,k,j,p_e_orgj_bb)/1.57)*conv3*2.60
        chem(i,k,j,p_pcg1_f_o) = chem(i,k,j,p_pcg1_f_o) &
        +(emis_ant(i,k,j,p_e_orgi_a)/1.25+emis_ant(i,k,j,p_e_orgj_a)/1.25)*conv3*0.08
        chem(i,k,j,p_pcg2_f_o) = chem(i,k,j,p_pcg2_f_o) &
        +(emis_ant(i,k,j,p_e_orgi_a)/1.25+emis_ant(i,k,j,p_e_orgj_a)/1.25)*conv3*0.52
             end do
          end do
       end do
     endif
    CASE (SAPRC99_MOSAIC_4BIN_VBS2_KPP, SAPRC99_MOSAIC_8BIN_VBS2_AQ_KPP, SAPRC99_MOSAIC_8BIN_VBS2_KPP)
     if(config_flags%emiss_opt == 13 ) then
       do j=jts,jte
          do i=its,ite
             do k=kts,min(config_flags%kemit,kte-ksub)
                conv = 4.828e-4/rho_phy(i,k,j)*dtstep/(dz8w(i,k,j)*60.)
                conv3 = (dtstep/dz8w(i,k,j))*alt(i,k,j)*28/250*1e-3
                conv4= (dtstep/dz8w(i,k,j))*alt(i,k,j)*28/226*1e-3
                oconv3= (dtstep/dz8w(i,k,j))*alt(i,k,j)*28/283*1e-3*4.5
                oconv4=(dtstep/dz8w(i,k,j))*alt(i,k,j)*28/226*1e-3*0.9
                chem(i,k,j,p_so2) = chem(i,k,j,p_so2) &
                     +emis_ant(i,k,j,p_e_so2)*conv
                chem(i,k,j,p_c2h6) = chem(i,k,j,p_c2h6) &
                     +emis_ant(i,k,j,p_e_c2h6)*conv
                chem(i,k,j,p_c3h8) = chem(i,k,j,p_c3h8) &
                     +emis_ant(i,k,j,p_e_c3h8)*conv
                chem(i,k,j,p_c2h2) = chem(i,k,j,p_c2h2) &
                     +emis_ant(i,k,j,p_e_c2h2)*conv
                chem(i,k,j,p_alk3) = chem(i,k,j,p_alk3) &
                     +emis_ant(i,k,j,p_e_alk3)*conv
                chem(i,k,j,p_alk4) = chem(i,k,j,p_alk4) &
                     +emis_ant(i,k,j,p_e_alk4)*conv
                chem(i,k,j,p_alk5) = chem(i,k,j,p_alk5) &
                     +emis_ant(i,k,j,p_e_alk5)*conv
                chem(i,k,j,p_ethene) = chem(i,k,j,p_ethene) &
                     +emis_ant(i,k,j,p_e_ethene)*conv
                chem(i,k,j,p_c3h6) = chem(i,k,j,p_c3h6) &
                     +emis_ant(i,k,j,p_e_c3h6)*conv
                chem(i,k,j,p_ole1) = chem(i,k,j,p_ole1) &
                     +emis_ant(i,k,j,p_e_ole1)*conv
                chem(i,k,j,p_ole2) = chem(i,k,j,p_ole2) &
                     +emis_ant(i,k,j,p_e_ole2)*conv
                chem(i,k,j,p_aro1) = chem(i,k,j,p_aro1) &
                     +emis_ant(i,k,j,p_e_aro1)*conv
                chem(i,k,j,p_aro2) = chem(i,k,j,p_aro2) &
                     +emis_ant(i,k,j,p_e_aro2)*conv
                chem(i,k,j,p_hcho) = chem(i,k,j,p_hcho) &
                     +emis_ant(i,k,j,p_e_hcho)*conv
                chem(i,k,j,p_ccho) = chem(i,k,j,p_ccho) &
                     +emis_ant(i,k,j,p_e_ccho)*conv
                chem(i,k,j,p_rcho) = chem(i,k,j,p_rcho) &
                     +emis_ant(i,k,j,p_e_rcho)*conv
                chem(i,k,j,p_acet) = chem(i,k,j,p_acet) &
                     +emis_ant(i,k,j,p_e_acet)*conv
                chem(i,k,j,p_mek) = chem(i,k,j,p_mek) &
                     +emis_ant(i,k,j,p_e_mek)*conv
                chem(i,k,j,p_isoprene) = chem(i,k,j,p_isoprene) &
                     +emis_ant(i,k,j,p_e_isoprene)*conv
                chem(i,k,j,p_terp) = chem(i,k,j,p_terp) &
                     +emis_ant(i,k,j,p_e_terp)*conv
                chem(i,k,j,p_sesq) = chem(i,k,j,p_sesq) &
                     +emis_ant(i,k,j,p_e_sesq)*conv
                chem(i,k,j,p_co) = chem(i,k,j,p_co) &
                     +emis_ant(i,k,j,p_e_co)*conv
                chem(i,k,j,p_no) = chem(i,k,j,p_no) &
                     +emis_ant(i,k,j,p_e_no)*conv
                chem(i,k,j,p_no2) = chem(i,k,j,p_no2) &
                     +emis_ant(i,k,j,p_e_no2)*conv
                chem(i,k,j,p_phen) = chem(i,k,j,p_phen) &
                     +emis_ant(i,k,j,p_e_phen)*conv
                chem(i,k,j,p_cres) = chem(i,k,j,p_cres) &
                     +emis_ant(i,k,j,p_e_cres)*conv
                chem(i,k,j,p_meoh) = chem(i,k,j,p_meoh) &
                     +emis_ant(i,k,j,p_e_meoh)*conv
                chem(i,k,j,p_gly) = chem(i,k,j,p_gly) &
                     +emis_ant(i,k,j,p_e_gly)*conv
                chem(i,k,j,p_mgly) = chem(i,k,j,p_mgly) &
                     +emis_ant(i,k,j,p_e_mgly)*conv
                chem(i,k,j,p_bacl) = chem(i,k,j,p_bacl) &
                     +emis_ant(i,k,j,p_e_bacl)*conv
                chem(i,k,j,p_isoprod) = chem(i,k,j,p_isoprod) &
                     +emis_ant(i,k,j,p_e_isoprod)*conv
                chem(i,k,j,p_methacro) = chem(i,k,j,p_methacro) &
                     +emis_ant(i,k,j,p_e_methacro)*conv
                chem(i,k,j,p_mvk) = chem(i,k,j,p_mvk) &
                     +emis_ant(i,k,j,p_e_mvk)*conv
                chem(i,k,j,p_prod2) = chem(i,k,j,p_prod2) &
                     +emis_ant(i,k,j,p_e_prod2)*conv
                chem(i,k,j,p_ch4) = chem(i,k,j,p_ch4) &
                     +emis_ant(i,k,j,p_e_ch4)*conv
                chem(i,k,j,p_bald) = chem(i,k,j,p_bald) &
                     +emis_ant(i,k,j,p_e_bald)*conv
                chem(i,k,j,p_hcooh) = chem(i,k,j,p_hcooh) &
                     +emis_ant(i,k,j,p_e_hcooh)*conv
                chem(i,k,j,p_cco_oh) = chem(i,k,j,p_cco_oh) &
                     +emis_ant(i,k,j,p_e_cco_oh)*conv
                chem(i,k,j,p_rco_oh) = chem(i,k,j,p_rco_oh) &
                     +emis_ant(i,k,j,p_e_rco_oh)*conv
                chem(i,k,j,p_nh3) = chem(i,k,j,p_nh3) &
                     +emis_ant(i,k,j,p_e_nh3)*conv
             end do
          end do
       end do
      else
       do j=jts,jte
          do i=its,ite
             do k=kts,min(config_flags%kemit,kte-ksub)
                conv = 4.828e-4/rho_phy(i,k,j)*dtstep/(dz8w(i,k,j)*60.)
                chem(i,k,j,p_so2) = chem(i,k,j,p_so2) &
                     +emis_ant(i,k,j,p_e_so2)*conv
                chem(i,k,j,p_co) = chem(i,k,j,p_co) &
                     +emis_ant(i,k,j,p_e_co)*conv
                chem(i,k,j,p_no) = chem(i,k,j,p_no) &
                     +emis_ant(i,k,j,p_e_no)*conv
                chem(i,k,j,p_hcho) = chem(i,k,j,p_hcho) &
                     +emis_ant(i,k,j,p_e_hcho)*conv
             end do
          end do
       end do
      endif
      call add_biogenics(id,dtstep,dz8w,config_flags, rho_phy,chem, &
            e_bio,ne_area, &
            ebio_iso,ebio_oli,ebio_api,ebio_lim,ebio_xyl, &
            ebio_hc3,ebio_ete,ebio_olt,ebio_ket,ebio_ald, &
            ebio_hcho,ebio_eth,ebio_ora2,ebio_co,ebio_nr,ebio_no, &
            ebio_sesq,ebio_mbo, &
            ids,ide, jds,jde, kds,kde, &
            ims,ime, jms,jme, kms,kme, &
            its,ite, jts,jte, kts,kte )
    CASE (GOCARTRACM_KPP,GOCARTRADM2,GOCARTRADM2_KPP)
       IF(config_flags%emiss_inpt_opt /= 3 ) then
       IF(config_flags%kemit .GT. kte-ksub) THEN
         k=config_flags%kemit
         write(message,'(" WARNING: EMISSIONS_DRIVER: KEMIT > KTE ",3i6)') kme,kte-ksub,k
         CALL WRF_MESSAGE (message)
       ENDIF
       call wrf_debug(15,'emissions_driver calling add_anthropogenics')
       call add_anthropogenics(id,dtstep,dz8w,config_flags,rho_phy,alt, &
            chem, emis_ant,emis_aircraft, &
            ids,ide, jds,jde, kds,kde, &
            ims,ime, jms,jme, kms,kme, &
            its,ite, jts,jte, kts,kte )
       call wrf_debug(15,'emissions_driver calling add_biogenics')
       call add_biogenics(id,dtstep,dz8w,config_flags,rho_phy,chem, &
            e_bio,ne_area, &
            ebio_iso,ebio_oli,ebio_api,ebio_lim,ebio_xyl, &
            ebio_hc3,ebio_ete,ebio_olt,ebio_ket,ebio_ald, &
            ebio_hcho,ebio_eth,ebio_ora2,ebio_co,ebio_nr,ebio_no, &
            ebio_sesq,ebio_mbo, &
            ids,ide, jds,jde, kds,kde, &
            ims,ime, jms,jme, kms,kme, &
            its,ite, jts,jte, kts,kte )
       end if
       do j=jts,jte
          do i=its,ite
             do k=kts,min(config_flags%kemit,kte-ksub)
                conv = 4.828e-4/rho_phy(i,k,j)*dtstep/(dz8w(i,k,j)*60.)
                chem(i,k,j,p_bc1) = chem(i,k,j,p_bc1) &
                     +(emis_ant(i,k,j,p_e_eci)+emis_ant(i,k,j,p_e_ecj))*alt(i,k,j)*dtstep/dz8w(i,k,j)
                chem(i,k,j,p_oc1) = chem(i,k,j,p_oc1) &
                     +(emis_ant(i,k,j,p_e_orgj)+emis_ant(i,k,j,p_e_orgi))*alt(i,k,j)*dtstep/dz8w(i,k,j)
                chem(i,k,j,p_p25) = chem(i,k,j,p_p25) &
                     +(emis_ant(i,k,j,p_e_pm25j)+emis_ant(i,k,j,p_e_pm25i) &
                     + emis_ant(i,k,j,p_e_no3j)+emis_ant(i,k,j,p_e_no3i)) &
                     *alt(i,k,j)*dtstep/dz8w(i,k,j)
                chem(i,k,j,p_sulf) = chem(i,k,j,p_sulf) &
                     +(emis_ant(i,k,j,p_e_so4i)+emis_ant(i,k,j,p_e_so4j))*alt(i,k,j)*dtstep/dz8w(i,k,j)*mwdry/mw_so4_aer*1.e-3
             end do
          end do
       end do
    CASE (GOCART_SIMPLE)
       if(config_flags%emiss_opt <= 5 ) then
       do j=jts,jte
          do i=its,ite
             do k=kts,min(config_flags%kemit,kte-ksub)
                conv = 4.828e-4/rho_phy(i,k,j)*dtstep/(dz8w(i,k,j)*60.)
                chem(i,k,j,p_so2) = chem(i,k,j,p_so2) &
                     +emis_ant(i,k,j,p_e_so2)*conv
                chem(i,k,j,p_bc1) = chem(i,k,j,p_bc1) &
                     +(emis_ant(i,k,j,p_e_eci)+emis_ant(i,k,j,p_e_ecj))*alt(i,k,j)*dtstep/dz8w(i,k,j)
                chem(i,k,j,p_oc1) = chem(i,k,j,p_oc1) &
                     +(emis_ant(i,k,j,p_e_orgj)+emis_ant(i,k,j,p_e_orgi))*alt(i,k,j)*dtstep/dz8w(i,k,j)
                chem(i,k,j,p_p25) = chem(i,k,j,p_p25) &
                     +(emis_ant(i,k,j,p_e_pm25j)+emis_ant(i,k,j,p_e_pm25i) &
                     +emis_ant(i,k,j,p_e_no3j)+emis_ant(i,k,j,p_e_no3i)) &
                     *alt(i,k,j)*dtstep/dz8w(i,k,j)
                chem(i,k,j,p_sulf) = chem(i,k,j,p_sulf) &
                     +(emis_ant(i,k,j,p_e_so4i)+emis_ant(i,k,j,p_e_so4j)) &
                     *alt(i,k,j)*dtstep/dz8w(i,k,j)*mwdry/mw_so4_aer*1.e-3
             end do
          end do
       end do
       endif
       if(config_flags%emiss_opt == 6 ) then
       do j=jts,jte
          do i=its,ite
             do k=kts,min(config_flags%kemit,kte-ksub)
                conv = 4.828e-4/rho_phy(i,k,j)*dtstep/(dz8w(i,k,j)*60.)
                chem(i,k,j,p_so2) = chem(i,k,j,p_so2) &
                     +emis_ant(i,k,j,p_e_so2)*conv
                chem(i,k,j,p_bc1) = chem(i,k,j,p_bc1) &
                     +(emis_ant(i,k,j,p_e_bc))*alt(i,k,j)*dtstep/dz8w(i,k,j)
                chem(i,k,j,p_oc1) = chem(i,k,j,p_oc1) &
                     +(emis_ant(i,k,j,p_e_oc))*alt(i,k,j)*dtstep/dz8w(i,k,j)
                chem(i,k,j,p_p25) = chem(i,k,j,p_p25) &
                     +(emis_ant(i,k,j,p_e_pm_25)) &
                     *alt(i,k,j)*dtstep/dz8w(i,k,j)
                chem(i,k,j,p_p10) = chem(i,k,j,p_p10) &
                     +(emis_ant(i,k,j,p_e_pm_10)) &
                     *alt(i,k,j)*dtstep/dz8w(i,k,j)
                chem(i,k,j,p_sulf) = chem(i,k,j,p_sulf) &
                     +emis_ant(i,k,j,p_e_sulf)*conv
             end do
          end do
       end do
       endif
    CASE DEFAULT
       call wrf_debug(15,'emissions_driver NOT CALLING gas add_... routines')
    END SELECT gas_addemiss_select
    emiss_select: SELECT CASE(config_flags%emiss_inpt_opt)
    CASE (EMISS_INPT_CPTEC)
       call wrf_debug(15,'emissions_driver calling add_emiss_cptec')
       call add_emis_cptec(id,dtstep,ktau,dz8w,config_flags,rho_phy,chem,&
            julday,gmt,xlat,xlong,t_phy,p_phy, &
            emis_ant, &
            ids,ide, jds,jde, kds,kde, &
            ims,ime, jms,jme, kms,kme, &
            its,ite, jts,jte, kts,kte )
    CASE DEFAULT
       call wrf_debug(15,'emissions_driver not calling add_emiss_cptec')
    END SELECT emiss_select
    aer_addemiss_select: SELECT CASE(config_flags%chem_opt)
    CASE (RADM2SORG,RADM2SORG_AQ,RADM2SORG_AQCHEM,RADM2SORG_KPP, &
          RACMSORG_AQ,RACMSORG_AQCHEM_KPP,RACM_ESRLSORG_AQCHEM_KPP,RACMSORG_KPP,RACM_ESRLSORG_KPP,CBMZSORG,CBMZSORG_AQ)
       call wrf_debug(15,'emissions_driver calling sorgam_addemiss')
       call sorgam_addemiss( id, dtstep, u10, v10, alt, dz8w, xland, chem, &
            ebu, &
            slai,ust,smois,ivgtyp,isltyp, &
            emis_ant,dust_emiss_active, &
            seasalt_emiss_active,config_flags%kemit, &
            config_flags%biomass_burn_opt, &
            config_flags%num_soil_layers,config_flags%emiss_opt, &
            config_flags%dust_opt, &
            ktau,p8w,u_phy,v_phy,rho_phy,g,dx,erod, &
            ids,ide, jds,jde, kds,kde, &
            ims,ime, jms,jme, kms,kme, &
            its,ite, jts,jte, kts,kte )
    CASE (RACM_SOA_VBS_KPP)
       call wrf_debug(15,'emissions_driver calling soa_vbs_addemiss')
       call soa_vbs_addemiss( id, dtstep, u10, v10, alt, dz8w, xland, chem, &
            ebu, &
            slai,ust,smois,ivgtyp,isltyp, &
            emis_ant,dust_emiss_active, &
            seasalt_emiss_active,config_flags%kemit, &
            config_flags%biomass_burn_opt, &
            config_flags%num_soil_layers,config_flags%emiss_opt, &
            config_flags%dust_opt, &
            ktau,p8w,u_phy,v_phy,rho_phy,g,dx,erod, &
            ids,ide, jds,jde, kds,kde, &
            ims,ime, jms,jme, kms,kme, &
            its,ite, jts,jte, kts,kte )
    CASE (CBMZ_MOSAIC_4BIN, CBMZ_MOSAIC_KPP, CBMZ_MOSAIC_8BIN,CBMZ_MOSAIC_8BIN_VBS9_KPP, &
          CBMZ_MOSAIC_4BIN_AQ, CBMZ_MOSAIC_8BIN_AQ, CBMZ_MOSAIC_4BIN_VBS9_KPP,&
          CBMZ_MOSAIC_DMS_4BIN, CBMZ_MOSAIC_DMS_8BIN, SAPRC99_MOSAIC_4BIN_VBS9_KPP,&
          CBMZ_MOSAIC_DMS_4BIN_AQ, CBMZ_MOSAIC_DMS_8BIN_AQ,SAPRC99_MOSAIC_4BIN_VBS2_KPP,&
          CBMZ_MOSAIC_4BIN_VBS2_KPP,MOZART_MOSAIC_4BIN_VBS0_KPP, &
          CRI_MOSAIC_8BIN_AQ_KPP, CRI_MOSAIC_4BIN_AQ_KPP,SAPRC99_MOSAIC_8BIN_VBS2_AQ_KPP, &
          SAPRC99_MOSAIC_8BIN_VBS2_KPP )
       call wrf_debug(15,'emissions_driver calling mosaic_addemiss')
       call mosaic_addemiss( id, dtstep, u10, v10, alt, dz8w, xland, &
            config_flags, chem, slai, ust, smois, ivgtyp, isltyp, &
            emis_ant,ebu,config_flags%biomass_burn_opt, &
            config_flags%dust_opt, &
            ktau,p8w,u_phy,v_phy,rho_phy,g,dx,erod, &
            dust_emiss_active, seasalt_emiss_active, &
            ids,ide, jds,jde, kds,kde, &
            ims,ime, jms,jme, kms,kme, &
            its,ite, jts,jte, kts,kte )
    CASE ( CBMZ_CAM_MAM3_NOAQ, CBMZ_CAM_MAM3_AQ, CBMZ_CAM_MAM7_NOAQ, CBMZ_CAM_MAM7_AQ )
       call wrf_debug(15,'emissions_driver calling cam_mam_addemiss')
       call cam_mam_addemiss( &
            id, dtstep, u10, v10, alt, dz8w, xland, &
            config_flags, chem, slai, ust, smois, ivgtyp, isltyp, &
            emis_ant,ebio_iso,ebio_olt,ebio_oli,rho_phy, &
            dust_emiss_active, seasalt_emiss_active, &
            ids,ide, jds,jde, kds,kde, &
            ims,ime, jms,jme, kms,kme, &
            its,ite, jts,jte, kts,kte )
       call wrf_debug(15,'emissions_driver backfrm cam_mam_addemiss')
    CASE DEFAULT
       call wrf_debug(15,'emissions_driver NOT CALLING aer add_... routines')
    END SELECT aer_addemiss_select
    CALL lightning_nox_driver ( &
            itimestep=ktau, dt=dtstep, dx=dx, dy=dx, &
            xlat=xlat, xlon=xlong, xland=xland, ht=ht, &
            t_phy=t_phy, p_phy=p_phy, rho=rho_phy, u=u_phy, v=v_phy, w=vvel, &
            z=z, moist=moist, &
            ic_flashrate=ic_flashrate, cg_flashrate=cg_flashrate, &
            refl=refl_10cm, &
            lightning_option=config_flags%lightning_option, &
            lightning_dt=config_flags%lightning_dt, &
            lightning_start_seconds=config_flags%lightning_start_seconds, &
            N_IC=config_flags%N_IC, N_CG=config_flags%N_CG, &
            lnox_opt=config_flags%lnox_opt, lnox_passive=config_flags%lnox_passive, &
            ltng_temp_upper=config_flags%ltng_temp_upper, &
            ltng_temp_lower=config_flags%ltng_temp_lower, &
            cellcount_method=config_flags%cellcount_method, &
            cldfra_cup=cldfra_cup, htop=htop, &
            ids=ids, ide=ide, jds=jds, jde=jde, kds=kds, kde=kde, &
            ims=ims, ime=ime, jms=jms, jme=jme, kms=kms, kme=kme, &
            its=its, ite=ite, jts=jts, jte=jte, kts=kts, kte=kte, &
            c_no=chem(:,:,:,p_no), &
            lnox_total=tracer(:,:,:,p_lnox_total), &
            lnox_ic=tracer(:,:,:,p_lnox_ic), &
            lnox_cg=tracer(:,:,:,p_lnox_cg) &
          )
    END subroutine emissions_driver
END module module_emissions_driver