ebischeme.F90 99 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209
  1. #define TRACEBACK write (gol,'("in ",a," (",a,i6,")")') rname, __FILE__, __LINE__ ; call goErr
  2. #define IF_NOTOK_RETURN(action) if (status/=0) then; TRACEBACK; action; return; end if
  3. #define IF_ERROR_RETURN(action) if (status> 0) then; TRACEBACK; action; return; end if
  4. !
  5. #include "tm5.inc"
  6. !
  7. !-----------------------------------------------------------------------------
  8. ! TM5 !
  9. !-----------------------------------------------------------------------------
  10. !BOP
  11. !
  12. ! !MODULE: EBISCHEME
  13. !
  14. ! !DESCRIPTION: Eulerian Backward Iteration (EBI) is a chemistry solver for
  15. ! the modified CB05 scheme.
  16. !\\
  17. !\\
  18. ! !INTERFACE:
  19. !
  20. module EBISCHEME
  21. !
  22. ! !USES:
  23. !
  24. use GO, only : gol, goPr, goErr
  25. use dims, only : nregions
  26. use tm5_distgrid, only : dgrid, Get_DistGrid
  27. use chem_param
  28. #ifdef with_budgets
  29. use budget_global, only : nbudg, nbud_vg
  30. use reaction_data, only : nreac, nreacw
  31. use photolysis_data, only : nj
  32. #endif
  33. implicit none
  34. private
  35. !
  36. ! !PUBLIC MEMBER FUNCTIONS:
  37. !
  38. public :: EBI
  39. !
  40. ! !PUBLIC DATA MEMBERS:
  41. !
  42. #ifdef with_budgets
  43. real, dimension(nregions), public :: sum_wetchem
  44. real, dimension(nregions), public :: sum_chemistry
  45. real, dimension(nregions), public :: sum_deposition
  46. type, public :: buddep_data
  47. real, dimension(:,:,:), pointer :: dry ! i,j,ntrace
  48. end type buddep_data
  49. type(buddep_data), dimension(nregions), public :: buddep_dat
  50. real, dimension(nbudg, nbud_vg, nreac ), public :: budrrg
  51. real, dimension(nbudg, nbud_vg, nj ), public :: budrjg
  52. real, dimension(nbudg, nbud_vg, nreacw), public :: budrwg
  53. real, dimension(nbudg, nbud_vg, nmark ), public :: budmarkg
  54. !allow saving of production of aqueous, gas-phase sulfate, elvoc, svoc
  55. type,public :: production_data
  56. real, dimension(:,:,:,:), pointer :: prod ! i,j,lev,nprod
  57. end type production_data
  58. integer,parameter,public :: nprod_AC_o3=2
  59. integer,parameter,public :: n_loss=2 !loss of ch4 and co
  60. integer,parameter,public :: nprod=12
  61. type(production_data), dimension(nregions),public:: diag_prod
  62. !The chemical production container for AerChemMIP output, needs own container, since the variable is zeroed when
  63. ! writing out and could possibly conflict with the general output routine.
  64. integer,parameter,public :: nprod_AC=4 ! N=4: GASSO4, AQSO4, SOA(3d monthly),SOA(2d hourly)
  65. integer,parameter,public :: iprod_gasso4=1, iprod_aqso4=2,iprod_soa3dmon=3,iprod_soa2dhour=4
  66. integer,parameter,public :: iloss_ch4=1, iloss_co=2
  67. type(production_data), dimension(nregions),public:: AC_diag_prod
  68. type(production_data), dimension(nregions),public:: AC_O3_lp
  69. type(production_data), dimension(nregions),public:: AC_loss
  70. real,dimension(:,:), allocatable :: temp_prod_so4
  71. real,dimension(:,:), allocatable :: temp_loss
  72. real,dimension(:,:), allocatable :: temp_prod_vocs
  73. #endif
  74. logical, public::isoprene_on
  75. character(len=*), parameter :: mname = 'ebischeme'
  76. !
  77. ! !REVISION HISTORY:
  78. !
  79. ! Feb 2007 - Elisabetta Vignati - changed for inclusion of cloud chemistry on modes
  80. ! 22 Mar 2012 - Philippe Le Sager - adapted for lon-lat MPI domain decomposition
  81. ! 21 mar 2014 - Jason Williams - port the modified CB05 chemistry scheme
  82. !
  83. ! !REMARKS:
  84. ! (1) initializations are made in chemistry/chemistry_init
  85. !
  86. ! !TODO : FIXME check sum_chemistry and sum_deposition
  87. !
  88. !EOP
  89. !------------------------------------------------------------------------
  90. contains
  91. !--------------------------------------------------------------------------
  92. ! TM5 !
  93. !--------------------------------------------------------------------------
  94. !BOP
  95. !
  96. ! !IROUTINE: EBI
  97. !
  98. ! !DESCRIPTION: perform Eulerian backwards chemistry at one model layer
  99. ! level in one region
  100. !\\
  101. !\\
  102. ! !INTERFACE:
  103. !
  104. subroutine EBI( region, level, is, js, rj, rr, y, ye, status)
  105. !
  106. ! !USES:
  107. !
  108. use dims, only : im, jm, nchem, tref, okdebug
  109. use Dims, only : CheckShape
  110. use binas, only : avog
  111. use chem_param, only : xmso4
  112. use global_data, only : region_dat
  113. #ifndef without_dry_deposition
  114. use dry_deposition, only : vd
  115. #endif
  116. !
  117. ! !INPUT PARAMETERS:
  118. !
  119. integer, intent(in) :: region, level, is, js
  120. real, intent(in) :: rr(is:,js:,:) ! array of reaction rates
  121. real, intent(in) :: rj(is:,js:,:) ! array of photolysis rates
  122. !
  123. ! !INPUT/OUTPUT PARAMETERS:
  124. !
  125. real, intent(inout) :: y(is:,js:,:) ! array of concentration
  126. real, intent(inout) :: ye(is:,js:,:)
  127. !
  128. ! !OUTPUT PARAMETERS:
  129. !
  130. integer, intent(out) :: status
  131. !
  132. ! !REVISION HISTORY:
  133. ! 22 Mar 2012 - P. Le Sager - adapted for lon-lat MPI domain decomposition
  134. !
  135. !EOP
  136. !------------------------------------------------------------------------
  137. !BOC
  138. character(len=*), parameter :: rname = mname//'/ebi'
  139. #ifdef with_budgets
  140. real, dimension(:,:,:), allocatable :: cr2, cr3, cr4 ! reaction budgets
  141. #endif
  142. real, dimension(:,:,:), allocatable :: y0
  143. real :: dtime, dt, dt2, fnoy
  144. integer :: iterebi, i, j, ib, maxit
  145. integer :: io, sfstart, sfend
  146. !SOA parameters
  147. real,parameter :: total_soa_yield_isoprene=0.01
  148. real,parameter :: total_soa_yield_terpenes=0.15
  149. real,parameter :: y_oh_isop_elvoc=0.0003
  150. real,parameter :: y_o3_isop_elvoc=0.0001
  151. real,parameter :: y_oh_terp_elvoc=0.01
  152. real,parameter :: y_o3_terp_elvoc=0.05
  153. real :: y_oh_isop_svoc ! =0.01-0.0003
  154. real :: y_o3_isop_svoc ! =0.01-0.0001
  155. real :: y_oh_terp_svoc ! =0.15-0.01
  156. real :: y_o3_terp_svoc ! =0.15-0.05
  157. ! For vectorization/blocking ....
  158. ! npts can be varied to optimize cache memory management.
  159. integer, parameter :: npts=15
  160. integer, dimension(npts) :: ipts, jpts
  161. real, dimension(npts, nreac ) :: rrv
  162. real, dimension(npts, nj ) :: rjv
  163. real, dimension(npts, ntrace) :: vdv ! deposition velocities
  164. real, dimension(npts) :: emino
  165. real, dimension(npts, maxtrace) :: yv, y0v
  166. integer :: iv, itrace, ivt, n
  167. integer :: i1, j1, i2, j2
  168. ! --- BEGIN --------------------------------
  169. call Get_DistGrid( dgrid(region), I_STRT=i1, I_STOP=i2, J_STRT=j1, J_STOP=j2 )
  170. ! check arguments ...
  171. call CheckShape( (/i2-i1+1, j2-j1+1, nreac /), shape(rr), status )
  172. IF_NOTOK_RETURN(status=1)
  173. call CheckShape( (/i2-i1+1, j2-j1+1, nj /), shape(rj), status )
  174. IF_NOTOK_RETURN(status=1)
  175. call CheckShape( (/i2-i1+1, j2-j1+1, maxtrace/), shape(y ), status )
  176. IF_NOTOK_RETURN(status=1)
  177. call CheckShape( (/i2-i1+1, j2-j1+1, n_extra /), shape(ye), status )
  178. IF_NOTOK_RETURN(status=1)
  179. dtime=nchem/(2*tref(region))
  180. !CMK iterebi=max(1,nint(dtime/2400)) !needed if nchem <2400
  181. iterebi=max(1,nint(dtime/1350)) !needed if nchem <2400
  182. dt=dtime/iterebi
  183. ! define svoc yield as remainder total soa yield after elvoc yields
  184. ! total yields at present (to check see variable defs):
  185. ! 1% for isoprene
  186. ! 15% for terpenes
  187. y_oh_isop_svoc=total_soa_yield_isoprene - y_oh_isop_elvoc
  188. y_o3_isop_svoc=total_soa_yield_isoprene - y_o3_isop_elvoc
  189. y_oh_terp_svoc=total_soa_yield_terpenes - y_oh_terp_elvoc
  190. y_o3_terp_svoc=total_soa_yield_terpenes - y_o3_terp_elvoc
  191. allocate( y0 (i1:i2, j1:j2, maxtrace))
  192. #ifdef with_budgets
  193. allocate( cr2(i1:i2, j1:j2, nj ))
  194. allocate( cr3(i1:i2, j1:j2, nreac ))
  195. allocate( cr4(i1:i2, j1:j2, nreacw ))
  196. allocate( temp_prod_so4(npts,2))
  197. allocate( temp_loss(npts,2))
  198. allocate( temp_prod_vocs(npts,8))
  199. #endif
  200. !*** SCALING OF NOx, which has changed due to transport/deposition
  201. ! This does not yet work. TODO: Make this working. (FIXME : ask VH what's this is about???)
  202. do j = j1, j2
  203. do i = i1, i2
  204. y(i,j,ino) =max(1e-3,y(i,j,ino))
  205. y(i,j,ino2) =max(1e-3,y(i,j,ino2))
  206. y(i,j,ino3) =max(1e-3,y(i,j,ino3))
  207. y(i,j,in2o5)=max(1e-3,y(i,j,in2o5))
  208. y(i,j,ihno4)=max(1e-3,y(i,j,ihno4))
  209. fnoy=y(i,j,ino)+y(i,j,ino2)+y(i,j,ino3)+2.*y(i,j,in2o5)+y(i,j,ihno4)
  210. fnoy=y(i,j,inox)/fnoy
  211. y(i,j,ino) =fnoy*y(i,j,ino)
  212. y(i,j,ino2) =fnoy*y(i,j,ino2)
  213. y(i,j,ino3) =fnoy*y(i,j,ino3)
  214. y(i,j,in2o5)=fnoy*y(i,j,in2o5)
  215. y(i,j,ihno4)=fnoy*y(i,j,ihno4)
  216. end do
  217. end do
  218. !
  219. ! set budget accumulators to zero
  220. !
  221. #ifdef with_budgets
  222. cr2 = 0.0
  223. cr3 = 0.0
  224. cr4 = 0.0
  225. temp_loss = 0.0
  226. temp_prod_so4 = 0.0
  227. temp_prod_vocs = 0.0
  228. #endif
  229. !===========================================================
  230. ! ** Start iterating over CHEMISTRY
  231. !===========================================================
  232. do ib=1,iterebi
  233. maxit=8 !CMKTEMP
  234. if(level<=3) maxit = maxit*2 ! lowest layers more iterations
  235. y0 = y
  236. !-------------------------------
  237. ! wet sulphur/ammonia chemistry
  238. !------------------------------
  239. #ifdef with_budgets
  240. call wetS(region, level, i1, j1, y0, dt, y, ye, cr4, status)
  241. #else
  242. call wetS(region, level, i1, j1, y0, dt, y, ye, status)
  243. #endif
  244. !-------------------------------------
  245. ! gasphase chemistry using EBI solver
  246. !-------------------------------------
  247. y0 = y ! reset initial concentrations
  248. ! ______do EBI solver_______
  249. dt2 = dt*dt
  250. ! block the input for EBI for efficiency:
  251. ! copy values with faster running index in inside loop
  252. iv = 0
  253. do j = j1, j2
  254. do i = i1, i2
  255. iv = iv+1
  256. ipts(iv) = i
  257. jpts(iv) = j
  258. if(iv==npts) then
  259. ! copy reaction rates...
  260. do itrace=1,nreac
  261. do ivt=1,npts
  262. rrv(ivt,itrace) = rr(ipts(ivt),jpts(ivt),itrace)
  263. end do
  264. end do
  265. ! copy photolysis rates....
  266. do itrace=1,nj
  267. do ivt=1,npts
  268. rjv(ivt,itrace) = rj(ipts(ivt),jpts(ivt),itrace)
  269. end do
  270. end do
  271. ! copy tracer concentrations ....
  272. do itrace=1,maxtrace
  273. do ivt=1,npts
  274. yv(ivt,itrace) = y(ipts(ivt),jpts(ivt),itrace)
  275. y0v(ivt,itrace) = y0(ipts(ivt),jpts(ivt),itrace)
  276. end do
  277. end do
  278. ! deposition ....
  279. #ifndef without_dry_deposition
  280. if(level == 1) then
  281. do itrace=1,ntrace
  282. do ivt=1,npts
  283. vdv(ivt,itrace) = &
  284. vd(region,itrace)%surf(ipts(ivt),jpts(ivt)) &
  285. / ye(ipts(ivt),jpts(ivt),idz) !1/s
  286. end do
  287. end do
  288. else
  289. vdv(:,:) = 0.0
  290. end if
  291. #endif
  292. ! copy nox emissions....
  293. do ivt=1,npts
  294. emino(ivt) = ye(ipts(ivt),jpts(ivt),ieno)
  295. end do
  296. ! do ebi solver....
  297. call DO_EBI(iv, npts, maxit, dt, dt2, rrv, rjv, vdv, emino, yv, y0v)
  298. do itrace=1,maxtrace
  299. do ivt=1,npts
  300. y(ipts(ivt),jpts(ivt),itrace)=yv(ivt,itrace)
  301. end do
  302. end do
  303. #ifdef with_budgets
  304. #ifdef with_m7
  305. do ivt=1,npts
  306. ! add change in gas-phase so4 production to diagnostic and change to mole->mass kg
  307. diag_prod(region)%prod(ipts(ivt),jpts(ivt),level,1)=diag_prod(region)%prod(ipts(ivt),jpts(ivt),level,1)+temp_prod_so4(ivt,1)/y(ipts(ivt),jpts(ivt),iair)*ye(ipts(ivt),jpts(ivt),iairm)/xmair*xmso4!kg
  308. AC_diag_prod(region)%prod(ipts(ivt),jpts(ivt),level,iprod_gasso4)=AC_diag_prod(region)%prod(ipts(ivt),jpts(ivt),level,iprod_gasso4)+temp_prod_so4(ivt,1)/y(ipts(ivt),jpts(ivt),iair)*ye(ipts(ivt),jpts(ivt),iairm)/xmair*xmso4!kg
  309. diag_prod(region)%prod(ipts(ivt),jpts(ivt),level,5)=diag_prod(region)%prod(ipts(ivt),jpts(ivt),level,5)+temp_prod_vocs(ivt,1)/y(ipts(ivt),jpts(ivt),iair)*ye(ipts(ivt),jpts(ivt),iairm)/xmair*xmelvoc!kg
  310. diag_prod(region)%prod(ipts(ivt),jpts(ivt),level,6)=diag_prod(region)%prod(ipts(ivt),jpts(ivt),level,6)+temp_prod_vocs(ivt,2)/y(ipts(ivt),jpts(ivt),iair)*ye(ipts(ivt),jpts(ivt),iairm)/xmair*xmelvoc!kg
  311. diag_prod(region)%prod(ipts(ivt),jpts(ivt),level,7)=diag_prod(region)%prod(ipts(ivt),jpts(ivt),level,7)+temp_prod_vocs(ivt,3)/y(ipts(ivt),jpts(ivt),iair)*ye(ipts(ivt),jpts(ivt),iairm)/xmair*xmelvoc!kg
  312. diag_prod(region)%prod(ipts(ivt),jpts(ivt),level,8)=diag_prod(region)%prod(ipts(ivt),jpts(ivt),level,8)+temp_prod_vocs(ivt,4)/y(ipts(ivt),jpts(ivt),iair)*ye(ipts(ivt),jpts(ivt),iairm)/xmair*xmelvoc!kg
  313. diag_prod(region)%prod(ipts(ivt),jpts(ivt),level,9)=diag_prod(region)%prod(ipts(ivt),jpts(ivt),level,9)+temp_prod_vocs(ivt,5)/y(ipts(ivt),jpts(ivt),iair)*ye(ipts(ivt),jpts(ivt),iairm)/xmair*xmsvoc!kg
  314. diag_prod(region)%prod(ipts(ivt),jpts(ivt),level,10)=diag_prod(region)%prod(ipts(ivt),jpts(ivt),level,10)+temp_prod_vocs(ivt,6)/y(ipts(ivt),jpts(ivt),iair)*ye(ipts(ivt),jpts(ivt),iairm)/xmair*xmsvoc!kg
  315. diag_prod(region)%prod(ipts(ivt),jpts(ivt),level,11)=diag_prod(region)%prod(ipts(ivt),jpts(ivt),level,11)+temp_prod_vocs(ivt,7)/y(ipts(ivt),jpts(ivt),iair)*ye(ipts(ivt),jpts(ivt),iairm)/xmair*xmsvoc!kg
  316. diag_prod(region)%prod(ipts(ivt),jpts(ivt),level,12)=diag_prod(region)%prod(ipts(ivt),jpts(ivt),level,12)+temp_prod_vocs(ivt,8)/y(ipts(ivt),jpts(ivt),iair)*ye(ipts(ivt),jpts(ivt),iairm)/xmair*xmsvoc!kg
  317. end do
  318. #endif
  319. #endif
  320. iv=0
  321. end if
  322. end do
  323. end do
  324. ! do the 'remaining' points...
  325. if(iv > 0) then
  326. do itrace=1,nreac
  327. do ivt=1,iv
  328. rrv(ivt,itrace) = rr(ipts(ivt),jpts(ivt),itrace)
  329. end do
  330. end do
  331. do itrace=1,nj
  332. do ivt=1,iv
  333. rjv(ivt,itrace) = rj(ipts(ivt),jpts(ivt),itrace)
  334. end do
  335. end do
  336. do itrace=1,maxtrace
  337. do ivt=1,iv
  338. yv(ivt,itrace) = y(ipts(ivt),jpts(ivt),itrace)
  339. y0v(ivt,itrace) = y0(ipts(ivt),jpts(ivt),itrace)
  340. end do
  341. end do
  342. ! deposition ....
  343. #ifndef without_dry_deposition
  344. if(level == 1) then
  345. do itrace=1,ntrace
  346. do ivt=1,iv
  347. vdv(ivt,itrace) = &
  348. vd(region,itrace)%surf(ipts(ivt),jpts(ivt)) &
  349. / ye(ipts(ivt),jpts(ivt),idz) !1/s
  350. end do
  351. end do
  352. else
  353. vdv(:,:) = 0.0
  354. end if
  355. #endif
  356. do ivt=1,iv
  357. emino(ivt) = ye(ipts(ivt),jpts(ivt),ieno)
  358. end do
  359. !the actual EBI solver on remaining cells
  360. call DO_EBI(iv, npts, maxit, dt, dt2, rrv, rjv, vdv, emino, yv, y0v)
  361. do itrace=1,maxtrace
  362. do ivt=1,iv
  363. y(ipts(ivt),jpts(ivt),itrace)=yv(ivt,itrace)
  364. end do
  365. end do
  366. #ifdef with_budgets
  367. #ifdef with_m7
  368. do ivt=1,iv
  369. ! add change in so4 production to diagnostic and change to molec->mass kg
  370. !
  371. diag_prod(region)%prod(ipts(ivt),jpts(ivt),level,1)= diag_prod(region)%prod(ipts(ivt),jpts(ivt),level,1)+temp_prod_so4(ivt,1)/y(ipts(ivt),jpts(ivt),iair)*ye(ipts(ivt),jpts(ivt),iairm)/xmair*xmso4!kg
  372. AC_diag_prod(region)%prod(ipts(ivt),jpts(ivt),level,iprod_gasso4)=AC_diag_prod(region)%prod(ipts(ivt),jpts(ivt),level,iprod_gasso4)+temp_prod_so4(ivt,1)/y(ipts(ivt),jpts(ivt),iair)*ye(ipts(ivt),jpts(ivt),iairm)/xmair*xmso4!kg
  373. ! SAVE SOA twice, one for hourly output and once fro monthly. Two variables needed because zeroing happens at different time steps
  374. diag_prod(region)%prod(ipts(ivt),jpts(ivt),level,5)=diag_prod(region)%prod(ipts(ivt),jpts(ivt),level,5)+temp_prod_vocs(ivt,1)/y(ipts(ivt),jpts(ivt),iair)*ye(ipts(ivt),jpts(ivt),iairm)/xmair*xmelvoc
  375. diag_prod(region)%prod(ipts(ivt),jpts(ivt),level,6)=diag_prod(region)%prod(ipts(ivt),jpts(ivt),level,6)+temp_prod_vocs(ivt,2)/y(ipts(ivt),jpts(ivt),iair)*ye(ipts(ivt),jpts(ivt),iairm)/xmair*xmelvoc
  376. diag_prod(region)%prod(ipts(ivt),jpts(ivt),level,7)=diag_prod(region)%prod(ipts(ivt),jpts(ivt),level,7)+temp_prod_vocs(ivt,3)/y(ipts(ivt),jpts(ivt),iair)*ye(ipts(ivt),jpts(ivt),iairm)/xmair*xmelvoc
  377. diag_prod(region)%prod(ipts(ivt),jpts(ivt),level,8)=diag_prod(region)%prod(ipts(ivt),jpts(ivt),level,8)+temp_prod_vocs(ivt,4)/y(ipts(ivt),jpts(ivt),iair)*ye(ipts(ivt),jpts(ivt),iairm)/xmair*xmelvoc
  378. diag_prod(region)%prod(ipts(ivt),jpts(ivt),level,9)=diag_prod(region)%prod(ipts(ivt),jpts(ivt),level,9)+temp_prod_vocs(ivt,5)/y(ipts(ivt),jpts(ivt),iair)*ye(ipts(ivt),jpts(ivt),iairm)/xmair*xmsvoc
  379. diag_prod(region)%prod(ipts(ivt),jpts(ivt),level,10)=diag_prod(region)%prod(ipts(ivt),jpts(ivt),level,10)+temp_prod_vocs(ivt,6)/y(ipts(ivt),jpts(ivt),iair)*ye(ipts(ivt),jpts(ivt),iairm)/xmair*xmsvoc
  380. diag_prod(region)%prod(ipts(ivt),jpts(ivt),level,11)=diag_prod(region)%prod(ipts(ivt),jpts(ivt),level,11)+temp_prod_vocs(ivt,7)/y(ipts(ivt),jpts(ivt),iair)*ye(ipts(ivt),jpts(ivt),iairm)/xmair*xmsvoc
  381. diag_prod(region)%prod(ipts(ivt),jpts(ivt),level,12)=diag_prod(region)%prod(ipts(ivt),jpts(ivt),level,12)+temp_prod_vocs(ivt,8)/y(ipts(ivt),jpts(ivt),iair)*ye(ipts(ivt),jpts(ivt),iairm)/xmair*xmsvoc
  382. end do
  383. #endif
  384. #endif
  385. end if
  386. call NOYmass
  387. !-------------------------------------
  388. ! marked tracers
  389. ! apply after correction of nitrogen components
  390. !----------------------------------------------
  391. call MARK_TRAC(region, level, is, js, y, rr, rj, dt, ye)
  392. !------------------------------------------------------------
  393. ! increase budget accumulators cr2 and cr3 (cr4 is done in wetS)
  394. !------------------------------------------------------------
  395. #ifdef with_budgets
  396. call incc2c3
  397. #endif
  398. !===========================================================
  399. ! ** END iterating over CHEMISTRY
  400. !===========================================================
  401. end do !iterebi
  402. #ifdef with_budgets
  403. call REACBUD
  404. #endif
  405. deallocate(y0)
  406. #ifdef with_budgets
  407. deallocate(cr2)
  408. deallocate(cr3)
  409. deallocate(cr4)
  410. deallocate(temp_prod_so4)
  411. deallocate(temp_prod_vocs)
  412. deallocate(temp_loss)
  413. #endif
  414. ! ok
  415. status = 0
  416. contains
  417. subroutine DO_EBI(lvec, npts, maxit, dt, dt2, rrv, rjv, vdv, emino, yv, y0v)
  418. ! INPUT/OUTPUT
  419. integer,intent(in) :: lvec, npts, maxit
  420. real, intent(in) :: dt, dt2, rrv(npts,nreac), rjv(npts,nj), &
  421. vdv(npts,ntrace), emino(npts), &
  422. y0v(npts,maxtrace)
  423. real, intent(out) :: yv(npts,maxtrace)
  424. ! Local
  425. integer :: ivec,iter
  426. real :: r57, r89, p1, r12, r21, xl1, p2, xl2, p3, p32, &
  427. xl3, x1, x2, x3, c1, c2, c3, y2, xjt,r21t, &
  428. r12t, acub, bcub,ccub,cubdet,dno2,r56, r65, r75,p5, &
  429. xl5, r66, x5, p6, xl6, x6, c6, x17, y1, c7, &
  430. r98, p8, xl8, x4, c5, xl9, r101,r102,xl7, &
  431. c8 , x101, r1920, r1919, p19, xl19,r2019, xl20, &
  432. xlhno3, ph2o2, xlh2o2, pch2o, pco, phno3, xlch2o, &
  433. pch3o2, xlch3o2, pch3o2h, xlch3o2h, pald2, &
  434. xlald2, pmgly, xlmgly, pole, xleth, xlole, &
  435. xlisop, prxpar, xlrxpar, ppar, xlpar, pror, &
  436. xlror, pxo2,xlxo2,pxo2n, xlxo2n, prooh,xlterp, &
  437. xlethooh,xlethp,phcooh,pmcooh,xlc3h6, xlrooh, &
  438. porgntr, xlorgntr, xlco, qdms, pso2, qso2, qso2d, &
  439. qnh3, qnh2o2, ppnh3, dnh3, pnh2, qnh2, qdms1, qdms2, &
  440. pmsa, pnh3, pispd,xlispd,xlacet,paco2,xlaco2, &
  441. pch3oh, pc3h7o2,phypro2,xlc3h7o2,xlhypro2,pacet, &
  442. pelvoc,psvoc!RM
  443. do iter=1,maxit
  444. do ivec=1,lvec
  445. ! --- Short living compounds & groups
  446. ! --- First group: NO NO2 O3
  447. P1=rjv(ivec,jbno3)*yv(ivec,ino3)+rjv(ivec,jn2o5b)*yv(ivec,in2o5)&
  448. +rjv(ivec,jhono)*yv(ivec,ihono)+rrv(ivec,knh2o2)*yv(ivec,inh2)+emino(ivec)
  449. R12=0.
  450. R21=rrv(ivec,kho2no)*yv(ivec,iho2)+rrv(ivec,kmo2no)*yv(ivec,ich3o2)&
  451. +rrv(ivec,kc79)*yv(ivec,ixo2)+rrv(ivec,kc46)*yv(ivec,ic2o3) &
  452. +rrv(ivec,kaco2no)*yv(ivec,iaco2)+rrv(ivec,kc3h7o2no)*yv(ivec,ic3h7o2)&
  453. +rrv(ivec,khypo2no)*yv(ivec,ihypro2)+rrv(ivec,knh2o2no)*yv(ivec,inh2o2)
  454. XL1=rrv(ivec,knono3)*yv(ivec,ino3)+rrv(ivec,kc81)*yv(ivec,ixo2n)&
  455. +rrv(ivec,knh2no)*yv(ivec,inh2)+rrv(ivec,khono)*yv(ivec,ioh)
  456. XL1 = XL1 + vdv(ivec,ino)
  457. P2=rjv(ivec,jhno3)*yv(ivec,ihno3)+rjv(ivec,jn2o5a)*yv(ivec,in2o5)&
  458. +rrv(ivec,kn2o5)*yv(ivec,in2o5)+rjv(ivec,jano3)*yv(ivec,ino3)&
  459. +yv(ivec,ihno4)*(rjv(ivec,jhno4)+rrv(ivec,khno4m)+rrv(ivec,khno4oh)*yv(ivec,ioh))&
  460. +rrv(ivec,kohhono)*yv(ivec,ioh)*yv(ivec,ihono)&
  461. +2.*rrv(ivec,knono3)*yv(ivec,ino3)*yv(ivec,ino)&
  462. +rrv(ivec,kc48)*yv(ivec,ipan)+rrv(ivec,kc59)*yv(ivec,iole)*yv(ivec,ino3)&
  463. +rjv(ivec,jorgn)*yv(ivec,iorgntr)&
  464. +rjv(ivec,jpana)*yv(ivec,ipan)&
  465. +0.2*rrv(ivec,kc78) *yv(ivec,iisop)*yv(ivec,ino3)&
  466. +rrv(ivec,kno3mo2)*yv(ivec,ich3o2)*yv(ivec,ino3)&
  467. +rrv(ivec,kno3c2o3)*yv(ivec,ic2o3)*yv(ivec,ino3)&
  468. +rrv(ivec,kno3xo2)*yv(ivec,ixo2)*yv(ivec,ino3)&
  469. +0.47*rrv(ivec,kno3terp)*yv(ivec,ino3)*yv(ivec,iterp)&
  470. +rjv(ivec,jmo2no2a)*yv(ivec,ich3o2no2)&
  471. +rrv(ivec,kch3o2no2m)*yv(ivec,ich3o2no2)
  472. XL2=rrv(ivec,kno2oh)*yv(ivec,ioh)+rrv(ivec,kno2no3)*yv(ivec,ino3)&
  473. +rrv(ivec,kno2ho2)*yv(ivec,iho2)+rrv(ivec,kno2o3)*yv(ivec,io3)&
  474. +rrv(ivec,kc47)*yv(ivec,ic2o3)+rrv(ivec,knh2no2)*yv(ivec,inh2)&
  475. +rrv(ivec,kmo2no2)*yv(ivec,ich3o2)
  476. XL2 = XL2 + vdv(ivec,ino2)
  477. P3=rjv(ivec,jano3)*yv(ivec,ino3)+rjv(ivec,jo2) ! JEW : O3P + O2 = O3
  478. XL3=rrv(ivec,ko3ho2)*yv(ivec,iho2)+rrv(ivec,ko3oh)*yv(ivec,ioh)&
  479. +rrv(ivec,kno2o3)*yv(ivec,ino2)+rjv(ivec,jo3d)+rrv(ivec,ko3po3)&
  480. +rrv(ivec,kc58)*yv(ivec,iole)&
  481. +rrv(ivec,kc62)*yv(ivec,ieth)&
  482. +rrv(ivec,kc77)*yv(ivec,iisop)&
  483. +rrv(ivec,ko3c3h6)*yv(ivec,ic3h6)&
  484. +rrv(ivec,ko3terp)*yv(ivec,iterp)&
  485. +rrv(ivec,ko3ispd)*yv(ivec,iispd)&
  486. +rrv(ivec,knh2o3)*yv(ivec,inh2)&
  487. +rrv(ivec,knh2o2o3)*yv(ivec,inh2o2)
  488. XL3 = XL3 + vdv(ivec,io3)
  489. X1=y0v(ivec,ino)+P1*DT
  490. X2=y0v(ivec,ino2)+P2*DT
  491. X3=y0v(ivec,io3)+P3*DT
  492. C1=1.+XL1*DT
  493. C2=1.+XL2*DT
  494. C3=1.+XL3*DT
  495. Y1=rrv(ivec,knoo3)*DT
  496. R21T=R21*DT
  497. R12T=R12*DT
  498. XJT=rjv(ivec,jno2)*DT
  499. P32=0.4*rrv(ivec,kc50)*yv(ivec,ic2o3)*yv(ivec,iho2)
  500. ! --- Solve unknown: x
  501. ACUB=-2.*Y1*(C2+R12T+C2*R21T/C1)
  502. BCUB=2.*C1*C2*C3+2.*C1*C3*(R12T+XJT)+2.*C2*C3*R21T+&
  503. 2.*Y1*(R12T*(X1-X2)+2.*C2*R21T*X1/C1+C2*(X1+X3))
  504. CCUB=2.*C1*C3*X2*(R12T+XJT)-2.*C2*C3*X1*R21T+2.*Y1*X1*&
  505. (X2*R12T-C2*X3-C2*R21T*X1/C1)
  506. CUBDET=BCUB*BCUB-4.*ACUB*CCUB
  507. DNO2=(-1.*BCUB+SQRT(CUBDET))/(2.*ACUB)
  508. dno2=min(x1,dno2)
  509. yv(ivec,ino2)=(X2+DNO2)/C2
  510. yv(ivec,ino)=(X1-DNO2)/C1
  511. yv(ivec,io3)=(X3+(P32*dt)+XJT*yv(ivec,ino2))/(C3+Y1*yv(ivec,ino))
  512. ! --- Second group: yv(ivec,iho2) yv(ivec,ioh) yv(ivec,ihno4) yv(ivec,ihono)
  513. R57=rjv(ivec,jhno4)+rrv(ivec,khno4m)
  514. R56=rrv(ivec,kcooh)*yv(ivec,ico)+rrv(ivec,ko3oh)*yv(ivec,io3)+rrv(ivec,khpoh)&
  515. *yv(ivec,ih2o2)+rrv(ivec,kfrmoh)*yv(ivec,ich2o)+rrv(ivec,kh2oh)&
  516. +rrv(ivec,kso2oh)*yv(ivec,iso2)
  517. p5=2.*rjv(ivec,jbch2o)*yv(ivec,ich2o)&
  518. +rrv(ivec,kmo2no)*yv(ivec,ich3o2)*yv(ivec,ino)&
  519. +rjv(ivec,jmepe)*yv(ivec,ich3o2h)&
  520. +2.0*rjv(ivec,jald2)*yv(ivec,iald2)&
  521. +rjv(ivec,jmgly)*yv(ivec,imgly)+0.11*rrv(ivec,kc52)*yv(ivec,ipar)*yv(ivec,ioh)&
  522. +0.94*rrv(ivec,kc53)*yv(ivec,iror)+rrv(ivec,kc54)*yv(ivec,iror)&
  523. +1.57*rrv(ivec,kc57)*yv(ivec,iole)*yv(ivec,ioh)&
  524. +0.76*rrv(ivec,kc58)*yv(ivec,io3)*yv(ivec,iole)&
  525. +0.56*rrv(ivec,kc59)*yv(ivec,ino3)*yv(ivec,iole)&
  526. +rrv(ivec,kc61)*yv(ivec,ieth)*yv(ivec,ioh)&
  527. +0.22*rrv(ivec,kc62)*yv(ivec,ieth)*yv(ivec,io3)&
  528. +0.066*rrv(ivec,kc77)*yv(ivec,iisop)*yv(ivec,io3)&
  529. +rrv(ivec,kc41)*yv(ivec,ich2o)*yv(ivec,ino3)&
  530. +0.9*rrv(ivec,kc84)*yv(ivec,ioh)*yv(ivec,iorgntr)&
  531. +0.9*rjv(ivec,jorgn)*yv(ivec,iorgntr)&
  532. +0.8*rrv(ivec,kc78)*yv(ivec,iisop)*yv(ivec,ino3)&
  533. +0.74*rrv(ivec,kmo2mo2)*yv(ivec,ich3o2)*yv(ivec,ich3o2)&
  534. +0.9*rjv(ivec,jrooh)*yv(ivec,irooh)&
  535. +rrv(ivec,kno3mo2)*yv(ivec,ich3o2)*yv(ivec,ino3)&
  536. +0.19*rrv(ivec,ko3c3h6)*yv(ivec,io3)*yv(ivec,ic3h6)&
  537. +0.28*rrv(ivec,ko3terp)*yv(ivec,io3)*yv(ivec,iterp)&
  538. +0.75*rrv(ivec,kno3terp)*yv(ivec,ino3)*yv(ivec,iterp)&
  539. +0.154*rrv(ivec,ko3ispd)*yv(ivec,io3)*yv(ivec,iispd)&
  540. +0.925*rrv(ivec,kno3ispd)*yv(ivec,ino3)*yv(ivec,iispd)&
  541. +1.033*rjv(ivec,jispd)*yv(ivec,iispd)&
  542. +rrv(ivec,kohch3oh)*yv(ivec,ich3oh)&
  543. +rrv(ivec,kohhcooh)*yv(ivec,ihcooh)&
  544. +rrv(ivec,kohethoh)*yv(ivec,iethoh)&
  545. +1.22*rrv(ivec,kohterp)*yv(ivec,iterp)&
  546. +rrv(ivec,kohc2h6)*yv(ivec,ic2h6)&
  547. +0.5*rrv(ivec,kc76)*yv(ivec,ioh)*yv(ivec,iisop)& ! reduced according to archibald et al, AE, 2011
  548. +0.503*rrv(ivec,kohispd)*yv(ivec,ioh)*yv(ivec,iispd)&
  549. +0.5*rrv(ivec,kaco2mo2)*yv(ivec,iaco2)*yv(ivec,ich3o2)&
  550. +rrv(ivec,kaco2no)*yv(ivec,iaco2)*yv(ivec,ino)&
  551. +rrv(ivec,kc3h7o2no)*yv(ivec,ic3h7o2)*yv(ivec,ino)&
  552. +rjv(ivec,jmo2no2b)*yv(ivec,ich3o2no2)
  553. XL5=rrv(ivec,kho2no) *yv(ivec,ino)&
  554. +rrv(ivec,kno2ho2) *yv(ivec,ino2)&
  555. +rrv(ivec,ko3ho2) *yv(ivec,io3)&
  556. +rrv(ivec,kmo2ho2a) *yv(ivec,ich3o2)&
  557. +rrv(ivec,kmo2ho2b) *yv(ivec,ich3o2)&
  558. +rrv(ivec,kc50) *yv(ivec,ic2o3)&
  559. +rrv(ivec,kho2oh) *yv(ivec,ioh)&
  560. +rrv(ivec,kc82) *yv(ivec,ixo2)&
  561. +rrv(ivec,kc85) *yv(ivec,ixo2n)&
  562. +rrv(ivec,kno3ho2) *yv(ivec,ino3)&
  563. +rrv(ivec,kaco2ho2)*yv(ivec,iaco2)&
  564. +rrv(ivec,kc3h7o2ho2)*yv(ivec,ic3h7o2)&
  565. +rrv(ivec,khypo2ho2)*yv(ivec,ihypro2)&
  566. +rrv(ivec,knh2ho2)*yv(ivec,inh2)&
  567. +rrv(ivec,knh2o2ho2)*yv(ivec,inh2o2)&
  568. +rrv(ivec,kho2_aer) &
  569. +rrv(ivec,kho2_l)
  570. R66=2.*rrv(ivec,kho2ho2)
  571. X5=y0v(ivec,iho2)+P5*DT
  572. R65=rrv(ivec,kho2no)*yv(ivec,ino)+rrv(ivec,ko3ho2)*yv(ivec,io3)
  573. P6=rjv(ivec,jhno3)*yv(ivec,ihno3)&
  574. +2.*rjv(ivec,jo3d)*yv(ivec,io3)&
  575. +2.*rjv(ivec,jh2o2)*yv(ivec,ih2o2)&
  576. +rjv(ivec,jmepe)*yv(ivec,ich3o2h)&
  577. +0.1*rrv(ivec,kc58)*yv(ivec,io3)*yv(ivec,iole)&
  578. +0.266*rrv(ivec,kc77)*yv(ivec,iisop)*yv(ivec,io3)&
  579. +rjv(ivec,jrooh)*yv(ivec,irooh)&
  580. +0.12*rrv(ivec,kc62)*yv(ivec,ieth)*yv(ivec,io3)&
  581. +0.33*rrv(ivec,ko3c3h6)*yv(ivec,io3)*yv(ivec,ic3h6)&
  582. +0.57*rrv(ivec,ko3terp)*yv(ivec,iterp)*yv(ivec,io3)&
  583. +0.268*rrv(ivec,ko3ispd)*yv(ivec,io3)*yv(ivec,iispd)
  584. XL6=rrv(ivec,khno4oh)*yv(ivec,ihno4)&
  585. +rrv(ivec,kohhono)*yv(ivec,ihono)&
  586. +rrv(ivec,kho2oh)*yv(ivec,iho2)&
  587. +rrv(ivec,kno2oh)*yv(ivec,ino2)&
  588. +rrv(ivec,khono)*yv(ivec,ino)&
  589. +rrv(ivec,kohhno3)*yv(ivec,ihno3)&
  590. +rrv(ivec,kcooh)*yv(ivec,ico)&
  591. +rrv(ivec,ko3oh)*yv(ivec,io3)&
  592. +rrv(ivec,khpoh)*yv(ivec,ih2o2)&
  593. +rrv(ivec,kfrmoh)*yv(ivec,ich2o)&
  594. +rrv(ivec,kch4oh)*yv(ivec,ich4)&
  595. +0.7*rrv(ivec,kohmper)*yv(ivec,ich3o2h)&
  596. +rrv(ivec,kc43)*yv(ivec,iald2)&
  597. +rrv(ivec,kc73)*yv(ivec,imgly)&
  598. +rrv(ivec,kc52)*yv(ivec,ipar)&
  599. +rrv(ivec,kc57)*yv(ivec,iole)&
  600. +rrv(ivec,kc61)*yv(ivec,ieth)&
  601. +rrv(ivec,kc76)*yv(ivec,iisop)&
  602. +0.77*rrv(ivec,kohrooh)*yv(ivec,irooh)& ! note: change from '0.7' to '0.77'
  603. +rrv(ivec,kc84)*yv(ivec,iorgntr)&
  604. +rrv(ivec,kh2oh)&
  605. +rrv(ivec,kso2oh)*yv(ivec,iso2) & ! bug found by Jason 01/2008
  606. +(rrv(ivec,kdmsoha)+rrv(ivec,kdmsohb)) *yv(ivec,idms) &
  607. +rrv(ivec,knh3oh)*yv(ivec,inh3)&
  608. +rrv(ivec,knh2oh)*yv(ivec,inh2)&
  609. +rrv(ivec,kohch3oh)*yv(ivec,ich3oh)&
  610. +rrv(ivec,kohhcooh)*yv(ivec,ihcooh)&
  611. +rrv(ivec,kohethoh)*yv(ivec,iethoh)&
  612. +rrv(ivec,kohterp)*yv(ivec,iterp)&
  613. +rrv(ivec,kohispd)*yv(ivec,iispd)&
  614. +rrv(ivec,kohmcooh)*yv(ivec,imcooh)&
  615. +rrv(ivec,kohc2h6)*yv(ivec,ic2h6)&
  616. +rrv(ivec,kohc3h8)*yv(ivec,ic3h8)&
  617. +rrv(ivec,kohc3h6)*yv(ivec,ic3h6)&
  618. +rrv(ivec,kohacet)*yv(ivec,iacet)
  619. R101=rjv(ivec,jhono)
  620. X6=y0v(ivec,ioh)+(P6*DT)+(R101*y0v(ivec,ihono)*DT)
  621. C6=1.+XL6*DT
  622. R75=rrv(ivec,kno2ho2)*yv(ivec,ino2)
  623. R102=rrv(ivec,khono)*yv(ivec,ino)
  624. X101=rjv(ivec,jhono)+rrv(ivec,kohhono)*yv(ivec,ioh)
  625. X101= X101 + vdv(ivec,ihono)
  626. C8=1.+X101*DT
  627. XL7=rjv(ivec,jhno4)+rrv(ivec,khno4oh)*yv(ivec,ioh)+rrv(ivec,khno4m)
  628. XL7 = XL7 + vdv(ivec,ihno4)
  629. C7=1.+XL7*DT
  630. Y1=R57/C7
  631. Y2=R56/C6
  632. ACUB=R66*DT
  633. BCUB=1.+XL5*DT-DT2*(Y1*R75+Y2*R65)
  634. CCUB=-1.*X5-DT*(Y1*y0v(ivec,ihno4)+Y2*X6)
  635. CUBDET=BCUB*BCUB-4.*ACUB*CCUB
  636. CUBDET=MAX(CUBDET,1.E-20)
  637. yv(ivec,iho2)=max(0.1,(-1.*BCUB+SQRT(CUBDET))/(2.*ACUB))
  638. yv(ivec,ioh)=(X6+R65*yv(ivec,iho2)*DT)/C6
  639. yv(ivec,ihono)=(y0v(ivec,ihono)+R102*DT*yv(ivec,ioh))/C8
  640. yv(ivec,ihno4)=(y0v(ivec,ihno4)+R75*DT*yv(ivec,iho2))/C7
  641. !
  642. ! --- Third group: NO3 N2O5
  643. !
  644. R89=rjv(ivec,jn2o5a)+rjv(ivec,jn2o5b)+rrv(ivec,kn2o5)
  645. P8=rrv(ivec,kohhno3)*yv(ivec,ihno3)*yv(ivec,ioh)+rrv(ivec,kno2o3)*yv(ivec,ino2)*yv(ivec,io3)&
  646. +rjv(ivec,jmo2no2b)*yv(ivec,ich3o2no2)+rjv(ivec,jpanb)*yv(ivec,ipan)
  647. XL8=rjv(ivec,jbno3)+rjv(ivec,jano3)&
  648. +rrv(ivec,knono3)*yv(ivec,ino)&
  649. +rrv(ivec,kno2no3)*yv(ivec,ino2)&
  650. +rrv(ivec,kc44)*yv(ivec,iald2)&
  651. +rrv(ivec,kc59)*yv(ivec,iole)&
  652. +rrv(ivec,kc78)*yv(ivec,iisop)&
  653. +rrv(ivec,kc41)*yv(ivec,ich2o)&
  654. +rrv(ivec,kdmsno3)*yv(ivec,idms)&
  655. +rrv(ivec,kno3_aer)&
  656. +rrv(ivec,kno3ho2)*yv(ivec,iho2)&
  657. +rrv(ivec,kno3mo2)*yv(ivec,ich3o2)&
  658. +rrv(ivec,kno3c2o3)*yv(ivec,ic2o3)&
  659. +rrv(ivec,kno3xo2)*yv(ivec,ixo2)&
  660. +rrv(ivec,kno3c3h6)*yv(ivec,ic3h6)&
  661. +rrv(ivec,kno3terp)*yv(ivec,iterp)&
  662. +rrv(ivec,kno3ispd)*yv(ivec,iispd)
  663. XL8 = XL8 + vdv(ivec,ino3)
  664. X4=y0v(ivec,ino3)+P8*DT
  665. C5=1.+XL8*DT
  666. R98=rrv(ivec,kno2no3)*yv(ivec,ino2)
  667. XL9=rjv(ivec,jn2o5a)+rjv(ivec,jn2o5b)+rrv(ivec,kn2o5)+rrv(ivec,kn2o5_aer)+rrv(ivec,kn2o5l) !cmk rates now idependent from y
  668. XL9 = XL9 + vdv(ivec,in2o5)
  669. C6=1.+XL9*DT
  670. C7=(C5*C6-R89*R98*DT2)
  671. yv(ivec,in2o5)=(C5*y0v(ivec,in2o5)+R98*DT*X4)/C7
  672. yv(ivec,ino3)=(C6*X4+R89*DT*y0v(ivec,in2o5))/C7
  673. !
  674. ! --- Fourth group: C2O3 PAN
  675. !
  676. R1920=rrv(ivec,kc48)+rjv(ivec,jpana)
  677. R1919=rrv(ivec,kc49)
  678. P19=rrv(ivec,kc43)*yv(ivec,iald2)*yv(ivec,ioh)&
  679. +rrv(ivec,kc44)*yv(ivec,iald2)*yv(ivec,ino3)&
  680. +rrv(ivec,kc73)*yv(ivec,imgly)*yv(ivec,ioh) &
  681. +rjv(ivec,jmgly)*yv(ivec,imgly)&
  682. +0.2*rrv(ivec,kc77)*yv(ivec,iisop)*yv(ivec,io3)&
  683. +0.74*rjv(ivec,jrooh)*yv(ivec,irooh)&
  684. +0.74*rrv(ivec,kc84)*yv(ivec,ioh)*yv(ivec,iorgntr)&
  685. +0.74*rjv(ivec,jorgn)*yv(ivec,iorgntr)&
  686. +0.39*rrv(ivec,ko3terp)*yv(ivec,io3)*yv(ivec,iterp)&
  687. +0.498*rrv(ivec,kohispd)*yv(ivec,ioh)*yv(ivec,iispd)&
  688. +0.114*rrv(ivec,ko3ispd)*yv(ivec,io3)*yv(ivec,iispd)&
  689. +0.075*rrv(ivec,kno3ispd)*yv(ivec,ino3)*yv(ivec,iispd)&
  690. +0.967*rjv(ivec,jispd)*yv(ivec,iispd)&
  691. +0.3*rrv(ivec,kaco2mo2)*yv(ivec,iaco2)*yv(ivec,ich3o2)&
  692. +rrv(ivec,kaco2no)*yv(ivec,iaco2)*yv(ivec,ino)&
  693. +rjv(ivec,jb_acet)*yv(ivec,iacet)&
  694. +rjv(ivec,jmo2no2b)*yv(ivec,ich3o2no2)
  695. XL19=rrv(ivec,kc46)*yv(ivec,ino)+rrv(ivec,kc50)*yv(ivec,iho2)&
  696. +rrv(ivec,kc47)*yv(ivec,ino2)&
  697. +rrv(ivec,kno3c2o3)*yv(ivec,ino3)
  698. XL19 = XL19 + vdv(ivec,ic2o3)
  699. R2019=rrv(ivec,kc47)*yv(ivec,ino2)
  700. XL20=rrv(ivec,kc48)+rjv(ivec,jpana)+rjv(ivec,jpanb)
  701. XL20 = XL20 + vdv(ivec,ipan)
  702. ACUB=2*R1919*DT*(1+XL20*DT)
  703. BCUB=(1+XL20*DT)*(1+XL19*DT)-R1920*DT*R2019*DT
  704. CCUB=(1+XL20*DT)*(y0v(ivec,ic2o3)+P19*DT)+R1920*DT*y0v(ivec,ipan)
  705. CUBDET=BCUB*BCUB+4.*ACUB*CCUB
  706. yv(ivec,ic2o3)=max(1e-8,(-1.*BCUB+SQRT(CUBDET))/(2.*ACUB)) !cmk put max here....
  707. yv(ivec,ipan)=(y0v(ivec,ipan)+R2019*yv(ivec,ic2o3)*DT)/(1.+XL20*DT)
  708. !
  709. ! ---- Fifth group : CH3O2 CH3O2NO2
  710. R1920=rrv(ivec,kch3o2no2m)+rjv(ivec,jmo2no2a)+rjv(ivec,jmo2no2b)
  711. R1919=rrv(ivec,kmo2mo2)
  712. P19=rrv(ivec,kch4oh)*yv(ivec,ich4)*yv(ivec,ioh) &
  713. +0.7*rrv(ivec,kohmper)*yv(ivec,ioh)*yv(ivec,ich3o2h)&
  714. +rrv(ivec,kno3c2o3)*yv(ivec,ino3)*yv(ivec,ic2o3)&
  715. +rrv(ivec,kc46)*yv(ivec,ino)*yv(ivec,ic2o3)&
  716. +2*rrv(ivec,kc49)*yv(ivec,ic2o3)*yv(ivec,ic2o3)&
  717. +rjv(ivec,jpanb)*yv(ivec,ipan)&
  718. +rjv(ivec,jald2)*yv(ivec,iald2)&
  719. +0.74*rjv(ivec,jrooh)*yv(ivec,irooh)&
  720. +0.74*rrv(ivec,kc84)*yv(ivec,iorgntr)&
  721. +0.74*rjv(ivec,jorgn)*yv(ivec,iorgntr)&
  722. +rrv(ivec,kohmcooh)*yv(ivec,ioh)*yv(ivec,imcooh)&
  723. +0.31*rrv(ivec,ko3c3h6)*yv(ivec,io3)*yv(ivec,ic3h6)&
  724. +0.39*rrv(ivec,ko3terp)*yv(ivec,iterp)*yv(ivec,io3)&
  725. +2.0*rjv(ivec,ja_acet)*yv(ivec,iacet)+rjv(ivec,jb_acet)*yv(ivec,iacet)
  726. XL19=rrv(ivec,kmo2no)*yv(ivec,ino)+rrv(ivec,kmo2ho2a)*yv(ivec,iho2)&
  727. +rrv(ivec,kmo2ho2b)*yv(ivec,iho2)+rrv(ivec,kno3mo2)*yv(ivec,ino3)&
  728. +rrv(ivec,kaco2mo2)*yv(ivec,iaco2)+rrv(ivec,kmo2no2)*yv(ivec,ino2)
  729. R2019=rrv(ivec,kmo2no2)*yv(ivec,ino2)
  730. XL20=rrv(ivec,kch3o2no2m)+rjv(ivec,jmo2no2a)+rjv(ivec,jmo2no2b)
  731. XL20 = XL20 + vdv(ivec,ich3o2no2)
  732. ACUB=2*R1919*DT*(1+XL20*DT)
  733. BCUB=(1+XL20*DT)*(1+XL19*DT)-R1920*DT*R2019*DT
  734. CCUB=(1+XL20*DT)*(y0v(ivec,ich3o2)+P19*DT)+R1920*DT*y0v(ivec,ich3o2no2)
  735. CUBDET=BCUB*BCUB+4.*ACUB*CCUB
  736. yv(ivec,ich3o2)=max(1e-8,(-1.*BCUB+SQRT(CUBDET))/(2.*ACUB)) !cmk put max here....
  737. yv(ivec,ich3o2no2)=(y0v(ivec,ich3o2no2)+R2019*yv(ivec,ich3o2)*DT)/(1.+XL20*DT)
  738. !
  739. ! -------- ISPD chemistry
  740. !
  741. pispd=0.912*rrv(ivec,kc76)*yv(ivec,ioh)*yv(ivec,iisop)&
  742. +0.65*rrv(ivec,kc77)*yv(ivec,io3)*yv(ivec,iisop)&
  743. +0.2*rrv(ivec,kc78)*yv(ivec,ino3)*yv(ivec,iisop)
  744. xlispd=rrv(ivec,kohispd)*yv(ivec,ioh)+rrv(ivec,ko3ispd)*yv(ivec,io3)&
  745. +rrv(ivec,kno3ispd)*yv(ivec,ino3)+rjv(ivec,jispd)+vdv(ivec,iispd)
  746. yv(ivec,iispd)=(y0v(ivec,iispd)+pispd*DT)/(1.+xlispd*DT)
  747. !
  748. ! -------- ACO2 chemistry
  749. !
  750. paco2=rrv(ivec,kohacet)*yv(ivec,iacet)*yv(ivec,ioh)
  751. xlaco2=rrv(ivec,kaco2ho2)*yv(ivec,iho2)+rrv(ivec,kaco2mo2)*yv(ivec,ich3o2)&
  752. +rrv(ivec,kaco2no)*yv(ivec,ino)+rrv(ivec,kaco2xo2)*yv(ivec,ixo2)
  753. yv(ivec,iaco2)=(y0v(ivec,iaco2)+paco2*DT)/(1.+xlaco2*DT)
  754. !
  755. ! -------- C3H7O2 chemistry
  756. !
  757. pc3h7o2=rrv(ivec,kohc3h8)*yv(ivec,ic3h8)*yv(ivec,ioh)
  758. xlc3h7o2=rrv(ivec,kc3h7o2no)*yv(ivec,ino)+rrv(ivec,kc3h7o2ho2)*yv(ivec,iho2)
  759. yv(ivec,ic3h7o2)=(y0v(ivec,ic3h7o2)+pc3h7o2*DT)/(1.+xlc3h7o2*DT)
  760. !
  761. ! -------- HYPRO2 chemistry
  762. !
  763. phypro2=rrv(ivec,kohc3h6)*yv(ivec,ic3h6)*yv(ivec,ioh)
  764. xlhypro2=rrv(ivec,khypo2no)*yv(ivec,ino)+rrv(ivec,khypo2ho2)*yv(ivec,iho2)
  765. yv(ivec,ihypro2)=(y0v(ivec,ihypro2)+phypro2*DT)/(1.+xlhypro2*DT)
  766. !
  767. !
  768. ! --- CBM4 chem.(short living compounds & operators)
  769. !
  770. PRXPAR=0.11*rrv(ivec,kc52)*yv(ivec,ioh)*yv(ivec,ipar)&
  771. +2.1*rrv(ivec,kc53)*yv(ivec,iror)&
  772. +0.7*rrv(ivec,kc57)*yv(ivec,iole)*yv(ivec,ioh)&
  773. +rrv(ivec,kc58)*yv(ivec,io3)*yv(ivec,iole)&
  774. +rrv(ivec,kc59)*yv(ivec,iole)*yv(ivec,ino3)&
  775. +rrv(ivec,kohrooh)*yv(ivec,ioh)*yv(ivec,irooh)&
  776. +1.98*rjv(ivec,jrooh)*yv(ivec,irooh)&
  777. +1.98*rrv(ivec,kc84)*yv(ivec,ioh)*yv(ivec,iorgntr)&
  778. +1.98*rjv(ivec,jorgn)*yv(ivec,iorgntr)
  779. XLRXPAR=rrv(ivec,kc83)*yv(ivec,ipar)
  780. yv(ivec,irxpar)=(y0v(ivec,irxpar)+PRXPAR*DT)/(1.+XLRXPAR*DT)
  781. XLISOP=rrv(ivec,kc76)*yv(ivec,ioh)+rrv(ivec,kc77)*yv(ivec,io3)+rrv(ivec,kc78)*yv(ivec,ino3)
  782. yv(ivec,iisop)=y0v(ivec,iisop)/(1.+XLISOP*DT)
  783. PROR=0.76*rrv(ivec,kc52)*yv(ivec,ipar)*yv(ivec,ioh)+0.02*rrv(ivec,kc53)*yv(ivec,iror)
  784. XLROR=rrv(ivec,kc53)+rrv(ivec,kc54)
  785. yv(ivec,iror)=(y0v(ivec,iror)+PROR*DT)/(1.+XLROR*DT)
  786. xlterp=rrv(ivec,kohterp)*yv(ivec,ioh)+rrv(ivec,ko3terp)*yv(ivec,io3)&
  787. +rrv(ivec,kno3terp)*yv(ivec,ino3)
  788. yv(ivec,iterp)=y0v(ivec,iterp)/(1.+xlterp*dt)
  789. #ifdef with_m7
  790. !ELVOC
  791. ! contribution from monoterpene
  792. pelvoc=y_oh_terp_elvoc*rrv(ivec,kohterp)*yv(ivec,ioh)*y0v(ivec,iterp)+y_o3_terp_elvoc*rrv(ivec,ko3terp)*yv(ivec,io3)*y0v(ivec,iterp)
  793. #ifdef with_budgets
  794. temp_prod_vocs(ivec,1)=y_oh_terp_elvoc * rrv(ivec,kohterp)*yv(ivec,ioh)*y0v(ivec,iterp)*DT
  795. temp_prod_vocs(ivec,2)=y_o3_terp_elvoc * rrv(ivec,ko3terp)*yv(ivec,io3)*y0v(ivec,iterp)*DT
  796. #endif
  797. !Contribution from isoprene
  798. if (isoprene_on)then
  799. pelvoc=pelvoc+ y_oh_isop_elvoc*rrv(ivec,kc76)*yv(ivec,ioh)*y0v(ivec,iisop)+y_o3_isop_elvoc*rrv(ivec,kc77)*yv(ivec,io3)*y0v(ivec,iisop)
  800. #ifdef with_budgets
  801. temp_prod_vocs(ivec,3) = y_oh_isop_elvoc*rrv(ivec,kc76)*yv(ivec,ioh)*y0v(ivec,iisop)*DT
  802. temp_prod_vocs(ivec,4) = y_o3_isop_elvoc*rrv(ivec,kc77)*yv(ivec,io3)*y0v(ivec,iisop)*DT
  803. #endif
  804. endif
  805. yv(ivec,ielvoc)=y0v(ivec,ielvoc)+pelvoc*dt
  806. !SVOC
  807. ! contribution from monoterpene
  808. psvoc=y_oh_terp_svoc*rrv(ivec,kohterp)*yv(ivec,ioh)*y0v(ivec,iterp)+y_o3_terp_svoc*rrv(ivec,ko3terp)*yv(ivec,io3)*y0v(ivec,iterp)
  809. #ifdef with_budgets
  810. temp_prod_vocs(ivec,5) = y_oh_terp_svoc*rrv(ivec,kohterp)*yv(ivec,ioh)*y0v(ivec,iterp)*DT
  811. temp_prod_vocs(ivec,6) = y_o3_terp_svoc*rrv(ivec,ko3terp)*yv(ivec,io3)*y0v(ivec,iterp)*DT
  812. #endif
  813. !Contribution from isoprene
  814. if (isoprene_on)then
  815. psvoc=psvoc + y_oh_isop_svoc*rrv(ivec,kc76)*yv(ivec,ioh)*y0v(ivec,iisop)+y_o3_isop_svoc*rrv(ivec,kc77)*yv(ivec,io3)*y0v(ivec,iisop)
  816. #ifdef with_budgets
  817. temp_prod_vocs(ivec,7)= y_oh_isop_svoc*rrv(ivec,kc76)*yv(ivec,ioh)*y0v(ivec,iisop)*DT
  818. temp_prod_vocs(ivec,8)= y_o3_isop_svoc*rrv(ivec,kc77)*yv(ivec,io3)*y0v(ivec,iisop)*DT
  819. #endif
  820. end if
  821. yv(ivec,isvoc)=y0v(ivec,isvoc)+psvoc*dt
  822. #endif
  823. pxo2=rrv(ivec,kc73)*yv(ivec,imgly)*yv(ivec,ioh)&
  824. +0.87*rrv(ivec,kc52)*yv(ivec,ipar)*yv(ivec,ioh)&
  825. +0.96*rrv(ivec,kc53)*yv(ivec,iror)&
  826. +0.8*rrv(ivec,kc57)*yv(ivec,iole)*yv(ivec,ioh)&
  827. +0.22*rrv(ivec,kc58)*yv(ivec,io3)*yv(ivec,iole)&
  828. +0.91*rrv(ivec,kc59)*yv(ivec,iole)*yv(ivec,ino3)&
  829. +rrv(ivec,kc61)*yv(ivec,ieth)*yv(ivec,ioh)&
  830. +0.991*rrv(ivec,kc76)*yv(ivec,iisop)*yv(ivec,ioh)&
  831. +rrv(ivec,kc78)*yv(ivec,iisop)*yv(ivec,ino3)&
  832. +0.77*rrv(ivec,kohrooh)*yv(ivec,irooh)*yv(ivec,ioh)&
  833. +0.5*rjv(ivec,jrooh)*yv(ivec,irooh)&
  834. +0.51*rrv(ivec,kc84)*yv(ivec,ioh)*yv(ivec,iorgntr)&
  835. +0.51*rjv(ivec,jorgn)*yv(ivec,iorgntr)&
  836. +0.2*rrv(ivec,kc77)*yv(ivec,iisop)*yv(ivec,io3)&
  837. +0.1*rrv(ivec,kohethoh)*yv(ivec,ioh)*yv(ivec,iethoh)&
  838. +0.991*rrv(ivec,kohc2h6)*yv(ivec,ioh)*yv(ivec,ic2h6)&
  839. +1.25*rrv(ivec,kohterp)*yv(ivec,ioh)*yv(ivec,iterp)&
  840. +0.76*rrv(ivec,ko3terp)*yv(ivec,io3)*yv(ivec,iterp)&
  841. +1.03*rrv(ivec,kno3terp)*yv(ivec,ino3)*yv(ivec,iterp)&
  842. +0.713*rrv(ivec,kohispd)*yv(ivec,ioh)*yv(ivec,iispd)&
  843. +0.064*rrv(ivec,ko3ispd)*yv(ivec,io3)*yv(ivec,iispd)&
  844. +0.075*rrv(ivec,kno3ispd)*yv(ivec,ino3)*yv(ivec,iispd)&
  845. +0.7*rjv(ivec,jispd)*yv(ivec,iispd)
  846. xlxo2=rrv(ivec,kc79)*yv(ivec,ino)+2.*rrv(ivec,kc80)*yv(ivec,ixo2)&
  847. +rrv(ivec,kc82)*yv(ivec,iho2)+rrv(ivec,kno3xo2)*yv(ivec,ino3)&
  848. +rrv(ivec,kaco2xo2)*yv(ivec,iaco2)+rrv(ivec,kxo2xo2n)*yv(ivec,ixo2n)
  849. yv(ivec,ixo2)=(y0v(ivec,ixo2)+pxo2*dt)/(1.+xlxo2*dt)
  850. pxo2n=0.13*rrv(ivec,kc52)*yv(ivec,ipar)*yv(ivec,ioh)&
  851. +0.04*rrv(ivec,kc53)*yv(ivec,iror)&
  852. +0.09*rrv(ivec,kc59)*yv(ivec,iole)*yv(ivec,ino3)&
  853. +0.009*rrv(ivec,kohc2h6)*yv(ivec,ioh)*yv(ivec,ic2h6)&
  854. +0.088*rrv(ivec,kc76)*yv(ivec,iisop)*yv(ivec,ioh)&
  855. +0.25*rrv(ivec,kohterp)*yv(ivec,ioh)*yv(ivec,iterp)&
  856. +0.18*rrv(ivec,ko3terp)*yv(ivec,io3)*yv(ivec,iterp)&
  857. +0.25*rrv(ivec,kno3terp)*yv(ivec,ino3)*yv(ivec,iterp)
  858. xlxo2n=rrv(ivec,kc81)*yv(ivec,ino)+rrv(ivec,kc85)*yv(ivec,iho2)&
  859. +rrv(ivec,kxo2xo2n)*yv(ivec,ixo2n)+rrv(ivec,kxo2n)*yv(ivec,ixo2n)
  860. yv(ivec,ixo2n)=(y0v(ivec,ixo2n)+pxo2n*dt)/(1.+xlxo2n*dt)
  861. end do !ivec
  862. if ( mod(iter,2) == 0 ) then
  863. do ivec=1,lvec
  864. ! --- Species with intermediate lifetimes
  865. ! --- Inorganic compounds (HNO3 H2O2)
  866. !
  867. PHNO3=rrv(ivec,kno2oh)*yv(ivec,ino2)*yv(ivec,ioh)&
  868. +2.*(rrv(ivec,kn2o5_aer)+rrv(ivec,kn2o5l))*yv(ivec,in2o5)&
  869. +rrv(ivec,kc44)*yv(ivec,iald2)*yv(ivec,ino3)&
  870. +rrv(ivec,kc41)*yv(ivec,ich2o)*yv(ivec,ino3)&
  871. +rrv(ivec,kc84)*yv(ivec,ioh)*yv(ivec,iorgntr)&
  872. +rrv(ivec,kno3ho2)*yv(ivec,ino3)*yv(ivec,iho2)&
  873. +0.15*rrv(ivec,kno3ispd)*yv(ivec,ino3)*yv(ivec,iispd)&
  874. +rrv(ivec,kdmsno3)*yv(ivec,ino3)*yv(ivec,idms)&
  875. +rrv(ivec,kno3_aer)*yv(ivec,ino3)
  876. XLHNO3=rjv(ivec,jhno3)+rrv(ivec,kohhno3)*yv(ivec,ioh)
  877. XLHNO3=XLHNO3 + vdv(ivec,ihno3)
  878. yv(ivec,ihno3)=(y0v(ivec,ihno3)+PHNO3*DT)/(1.+XLHNO3*DT)
  879. PH2O2=rrv(ivec,kho2ho2)*yv(ivec,iho2)*yv(ivec,iho2)&
  880. +0.5*rrv(ivec,kho2_aer)*yv(ivec,iho2)
  881. XLH2O2=rjv(ivec,jh2o2)+rrv(ivec,khpoh)*yv(ivec,ioh)
  882. XLH2O2=XLH2O2 + vdv(ivec,ih2o2)
  883. yv(ivec,ih2o2)=(y0v(ivec,ih2o2)+PH2O2*DT)/(1.+XLH2O2*DT)
  884. ! --- CH4-chemistry (methyl peroxide formaldehyde)
  885. PCH3O2H=rrv(ivec,kmo2ho2a)*yv(ivec,ich3o2)*yv(ivec,iho2)
  886. XLCH3O2H=rrv(ivec,kohmper)*yv(ivec,ioh)+rjv(ivec,jmepe)
  887. XLCH3O2H=XLCH3O2H + vdv(ivec,ich3o2h)
  888. yv(ivec,ich3o2h)=(y0v(ivec,ich3o2h)+PCH3O2H*DT)/(1.+XLCH3O2H*DT)
  889. pch2o=0.3*rrv(ivec,kohmper)*yv(ivec,ich3o2h)*yv(ivec,ioh)&
  890. +rrv(ivec,kmo2no)*yv(ivec,ich3o2)*yv(ivec,ino)&
  891. +rrv(ivec,kmo2ho2b)*yv(ivec,ich3o2)*yv(ivec,iho2)&
  892. +1.37*rrv(ivec,kmo2mo2)*yv(ivec,ich3o2)*yv(ivec,ich3o2)&
  893. +rjv(ivec,jmepe)*yv(ivec,ich3o2h)&
  894. +0.8*rrv(ivec,kc57)*yv(ivec,iole)*yv(ivec,ioh)&
  895. +0.74*rrv(ivec,kc58)*yv(ivec,iole)*yv(ivec,io3)&
  896. +rrv(ivec,kc59)*yv(ivec,iole)*yv(ivec,ino3)&
  897. +1.56*rrv(ivec,kc61)*yv(ivec,ieth)*yv(ivec,ioh)&
  898. +rrv(ivec,kc62)*yv(ivec,ieth)*yv(ivec,io3)&
  899. +0.629*rrv(ivec,kc76)*yv(ivec,iisop)*yv(ivec,ioh)&
  900. +0.6*rrv(ivec,kc77)*yv(ivec,iisop)*yv(ivec,io3)&
  901. +rrv(ivec,kohch3oh)*yv(ivec,ioh)*yv(ivec,ich3oh)&
  902. +rrv(ivec,kno3mo2)*yv(ivec,ino3)*yv(ivec,ich3o2)&
  903. +0.1*rrv(ivec,kohethoh)*yv(ivec,ioh)*yv(ivec,iethoh)&
  904. +0.54*rrv(ivec,ko3c3h6)*yv(ivec,io3)*yv(ivec,ic3h6)&
  905. +1.22*rrv(ivec,kohterp)*yv(ivec,ioh)*yv(ivec,iterp)&
  906. +1.8*rrv(ivec,ko3terp)*yv(ivec,io3)*yv(ivec,iterp)&
  907. +0.167*rrv(ivec,kohispd)*yv(ivec,ioh)*yv(ivec,iispd)&
  908. +0.15*rrv(ivec,ko3ispd)*yv(ivec,io3)*yv(ivec,iispd)&
  909. +0.282*rrv(ivec,kno3ispd)*yv(ivec,ino3)*yv(ivec,iispd)&
  910. +0.9*rjv(ivec,jispd)*yv(ivec,iispd)&
  911. +rrv(ivec,kaco2no)*yv(ivec,iaco2)*yv(ivec,ino)&
  912. +rrv(ivec,khypo2no)*yv(ivec,ino)*yv(ivec,ihypro2)&
  913. +rjv(ivec,jmo2no2b)*yv(ivec,ich3o2no2)
  914. XLCH2O=rjv(ivec,jach2o)+rjv(ivec,jbch2o)+yv(ivec,ioh)*rrv(ivec,kfrmoh)&
  915. +rrv(ivec,kc41)*yv(ivec,ino3)
  916. XLCH2O=XLCH2O + vdv(ivec,ich2o)
  917. yv(ivec,ich2o)=(y0v(ivec,ich2o)+PCH2O*DT)/(1.+XLCH2O*DT)
  918. ! --- CBIV-elements for higher HC-chemistry: ALD2 MGLY
  919. ! --- ETH OLE ISOP ROOH ORGNTR
  920. PALD2=0.11*rrv(ivec,kc52)*yv(ivec,ipar)*yv(ivec,ioh)&
  921. +1.1*rrv(ivec,kc53)*yv(ivec,iror)&
  922. +0.95*rrv(ivec,kc57)*yv(ivec,iole)*yv(ivec,ioh)&
  923. +0.5*rrv(ivec,kc58)*yv(ivec,iole)*yv(ivec,io3)&
  924. +0.91*rrv(ivec,kc59)*yv(ivec,iole)*yv(ivec,ino3)&
  925. +0.22*rrv(ivec,kc61)*yv(ivec,ieth)*yv(ivec,ioh)&
  926. +0.8*rrv(ivec,kc78)*yv(ivec,iisop)*yv(ivec,ino3)&
  927. +0.04*rrv(ivec,kohrooh)*yv(ivec,ioh)*yv(ivec,irooh)&
  928. +0.991*rrv(ivec,kohc2h6)*yv(ivec,ioh)*yv(ivec,ic2h6)&
  929. +0.3*rjv(ivec,jrooh)*yv(ivec,irooh)&
  930. +0.3*rrv(ivec,kc84)*yv(ivec,ioh)*yv(ivec,iorgntr)&
  931. +0.3*rjv(ivec,jorgn)*yv(ivec,iorgntr)&
  932. +rrv(ivec,kohethoh)*yv(ivec,ioh)*yv(ivec,iethoh)&
  933. +0.5*rrv(ivec,ko3c3h6)*yv(ivec,io3)*yv(ivec,ic3h6)&
  934. +0.47*rrv(ivec,kohterp)*yv(ivec,ioh)*yv(ivec,iterp)&
  935. +0.21*rrv(ivec,ko3terp)*yv(ivec,io3)*yv(ivec,iterp)&
  936. +0.47*rrv(ivec,kno3terp)*yv(ivec,ino3)*yv(ivec,iterp)&
  937. +0.273*rrv(ivec,kohispd)*yv(ivec,ioh)*yv(ivec,iispd)&
  938. +0.02*rrv(ivec,ko3ispd)*yv(ivec,io3)*yv(ivec,iispd)&
  939. +0.357*rrv(ivec,kno3ispd)*yv(ivec,ino3)*yv(ivec,iispd)&
  940. +0.067*rjv(ivec,jispd)*yv(ivec,iispd)&
  941. +0.7*rrv(ivec,kaco2mo2)*yv(ivec,iaco2)*yv(ivec,ich3o2)&
  942. +0.27*rrv(ivec,kc3h7o2no)*yv(ivec,ic3h7o2)*yv(ivec,ino)&
  943. +rrv(ivec,khypo2no)*yv(ivec,ihypro2)*yv(ivec,ino)
  944. XLALD2=rrv(ivec,kc43)*yv(ivec,ioh)+rrv(ivec,kc44)*yv(ivec,ino3)&
  945. +rjv(ivec,jald2)
  946. XLALD2=XLALD2 + vdv(ivec,iald2)
  947. yv(ivec,iald2)=(y0v(ivec,iald2)+PALD2*DT)/(1.+XLALD2*DT)
  948. PMGLY=0.19*rrv(ivec,kohrooh)*yv(ivec,ioh)*yv(ivec,irooh)&
  949. +0.168*rrv(ivec,kohispd)*yv(ivec,ioh)*yv(ivec,iispd)&
  950. +0.85*rrv(ivec,ko3ispd)*yv(ivec,io3)*yv(ivec,iispd)&
  951. +0.5*rrv(ivec,kaco2mo2)*yv(ivec,iaco2)*yv(ivec,ich3o2)
  952. XLMGLY=rrv(ivec,kc73)*yv(ivec,ioh)+rjv(ivec,jmgly)
  953. yv(ivec,imgly)=(y0v(ivec,imgly)+PMGLY*DT)/(1.+XLMGLY*DT)
  954. XLETH=rrv(ivec,kc61)*yv(ivec,ioh)+rrv(ivec,kc62)*yv(ivec,io3)
  955. yv(ivec,ieth)=y0v(ivec,ieth)/(1.+XLETH*DT)
  956. POLE=0.
  957. XLOLE=rrv(ivec,kc57)*yv(ivec,ioh)+rrv(ivec,kc58)*yv(ivec,io3)+rrv(ivec,kc59)*yv(ivec,ino3)
  958. yv(ivec,iole)=(y0v(ivec,iole)+POLE*DT)/(1.+XLOLE*DT)
  959. PROOH=rrv(ivec,kc82)*yv(ivec,ixo2)*yv(ivec,iho2)&
  960. +rrv(ivec,kc85)*yv(ivec,iho2)*yv(ivec,ixo2n)&
  961. +rrv(ivec,kaco2ho2)*yv(ivec,iaco2)*yv(ivec,iho2)&
  962. +rrv(ivec,kc3h7o2ho2)*yv(ivec,ic3h7o2)*yv(ivec,iho2)&
  963. +rrv(ivec,khypo2ho2)*yv(ivec,ihypro2)*yv(ivec,iho2)
  964. XLROOH=rjv(ivec,jrooh)+rrv(ivec,kohrooh)*yv(ivec,ioh)
  965. XLROOH = XLROOH + vdv(ivec,irooh)
  966. yv(ivec,irooh)=(y0v(ivec,irooh)+PROOH*DT)/(1.+XLROOH*DT)
  967. PORGNTR=rrv(ivec,kc81)*yv(ivec,ino)*yv(ivec,ixo2n)&
  968. +0.8*rrv(ivec,kc78)*yv(ivec,iisop)*yv(ivec,ino3)&
  969. +rrv(ivec,kno3c3h6)*yv(ivec,ic3h6)*yv(ivec,ino3)&
  970. +0.53*rrv(ivec,kno3terp)*yv(ivec,ino3)*yv(ivec,iterp)&
  971. +0.85*rrv(ivec,kno3ispd)*yv(ivec,ino3)*yv(ivec,iispd)
  972. XLORGNTR=rrv(ivec,kc84)*yv(ivec,ioh)+rjv(ivec,jorgn)
  973. XLORGNTR=XLORGNTR+vdv(ivec,iorgntr)
  974. yv(ivec,iorgntr)=(y0v(ivec,iorgntr)+PORGNTR*DT)/(1.+XLORGNTR*DT)
  975. PACET=0.82*rrv(ivec,kc3h7o2no)*yv(ivec,ino)*yv(ivec,ic3h7o2)
  976. XLACET=rjv(ivec,ja_acet)+rjv(ivec,jb_acet)+rrv(ivec,kohacet)*yv(ivec,ioh)
  977. XLACET=XLACET+vdv(ivec,iacet)
  978. yv(ivec,iacet)=(y0v(ivec,iacet)+PACET*DT)/(1.+XLACET*DT)
  979. ! gas phase sulfur & ammonia
  980. qdms1=rrv(ivec,kdmsoha)*yv(ivec,ioh)+rrv(ivec,kdmsno3)*yv(ivec,ino3)
  981. qdms2=rrv(ivec,kdmsohb)*yv(ivec,ioh)
  982. qdms=qdms1+qdms2
  983. yv(ivec,idms)=y0v(ivec,idms)/(1.+qdms*DT)
  984. pso2=yv(ivec,idms)*(qdms1+0.75*qdms2)
  985. pmsa=yv(ivec,idms)*0.25*qdms2
  986. qso2=rrv(ivec,kso2oh)*yv(ivec,ioh)
  987. qso2d=qso2 + vdv(ivec,iso2)
  988. yv(ivec,iso2)=(y0v(ivec,iso2)+pso2*DT) /(1.+qso2d*DT) !qso2d includes deposition
  989. #ifdef with_m7
  990. ! Dry deposition of gas-phase H2SO4 is not important and therefore neglected:
  991. yv(ivec,iso4)=(y0v(ivec,iso4)+qso2*yv(ivec,iso2)*DT)
  992. ! Do not apply dry deposition to bulk aerosols (NO3_a, NH4 and MSA).
  993. ! When M7 is active, this is done in the sedimentation routine.
  994. #ifdef with_budgets
  995. ! leave out dt to get s-1 values
  996. temp_prod_so4(ivec,1)=qso2*yv(ivec,iso2)*DT
  997. #endif
  998. #else
  999. !VH: Do apply dry deposition to SO4_A : This deposition velocity does represent aerosol deposition
  1000. !VH: Use the same aerosol deposition velocity for NO3_A deposition.
  1001. yv(ivec,iso4)=(y0v(ivec,iso4)+qso2*yv(ivec,iso2)*DT) /(1. + vdv(ivec,iso4)*DT) !corrected CMK qso2/qso2d
  1002. ! Without M7, apply dry deposition to other bulk aerosols:
  1003. yv(ivec,ino3_a)=y0v(ivec,ino3_a) /(1.+vdv(ivec,ino3_a)*DT)
  1004. yv(ivec,inh4)=y0v(ivec,inh4)/(1.+vdv(ivec,inh4)*DT)
  1005. yv(ivec,imsa)=(y0v(ivec,imsa)+pmsa*DT) /(1.+vdv(ivec,imsa)*DT)
  1006. #endif
  1007. pnh2=yv(ivec,inh2o2)*yv(ivec,ino)*rrv(ivec,knh2o2no)&
  1008. +yv(ivec,inh2o2)*yv(ivec,io3)*rrv(ivec,knh2o2o3)&
  1009. +yv(ivec,inh2o2)*yv(ivec,iho2)*rrv(ivec,knh2o2ho2)
  1010. pnh3=rrv(ivec,Knh2ho2)*yv(ivec,inh2)*yv(ivec,iho2)
  1011. dnh3=yv(ivec,ioh)*rrv(ivec,knh3oh) + vdv(ivec,inh3)
  1012. yv(ivec,inh3)=(y0v(ivec,inh3)+pnh3*DT)/(1.+dnh3*DT)
  1013. ppnh3=yv(ivec,ioh)*yv(ivec,inh3)*rrv(ivec,knh3oh)
  1014. qnh2= rrv(ivec,knh2oh)*yv(ivec,ioh)+rrv(ivec,knh2no)*yv(ivec,ino)&
  1015. +rrv(ivec,knh2no2)*yv(ivec,ino2)+rrv(ivec,knh2ho2)*yv(ivec,iho2)&
  1016. +rrv(ivec,knh2o3)*yv(ivec,io3)&
  1017. +rrv(ivec,knh2o2)
  1018. yv(ivec,inh2)=(y0v(ivec,inh2)+ppnh3*dt+pnh2*dt)/(1.+qnh2*dt)
  1019. !
  1020. ! Now nh2o2 radical
  1021. !
  1022. qnh2o2=rrv(ivec,knh2o2no)*yv(ivec,ino)+rrv(ivec,knh2o2o3)*yv(ivec,io3)+rrv(ivec,knh2o2ho2)*yv(ivec,iho2)
  1023. yv(ivec,inh2o2)=(y0v(ivec,inh2o2)+(rrv(ivec,knh2o3)*yv(ivec,io3)*yv(ivec,inh2)*DT))/(1.+qnh2o2*DT)
  1024. end do !ivec
  1025. end if
  1026. if ( mod(iter,maxit) == 0 ) then
  1027. ! --- Long living compounds
  1028. do ivec=1,lvec
  1029. yv(ivec,ich4)=y0v(ivec,ich4)/(1.+rrv(ivec,kch4oh)*yv(ivec,ioh)*DT)
  1030. #ifdef with_budgets
  1031. !ch4loss=(1.0-1.0/((1.+rrv(ivec,kch4oh)*yv(ivec,ioh)*DT)))*y0v(ivec,ich4)
  1032. temp_loss(ivec,1)=(1.0-1.0/((1.+rrv(ivec,kch4oh)*yv(ivec,ioh)*DT)))*y0v(ivec,ich4)
  1033. #endif
  1034. !methane loss?
  1035. PCO=yv(ivec,ich2o)*(rjv(ivec,jach2o)+rjv(ivec,jbch2o)&
  1036. +yv(ivec,ioh)*rrv(ivec,kfrmoh))&
  1037. +rjv(ivec,jald2)*yv(ivec,iald2)&
  1038. +rjv(ivec,jmgly)*yv(ivec,imgly)&
  1039. +0.62*rrv(ivec,kc57)*yv(ivec,iole)*yv(ivec,ioh)&
  1040. +0.65*rrv(ivec,kc58)*yv(ivec,iole)*yv(ivec,io3)&
  1041. +0.56*rrv(ivec,kc59)*yv(ivec,iole)*yv(ivec,ino3)&
  1042. +0.24*rrv(ivec,kc62)*yv(ivec,ieth)*yv(ivec,io3)&
  1043. +0.066*rrv(ivec,kc77)*yv(ivec,iisop)*yv(ivec,io3)&
  1044. +rrv(ivec,kc41)*yv(ivec,ich2o)*yv(ivec,ino3)&
  1045. +0.56*rrv(ivec,ko3c3h6)*yv(ivec,io3)*yv(ivec,ic3h6)&
  1046. +0.47*rrv(ivec,kohterp)*yv(ivec,ioh)*yv(ivec,iterp)&
  1047. +0.211*rrv(ivec,ko3terp)*yv(ivec,io3)*yv(ivec,iterp)&
  1048. +0.47*rrv(ivec,kno3terp)*yv(ivec,ino3)*yv(ivec,iterp)&
  1049. +0.334*rrv(ivec,kohispd)*yv(ivec,ioh)*yv(ivec,iispd)&
  1050. +0.225*rrv(ivec,ko3ispd)*yv(ivec,io3)*yv(ivec,iispd)&
  1051. +0.643*rrv(ivec,kno3ispd)*yv(ivec,ino3)*yv(ivec,iispd)&
  1052. +0.333*rjv(ivec,jispd)*yv(ivec,iispd)&
  1053. +rjv(ivec,ja_acet)*yv(ivec,iacet)
  1054. XLCO = rrv(ivec,kcooh)*yv(ivec,ioh)
  1055. XLCO = XLCO + vdv(ivec,ico)
  1056. yv(ivec,ico)=(y0v(ivec,ico)+PCO*DT)/(1.+XLCO*DT)
  1057. #ifdef with_budgets
  1058. !carbon monoxide loss? change=(t-1)-t
  1059. temp_loss(ivec,2)=y0v(ivec,ico)-(y0v(ivec,ico)+PCO*DT)/(1.+XLCO*DT)
  1060. #endif
  1061. pch3oh=(0.63*rrv(ivec,kmo2mo2)*yv(ivec,ich3o2)*yv(ivec,ich3o2))+&
  1062. (0.5*rrv(ivec,kaco2mo2)*yv(ivec,ich3o2)*yv(ivec,iaco2))
  1063. yv(ivec,ich3oh)=(y0v(ivec,ich3oh)+pch3oh*dt)/&
  1064. (1.+(vdv(ivec,ich3oh)+rrv(ivec,kohch3oh)*yv(ivec,ioh))*dt)
  1065. phcooh=(0.52*rrv(ivec,kc62)*yv(ivec,io3)*yv(ivec,ieth)) +&
  1066. (0.25*rrv(ivec,ko3c3h6)*yv(ivec,io3)*yv(ivec,ic3h6))
  1067. yv(ivec,ihcooh)=(y0v(ivec,ihcooh)+(phcooh*dt))/&
  1068. (1.+rrv(ivec,kohhcooh)*yv(ivec,ioh)*dt)
  1069. pmcooh=0.4*rrv(ivec,kc50)*yv(ivec,ic2o3)*yv(ivec,iho2)
  1070. yv(ivec,imcooh)=(y0v(ivec,imcooh)+(pmcooh*dt))/&
  1071. (1.+(vdv(ivec,imcooh)+rrv(ivec,kohmcooh)*yv(ivec,ioh))*dt)
  1072. yv(ivec,ic2h6)=y0v(ivec,ic2h6)/(1.+rrv(ivec,kohc2h6)*yv(ivec,ioh)*dt)
  1073. yv(ivec,iethoh)=(y0v(ivec,iethoh)/(1.+(vdv(ivec,iethoh)+rrv(ivec,kohethoh)*yv(ivec,ioh))*dt))
  1074. yv(ivec,ic3h8)=(y0v(ivec,ic3h8)/(1.+rrv(ivec,kohc3h8)*yv(ivec,ioh)*dt))
  1075. xlc3h6=rrv(ivec,kohc3h6)*yv(ivec,ioh)&
  1076. +rrv(ivec,ko3c3h6)*yv(ivec,io3)&
  1077. +rrv(ivec,kno3c3h6)*yv(ivec,ino3)
  1078. yv(ivec,ic3h6)=(y0v(ivec,ic3h6)/(1.+xlc3h6*dt))
  1079. ppar=0.35*rrv(ivec,kc77)*yv(ivec,iisop)*yv(ivec,io3)&
  1080. +2.4*rrv(ivec,kc78)*yv(ivec,iisop)*yv(ivec,ino3)&
  1081. +5.0*rrv(ivec,kohterp)*yv(ivec,ioh)*yv(ivec,iterp)&
  1082. +6.0*rrv(ivec,ko3terp)*yv(ivec,io3)*yv(ivec,iterp)&
  1083. +6.0*rrv(ivec,kno3terp)*yv(ivec,ino3)*yv(ivec,iterp)&
  1084. +1.565*rrv(ivec,kohispd)*yv(ivec,ioh)*yv(ivec,iispd)&
  1085. +0.36*rrv(ivec,ko3ispd)*yv(ivec,io3)*yv(ivec,iispd)&
  1086. +1.282*rrv(ivec,kno3ispd)*yv(ivec,ino3)*yv(ivec,iispd)&
  1087. +0.832*rjv(ivec,jispd)*yv(ivec,iispd)&
  1088. +0.6*rrv(ivec,kaco2mo2)*yv(ivec,ich3o2)*yv(ivec,iaco2)
  1089. xlpar=rrv(ivec,kc52)*yv(ivec,ioh)+rrv(ivec,kc83)*yv(ivec,irxpar)
  1090. yv(ivec,ipar)=(y0v(ivec,ipar)+ppar*dt)/(1.+xlpar*dt)
  1091. !cmk ____added rn222 chemistry in EBI language
  1092. yv(ivec,irn222) = y0v(ivec,irn222)/(1.+rrv(ivec,krn222)*dt)
  1093. yv(ivec,ipb210) = y0v(ivec,ipb210)+y0v(ivec,irn222)-yv(ivec,irn222)
  1094. end do !ivec
  1095. end if
  1096. end do !ITER
  1097. end subroutine DO_EBI
  1098. subroutine NOYmass
  1099. integer i,j,imax
  1100. real :: ncormax,ncorav,totn,totn0,fnoy,fnoy1
  1101. real :: ncorr,ncorr1,ncorr2,ncorr3,ncorr4,ncorr5, totdep
  1102. logical :: nerr
  1103. ncormax=0.
  1104. ncorav=0.
  1105. nerr=.false.
  1106. imax = 0
  1107. do j=j1,j2
  1108. do i=i1,i2
  1109. imax = imax + 1
  1110. !
  1111. !** Guarantee exact mass conservation of NOY
  1112. ! (this may matter a few percent)
  1113. !
  1114. fnoy=y(i,j,ino)+y(i,j,ino2)+y(i,j,ino3)+2.*y(i,j,in2o5)+y(i,j,ihno4)
  1115. if (level == 1) then
  1116. #ifndef without_dry_deposition
  1117. totdep = (y(i,j,ino) *vd(region,ino )%surf(i,j) + &
  1118. y(i,j,ino2)*vd(region,ino2)%surf(i,j) + &
  1119. y(i,j,ino3)*vd(region,ino3)%surf(i,j) + &
  1120. y(i,j,ihno3)*vd(region,ihno3)%surf(i,j) + &
  1121. y(i,j,ipan)*vd(region,ipan)%surf(i,j) + &
  1122. y(i,j,iorgntr)*vd(region,iorgntr)%surf(i,j) + &
  1123. y(i,j,ich3o2no2)*vd(region,ich3o2no2)%surf(i,j) + &
  1124. 2*y(i,j,in2o5)*vd(region,in2o5)%surf(i,j) + &
  1125. y(i,j,ihno4)*vd(region,ihno4)%surf(i,j) + &
  1126. y(i,j,ihono)*vd(region,ihono)%surf(i,j))*dt/ye(i,j,idz)
  1127. #else
  1128. totdep = 0.0
  1129. #endif
  1130. else
  1131. totdep = 0.0
  1132. end if
  1133. totn0=y0(i,j,inox)+y0(i,j,ihno3)+y0(i,j,ipan)+y0(i,j,ihono)+ &
  1134. y0(i,j,iorgntr) + y0(i,j,ich3o2no2) + ye(i,j,ieno)*dt - totdep
  1135. ! note that emino is added here and the total deposition is subtracted
  1136. !
  1137. ! totn0 contains all nitrogen at beginning of timestep + nox emissions
  1138. !
  1139. !
  1140. ! totn contains all nitrogen at end of timestep
  1141. !
  1142. totn=fnoy+y(i,j,ihno3)+y(i,j,ipan)+y(i,j,iorgntr)+y(i,j,ihono)+ y(i,j,ich3o2no2)
  1143. ! correction factor for all nitrogen compounds
  1144. ncorr=totn-totn0
  1145. if ( totn < tiny(totn) ) cycle
  1146. if ( (abs(ncorr)/totn) > 0.05 ) then !CMK changed from 0.1 to 0.05
  1147. nerr=.true.
  1148. !AJS>>>
  1149. ! print *,'NOYmass: N-error....',region,level,i,j,totn0,totn
  1150. ! print *,'NOYmass: emino ',ye(i,j,ieno)*dt/y0(i,j,iair)*1e9
  1151. ! print *,'NOYmass: NO(0) ', &
  1152. ! y0(i,j,ino)/y0(i,j,iair)*1e9,y(i,j,ino)/y(i,j,iair)*1e9
  1153. ! print *,'NOYmass: NO2(0) ', &
  1154. ! y0(i,j,ino2)/y0(i,j,iair)*1e9,y(i,j,ino2)/y(i,j,iair)*1e9
  1155. ! print *,'NOYmass: O3(0) ', &
  1156. ! y0(i,j,io3)/y0(i,j,iair)*1e9,y(i,j,io3)/y(i,j,iair)*1e9
  1157. ! print *,'NOYmass: NO3(0) ', &
  1158. ! y0(i,j,ino3)/y0(i,j,iair)*1e9,y(i,j,ino3)/y(i,j,iair)*1e9
  1159. ! print *,'NOYmass: N2O5(0) ', &
  1160. ! y0(i,j,in2o5)/y0(i,j,iair)*1e9,y(i,j,in2o5)/y(i,j,iair)*1e9
  1161. ! print *,'NOYmass: HNO4(0) ', &
  1162. ! y0(i,j,ihno4)/y0(i,j,iair)*1e9,y(i,j,ihno4)/y(i,j,iair)*1e9
  1163. ! print *,'NOYmass: HNO3(0) ', &
  1164. ! y0(i,j,ihno3)/y0(i,j,iair)*1e9,y(i,j,ihno3)/y(i,j,iair)*1e9
  1165. ! print *,'NOYmass: PAN(0) ', &
  1166. ! y0(i,j,ipan)/y0(i,j,iair)*1e9,y(i,j,ipan)/y(i,j,iair)*1e9
  1167. ! print *,'NOYmass: ORGNT(0) ', &
  1168. ! y0(i,j,iorgntr)/y0(i,j,iair)*1e9,y(i,j,iorgntr)/y(i,j,iair)*1e9
  1169. ! print *,'NOYmass: NOx(0) ', &
  1170. ! y0(i,j,inox)/y0(i,j,iair)*1e9,y(i,j,inox)/y(i,j,iair)*1e9
  1171. ! print *,'NOYmass: ',rj(i,j,jhno3),rr(i,j,kohhno3)*y(i,j,ioh), &
  1172. ! y(i,j,ioh)/y(i,j,iair)*1e9
  1173. !<<<AJS
  1174. end if
  1175. ! maximum and average correction factor in this loop
  1176. ncormax=max(abs(ncormax),abs(ncorr/totn))
  1177. ncorav=ncorav+abs(ncorr/totn)
  1178. !
  1179. ! first correct hno3, pan and organic nitrates (added hono)
  1180. ! (as a group of reservoir tracers)
  1181. !
  1182. totn=y(i,j,ihno3)+y(i,j,ipan)+y(i,j,iorgntr)+y(i,j,ihono)+y(i,j,ich3o2no2)
  1183. if ( totn < tiny(totn) ) cycle
  1184. ncorr1=y(i,j,ihno3) *(1.-ncorr/totn)
  1185. ncorr2=y(i,j,ipan) *(1.-ncorr/totn)
  1186. ncorr3=y(i,j,iorgntr)*(1.-ncorr/totn)
  1187. ncorr4=y(i,j,ihono)*(1.-ncorr/totn)
  1188. ncorr5=y(i,j,ich3o2no2)*(1.-ncorr/totn)
  1189. y(i,j,ihno3) =max(0.,ncorr1)
  1190. y(i,j,ipan) =max(0.,ncorr2)
  1191. y(i,j,iorgntr) =max(0.,ncorr3)
  1192. y(i,j,ihono) =max(0.,ncorr4)
  1193. y(i,j,ich3o2no2)=max(0.,ncorr5)
  1194. ncorr=ncorr1+ncorr2+ncorr3+ncorr4+ncorr5-y(i,j,ihno3)-y(i,j,ipan)-y(i,j,iorgntr)-y(i,j,ihono)-y(i,j,ich3o2no2)
  1195. !
  1196. ! the remainder is used to scale the noy components
  1197. !
  1198. fnoy1=(fnoy+ncorr)/fnoy
  1199. y(i,j,ino) =fnoy1*y(i,j,ino)
  1200. y(i,j,ino2) =fnoy1*y(i,j,ino2)
  1201. y(i,j,ino3) =fnoy1*y(i,j,ino3)
  1202. y(i,j,in2o5)=fnoy1*y(i,j,in2o5)
  1203. y(i,j,ihno4)=fnoy1*y(i,j,ihno4)
  1204. y(i,j,inox) =y(i,j,ino)+y(i,j,ino2)+y(i,j,ino3)+2.*y(i,j,in2o5)+y(i,j,ihno4)
  1205. end do
  1206. end do
  1207. if ( nerr ) then
  1208. write (gol,'("NOYmass: N-mass balance error, ncorr>5% ")'); call goPr
  1209. write (gol,'(" Maximum correction : ",f8.2)') ncormax; call goPr
  1210. write (gol,'(" Average correction in this loop (imax) : ",f8.2," (",i6,")")') ncorav/imax, imax; call goPr
  1211. end if
  1212. end subroutine NOYmass
  1213. #ifdef with_budgets
  1214. !--------------------------------------------------------------------------
  1215. ! TM5 !
  1216. !--------------------------------------------------------------------------
  1217. !BOP
  1218. !
  1219. ! !IROUTINE:
  1220. !
  1221. ! !DESCRIPTION: increase reaction budgets for each reaction
  1222. ! arrays nrr and nrj determine which species are
  1223. ! involved in a reaction
  1224. !\\
  1225. !\\
  1226. ! !INTERFACE:
  1227. !
  1228. subroutine INCC2C3
  1229. !
  1230. #ifdef with_tendencies
  1231. use TRACER_DATA, only : PLC_AddValue, plc_ipr_lddep, plc_kg_from_tm
  1232. #endif
  1233. ! integer, intent(out) :: status
  1234. integer :: i01,n1,n2,jl,i,j
  1235. ! nrj and nrr used for reaction budget calculations
  1236. integer,dimension(nj),parameter :: nrj=(/io3,ino2,ih2o2,ihno3,ihno4,in2o5,in2o5,ich2o,ich2o, &
  1237. ich3o2h,ino3,ino3,ipan,ipan,iorgntr,iald2,imgly,irooh,io2,iispd,iacet,iacet, &
  1238. ihono,ich3o2no2,ich3o2no2/)
  1239. integer,dimension(nreac,2),parameter :: nrr = reshape((/ &
  1240. ino ,iho2 ,ich3o2,ino2 ,ioh ,ino2 ,ino ,ino2 ,in2o5, ihno4 , &
  1241. ino2 ,ihno4 ,iair ,ih2o ,io3 ,ico ,io3 ,ih2o2 ,ich2o, ich4 , &
  1242. ioh ,ioh ,ich3o2,ich3o2 ,ich3o2 ,iho2 ,iho2 ,in2o5 ,ioh , ich2o , &
  1243. iald2 ,iald2 ,ic2o3 ,ic2o3 ,ipan ,ic2o3 ,ic2o3 ,ipar ,iror , iror , &
  1244. ioh ,io3 ,ino3 ,ioh ,io3 ,ioh ,ioh ,io3 ,ino3 , ixo2 , &
  1245. ixo2 ,ixo2n ,ixo2 ,irxpar ,iorgntr,ixo2n ,idms ,idms ,idms , iso2 , &
  1246. inh3 ,inh3 ,inh2 ,inh2 ,inh2 ,inh2 ,inh2 ,inh2 ,ioh ,ioh , ino3 , &
  1247. ino3 ,ino3 ,ino3 ,ioh ,ioh ,ioh ,ioh ,ioh ,io3 , ino3 , &
  1248. ioh ,io3 ,ino3 ,ioh ,io3 ,ino3 ,irn222,io3 ,iair , iacet , &
  1249. iaco2 ,iaco2 ,iaco2 ,iaco2 ,ixo2 ,ixo2n ,ino ,iho2 ,ino , iho2 , &
  1250. in2o5 ,ino3 ,iho2 ,iho2 ,ino ,io3 ,iho2, ioh ,ioh ,ich3o2,ich3o2no2, &
  1251. !second reaction partner (if monmolecular = 0)
  1252. io3 ,ino ,ino ,ioh ,ihno3 ,io3 ,ino3 ,ino3 ,0 ,ioh , &
  1253. iho2 ,0 ,0 ,0 ,iho2 ,ioh ,ioh ,ioh ,ioh ,ioh , &
  1254. ich3o2h,irooh ,iho2 ,iho2 ,ich3o2 ,ioh ,iho2 ,0 ,0 ,ino3 , &
  1255. ioh ,ino3 ,ino ,ino2 ,0 ,ic2o3 ,iho2 ,ioh ,0 ,0 , &
  1256. iole ,iole ,iole ,ieth ,ieth ,imgly ,iisop ,iisop ,iisop ,ino , &
  1257. ixo2 ,ino ,iho2 ,ipar ,ioh ,iho2 ,ioh ,ioh ,ino3 ,ioh , &
  1258. iacid ,ioh ,ioh ,ino ,ino2 ,iho2 ,0 ,io3 ,ich3oh ,ihcooh ,iho2 , &
  1259. ich3o2 ,ic2o3 ,ixo2 ,imcooh ,ic2h6 ,iethoh,ic3h8 ,ic3h6 ,ic3h6 ,ic3h6 , &
  1260. iterp ,iterp ,iterp ,iispd ,iispd ,iispd ,0 ,iair ,0 ,ioh , &
  1261. iho2 ,ich3o2,ino ,ixo2 ,ixo2n ,ixo2n ,ic3h7o2,ic3h7o2,ihypro2,ihypro2, &
  1262. 0 ,0 ,0 ,0 ,inh2o2 ,inh2o2,inh2o2, ino ,ihono ,ino2 ,0/),(/nreac,2/))
  1263. real :: c1,xdep
  1264. c1=dt*1000./xmair !conversion to moles...
  1265. ! Reaction budgets
  1266. do i01=1,nj !photolysis rates
  1267. n1=nrj(i01)
  1268. do j=j1,j2
  1269. do i=i1,i2
  1270. if(n1 > 0) cr2(i,j,i01)=cr2(i,j,i01)+rj(i,j,i01)*y(i,j,n1)
  1271. end do
  1272. end do
  1273. end do!i01=1,nj
  1274. !
  1275. do i01=1,nreac !reactions
  1276. n1=nrr(i01,1) !make sure n1 > 0
  1277. n2=nrr(i01,2)
  1278. if (n2 > 0.) then
  1279. do j=j1,j2
  1280. do i=i1,i2
  1281. cr3(i,j,i01)= cr3(i,j,i01)+y(i,j,n1)*y(i,j,n2)*rr(i,j,i01)
  1282. end do
  1283. end do
  1284. else
  1285. do j=j1,j2
  1286. do i=i1,i2
  1287. cr3(i,j,i01)= cr3(i,j,i01)+y(i,j,n1)*rr(i,j,i01)
  1288. end do
  1289. end do
  1290. end if
  1291. end do !i01=1,nreac
  1292. if ( level == 1 ) then ! deposition budget
  1293. do i01=1,ntrace
  1294. if (fscale(i01) > 0) then
  1295. do j=j1,j2
  1296. do i=i1,i2
  1297. #ifndef without_dry_deposition
  1298. if (i01 .ne. inox) then
  1299. xdep = y(i,j,i01)*vd(region,i01)%surf(i,j)/ye(i,j,idz)* &
  1300. c1*ye(i,j,iairm)/y(i,j,iair) !from updated concentrations
  1301. else ! compute nox deposition from other contributors!
  1302. xdep = (y(i,j,ino) *vd(region,ino)%surf(i,j) + &
  1303. y(i,j,ino2 )*vd(region,ino2)%surf(i,j)+ &
  1304. y(i,j,ino3) *vd(region,ino3)%surf(i,j)+ &
  1305. y(i,j,ihno3)*vd(region,ihno3)%surf(i,j)+ &
  1306. 2*y(i,j,in2o5)*vd(region,in2o5)%surf(i,j) + &
  1307. y(i,j,ihono)*vd(region,ihono)%surf(i,j)) &
  1308. /ye(i,j,idz)* &
  1309. c1*ye(i,j,iairm)/y(i,j,iair) !from updated concentrations
  1310. endif
  1311. #else
  1312. xdep = 0.0
  1313. #endif
  1314. buddep_dat(region)%dry(i,j,i01) = &
  1315. buddep_dat(region)%dry(i,j,i01) + xdep
  1316. if ( i01 == 1 ) then !seperate deposition from 'other' chemistry
  1317. #ifndef without_dry_deposition
  1318. sum_deposition(region) = sum_deposition(region) - &
  1319. xdep*ra(1)*1e-3 ! in kg
  1320. #endif
  1321. sum_chemistry(region) = sum_chemistry(region) + &
  1322. (y(i,j,1)-y0(i,j,1))/y(i,j,iair)* &
  1323. ye(i,j,iairm)/xmair*ra(1) + xdep*ra(1)*1e-3
  1324. end if
  1325. ! FIXME TENDENCIES
  1326. #ifdef with_tendencies
  1327. ! Add deposition budget in kg to tendencies;
  1328. ! (mole tm tracer) * (g/mole) * (kg/g) = kg tm tracer
  1329. call PLC_AddValue( region, plc_ipr_lddep, i, j, 1, i01, &
  1330. xdep * ra(i01) * 1e-3 * plc_kg_from_tm(i01), & ! kg plc tracer
  1331. status )
  1332. ! IF_NOTOK_RETURN(status=1)
  1333. #endif
  1334. end do
  1335. end do
  1336. endif
  1337. end do !i01
  1338. else ! other layers
  1339. do j=j1,j2
  1340. do i=i1,i2
  1341. sum_chemistry(region) = sum_chemistry(region) + &
  1342. (y(i,j,1)-y0(i,j,1))/y(i,j,iair)*ye(i,j,iairm)/xmair*ra(1)
  1343. end do
  1344. end do
  1345. end if !level ==1
  1346. end subroutine INCC2C3
  1347. !--------------------------------------------------------------------------
  1348. ! TM5 !
  1349. !--------------------------------------------------------------------------
  1350. !BOP
  1351. !
  1352. ! !IROUTINE: REACBUD
  1353. !
  1354. ! !DESCRIPTION: accumulate budgets, o3 P/L
  1355. !\\
  1356. !\\
  1357. ! !INTERFACE:
  1358. !
  1359. SUBROUTINE REACBUD
  1360. !
  1361. ! !USES:
  1362. !
  1363. USE BUDGET_GLOBAL, ONLY : budg_dat, nzon_vg
  1364. !
  1365. !EOP
  1366. !------------------------------------------------------------------------
  1367. !BOC
  1368. integer :: i01, i, j, nzone, nzone_v
  1369. real :: c1
  1370. c1=dt*1000./xmair !conversion to moles
  1371. do j=j1,j2
  1372. do i=i1,i2
  1373. nzone=budg_dat(region)%nzong(i,j) !global budget
  1374. nzone_v=nzon_vg(level) !level is passed to ebi...
  1375. do i01=1,nj
  1376. budrjg(nzone,nzone_v,i01)=budrjg(nzone,nzone_v,i01)+ &
  1377. cr2(i,j,i01)*c1*ye(i,j,iairm)/y(i,j,iair) !units mole
  1378. end do !nj
  1379. ! ozone production on a 3D grid:
  1380. ! defined as: HO2 + NO, CH3O2 + NO, XO2 + NO, C2O3 + NO
  1381. o3p(region)%d3(i,j,level) = o3p(region)%d3(i,j,level) + &
  1382. (cr3(i,j,2) + cr3(i,j,3) + cr3(i,j,33) + cr3(i,j,50)) &
  1383. *c1*ye(i,j,iairm)/y(i,j,iair) ! acc. moles/gridbox
  1384. !AERCHEMMIP output
  1385. #ifdef with_m7
  1386. AC_O3_lp(region)%prod(i,j,level,1)=AC_O3_lp(region)%prod(i,j,level,1)+&
  1387. (cr3(i,j,2)+ cr3(i,j,3) + cr3(i,j,33) + cr3(i,j,50)) &
  1388. *c1*ye(i,j,iairm)/y(i,j,iair)
  1389. #endif
  1390. o3l(region)%d3(i,j,level) = o3l(region)%d3(i,j,level) + &
  1391. (cr3(i,j,4)-2*cr3(i,j,7) + 2*cr3(i,j,6) + cr3(i,j,8) - cr3(i,j,9) + &
  1392. cr3(i,j,15) + cr3(i,j,17) + cr3(i,j,42) - cr3(i,j,43) + &
  1393. cr3(i,j,45) + cr3(i,j,48) - 0.1*cr3(i,j,49) - cr3(i,j,55) + &
  1394. cr2(i,j,1) - cr2(i,j,4) - cr2(i,j,6) - cr2(i,j,13) - 2.*cr2(i,j,10)) &
  1395. *c1*ye(i,j,iairm)/y(i,j,iair) ! acc. moles/gridbox
  1396. !AERCHEMMIP output
  1397. #ifdef with_m7
  1398. AC_O3_lp(region)%prod(i,j,level,2)=AC_O3_lp(region)%prod(i,j,level,2)+&
  1399. (cr3(i,j,4)-2*cr3(i,j,7) + 2*cr3(i,j,6) + cr3(i,j,8) - cr3(i,j,9) + &
  1400. cr3(i,j,15) + cr3(i,j,17) + cr3(i,j,42) - cr3(i,j,43) + &
  1401. cr3(i,j,45) + cr3(i,j,48) - 0.1*cr3(i,j,49) - cr3(i,j,55) + &
  1402. cr2(i,j,1) - cr2(i,j,4) - cr2(i,j,6) - cr2(i,j,13) - 2.*cr2(i,j,10)) &
  1403. *c1*ye(i,j,iairm)/y(i,j,iair) ! acc. moles/gridbox
  1404. #endif
  1405. o3l(region)%d3(i,j,level) = o3l(region)%d3(i,j,level) - &
  1406. cr4(i,j,1)*(1000./xmair)*ye(i,j,iairm)/y(i,j,iair) !O3 + SO2 (note negative)
  1407. #ifdef with_m7
  1408. AC_O3_lp(region)%prod(i,j,level,2)=AC_O3_lp(region)%prod(i,j,level,2)-&
  1409. cr4(i,j,1)*(1000./xmair)*ye(i,j,iairm)/y(i,j,iair) !O3 + SO2 (note negative)
  1410. ! ch4+oh loss
  1411. AC_loss(region)%prod(i,j,level,iloss_ch4)= AC_loss(region)%prod(i,j,level,iloss_ch4) +&
  1412. cr3(i,j,20)*c1*ye(i,j,iairm)/y(i,j,iair) ! acc. moles/gridbox
  1413. !co+oh loss
  1414. AC_loss(region)%prod(i,j,level,iloss_co)= AC_loss(region)%prod(i,j,level,iloss_co) +&
  1415. cr3(i,j,16)*c1*ye(i,j,iairm)/y(i,j,iair) ! acc. moles/gridbox
  1416. #endif
  1417. !write(4321,*) AC_O3_lp(region)%prod(i,j,level,2)
  1418. !write(4322,*) (cr3(i,j,2) + cr3(i,j,3) + cr3(i,j,33) + cr3(i,j,50)) &
  1419. ! *c1*ye(i,j,iairm)/y(i,j,iair)
  1420. !write(4323,*) (cr3(i,j,4)-2*cr3(i,j,7) + 2*cr3(i,j,6) + cr3(i,j,8) - cr3(i,j,9) + &
  1421. ! cr3(i,j,15) + cr3(i,j,17) + cr3(i,j,42) - cr3(i,j,43) + &
  1422. ! cr3(i,j,45) + cr3(i,j,48) - 0.1*cr3(i,j,49) - cr3(i,j,55) + &
  1423. ! cr2(i,j,1) - cr2(i,j,4) - cr2(i,j,6) - cr2(i,j,13) - 2.*cr2(i,j,10)) &
  1424. ! *c1*ye(i,j,iairm)/y(i,j,iair) ! acc. moles/gridbox
  1425. !write(4324,*) cr4(i,j,1)*(1000./xmair)*ye(i,j,iairm)/y(i,j,iair) !O3 + SO2 (note negative)
  1426. !PLS ! ch4+oh
  1427. !PLS ch4oh(region)%d3(i,j,level) = ch4oh(region)%d3(i,j,level) + &
  1428. !PLS cr3(i,j,20)*c1*ye(i,j,iairm)/y(i,j,iair) ! acc. moles/gridbox
  1429. !PLS ! S gas phase production (OH + SO2---> SO4, OH + DMS = 0.25 MSA)
  1430. !PLS so4pg(region)%d3(i,j,level) = so4pg(region)%d3(i,j,level) + &
  1431. !PLS (0.25*cr3(i,j,58) + cr3(i,j,60))*c1*ye(i,j,iairm)/y(i,j,iair) ! acc. moles/gridbox OH + SO2
  1432. !PLS ! SO4 wet production
  1433. !PLS so4pa(region)%d3(i,j,level) = so4pa(region)%d3(i,j,level) - &
  1434. !PLS (cr4(i,j,1)+cr4(i,j,2))*(1000./xmair)*ye(i,j,iairm)/y(i,j,iair) ! acc. moles/gridbox note neg.
  1435. do i01=1,nreac
  1436. budrrg(nzone,nzone_v,i01)=budrrg(nzone,nzone_v,i01)+ &
  1437. cr3(i,j,i01)*c1*ye(i,j,iairm)/y(i,j,iair) !units mole
  1438. end do
  1439. do i01=1,nreacw
  1440. budrwg(nzone,nzone_v,i01)=budrwg(nzone,nzone_v,i01)- &
  1441. cr4(i,j,i01)*(1000./xmair)*ye(i,j,iairm)/y(i,j,iair) ! mole
  1442. !note: changed sign to get 'positive' budget, just a
  1443. ! matter of definition, !CMK
  1444. end do
  1445. end do
  1446. end do
  1447. !sum up global budgets (done in chemistry/chemistry_done)
  1448. end subroutine REACBUD
  1449. !EOC
  1450. #endif
  1451. end subroutine EBI
  1452. !EOC
  1453. !--------------------------------------------------------------------------
  1454. ! TM5 !
  1455. !--------------------------------------------------------------------------
  1456. !BOP
  1457. !
  1458. ! !IROUTINE: WETS
  1459. !
  1460. ! !DESCRIPTION: aqueous phase chemistry of sulfur (and other): oxidation of
  1461. ! SO2 and uptake of other gases in the aqueous phase
  1462. ! Method : implicit solution of oxidation of SO2
  1463. !\\
  1464. !\\
  1465. ! !INTERFACE:
  1466. !
  1467. #ifdef with_budgets
  1468. subroutine wetS(region, level, is, js, y0, dt, y, ye, c4, status)
  1469. #else
  1470. subroutine wetS(region, level, is, js, y0, dt, y, ye, status)
  1471. #endif
  1472. !
  1473. ! !USES:
  1474. !
  1475. use Dims, only: CheckShape, idatei
  1476. use global_data, only: region_dat
  1477. use reaction_data, only: nreacw, ntlow, kso2hp, kso2o3
  1478. use chem_param
  1479. use dims, only: im, jm
  1480. use Binas, only: Avog
  1481. use boundary, only: LCMIP6_CO2, co2_glob
  1482. !
  1483. ! !INPUT PARAMETERS:
  1484. !
  1485. integer,intent(in) :: region !region region under operation (provides im,jm,lm via chemistry.mod)
  1486. integer,intent(in) :: level, is, js ! vertical level, tile start indices
  1487. real, intent(in) :: dt ! chemistry timestep
  1488. real, intent(in) :: y0(is:,js:,:) ! initial concentration
  1489. !
  1490. ! !OUTPUT PARAMETERS:
  1491. !
  1492. real, intent(out) :: y(is:,js:,:) ! concentrations at time is t
  1493. integer,intent(out) :: status
  1494. !
  1495. ! !INPUT/OUTPUT PARAMETERS:
  1496. !
  1497. real, intent(inout) :: ye(is:,js:,:) ! extra fields (temp, cc, pH)
  1498. #ifdef with_budgets
  1499. real, intent(inout) :: c4(is:,js:,:) ! budget accumulatior
  1500. #endif
  1501. !
  1502. ! !REVISION HISTORY:
  1503. ! ???? - Ad Jeuken (KNMI) and Frank Dentener (IMAU) - v0
  1504. ! Jan 2002 - Maarten Krol (IMAU) - adapted for TM5
  1505. ! Feb 2007 - Elisabetta Vignati (JRC) - adapted for TM5/M7
  1506. ! 22 Mar 2012 - P. Le Sager - adapted for lon-lat MPI domain decomposition
  1507. !
  1508. !EOP
  1509. !------------------------------------------------------------------------
  1510. !BOC
  1511. character(len=*), parameter :: rname = mname//'/Wets'
  1512. integer n,i,j,l,itemp,iter
  1513. real x1,x2,x3,b1,b2,so2x,dh2o2,dso2,disc,dnh3,dn2o5,xso2o3a,xso2o3b,co2
  1514. real,parameter :: rg=0.08314
  1515. real,dimension(:,:),allocatable :: hkso2 ! Henry's constant for sulfur dioxide
  1516. real,dimension(:,:),allocatable :: hkh2o2 ! Henry's constant for hydroperoxide
  1517. real,dimension(:,:),allocatable :: hko3 ! Henry's constant for ozone
  1518. real,dimension(:,:),allocatable :: dkso2 ! Dissociation constant for SO2
  1519. real,dimension(:,:),allocatable :: dkhso3 ! Dissociation constant for HSO3-
  1520. real,dimension(:,:),allocatable :: dkh2o ! dissociation constant water
  1521. real,dimension(:,:),allocatable :: dknh3 ! dissociation constant ammonia
  1522. real,dimension(:,:),allocatable :: hknh3 ! Henry's constant ammonia
  1523. real,dimension(:,:),allocatable :: hkco2 ! Henry's constant CO2
  1524. real,dimension(:,:),allocatable :: dkco2 ! Dissociation constant CO2
  1525. real phs4 ! effective dissolvation of S(IV)
  1526. real phso2 ! effective dissolvation of SO2
  1527. real phh2o2 ! effective dissolvation of H2O2
  1528. real phozone ! effective dissolvation of O3
  1529. real,dimension(:,:),allocatable :: hplus !concentration h+
  1530. real,dimension(:,:),allocatable :: sulph !accumul+coarse mode sulphate
  1531. real a1,a2,a,b,c,z,ft ! help variables
  1532. real xcov,xliq,xl,temp,rt,ztr,h2o,air,press ! meteo
  1533. real,dimension(:,:,:),allocatable :: rw ! reaction rates
  1534. logical,dimension(:,:),allocatable :: cloudy
  1535. integer :: i1, i2, j1, j2
  1536. real :: l_sum_wet
  1537. ! --- begin --------------------------------
  1538. call Get_DistGrid( dgrid(region), I_STRT=i1, I_STOP=i2, J_STRT=j1, J_STOP=j2 )
  1539. ! check arguments ...
  1540. call CheckShape( (/i2-i1+1, j2-j1+1, maxtrace/), shape(y0), status )
  1541. IF_NOTOK_RETURN(status=1)
  1542. call CheckShape( (/i2-i1+1, j2-j1+1, maxtrace/), shape(y ), status )
  1543. IF_NOTOK_RETURN(status=1)
  1544. call CheckShape( (/i2-i1+1, j2-j1+1, n_extra /), shape(ye), status )
  1545. IF_NOTOK_RETURN(status=1)
  1546. #ifdef with_budgets
  1547. call CheckShape( (/i2-i1+1, j2-j1+1, nreacw /), shape(c4), status )
  1548. IF_NOTOK_RETURN(status=1)
  1549. #endif
  1550. allocate(hkso2 (i1:i2, j1:j2))
  1551. allocate(hkh2o2 (i1:i2, j1:j2))
  1552. allocate(hko3 (i1:i2, j1:j2))
  1553. allocate(dkso2 (i1:i2, j1:j2))
  1554. allocate(dkhso3 (i1:i2, j1:j2))
  1555. allocate(dkh2o (i1:i2, j1:j2))
  1556. allocate(dknh3 (i1:i2, j1:j2))
  1557. allocate(hknh3 (i1:i2, j1:j2))
  1558. allocate(hkco2 (i1:i2, j1:j2))
  1559. allocate(dkco2 (i1:i2, j1:j2))
  1560. allocate(hplus (i1:i2, j1:j2))
  1561. allocate(rw (i1:i2, j1:j2, nreacw))
  1562. allocate(cloudy (i1:i2, j1:j2))
  1563. allocate(sulph (i1:i2, j1:j2))
  1564. !-----------------------------
  1565. ! wet phase reactions
  1566. !-----------------------------
  1567. rw =0.0
  1568. hplus=0.0
  1569. if (LCMIP6_CO2) then
  1570. co2=co2_glob
  1571. else
  1572. !
  1573. ! JEW: now scaled to 2000 to account for annual growth of ~2ppbv/yr-1
  1574. !
  1575. co2=3.69e-4 ! was parameter co2=3.75e-4,
  1576. endif
  1577. #if defined (with_budgets)
  1578. l_sum_wet = 0.0
  1579. #endif
  1580. do j = j1, j2
  1581. do i = i1, i2
  1582. cloudy(i,j)=.false.
  1583. ! lwc is dimensionless
  1584. if ((ye(i,j,ilwc) > 1e-10).and.(ye(i,j,icc) > 0.02)) then
  1585. cloudy(i,j)=.true.
  1586. TEMP=ye(i,j,i_temp)
  1587. ZTR=(1./TEMP-1./298)
  1588. RT=TEMP*rg
  1589. ITEMP=nint(TEMP-float(ntlow))
  1590. !
  1591. !CEV sulph is the initial total sulphate content in accumulation+
  1592. !coarse mode, the incloud production is calculated on bulk
  1593. !characteristics, and redistributed on the modes depending on their
  1594. !particle numbers
  1595. #ifdef with_m7
  1596. !Stelios: small contributions from nucleation and Aitken mode
  1597. ! as well as gas-phase should be added for pH calculation
  1598. sulph(i,j)=y0(i,j,iso4acs)+y0(i,j,iso4cos)+&
  1599. y0(i,j,iso4nus)+y0(i,j,iso4ais)+y0(i,j,iso4)
  1600. #else
  1601. sulph(i,j)=y0(i,j,iso4)
  1602. #endif
  1603. !
  1604. ! Henry and dissociation equilibria
  1605. !
  1606. dkh2o(i,j) =1.01e-14*exp(-6706.0 *ztr) !h2o<=>hplus+so3--
  1607. !bug hkco2(i,j) =3.4e-2*(2420.*ztr) ! is already dimensionless
  1608. hkco2(i,j) =3.4e-2*exp(2420.*ztr) ! is already dimensionless
  1609. dkco2(i,j) =4.5E-7*exp(-1000.*ztr) !co2aq<=>hco3- + hplus
  1610. hkso2(i,j) =henry(iso2,itemp)*rt !dimensionless
  1611. dknh3(i,j) =1.8e-5*exp(-450.*ztr) !nh3<=>nh4+ + OH-
  1612. hknh3(i,j) =henry(inh3,itemp)*rt !dimensionless
  1613. hkh2o2(i,j)=henry(ih2o2,itemp)*rt !dimensionless
  1614. hko3(i,j) =henry(io3,itemp)*rt !dimensionless
  1615. dkso2(i,j) =1.7e-2*exp(2090.*ztr) !so2<=>hso3m+hplus
  1616. dkhso3(i,j)=6.6e-8*exp(1510.*ztr) !hso3m<=>so3-- + hplus
  1617. !
  1618. ! calculate H+ from initial sulfate, ammonium, hno3, and nh3
  1619. ! if solution is strongly acidic no further calculations are performed
  1620. !
  1621. xl=ye(i,j,ilwc)*Avog*1e-3/ye(i,j,icc)
  1622. !x1 is initial strong acidity from SO4 and NO3
  1623. !
  1624. !acidity from strong acids alone
  1625. !
  1626. !CMK hplus(i,j)=(2.*y0(i,j,iso4)+y0(i,j,imsa)-y0(i,j,inh4)+ &
  1627. !CMK y0(i,j,ihno3)+y0(i,j,ino3_a))/xl
  1628. hplus(i,j)=(2.*sulph(i,j) + &
  1629. y0(i,j,imsa)-y0(i,j,inh4)+ &
  1630. y0(i,j,ihno3)+y0(i,j,ino3_a))/xl
  1631. end if
  1632. end do
  1633. end do
  1634. do iter=1,10
  1635. do j=j1, j2
  1636. do i=i1, i2
  1637. ! only if solution pH>4.5
  1638. if ( cloudy(i,j) .and. hplus(i,j) < 3e-5 ) then
  1639. xl=ye(i,j,ilwc)*Avog*1e-3/ye(i,j,icc)
  1640. !CEV y0(i,j,iso4)---> sulph(i,j)
  1641. x1=(2.*sulph(i,j)+y0(i,j,imsa)+y0(i,j,ihno3)+ &
  1642. y0(i,j,ino3_a))/xl
  1643. !x2 is initial total NHx
  1644. x2=(y0(i,j,inh3)+y0(i,j,inh4))/xl
  1645. !x3 is combined dissolution and solubility const for CO2
  1646. x3=dkco2(i,j)*hkco2(i,j)*co2
  1647. a1=dkh2o(i,j)/dknh3(i,j)*(1.+1./hknh3(i,j)) ! integration constant
  1648. a2=y0(i,j,iso2)/xl !initial SO2
  1649. ! trap division by zero ...
  1650. if ( hplus(i,j) == 0.0 ) then
  1651. z = 0.0
  1652. else
  1653. z = a2/( hplus(i,j)/dkso2(i,j)*(1.0+1.0/hkso2(i,j)) + dkhso3(i,j)/hplus(i,j) + 1.0 )
  1654. end if
  1655. ! solve quadratic equation for new H+ concentration:
  1656. a=1.+x2/(a1+hplus(i,j))
  1657. b=-x1-z
  1658. c=-x3-2.*dkhso3(i,j)*z
  1659. z=max(0.,(b*b-4.*a*c))
  1660. hplus(i,j)=max(1.e-10,(-b+sqrt(z))/(2.*a))
  1661. end if
  1662. end do !
  1663. end do ! i,j loop
  1664. end do !iter
  1665. do j=j1,j2
  1666. do i=i1,i2
  1667. if (cloudy(i,j)) then
  1668. temp=ye(i,j,i_temp)
  1669. ZTR=(1./TEMP-1./298)
  1670. xliq=ye(i,j,ilwc)/ye(i,j,icc)
  1671. xl=ye(i,j,ilwc)*Avog*1e-3/ye(i,j,icc)
  1672. ye(i,j,iph)=-log10(hplus(i,j)) ! pH for diagnostics
  1673. ! phase factor ratio of aqueous phase to gas phase concentration
  1674. phs4 =hkso2(i,j) *(1.+dkso2(i,j)/hplus(i,j)+ &
  1675. dkso2(i,j)*dkhso3(i,j)/hplus(i,j)/hplus(i,j))*xliq
  1676. phso2 =hkso2(i,j) *xliq
  1677. phh2o2 =hkh2o2(i,j)*xliq
  1678. phozone=hko3(i,j) *xliq
  1679. ! the original rate equations could be partly in look-up table
  1680. rw(i,j,KSO2HP) =8e4*exp(-3560.*ztr)/(0.1+hplus(i,j))
  1681. XSO2O3A=4.39e11*exp(-4131./temp)+2.56e3*exp(-966./temp) !S(IV)
  1682. XSO2O3B=2.56e3*exp(-966./temp)/hplus(i,j)
  1683. !divide by [H+]!S(IV)
  1684. ! make rate constants dimensionless by multiplying
  1685. ! by (1./xliq/avo=6e20)
  1686. ! multiply with the fractions of concentrations residing
  1687. ! in the aqueous phase
  1688. rw(i,j,KSO2HP)=rw(i,j,KSO2HP)/xl*phso2/(1.+phs4)*phh2o2/(1.+phh2o2)
  1689. rw(i,j,KSO2O3)=(XSO2O3A+XSO2O3B)/xl*phs4/(1.+phs4)*phozone/ &
  1690. (1.+phozone)
  1691. end if !cloudy
  1692. end do !
  1693. end do ! I,J, LOOP
  1694. !------------- Start main loop
  1695. do j=j1,j2
  1696. do i=i1,i2
  1697. !
  1698. ! only cloud chemistry if substantial amount of clouds are present
  1699. !
  1700. if (cloudy(i,j)) then
  1701. !
  1702. ! oxidation of S(IV) by O3
  1703. !
  1704. so2x=y0(i,j,iso2)
  1705. xcov=ye(i,j,icc)
  1706. x1=min(100.,rw(i,j,kso2o3)*y0(i,j,io3)*dt)
  1707. dso2=y0(i,j,iso2)*xcov*(exp(-x1)-1.)
  1708. !only applied to xcov part of cloud
  1709. !CMK print *, i,j, xcov, x1, y0(i,j,iso2), dso2
  1710. dso2=max(-y0(i,j,io3)*xcov,dso2)! limit to o3 availability
  1711. !CEV y(i,j,iso2)=y0(i,j,iso2)+dso2
  1712. !NOTE CMK: parallel MPI should take care here!
  1713. #ifdef with_m7
  1714. ft = y0(i,j,iacs_n) + y0(i,j,icos_n)
  1715. if (ft > tiny(ft)) then
  1716. y(i,j,iso4acs)=y0(i,j,iso4acs)-dso2*(y0(i,j,iacs_n)/ft)
  1717. y(i,j,iso4cos)=y0(i,j,iso4cos)-dso2*(y0(i,j,icos_n)/ft)
  1718. y(i,j,iso2)=y0(i,j,iso2)+dso2
  1719. y(i,j,io3)=y0(i,j,io3)+dso2
  1720. !AERHEMMIP
  1721. ! Production of liquid phase so4
  1722. ! D_prod_liq(i,j)=-dso2
  1723. #ifdef with_budgets
  1724. c4(i,j,1)=c4(i,j,1)+dso2
  1725. !conversion 1e-3 g->kg 1e6 cm-3 ->1m-3
  1726. diag_prod(region)%prod(i,j,level,2)=diag_prod(region)%prod(i,j,level,2)-dso2/y(i,j,iair)*ye(i,j,iairm)/xmair*xmso4
  1727. AC_diag_prod(region)%prod(i,j,level,iprod_aqso4)=AC_diag_prod(region)%prod(i,j,level,iprod_aqso4)-dso2/y(i,j,iair)*ye(i,j,iairm)/xmair*xmso4!kg
  1728. #endif
  1729. else
  1730. #ifdef with_budgets
  1731. diag_prod(region)%prod(i,j,level,2)=diag_prod(region)%prod(i,j,level,2)+0.0
  1732. AC_diag_prod(region)%prod(i,j,level,iprod_aqso4)=AC_diag_prod(region)%prod(i,j,level,iprod_aqso4)+0.0
  1733. #endif
  1734. !CEV y(i,j,iso4)=y0(i,j,iso4)-dso2
  1735. y(i,j,iso4acs)=y0(i,j,iso4acs)
  1736. y(i,j,iso4cos)=y0(i,j,iso4cos)
  1737. y(i,j,iso2)=y0(i,j,iso2)
  1738. y(i,j,io3)=y0(i,j,io3)
  1739. endif
  1740. !CEV y(i,j,io3)=y0(i,j,io3)+dso2
  1741. #else
  1742. ! gas phase chemistry: ft = 0.
  1743. y(i,j,iso4)=y0(i,j,iso4)-dso2
  1744. y(i,j,iso2)=y0(i,j,iso2)+dso2
  1745. y(i,j,io3)=y0(i,j,io3)+dso2
  1746. #ifdef with_budgets
  1747. c4(i,j,1)=c4(i,j,1)+dso2
  1748. #endif
  1749. #endif
  1750. #ifdef with_budgets
  1751. if ( io3 == 1 ) l_sum_wet = l_sum_wet- &
  1752. dso2 *ye(i,j,iairm)/ (fscale(1)*y(i,j,iair))
  1753. if ( iso2 == 1 ) l_sum_wet = l_sum_wet+ &
  1754. dso2 *ye(i,j,iairm)/ (fscale(1)*y(i,j,iair))
  1755. if ( iso4 == 1 ) l_sum_wet = l_sum_wet- &
  1756. dso2 *ye(i,j,iairm)/ (fscale(1)*y(i,j,iair))
  1757. !CEV c4(i,j,1)=c4(i,j,1)+dso2
  1758. #endif
  1759. xliq=ye(i,j,ilwc)/ye(i,j,icc)
  1760. !
  1761. ! oxidation of S(IV) by H2O2
  1762. !
  1763. !*** here we explicitly solve the dv:
  1764. ! y'=P-Q*y-R*y*y (P and Q are 0=>b3=0.)
  1765. !
  1766. so2x=y(i,j,iso2)
  1767. if ( so2x > tiny(so2x) ) then
  1768. b1=rw(i,j,kso2hp)
  1769. b2=b1*(y0(i,j,ih2o2)-so2x)
  1770. disc=min(100.,sqrt(b2*b2)) ! disc is b2 for b3=0.0
  1771. x1=(b2-disc)/(-2.*b1) ! in this case x1 =0.
  1772. x2=(b2+disc)/(-2.*b1)
  1773. x3=(so2x-x1)/(so2x-x2)*exp(-disc*dt)
  1774. so2x=(x1-x2*x3)/(1.-x3)
  1775. dso2=(so2x-y(i,j,iso2))*xcov
  1776. dso2=max(dso2,-y0(i,j,ih2o2)*xcov)
  1777. !CEV y(i,j,iso2) =y(i,j,iso2)+dso2 ! dso2 is loss of SO2 and H2O2
  1778. ! divide produced SO4 over CO/ACC
  1779. #ifdef with_m7
  1780. ft = y0(i,j,iacs_n) + y0(i,j,icos_n)
  1781. if (ft > tiny(ft)) then
  1782. y(i,j,iso4acs)=y(i,j,iso4acs)-dso2*(y0(i,j,iacs_n)/ft)
  1783. y(i,j,iso4cos)=y(i,j,iso4cos)-dso2*(y0(i,j,icos_n)/ft)
  1784. y(i,j,iso2)=y(i,j,iso2)+dso2
  1785. y(i,j,ih2o2)=y0(i,j,ih2o2)+dso2
  1786. #ifdef with_budgets
  1787. c4(i,j,2)=c4(i,j,2)+dso2
  1788. ! add amount liquid so4 production to diagnostic and change to molec->mass kg
  1789. !
  1790. diag_prod(region)%prod(i,j,level,2)=diag_prod(region)%prod(i,j,level,2)-dso2/y(i,j,iair)*ye(i,j,iairm)/xmair*xmso4!kg
  1791. AC_diag_prod(region)%prod(i,j,level,iprod_aqso4)=AC_diag_prod(region)%prod(i,j,level,iprod_aqso4)-dso2/y(i,j,iair)*ye(i,j,iairm)/xmair*xmso4!kg
  1792. #endif
  1793. else
  1794. #ifdef with_budgets
  1795. diag_prod(region)%prod(i,j,level,2)=diag_prod(region)%prod(i,j,level,2)+0.0
  1796. AC_diag_prod(region)%prod(i,j,level,iprod_aqso4)=AC_diag_prod(region)%prod(i,j,level,iprod_aqso4)+0.0
  1797. #endif
  1798. y(i,j,ih2o2) =y0(i,j,ih2o2)
  1799. endif
  1800. #else
  1801. ! gas - phase chemistry
  1802. y(i,j,iso4)=y(i,j,iso4)-dso2
  1803. y(i,j,iso2)=y(i,j,iso2)+dso2
  1804. y(i,j,ih2o2)=y0(i,j,ih2o2)+dso2
  1805. #ifdef with_budgets
  1806. c4(i,j,2)=c4(i,j,2)+dso2
  1807. #endif
  1808. #endif
  1809. #ifdef with_budgets
  1810. if ( ih2o2 == 1 ) l_sum_wet = l_sum_wet- &
  1811. dso2 *ye(i,j,iairm)/ (fscale(1)*y(i,j,iair))
  1812. if ( iso2 == 1 ) l_sum_wet = l_sum_wet- &
  1813. dso2 *ye(i,j,iairm)/ (fscale(1)*y(i,j,iair))
  1814. if ( iso4 == 1 ) l_sum_wet = l_sum_wet+ &
  1815. dso2 *ye(i,j,iairm)/ (fscale(1)*y(i,j,iair))
  1816. !CEV c4(i,j,2)=c4(i,j,2)+dso2
  1817. #endif
  1818. end if
  1819. !
  1820. ! NH3 uptake in cloud droplets is limited by SO4 availability
  1821. ! no HNO3 is considered at this point
  1822. ! assume instantaneous uptake of NH3 incloud only in cloudy part
  1823. !
  1824. ! EQSAM gives hell to any NH3/NH4 interchange. It first drops both in one heap
  1825. ! and then redistributes. So this cloud chemistry reaction does not matter.
  1826. end if !cloudy
  1827. end do ! i,j,loop
  1828. end do !
  1829. #ifdef with_budgets
  1830. sum_wetchem(region) = sum_wetchem(region) + l_sum_wet
  1831. #endif
  1832. !free memory
  1833. deallocate(hkso2 )
  1834. deallocate(hkh2o2 )
  1835. deallocate(hko3 )
  1836. deallocate(dkso2 )
  1837. deallocate(dkhso3 )
  1838. deallocate(dkh2o )
  1839. deallocate(dknh3 )
  1840. deallocate(hknh3 )
  1841. deallocate(hkco2 )
  1842. deallocate(dkco2 )
  1843. deallocate(hplus )
  1844. deallocate(rw )
  1845. deallocate(cloudy )
  1846. deallocate(sulph )
  1847. status = 0
  1848. end subroutine WETS
  1849. !EOC
  1850. !--------------------------------------------------------------------------
  1851. ! TM5 !
  1852. !--------------------------------------------------------------------------
  1853. !BOP
  1854. !
  1855. ! !IROUTINE: MARK_TRAC
  1856. !
  1857. ! !DESCRIPTION: calculate nox/pan/orgn/hno3 analogous to ebi scheme
  1858. ! ozone production from marked nox
  1859. ! simple nhx chemistry, scaled to real nhx
  1860. !\\
  1861. !\\
  1862. ! !INTERFACE:
  1863. !
  1864. subroutine MARK_TRAC( region, level, is, js, y, rr, rj, dt, ye)
  1865. !
  1866. ! !USES:
  1867. !
  1868. use chem_param
  1869. use Dims, only : CheckShape
  1870. use global_data, only : region_dat
  1871. use dims, only : at, bt, im, jm
  1872. #ifdef with_budgets
  1873. use budget_global, only : budg_dat, nzon_vg
  1874. #endif
  1875. !
  1876. ! !INPUT PARAMETERS:
  1877. !
  1878. integer, intent(in) :: region, level, is, js
  1879. real :: dt ! time step
  1880. !
  1881. ! !INPUT/OUTPUT PARAMETERS:
  1882. !
  1883. real, intent(inout):: y (is:,js:,:) ! concentrations
  1884. real, intent(in) :: rr(is:,js:,:) ! reaction rates
  1885. real, intent(in) :: rj(is:,js:,:) ! photolysis rates
  1886. real, intent(in) :: ye(is:,js:,:) ! help fields ( air masses )
  1887. !
  1888. ! !REVISION HISTORY:
  1889. ! Jan 1999 - fjd
  1890. ! Jan 2002 - MK - adapted for TM5
  1891. ! 22 Mar 2012 - P. Le Sager - adapted for lon-lat MPI domain decomposition
  1892. !
  1893. !EOP
  1894. !------------------------------------------------------------------------
  1895. !BOC
  1896. integer :: status, i1, i2, j1, j2
  1897. ! --- begin --------------------------------
  1898. call Get_DistGrid( dgrid(region), I_STRT=i1, I_STOP=i2, J_STRT=j1, J_STOP=j2 )
  1899. ! check arguments ...
  1900. call CheckShape( (/i2-i1+1, j2-j1+1, maxtrace/), shape(y ), status )
  1901. call CheckShape( (/i2-i1+1, j2-j1+1, nreac /), shape(rr), status )
  1902. call CheckShape( (/i2-i1+1, j2-j1+1, nj /), shape(rj), status )
  1903. call CheckShape( (/i2-i1+1, j2-j1+1, n_extra /), shape(ye), status )
  1904. call MARK_O3S
  1905. !
  1906. ! more marked tracers possible here
  1907. !
  1908. contains
  1909. subroutine mark_o3s
  1910. !---------------------------------------------------
  1911. ! marked tracer O3S stratospheric ozone
  1912. !---------------------------------------------------
  1913. #ifndef without_dry_deposition
  1914. use dry_deposition, only: vd
  1915. #endif
  1916. integer :: i, j, nzone, nzone_v
  1917. real :: p3, xl3, o3old
  1918. do j = j1, j2
  1919. do i = i1, i2
  1920. if (at(level+1)+bt(level+1)*1e5<= 14000) then !
  1921. ! well, you want to count all layers below 140 hPa
  1922. ! (given surface pressure of 1e5 Pa)
  1923. ! in the current model setup (25 layers) this means
  1924. ! 12077 + 1e5*0.00181 = 12258 Pa and above...
  1925. ! p3: production of o3 in stratosphere
  1926. P3 = rj(i,j,jano3)*y(i,j,ino3)+ &
  1927. rj(i,j,jno2)*y(i,j,ino2)
  1928. XL3= rr(i,j,ko3ho2)*y(i,j,iho2)+&
  1929. rr(i,j,ko3oh)*y(i,j,ioh)+ &
  1930. rr(i,j,kno2o3)*y(i,j,ino2)+&
  1931. rj(i,j,jo3d)+&
  1932. rr(i,j,knoo3)*y(i,j,ino)+&
  1933. rr(i,j,kc62)*y(i,j,ieth)+&
  1934. rr(i,j,kc58)*y(i,j,iole)+&
  1935. rr(i,j,kc77)*y(i,j,iisop)+&
  1936. rr(i,j,ko3c3h6)*y(i,j,ic3h6)+&
  1937. rr(i,j,ko3terp)*y(i,j,iterp)+&
  1938. rr(i,j,ko3ispd)*y(i,j,iispd)
  1939. else
  1940. !
  1941. ! these are only the net destruction reactions
  1942. !
  1943. P3 = 0.
  1944. XL3= rr(i,j,ko3ho2)*y(i,j,iho2)+&
  1945. rr(i,j,ko3oh)*y(i,j,ioh)+&
  1946. rj(i,j,jo3d)+&
  1947. rr(i,j,kc62)*y(i,j,ieth)+&
  1948. rr(i,j,kc58)*y(i,j,iole)+&
  1949. rr(i,j,kc77)*y(i,j,iisop)+&
  1950. rr(i,j,ko3c3h6)*y(i,j,ic3h6)+&
  1951. rr(i,j,ko3terp)*y(i,j,iterp)+&
  1952. rr(i,j,ko3ispd)*y(i,j,iispd)+&
  1953. rr(i,j,knh2o3)*y(i,j,inh2)+&
  1954. rr(i,j,knh2o2o3)*y(i,j,inh2o2)
  1955. ! add up deposition....
  1956. #ifndef without_dry_deposition
  1957. if ( level == 1 ) &
  1958. XL3 = XL3 + vd(region,io3)%surf(i,j)/ye(i,j,idz)
  1959. #endif
  1960. end if
  1961. o3old=y(i,j,io3s)
  1962. y(i,j,io3s)=(o3old+p3*dt)/(1.+xl3*dt)
  1963. #ifdef with_budgets
  1964. nzone=budg_dat(region)%nzong(i,j) ! global budget
  1965. nzone_v=nzon_vg(level)
  1966. budmarkg(nzone,nzone_v,1)=budmarkg(nzone,nzone_v,1)+ &
  1967. (y(i,j,io3s)-o3old)*ye(i,j,iairm)*1000./xmair/y(i,j,iair)
  1968. #endif
  1969. end do
  1970. end do !i,j
  1971. end subroutine MARK_O3S
  1972. end subroutine MARK_TRAC
  1973. !EOC
  1974. end module EBISCHEME