chemistry.F90 71 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854
  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: CHEMISTRY
  13. !
  14. ! !DESCRIPTION: perform CB05 chemistry simulation in TM5 + M7
  15. !\\
  16. !\\
  17. ! !INTERFACE:
  18. !
  19. MODULE CHEMISTRY
  20. !
  21. ! !USES:
  22. !
  23. use GO, only : gol, goErr, goPr, goBug
  24. use tm5_distgrid, only : dgrid, Get_DistGrid, gather
  25. use dims, only : nregions
  26. #ifdef with_budgets
  27. use budget_global, only : nbudg, nbud_vg
  28. use chem_param, only : ntrace, ntracet
  29. #endif
  30. IMPLICIT NONE
  31. PRIVATE
  32. !
  33. ! !PUBLIC MEMBER FUNCTIONS:
  34. !
  35. public :: Chemistry_Init, Chemistry_Done
  36. public :: Chemie
  37. !
  38. ! !PRIVATE DATA MEMBERS:
  39. !
  40. #ifdef with_budgets
  41. real, dimension(:,:,:), allocatable :: budchem
  42. real, Dimension(:,:,:), Allocatable :: budeqsam
  43. real :: eminox
  44. #ifdef with_m7
  45. real, dimension(:,:,:), allocatable :: budm7proc
  46. real, dimension(:,:,:), allocatable :: budm7
  47. real, dimension(:,:,:),allocatable,public::d_nucle, growth1_2, coag_sink_nuc, cond1_soa, cond1_su, m_nucle_su
  48. real, dimension(:,:,:),allocatable,public::cond2_soa, cond3_soa, cond4_soa, cond5_soa, m_nucle_soa
  49. #endif
  50. #endif
  51. character(len=*), parameter :: mname = 'chemistry'
  52. !
  53. ! minimal concentration required to apply scaling for slopes
  54. ! (to avoid floating point overflows):
  55. real, parameter :: eps = 1.0e-20
  56. !
  57. ! !REVISION HISTORY:
  58. ! 2005 - Elisabetta Vignati - changed for coupling with M7
  59. ! 22 Mar 2012 - P. Le Sager - adapted for lon-lat MPI domain decomposition
  60. !
  61. ! !REMARKS:
  62. !
  63. !EOP
  64. !------------------------------------------------------------------------
  65. CONTAINS
  66. !--------------------------------------------------------------------------
  67. ! TM5 !
  68. !--------------------------------------------------------------------------
  69. !BOP
  70. !
  71. ! !IROUTINE: CHEMISTRY_INIT
  72. !
  73. ! !DESCRIPTION: allocate and initialize budget arrays. Init M7 if needed.
  74. !\\
  75. !\\
  76. ! !INTERFACE:
  77. !
  78. SUBROUTINE CHEMISTRY_INIT( status )
  79. !
  80. ! !USES:
  81. !
  82. use Dims , only : nregions, im, jm, lm
  83. #ifdef with_budgets
  84. use Chem_param, only : ntrace, ntracet
  85. use ebischeme , only : sum_deposition, sum_wetchem, sum_chemistry
  86. use ebischeme , only : buddep_dat, budrrg, budrjg, budrwg,diag_prod,AC_diag_prod,AC_O3_lp,nprod,nprod_AC,nprod_AC_o3
  87. !PLS use chem_param, only : ch4oh, so4pg, so4pa, o3p, o3l
  88. use chem_param, only : o3p, o3l
  89. #ifdef with_m7
  90. use m7_data, only : nm7procs
  91. #endif
  92. #endif
  93. #ifdef with_m7
  94. use mo_aero_m7, only : m7_initialize
  95. use m7_data, only : init_m7_data
  96. #endif
  97. use meteoData , only : Set
  98. use MeteoData , only : phlb_dat, m_dat, temper_dat, humid_dat, gph_dat
  99. use MeteoData , only : lwc_dat, iwc_dat, cc_dat
  100. !
  101. ! !OUTPUT PARAMETERS:
  102. !
  103. integer, intent(out) :: status
  104. !
  105. ! !REVISION HISTORY:
  106. ! 22 Mar 2012 - P. Le Sager - adapted for lon-lat MPI domain decomposition
  107. !
  108. !EOP
  109. !------------------------------------------------------------------------
  110. !BOC
  111. integer :: region, i1, i2, j1, j2
  112. character(len=*), parameter :: rname = mname//'/Chemistry_Init'
  113. ! --- begin --------------------------------
  114. ! select meteo to be used:
  115. do region = 1, nregions
  116. call Set( phlb_dat(region), status, used=.true. )
  117. call Set( m_dat(region), status, used=.true. )
  118. call Set( temper_dat(region), status, used=.true. )
  119. call Set( humid_dat(region), status, used=.true. )
  120. call Set( gph_dat(region), status, used=.true. )
  121. call Set( lwc_dat(region), status, used=.true. )
  122. call Set( iwc_dat(region), status, used=.true. )
  123. call Set( cc_dat(region), status, used=.true. )
  124. enddo
  125. #ifdef with_budgets
  126. do region = 1, nregions
  127. sum_chemistry (region) = 0.0
  128. sum_deposition(region) = 0.0
  129. sum_wetchem (region) = 0.0
  130. call Get_DistGrid( dgrid(region), I_STRT=i1, I_STOP=i2, J_STRT=j1, J_STOP=j2 )
  131. allocate(buddep_dat(region)%dry(i1:i2, j1:j2, ntrace))
  132. buddep_dat(region)%dry = 0.0
  133. !nprod=4
  134. #ifdef with_m7
  135. allocate(diag_prod(region)%prod(i1:i2, j1:j2, lm(region),nprod))
  136. allocate(AC_diag_prod(region)%prod(i1:i2, j1:j2, lm(region),nprod_AC))
  137. allocate(AC_O3_lp(region)%prod(i1:i2, j1:j2, lm(region),nprod_AC_o3))
  138. diag_prod(region)%prod = 0.0
  139. AC_diag_prod(region)%prod = 0.0
  140. AC_O3_lp(region)%prod = 0.0
  141. allocate(d_nucle(i1:i2,j1:j2,lm(region)))
  142. allocate(m_nucle_su(i1:i2,j1:j2,lm(region)))
  143. allocate(m_nucle_soa(i1:i2,j1:j2,lm(region)))
  144. allocate(growth1_2(i1:i2,j1:j2,lm(region)))
  145. allocate(coag_sink_nuc(i1:i2,j1:j2,lm(region)))
  146. allocate(cond1_soa(i1:i2,j1:j2,lm(region)))
  147. allocate(cond2_soa(i1:i2,j1:j2,lm(region)))
  148. allocate(cond3_soa(i1:i2,j1:j2,lm(region)))
  149. allocate(cond4_soa(i1:i2,j1:j2,lm(region)))
  150. allocate(cond5_soa(i1:i2,j1:j2,lm(region)))
  151. allocate(cond1_su(i1:i2,j1:j2,lm(region)))
  152. d_nucle=0.0
  153. m_nucle_soa=0.0
  154. m_nucle_su=0.0
  155. growth1_2=0.0
  156. coag_sink_nuc=0.0
  157. cond1_soa=0.0
  158. cond2_soa=0.0
  159. cond3_soa=0.0
  160. cond4_soa=0.0
  161. cond5_soa=0.0
  162. cond1_su=0.0
  163. #endif
  164. allocate(o3p(region)%d3(i1:i2, j1:j2, lm(region))); o3p(region)%d3 = 0.0
  165. allocate(o3l(region)%d3(i1:i2, j1:j2, lm(region))); o3l(region)%d3 = 0.0
  166. ! >>>
  167. ! TvN: still in sources_sinks.F90
  168. ! allocate(ch4oh(region)%d3(i1:i2, j1:j2, lm(region))); ch4oh(region)%d3 = 0.0
  169. ! allocate(so4pg(region)%d3(i1:i2, j1:j2, lm(region))); so4pg(region)%d3 = 0.0
  170. ! allocate(so4pa(region)%d3(i1:i2, j1:j2, lm(region))); so4pa(region)%d3 = 0.0
  171. ! <<<
  172. enddo
  173. budrrg = 0.0
  174. budrjg = 0.0
  175. budrwg = 0.0
  176. Allocate(budchem(nbudg,nbud_vg,ntrace))
  177. budchem = 0.0
  178. ! Two acid-base reactions
  179. Allocate(budeqsam(nbudg,nbud_vg,2))
  180. budeqsam = 0.0
  181. #ifdef with_m7
  182. ! M7 Bugets
  183. Allocate(budm7proc(nbudg,nbud_vg,nm7procs))
  184. Allocate(budm7(nbudg,nbud_vg,ntracet))
  185. budm7proc = 0.0
  186. budm7 = 0.0
  187. #endif
  188. ! global lightning NOx
  189. eminox = 0.
  190. #endif /* BUDGETS */
  191. #ifdef with_m7
  192. CALL M7_INITIALIZE
  193. CALL INIT_M7_DATA( status ) ! declare M7 output data structure
  194. IF_NOTOK_RETURN(status=1)
  195. #endif
  196. ! ok
  197. status = 0
  198. END SUBROUTINE CHEMISTRY_INIT
  199. !EOC
  200. !--------------------------------------------------------------------------
  201. ! TM5 !
  202. !--------------------------------------------------------------------------
  203. !BOP
  204. !
  205. ! !IROUTINE: CHEMISTRY_DONE
  206. !
  207. ! !DESCRIPTION: gather and write budgets
  208. !\\
  209. !\\
  210. ! !INTERFACE:
  211. !
  212. SUBROUTINE CHEMISTRY_DONE( status )
  213. !
  214. ! !USES:
  215. !
  216. use dims, only : nregions, im, jm, lm
  217. #ifdef with_budgets
  218. use dims, only : region_name
  219. use file_hdf, only : Init, Done, WriteAttribute, WriteData, SetDim, THdfFile, TSds
  220. use budget_global, only : budget_file_global, budg_dat, NHAB
  221. #ifndef without_boundary
  222. use boundary, only : budstratg
  223. #endif
  224. #ifndef without_emission
  225. use emission, only : budemig_all
  226. #endif
  227. use partools, only : isRoot, par_reduce_element, par_reduce
  228. use ebischeme, only : sum_deposition, sum_wetchem, sum_chemistry
  229. use ebischeme, only : buddep_dat, budrrg, budrjg, budrwg, budmarkg,diag_prod
  230. !PLS use chem_param, only : ch4oh, so4pg, so4pa, o3p, o3l, marknam, nmark
  231. use chem_param, only : o3p, o3l, marknam, nmark
  232. use chem_param, only : marknam, ntrace
  233. use chem_param, only : inox
  234. use reaction_data, only : nreac, ratnam, nreacw, rwnam
  235. use photolysis_data, only : nj, jnam
  236. #ifdef with_cariolle
  237. use chem_param, only : ncar, carnam
  238. use chemistry_cariolle, only : budcarg
  239. #endif
  240. #ifdef with_m7
  241. use m7_data, only : nm7procs
  242. #endif
  243. #endif /* BUDGETS */
  244. #ifdef with_m7
  245. use m7_data, only : free_m7_data
  246. #endif
  247. !
  248. ! !OUTPUT PARAMETERS:
  249. !
  250. integer, intent(out) :: status
  251. !
  252. ! !REVISION HISTORY:
  253. ! 22 Mar 2012 - P. Le Sager - adapted for lon-lat MPI domain decomposition
  254. !
  255. ! !REMARKS:
  256. !
  257. !EOP
  258. !------------------------------------------------------------------------
  259. !BOC
  260. character(len=*), parameter :: rname = mname//'/Chemistry_Done'
  261. integer :: region
  262. #ifdef with_budgets
  263. type(THdfFile) :: io
  264. type(TSds) :: sds
  265. real, dimension(:,:,:), allocatable :: collectb
  266. real,dimension(nbudg,nbud_vg,ntrace) :: buddry
  267. real,dimension(nbudg,nbud_vg,ntrace) :: budchem_result
  268. integer :: i, j, l, nzone, n, nsend, i1, i2, j1, j2
  269. ! for buggy MPI (see comment in budget_global.F90 for details)
  270. real, dimension(nregions) :: sum_chemistry_all, sum_wetchem_all, sum_deposition_all
  271. real, dimension(nbudg,nbud_vg,nreac) :: budrrg_all
  272. real, dimension(nbudg,nbud_vg,nj) :: budrjg_all
  273. real, dimension(nbudg,nbud_vg,nreacw) :: budrwg_all
  274. real, dimension(nbudg,nbud_vg,nmark) :: budmarkg_all
  275. real, dimension(nbudg,nbud_vg,ntrace) :: buddry_all
  276. real, dimension(nbudg,nbud_vg,ntrace) :: budchem_all
  277. real, dimension(nbudg,nbud_vg,2) :: budeqsam_all
  278. real :: eminox_all
  279. #ifndef without_boundary
  280. real, dimension(nbudg,nbud_vg,ntracet) :: budstratg_all
  281. #endif
  282. #ifdef with_cariolle
  283. real, dimension(nbudg,nbud_vg,ncar) :: budcarg_all
  284. #endif
  285. #ifdef with_m7
  286. real, dimension(nbudg,nbud_vg,ntracet) :: budm7_all
  287. real, dimension(nbudg,nbud_vg,nm7procs) :: budm7proc_all
  288. #endif
  289. #ifdef with_m7
  290. ! Do not change this order. And if you do, look through the M7 code to pprocess (parameter process) where it is written with a fixed paramter. You can, however, change this order if it is made dynamic.
  291. Character(len=8), Dimension(nm7procs), Parameter :: m7procnames = (/'NucN ','NucSU ','Coag11N ','Coag12N ','Coag12SU',&
  292. 'Coag13N ','Coag13SU','Coag14N ','Coag14SU','Coag15N ','Coag15SU','Coag16N ','Coag16SU','Coag17N ','Coag17SU',&
  293. 'Coag22N ','Coag23N ','Coag23SU','Coag23BC','Coag23OC','Coag24N ','Coag24SU','Coag24BC','Coag24OC','Coag25N ',&
  294. 'Coag25BC','Coag25OC','Coag26N ','Coag26SU','Coag26BC','Coag26OC','Coag27N ','Coag27SU','Coag27BC','Coag27OC',&
  295. 'Coag33N ','Coag35N ','Coag35BC','Coag35OC','Coag55N ','Cond1SU ','Cond2SU ','Cond3SU ','Cond4SU ','Cond5SU ',&
  296. 'Cond6SU ','Cond7SU ','Age5N ','Age5BC ','Age5OC ','Age6N ','Age6DU ','Age7N ','Age7DU ','Grow1N ',&
  297. 'Grow1SU ','Grow2N ','Grow2SU ','Grow2BC ','Grow2OC ','Grow3N ','Grow3SU ','Grow3BC ','Grow3OC ','Grow3SS ',&
  298. 'Grow3DU ','Coa12SOA','Coa13SOA','Coa14SOA','Coa15SOA','Coa16SOA','Coa17SOA','Coa23SOA','Coa24SOA','Coa25SOA',&
  299. 'Coa26SOA','Coa27SOA','Coa35SOA','Cond1SOA','Cond2SOA','Cond3SOA','Cond4SOA','Cond5SOA','Age5SOA ','Grow1SOA',&
  300. 'Grow2SOA','Grow3SOA','NucSOA '/)
  301. ! Array for left hand sides, static attribute for the M7 process budget data set.
  302. Character(len=8), Dimension(nm7procs), Parameter :: m7proclhs = (/'void ','H2SO4 ','NUS_N ','NUS_N ','SO4NUS ',&
  303. 'NUS_N ','SO4NUS ','NUS_N ','SO4NUS ','NUS_N ','SO4NUS ','NUS_N ','SO4NUS ','NUS_N ','SO4NUS ',&
  304. 'AIS_N ','AIS_N ','SO4AIS ','BCAIS ','POMAIS ','AIS_N ','SO4AIS ','BCAIS ','POMAIS ','AII_N ',&
  305. 'BCAII ','POMAII ','AIS_N ','SO4AIS ','BCAIS ','POMAIS ','AIS_N ','SO4AIS ','BCAIS ','POMAIS ',&
  306. 'ACS_N ','AII_N ','BCAII ','POMAII ','AII_N ','H2SO4 ','H2SO4 ','H2SO4 ','H2SO4 ','H2SO4 ',&
  307. 'H2SO4 ','H2SO4 ','AII_N ','BCAII ','POMAII ','ACI_N ','DUACI ','COI_N ','DUCOI ','NUS_N ',&
  308. 'SO4NUS ','AIS_N ','SO4AIS ','BCAIS ','POMAIS ','ACS_N ','SO4ACS ','BCACS ','POMACS ','SSACS ',&
  309. 'DUACS ','SOANUS ','SOANUS ','SOANUS ','SOANUS ','SOANUS ','SOANUS ','SOAAIS ','SOAAIS ','SOAAII ',&
  310. 'SOAAIS ','SOAAIS ','SOAAII ','EL+SVOC ','EL+SVOC ','EL+SVOC ','EL+SVOC ','EL+SVOC ','SOAAII ','SOANUS ',&
  311. 'SOAAIS ','SOAACS ','ELVOC '/)
  312. ! Array for right hand sides, static attribute for the M7 process budget data set.
  313. Character(len=8), Dimension(nm7procs), Parameter :: m7procrhs = (/'NUS_N ','SO4NUS ','void ','void ','SO4AIS ',&
  314. 'void ','SO4ACS ','void ','SO4COS ','void ','SO4AIS ','void ','SO4ACS ','void ','SO4COS ',&
  315. 'void ','void ','SO4ACS ','BCACS ','POMACS ','void ','SO4COS ','BCCOS ','POMCOS ','void ',&
  316. 'BCAIS ','POMAIS ','void ','SO4ACS ','BCACS ','POMACS ','void ','SO4COS ','BCCOS ','POMCOS ',&
  317. 'void ','void ','BCACS ','POMACS ','void ','SO4NUS ','SO4AIS ','SO4ACS ','SO4COS ','SO4AIS ',&
  318. 'SO4ACS ','SO4COS ','AIS_N ','BCAIS ','POMAIS ','ACS_N ','DUACS ','COS_N ','DUCOS ','AIS_N ',&
  319. 'SO4AIS ','ACS_N ','SO4ACS ','BCACS ','POMACS ','COS_N ','SO4COS ','BCCOS ','POMCOS ','SSCOS ',&
  320. 'DUCOS ','SOAAIS ','SOAACS ','SOACOS ','SOAAIS ','SOAACS ','SOACOS ','SOAACS ','SOAACS ','SOAAIS ',&
  321. 'SOAACS ','SOACOS ','SOAACS ','SOANUS ','SOAAIS ','SOAACS ','SOACOS ','SOAAII ','SOAAIS ','SOAAIS ',&
  322. 'SOAACS ','SOACOS ','SOANUS '/)
  323. #endif
  324. #endif /* BUDGETS */
  325. ! --- begin --------------------------------
  326. #ifdef with_budgets
  327. eminox_all=0.0
  328. ! Sum up contribution from each proc into root array
  329. call PAR_REDUCE_ELEMENT(budrrg, 'SUM', budrrg_all, status )
  330. do region = 1, nregions
  331. CALL PAR_REDUCE(sum_chemistry(region), 'SUM', sum_chemistry_all(region), status)
  332. IF_NOTOK_RETURN(status=1)
  333. CALL PAR_REDUCE(sum_deposition(region), 'SUM', sum_deposition_all(region), status)
  334. IF_NOTOK_RETURN(status=1)
  335. CALL PAR_REDUCE(sum_wetchem(region), 'SUM', sum_wetchem_all(region), status)
  336. IF_NOTOK_RETURN(status=1)
  337. end do
  338. ! Sum up contribution from each proc into root array for "total LiNOx"
  339. call PAR_REDUCE( eminox, 'SUM', eminox_all, status )
  340. eminox_all = eminox_all*1.e-9 ! kg -> Tg
  341. if ( isRoot ) then
  342. call Init(io, budget_file_global, 'write', status)
  343. IF_NOTOK_RETURN(status=1)
  344. call WriteAttribute(io, 'sum_chemistry' , sum_chemistry_all, status)
  345. IF_NOTOK_RETURN(status=1)
  346. call WriteAttribute(io, 'sum_wetchem' , sum_wetchem_all, status)
  347. IF_NOTOK_RETURN(status=1)
  348. call WriteAttribute(io, 'sum_deposition' , sum_deposition_all, status)
  349. IF_NOTOK_RETURN(status=1)
  350. call WriteAttribute(io, 'total_lightning_nox_emissions_Tg_N' , eminox_all, status)
  351. IF_NOTOK_RETURN(status=1)
  352. call Init(Sds, io, 'budrr', (/nbudg,nbud_vg,nreac/), 'real(8)', status)
  353. IF_NOTOK_RETURN(status=1)
  354. call WriteAttribute(Sds, 'ratnam', ratnam, status)
  355. IF_NOTOK_RETURN(status=1)
  356. call SetDim(Sds, 0, 'nbudg', 'horizontal region', (/(j, j=1,nbudg)/), status)
  357. call SetDim(Sds, 1, 'nbud_vg','vertical layer', (/(j, j=1,nbud_vg)/), status)
  358. call SetDim(Sds, 2, 'nreac', 'reaction number', (/(j, j=1,nreac)/), status)
  359. IF_NOTOK_RETURN(status=1)
  360. call WriteData(Sds, BUDRRG_all, status)
  361. IF_NOTOK_RETURN(status=1)
  362. call Done(Sds, status)
  363. IF_NOTOK_RETURN(status=1)
  364. end if
  365. ! Sum up contribution from each proc into root array
  366. call PAR_REDUCE_ELEMENT(budrjg, 'SUM', budrjg_all, status )
  367. if ( isRoot ) then
  368. call Init(Sds,io, 'budrj',(/nbudg,nbud_vg,nj/), 'real(8)', status)
  369. IF_NOTOK_RETURN(status=1)
  370. call WriteAttribute(Sds, 'jnam', jnam, status)
  371. IF_NOTOK_RETURN(status=1)
  372. call SetDim(Sds, 0, 'nbudg','horizontal region', (/(j, j=1,nbudg)/), status)
  373. call SetDim(Sds, 1, 'nbud_vg','vertical layer', (/(j, j=1,nbud_vg)/), status)
  374. call SetDim(Sds, 2, 'nj','reaction number', (/(j, j=1,nj)/), status)
  375. IF_NOTOK_RETURN(status=1)
  376. call WriteData(Sds, BUDRJG_all, status)
  377. IF_NOTOK_RETURN(status=1)
  378. call Done(Sds, status)
  379. IF_NOTOK_RETURN(status=1)
  380. end if
  381. ! Lets us write down the WET CHEMISTRY
  382. call PAR_REDUCE_ELEMENT(budrwg, 'SUM', budrwg_all, status )
  383. if ( isRoot ) then
  384. call Init(Sds,io, 'budrw',(/nbudg,nbud_vg,nreacw/), 'real(8)', status)
  385. IF_NOTOK_RETURN(status=1)
  386. call WriteAttribute(Sds, 'rwnam', rwnam, status)
  387. IF_NOTOK_RETURN(status=1)
  388. call SetDim(Sds, 0, 'nbudg','horizontal region', (/(j, j=1,nbudg)/), status)
  389. call SetDim(Sds, 1, 'nbud_vg','vertical layer', (/(j, j=1,nbud_vg)/), status)
  390. call SetDim(Sds, 2, 'nreacw','wet reaction number', (/(j, j=1,nreacw)/), status)
  391. IF_NOTOK_RETURN(status=1)
  392. call WriteData(Sds, BUDRWG_all, status)
  393. IF_NOTOK_RETURN(status=1)
  394. call Done(Sds, status)
  395. IF_NOTOK_RETURN(status=1)
  396. end if
  397. ! Sum up contribution from each proc into root array
  398. call PAR_REDUCE_ELEMENT(budmarkg, 'SUM', budmarkg_all, status )
  399. if ( isRoot ) then
  400. call Init(Sds,io, 'budmark',(/nbudg,nbud_vg,nmark/), 'real(8)', status)
  401. IF_NOTOK_RETURN(status=1)
  402. call WriteAttribute(Sds, 'marknam', marknam, status)
  403. IF_NOTOK_RETURN(status=1)
  404. call SetDim(Sds, 0, 'nbudg','horizontal region', (/(j, j=1,nbudg)/), status)
  405. call SetDim(Sds, 1, 'nbud_vg','vertical layer', (/(j, j=1,nbud_vg)/), status)
  406. call SetDim(Sds, 2, 'nmark','marked tracer number', (/(j, j=1,nmark)/), status)
  407. IF_NOTOK_RETURN(status=1)
  408. call WriteData(Sds, BUDMARKG_all, status)
  409. IF_NOTOK_RETURN(status=1)
  410. call Done(Sds, status)
  411. IF_NOTOK_RETURN(status=1)
  412. end if
  413. ! DRYDEP budget
  414. buddry = 0.0
  415. do region=1,nregions
  416. ! aggregates horizontally budget
  417. call Get_DistGrid( dgrid(region), I_STRT=i1, I_STOP=i2, J_STRT=j1, J_STOP=j2 )
  418. do n=1,ntrace
  419. do j=j1,j2
  420. do i=i1,i2
  421. nzone = budg_dat(region)%nzong(i,j)
  422. buddry(nzone,1,n) = buddry(nzone,1,n) + buddep_dat(region)%dry(i,j,n)
  423. end do
  424. end do
  425. end do
  426. call PAR_REDUCE_ELEMENT(buddry, 'SUM', buddry_all, status ) ! contribution from all procs
  427. ! gather and write Non-Horizontally-Aggregated-Budgets
  428. if (NHAB) then
  429. if ( isRoot ) then
  430. allocate( collectb(im(region),jm(region),ntrace ))
  431. else
  432. allocate( collectb(1,1,1))
  433. end if
  434. call GATHER( dgrid(region), buddep_dat(region)%dry, collectb, 0, status)
  435. if(isRoot) then
  436. call Init(Sds,io, 'buddep_dat_dry_'//region_name(region),(/im(region),jm(region),ntrace/), 'real(4)', status)
  437. call SetDim(Sds, 0, 'im_'//region_name(region),'longitude', (/(j, j=1,im(region))/), status)
  438. call SetDim(Sds, 1, 'jm_'//region_name(region),'latitude', (/(j, j=1,jm(region))/), status)
  439. call SetDim(Sds, 2, 'ntrace','tracer index', (/(j, j=1,ntrace)/), status)
  440. IF_NOTOK_RETURN(status=1)
  441. call WriteData(Sds, collectb, status)
  442. IF_NOTOK_RETURN(status=1)
  443. call Done(Sds, status)
  444. IF_NOTOK_RETURN(status=1)
  445. endif
  446. deallocate(collectb)
  447. endif ! NHAB
  448. enddo ! regions
  449. !-- write more aggregated budgets
  450. call PAR_REDUCE_ELEMENT(budchem, 'SUM', budchem_all, status )
  451. call PAR_REDUCE_ELEMENT(budeqsam, 'SUM', budeqsam_all, status )
  452. #ifndef without_boundary
  453. call PAR_REDUCE_ELEMENT(budstratg,'SUM', budstratg_all, status )
  454. #endif
  455. #ifdef with_m7
  456. call PAR_REDUCE_ELEMENT(budm7, 'SUM', budm7_all, status )
  457. call PAR_REDUCE_ELEMENT(budm7proc,'SUM', budm7proc_all, status )
  458. #endif
  459. if(isRoot) then
  460. call Init(Sds,io, 'buddry',(/nbudg,nbud_vg,ntrace/), 'real(8)', status)
  461. IF_NOTOK_RETURN(status=1)
  462. call SetDim(Sds, 0, 'nbudg','horizontal region', (/(j, j=1,nbudg)/), status)
  463. call SetDim(Sds, 1, 'nbud_vg','vertical layer', (/(j, j=1,nbud_vg)/), status)
  464. call SetDim(Sds, 2, 'ntrace','tracer index', (/(j, j=1,ntrace)/), status)
  465. IF_NOTOK_RETURN(status=1)
  466. call WriteData(Sds,buddry_all,status)
  467. IF_NOTOK_RETURN(status=1)
  468. call Done(Sds, status)
  469. IF_NOTOK_RETURN(status=1)
  470. Call Init(Sds,io,"budchem",(/nbudg,nbud_vg,ntrace/),'real(8)',status)
  471. call SetDim(Sds, 0, 'nbudg','horizontal budget', (/(j, j=1,nbudg)/), status)
  472. call SetDim(Sds, 1, 'nbud_vg','vertical budget', (/(j, j=1,nbud_vg)/), status)
  473. call SetDim(Sds, 2, 'ntrace','tracer number', (/(j, j=1,ntrace)/), status)
  474. IF_NOTOK_RETURN(status=1)
  475. call WriteAttribute(Sds, 'comment', 'EBI budget stuffed together. Hopefully it does not explode', status)
  476. ! correct chemistry budget
  477. budchem_result = budchem_all+buddry_all
  478. #ifndef without_emission
  479. budchem_result(:,:,inox) = budchem_result(:,:,inox) - budemig_all(:,:,inox)
  480. #endif
  481. call WriteData(Sds,budchem_result,status)
  482. IF_NOTOK_RETURN(status=1)
  483. call Done(Sds, status)
  484. IF_NOTOK_RETURN(status=1)
  485. Call Init(Sds,io,"budeqsam",(/nbudg,nbud_vg,2/),'real(8)',status)
  486. call SetDim(Sds, 0, 'nbudg','horizontal budget', (/(j, j=1,nbudg)/), status)
  487. call SetDim(Sds, 1, 'nbud_vg','vertical budget', (/(j, j=1,nbud_vg)/), status)
  488. call SetDim(Sds, 2, 'AB_reac','Acid-base reaction number', (/(j, j=1,2)/), status)
  489. IF_NOTOK_RETURN(status=1)
  490. call WriteAttribute(Sds, 'comment', 'EQSAM evil acid base reaction. Positive forms aerosol material.', status)
  491. call WriteData(Sds,budeqsam_all,status)
  492. IF_NOTOK_RETURN(status=1)
  493. call Done(Sds, status)
  494. IF_NOTOK_RETURN(status=1)
  495. #ifndef without_boundary
  496. Call Init(Sds,io,"budstrat",(/nbudg,nbud_vg,ntracet/),'real(8)',status)
  497. call SetDim(Sds, 0, 'nbudg','horizontal budget', (/(j, j=1,nbudg)/), status)
  498. call SetDim(Sds, 1, 'nbud_vg','vertical budget', (/(j, j=1,nbud_vg)/), status)
  499. call SetDim(Sds, 2, 'ntracet','tracer number', (/(j, j=1,ntracet)/), status)
  500. IF_NOTOK_RETURN(status=1)
  501. call WriteAttribute(Sds, 'comment', 'Stratosphere (from boundary.F90)', status)
  502. call WriteData(Sds,budstratg_all,status)
  503. IF_NOTOK_RETURN(status=1)
  504. call Done(Sds, status)
  505. IF_NOTOK_RETURN(status=1)
  506. #endif
  507. endif
  508. #ifdef with_cariolle
  509. call PAR_REDUCE_ELEMENT(budcarg, 'SUM', budcarg_all, status )
  510. if ( isRoot ) then
  511. call Init(Sds,io, 'budcar',(/nbudg,nbud_vg,ncar/), 'real(8)', status)
  512. IF_NOTOK_RETURN(status=1)
  513. call WriteAttribute(Sds, 'carnam', carnam, status)
  514. IF_NOTOK_RETURN(status=1)
  515. call SetDim(Sds, 0, 'nbudg','horizontal region', (/(j, j=1,nbudg)/), status)
  516. call SetDim(Sds, 1, 'nbud_vg','vertical layer', (/(j, j=1,nbud_vg)/), status)
  517. call SetDim(Sds, 2, 'ncar','Cariolle tracer number', (/(j, j=1,ncar)/), status)
  518. IF_NOTOK_RETURN(status=1)
  519. call WriteData(Sds,budcarg_all,status)
  520. IF_NOTOK_RETURN(status=1)
  521. call Done(Sds, status)
  522. IF_NOTOK_RETURN(status=1)
  523. end if
  524. #endif
  525. #ifdef with_m7
  526. if ( isRoot ) then
  527. ! M7 process budget
  528. Call Init(Sds,io,"budm7proc",(/nbudg,nbud_vg,nm7procs/),'real(8)',status)
  529. call SetDim(Sds, 0, 'nbudg','horizontal budget', (/(j, j=1,nbudg)/), status)
  530. call SetDim(Sds, 1, 'nbud_vg','vertical budget', (/(j, j=1,nbud_vg)/), status)
  531. call SetDim(Sds, 2, 'nm7proc','M7 process number', (/(j, j=1,nm7procs)/), status)
  532. IF_NOTOK_RETURN(status=1)
  533. call WriteAttribute(Sds, 'procnames',m7procnames, status)
  534. call WriteAttribute(Sds, 'lefthandsides',m7proclhs, status)
  535. call WriteAttribute(Sds, 'righthandsides',m7procrhs, status)
  536. call WriteData(Sds,budm7proc_all,status)
  537. IF_NOTOK_RETURN(status=1)
  538. call Done(Sds, status)
  539. IF_NOTOK_RETURN(status=1)
  540. ! M7 budget
  541. Call Init(Sds,io,"budm7",(/nbudg,nbud_vg,ntracet/),'real(8)',status)
  542. call SetDim(Sds, 0, 'nbudg','horizontal budget', (/(j, j=1,nbudg)/), status)
  543. call SetDim(Sds, 1, 'nbud_vg','vertical budget', (/(j, j=1,nbud_vg)/), status)
  544. call SetDim(Sds, 2, 'ntracet','tracer number', (/(j, j=1,ntracet)/), status)
  545. IF_NOTOK_RETURN(status=1)
  546. call WriteAttribute(Sds, 'comment', 'M7 budget stuffed together. Hopefully the M7 tracers have now correct budgets', status)
  547. call WriteData(Sds,budm7_all,status)
  548. IF_NOTOK_RETURN(status=1)
  549. call Done(Sds, status)
  550. IF_NOTOK_RETURN(status=1)
  551. endif
  552. #endif
  553. if ( isRoot ) then
  554. call Done(io, status)
  555. IF_NOTOK_RETURN(status=1)
  556. endif
  557. do region = 1, nregions
  558. #ifdef with_m7
  559. deallocate(diag_prod(region)%prod)
  560. #endif
  561. deallocate(buddep_dat(region)%dry)
  562. deallocate(o3p(region)%d3)
  563. deallocate(o3l(region)%d3)
  564. enddo
  565. deallocate(budchem)
  566. deallocate(budeqsam)
  567. #ifdef with_m7
  568. deallocate(budm7proc)
  569. deallocate(budm7)
  570. deallocate(d_nucle)
  571. deallocate(growth1_2)
  572. deallocate(coag_sink_nuc)
  573. deallocate(cond1_soa)
  574. deallocate(cond2_soa)
  575. deallocate(cond3_soa)
  576. deallocate(cond4_soa)
  577. deallocate(cond5_soa)
  578. deallocate(cond1_su)
  579. #endif
  580. #endif /* BUDGETS */
  581. #ifdef with_m7
  582. call free_m7_data
  583. #endif
  584. ! ok
  585. status = 0
  586. END SUBROUTINE CHEMISTRY_DONE
  587. !EOC
  588. !--------------------------------------------------------------------------
  589. ! TM5 !
  590. !--------------------------------------------------------------------------
  591. !BOP
  592. !
  593. ! !IROUTINE: CHEMIE
  594. !
  595. ! !DESCRIPTION: performs chemistry transformations of the tracers
  596. !\\
  597. !\\
  598. ! !INTERFACE:
  599. !
  600. SUBROUTINE CHEMIE( region, tr, status )
  601. !
  602. ! !USES:
  603. !
  604. use GO, only : TDate
  605. use binas, only : Avog, pi, xmair, Rgas_air
  606. use dims, only : itaur, nchem, tref, sec_month, revert, okdebug
  607. use dims, only : dx, xref, dy, yref, im, jm, lm
  608. use dims, only : nregions, ndyn, ndyn_max
  609. use dims, only : xbeg, ybeg, adv_scheme, mlen
  610. use chem_param, only : xmbc, xmpom, xmnacl, xmdust !EV
  611. use chem_param, only : maxtrace, n_extra, iso4, ino3_a, inh4, ih2opart
  612. use chem_param, only : irinc, ino, xmn, inox, ieno, iairm, iairn, ntrace
  613. use chem_param, only : ntracet, fscale, imsa, iacid, iair, ih2o, io2, ih2on
  614. use chem_param, only : iairm,i_temp, i_pres, inh3, ihno3, xmh2o, names, iterp, xmelvoc, xmsvoc
  615. #ifdef with_m7
  616. use chem_param, only : iso4nus, iso4ais, iso4acs, iso4cos, ibcais, ibcacs, ibccos, ibcaii, isoanus, ipomais, ipomacs
  617. use chem_param, only : ipomcos, ipomaii, issacs, isscos, iduacs, iducos, iduaci,iducoi
  618. use chem_param, only : isoaais, isoaacs, isoacos, isoaaii
  619. use chem_param, only : inus_n, xmnumb, iais_n, iacs_n, icos_n, iaii_n, iaci_n, icoi_n
  620. use chem_param, only : nh4no3_factor, nh4no3_density, msa_density
  621. use mo_aero_m7, only : cmr2ram, ram2cmr
  622. use binas, only : rol
  623. use chem_param, only : ielvoc, isvoc
  624. #endif
  625. use chem_param, only : idz
  626. use meteodata, only : m_dat, gph_dat
  627. use reaction_data, only : nreac, aerdens
  628. use chem_rates, only : calrates
  629. use eqsam_param, only : eqsam_v03d
  630. use toolbox, only : dumpfield
  631. use datetime, only : tau2date, get_day
  632. use global_data, only : region_dat, mass_dat, chem_dat
  633. #ifndef without_photolysis
  634. #ifdef with_optics
  635. use photolysis, only : aerosol_info_m7
  636. #else
  637. use photolysis, only : aerosol_info
  638. #endif
  639. use photolysis, only : daysim, get_sza, photo_flux
  640. use photolysis_data
  641. #endif
  642. use ebischeme, only : ebi,diag_prod,nprod
  643. #ifdef with_m7
  644. use ebischeme, only :diag_prod,nprod
  645. #endif
  646. #ifndef without_emission
  647. use dims, only : at, bt
  648. use emission_nox, only : eminox_lightning, nox_emis_3d
  649. use emission_nox, only : nox_emis_3d_bb_app, emission_nox_bb_daily_cycle
  650. #endif
  651. #ifdef with_budgets
  652. use emission_data, only : budemi_dat, sum_emission
  653. use budget_global, only : budg_dat, nzon_vg
  654. #endif
  655. #ifndef without_sedimentation
  656. use sedimentation, only : rh
  657. #endif
  658. #ifdef with_cariolle
  659. use chem_param, only : io3
  660. use chemistry_cariolle, only : l_cariolle, with_trop_force
  661. #endif
  662. ! use tracer_data, only : tracer_print ! for debugging
  663. #ifdef with_m7
  664. use mo_aero, only : nsoa !RM
  665. use mo_aero_m7, only : naermod, nmod, nsol
  666. use m7_data, only : rw_mode, rwd_mode, dens_mode, h2o_mode
  667. !use emission_data, only : oc2pom !factor for conversion of OC mass to POM
  668. #ifdef with_budgets
  669. Use m7_data, only : nm7procs
  670. #endif
  671. !#ifdef with_optics
  672. ! Use Optics, only : nwl, aod_count, AOD, calculate_aop
  673. ! Use chem_param, only : xmso4, xmno3
  674. !#endif
  675. external :: m7
  676. #endif /* M7 */
  677. !
  678. ! !INPUT PARAMETERS:
  679. !
  680. integer, intent(in) :: region
  681. type(TDate), intent(in) :: tr(2)
  682. !
  683. ! !OUTPUT PARAMETERS:
  684. !
  685. integer, intent(out) :: status
  686. !
  687. ! !REVISION HISTORY:
  688. ! 22 Mar 2012 - P. Le Sager - adapted for lon-lat MPI domain decomposition
  689. !
  690. !EOP
  691. !------------------------------------------------------------------------
  692. !BOC
  693. character(len=*), parameter :: rname = mname//'/chemie'
  694. ! --- local ------------------------------
  695. real,dimension(:,:,:),pointer :: m
  696. real,dimension(:,:,:,:),pointer :: rm
  697. #ifdef slopes
  698. real,dimension(:,:,:,:),pointer :: rxm, rym, rzm
  699. #ifdef secmom
  700. real,dimension(:,:,:,:),pointer :: rxxm, rxym, rxzm, ryym, ryzm, rzzm
  701. #endif
  702. #endif
  703. real,dimension(:,:,:,:),pointer :: rmc
  704. real,dimension(:,:,:),pointer :: r_cloud
  705. ! store per level actinic fluxes, photolysis rates, and reaction rates
  706. #ifndef without_photolysis
  707. real,dimension(:,:,:),allocatable :: fact
  708. #endif
  709. real,dimension(:,:,:),allocatable :: rj, rr
  710. ! new photolysis array
  711. real,dimension(:,:,:,:),allocatable :: rj_new
  712. ! store concentrations for chemistry ....
  713. real,dimension(:,:,:),allocatable :: y, y0, yhelp
  714. ! store information that is transferred
  715. ! between chemistry modules
  716. real,dimension(:,:,:),allocatable :: ye
  717. real,dimension(:,:), allocatable :: th, tha, sza, mu, reff
  718. real :: starttime,deltat
  719. ! eqsam:
  720. real,dimension(:,:), allocatable :: yi, yo
  721. ! sad:
  722. real,dimension(:,:,:), allocatable :: sad_aer_out, sad_cld_out, sad_ice_out
  723. #ifdef with_m7
  724. ! m7:
  725. real, dimension(:), pointer :: dxyp
  726. real, dimension(:,:), allocatable :: presm7, rhm7, tempm7, dryairm7 ! meteo parameters
  727. real, dimension(:,:), allocatable :: h2so4m7 ! h2so4 gas phase
  728. real, dimension(:,:,:), allocatable :: aemassm7 ! aerosol mass
  729. real, dimension(:,:,:), allocatable :: aenumm7 ! aerosol number
  730. real, dimension(:,:), allocatable :: elvocm7, svocm7 ! ELVOC & SVOC gas phase !RM
  731. !#ifdef with_optics
  732. ! Integer :: iband
  733. ! real,dimension(:,:,:),allocatable :: Ext ! extinction coefficient [1/m]
  734. ! real,dimension(:,:,:),allocatable :: a ! single-scattering albedo [unitless]
  735. ! real,dimension(:,:,:),allocatable :: g ! asymmetry parameter [unitless]
  736. !#endif
  737. real, dimension(:,:,:), allocatable :: aedensm7 ! aerosol density
  738. real, dimension(:,:,:), allocatable :: aewatm7 ! aerosol water content
  739. real, dimension(:,:,:), allocatable :: aeradm7 ! aerosol radius in equilibrium with water
  740. real, dimension(:,:,:), allocatable :: aeradrm7 ! aerosol dry radius
  741. !
  742. ! To convert units from M7 to TM5 units
  743. real, parameter :: convnumb = 1.e3/xmnumb*Avog ! This value is needed directly
  744. real, parameter :: convsu = 1. ! Nothing happens for sulfate.
  745. real, parameter :: convbc = 1e-12/xmbc*Avog ! BC
  746. !>>> TvN
  747. ! I have the impression that OC in M7 actually refers to POM.
  748. ! doc seems to be the density of POM not OC, and is equal to the density of BC (dbc).
  749. ! Compare with GLOMAP, where the densities of POM and BC are the same (Mann et al., GMD, 2010).
  750. ! This would imply that also the mass of POM and not OC should be used in M7,
  751. ! and that "OC" in the paper by Vignati et al. (JGR, 2004) is actually referring to POM,
  752. ! consistent with the terminology used by Stier et al. (ACP, 2005).
  753. !real, parameter :: convoc = 1e-12/xmpom*Avog*oc2pom ! OC (M7) POM (TM5)
  754. real, parameter :: convoc = 1e-12/xmpom*Avog ! POM (in both M7 and TM5)
  755. !<<< TvN
  756. !RM
  757. real, parameter :: convelvoc = 1e-12/xmelvoc*Avog ! ELVOC
  758. real, parameter :: convsvoc = 1e-12/xmsvoc*Avog ! S/LVOC
  759. real, parameter :: convss = 1e-12/xmnacl*Avog ! SS
  760. real, parameter :: convdu = 1e-12/xmdust*Avog ! DU
  761. #ifdef with_budgets
  762. real,dimension(:,:,:), allocatable :: processm7 ! M7 processes in M7 units.
  763. ! Array that convertts M7 processes from M7 to TM5 units.
  764. real, dimension(nm7procs), parameter :: processm7totm5 = (/ &
  765. ! 1 2 3 4 5 6 7 8 9 10
  766. convnumb,convsu ,convnumb,convnumb,convsu ,convnumb,convsu ,convnumb,convsu,convnumb,& ! 0?
  767. convsu ,convnumb,convsu ,convnumb,convsu ,convnumb,convnumb,convsu ,convbc,convoc ,& ! 1?
  768. convnumb,convsu ,convbc ,convoc ,convnumb,convbc ,convoc ,convnumb,convsu,convbc ,& ! 2?
  769. convoc ,convnumb,convsu ,convbc ,convoc ,convnumb,convnumb,convbc ,convoc,convnumb,& ! 3?
  770. convsu ,convsu ,convsu ,convsu ,convsu ,convsu ,convsu ,convnumb,convbc,convoc ,& ! 4?
  771. convnumb,convdu ,convnumb,convdu ,convnumb,convsu ,convnumb,convsu ,convbc,convoc ,& ! 5?
  772. convnumb,convsu ,convbc ,convoc ,convss ,convdu ,convoc ,convoc ,convoc,convoc ,& ! 6?
  773. convoc ,convoc ,convoc ,convoc ,convoc ,convoc ,convoc ,convoc ,convoc,convoc ,& ! 7?
  774. convoc ,convoc ,convoc ,convoc ,convoc ,convoc ,convoc ,convoc/) ! 8?
  775. #endif
  776. real :: dryvol_m7, vol_nh4no3, vol_msa, vol_h2o
  777. real :: number_conc
  778. integer :: imode
  779. #endif /* M7 */
  780. real :: dtime, gmt, dxx, dyy, lat, lon
  781. real :: px, skf, x, month2dt
  782. integer :: day, level, nzone, nzone_v
  783. integer,dimension(6) :: idater, idate_temp
  784. integer :: i, j, l, n
  785. integer :: ispec
  786. integer :: imax, nca, nco, iloop
  787. integer :: eqsam_option
  788. real :: dry_aerosol_mass, dry_aerosol_volume
  789. real :: water_aerosol_mass, water_aerosol_volume, ccs, s
  790. integer :: i1, i2, j1, j2, lmr, is3, ie3, klm
  791. ! --- begin ---------------------------------
  792. if ( okdebug ) write (*,*) 'start of chemistry'
  793. m => m_dat (region)%data
  794. rmc => chem_dat(region)%rm
  795. rm => mass_dat(region)%rm
  796. #ifdef slopes
  797. rxm => mass_dat(region)%rxm
  798. rym => mass_dat(region)%rym
  799. rzm => mass_dat(region)%rzm
  800. #ifdef secmom
  801. rxxm => mass_dat(region)%rxxm
  802. rxym => mass_dat(region)%rxym
  803. rxzm => mass_dat(region)%rxzm
  804. ryym => mass_dat(region)%ryym
  805. ryzm => mass_dat(region)%ryzm
  806. rzzm => mass_dat(region)%rzzm
  807. #endif
  808. #endif
  809. #ifdef with_m7
  810. dxyp => region_dat(region)%dxyp
  811. #endif
  812. r_cloud => phot_dat(region)%cloud_reff
  813. ! ------- Time stuff
  814. call tau2date(itaur(region), idater) ! current time
  815. dtime = nchem/(2*tref(region)) ! time step
  816. month2dt = dtime/sec_month ! conversion to emission per timestep
  817. call tau2date(itaur(region)+revert*nint(dtime*0.5),idate_temp) ! get date @ halfway interval.
  818. gmt = idate_temp(4) + idate_temp(5)/60.0 + idate_temp(6)/3600.0 ! GMT in hours
  819. day = get_day(idate_temp(2),idate_temp(3),mlen)
  820. if ( okdebug ) then
  821. write(gol,*)'chemistry: region ',region, ' at date: ',idater,' with time step ',dtime
  822. call goPr
  823. write(gol,*)'chemistry: day, gmt, date@halfway interval ', day, gmt, idate_temp
  824. call goPr
  825. end if
  826. ! ------- Resolution and bounds
  827. dxx = dx/xref(region) ! gridsize at current region
  828. dyy = dy/yref(region) ! gridsize at current region
  829. call Get_DistGrid( dgrid(region), I_STRT=i1, I_STOP=i2, J_STRT=j1, J_STOP=j2 )
  830. lmr = lm(region)
  831. is3=(i1-1)*3+1 ! to cover three times oversampled
  832. ie3=i2*3
  833. ! allocate(tha (is3:ie3,j1:j2))
  834. allocate(tha (im(region)*3,j1:j2))
  835. allocate(sza (i1:i2, j1:j2 ))
  836. allocate(mu (i1:i2, j1:j2 ))
  837. allocate(reff (i1:i2, j1:j2 ))
  838. allocate(fact (i1:i2, j1:j2, nbands_trop ))
  839. allocate(rj (i1:i2, j1:j2, nj ))
  840. allocate(rr (i1:i2, j1:j2, nreac ))
  841. allocate(rj_new(i1:i2, j1:j2, lmr, nj ))
  842. allocate(y (i1:i2, j1:j2, maxtrace ))
  843. allocate(y0 (i1:i2, j1:j2, maxtrace ))
  844. allocate(yhelp (i1:i2, j1:j2, ntrace ))
  845. allocate(ye (i1:i2, j1:j2, n_extra )) ! Eqsam
  846. allocate(sad_cld_out(i1:i2, j1:j2, lmr )) ; sad_cld_out = 0.
  847. allocate(sad_ice_out(i1:i2, j1:j2, lmr )) ; sad_ice_out = 0.
  848. allocate(sad_aer_out(i1:i2, j1:j2, lmr )) ; sad_aer_out = 0.
  849. imax = (i2-i1+1)*(j2-j1+1) !nb of grid box per layer (was im(region)*jm(region))
  850. nca = 11
  851. nco = 37 ! was 36, JadB added one for the water associated with just the nitrate.
  852. allocate(yi(imax,nca)) ; yi = 0.0
  853. allocate(yo(imax,nco)) ; yo = 0.0
  854. #ifdef with_m7
  855. allocate( presm7 (imax, 1 ))
  856. allocate( rhm7 (imax, 1 ))
  857. allocate( tempm7 (imax, 1 ))
  858. allocate( dryairm7(imax, 1 ))
  859. allocate( h2so4m7 (imax, 1 ))
  860. allocate( aemassm7(imax, 1, naermod))
  861. allocate( aenumm7 (imax, 1, nmod ))
  862. allocate( aedensm7(imax,1,nmod))
  863. allocate( aewatm7 (imax,1,nmod))
  864. allocate( aeradm7 (imax,1,nmod))
  865. allocate( aeradrm7(imax,1,nsol))
  866. allocate( elvocm7 (imax, 1 )) !RM
  867. allocate( svocm7 (imax, 1 )) !RM
  868. !PLS debug
  869. presm7 =0.
  870. rhm7 =0.
  871. tempm7 =0.
  872. dryairm7=0.
  873. h2so4m7 =0.
  874. aemassm7=0.
  875. aenumm7 =0.
  876. aedensm7=0.
  877. aewatm7 =0.
  878. aeradm7 =0.
  879. aeradrm7=0.
  880. elvocm7=0. !RM
  881. svocm7=0. !RM
  882. #ifdef with_budgets
  883. allocate(processm7(imax,1,nm7procs))
  884. #endif
  885. #endif
  886. tha = 0.0
  887. sza = 0.0
  888. mu = 0.0
  889. fact = 0.0
  890. rj = 0.0
  891. rr = 0.0
  892. rj_new = 0.0
  893. y = 0.0
  894. y0 = 0.0
  895. ye = 0.0
  896. ! alternative calculation of zenith angle with higher sampling (time and space).
  897. ! yields factor of two lower angles in the tropics!
  898. ! Difference is resolution dependent. The coarser the larger the differences
  899. starttime = real(idate_temp(4)) + real(idate_temp(5))/60.0 + real(idate_temp(6))/3600.
  900. deltat = nchem/3600.0
  901. call daysim(region, day, is3, i1,i2,j1, j2, tha)
  902. call get_sza(region, i1, j1, i2, j2, starttime, deltat, tha, sza)
  903. ! ascribe mu
  904. do j=j1,j2
  905. do i=i1,i2
  906. mu(i,j)=max(1.e-5,COS(sza(i,j)*pi/180.))
  907. enddo
  908. enddo
  909. #ifdef with_optics
  910. call aerosol_info_m7(region, status)
  911. IF_NOTOK_RETURN(status=1)
  912. #else
  913. call aerosol_info(region)
  914. #endif
  915. ! calculate actinic flux outside level loop for online fluxes
  916. call photo_flux(region, i1, j1, sza, rj_new)
  917. ! scale NOx BMB if needed
  918. #ifndef without_emission
  919. call emission_nox_bb_daily_cycle(status)
  920. IF_NOTOK_RETURN(status=1)
  921. #endif
  922. ! compute global LiNox budget
  923. #ifdef with_budgets
  924. #ifndef without_emission
  925. #ifndef without_convection
  926. eminox=eminox+sum(eminox_lightning(region)%d3)*month2dt ! kg [N] month-1 * dt /(sec_month) = kg [N]
  927. #endif
  928. #endif
  929. #endif
  930. LEVS: do level = 1, lmr
  931. rj(:,:,:) = rj_new (:,:,level,:)
  932. reff(:,:) = r_cloud(:,:,level)
  933. #ifdef with_budgets
  934. nzone_v=nzon_vg(level)
  935. #endif
  936. ! get/calculate all the fields needed in chemistry
  937. call GET_EXTRA( region, level, ye, i1, j1)
  938. ! calculate the rinc: relative radius growth of aerosols due to water
  939. ! Eqsam wants to calculate aerosol radii
  940. ! irinc is used by chem_rates in calchet2
  941. ! calchet2 is used by no one
  942. ! So, this part is not so important
  943. ! -----------------------------------
  944. ! To get this code back, take a stone-age copy of chemistry.F90
  945. ! But, to prevent even more errors.
  946. ! -----------------------------------
  947. ye(:,:,irinc) = 1.0
  948. call CALRATES(region, level, i1, j1, rj, rr, reff, ye, dtime, &
  949. sad_cld_out(:,:,level), sad_ice_out(:,:,level), sad_aer_out(:,:,level), status) ! also returns rh in ye
  950. IF_ERROR_RETURN(status=1)
  951. ! CALCULATE NOX EMISSIONS
  952. ! ---------------------------
  953. do j=j1,j2
  954. do i=i1,i2
  955. ! nox emis in this cell; init to zero:
  956. x = 0.0 ! kg(N)/month
  957. #ifndef without_emission
  958. ! add total 3d emissions if any
  959. if(associated(nox_emis_3d(region)%d3)) then
  960. x = x + nox_emis_3d(region)%d3(i,j,level)
  961. end if
  962. if(associated(nox_emis_3d_bb_app(region)%d3)) then
  963. x = x + nox_emis_3d_bb_app(region)%d3(i,j,level)
  964. end if
  965. #ifndef without_convection
  966. ! add lightning emissions:
  967. x = x + eminox_lightning(region)%d3(i,j,level)
  968. #endif
  969. #endif /* EMISS */
  970. ! emission budget (since nox emissions are added in chemistry)
  971. #ifdef with_budgets
  972. #ifndef without_emission
  973. budemi_dat(region)%emi(i,j,nzone_v,inox) = &
  974. budemi_dat(region)%emi(i,j,nzone_v,inox) + x/xmn*month2dt*1e3 ! g
  975. if (inox == 1) sum_emission(region) = sum_emission(region) + x*month2dt ! kg N
  976. #endif
  977. #endif
  978. ! put emissions in the units #/s/cm3 used in chemistry
  979. ye(i,j,ieno) = x/ye(i,j,iairm)*ye(i,j,iairn)* &
  980. (xmair/xmn)/sec_month !kg N/month ----> #(NO)/cm3/s
  981. end do
  982. end do
  983. ! INITIAL CONCENTRATIONS
  984. ! ---------------------------
  985. do n=1,ntracet
  986. do j=j1,j2
  987. do i=i1,i2
  988. y(i,j,n) = rm(i,j,level,n)/ye(i,j,iairm)*ye(i,j,iairn)* fscale(n) !kg ----> #/cm3
  989. end do
  990. end do
  991. end do
  992. do n=ntracet+1,ntrace
  993. do j=j1,j2
  994. do i=i1,i2
  995. ! remember nontransported tracers are in rmc
  996. y(i,j,n) =rmc(i,j,level,n)/ye(i,j,iairm)*ye(i,j,iairn)* fscale(n) !kg ----> #/cm3
  997. end do
  998. end do
  999. end do
  1000. ! FILL EXTRA SPECIES : (from ntrace+1 to maxtrace)
  1001. ! ---------------------------
  1002. do j=j1,j2
  1003. do i=i1,i2
  1004. ! these are in #/cm3 and used in budget....should be in y....
  1005. y(i,j,iair) = ye(i,j,iairn)
  1006. y(i,j,ih2o) = ye(i,j,ih2on)
  1007. ! introduced to calculate correct budget for JO2
  1008. y(i,j,io2) = 1.
  1009. #ifdef with_m7
  1010. !RM
  1011. y(i,j,ielvoc)=0.
  1012. y(i,j,isvoc)=0.
  1013. #endif
  1014. end do
  1015. end do
  1016. ! BACKUP INIT CONCENTRATIONS
  1017. ! ---------------------------
  1018. y0 = y
  1019. do klm=1,ntrace
  1020. yhelp(:,:,klm) = y(:,:,klm)*ye(:,:,iairm)*1000./xmair/y(:,:,iair)
  1021. end do
  1022. ! EBI
  1023. ! ---------------------------
  1024. CALL EBI( region, level, i1, j1, rj, rr, y, ye, status)
  1025. IF_ERROR_RETURN(status=1)
  1026. ! EBI scheme budgets
  1027. #ifdef with_budgets
  1028. do j=j1,j2
  1029. do i=i1,i2
  1030. nzone=budg_dat(region)%nzong(i,j) ! global budget zone
  1031. budchem(nzone,nzone_v,1:ntrace) = budchem(nzone,nzone_v,1:ntrace) + &
  1032. y(i,j,1:ntrace)*ye(i,j,iairm)*1000./xmair/y(i,j,iair)-yhelp(i,j,:)
  1033. !production data
  1034. !d_gas_prod_so4=1
  1035. !d_liq_prod_so4=2
  1036. !d_prod_elvoc=3
  1037. !d_prod_svoc=4
  1038. ! cannot be done here, or would have also the existing so4-> ebischeme
  1039. !diag_prod(region)%prod(i,j,1)=y(i,j,iso4)
  1040. !diag_prod(region)%prod(i,j,1)=y(i,j,ielvoc)
  1041. !=y(i,j,n)/y(i,j,iair)*ye(i,j,iairm)/fscale(n)
  1042. ! y in #cm-3
  1043. ! y /dtime -> #cm-3s-1 : /y(air)-> #/#(air) s-1: *y(airm)/xmair*xmelvoc -> kg(elvoc) s-1
  1044. #ifdef with_m7
  1045. diag_prod(region)%prod(i,j,level,3)=diag_prod(region)%prod(i,j,level,3)+y(i,j,ielvoc)/y(i,j,iair)*ye(i,j,iairm)/xmair*xmelvoc
  1046. diag_prod(region)%prod(i,j,level,4)=diag_prod(region)%prod(i,j,level,4)+y(i,j,isvoc)/y(i,j,iair)*ye(i,j,iairm)/xmair*xmsvoc
  1047. #endif
  1048. end do
  1049. end do
  1050. #endif
  1051. !--- Begin of M7: ------------------------------------------------------
  1052. #ifdef with_m7
  1053. ! M7
  1054. iloop = 0
  1055. do j=j1,j2
  1056. do i=i1,i2
  1057. #ifdef with_budgets
  1058. ! For the M7 budgets, we first subtract the old concentrations.
  1059. nzone=budg_dat(region)%nzong(i,j) ! global budget zone
  1060. budm7(nzone,nzone_v,:)=budm7(nzone,nzone_v,:)-y(i,j,1:ntracet)*ye(i,j,iairm)*1000./xmair/y(i,j,iair)
  1061. #endif
  1062. iloop = iloop + 1
  1063. ! meteo parameters
  1064. presm7 (iloop,1) = ye(i,j,i_pres) ! Pa
  1065. rhm7 (iloop,1) = rh(region)%d3(i,j,level) ! fraction, in cloud free part!
  1066. tempm7 (iloop,1) = ye(i,j,i_temp) ! K
  1067. dryairm7(iloop,1) = presm7(iloop,1)/(Rgas_air*tempm7(iloop,1)) ! density of dry air
  1068. ! H2SO4 gas concentrations molecule/cm3
  1069. h2so4m7(iloop,1) = y(i,j,iso4)/convsu
  1070. ! molecule/cm3 ----> molecules/cm3
  1071. if (nsoa==2) then
  1072. !RM ELVOC+SVOC
  1073. elvocm7(iloop,1) = y(i,j,ielvoc)/convelvoc
  1074. svocm7(iloop,1) = y(i,j,isvoc)/convsvoc
  1075. end if
  1076. ! sulphate mass in the 4 soluble modes molecule/cm3
  1077. aemassm7(iloop,1,1) = y(i,j,iso4nus)/convsu
  1078. aemassm7(iloop,1,2) = y(i,j,iso4ais)/convsu
  1079. aemassm7(iloop,1,3) = y(i,j,iso4acs)/convsu
  1080. aemassm7(iloop,1,4) = y(i,j,iso4cos)/convsu
  1081. ! molecule/cm3 ----> molecules/cm3
  1082. ! BC mass in the 3 soluble modes and 1 insoluble
  1083. aemassm7(iloop,1,5) = y(i,j,ibcais)/convbc
  1084. aemassm7(iloop,1,6) = y(i,j,ibcacs)/convbc
  1085. aemassm7(iloop,1,7) = y(i,j,ibccos)/convbc
  1086. aemassm7(iloop,1,8) = y(i,j,ibcaii)/convbc
  1087. ! molecule/cm3 -----> ug/m3
  1088. ! was: POM (tm5) OC (m7) mass in the 3 soluble modes and 1 insoluble
  1089. ! POM mass in the 3 soluble modes and 1 insoluble
  1090. aemassm7(iloop,1,9) = y(i,j,ipomais)/convoc
  1091. aemassm7(iloop,1,10) = y(i,j,ipomacs)/convoc
  1092. aemassm7(iloop,1,11) = y(i,j,ipomcos)/convoc
  1093. aemassm7(iloop,1,12) = y(i,j,ipomaii)/convoc
  1094. ! molecule/cm3 -----> ug/m3
  1095. ! SOA mass in the 3 soluble modes and 1 insoluble
  1096. aemassm7(iloop,1,19) = y(i,j,isoanus)/convoc
  1097. aemassm7(iloop,1,20) = y(i,j,isoaais)/convoc
  1098. aemassm7(iloop,1,21) = y(i,j,isoaacs)/convoc
  1099. aemassm7(iloop,1,22) = y(i,j,isoacos)/convoc
  1100. aemassm7(iloop,1,23) = y(i,j,isoaaii)/convoc
  1101. ! molecule/cm3 -----> ug/m3
  1102. ! SS mass in the 2 soluble modes
  1103. aemassm7(iloop,1,13) = y(i,j,issacs)/convss
  1104. aemassm7(iloop,1,14) = y(i,j,isscos)/convss
  1105. ! molecule/cm3 -----> ug/m3
  1106. ! DUST mass in the 2 soluble modes and 2 insoluble
  1107. aemassm7(iloop,1,15) = y(i,j,iduacs)/convdu
  1108. aemassm7(iloop,1,16) = y(i,j,iducos)/convdu
  1109. aemassm7(iloop,1,17) = y(i,j,iduaci)/convdu
  1110. aemassm7(iloop,1,18) = y(i,j,iducoi)/convdu
  1111. ! molecule/cm3 -----> ug/m3
  1112. ! number concentrations of the 7 modes
  1113. aenumm7(iloop,1,1) = y(i,j,inus_n)/convnumb
  1114. aenumm7(iloop,1,2) = y(i,j,iais_n)/convnumb
  1115. aenumm7(iloop,1,3) = y(i,j,iacs_n)/convnumb
  1116. aenumm7(iloop,1,4) = y(i,j,icos_n)/convnumb
  1117. aenumm7(iloop,1,5) = y(i,j,iaii_n)/convnumb
  1118. aenumm7(iloop,1,6) = y(i,j,iaci_n)/convnumb
  1119. aenumm7(iloop,1,7) = y(i,j,icoi_n)/convnumb
  1120. !
  1121. ! molecule/cm3 -----> particle/cm3:
  1122. ! 1 # air
  1123. !rm in total aerosol number (#aer) ----> #aer * ------ * ------ is y
  1124. ! kg(air) cm-3
  1125. !#aer # air 1
  1126. !---- * ------- ----> 1 kg(air) = 10^3 g air = 10^3 * ----- * Avog
  1127. !cm-3 kg(air) xmair
  1128. !
  1129. end do
  1130. end do
  1131. ! The M7 processes will be calculated when budgets are used. The extra
  1132. ! argument will appear when the compiler flag with_budgets is set.
  1133. #ifdef with_budgets
  1134. call M7(iloop, imax, 1, & ! TM5 indices
  1135. presm7, rhm7, tempm7, & ! " thermodynamics
  1136. h2so4m7, elvocm7, svocm7, aemassm7, aenumm7, & ! M7 tracers
  1137. aedensm7, aewatm7, aeradm7, aeradrm7, dtime, & ! M7 aerosol propertis
  1138. processm7) ! The extra argument, in which the rates of each process is stored in M7 units.
  1139. #else
  1140. call M7(iloop, imax, 1, & ! TM5 indices
  1141. presm7, rhm7, tempm7, & ! " thermodynamics
  1142. h2so4m7, elvocm7, svocm7, aemassm7, aenumm7, & ! M7 tracers
  1143. aedensm7, aewatm7, aeradm7, aeradrm7, dtime) ! M7 aerosol propertis
  1144. #endif
  1145. iloop = 0
  1146. do j=j1,j2
  1147. do i=i1,i2
  1148. iloop = iloop + 1
  1149. ! H2SO4 gas concentrations in molecule/cm3
  1150. y(i,j,iso4) = h2so4m7(iloop,1)*convsu
  1151. ! molecule/cm3 ----> molecule/cm3
  1152. if (nsoa==2)then
  1153. !RM ELVOC+SVOC
  1154. y(i,j,ielvoc) = elvocm7(iloop,1)*convelvoc
  1155. y(i,j,isvoc) = svocm7(iloop,1)*convsvoc
  1156. end if
  1157. ! sulphate mass in the 4 soluble modes
  1158. y(i,j,iso4nus) = aemassm7(iloop,1,1)*convsu
  1159. y(i,j,iso4ais) = aemassm7(iloop,1,2)*convsu
  1160. y(i,j,iso4acs) = aemassm7(iloop,1,3)*convsu
  1161. y(i,j,iso4cos) = aemassm7(iloop,1,4)*convsu
  1162. ! molecule/cm3 ----> molecule/cm3
  1163. ! BC mass in the 3 soluble modes and 1 insoluble
  1164. y(i,j,ibcais) = aemassm7(iloop,1,5)*convbc
  1165. y(i,j,ibcacs) = aemassm7(iloop,1,6)*convbc
  1166. y(i,j,ibccos) = aemassm7(iloop,1,7)*convbc
  1167. y(i,j,ibcaii) = aemassm7(iloop,1,8)*convbc
  1168. ! ug/m3 ----> molecule/cm3
  1169. ! was: POM (tm5) OC (m7) mass in the 3 soluble modes and 1 insoluble
  1170. ! POM mass in the 3 soluble modes and 1 insoluble
  1171. y(i,j,ipomais) = aemassm7(iloop,1,9)*convoc
  1172. y(i,j,ipomacs) = aemassm7(iloop,1,10)*convoc
  1173. y(i,j,ipomcos) = aemassm7(iloop,1,11)*convoc
  1174. y(i,j,ipomaii) = aemassm7(iloop,1,12)*convoc
  1175. ! ug/m3 ----> molecule/cm3
  1176. ! POM mass in the 3 soluble modes and 1 insoluble
  1177. y(i,j,isoanus) = aemassm7(iloop,1,19)*convoc
  1178. y(i,j,isoaais) = aemassm7(iloop,1,20)*convoc
  1179. y(i,j,isoaacs) = aemassm7(iloop,1,21)*convoc
  1180. y(i,j,isoacos) = aemassm7(iloop,1,22)*convoc
  1181. y(i,j,isoaaii) = aemassm7(iloop,1,23)*convoc
  1182. ! ug/m3 ----> molecule/cm3
  1183. ! SS mass in the 2 soluble modes
  1184. y(i,j,issacs) = aemassm7(iloop,1,13)*convss
  1185. y(i,j,isscos) = aemassm7(iloop,1,14)*convss
  1186. ! ug/m3 ----> molecule/cm3
  1187. ! DUST mass in the 2 soluble modes and 2 insoluble
  1188. y(i,j,iduacs) = aemassm7(iloop,1,15)*convdu
  1189. y(i,j,iducos) = aemassm7(iloop,1,16)*convdu
  1190. y(i,j,iduaci) = aemassm7(iloop,1,17)*convdu
  1191. y(i,j,iducoi) = aemassm7(iloop,1,18)*convdu
  1192. ! ug/m3 ----> molecule/cm3
  1193. ! number concentrations of the 7 modes
  1194. y(i,j,inus_n) = aenumm7(iloop,1,1)*convnumb
  1195. y(i,j,iais_n) = aenumm7(iloop,1,2)*convnumb
  1196. y(i,j,iacs_n) = aenumm7(iloop,1,3)*convnumb
  1197. y(i,j,icos_n) = aenumm7(iloop,1,4)*convnumb
  1198. y(i,j,iaii_n) = aenumm7(iloop,1,5)*convnumb
  1199. y(i,j,iaci_n) = aenumm7(iloop,1,6)*convnumb
  1200. y(i,j,icoi_n) = aenumm7(iloop,1,7)*convnumb
  1201. !number of particles/cm3 ----> molecule/cm3 (see comment above)
  1202. #ifdef with_budgets
  1203. ! For the M7 budgets, we now add the new concentrations.
  1204. nzone=budg_dat(region)%nzong(i,j) ! global budget zone
  1205. budm7(nzone,nzone_v,:)=budm7(nzone,nzone_v,:)+y(i,j,1:ntracet)*ye(i,j,iairm)*1000./xmair/y(i,j,iair)
  1206. budm7proc(nzone,nzone_v,:)=budm7proc(nzone,nzone_v,:)+processm7(iloop,1,:)*processm7totm5*ye(i,j,iairm)*&
  1207. 1000./xmair/y(i,j,iair) ! processm7totm5 is a 88-element array with unit conversion factors.
  1208. !nucleation in processm7 is saved as #/cm3 within one timestep
  1209. d_nucle(i,j,level)= d_nucle(i,j,level)+processm7(iloop,1,1)
  1210. m_nucle_su(i,j,level)= m_nucle_su(i,j,level)+processm7(iloop,1,2)
  1211. m_nucle_soa(i,j,level)= m_nucle_soa(i,j,level)+processm7(iloop,1,88)
  1212. growth1_2(i,j,level)= growth1_2(i,j,level)+processm7(iloop,1,55)
  1213. coag_sink_nuc(i,j,level)=coag_sink_nuc(i,j,level)+(processm7(iloop,1,3)+processm7(iloop,1,4)+processm7(iloop,1,6)&
  1214. +processm7(iloop,1,8)+processm7(iloop,1,10)+processm7(iloop,1,12)&
  1215. +processm7(iloop,1,14))
  1216. cond1_soa(i,j,level)= cond1_soa(i,j,level)+processm7(iloop,1,79)
  1217. cond2_soa(i,j,level)= cond2_soa(i,j,level)+processm7(iloop,1,80)
  1218. cond3_soa(i,j,level)= cond3_soa(i,j,level)+processm7(iloop,1,81)
  1219. cond4_soa(i,j,level)= cond4_soa(i,j,level)+processm7(iloop,1,82)
  1220. cond5_soa(i,j,level)= cond5_soa(i,j,level)+processm7(iloop,1,83)
  1221. cond1_su(i,j,level)= cond1_su(i,j,level)+processm7(iloop,1,41)
  1222. !1000./xmair/y(i,j,iair)
  1223. #endif
  1224. ! output m7
  1225. ! kgH2O/m3 ---> kg water per gridbox
  1226. do imode=1,nsol
  1227. h2o_mode(region,imode)%d3(i,j,level) = aewatm7(iloop,1,imode) *dxyp(j)*ye(i,j,idz)
  1228. rwd_mode (region,imode)%d3(i,j,level) = aeradrm7(iloop,1,imode)*1e-2 ! from cm to meter
  1229. end Do
  1230. do imode=1,nmod
  1231. dens_mode(region,imode)%d3(i,j,level) = aedensm7(iloop,1,imode)*1e3 ! from g/cm^3 --> kg/m^3
  1232. rw_mode (region,imode)%d3(i,j,level) = aeradm7(iloop,1,imode)*1e-2 ! from cm to meter
  1233. end do
  1234. end do
  1235. end do
  1236. #endif /* M7 */
  1237. ! ====================== EQSAM ! Using HNO3 / NO3_A, NH4 / NH2 and SO4.
  1238. yi = 0.0
  1239. yo = 0.0
  1240. iloop = 0
  1241. do j=j1,j2
  1242. do i=i1,i2
  1243. iloop = iloop + 1
  1244. yi(iloop,1)=ye(i,j,i_temp) ! K
  1245. #ifndef without_sedimentation
  1246. #ifdef with_m7
  1247. s = rh(region)%d3(i,j,level) ! in cloud free part!
  1248. #else
  1249. s = 0.0
  1250. #endif
  1251. #else
  1252. s = 0.0
  1253. #endif
  1254. yi(iloop,2)=max(0.001,min(0.95,s))
  1255. yi(iloop,11)=ye(i,j,i_pres)/100. ! Pa -> hPa
  1256. ! yi(iloop,6)= c(nv2,ina)/Avog*1.e12
  1257. yi(iloop,6)=0.
  1258. #ifdef with_m7
  1259. yi(iloop,4)=(y(i,j,iso4)+y(i,j,iso4nus)+y(i,j,iso4ais)+y(i,j,iso4acs)+y(i,j,iso4cos))/Avog*1.e12 ! molec/cm3 -> umol/m3
  1260. #else
  1261. yi(iloop,4)=(y(i,j,iso4))/Avog*1.e12 ! molec/cm3 -> umol/m3
  1262. #endif
  1263. yi(iloop,3)=(y(i,j,inh3)+y(i,j,inh4))/Avog*1.e12
  1264. yi(iloop,5)=(y(i,j,ihno3)+y(i,j,ino3_a))/Avog*1.e12
  1265. !yi(iloop,7)=(c(nv2,ihcl)+c(nv2,icl))/Avog*1.e12
  1266. yi(iloop,7)=0.
  1267. !yi(iloop,8)=c(nv2,ik)/Avog*1.e12
  1268. yi(iloop,8)=0.
  1269. !yi(iloop,9)=c(nv2,ica)/Avog*1.e12
  1270. yi(iloop,9)=0.
  1271. !yi(iloop,10)=c(nv2,img)/Avog*1.e12
  1272. yi(iloop,10)=0.
  1273. end do
  1274. end do
  1275. eqsam_option = 1
  1276. call EQSAM_V03D( yi, yo, nca, nco, eqsam_option, iloop, imax, 0, (/0,0,0,0,0,0/))
  1277. iloop = 0
  1278. do j=j1,j2
  1279. do i=i1,i2
  1280. iloop = iloop + 1
  1281. #ifdef with_budgets
  1282. nzone=budg_dat(region)%nzong(i,j) ! global budget zone
  1283. budeqsam(nzone,nzone_v,1) = budeqsam(nzone,nzone_v,1) + &
  1284. (yo(iloop,19)*Avog*1.e-12-y(i,j,inh4)) *ye(i,j,iairm)*1000./xmair/y(i,j,iair) ! Ammonium
  1285. budeqsam(nzone,nzone_v,2) = budeqsam(nzone,nzone_v,2) + &
  1286. (yo(iloop,20)*Avog*1.e-12-y(i,j,ino3_a))*ye(i,j,iairm)*1000./xmair/y(i,j,iair) ! Nitrate
  1287. #endif
  1288. y(i,j,ihno3) = yo(iloop, 9)*Avog*1.e-12 ! umol/m3 -> molec/cm3
  1289. y(i,j,inh3) = yo(iloop,10)*Avog*1.e-12 ! umol/m3 -> molec/cm3
  1290. y(i,j,inh4) = yo(iloop,19)*Avog*1.e-12 ! umol/m3 -> molec/cm3
  1291. y(i,j,ino3_a) = yo(iloop,20)*Avog*1.e-12 ! umol/m3 -> molec/cm3
  1292. ! Sulfuric acid is unchanged:
  1293. ! y(i,j,iso4) = yo(iloop,21)*Avog*1.e-12
  1294. ! The NO3_A should also get some water. M7 takes the water for the
  1295. ! anoins: SO4-- and Cl- (Sea Salt). Cations are neglected.
  1296. ! Just the NO3- water is used apart from the M7 water.
  1297. ! Ignore the direct eqsam water
  1298. ! ug/m3 -> molec/cm3
  1299. ! y(i,j,ih2opart) = yo(iloop,12)*Avog*1.e-12/xmh2o
  1300. #ifdef with_m7
  1301. ! The water associated with nitrate aerosol is put into
  1302. ! the soluble accumulation mode.
  1303. h2o_mode(region,3)%d3(i,j,level) = h2o_mode(region,3)%d3(i,j,level) + yo(iloop,37)*dxyp(j)*ye(i,j,idz)*1.e-9
  1304. ! from ug/m^3 (according to eqsam), then take the M7 conversion (from kg/m^3) times 1.e-9.
  1305. ! This EQSAM water is added to the optics water at the call of optics.
  1306. #endif
  1307. end do
  1308. end do
  1309. ! END EQSAM
  1310. ! Check for negative concentrations.
  1311. do n=1,ntrace
  1312. do j=j1,j2
  1313. do i=i1,i2
  1314. if ( y(i,j,n) < 0. ) then
  1315. !print *,' chemistry: negatives appeared in chemie'
  1316. !write(6,*)i,j,level,idater
  1317. !write(6,907)(y0(i,j,ispec),ispec=1,ntrace)
  1318. !write(6,907)(y(i,j,ispec),ispec=1,ntrace)
  1319. if ( n > ntracet ) then
  1320. do ispec=ntracet+1,ntrace
  1321. y(i,j,ispec)=max(0.,y(i,j,ispec))
  1322. end do
  1323. else
  1324. write (gol,'(a,a8,a,4i4,e12.4)') &
  1325. 'chemistry: negatives for species:',names(n), ' at ', i,j,level,region, &
  1326. y(i,j,n)/y(i,j,iair); call goPr
  1327. y(i,j,n)=max(0.,y(i,j,n))
  1328. end if
  1329. end if
  1330. end do !i
  1331. end do !j
  1332. end do !n
  1333. ! Write the tracers back to the mass_dat (rm)
  1334. do n=1,ntrace
  1335. #ifdef with_cariolle
  1336. if ( (n==io3) .and. ( (level.ge.l_cariolle(region)) .or. with_trop_force ) ) then
  1337. ! O3 is changed by Cariolle chemistry
  1338. else
  1339. #endif
  1340. do j=j1,j2
  1341. do i=i1,i2
  1342. if ( n <= ntracet ) then
  1343. rm(i,j,level,n)=y(i,j,n)/y(i,j,iair)*ye(i,j,iairm)/fscale(n)
  1344. else
  1345. rmc(i,j,level,n)=y(i,j,n)/y(i,j,iair)*ye(i,j,iairm)/fscale(n)
  1346. end if
  1347. #ifdef slopes
  1348. if ( n <= ntracet ) then
  1349. skf=0.
  1350. if ( y(i,j,n) > eps .and. y0(i,j,n) > eps ) skf=y(i,j,n)/y0(i,j,n)
  1351. rxm(i,j,level,n)=rxm(i,j,level,n)*skf
  1352. rym(i,j,level,n)=rym(i,j,level,n)*skf
  1353. rzm(i,j,level,n)=rzm(i,j,level,n)*skf
  1354. #ifdef secmom
  1355. rxxm(i,j,level,n)=rxxm(i,j,level,n)*skf
  1356. rxym(i,j,level,n)=rxym(i,j,level,n)*skf
  1357. rxzm(i,j,level,n)=rxzm(i,j,level,n)*skf
  1358. ryym(i,j,level,n)=ryym(i,j,level,n)*skf
  1359. ryzm(i,j,level,n)=ryzm(i,j,level,n)*skf
  1360. rzzm(i,j,level,n)=rzzm(i,j,level,n)*skf
  1361. #endif
  1362. endif
  1363. #endif
  1364. end do
  1365. end do !j,i
  1366. #ifdef with_cariolle
  1367. endif
  1368. #endif
  1369. end do !n
  1370. ! For the optics calculations,
  1371. ! it is assumed that nitrate aerosol is formed
  1372. ! by condensation onto existing particles
  1373. ! in the soluble accumulation mode (Adams et al., JGR, 2001).
  1374. ! Therefore, the presence of nitrate does not increase
  1375. ! the number of particles, nor does it have an impact
  1376. ! on the processes described by M7.
  1377. ! Above, the water associated with nitrate aerosol
  1378. ! is added to the total aerosol water (h2o_mode) in the accumulation mode.
  1379. ! However, this only affects the calculation of the refractive index,
  1380. ! which also accounts for the nitrate mass itself.
  1381. ! In order to properly account for the additional ammonium nitrate
  1382. ! and the associated water in the optics routine,
  1383. ! the corresponding dry and wet particle radii have to be increased as well;
  1384. ! the aerosol density (dens_mode) can be left unchanged,
  1385. ! because it is not used in the optics routine.
  1386. ! We use the same refractive index for ammonium nitrate as for sulfate.
  1387. ! This is a reasonable approximation, since,
  1388. ! according to Tang (JGR, 1997), for sulfate and nitrate aerosols
  1389. ! the effect of chemical composition on light scattering
  1390. ! is outweighted by the size effect of the particles.
  1391. ! Lowenthal et al. (Atmos. Environ., 2000)
  1392. ! give a refractive index of 1.44 for sulfuric acid
  1393. ! and 1.55 for ammonium nitrate.
  1394. ! If desired, the refractive index of ammonium nitrate
  1395. ! could be estimated at different wavelengths
  1396. ! by scaling the OPAC data for sulfate,
  1397. ! based on these values.
  1398. ! In M7 and in the optics calculations,
  1399. ! sulfate aerosols are assumed to be pure sulfuric acid,
  1400. ! and we do not try to account for the presence of ammonium (bi)sulfate.
  1401. ! The reason is that the presence of ammonium (bi)sulfate
  1402. ! has competing effects on scattering,
  1403. ! which cannot be easily accounted for in a model based on M7.
  1404. ! Sulfuric acid particles are extremely hygroscopic
  1405. ! and will draw significant water mass into the aerosol phase
  1406. ! at any relative humidity (RH).
  1407. ! If these particles are partially or completely neutralized
  1408. ! by drawing ammonia from the gas phase,
  1409. ! there will be an increase in particle mass due to the added ammonium
  1410. ! but a decrease in particle hygroscopicity at low to moderate RH,
  1411. ! and thus a decrease in particulate water mass.
  1412. ! On the other hand, ammonium bisulfate and ammonium sulfate both
  1413. ! have a higher refractive index than sulfuric acid (see e.g. Boucher and Anderson, 1995).
  1414. ! The net result of these competing factors is that
  1415. ! one mole of sulfuric acid scatters about 25% more sunlight
  1416. ! than one mole of ammonium bisulfate at 80% relative humidity.
  1417. ! Ammonium sulfate is intermediate between the two.
  1418. ! For more information see Boucher and Anderson (1995) and Boucher et al. (JGR, 1998).
  1419. ! An excellent discussion of the optical properties of ammonium (bi)sulfate
  1420. ! versus sulfuric acid is also given by Adams et al. (JGR, 2001).
  1421. !
  1422. ! In remote regions, especially outside the tropics,
  1423. ! the contribution of methane sulfonate (MSA-) aerosol
  1424. ! to the total particulate sulfure burden
  1425. ! cannot be neglected.
  1426. ! Like nitrate, MSA- aerosols are mainly formed by
  1427. ! condensation onto exisiting particles,
  1428. ! in the soluble accumulation and coarse modes
  1429. ! (Saltzmann et al., JGR, 1983; Pzenny et al., J. Atmos. Chem., 1992).
  1430. ! For simplicity, we assume in the model
  1431. ! that MSA- is formed only in the accumulation mode.
  1432. ! Moreover, it seems reasonable to use the refractive index of
  1433. ! sulfuric acid (H2SO4) for MSA, as is done by Kinne et al. (2003).
  1434. ! The similarity between the refractive index for MSA and H2SO4
  1435. ! is also discussed by Myhre et al. (Applied Optics, 2004).
  1436. !
  1437. #ifdef with_m7
  1438. do j=j1,j2
  1439. do i=i1,i2
  1440. ! prevent division for zero for extremely low aerosol concentrations
  1441. ! calculate corresponding number concentration in #/cm3
  1442. ! and test if this is larger than 1.e-10
  1443. ! the same criterion is applied in m7_equil
  1444. number_conc = rm(i,j,level,iacs_n) / ( 1.e6 * dxyp(j) * ye(i,j,idz) )
  1445. if ( number_conc > 1.e-10 ) then
  1446. dryvol_m7=((rwd_mode(region,3)%d3(i,j,level)*cmr2ram(3))**3.0)*pi/0.75 ! dry particle volume [m3]
  1447. ! in the accumulation mode from M7
  1448. vol_nh4no3=rm(i,j,level,ino3_a)*nh4no3_factor/ &
  1449. (rm(i,j,level,iacs_n)*nh4no3_density) ! ammonium-nitrate aerosol volume per particle [m3]
  1450. vol_msa=rm(i,j,level,imsa)/(rm(i,j,level,iacs_n)*msa_density) ! MSA- aerosol volume per particle [m3]
  1451. vol_h2o=h2o_mode(region,3)%d3(i,j,level)/(rm(i,j,level,iacs_n)*rol) ! total aerosol water per particle [m3]
  1452. rw_mode(region,3)%d3(i,j,level) = ((dryvol_m7+vol_nh4no3+vol_msa+vol_h2o)*0.75/pi)**(1./3.)*ram2cmr(3)
  1453. rwd_mode(region,3)%d3(i,j,level) = ((dryvol_m7+vol_nh4no3+vol_msa)*0.75/pi)**(1./3.)*ram2cmr(3)
  1454. else
  1455. ! don't change rwd_mode and set rw_mode equal to rwd_mode
  1456. rw_mode(region,3)%d3(i,j,level) = rwd_mode(region,3)%d3(i,j,level)
  1457. endif
  1458. enddo
  1459. enddo
  1460. #endif
  1461. end do LEVS ! loop over vertical levels...
  1462. ! SAD
  1463. phot_dat(region)%sad_cld=sad_cld_out
  1464. phot_dat(region)%sad_ice=sad_ice_out
  1465. phot_dat(region)%sad_aer=sad_aer_out
  1466. ! perform averaging...
  1467. phot_dat(region)%nsad_av = phot_dat(region)%nsad_av + float(ndyn)/float(ndyn_max)
  1468. phot_dat(region)%sad_cld_av = phot_dat(region)%sad_cld_av + (float(ndyn)/float(ndyn_max))*phot_dat(region)%sad_cld
  1469. phot_dat(region)%sad_ice_av = phot_dat(region)%sad_ice_av + (float(ndyn)/float(ndyn_max))*phot_dat(region)%sad_ice
  1470. phot_dat(region)%sad_aer_av = phot_dat(region)%sad_aer_av + (float(ndyn)/float(ndyn_max))*phot_dat(region)%sad_aer
  1471. ! cleanup
  1472. deallocate(tha)
  1473. deallocate(mu)
  1474. deallocate(sza)
  1475. deallocate(reff)
  1476. deallocate(fact)
  1477. deallocate(rj)
  1478. deallocate(rj_new)
  1479. deallocate(rr)
  1480. deallocate(y)
  1481. deallocate(y0)
  1482. deallocate(ye, yhelp)
  1483. ! eqsam
  1484. deallocate(yo)
  1485. deallocate(yi)
  1486. ! sad
  1487. deallocate(sad_cld_out,sad_ice_out,sad_aer_out)
  1488. #ifdef with_m7
  1489. deallocate(presm7)
  1490. deallocate(rhm7)
  1491. deallocate(tempm7)
  1492. deallocate(dryairm7)
  1493. deallocate(h2so4m7)
  1494. deallocate(aemassm7)
  1495. deallocate(aenumm7)
  1496. deallocate(aedensm7)
  1497. deallocate(aewatm7)
  1498. deallocate(aeradm7)
  1499. deallocate(aeradrm7)
  1500. #ifdef with_budgets
  1501. deallocate(processm7)
  1502. #endif
  1503. nullify(dxyp)
  1504. #endif
  1505. nullify(m)
  1506. nullify(rm)
  1507. nullify(rmc)
  1508. #ifdef slopes
  1509. nullify(rxm)
  1510. nullify(rym)
  1511. nullify(rzm)
  1512. #ifdef secmom
  1513. nullify(rxxm)
  1514. nullify(rxym)
  1515. nullify(rxzm)
  1516. nullify(ryym)
  1517. nullify(ryzm)
  1518. nullify(rzzm)
  1519. #endif
  1520. #endif
  1521. nullify(r_cloud)
  1522. if ( okdebug ) write (*,*) 'end of chemistry'
  1523. ! ok
  1524. status = 0
  1525. END SUBROUTINE CHEMIE
  1526. !EOC
  1527. !--------------------------------------------------------------------------
  1528. ! TM5 !
  1529. !--------------------------------------------------------------------------
  1530. !BOP
  1531. !
  1532. ! !IROUTINE: GET_EXTRA
  1533. !
  1534. ! !DESCRIPTION:
  1535. ! calculate / get 2D fields needed in the chemistry routines...
  1536. ! some fields (like pH) are calculated later on...
  1537. !\\
  1538. !\\
  1539. ! !INTERFACE:
  1540. !
  1541. SUBROUTINE GET_EXTRA( region, level, ye, is, js)
  1542. !
  1543. ! !USES:
  1544. !
  1545. use Binas, only : Avog, grav
  1546. use dims, only : im, jm, lm
  1547. use Dims, only : CheckShape
  1548. use global_data, only : region_dat, mass_dat
  1549. use meteodata, only : phlb_dat, m_dat, temper_dat, humid_dat, gph_dat, cc_dat, iwc_dat, lwc_dat
  1550. use chem_param, only : n_extra, i_pres, i_temp, iairn, ih2on
  1551. use chem_param, only : xmair, xmh2o, iairm, ilwc, iiwc, icc, iph, idz,iciwc,iclwc
  1552. !
  1553. ! !INPUT PARAMETERS:
  1554. !
  1555. integer, intent(in) :: region ! region #
  1556. integer, intent(in) :: level, is, js ! level and start indices
  1557. !
  1558. ! !OUTPUT PARAMETERS:
  1559. !
  1560. real, intent(out) :: ye(is:,js:,:)
  1561. !
  1562. ! !REVISION HISTORY:
  1563. ! 22 Mar 2012 - P. Le Sager - adapted for lon-lat MPI domain decomposition
  1564. !
  1565. ! !REMARKS:
  1566. !
  1567. !EOP
  1568. !------------------------------------------------------------------------
  1569. !BOC
  1570. real,dimension(:,:,:),pointer :: phlb,m,gph,t,q,lwc,iwc,cc
  1571. integer :: i,j,l
  1572. real :: px,x1,x2,xice,xliq,aird
  1573. integer :: imr, jmr, lmr, i1, i2, j1, j2, status
  1574. ! --- begin --------------------------------
  1575. call Get_DistGrid( dgrid(region), I_STRT=i1, I_STOP=i2, J_STRT=j1, J_STOP=j2 )
  1576. ! check arguments ...
  1577. call CheckShape( (/i2-i1+1, j2-j1+1, n_extra/), shape(ye ), status )
  1578. lmr = lm(region)
  1579. phlb => phlb_dat(region)%data
  1580. m => m_dat(region)%data
  1581. t => temper_dat(region)%data
  1582. q => humid_dat(region)%data
  1583. gph => gph_dat(region)%data ! (:,:,1:lm(region)+1)
  1584. lwc => lwc_dat(region)%data
  1585. iwc => iwc_dat(region)%data
  1586. cc => cc_dat(region)%data
  1587. do j=j1,j2
  1588. do i=i1,i2
  1589. px = 0.5*(phlb(i,j,level)+phlb(i,j,level+1))
  1590. ye(i,j,i_pres) = px
  1591. ye(i,j,i_temp) = t(i,j,level)
  1592. ye(i,j,iairn ) = 7.24e16*px/t(i,j,level)
  1593. ye(i,j,ih2on ) = q(i,j,level)*ye(i,j,iairn)*xmair/xmh2o
  1594. ye(i,j,iairm ) = m(i,j,level)
  1595. ye(i,j,iclwc ) = lwc(i,j,level)
  1596. ye(i,j,iciwc ) = iwc(i,j,level)
  1597. ! x1: kg water to m3 water (m3 water/ kg air)
  1598. x1=lwc(i,j,level)*1.e-3
  1599. aird = ye(i,j,iairn)
  1600. x2=xmair*1e3*aird/Avog ! kg/m3 (air)
  1601. xliq = x1/x2 ! dimensionless number (m^3/m^3)
  1602. ! avoid negatives and artificial values(1e-10 is about 0.0001 g/m3)
  1603. if ( xliq < 1e-10 ) xliq=0.
  1604. ye(i,j,ilwc) = xliq
  1605. x1=iwc(i,j,level)*1.e-3 ! kg ice to m3 ice
  1606. xice=x1/x2
  1607. ! avoid negatives and artificial values)
  1608. if ( xice < 1e-10 ) xice=0.
  1609. ye(i,j,iiwc) = xice
  1610. ye(i,j,icc) = cc(i,j,level)
  1611. ye(i,j,iph) = 0.0 ! only set in wetS when cloudy!!!
  1612. ye(i,j,idz) = gph(i,j,level+1)-gph(i,j,level) !dz
  1613. end do
  1614. end do
  1615. nullify(phlb)
  1616. nullify(m)
  1617. nullify(gph)
  1618. nullify(t)
  1619. nullify(q)
  1620. nullify(lwc)
  1621. nullify(iwc)
  1622. nullify(cc)
  1623. END SUBROUTINE GET_EXTRA
  1624. !EOC
  1625. END MODULE CHEMISTRY