Merge remote-tracking branch 'origin/release-v4.6.1'
[WRF.git] / chem / module_gocart_so2so4.F
bloba73298645dce14272b67d9f97eae991dbc9e6352
1 MODULE module_gocart_so2so4
3 CONTAINS
5   subroutine so2so4(ils,chem,p_so2,p_sulf,p_h2o2,p_QC,T_PHY,MOIST,gd,          &
6                     gd_cldfr,gd_on, NUM_CHEM,NUM_MOIST,                        &
7                     ids,ide, jds,jde, kds,kde,                                 &
8                     ims,ime, jms,jme, kms,kme,                                 &
9                     its,ite, jts,jte, kts,kte                                  )
10    INTEGER,      INTENT(IN   ) :: ils,num_chem,num_moist,                      &
11                                   p_so2,p_sulf,p_h2o2,p_QC,gd_on,          &
12                                   ids,ide, jds,jde, kds,kde,               &
13                                   ims,ime, jms,jme, kms,kme,               &
14                                   its,ite, jts,jte, kts,kte
15    REAL, DIMENSION( ims:ime, kms:kme, jms:jme, num_moist ),                &
16          INTENT(IN ) ::                                   moist
17    REAL, DIMENSION( ims:ime, kms:kme, jms:jme, num_chem ),                 &
18          INTENT(INOUT ) ::                                   chem
19    REAL,  DIMENSION( ims:ime , kms:kme , jms:jme ),                        &
20           INTENT(IN   ) ::                     t_phy,gd
21    REAL,  DIMENSION( ims:ime , kms:kme , jms:jme ),                        &
22           OPTIONAL,                                                        &
23           INTENT(IN   ) ::                     gd_cldfr
25    integer :: i,k,j
26    real :: tc2,tc3,h2o2,cldf
27           do j=jts,jte
28           do k=kts,kte
29           do i=its,ite
30              cldf=0.
31              if(ils.eq.0 .and. gd_on==1 ) then
32                 cldf=gd_cldfr(i,k,j)
33              elseif(p_qc.gt.1 )then
34                if(moist(i,k,j,p_qc).gt.0 )cldf=1.
35              endif
36              tc2=chem(i,k,j,p_so2)
37              IF (cldf > 0.0 .AND. tc2 > 0.0 .AND. t_phy(i,k,j) > 258.0) THEN
38                  tc3=chem(i,k,j,p_sulf)
39                  h2o2=chem(i,k,j,p_h2o2)
41 ! ****************************************************************************
42 ! *  Update SO2 concentration after cloud chemistry.                         *
43 ! *  SO2 chemical loss rate  = SO4 production rate (MixingRatio/timestep).   *
44 ! ****************************************************************************
46            ! Cloud chemistry (above 258K): 
48               IF (tc2 > h2o2) THEN
49                  cldf = cldf * (h2o2/tc2)
50                  h2o2 = h2o2 * (1.0 - cldf)
51               ELSE
52                  h2o2 = h2o2 * (1.0 - cldf*tc2/h2o2)
53               END IF
54               chem(i,k,j,p_so2) = max(1.e-16,tc2 * (1.0 - cldf) )
55               chem(i,k,j,p_sulf) = max(1.e-16,(tc3 + tc2*cldf))
56               chem(i,k,j,p_h2o2)=max(1.e-16,h2o2)
57 !             write(0,*)'2,so2,sulf,h2o2 = ',chem(i,k,j,p_so2),chem(i,k,j,p_sulf),chem(i,k,j,p_h2o2)
58            END IF
59            enddo
60            enddo
61            enddo
63 ! ****************************************************************************
65 END  subroutine so2so4
66 END MODULE module_gocart_so2so4