user_output_general.F90 153 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073
  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. #define IF_NOTOK_MDF(action) if (status/=0) then; TRACEBACK; action; call MDF_CLose(fid,status); status=1; return; end if
  5. !
  6. #include "tm5.inc"
  7. !
  8. !-----------------------------------------------------------------------------
  9. ! TM5 !
  10. !-----------------------------------------------------------------------------
  11. !BOP
  12. !
  13. ! !MODULE: USER_OUTPUT_GENERAL
  14. !
  15. ! !DESCRIPTION:
  16. !
  17. ! This module provides objects and methods for the AEROCOM-2 related
  18. ! diagnostics package. It is strongly related to the setup of the
  19. ! optics module.
  20. ! A list of parameters are defined for which daily averages are output
  21. ! (so far), result is one file per day containing 50 2d-fields and
  22. ! 4 3d-fields.
  23. !
  24. ! Life cycle(s):
  25. ! 1) output_aerocom_init:
  26. ! - if( newsrun ): - allocation and initialisation of output container
  27. ! (mixf%..., drydepos/wetdepos/emission, wdep_out)
  28. ! - initialisation of optics module
  29. ! - lookuptable
  30. ! - wavelengths
  31. ! - open output file (for today), initialise it and write attributes
  32. ! 2) output_aerocom_step:
  33. ! - gather tracer
  34. ! - add current state of model to containers
  35. ! (weighted by time since last call, --> period of validity)
  36. ! - do fluxes, surface concentrations and loads
  37. ! - do optics
  38. ! - aerocom_aopio_init: initialise and fill input parameters
  39. ! - optics::optics_calculate_aop:
  40. ! calculate optical properties (per wavelength)
  41. ! (take into account additional splitting, facilitated in
  42. ! optics::optics_calculate_aop)
  43. ! - fill containers for optical properties
  44. ! - free optics input parameters
  45. ! - fill aerocom output containers
  46. ! 3) output_aerocom_write:
  47. ! - collect_budgets:
  48. ! - use current budget containers (budemi, buddep, buddry)
  49. ! - compare with saved values and infer by that the increment
  50. ! - add to temporary output containers (wetdepos,drydepos,emission)
  51. ! - write output containers to file
  52. ! - close file
  53. ! 4) output_aerocom_done:
  54. ! - free allocated containers
  55. ! (mixf%..., drydepos/wetdepos/emission, wdep_out)
  56. !
  57. !\\
  58. !\\
  59. ! !INTERFACE:
  60. !
  61. MODULE USER_OUTPUT_GENERAL
  62. !
  63. ! !USES:
  64. !
  65. use go, only : gol, goErr, goPr, goLabel
  66. use dims, only : nregions
  67. use optics, only : wavelendep
  68. use meteodata, only : global_lli, levi
  69. use MDF
  70. use TM5_DISTGRID, only : dgrid, Get_DistGrid, update_halo, update_halo_iband
  71. use mo_aero_m7 , only: ncomp,nmod,naermod
  72. implicit none
  73. private
  74. !
  75. ! !PUBLIC MEMBER FUNCTIONS:
  76. !
  77. public :: output_general_init
  78. public :: output_general_step
  79. public :: output_general_write
  80. public :: output_general_done
  81. public :: wdep_out
  82. ! Control variables
  83. character(len=20), public :: gen_exper ! general experiment name
  84. character(len=20), public :: gen_freq ! general output frequency
  85. logical,public :: all_chemistry=.false.
  86. logical, parameter :: aai_output=.false.
  87. !
  88. ! diagnostic CCN
  89. logical, public :: nCCNdiag = .false. ! diagnostic CCN under given supersaturations for comparison to CCNC measurements
  90. ! nCCNdiag = .false. no diagnostic CCN
  91. ! nCCNdiag = .true. with diagnostic CCN
  92. integer,public :: nSat = 0 ! Number of supersaturations for which number of CCN will be calculated
  93. real, public, allocatable :: SuperSat(:)
  94. integer,public :: n_rad = 3 ! bacchus output at n diam
  95. integer, public :: HG_rad(3)=(/50,80, 120/)
  96. integer, public :: N_diam(3)=(/50,80, 120/)
  97. ! !PRIVATE DATA MEMBERS:
  98. !
  99. character(len=*), parameter :: mname = 'user_output_general'
  100. ! Changed naming convections to AeroCom Control 2015 experiment
  101. character(len=20), parameter :: f_dataid='general', f_model='TM5'
  102. character(len=20), parameter :: f_dimmix='global', f_dimstat='stations'
  103. !
  104. ! !PRIVATE TYPES:
  105. !
  106. type metafields
  107. integer :: itm5
  108. character(len=20) :: vname
  109. character(len=64) :: lname
  110. character(len=10) :: unit
  111. character(len=10) :: positive
  112. character(len=130) :: standard_name
  113. end type metafields
  114. type metafields2
  115. integer :: itm5
  116. character(len=17) :: vname
  117. character(len=64) :: lname
  118. character(len=10) :: unit
  119. character(len=130) :: standard_name
  120. end type metafields2
  121. type field3d
  122. type( metafields ) :: mf
  123. real, dimension(:,:,:), pointer :: field
  124. integer :: varid
  125. logical :: writeout
  126. end type field3d
  127. type field2d
  128. type( metafields ) :: mf
  129. real, dimension(:,:), pointer :: field
  130. integer :: varid
  131. logical :: writeout
  132. end type field2d
  133. type field1d
  134. type( metafields2 ) :: mf
  135. real, dimension(:,:), pointer :: field
  136. integer :: varid
  137. end type field1d
  138. type field0d
  139. type( metafields2 ) :: mf
  140. real, dimension(:), pointer :: field
  141. integer :: varid
  142. end type field0d
  143. type mixfile
  144. type( field3d ), dimension(:), pointer :: f3d
  145. type( field2d ), dimension(:), pointer :: f2d
  146. character(len=200) :: fname
  147. integer :: acct ! accumulation time
  148. integer :: funit ! unit number
  149. integer :: nlon ! x dimension of requested field
  150. integer :: nlat ! y dimension of requested field
  151. integer :: nlev ! z dimension of requested field
  152. real,dimension(:),pointer :: lon ! x dimension of requested field
  153. real,dimension(:),pointer :: lat ! y dimension of requested field
  154. real,dimension(:),pointer :: lev ! z dimension of requested field
  155. integer :: lonid ! x dimension id in nc
  156. integer :: latid ! y dimension id in nc
  157. integer :: levid ! z dimension id in nc
  158. integer :: timeid ! time dimension id in nc
  159. integer :: time_varid
  160. end type mixfile
  161. type(mixfile), dimension(nregions), save :: mixf
  162. integer::lon_varid
  163. integer::lat_varid
  164. integer::lev_varid
  165. ! diagnostic CCN
  166. integer, allocatable :: ind_CCN(:)
  167. integer, allocatable :: ind_HG(:)
  168. integer, allocatable :: ind_N(:)
  169. type budgetstore
  170. real, dimension(:,:,:), allocatable :: f2dslast
  171. integer :: lasttime
  172. end type budgetstore
  173. type(budgetstore), dimension(nregions), save :: drydepos, wetdepos, emission
  174. ! wavelength information
  175. type(wavelendep), dimension(:), allocatable :: wdep_out
  176. integer :: fid ! file id for IF_NOTOK_MDF macro
  177. integer :: access_mode ! netcdf-4 parallel access mode for distributed data
  178. ! generate output if true:
  179. logical :: okdebug = .true.
  180. ! reference time:
  181. integer :: time_reftime6(6) = (/2000,01,01,00,00,00/)
  182. character(len=*), parameter :: time_units = 'hours since 2000-01-01 00:00'
  183. ! sizes of arrays
  184. integer, save :: ntracer_3d, ntracer_2d
  185. integer, save :: ntracer_1dstat, ntracer_0dstat, nstations
  186. integer, save :: nextra_1dstat
  187. integer, save :: n_2d_vars=0
  188. integer, save :: n_3d_vars=0
  189. ! index pointers for 1d/2d/3d fields in mixf
  190. integer, save :: temp, hus, airmass, pressure
  191. integer, save :: p_gas_so4,p_liq_so4,p_elvoc,p_svoc,d_nuc,m_nuc_su,m_nuc_soa,p_svoc2d,p_elvoc2d,p_gas_so42d,p_liq_so42d
  192. integer, save :: p_elohterp,p_elo3terp,p_elohisop,p_elo3isop,p_svohterp,p_svo3terp,p_svohisop,p_svo3isop
  193. integer, save :: coag1, gr1_2, co1_soa, co1_su, co2_soa, co3_soa, co4_soa, co5_soa,gph
  194. integer, save :: so4pm1,bcpm1,orgpm1,soapm1,dupm1,sspm1,nh4pm1,no3pm1
  195. integer, save :: so4,bc,org,du,ss,nh4,no3,n3,mmf1,mmf2,mmf3,mmf4
  196. integer, save :: ec5503Daer, abs5503Daer, ec3503Daer, abs3503Daer
  197. integer, save :: ps , precip , sconcoa , sconcsoa , sconcbc , sconcso4 , sconcdust
  198. integer, save :: sconcss , sconcno3 , loadoa , loadsoa , loadbc , loadso4 , loaddust
  199. integer, save :: loadss , loadno3 , emioa , emibc , emiso2 , emiso4
  200. integer, save :: emidust , emidms , emiss , dryso2 , drybc , dryso4
  201. integer, save :: drydust , drydms , dryss , wetoa , wetsoa , wetbc , wetso2
  202. integer, save :: emiterp , emiisop
  203. integer, save :: wetso4 , wetdust , wetdms , wetss , od550aer , od550so4, od550soa
  204. integer, save :: od550bc , od550oa , od550ss , od550dust , od550no3 , od550aerh2o
  205. integer, save :: od550lt1aer , od550lt1dust, od550lt1ss , abs550aer , ec550aer , asyaer
  206. integer, save :: ec550dryaer , abs550dryaer, asydryaer , ec550drylt1aer, abs550drylt1aer
  207. integer, save :: od440aer , od870aer , sconcmsa , dryoa , drysoa , sconcnh4
  208. integer, save :: abs440aer , ec440dryaer , abs440dryaer
  209. integer, save :: abs870aer , ec870dryaer , abs870dryaer
  210. integer, save :: od350aer , abs350aer,ccn02
  211. integer, save :: bso4nus, bso4ais, bso4acs, bso4cos, bbcais , bbcacs
  212. integer, save :: bbccos , bbcaii , bpomais, bpomacs, bpomcos, bpomaii
  213. integer, save :: bssacs , bsscos , bduacs , bducos , bduaci , bducoi, bno3_a
  214. integer, save :: bnus_n , bais_n , bacs_n , bcos_n , baii_n , baci_n
  215. integer, save :: bcoi_n , bh2onus, bh2oais, bh2oacs, bh2ocos
  216. integer, save :: tr2d_1, tr2d_2, tr2d_3, tr2d_4, tr2d_5, tr2d_6, tr2d_7, tr2d_8, tr2d_9, tr2d_10
  217. integer, save :: tr2d_11, tr2d_12, tr2d_13, tr2d_14, tr2d_15, tr2d_16, tr2d_17, tr2d_18, tr2d_19
  218. integer, save :: tr2d_20, tr2d_21, tr2d_22, tr2d_23
  219. integer, save :: cc01, cc02, cc03, cc04, cc05, cc06, cc07
  220. integer, save :: cc3d01, cc3d02, cc3d03, cc3d04, cc3d05, cc3d06, cc3d07
  221. integer, save :: rw01, rw02, rw03, rw04, rw05, rw06, rw07
  222. integer, save :: rd01, rd02, rd03, rd04, rd05, rd06, rd07
  223. integer, save :: h2o1, h2o2, h2o3, h2o4
  224. integer, save :: tr3d_1, tr3d_2, tr3d_3, tr3d_4, tr3d_5, tr3d_6, tr3d_7, tr3d_8, tr3d_9, tr3d_10
  225. integer, save :: tr3d_11, tr3d_12, tr3d_13, tr3d_14, tr3d_15, tr3d_16, tr3d_17, tr3d_18, tr3d_19
  226. integer, save :: rw3d01, rw3d02, rw3d03, rw3d04, rw3d05, rw3d06, rw3d07
  227. integer, save :: rd3d01, rd3d02, rd3d03, rd3d04, rd3d05, rd3d06, rd3d07
  228. integer, save :: h2o3d1, h2o3d2, h2o3d3, h2o3d4
  229. integer, save ,dimension(2*nmod) :: radius
  230. integer, save ,dimension(ncomp) :: load
  231. integer, save ,dimension(ncomp) :: drydep
  232. integer, save ,dimension(ncomp) :: emi
  233. integer, save ,dimension(ncomp) :: wetdep
  234. integer, save ,dimension(ncomp) :: sed
  235. integer, save ,dimension(nmod) :: number
  236. integer, save ,dimension(naermod) :: masses
  237. integer, save :: ngas_output=10
  238. integer, save, dimension(:),allocatable :: gas_output
  239. integer::itim_opt_out
  240. !
  241. ! !REVISION HISTORY:
  242. ! 16 Nov 2010 - Achim Strunk
  243. ! 8 Dec 2016 - Tommi Bergman - Modified from AEROCOM-output
  244. !
  245. ! !REMARKS:
  246. ! (1) compiled only if with_m7 is used.
  247. !
  248. !EOP
  249. !------------------------------------------------------------------------
  250. contains
  251. !--------------------------------------------------------------------------
  252. ! TM5 !
  253. !--------------------------------------------------------------------------
  254. !BOP
  255. !
  256. ! !IROUTINE: OUTPUT_GENERAL_INIT
  257. !
  258. ! !DESCRIPTION: Initialise various parameters, eg.,
  259. ! wavelengths for optics and output containers.
  260. ! This routine should be called once per day, since fields
  261. ! are daily averages and one file per day is written.
  262. ! Additional tasks are done for newsrun==.true. .
  263. !\\
  264. !\\
  265. ! !INTERFACE:
  266. !
  267. subroutine output_general_init(status, iregion)
  268. !
  269. ! !USES:
  270. !
  271. !use MeteoData, only : sp_dat, set
  272. use GO, only: GO_Timer_Def, GO_Timer_End, GO_Timer_Start
  273. use chem_param, only : ntracet,ntrace,names,mode_tracers,mode_start,mode_nm
  274. use chem_param, only : inus_n, iso4nus, isoanus,nmod
  275. use chem_param, only : iais_n, iso4ais, ibcais, ipomais, isoaais
  276. use chem_param, only : iacs_n, iso4acs, ibcacs, ipomacs, isoaacs, issacs, iduacs
  277. use chem_param, only : icos_n, iso4cos, ibccos, ipomcos, isoacos, isscos, iducos
  278. use chem_param, only : iaii_n, ibcaii, ipomaii, isoaaii
  279. use chem_param, only : iaci_n, icoi_n, iduaci, iducoi
  280. use chem_param, only : ino3_a, inh4, imsa
  281. use chem_param, only : Kap_su, Kap_pom, Kap_soa, Kap_bc, Kap_du, Kap_ss, Kap_na2so4, Kap_no3, Kap_msa
  282. !use chem_param, only : io3, idms, imsa, inh4, iterp, ioh, ino3, ielvoc, isvoc, iisop,iso2,iso4
  283. use chem_param, only : io3, ih2o2, ieth, irooh, idms, imsa, imgly, inox, ico, ipar, ipan
  284. use chem_param, only : ich2o, iald2, iisop, iso4, irn222, ino3_a, ich4, ich3o2h, iole, iorgntr, inh3
  285. use chem_param, only : ic2h6, iethoh, ic3h8, iterp, iacet, iispd, ihono, ich3o2no2, ino, iho2, ich3o2
  286. use chem_param, only : in2o5, ihno4, ic2o3, iror, irxpar, ixo2, ixo2n, inh2, ih2opart,ic3h7o2, ihypro2
  287. use chem_param, only : isvoc, iso2, inh4, ipb210,io3s, ich3oh, ihcooh , ioh, ino2, ino3, iaco2, inh2o2, ielvoc
  288. USE mo_aero_m7, ONLY : nmod, nsol
  289. use dims, only : nregions, newsrun, idatee, idatei ,sdate_simulation
  290. use dims, only : region_name, parent, itau
  291. use dims, only : xbeg, xend, ybeg, yend, dx, dy, xref, yref
  292. use dims, only : zbeg, zend, dz, zref
  293. use global_data, only : region_dat, outdir
  294. use datetime, only : tau2date, date2tau
  295. use budget_global, only : nbud_vg
  296. use partools, only : MPI_INFO_NULL, localComm
  297. use optics, only : Optics_Init
  298. use datetime, only : date2tau
  299. use dims, only : mlen, idatei
  300. use NetCDF, only : NF90_Def_Var,NF90_put_var
  301. !
  302. ! !OUTPUT PARAMETERS:
  303. !
  304. integer, intent(out) :: status
  305. !
  306. ! !INPUT PARAMETERS:
  307. !
  308. integer, intent(in), optional :: iregion
  309. !
  310. ! !REVISION HISTORY:
  311. ! Nov 2010 - Achim Strunk
  312. ! 16 Dec 2016 - Tommi Bergman KNMI
  313. ! - Modified from AEROCOM output
  314. !
  315. ! !REMARKS:
  316. !
  317. !EOP
  318. !------------------------------------------------------------------------
  319. !BOC
  320. character(len=*), parameter :: rname = mname//'/output_general_init'
  321. ! --- local ------------------------------
  322. integer :: imr, jmr, lmr, access_mode_sta
  323. integer :: lat_dimid,lon_dimid,lev_dimid,kappa_dimid
  324. integer :: year_varid,month_varid,kso4_varid, kss_varid,kpom_varid,kbc_varid,kdu_varid,kno3_varid,kna2so4_varid,ksoa_varid,kmsa_varid
  325. integer :: region, varid
  326. integer :: io, istat, i, j, n, sc, iSat
  327. integer :: i1, i2, j1, j2
  328. integer, dimension(6) :: idater
  329. character(len=10) :: idates
  330. character(len=16) :: lidates
  331. character(len=3) :: cwavel
  332. real :: reftime
  333. integer :: itaucur, itauref, time_shift
  334. real :: dlat, dlon
  335. integer :: mlength
  336. integer :: itracer,index_aer,imass,iout
  337. character(len=14) :: str, str2
  338. character(len=28) :: str_reftime
  339. ! --- begin -------------------------------
  340. call goLabel(rname)
  341. ! access mode for distributed data (2d and 3d)
  342. #ifdef MPI
  343. #ifdef with_netcdf4_par
  344. access_mode = MDF_COLLECTIVE
  345. #else
  346. write(gol,'("General aerosol output requires netcdf4 with parallel access enabled")') ; call goErr
  347. TRACEBACK
  348. status=1; return
  349. #endif
  350. #else
  351. access_mode = MDF_INDEPENDENT
  352. #endif
  353. ! for station
  354. access_mode_sta = MDF_INDEPENDENT
  355. ! initialize (only once)
  356. if( newsrun ) then
  357. call GO_Timer_Def( itim_opt_out, 'optics-output', status )
  358. IF_NOTOK_RETURN(status=1)
  359. ! ensure that required meteo is loaded:
  360. ! call Set( sp_dat(region), status, used=.true. )
  361. ! set wavelength information
  362. ! wl: wavelength in microns
  363. ! split: whether to split into contributions from
  364. ! M7 constituents (incl. water)
  365. allocate( wdep_out( 4 ) )
  366. wdep_out(1)%wl = 0.550 ; wdep_out(1)%split = .true. ; wdep_out(1)%insitu = .true.
  367. wdep_out(2)%wl = 0.440 ; wdep_out(2)%split = .false. ; wdep_out(2)%insitu = .true.
  368. wdep_out(3)%wl = 0.870 ; wdep_out(3)%split = .false. ; wdep_out(3)%insitu = .true.
  369. wdep_out(4)%wl = 0.350 ; wdep_out(4)%split = .false. ; wdep_out(4)%insitu = .false.
  370. ! get the optics code prepared
  371. call Optics_Init(size(wdep_out), wdep_out, status )
  372. IF_NOTOK_RETURN(status=1)
  373. ! -----------------------
  374. ! parameters needed to reference the different 1d/2d/3d-fields
  375. ! (in order to avoid errors in referencing)
  376. ! finally, this list here simply determines the order in the output files
  377. ntracer_3d = 160+nSat
  378. ! list removed, not needed anymore.
  379. ! 2d-output list needed for the moment
  380. ! optics needs to be changed first, since it relies on having optical variables
  381. ! using indices 38->
  382. ntracer_2d = 122
  383. ps = 1 ! 2d
  384. precip = 2 ! 2d
  385. sconcoa = 3 ! 2d
  386. sconcbc = 4 ! 2d
  387. sconcso4 = 5 ! 2d
  388. sconcdust = 6 ! 2d
  389. sconcss = 7 ! 2d
  390. sconcno3 = 8 ! 2d
  391. sconcnh4 = 9 ! 2d
  392. sconcmsa = 10 ! 2d
  393. loadoa = 11 ! 2d
  394. loadbc = 12 ! 2d
  395. loadso4 = 13 ! 2d
  396. loaddust = 14 ! 2d
  397. loadss = 15 ! 2d
  398. loadno3 = 16 ! 2d
  399. emioa = 17 ! 2d
  400. emibc = 18 ! 2d
  401. emiso2 = 19 ! 2d
  402. emiso4 = 20 ! 2d
  403. emidust = 21 ! 2d
  404. emidms = 22 ! 2d
  405. emiss = 23 ! 2d
  406. dryso2 = 24 ! 2d
  407. dryoa = 25 ! 2d
  408. drybc = 26 ! 2d
  409. dryso4 = 27 ! 2d
  410. drydust = 28 ! 2d
  411. drydms = 29 ! 2d
  412. dryss = 30 ! 2d
  413. wetoa = 31 ! 2d
  414. wetbc = 32 ! 2d
  415. wetso2 = 33 ! 2d
  416. wetso4 = 34 ! 2d
  417. wetdust = 35 ! 2d
  418. wetdms = 36 ! 2d
  419. wetss = 37 ! 2d
  420. ! --- from here onwards keep consistent with order in optics (optics.F90)
  421. ! --- begin split order
  422. od550aer = 38 ! 2d
  423. od550so4 = 39 ! 2d
  424. od550bc = 40 ! 2d
  425. od550oa = 41 ! 2d
  426. od550soa = 42 ! 2d
  427. od550ss = 43 ! 2d
  428. od550dust = 44 ! 2d
  429. od550no3 = 45 ! 2d
  430. od550aerh2o = 46 ! 2d
  431. od550lt1aer = 47 ! 2d
  432. od550lt1dust = 48 ! 2d
  433. od550lt1ss = 49 ! 2d
  434. ! --- end split order
  435. abs550aer = 50 ! 2d
  436. asyaer = 51 ! 2d
  437. ec550aer = 52 ! 2d
  438. ! --- begin in-situ data order
  439. ec550dryaer = 53 ! 2d
  440. abs550dryaer = 54 ! 2d
  441. asydryaer = 55 ! 2d
  442. ec550drylt1aer = 56 ! 2d
  443. abs550drylt1aer = 57 ! 2d
  444. ! --- end in-situ data order
  445. !
  446. od440aer = 58 ! 2d
  447. abs440aer = 59 ! 2d
  448. ec440dryaer = 60 ! 2d
  449. abs440dryaer = 61 ! 2d
  450. !
  451. od870aer = 62 ! 2d
  452. abs870aer = 63 ! 2d
  453. ec870dryaer = 64 ! 2d
  454. abs870dryaer = 65 ! 2d
  455. !
  456. od350aer = 66 ! 2d
  457. abs350aer = 67 ! 2d
  458. !
  459. tr2d_1=68
  460. tr2d_2=69
  461. tr2d_3=70
  462. tr2d_4=71
  463. tr2d_5=72
  464. tr2d_6=73
  465. tr2d_7=74
  466. tr2d_8=75
  467. tr2d_9=76
  468. tr2d_10=77
  469. tr2d_11=78
  470. tr2d_12=79
  471. tr2d_13=80
  472. tr2d_14=81
  473. tr2d_15=82
  474. tr2d_16=83
  475. tr2d_17=84
  476. tr2d_18=85
  477. tr2d_19=86
  478. tr2d_20=87
  479. tr2d_21=88
  480. tr2d_22=89
  481. tr2d_23=90
  482. cc01=91
  483. cc02=92
  484. cc03=93
  485. cc04=94
  486. cc05=95
  487. cc06=96
  488. cc07=97
  489. h2o1=98
  490. h2o2=99
  491. h2o3=100
  492. h2o4=101
  493. rw01=102
  494. rw02=103
  495. rw03=104
  496. rw04=105
  497. rw05=106
  498. rw06=107
  499. rw07=108
  500. rd01=109
  501. rd02=110
  502. rd03=111
  503. rd04=112
  504. sconcsoa=113
  505. loadsoa=114
  506. drysoa=115
  507. wetsoa=116
  508. emiterp=117
  509. emiisop=118
  510. p_svoc2d=119
  511. p_elvoc2d=120
  512. p_liq_so42d=121
  513. p_gas_so42d=122
  514. end if
  515. regionloop: do region = 1, nregions
  516. ! if region given, cycle if other region!
  517. if (present(iregion)) then
  518. if(iregion /= region) cycle regionloop
  519. endif
  520. imr = global_lli(region)%nlon
  521. jmr = global_lli(region)%nlat
  522. lmr = levi%nlev
  523. if( nbud_vg /= lmr ) then
  524. write(gol,*)'output_general_init: nbud_vg /= lmr'; call goErr
  525. write(gol,*)'output_general_init: YOU MUST ADD THE PROJ/BUDGET10 TO SRC CODE !!!!!'; call goErr
  526. TRACEBACK
  527. status=1; return
  528. end if
  529. ! initialize the output:
  530. if( newsrun ) then
  531. if (all_chemistry) then
  532. ngas_output=57
  533. allocate(gas_output(ngas_output))
  534. gas_output=(/&
  535. io3, ih2o2, ieth, irooh, idms, imsa, imgly, inox, ico, ipar, ipan, iso2, inh4, ipb210, &
  536. ich2o, iald2, iisop, iso4, irn222, ino3_a, ich4, ich3o2h, iole, iorgntr, inh3, io3s, ich3oh, ihcooh, &
  537. ic2h6, iethoh, ic3h8, iterp, iacet, iispd, ihono, ich3o2no2, ino, iho2, ich3o2, ioh, ino2, ino3, &
  538. in2o5, ihno4, ic2o3, iror, irxpar, ixo2, ixo2n, inh2, ih2opart,ic3h7o2, ihypro2, iaco2, inh2o2, ielvoc, &
  539. isvoc/)
  540. else
  541. allocate(gas_output(ngas_output))
  542. gas_output=(/io3,idms,iso4,iso2,iterp,ioh,ino3,ielvoc,isvoc,iisop /)
  543. end if
  544. call Get_DistGrid( dgrid(region), I_STRT=i1, I_STOP=i2, J_STRT=j1, J_STOP=j2 )
  545. !timeidx=1
  546. ! target structures for output
  547. allocate(mixf (region)%f3d(ntracer_3d))
  548. allocate(mixf (region)%f2d(ntracer_2d))
  549. ! allocate data holder for maximum amount of tracers
  550. do i=1,ntracer_3d
  551. allocate( mixf(region)%f3d(i)%field(i1:i2,j1:j2,lmr) )
  552. end do
  553. do i=1,ntracer_2d
  554. allocate( mixf(region)%f2d(i)%field(i1:i2,j1:j2))
  555. end do
  556. ! METEO variables
  557. call add_Variable(region,-1 , 'temp ', 'Temperature ' , 'K ',3,temp,status )
  558. call add_Variable(region,-1 , 'hus ', 'Specific Humidity ' , '1 ',3,hus,status )
  559. call add_Variable(region,-1 , 'airmass ', 'Air Mass ' , 'kg m-2 ',3,airmass,status )
  560. call add_Variable(region,-1 ,'pres ', 'Pressure ' , 'Pa ',3,pressure,status )
  561. !call add_Variable(region,-1 ,'prod_gas_so4 ', 'production of so4 ' , 'kg m-2s-1',3,p_gas_so4,status )
  562. !call add_Variable(region,-1 ,'prod_liq_so4 ', 'production of so4 ' , 'kg m-2s-1',3,p_liq_so4,status )
  563. !call add_Variable(region,-1 ,'prod_elvoc ', 'production of elvoc ' , 'kg m-2s-1',3,p_elvoc,status )
  564. !call add_Variable(region,-1 ,'prod_svoc ', 'production of svoc ' , 'kg m-2s-1',3,p_svoc,status )
  565. !call add_Variable(region,-1 ,'p_el_ohterp ', 'production of elvoc, ohterp ' , 'kg m-2s-1',3,p_elohterp,status )
  566. !call add_Variable(region,-1 ,'p_el_o3terp ', 'production of elvoc, o3terp ' , 'kg m-2s-1',3,p_elo3terp,status )
  567. !call add_Variable(region,-1 ,'p_el_ohisop ', 'production of elvoc, ohisop ' , 'kg m-2s-1',3,p_elohisop,status )
  568. !call add_Variable(region,-1 ,'p_el_o3isop ', 'production of elvoc, o3isop ' , 'kg m-2s-1',3,p_elo3isop,status )
  569. !call add_Variable(region,-1 ,'p_sv_ohterp ', 'production of svoc, ohterp ' , 'kg m-2s-1',3,p_svohterp,status )
  570. !call add_Variable(region,-1 ,'p_sv_o3terp ', 'production of svoc, o3terp ' , 'kg m-2s-1',3,p_svo3terp,status )
  571. !call add_Variable(region,-1 ,'p_sv_ohisop ', 'production of svoc, ohisop ' , 'kg m-2s-1',3,p_svohisop,status )
  572. !call add_Variable(region,-1 ,'p_sv_o3isop ', 'production of svoc, o3isop ' , 'kg m-2s-1',3,p_svo3isop,status )
  573. !call add_Variable(region,-1 ,'d_nuc ', 'production of particles ' , ' cm-3s-1',3,d_nuc,status )
  574. !call add_Variable(region,-1 ,'m_nuc_su ', 'nucleation sulfate ' , ' molec cm-3s-1',3,m_nuc_su,status )
  575. !call add_Variable(region,-1 ,'m_nuc_soa ', 'nucleation ELVOC ' , ' µg m-3s-1',3,m_nuc_soa,status )
  576. !call add_Variable(region,-1 ,'gr1_2 ', 'growth of mode 1 into 2 ' , ' cm-3s-1',3,gr1_2,status )
  577. !call add_Variable(region,-1 ,'coag1 ', 'coagulation sink of mode 1 ' , ' cm-3s-1',3,coag1,status )
  578. !call add_Variable(region,-1 ,'co1_soa ', 'condensation of ELVOC to mode 1 ' , ' µg m-3s-1',3,co1_soa,status )
  579. !call add_Variable(region,-1 ,'co2_soa ', 'condensation of ELVOC to mode 2 ' , ' µg m-3s-1',3,co2_soa,status )
  580. !call add_Variable(region,-1 ,'co3_soa ', 'condensation of ELVOC to mode 3 ' , ' µg m-3s-1',3,co3_soa,status )
  581. !call add_Variable(region,-1 ,'co4_soa ', 'condensation of ELVOC to mode 4 ' , ' µg m-3s-1',3,co4_soa,status )
  582. !call add_Variable(region,-1 ,'co5_soa ', 'condensation of ELVOC to mode 5 ' , ' µg m-3s-1',3,co5_soa,status )
  583. !call add_Variable(region,-1 ,'co1_su ', 'condensation of sulfate to mode 1 ' , ' molec cm-3s-1',3,co1_su,status )
  584. call add_Variable(region,-1 ,'mf1 ', 'mass of so4 in pm1 ' , ' ug m-3',3,mmf1,status )
  585. call add_Variable(region,-1 ,'mf2 ', 'mass of BC in pm1 ' , ' ug m-3',3,mmf2,status )
  586. call add_Variable(region,-1 ,'mf3 ', 'mass of ORG in pm1 ' , ' ug m-3',3,mmf3,status )
  587. call add_Variable(region,-1 ,'mf4 ', 'mass of SOA in pm1 ' , ' ug m-3',3,mmf4,status )
  588. call add_Variable(region,-1 ,'SO4pm1 ', 'mass of so4 in pm1 ' , ' ug m-3',3,so4pm1,status )
  589. call add_Variable(region,-1 ,'BCpm1 ', 'mass of BC in pm1 ' , ' ug m-3',3,bcpm1,status )
  590. call add_Variable(region,-1 ,'ORGpm1 ', 'mass of ORG in pm1 ' , ' ug m-3',3,orgpm1,status )
  591. call add_Variable(region,-1 ,'SOApm1 ', 'mass of SOA in pm1 ' , ' ug m-3',3,soapm1,status )
  592. call add_Variable(region,-1 ,'SSpm1 ', 'mass of SS in pm1 ' , ' ug m-3',3,sspm1,status )
  593. call add_Variable(region,-1 ,'DUpm1 ', 'mass of DU in pm1 ' , ' ug m-3',3,dupm1,status )
  594. call add_Variable(region,-1 ,'NH4pm1 ', 'mass of NH4 in pm1 ' , ' ug m-3',3,nh4pm1,status )
  595. call add_Variable(region,-1 ,'NO3pm1 ', 'mass of NO3 in pm1 ' , ' ug m-3',3,no3pm1,status )
  596. call add_Variable(region,-1 ,'SO4 ', 'mass of SO4 ' , ' ug S m-3',3,so4,status )
  597. call add_Variable(region,-1 ,'BC ', 'mass of BC ' , ' ug C m-3',3,bc,status )
  598. call add_Variable(region,-1 ,'ORG ', 'mass of ORG ' , ' ug C m-3',3,org,status )
  599. call add_Variable(region,-1 ,'SS ', 'mass of SS ' , ' ug m-3',3,ss,status )
  600. call add_Variable(region,-1 ,'DU ', 'mass of DU ' , ' ug m-3',3,du,status )
  601. call add_Variable(region,-1 ,'NH4 ', 'mass of NH4 ' , ' ug m-3',3,nh4,status )
  602. call add_Variable(region,-1 ,'NO3 ', 'mass of NO3 ' , ' ug m-3',3,no3,status )
  603. IF (nCCNdiag) THEN
  604. ALLOCATE(ind_CCN(nSat))
  605. DO iSat=1,nSat
  606. !write(1111,*)SuperSat(iSat)*1000.e0
  607. if (supersat(isat)<0.0006)then
  608. !WRITE(str,'("CCN",I0.3)') SuperSat(iSat)*10000.e0 !CCN005 (0.0005*1e4=5)
  609. WRITE(str,'("CCN005")') !SuperSat(iSat)*10000.e0 !CCN005 (0.0005*1e4=5)
  610. else if (supersat(isat)<0.0008)then
  611. WRITE(str,'("CCN0075")') !SuperSat(iSat)*100000.e0!CCN0075 (0.00075*1e5=75
  612. else if (supersat(isat)<0.0012)then
  613. WRITE(str,'("CCN01")') !SuperSat(iSat)*1000.e0 !CCN01 (0.001*1e3=1)
  614. else if (supersat(isat)<0.0016)then
  615. WRITE(str,'("CCN015")') !SuperSat(iSat)*10000.e0!CCN015 0.0015*1e4=15)
  616. else
  617. !write(1112,*)SuperSat(iSat)*1000.e0
  618. WRITE(str,'("CCN",I0.2)') nint(SuperSat(iSat)*1000.e0) !CCN0[23456789] & CCN10
  619. end if
  620. !write(1112,*) str , int(SuperSat(iSat)*1000.e0) , nint(SuperSat(iSat)*1000.e0), (SuperSat(iSat)*1000.e0)
  621. WRITE(str2,'("CCN at ",F4.2,"%")') SuperSat(iSat)*100.e0
  622. call add_Variable(region,-1 ,str, str2, ' cm-3',3,ind_CCN(iSat),status )
  623. ENDDO
  624. allocate(ind_HG(n_rad))
  625. allocate(ind_N(n_rad))
  626. do isat=1,n_rad
  627. if (HG_rad(isat)>99) then
  628. WRITE(str,'("HG",I3)') HG_rad(isat)
  629. else
  630. WRITE(str,'("HG",I2)') HG_rad(isat)
  631. end if
  632. WRITE(str2,'("HG at ",I3,"nm")') HG_rad(isat)
  633. call add_variable(region,-1 ,str, str2, '1',3,ind_HG(iSat),status )
  634. if (N_diam(isat)>99)then
  635. WRITE(str,'("N",I3)') N_diam(isat)
  636. else
  637. WRITE(str,'("N",I2)') N_diam(isat)
  638. end if
  639. !write(1000,*)str
  640. WRITE(str2,'("N at ",I3,"nm")') N_diam(isat)
  641. call add_variable(region,-1 ,str, str2, ' cm-3',3,ind_N(iSat),status )
  642. end do
  643. ENDIF
  644. call add_variable(region,-1 ,'N3', 'N at 3nm', ' cm-3',3,n3,status )
  645. call add_Variable(region,-1 ,'gph', 'Geopotential height', 'm',3,gph,status )
  646. call add_Variable(region,-1 ,'CCN', 'CCN at 0.2%', '#/cm3',3,ccn02,status )
  647. ! mass concentrations of different modes
  648. imass=0
  649. do i=1,nmod
  650. do j=1,mode_nm(i)!ncomp
  651. !get tracer id from mode_tracers array
  652. itracer=mode_tracers(j,i)
  653. ! if there is a tracer, add variable to output array
  654. !if (itracer>0)then
  655. imass=imass+1
  656. call add_Variable(region,itracer ,'M_'//names(itracer), 'mass concentration of '//names(itracer), 'kg m-3',3,index_aer,status )
  657. !end if
  658. ! save output array id for masses
  659. masses(imass)=index_aer
  660. end do
  661. end do
  662. call add_Variable(region,imsa ,'M_MSA', 'mass concentration of MSA (ACS)', 'kg m-3',3,index_aer,status )
  663. call add_Variable(region,ino3_a ,'M_NO3', 'mass concentration of NO3 (ACS)', 'kg m-3',3,index_aer,status )
  664. call add_Variable(region,inh4 ,'M_NH4', 'mass concentration of NH4 (ACS)', 'kg m-3',3,index_aer,status )
  665. ! Mode number concentrations
  666. do i=1,nmod
  667. !get tracer id from mode_tracers array
  668. ! 0-index of mode_tracers has the number for each mode
  669. itracer=mode_tracers(0,i)
  670. ! if there is a tracer, add variable to output array
  671. if (itracer>0)then
  672. !
  673. call add_Variable(region,itracer ,'N_'//names(itracer)(1:3), 'number concentration of '//names(itracer), '1 m-3',3,index_aer,status )
  674. end if
  675. ! save output array id for number
  676. number(i)=index_aer
  677. end do
  678. ! gas-phase output
  679. !!$ do i=1,ngas_output
  680. !!$ itracer=gas_output(i)
  681. !!$ call add_Variable(region,itracer ,'GAS_'//names(itracer), 'gas phase concentration of '//names(itracer), 'kg m-3',3,index_aer,status )
  682. !!$ end do
  683. !!$
  684. !!$ ! particle water
  685. !!$ do i=1,nsol
  686. !!$ !write(iout,'(I2.2)') i
  687. !!$ itracer=mode_start(i)
  688. !!$ call add_Variable(region,-1 , 'aerh2o3d_'//names(itracer)(1:3), 'concentration of aerosol water of mode '//names(itracer)(1:3) , 'kg m-3',3,index_aer,status )
  689. !!$
  690. !!$ end do
  691. ! Radius of the particles
  692. ! wet radius for all
  693. !!$ do i=1,nmod
  694. !!$ itracer=mode_start(i)
  695. !!$ call add_Variable(region,-1 ,'RWET_'//names(itracer)(1:3), 'wet radius of '//names(itracer)(1:3), 'm',3,index_aer,status )
  696. !!$ end do
  697. !!$ ! dry radius only for soluble, as rwet=rdry for insoluble
  698. !!$ do i=1,nsol
  699. !!$ itracer=mode_start(i)
  700. !!$
  701. !!$ call add_Variable(region,-1 ,'RDRY_'//names(itracer)(1:3), 'dry radius of '//names(itracer)(1:3), 'm',3,index_aer,status )
  702. !!$
  703. !!$ end do
  704. ! 2d data
  705. ! For now it is exactly the same as in AEROCOM-output, mostly due to optics depending on
  706. ! output indices now in place
  707. mixf(region)%f2d(ps )%mf = metafields( -1 , 'ps ', 'Surface Air Pressure ' , 'Pa ', '', 'surface_air_pressure' )
  708. mixf(region)%f2d(precip )%mf = metafields( -1 , 'precip ', 'Precipitation ' , 'kg m-2 s-1', '', 'precipitation_flux' )
  709. mixf(region)%f2d(sconcoa )%mf = metafields( -1 , 'sconcoa ', 'Surface Concentration POM ' , 'kg m-3 ', '', 'mass_concentration_of_particulate_organic_matter_dry_aerosol_in_air' )
  710. mixf(region)%f2d(sconcbc )%mf = metafields( -1 , 'sconcbc ', 'Surface Concentration BC ' , 'kg m-3 ', '', 'mass_concentration_of_black_carbon_dry_aerosol_in_air' )
  711. mixf(region)%f2d(sconcso4 )%mf = metafields( -1 , 'sconcso4 ', 'Surface Concentration SO4 ' , 'kg m-3 ', '', 'mass_concentration_of_sulfate_dry_aerosol_in_air' )
  712. mixf(region)%f2d(sconcdust )%mf = metafields( -1 , 'sconcdust ', 'Surface Concentration Dust ' , 'kg m-3 ', '', 'mass_concentration_of_dust_dry_aerosol_in_air' )
  713. mixf(region)%f2d(sconcss )%mf = metafields( -1 , 'sconcss ', 'Surface Concentration SS ' , 'kg m-3 ', '', 'mass_concentration_of_seasalt_dry_aerosol_in_air' )
  714. mixf(region)%f2d(sconcno3 )%mf = metafields( -1 , 'sconcno3 ', 'Surface Concentration NO3 ' , 'kg m-3 ', '', 'mass_concentration_of_nitrate_dry_aerosol_in_air' )
  715. mixf(region)%f2d(sconcnh4 )%mf = metafields( -1 , 'sconcnh4 ', 'Surface Concentration NH4 ' , 'kg m-3 ', '', 'mass_concentration_of_ammonium_dry_aerosol_in_air' )
  716. mixf(region)%f2d(sconcmsa )%mf = metafields( -1 , 'sconcmsa ', 'Surface Concentration MSA ' , 'kg m-3 ', '', 'mass_concentration_of_methane_sulfonic_acid_in_air' )
  717. mixf(region)%f2d(loadoa )%mf = metafields( -1 , 'loadoa ', 'Load of POM ' , 'kg m-2 ', '', 'atmosphere_mass_content_of_particulate_organic_matter_dry_aerosol' )
  718. mixf(region)%f2d(loadbc )%mf = metafields( -1 , 'loadbc ', 'Load of BC ' , 'kg m-2 ', '', 'atmosphere_mass_content_of_black_carbon_dry_aerosol' )
  719. mixf(region)%f2d(loadso4 )%mf = metafields( -1 , 'loadso4 ', 'Load of SO4 ' , 'kg m-2 ', '', 'atmosphere_mass_content_of_sulfate_dry_aerosol' )
  720. mixf(region)%f2d(loaddust )%mf = metafields( -1 , 'loaddust ', 'Load of Dust ' , 'kg m-2 ', '', 'atmosphere_mass_content_of_dust_dry_aerosol' )
  721. mixf(region)%f2d(loadss )%mf = metafields( -1 , 'loadss ', 'Load of SS ' , 'kg m-2 ', '', 'atmosphere_mass_content_of_seasalt_dry_aerosol' )
  722. mixf(region)%f2d(loadno3 )%mf = metafields( -1 , 'loadno3 ', 'Load of NO3 ' , 'kg m-2 ', '', 'atmosphere_mass_content_of_nitrate_dry_aerosol' )
  723. mixf(region)%f2d(emioa )%mf = metafields( -1 , 'emioa ', 'Total Emission of POM ' , 'kg m-2 s-1', 'up', 'tendency_of_atmosphere_mass_content_of_primary_particulate_organic_matter_dry_aerosol_due_to_emission' )
  724. mixf(region)%f2d(emibc )%mf = metafields( -1 , 'emibc ', 'Total Emission of BC ' , 'kg m-2 s-1', 'up', 'tendency_of_atmosphere_mass_content_of_black_carbon_dry_aerosol_due_to_emission' )
  725. mixf(region)%f2d(emiso2 )%mf = metafields( -1 , 'emiso2 ', 'Total Emission of SO2 ' , 'kg m-2 s-1', 'up', 'tendency_of_atmosphere_mass_content_of_sulfur_dioxide_due_to_emission' )
  726. mixf(region)%f2d(emiso4 )%mf = metafields( -1 , 'emiso4 ', 'Total Direct Emission of SO4 ' , 'kg m-2 s-1', 'up', 'tendency_of_atmosphere_mass_content_of_sulfate_dry_aerosol_due_to_emission' )
  727. mixf(region)%f2d(emidust )%mf = metafields( -1 , 'emidust ', 'Total Emission of Dust ' , 'kg m-2 s-1', 'up', 'tendency_of_atmosphere_mass_content_of_dust_dry_aerosol_due_to_emission' )
  728. mixf(region)%f2d(emidms )%mf = metafields( -1 , 'emidms ', 'Total Emission of DMS ' , 'kg m-2 s-1', 'up', 'tendency_of_atmosphere_mass_content_of_dimethyl_sulfide_due_to_emission' )
  729. mixf(region)%f2d(emiss )%mf = metafields( -1 , 'emiss ', 'Total Emission of SeaSalt ' , 'kg m-2 s-1', 'up', 'tendency_of_atmosphere_mass_content_of_seasalt_dry_aerosol_due_to_emission' )
  730. mixf(region)%f2d(dryso2 )%mf = metafields( -1 , 'dryso2 ', 'Dry Deposition of SO2 ' , 'kg m-2 s-1', 'down', 'tendency_of_atmosphere_mass_content_of_sulfur_dioxide_due_to_dry_deposition' )
  731. mixf(region)%f2d(dryoa )%mf = metafields( -1 , 'dryoa ', 'Dry Deposition of POM ' , 'kg m-2 s-1', 'down', &
  732. 'tendency_of_atmosphere_mass_content_of_primary_particulate_organic_matter_dry_aerosol_due_to_dry_deposition' )
  733. mixf(region)%f2d(drybc )%mf = metafields( -1 , 'drybc ', 'Dry Deposition of BC ' , 'kg m-2 s-1', 'down', 'tendency_of_atmosphere_mass_content_of_black_carbon_dry_aerosol_due_to_dry_deposition' )
  734. mixf(region)%f2d(dryso4 )%mf = metafields( -1 , 'dryso4 ', 'Dry Deposition of SO4 ' , 'kg m-2 s-1', 'down', 'tendency_of_atmosphere_mass_content_of_sulfate_dry_aerosol_due_to_dry_deposition' )
  735. mixf(region)%f2d(drydust )%mf = metafields( -1 , 'drydust ', 'Dry Deposition of Dust ' , 'kg m-2 s-1', 'down', 'tendency_of_atmosphere_mass_content_of_dust_dry_aerosol_due_to_dry_deposition' )
  736. mixf(region)%f2d(drydms )%mf = metafields( -1 , 'drydms ', 'Dry Deposition of DMS ' , 'kg m-2 s-1', 'down', 'tendency_of_atmosphere_mass_content_of_dimethyl_sulfide_due_to_dry_deposition' )
  737. mixf(region)%f2d(dryss )%mf = metafields( -1 , 'dryss ', 'Dry Deposition of SeaSalt ' , 'kg m-2 s-1', 'down', 'tendency_of_atmosphere_mass_content_of_seasalt_dry_aerosol_due_to_dry_deposition' )
  738. mixf(region)%f2d(wetoa )%mf = metafields( -1 , 'wetoa ', 'Wet Deposition of POM ' , 'kg m-2 s-1', 'down', 'tendency_of_atmosphere_mass_content_of_particulate_organic_matter_dry_aerosol_due_to_wet_deposition' )
  739. mixf(region)%f2d(wetbc )%mf = metafields( -1 , 'wetbc ', 'Wet Deposition of BC ' , 'kg m-2 s-1', 'down', 'tendency_of_atmosphere_mass_content_of_black_carbon_dry_aerosol_due_to_wet_deposition' )
  740. mixf(region)%f2d(wetso2 )%mf = metafields( -1 , 'wetso2 ', 'Wet Deposition of SO2 ' , 'kg m-2 s-1', 'down', 'tendency_of_atmosphere_mass_content_of_sulfur_dioxide_due_to_wet_deposition' )
  741. mixf(region)%f2d(wetso4 )%mf = metafields( -1 , 'wetso4 ', 'Wet Deposition of SO4 ' , 'kg m-2 s-1', 'down', 'tendency_of_atmosphere_mass_content_of_sulfate_dry_aerosol_due_to_wet_deposition' )
  742. mixf(region)%f2d(wetdust )%mf = metafields( -1 , 'wetdust ', 'Wet Deposition of Dust ' , 'kg m-2 s-1', 'down', 'tendency_of_atmosphere_mass_content_of_dust_dry_aerosol_due_to_wet_deposition' )
  743. mixf(region)%f2d(wetdms )%mf = metafields( -1 , 'wetdms ', 'Wet Deposition of DMS ' , 'kg m-2 s-1', 'down', 'tendency_of_atmosphere_mass_content_of_dimethyl_sulfide_due_to_wet_deposition' )
  744. mixf(region)%f2d(wetss )%mf = metafields( -1 , 'wetss ', 'Wet Deposition of Seasalt ' , 'kg m-2 s-1', 'down', 'tendency_of_atmosphere_mass_content_of_seasalt_dry_aerosol_due_to_wet_deposition' )
  745. mixf(region)%f2d(od550aer )%mf = metafields( -1 , 'od550aer ', 'AOD@550nm ' , '1 ', '', 'atmosphere_optical_thickness_due_to_ambient_aerosol' )
  746. mixf(region)%f2d(od550so4 )%mf = metafields( -1 , 'od550so4 ', 'SO4 AOD@550nm ' , '1 ', '', 'atmosphere_optical_thickness_due_to_sulfate_ambient_aerosol' )
  747. mixf(region)%f2d(od550bc )%mf = metafields( -1 , 'od550bc ', 'Black Carbon AOD@550nm ' , '1 ', '', 'atmosphere_optical_thickness_due_to_black_carbon_ambient_aerosol' )
  748. mixf(region)%f2d(od550oa )%mf = metafields( -1 , 'od550oa ', 'POM AOD@550nm ' , '1 ', '', 'atmosphere_optical_thickness_due_to_particulate_organic_matter_ambient_aerosol' )
  749. mixf(region)%f2d(od550soa )%mf = metafields( -1 , 'od550soa ', 'SOA AOD@550nm ' , '1 ', '', 'atmosphere_optical_thickness_due_to_particulate_secondary_organic_aerosol_ambient_aerosol' )
  750. mixf(region)%f2d(od550ss )%mf = metafields( -1 , 'od550ss ', 'SeaSalt AOD@550nm ' , '1 ', '', 'atmosphere_optical_thickness_due_to_seasalt_ambient_aerosol' )
  751. mixf(region)%f2d(od550dust )%mf = metafields( -1 , 'od550dust ', 'Dust AOD@550nm ' , '1 ', '', 'atmosphere_optical_thickness_due_to_dust_ambient_aerosol' )
  752. mixf(region)%f2d(od550no3 )%mf = metafields( -1 , 'od550no3 ', 'Nitrate AOD@550nm ' , '1 ', '', 'atmosphere_optical_thickness_due_to_nitrate_ambient_aerosol' )
  753. mixf(region)%f2d(od550aerh2o )%mf = metafields( -1 , 'od550aerh2o ', 'Aerosol Water AOD@550nm ' , '1 ', '', 'atmosphere_optical_thickness_due_to_water_in_ambient_aerosol' )
  754. mixf(region)%f2d(od550lt1aer )%mf = metafields( -1 , 'od550lt1aer ', 'Fine Mode AOD@550nm ' , '1 ', '', 'atmosphere_optical_thickness_due_to_pm1_ambient_aerosol' )
  755. mixf(region)%f2d(od550lt1dust)%mf = metafields( -1 , 'od550lt1dust', 'Fine Mode Dust AOD@550nm ' , '1 ', '', 'atmosphere_optical_thickness_due_to_dust_pm1_ambient_aerosol' )
  756. mixf(region)%f2d(od550lt1ss)%mf = metafields( -1 , 'od550lt1ss ', 'Fine Mode SeaSalt AOD@550nm ' , '1 ', '', 'atmosphere_optical_thickness_due_to_seasalt_pm1_ambient_aerosol' )
  757. mixf(region)%f2d(abs550aer )%mf = metafields( -1 , 'abs550aer ', 'Absorption AOD@550nm ' , '1 ', '', 'atmosphere_absorption_optical_thickness_due_to_ambient_aerosol' )
  758. mixf(region)%f2d(asyaer )%mf = metafields( -1 , 'asyaer ', 'Asymmetry Parameter ' , '1 ', '', 'atmosphere_asymmetry_parameter_ambient_aerosol' )
  759. mixf(region)%f2d(ec550aer )%mf = metafields( -1 , 'ec550aer ', 'Surface Ambient Aerosol Extinction@550nm' , 'm-1 ', '', 'surface_extinction_due_to_ambient_aerosol' )
  760. mixf(region)%f2d(ec550dryaer )%mf = metafields( -1 , 'ec550dryaer ', 'Surface Dry Aerosol Extinction@550 nm','m-1 ', '', 'surface_extinction_due_to_dry_aerosol' )
  761. mixf(region)%f2d(abs550dryaer)%mf = metafields( -1 , 'abs550dryaer', 'Surface Dry Aerosol Absorption@550 nm','m-1 ', '', 'surface_absorption_due_to_dry_aerosol' )
  762. mixf(region)%f2d(asydryaer )%mf = metafields( -1 , 'asydryaer ', 'Surface Dry Aersol Asymmetry Parameter' , '1 ', '', 'surface_asymmetry_parameter_dry_aerosol' )
  763. mixf(region)%f2d(ec550drylt1aer )%mf = metafields( -1 , 'ec550drylt1aer ', 'Surface Fine Mode Dry Aerosol Extinction@550 nm' , 'm-1', '', 'surface_extinction_due_to_pm1_dry_aerosol' )
  764. mixf(region)%f2d(abs550drylt1aer)%mf = metafields( -1 , 'abs550drylt1aer', 'Surface Fine Mode Dry Aerosol Absorption@550 nm' , 'm-1', '', 'surface_absorption_due_to_pm1_dry_aerosol' )
  765. mixf(region)%f2d(od440aer )%mf = metafields( -1 , 'od440aer ', 'AOD@440nm ' , '1 ', '', 'atmosphere_optical_thickness_due_to_ambient_aerosol' )
  766. mixf(region)%f2d(abs440aer )%mf = metafields( -1 , 'abs440aer ', 'Absorption AOD@440nm ' , '1 ', '', 'atmosphere_absorption_optical_thickness_due_to_ambient_aerosol' )
  767. mixf(region)%f2d(ec440dryaer )%mf = metafields( -1 , 'ec440dryaer ', 'Surface Dry Aerosol Extinction@440nm' , 'm-1 ', '', 'surface_extinction_due_to_dry_aerosol' )
  768. mixf(region)%f2d(abs440dryaer)%mf = metafields( -1 , 'abs440dryaer', 'Surface Dry Aerosol Absorption@440nm' , 'm-1 ', '', 'surface_absorption_due_to_dry_aerosol' )
  769. mixf(region)%f2d(od870aer )%mf = metafields( -1 , 'od870aer ', 'AOD@870nm ' , '1 ', '', 'atmosphere_optical_thickness_due_to_ambient_aerosol' )
  770. mixf(region)%f2d(abs870aer )%mf = metafields( -1 , 'abs870aer ', 'Absorption AOD@870nm ' , '1 ', '', 'atmosphere_absorption_optical_thickness_due_to_ambient_aerosol' )
  771. mixf(region)%f2d(ec870dryaer )%mf = metafields( -1 , 'ec870dryaer ', 'Surface Dry Aerosol Extinction@870nm' , 'm-1 ', '', 'surface_extinction_due_to_dry_aerosol' )
  772. mixf(region)%f2d(abs870dryaer)%mf = metafields( -1 , 'abs870dryaer', 'Surface Dry Aerosol Absorption@870nm' , 'm-1 ', '', 'surface_absorption_due_to_dry_aerosol' )
  773. mixf(region)%f2d(od350aer )%mf = metafields( -1 , 'od350aer ', 'AOD@350nm ' , '1 ', '', 'atmosphere_optical_thickness_due_to_ambient_aerosol' )
  774. mixf(region)%f2d(abs350aer )%mf = metafields( -1 , 'abs350aer ', 'Absorption AOD@350nm ' , '1 ', '', 'atmosphere_absorption_optical_thickness_due_to_ambient_aerosol' )
  775. !!$
  776. !!$
  777. !!$ mixf(region)%f2d(52)%mf = metafields( 'od550soa ', 'AOD@550nm SOA ' , '1 ' )
  778. !!$ mixf(region)%f2d(53)%mf = metafields( 'od550bb ', 'AOD@550nm BB ' , '1 ' )
  779. !!$ mixf(region)%f2d(54)%mf = metafields( 'gf90aer ', 'GF @ 90 % RH ' , '1 ' )
  780. mixf(region)%f2d( tr2d_1)%mf = metafields( iso4nus, 'SO4NUS ', 'concentration of tracer 01' , 'kg m-3', '', 'concentration_of_tracer_dry_aerosol_in_air' )
  781. mixf(region)%f2d( tr2d_2)%mf = metafields( iso4ais, 'SO4AIS ', 'concentration of tracer 02' , 'kg m-3','', 'concentration_of_tracer_dry_aerosol_in_air' )
  782. mixf(region)%f2d( tr2d_3)%mf = metafields( iso4acs, 'SO4ACS ', 'concentration of tracer 03' , 'kg m-3','', 'concentration_of_tracer_dry_aerosol_in_air' )
  783. mixf(region)%f2d( tr2d_4)%mf = metafields( iso4cos, 'SO4COS ', 'concentration of tracer 04' , 'kg m-3','', 'concentration_of_tracer_dry_aerosol_in_air' )
  784. mixf(region)%f2d( tr2d_5)%mf = metafields( ibcais , 'BCAIS ', 'concentration of tracer 05' , 'kg m-3','', 'concentration_of_tracer_dry_aerosol_in_air' )
  785. mixf(region)%f2d( tr2d_6)%mf = metafields( ibcacs , 'BCACS ', 'concentration of tracer 06' , 'kg m-3','', 'concentration_of_tracer_dry_aerosol_in_air' )
  786. mixf(region)%f2d( tr2d_7)%mf = metafields( ibccos , 'BCCOS ', 'concentration of tracer 07' , 'kg m-3','', 'concentration_of_tracer_dry_aerosol_in_air' )
  787. mixf(region)%f2d( tr2d_8)%mf = metafields( ibcaii , 'BCAII ', 'concentration of tracer 08' , 'kg m-3','', 'concentration_of_tracer_dry_aerosol_in_air' )
  788. mixf(region)%f2d( tr2d_9)%mf = metafields( ipomais, 'POMAIS ', 'concentration of tracer 09' , 'kg m-3','', 'concentration_of_tracer_dry_aerosol_in_air' )
  789. mixf(region)%f2d(tr2d_10)%mf = metafields( ipomacs, 'POMACS ', 'concentration of tracer 10' , 'kg m-3','', 'concentration_of_tracer_dry_aerosol_in_air' )
  790. mixf(region)%f2d(tr2d_11)%mf = metafields( ipomcos, 'POMCOS ', 'concentration of tracer 11' , 'kg m-3','', 'concentration_of_tracer_dry_aerosol_in_air' )
  791. mixf(region)%f2d(tr2d_12)%mf = metafields( ipomaii, 'POMAII ', 'concentration of tracer 12' , 'kg m-3','', 'concentration_of_tracer_dry_aerosol_in_air' )
  792. mixf(region)%f2d(tr2d_13)%mf = metafields( issacs , 'SSACS ', 'concentration of tracer 13' , 'kg m-3','', 'concentration_of_tracer_dry_aerosol_in_air' )
  793. mixf(region)%f2d(tr2d_14)%mf = metafields( isscos , 'SSCOS ', 'concentration of tracer 14' , 'kg m-3','', 'concentration_of_tracer_dry_aerosol_in_air' )
  794. mixf(region)%f2d(tr2d_15)%mf = metafields( iduacs , 'DUACS ', 'concentration of tracer 15' , 'kg m-3','', 'concentration_of_tracer_dry_aerosol_in_air' )
  795. mixf(region)%f2d(tr2d_16)%mf = metafields( iducos , 'DUCOS ', 'concentration of tracer 16' , 'kg m-3','', 'concentration_of_tracer_dry_aerosol_in_air' )
  796. mixf(region)%f2d(tr2d_17)%mf = metafields( iduaci , 'DUACI ', 'concentration of tracer 17' , 'kg m-3','', 'concentration_of_tracer_dry_aerosol_in_air' )
  797. mixf(region)%f2d(tr2d_18)%mf = metafields( iducoi , 'DUCOI ', 'concentration of tracer 18' , 'kg m-3','', 'concentration_of_tracer_dry_aerosol_in_air' )
  798. mixf(region)%f2d(tr2d_19)%mf = metafields( isoanus, 'SOANUS ', 'concentration of tracer 19' , 'kg m-3','', 'concentration_of_tracer_dry_aerosol_in_air' )
  799. mixf(region)%f2d(tr2d_20)%mf = metafields( isoaais, 'SOAAIS ', 'concentration of tracer 20' , 'kg m-3','', 'concentration_of_tracer_dry_aerosol_in_air' )
  800. mixf(region)%f2d(tr2d_21)%mf = metafields( isoaacs, 'SOAACS ', 'concentration of tracer 21' , 'kg m-3','', 'concentration_of_tracer_dry_aerosol_in_air' )
  801. mixf(region)%f2d(tr2d_22)%mf = metafields( isoacos, 'SOACOS ', 'concentration of tracer 22' , 'kg m-3','', 'concentration_of_tracer_dry_aerosol_in_air' )
  802. mixf(region)%f2d(tr2d_23)%mf = metafields( isoaaii, 'SOAAII ', 'concentration of tracer 23' , 'kg m-3','', 'concentration_of_tracer_dry_aerosol_in_air' )
  803. !!$
  804. mixf(region)%f2d(cc01)%mf = metafields( inus_n , 'conc_NUS', 'number concentration of mode 01' , 'm-3' ,'', 'number_concentration_of_ambient_aerosol_in_air' )
  805. mixf(region)%f2d(cc02)%mf = metafields( iais_n , 'conc_AIS', 'number concentration of mode 02' , 'm-3' ,'', 'number_concentration_of_ambient_aerosol_in_air' )
  806. mixf(region)%f2d(cc03)%mf = metafields( iacs_n , 'conc_ACS', 'number concentration of mode 03' , 'm-3' ,'', 'number_concentration_of_ambient_aerosol_in_air' )
  807. mixf(region)%f2d(cc04)%mf = metafields( icos_n , 'conc_COS', 'number concentration of mode 04' , 'm-3' ,'', 'number_concentration_of_ambient_aerosol_in_air' )
  808. mixf(region)%f2d(cc05)%mf = metafields( iaii_n , 'conc_AII', 'number concentration of mode 05' , 'm-3' ,'', 'number_concentration_of_ambient_aerosol_in_air' )
  809. mixf(region)%f2d(cc06)%mf = metafields( iaci_n , 'conc_ACI', 'number concentration of mode 06' , 'm-3' ,'', 'number_concentration_of_ambient_aerosol_in_air' )
  810. mixf(region)%f2d(cc07)%mf = metafields( icoi_n , 'conc_COI', 'number concentration of mode 07' , 'm-3' ,'', 'number_concentration_of_ambient_aerosol_in_air' )
  811. mixf(region)%f2d(h2o1)%mf = metafields( -1 , 'aerh2o01 ', 'conc of aerosol water of mode 01' , 'kg m-3','', 'concentration_of_water_in_ambient_aerosol_in_air' )
  812. mixf(region)%f2d(h2o2)%mf = metafields( -1 , 'aerh2o02 ', 'conc of aerosol water of mode 02' , 'kg m-3','', 'concentration_of_water_in_ambient_aerosol_in_air' )
  813. mixf(region)%f2d(h2o3)%mf = metafields( -1 , 'aerh2o03 ', 'conc of aerosol water of mode 03' , 'kg m-3','', 'concentration_of_water_in_ambient_aerosol_in_air' )
  814. mixf(region)%f2d(h2o4)%mf = metafields( -1 , 'aerh2o04 ', 'conc of aerosol water of mode 04' , 'kg m-3','', 'concentration_of_water_in_ambient_aerosol_in_air' )
  815. mixf(region)%f2d(rw01)%mf = metafields( -1 , 'RWETnus ', 'rwet nus ' , 'm','', 'wet_radius' )
  816. mixf(region)%f2d(rw02)%mf = metafields( -1 , 'RWETais ', 'rwet ais ' , 'm','', 'wet_radius' )
  817. mixf(region)%f2d(rw03)%mf = metafields( -1 , 'RWETacs ', 'rwet acs ' , 'm','', 'wet_radius' )
  818. mixf(region)%f2d(rw04)%mf = metafields( -1 , 'RWETcos ', 'rwet cos ' , 'm','', 'wet_radius' )
  819. mixf(region)%f2d(rw05)%mf = metafields( -1 , 'RWETaii ', 'rwet aii ' , 'm','', 'wet_radius' )
  820. mixf(region)%f2d(rw06)%mf = metafields( -1 , 'RWETaci ', 'rwet aci ' , 'm','', 'wet_radius' )
  821. mixf(region)%f2d(rw07)%mf = metafields( -1 , 'RWETcoi ', 'rwet coi ' , 'm','', 'wet_radius' )
  822. mixf(region)%f2d(rd01)%mf = metafields( -1 , 'RDRYnus ', 'rdry nus ' , 'm','', 'dry radius' )
  823. mixf(region)%f2d(rd02)%mf = metafields( -1 , 'RDRYais ', 'rdry ais ' , 'm','', 'dry radius' )
  824. mixf(region)%f2d(rd03)%mf = metafields( -1 , 'RDRYacs ', 'rdry acs ' , 'm','', 'dry radius' )
  825. mixf(region)%f2d(rd04)%mf = metafields( -1 , 'RDRYcos ', 'rdry cos ' , 'm','', 'dry radius' )
  826. mixf(region)%f2d(emiterp)%mf = metafields( -1 , 'emiterp ', 'emiterp ' , 'kgm-2s-1','', 'emission_of_terpene' )
  827. mixf(region)%f2d(emiisop)%mf = metafields( -1 , 'emiisop ', 'emiisop ' , 'kgm-2s-1','', 'emission_of_isoprene' )
  828. !!$ mixf(region)%f2d(rd05)%mf = metafields( -1 , 'RDRYaii ', 'rdry ' , 'm','', 'precipitation_flux' )
  829. !!$ mixf(region)%f2d(rd06)%mf = metafields( -1 , 'RDRYaci ', 'rdry ' , 'm','', 'precipitation_flux' )
  830. !!$ mixf(region)%f2d(rd07)%mf = metafields( -1 , 'RDRYcoi ', 'rdry ' , 'm','', 'precipitation_flux' )
  831. !!$ !mixf(region)%f2d(31)%mf = metafields( ino3_a , 'mmrno3_a ', 'mmr of nitrate aerosol' , 'kg m-3', 'mass_fraction_of_nitrate_dry_aerosol_in_air' )
  832. !!$ !mixf(region)%f2d(32)%mf = metafields( inh4 , 'mmrnh4 ', 'mmr of ammonium' , 'kg m-3', 'mass_fraction_of_ammonium_dry_aerosol_in_air' )
  833. !!$ !mixf(region)%f2d(33)%mf = metafields( imsa , 'mmrmsa ', 'mmr of methane sulfonic acid' , 'kg m-3', 'mass_fraction_of_methane_sulfonic_acid_in_air' )
  834. mixf(region)%f2d(sconcsoa )%mf = metafields( -1 , 'sconcsoa ', 'Surface Concentration SOA ' , 'kg m-3 ', '', 'mass_concentration_of_secondary_particulate_organic_matter_dry_aerosol_in_air' )
  835. mixf(region)%f2d(loadsoa )%mf = metafields( -1 , 'loadsoa ', 'Load of SOA ' , 'kg m-2 ', '', 'atmosphere_mass_content_of_secondary_particulate_organic_matter_dry_aerosol' )
  836. mixf(region)%f2d(drysoa )%mf = metafields( -1 , 'drysoa ', 'Dry Deposition of SOA ' , 'kg m-2 s-1', 'down', &
  837. 'tendency_of_atmosphere_mass_content_of_secondary_particulate_organic_matter_dry_aerosol_due_to_dry_deposition' )
  838. mixf(region)%f2d(wetsoa )%mf = metafields( -1, 'wetsoa ', 'Wet Deposition of SOA ', 'kg m-2 s-1', 'down', 'tendency_of_atmosphere_mass_content_of_secondary_particulate_organic_matter_dry_aerosol_due_to_wet_deposition')
  839. mixf(region)%f2d(p_svoc2d )%mf = metafields( -1, 'p_svoc2D ', 'Column integral of SVOC production ', 'kg m-2 s-1', 'down', 'tendency_of_atmosphere_mass_content_of_secondary_particulate_organic_matter_dry_aerosol_due_to_wet_deposition')
  840. mixf(region)%f2d(p_elvoc2d )%mf = metafields( -1, 'p_elvoc2D ', 'Column integral of ELVOC production ', 'kg m-2 s-1', 'down', 'tendency_of_atmosphere_mass_content_of_secondary_particulate_organic_matter_dry_aerosol_due_to_wet_deposition')
  841. mixf(region)%f2d(p_gas_so42d)%mf = metafields( -1, 'prod_gas_so42D ', 'Column integral of gas SO4 production', 'kg m-2 s-1', 'down', 'tendency_of_atmosphere_mass_content_of_gas_phase_sulfate' )
  842. mixf(region)%f2d(p_liq_so42d)%mf = metafields( -1, 'prod_liq_so42D ', 'Column integral of liq SO4 production', 'kg m-2 s-1', 'down', 'tendency_of_atmosphere_mass_content_of_liquid_phase_sulfate' )
  843. ! set global dimensions of fields for netcdf definitions
  844. mixf (region)%nlon = imr
  845. mixf (region)%nlat = jmr
  846. mixf (region)%nlev = lmr
  847. !allocate space for lon, lat, lev information
  848. allocate(mixf (region)%lon(imr))
  849. allocate(mixf (region)%lat(jmr))
  850. allocate(mixf (region)%lev(lmr))
  851. ! save the lat and lon data for use in output
  852. mixf (region)%lat=global_lli(region)%lat_deg
  853. mixf (region)%lon=global_lli(region)%lon_deg
  854. mixf (region)%lev=(/1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34/)
  855. ! intermediate structures for budgets
  856. allocate(drydepos(region)%f2dslast(i1:i2,j1:j2,8))
  857. allocate(wetdepos(region)%f2dslast(i1:i2,j1:j2,8))
  858. allocate(emission(region)%f2dslast(i1:i2,j1:j2,9))! pom, bc, su, so2, dms, ss, dust, terp, isop
  859. ! these here are the initial budgets (monthly): 0.0
  860. drydepos(region)%f2dslast = 0.0
  861. wetdepos(region)%f2dslast = 0.0
  862. emission(region)%f2dslast = 0.0
  863. endif ! newsrun
  864. ! reset counters and accumulators
  865. mixf (region)%acct = 0
  866. do i = 1, ntracer_3d
  867. mixf(region)%f3d(i)%field = 0.0
  868. end do
  869. do i = 1, ntracer_2d
  870. mixf(region)%f2d(i)%field = 0.0
  871. end do
  872. ! ----------------
  873. ! open NetCDF file (mixf)
  874. ! ----------------
  875. call tau2date(itau,idater)
  876. ! time (in days since 2001-01-01 00:00)
  877. !Change to from beginning of a run (idatei)
  878. !time_reftime6=sdate_simulation
  879. call date2tau( time_reftime6, itauref )
  880. select case (trim(gen_freq))
  881. case ('hourly')
  882. write(idates, '(i4,3i2.2)') idater(1), idater(2), idater(3), idater(4)+1
  883. !write(idates, '(i4,2i2.2)') idater(1), idater(2), idater(3)
  884. write(lidates, '(i4,"-",i2.2,"-",i2.2," ",i2.2,":30")') idater(1), idater(2), idater(3), idater(4)
  885. idater(5:6) = (/30,0/)
  886. case ('daily')
  887. write(idates, '(i4,2i2.2)') idater(1), idater(2), idater(3)
  888. write(lidates, '(i4,"-",i2.2,"-",i2.2," 12:00")') idater(1), idater(2), idater(3)
  889. ! set noon (recommendations)
  890. idater(4:6) = (/12,0,0/)
  891. case ('monthly')
  892. ! for monthly files, set time to middle of the month
  893. write(idates, '(i4,i2.2)') idater(1), idater(2)
  894. mlength=mlen(idater(2))
  895. if ( mod(mlength,2) == 0 ) then
  896. idater(3:6) = (/mlength/2 + 1,0,0,0/)
  897. write(lidates, '(i4,"-",i2.2,"-",i2.2," 00:00")') idater(1), idater(2), idater(3)
  898. else
  899. idater(3:6) = (/(mlength+1)/2,12,0,0/)
  900. write(lidates, '(i4,"-",i2.2,"-",i2.2," 12:00")') idater(1), idater(2), idater(3)
  901. endif
  902. case default
  903. write (gol,'("Unknown General output frequency;")'); call goErr
  904. end select
  905. call date2tau( idater, itaucur )
  906. !move the timestamp in middle of the average period
  907. if (trim(gen_freq)=='hourly') then
  908. ! if average period is hour move the timestamp 30 min back
  909. time_shift=30*60
  910. else if (trim(gen_freq)=='daily') then
  911. ! if average period is hour move the timestamp 30 min back
  912. time_shift = 12*60*60
  913. else if (trim(gen_freq)=='monthly') then
  914. ! assume 30 day months
  915. time_shift=15*60*60*24
  916. end if
  917. reftime = (itaucur - itauref + time_shift) / 3600.00 !86400.
  918. !call date2tau(
  919. !WRITE(str_reftime,'("days since ",i4,"-",i2,"-",i2," ",i2,":",i2)') idatei(1),idatei(2),idatei(3),idatei(4),idatei(5)
  920. !WRITE(str_reftime,'("hours since ",i4,"-",i2,"-",i2," ",i2,":",i2)') idatei(1),idatei(2),idatei(3),idatei(4),idatei(5)
  921. str_reftime=time_units
  922. ! Changed file name convention to General Control 2015
  923. mixf(region)%fname = trim(outdir)//'/'//&
  924. trim(f_dataid)//'_'//&
  925. trim(f_model) //'_'//&
  926. trim(gen_exper)//'_'//&
  927. trim(idates) //'_'//&
  928. trim(gen_freq) //'.nc'
  929. #ifdef MPI
  930. ! overwrite existing files (clobber), provide MPI stuff:
  931. call MDF_Create( mixf(region)%fname, MDF_NETCDF4, MDF_REPLACE, mixf(region)%funit, status, &
  932. mpi_comm=localComm, mpi_info=MPI_INFO_NULL )
  933. if (status/=0) then
  934. write (gol,'("from creating NetCDF4 file for writing in parallel;")'); call goErr
  935. write (gol,'("MDF module not compiled with netcdf4_par support ?")'); call goErr
  936. TRACEBACK; status=1; return
  937. end if
  938. #else
  939. ! overwrite existing files (clobber)
  940. call MDF_Create( mixf(region)%fname, MDF_NETCDF4, MDF_REPLACE, mixf(region)%funit, status )
  941. IF_NOTOK_RETURN(status=1)
  942. #endif
  943. if(okdebug) then
  944. write(gol,*) 'output_general_init: File ', trim(mixf(region)%fname), ' opened ' ; call goPr
  945. endif
  946. ! global attributes
  947. call MDF_Put_Att( mixf(region)%funit, MDF_GLOBAL, 'title', 'Model output for BACCHUS', status )
  948. IF_NOTOK_MDF(fid=mixf(region)%funit)
  949. call MDF_Put_Att( mixf(region)%funit, MDF_GLOBAL, 'source', 'TM5-MP revision xxx in SVN repository, including SOA description', status )
  950. IF_NOTOK_MDF(fid=mixf(region)%funit)
  951. call MDF_Put_Att( mixf(region)%funit, MDF_GLOBAL, 'institution', 'Royal Netherlands Meteorological Institute (KNMI), De Bilt, The Netherlands)', status )
  952. IF_NOTOK_MDF(fid=mixf(region)%funit)
  953. call MDF_Put_Att( mixf(region)%funit, MDF_GLOBAL, 'contact' , 'Tommi Bergman: tommi.bergman@knmi.nl ; Twan van Noije; noije@knmi.nl', status )
  954. IF_NOTOK_MDF(fid=mixf(region)%funit)
  955. call MDF_Put_Att( mixf(region)%funit, MDF_GLOBAL, 'project_id', 'BACCHUS', status )
  956. IF_NOTOK_MDF(fid=mixf(region)%funit)
  957. call MDF_Put_Att( mixf(region)%funit, MDF_GLOBAL, 'conventions', 'CF-1.0 - HTAP', status )
  958. IF_NOTOK_MDF(fid=mixf(region)%funit)
  959. call MDF_Put_Att( mixf(region)%funit, MDF_GLOBAL, 'date', lidates, status )
  960. IF_NOTOK_MDF(fid=mixf(region)%funit)
  961. call MDF_Put_Att( mixf(region)%funit, MDF_GLOBAL, 'time_units', time_units, status )
  962. IF_NOTOK_MDF(fid=mixf(region)%funit)
  963. call MDF_Put_Att( mixf(region)%funit, MDF_GLOBAL, 'references', 'http://tm5.sourceforge.net/', status )
  964. IF_NOTOK_MDF(fid=mixf(region)%funit)
  965. ! define dimensions
  966. call MDF_Def_Dim( mixf(region)%funit, 'lon', imr, lon_dimid, status )
  967. IF_NOTOK_MDF(fid=mixf(region)%funit)
  968. call MDF_Def_Dim( mixf(region)%funit, 'lat', jmr, lat_dimid, status )
  969. IF_NOTOK_MDF(fid=mixf(region)%funit)
  970. !write(3000,*)lmr
  971. call MDF_Def_Dim( mixf(region)%funit, 'lev', 34, lev_dimid, status )
  972. IF_NOTOK_MDF(fid=mixf(region)%funit)
  973. !Unlimited time causes a crash in the parallel NETCDF, when unlimited dimension is increased in the file
  974. !4.4.0 may correct this, but for now netcdf v4.4.0 on cca is not working
  975. call MDF_Def_Dim( mixf(region)%funit, 'time', 1, mixf(region)%timeid, status )
  976. IF_NOTOK_MDF(fid=mixf(region)%funit)
  977. ! define dimension variables
  978. ! longitude
  979. call MDF_Def_Var( mixf(region)%funit, 'lon', MDF_DOUBLE, &
  980. (/lon_dimid/), mixf(region)%lonid, status )
  981. IF_NOTOK_MDF(fid=mixf(region)%funit)
  982. call MDF_Put_Att( mixf(region)%funit,mixf(region)%lonid , 'units', 'degrees_east', status)
  983. IF_NOTOK_MDF(fid=mixf(region)%funit)
  984. call MDF_Put_Att( mixf(region)%funit,mixf(region)%lonid , 'axis', 'X', status)
  985. IF_NOTOK_MDF(fid=mixf(region)%funit)
  986. call MDF_Put_Att( mixf(region)%funit,mixf(region)%lonid , 'long_name', 'longitude', status)
  987. IF_NOTOK_MDF(fid=mixf(region)%funit)
  988. call MDF_Put_Att( mixf(region)%funit,mixf(region)%lonid , 'standard_name', 'longitude', status)
  989. IF_NOTOK_MDF(fid=mixf(region)%funit)
  990. ! Write out the longitudes
  991. call MDF_Put_Var( mixf(region)%funit, mixf(region)%lonid, mixf(region)%lon, status)
  992. IF_NOTOK_MDF(fid=mixf(region)%funit)
  993. ! define latitude variable
  994. call MDF_Def_Var( mixf(region)%funit, 'lat', MDF_DOUBLE, &
  995. (/lat_dimid/), mixf(region)%latid, status )
  996. IF_NOTOK_MDF(fid=mixf(region)%funit)
  997. !write out the latitude to variable
  998. call MDF_Put_Var( mixf(region)%funit, mixf(region)%latid, mixf(region)%lat, status)
  999. IF_NOTOK_MDF(fid=mixf(region)%funit)
  1000. call MDF_Put_Att( mixf(region)%funit,mixf(region)%latid , 'units', 'degrees_north', status)
  1001. IF_NOTOK_MDF(fid=mixf(region)%funit)
  1002. call MDF_Put_Att( mixf(region)%funit,mixf(region)%latid , 'axis', 'Y', status)
  1003. IF_NOTOK_MDF(fid=mixf(region)%funit)
  1004. call MDF_Put_Att( mixf(region)%funit,mixf(region)%latid , 'long_name', 'latitude', status)
  1005. IF_NOTOK_MDF(fid=mixf(region)%funit)
  1006. call MDF_Put_Att( mixf(region)%funit,mixf(region)%latid , 'standard_name', 'latitude', status)
  1007. IF_NOTOK_MDF(fid=mixf(region)%funit)
  1008. ! lev
  1009. call MDF_Def_Var( mixf(region)%funit, 'lev' , MDF_DOUBLE, &
  1010. (/lev_dimid/), mixf(region)%levid, status )
  1011. IF_NOTOK_MDF(fid=mixf(region)%funit)
  1012. !call MDF_Put_Var( mixf(region)%funit, mixf(region)%levid, (/1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34/), status)
  1013. call MDF_Put_Var( mixf(region)%funit, mixf(region)%levid, mixf(region)%lev, status)
  1014. IF_NOTOK_MDF(fid=mixf(region)%funit)
  1015. ! time
  1016. call MDF_Def_Var( mixf(region)%funit, 'time', MDF_DOUBLE, &
  1017. (/mixf(region)%timeid/), mixf(region)%time_varid, status )
  1018. IF_NOTOK_MDF(fid=mixf(region)%funit)
  1019. call MDF_Put_Att( mixf(region)%funit,mixf(region)%time_varid , 'units', str_reftime, status)
  1020. IF_NOTOK_MDF(fid=mixf(region)%funit)
  1021. !call MDF_Put_Att( mixf(region)%funit,mixf(region)%timeid , 'long_name', 'time', status)
  1022. !IF_NOTOK_MDF(fid=mixf(region)%funit)
  1023. call MDF_Put_Att( mixf(region)%funit,mixf(region)%time_varid , 'standard_name', 'time', status)
  1024. IF_NOTOK_MDF(fid=mixf(region)%funit)
  1025. ! define variables
  1026. !do i = 1, ntrace!r_3d
  1027. do i = 1, n_3d_vars!ntracer_3d
  1028. !write(1234,*)i,trim(mixf(region)%f3d(i)%mf%vname)
  1029. call MDF_Def_Var( mixf(region)%funit, trim(mixf(region)%f3d(i)%mf%vname), MDF_FLOAT, &
  1030. (/mixf(region)%lonid, mixf(region)%latid, mixf(region)%levid, mixf(region)%timeid/), varid, status )
  1031. IF_NOTOK_MDF(fid=mixf(region)%funit)
  1032. call MDF_Var_Par_Access( mixf(region)%funit, varid, access_mode, status )
  1033. IF_NOTOK_MDF(fid=mixf(region)%funit)
  1034. call MDF_Put_Att( mixf(region)%funit, varid, 'long_name', trim(mixf(region)%f3d(i)%mf%lname), status )
  1035. IF_NOTOK_MDF(fid=mixf(region)%funit)
  1036. call MDF_Put_Att( mixf(region)%funit, varid, 'standard_name', trim(mixf(region)%f3d(i)%mf%standard_name), status )
  1037. IF_NOTOK_MDF(fid=mixf(region)%funit)
  1038. call MDF_Put_Att( mixf(region)%funit, varid, 'units', trim(mixf(region)%f3d(i)%mf%unit), status )
  1039. IF_NOTOK_MDF(fid=mixf(region)%funit)
  1040. ! call MDF_Put_Att( mixf(region)%funit, varid, 'time', reftime, status )
  1041. ! IF_NOTOK_MDF(fid=mixf(region)%funit)
  1042. call MDF_Put_Att( mixf(region)%funit, varid, 'cell_methods', 'time: mean', status )
  1043. IF_NOTOK_MDF(fid=mixf(region)%funit)
  1044. if( mixf(region)%f3d(i)%mf%positive /= '' ) then
  1045. call MDF_Put_Att( mixf(region)%funit, varid, 'positive', trim(mixf(region)%f3d(i)%mf%positive), status )
  1046. IF_NOTOK_MDF(fid=mixf(region)%funit)
  1047. end if
  1048. mixf(region)%f3d(i)%varid = varid
  1049. end do
  1050. do i = 1, ntracer_2d
  1051. ! write(1234,*)i,trim(mixf(region)%f2d(i)%mf%vname)
  1052. call MDF_Def_Var( mixf(region)%funit, trim(mixf(region)%f2d(i)%mf%vname), MDF_FLOAT, &
  1053. (/mixf(region)%lonid, mixf(region)%latid, mixf(region)%timeid/), varid, status )
  1054. IF_NOTOK_MDF(fid=mixf(region)%funit)
  1055. call MDF_Var_Par_Access( mixf(region)%funit, varid, access_mode, status )
  1056. IF_NOTOK_MDF(fid=mixf(region)%funit)
  1057. call MDF_Put_Att( mixf(region)%funit, varid, 'long_name', trim(mixf(region)%f2d(i)%mf%lname), status )
  1058. IF_NOTOK_MDF(fid=mixf(region)%funit)
  1059. call MDF_Put_Att( mixf(region)%funit, varid, 'standard_name', trim(mixf(region)%f2d(i)%mf%standard_name), status )
  1060. IF_NOTOK_MDF(fid=mixf(region)%funit)
  1061. call MDF_Put_Att( mixf(region)%funit, varid, 'units', trim(mixf(region)%f2d(i)%mf%unit), status )
  1062. IF_NOTOK_MDF(fid=mixf(region)%funit)
  1063. ! call MDF_Put_Att( mixf(region)%funit, varid, 'time', reftime, status )
  1064. ! IF_NOTOK_MDF(fid=mixf(region)%funit)
  1065. call MDF_Put_Att( mixf(region)%funit, varid, 'cell_methods', 'time: mean', status )
  1066. IF_NOTOK_MDF(fid=mixf(region)%funit)
  1067. if( mixf(region)%f2d(i)%mf%positive /= '' ) then
  1068. call MDF_Put_Att( mixf(region)%funit, varid, 'positive', trim(mixf(region)%f2d(i)%mf%positive), status )
  1069. IF_NOTOK_MDF(fid=mixf(region)%funit)
  1070. end if
  1071. mixf(region)%f2d(i)%varid = varid
  1072. end do
  1073. call MDF_Def_Dim( mixf(region)%funit, 'kappa', 1, kappa_dimid, status )
  1074. IF_NOTOK_MDF(fid=mixf(region)%funit)
  1075. call MDF_Def_Var( mixf(region)%funit, 'year', MDF_FLOAT, &
  1076. (/kappa_dimid/),year_varid, status )
  1077. call MDF_Def_Var( mixf(region)%funit, 'month', MDF_FLOAT, &
  1078. (/kappa_dimid/),month_varid, status )
  1079. call MDF_Def_Var( mixf(region)%funit, 'kSO4', MDF_FLOAT, &
  1080. (/kappa_dimid/),kso4_varid, status )
  1081. !status = NF90_Def_Var( mixf(region)%funit, 'kSO4', MDF_FLOAT, &
  1082. ! kso4_varid )
  1083. call MDF_Def_Var( mixf(region)%funit, 'kPOM', MDF_FLOAT, &
  1084. (/kappa_dimid/), kpom_varid, status )
  1085. call MDF_Def_Var( mixf(region)%funit, 'kSOA', MDF_FLOAT, &
  1086. (/kappa_dimid/), ksoa_varid, status )
  1087. call MDF_Def_Var( mixf(region)%funit, 'kBC', MDF_FLOAT, &
  1088. (/kappa_dimid/), kbc_varid, status )
  1089. call MDF_Def_Var( mixf(region)%funit, 'kDU', MDF_FLOAT, &
  1090. (/kappa_dimid/), kdu_varid, status )
  1091. call MDF_Def_Var( mixf(region)%funit, 'kSS', MDF_FLOAT, &
  1092. (/kappa_dimid/), kss_varid, status )
  1093. call MDF_Def_Var( mixf(region)%funit, 'kNO3', MDF_FLOAT, &
  1094. (/kappa_dimid/), kno3_varid, status )
  1095. call MDF_Def_Var( mixf(region)%funit, 'kNa2SO4', MDF_FLOAT, &
  1096. (/kappa_dimid/), kna2so4_varid, status )
  1097. call MDF_Def_Var( mixf(region)%funit, 'kMSA', MDF_FLOAT, &
  1098. (/kappa_dimid/), kmsa_varid, status )
  1099. call MDF_EndDef( mixf(region)%funit, status )
  1100. IF_NOTOK_MDF(fid=mixf(region)%funit)
  1101. ! KAPPA values written only once
  1102. ! needed for BACCHUS intercomparison...
  1103. call MDF_Put_Var( mixf(region)%funit, year_varid, (/idater(1)/), status)
  1104. call MDF_Put_Var( mixf(region)%funit, month_varid, (/idater(2)/), status)
  1105. call MDF_Put_Var( mixf(region)%funit, kso4_varid, (/kap_su/), status)
  1106. !status= NF90_Put_Var( mixf(region)%funit, kso4_varid, kap_su)
  1107. !IF_NOTOK_MDF(fid=mixf(region)%funit)
  1108. call MDF_Put_Var( mixf(region)%funit, kpom_varid, (/kap_pom/), status)
  1109. IF_NOTOK_MDF(fid=mixf(region)%funit)
  1110. call MDF_Put_Var( mixf(region)%funit, kbc_varid, (/kap_bc/), status)
  1111. IF_NOTOK_MDF(fid=mixf(region)%funit)
  1112. call MDF_Put_Var( mixf(region)%funit, ksoa_varid, (/kap_soa/), status)
  1113. IF_NOTOK_MDF(fid=mixf(region)%funit)
  1114. call MDF_Put_Var( mixf(region)%funit, kss_varid, (/kap_ss/), status)
  1115. IF_NOTOK_MDF(fid=mixf(region)%funit)
  1116. call MDF_Put_Var( mixf(region)%funit, kdu_varid, (/kap_du/), status)
  1117. IF_NOTOK_MDF(fid=mixf(region)%funit)
  1118. call MDF_Put_Var( mixf(region)%funit, kno3_varid, (/kap_no3/), status)
  1119. IF_NOTOK_MDF(fid=mixf(region)%funit)
  1120. call MDF_Put_Var( mixf(region)%funit, kna2so4_varid, (/kap_na2so4/), status)
  1121. IF_NOTOK_MDF(fid=mixf(region)%funit)
  1122. call MDF_Put_Var( mixf(region)%funit, kmsa_varid, (/kap_msa/), status)
  1123. IF_NOTOK_MDF(fid=mixf(region)%funit)
  1124. end do regionloop ! nregions
  1125. call goLabel() ; status = 0
  1126. end subroutine output_general_init
  1127. !EOC
  1128. !--------------------------------------------------------------------------
  1129. ! TM5 !
  1130. !--------------------------------------------------------------------------
  1131. !BOP
  1132. !
  1133. ! !IROUTINE: OUTPUT_GENERAL_DONE
  1134. !
  1135. ! !DESCRIPTION: Free parameters.
  1136. !\\
  1137. !\\
  1138. ! !INTERFACE:
  1139. !
  1140. subroutine output_general_done(status, iregion)
  1141. !
  1142. ! !USES:
  1143. use chem_param, only : ntracet,ntrace
  1144. !
  1145. ! !INPUT PARAMETERS:
  1146. !
  1147. !logical, intent(in) :: stat_output ! true if stations output is requested
  1148. integer, intent(in), optional :: iregion
  1149. !
  1150. ! !OUTPUT PARAMETERS:
  1151. !
  1152. integer, intent(out) :: status
  1153. !
  1154. ! !REVISION HISTORY:
  1155. ! 29 Nov 2010 - Achim Strunk -
  1156. !
  1157. ! !REMARKS:
  1158. !
  1159. !EOP
  1160. !------------------------------------------------------------------------
  1161. !BOC
  1162. character(len=*), parameter :: rname = mname//'/output_general_done'
  1163. integer :: i, region
  1164. ! --- begin -------------------------------------
  1165. call goLabel(rname)
  1166. deallocate( wdep_out )
  1167. regionloop: do region = 1, nregions
  1168. ! if region given, cycle if other region!
  1169. if (present(iregion)) then
  1170. if(iregion /= region) cycle regionloop
  1171. endif
  1172. do i=1,ntracer_3d
  1173. deallocate( mixf(region)%f3d(i)%field )
  1174. end do
  1175. do i=1,ntracer_2d
  1176. deallocate( mixf(region)%f2d(i)%field )
  1177. end do
  1178. deallocate( gas_output)
  1179. deallocate( mixf (region)%f3d )
  1180. deallocate( mixf (region)%f2d )
  1181. deallocate( drydepos(region)%f2dslast )
  1182. deallocate( wetdepos(region)%f2dslast )
  1183. deallocate( emission(region)%f2dslast )
  1184. end do regionloop
  1185. if (nCCNdiag) then
  1186. deallocate(ind_CCN)
  1187. ! deallocate(N_rad)
  1188. ! deallocate(HG_rad)
  1189. end if
  1190. call goLabel() ; status = 0
  1191. end subroutine output_general_done
  1192. !EOC
  1193. !--------------------------------------------------------------------------
  1194. ! TM5 !
  1195. !--------------------------------------------------------------------------
  1196. !BOP
  1197. !
  1198. ! !IROUTINE: output_general_write
  1199. !
  1200. ! !DESCRIPTION: This routines builds the average by dividing accumulated
  1201. ! data by stack counter. The results are written to file.
  1202. !\\
  1203. !\\
  1204. ! !INTERFACE:
  1205. !
  1206. subroutine output_general_write(region, status)
  1207. !
  1208. ! !USES:
  1209. !
  1210. use chem_param, only : ntracet,ntrace
  1211. use dims,only:itau
  1212. use datetime, only : tau2date, date2tau
  1213. ! !INPUT PARAMETERS:
  1214. !
  1215. integer, intent(in) :: region
  1216. !logical, intent(in) :: stat_output ! true if stations output is requested
  1217. !
  1218. ! !OUTPUT PARAMETERS:
  1219. !
  1220. integer, intent(out) :: status
  1221. !
  1222. ! !REVISION HISTORY:
  1223. ! 29 Nov 2010 - Achim Strunk -
  1224. !
  1225. ! !REMARKS:
  1226. !
  1227. !EOP
  1228. !------------------------------------------------------------------------
  1229. !BOC
  1230. character(len=*), parameter :: rname = mname//'/output_general_write'
  1231. integer :: i, imr, jmr, lmr
  1232. integer :: i1, i2, j1, j2, ilev
  1233. integer :: istat
  1234. ! Time definitions for General
  1235. real :: reftime
  1236. integer :: itauref, time_shift
  1237. ! --- begin -------------------------------------
  1238. call goLabel(rname)
  1239. ! grid size
  1240. call Get_DistGrid( dgrid(region), I_STRT=i1, I_STOP=i2, J_STRT=j1, J_STOP=j2 )
  1241. imr = i2-i1+1
  1242. jmr = j2-j1+1
  1243. lmr = levi%nlev
  1244. ! this here is already accumulated over the time period (day)
  1245. call collect_budgets( region, status )
  1246. IF_NOTOK_RETURN(status=1)
  1247. ! ---------------------
  1248. ! divide by accumulator
  1249. ! ---------------------
  1250. do i = 1, n_3d_vars!ntracer_3d
  1251. mixf(region)%f3d(i)%field = mixf(region)%f3d(i)%field / real( mixf(region)%acct )
  1252. end do
  1253. do i = 1, ntracer_2d
  1254. mixf(region)%f2d(i)%field = mixf(region)%f2d(i)%field / real( mixf(region)%acct )
  1255. end do
  1256. select case (trim(gen_freq))
  1257. case ('hourly')
  1258. write(gol,'("---> GENERAL diagnostics: write file for previous hour")'); call goPr
  1259. case ('daily')
  1260. write(gol,'("---> GENERAL diagnostics: write file for previous day")'); call goPr
  1261. case ('monthly')
  1262. write(gol,'("---> GENERAL diagnostics: write file for previous month")'); call goPr
  1263. end select
  1264. ! -------------
  1265. ! write to file
  1266. ! -------------
  1267. ! Ncfile needs a timestep
  1268. ! define the reference time
  1269. ! time (for now in days since 2001-01-01 00:00)
  1270. call date2tau( time_reftime6, itauref )
  1271. ! calculate reftime as fractional days from itauref, hence division by 86400 (24h*3600s)
  1272. !call date2tau( idater, itaucur )
  1273. if (trim(gen_freq)=='hourly') then
  1274. ! if average period is hour move the timestamp 30 min forward because current itau is
  1275. ! at the beginning of the timestep
  1276. time_shift=30.0*60.0
  1277. else if (trim(gen_freq)=='daily') then
  1278. ! if average period is hour move the timestamp 30 min back
  1279. time_shift = 12*60*60
  1280. else if (trim(gen_freq)=='monthly') then
  1281. ! assume 30 day months
  1282. time_shift=15*60*60*24
  1283. end if
  1284. !reftime = (itau - itauref-time_shift) / 3600 !86400. in hours instead of days
  1285. reftime = (itau - itauref+time_shift) / 3600 !86400. in hours instead of days
  1286. !write (1111,*)reftime,itau,itauref,itau-itauref, itau-itauref-time_shift,time_shift
  1287. reftime =reftime-0.5
  1288. !reftime = (itau - itauref) / 86400.
  1289. !Add time stamp to current
  1290. !Currently only allows 1 step per file, needs to be extended
  1291. do i=1,ntracer_2d
  1292. call MDF_Put_Var( mixf(region)%funit, mixf(region)%f2d(i)%varid, mixf(region)%f2d(i)%field(i1:i2,j1:j2), status, start=(/i1,j1,1/), count=(/imr,jmr,1/) )
  1293. IF_NOTOK_MDF(fid=mixf(region)%funit)
  1294. end do
  1295. do i=1,n_3d_vars!ntracer_3d
  1296. !write(1111,*) mixf(region)%f3d(i)%mf%vname,imr,jmr,lmr, mixf(region)%nlev,mixf(region)%nlat,mixf(region)%nlon
  1297. call MDF_Put_Var( mixf(region)%funit, mixf(region)%f3d(i)%varid, mixf(region)%f3d(i)%field(i1:i2,j1:j2,1:lmr), status, start=(/i1,j1,1,1/), count=(/imr,jmr,lmr,1/) )
  1298. IF_NOTOK_MDF(fid=mixf(region)%funit)
  1299. end do
  1300. call MDF_Var_Par_Access( mixf(region)%funit, mixf(region)%time_varid, MDF_INDEPENDENT, status )
  1301. IF_NOTOK_MDF(fid=mixf(region)%funit)
  1302. ! Write current reftime
  1303. call MDF_Put_Var( mixf(region)%funit, mixf(region)%time_varid,(/reftime/), status, start=(/1/),count=(/1/))
  1304. IF_NOTOK_MDF(fid=mixf(region)%funit)
  1305. call MDF_Close( mixf(region)%funit, status )
  1306. IF_NOTOK_MDF(fid=mixf(region)%funit)
  1307. call goLabel() ; status = 0
  1308. end subroutine output_general_write
  1309. !EOC
  1310. !--------------------------------------------------------------------------
  1311. ! TM5 !
  1312. !--------------------------------------------------------------------------
  1313. !BOP
  1314. !
  1315. ! !IROUTINE: OUTPUT_GENERAL_STEP
  1316. !
  1317. ! !DESCRIPTION: This is the accumulation routine. It is called following
  1318. ! the user specification general.dhour in rc-file. It
  1319. ! evaluates the various diagnostics and does summing.
  1320. !\\
  1321. !\\
  1322. ! !INTERFACE:
  1323. !
  1324. subroutine output_general_step( region, dhour, status )
  1325. !
  1326. ! !USES:
  1327. !
  1328. use GO , only : TDate, NewDate, rTotal, operator(-), GO_Timer_Def, GO_Timer_End, GO_Timer_Start
  1329. use Grid , only : FPressure
  1330. use binas, only : rgas, rol,pi
  1331. use datetime, only : tau2date
  1332. use MeteoData, only : sp_dat, lsp_dat, cp_dat, m_dat
  1333. use MeteoData, only : temper_dat, humid_dat, gph_dat
  1334. use global_data, only : mass_dat, region_dat
  1335. use tracer_data, only : chem_dat
  1336. use dims, only : itaur
  1337. use chemistry, only : d_nucle, m_nucle_su, m_nucle_soa, growth1_2, coag_sink_nuc, cond1_soa, cond1_su
  1338. use chemistry, only : cond2_soa, cond3_soa, cond4_soa, cond5_soa
  1339. use chem_param, only : iso4acs, iso4cos, iduacs, iso4ais, ibccos, ibcaii, xmair
  1340. use chem_param, only : iso4nus, isscos, ino3_a, issacs, iducos, iduaci, nmod
  1341. use chem_param, only : iducoi, ibcacs, ipomcos, ipomaii, ibcais, ipomacs, ipomais,isoanus
  1342. use chem_param, only : isoaais, isoaacs, isoacos, isoaaii
  1343. use chem_param, only : imsa, inh4
  1344. use chem_param, only : inus_n,iacs_n,icos_n,iais_n,iaii_n,iaci_n,icoi_n
  1345. use chem_param, only : ntracet,ntrace,xms,xmso4,xmc,xmbc,xmpom
  1346. use chem_param, only : mode_end_pom,mode_end_so4,mode_end_ss,mode_end_bc,mode_end_dust,mode_end_soa
  1347. use mo_aero_m7, only : nsol,nmod,dnacl,doc,dh2so4,dbc,ddust
  1348. use optics, only : optics_aop_get
  1349. use m7_data, only : h2o_mode, rw_mode, rwd_mode
  1350. use ebischeme, only : diag_prod
  1351. use mo_aero_m7, only : cmedr2mmedr,sigma
  1352. !
  1353. ! !INPUT PARAMETERS:
  1354. !
  1355. integer, intent(in) :: region
  1356. integer, intent(in) :: dhour ! this is general.dhour [hours]
  1357. !logical, intent(in) :: stat_output ! true if stations output is requested
  1358. !
  1359. ! !OUTPUT PARAMETERS:
  1360. !
  1361. integer, intent(out) :: status
  1362. !
  1363. ! !REVISION HISTORY:
  1364. ! 29 Nov 2010 - Achim Strunk - Creation
  1365. !
  1366. ! !REMARKS:
  1367. !
  1368. !EOP
  1369. !------------------------------------------------------------------------
  1370. !BOC
  1371. character(len=*), parameter :: rname = mname//'/output_general_step'
  1372. ! MPI arrays to gather fields.
  1373. real, dimension(:,:,:,:), pointer :: rm, rmc
  1374. real, dimension(:,:,:), allocatable, target :: mg
  1375. real, dimension(:), pointer :: dxyp
  1376. real, dimension(:,:,:), allocatable :: pres3d
  1377. integer :: i, j, k, imr, jmr, lmr, lwl, dtime, iSat
  1378. integer :: i1, i2, j1, j2
  1379. integer :: ie, je ! indices for subdomain extended with halo cells
  1380. integer, parameter :: l_halo=1
  1381. logical :: polar
  1382. integer :: istat, imode
  1383. real :: dens, load_tmp
  1384. integer :: rwetcounter,h2ocounter,rdrycounter
  1385. Real, Dimension(:,:,:), Allocatable :: aop_output_ext ! extinctions
  1386. Real, Dimension(:,:), Allocatable :: aop_output_a ! single scattering albedo
  1387. Real, Dimension(:,:), Allocatable :: aop_output_g ! assymetry factor
  1388. Real, Dimension(:,:,:), Allocatable :: aop_output_add ! additional parameters
  1389. real, dimension(:,:,:,:,:), allocatable :: opt_ext
  1390. real, dimension(:,:,:,:), allocatable :: opt_a
  1391. real, dimension(:,:,:,:), allocatable :: opt_g
  1392. real, dimension(:,:,:,:,:), allocatable :: opt_add
  1393. real, dimension(:,:,:), allocatable :: volume
  1394. real, dimension(:,:), allocatable :: temp2d
  1395. real, dimension(:,:,:,:), allocatable :: CCN
  1396. real, dimension(:,:,:,:), allocatable :: dry_rad
  1397. real, dimension(:,:,:,:), allocatable :: Kappa_r
  1398. real, dimension(:,:,:,:), allocatable :: N_r
  1399. integer :: ncontr, lvec, lct, l, indoffset, nwl,nn,irw,irwd
  1400. integer :: nadd, nadd_max, indoffset_stat, indabs
  1401. integer :: iadd
  1402. real :: z,sizelimit,hr2,rad
  1403. real :: no3fac, wght, dwght, tabs
  1404. real,dimension(7) :: modfrac,lnsigma
  1405. integer,dimension(6) :: idate_f
  1406. type(TDate) :: t, t0
  1407. real :: time
  1408. real :: perm3_to_percm3,kg_to_ug
  1409. integer :: d_ind
  1410. ! --- begin -------------------------------
  1411. call goLabel(rname)
  1412. ! grid size
  1413. call Get_DistGrid( dgrid(region), I_STRT=i1, I_STOP=i2, J_STRT=j1, J_STOP=j2, hasNorthPole=polar )
  1414. imr = i2-i1+1
  1415. jmr = j2-j1+1
  1416. lmr = levi%nlev
  1417. ! link the datastructures for transported and non transported variables and
  1418. ! Gridbox area
  1419. nullify(rmc)
  1420. rmc => chem_dat(region)%rm
  1421. dxyp => region_dat(region)%dxyp
  1422. rm => mass_dat(region)%rm
  1423. ! get helping pressure field in 3d
  1424. ie=i2; je=j2
  1425. allocate( pres3d(i1:ie,j1:je,lmr) )
  1426. ! fill mid level pressure
  1427. call FPressure( levi, sp_dat(region)%data(i1:ie,j1:je,1), pres3d, status )
  1428. IF_NOTOK_RETURN(status=1)
  1429. allocate( CCN(nSat,i1:ie,j1:je,lmr))
  1430. allocate( dry_rad(nsol,i1:ie,j1:je,lmr))
  1431. allocate( Kappa_r(3,i1:ie,j1:je,lmr))
  1432. allocate( N_r(3,i1:ie,j1:je,lmr))
  1433. call CCN_Diag(CCN, rm(i1:ie,j1:je,1:lmr,1:ntracet), dry_rad, temper_dat(region)%data(i1:i2,j1:j2,1:lmr))
  1434. call Kappa_diag(CCN, rm(i1:ie,j1:je,1:lmr,1:ntracet), dry_rad, temper_dat(region)%data(i1:i2,j1:j2,1:lmr),N_r,Kappa_r)
  1435. ! dtime is seconds per step
  1436. ! dtime will be taken as weight for summing up
  1437. ! (makes it fit for varying step lengths)
  1438. dtime = dhour * 3600.
  1439. ! sum up for later averaging
  1440. mixf (region)%acct = mixf (region)%acct + dtime
  1441. ! ----------------------
  1442. ! 3D meteo fields
  1443. ! ----------------------
  1444. !temp=1
  1445. !hus=2
  1446. !airmass=3
  1447. !pressure=4
  1448. ! temperature
  1449. mixf(region)%f3d(temp)%field = mixf(region)%f3d(temp)%field + dtime * temper_dat(region)%data(i1:i2,j1:j2,:)
  1450. ! specific humidity
  1451. mixf(region)%f3d(hus)%field = mixf(region)%f3d(hus)%field + dtime * humid_dat(region)%data(i1:i2,j1:j2,:)
  1452. ! air mass (kg -> kg/m2)
  1453. do j = j1, j2
  1454. mixf(region)%f3d(airmass)%field(:,j,:) = mixf(region)%f3d(airmass)%field(:,j,:) + &
  1455. dtime * m_dat(region)%data(i1:i2,j,:) / dxyp(j)
  1456. end do
  1457. ! pressure (already filled above)
  1458. mixf(region)%f3d(pressure)%field = mixf(region)%f3d(pressure)%field + dtime * pres3d
  1459. do k=1,lmr
  1460. do j=j1,j2
  1461. do i=i1,i2
  1462. dens = pres3d(i,j,k) / temper_dat(region)%data(i,j,k) * xmair * 1.E-3 / (m_dat(region)%data(i,j,k) * Rgas)
  1463. !!$ mixf(region)%f3d(p_gas_so4)%field(i,j,k)= mixf(region)%f3d(p_gas_so4)%field(i,j,k)+diag_prod(region)%prod(i,j,k,1) / dxyp(j)
  1464. !!$ mixf(region)%f3d(p_liq_so4)%field(i,j,k)= mixf(region)%f3d(p_liq_so4)%field(i,j,k)+diag_prod(region)%prod(i,j,k,2) / dxyp(j)
  1465. mixf(region)%f2d(p_gas_so42d)%field(i,j)= mixf(region)%f2d(p_gas_so42d)%field(i,j)+diag_prod(region)%prod(i,j,k,1) / dxyp(j)
  1466. mixf(region)%f2d(p_liq_so42d)%field(i,j)= mixf(region)%f2d(p_liq_so42d)%field(i,j)+diag_prod(region)%prod(i,j,k,2) / dxyp(j)
  1467. !!$
  1468. !!$ mixf(region)%f3d(p_elvoc)%field(i,j,k)= mixf(region)%f3d(p_elvoc)%field(i,j,k)+diag_prod(region)%prod(i,j,k,3) / dxyp(j)! divide by 2 to calculate mean over 2 chemistry timesteps in one model timestep
  1469. !!$ mixf(region)%f3d(p_svoc)%field(i,j,k)= mixf(region)%f3d(p_svoc)%field(i,j,k)+diag_prod(region)%prod(i,j,k,4) / dxyp(j)
  1470. !!$
  1471. !!$ mixf(region)%f3d(p_elohterp)%field(i,j,k)= mixf(region)%f3d(p_elohterp)%field(i,j,k)+diag_prod(region)%prod(i,j,k,5) / dxyp(j)
  1472. !!$ mixf(region)%f3d(p_elo3terp)%field(i,j,k)= mixf(region)%f3d(p_elo3terp)%field(i,j,k)+diag_prod(region)%prod(i,j,k,6) / dxyp(j)
  1473. !!$ mixf(region)%f3d(p_elohisop)%field(i,j,k)= mixf(region)%f3d(p_elohisop)%field(i,j,k)+diag_prod(region)%prod(i,j,k,7) / dxyp(j)
  1474. !!$ mixf(region)%f3d(p_elo3isop)%field(i,j,k)= mixf(region)%f3d(p_elo3isop)%field(i,j,k)+diag_prod(region)%prod(i,j,k,8) / dxyp(j)
  1475. !!$ mixf(region)%f3d(p_svohterp)%field(i,j,k)= mixf(region)%f3d(p_svohterp)%field(i,j,k)+diag_prod(region)%prod(i,j,k,9) / dxyp(j)
  1476. !!$ mixf(region)%f3d(p_svo3terp)%field(i,j,k)= mixf(region)%f3d(p_svo3terp)%field(i,j,k)+diag_prod(region)%prod(i,j,k,10) / dxyp(j)
  1477. !!$ mixf(region)%f3d(p_svohisop)%field(i,j,k)= mixf(region)%f3d(p_svohisop)%field(i,j,k)+diag_prod(region)%prod(i,j,k,11) / dxyp(j)
  1478. !!$ mixf(region)%f3d(p_svo3isop)%field(i,j,k)= mixf(region)%f3d(p_svo3isop)%field(i,j,k)+diag_prod(region)%prod(i,j,k,12) / dxyp(j)
  1479. mixf(region)%f2d(p_elvoc2d)%field(i,j)= mixf(region)%f2d(p_elvoc2d)%field(i,j)+diag_prod(region)%prod(i,j,k,3) / dxyp(j)
  1480. mixf(region)%f2d(p_svoc2d)%field(i,j)= mixf(region)%f2d(p_svoc2d)%field(i,j)+diag_prod(region)%prod(i,j,k,4) / dxyp(j)
  1481. !!$ mixf(region)%f3d(d_nuc)%field(i,j,k)= mixf(region)%f3d(d_nuc)%field(i,j,k)+d_nucle(i,j,k)*dtime !value is saved #cm-3s-1
  1482. !!$ mixf(region)%f3d(m_nuc_su)%field(i,j,k)= mixf(region)%f3d(m_nuc_su)%field(i,j,k)+m_nucle_su(i,j,k)*dtime !value is saved #molec cm-3s-1
  1483. !!$ mixf(region)%f3d(m_nuc_soa)%field(i,j,k)= mixf(region)%f3d(m_nuc_soa)%field(i,j,k)+m_nucle_soa(i,j,k)*dtime !value is saved #µg m-3s-1
  1484. !!$ mixf(region)%f3d(gr1_2)%field(i,j,k)= mixf(region)%f3d(gr1_2)%field(i,j,k)+growth1_2(i,j,k)*dtime !value is saved #cm-3s-1
  1485. !!$ mixf(region)%f3d(coag1)%field(i,j,k)= mixf(region)%f3d(coag1)%field(i,j,k)+coag_sink_nuc(i,j,k)*dtime !value is saved #cm-3s-1
  1486. !!$ mixf(region)%f3d(co1_soa)%field(i,j,k)= mixf(region)%f3d(co1_soa)%field(i,j,k)+cond1_soa(i,j,k)*dtime !value is saved # unit?
  1487. !!$ mixf(region)%f3d(co2_soa)%field(i,j,k)= mixf(region)%f3d(co2_soa)%field(i,j,k)+cond2_soa(i,j,k)*dtime !value is saved # unit?
  1488. !!$ mixf(region)%f3d(co3_soa)%field(i,j,k)= mixf(region)%f3d(co3_soa)%field(i,j,k)+cond3_soa(i,j,k)*dtime !value is saved # unit?
  1489. !!$ mixf(region)%f3d(co4_soa)%field(i,j,k)= mixf(region)%f3d(co4_soa)%field(i,j,k)+cond4_soa(i,j,k)*dtime !value is saved # unit?
  1490. !!$ mixf(region)%f3d(co5_soa)%field(i,j,k)= mixf(region)%f3d(co5_soa)%field(i,j,k)+cond5_soa(i,j,k)*dtime !value is saved # unit?
  1491. !!$ mixf(region)%f3d(co1_su)%field(i,j,k)= mixf(region)%f3d(co1_su)%field(i,j,k)+cond1_su(i,j,k)*dtime !value is saved # unit?
  1492. !BACCHUS pm1 vars
  1493. lnsigma=log(sigma)
  1494. hr2= 0.5*sqrt(2.0)
  1495. sizelimit=1.0*5.e-7! pm1(1.0 um in diam) in radius (m)
  1496. Do imode = 1, nmod
  1497. ! Calculate the median radius of the volume weighted distribution.
  1498. rad = rw_mode(region,imode)%d3(i,j,k) * cmedr2mmedr(imode)
  1499. !! if( rad == 0.0 ) then ! changed to a precision depending value
  1500. if( rad < 100*TINY(1.0) ) then
  1501. modfrac(imode) = 1.0 ! Should not matter, because if the radius is zero,
  1502. ! there are no aerosols. But in principle, it would
  1503. ! mean that all aerosols are infinitely small, so
  1504. ! they would fit in any PM-class.
  1505. else
  1506. z = ( log(sizelimit) - log(rad) ) / lnsigma(imode)
  1507. modfrac(imode) = 0.5 + 0.5 * ERF(z*hr2)
  1508. end if
  1509. end do
  1510. perm3_to_percm3=1.0e-6
  1511. kg_to_ug=1.0e9
  1512. mixf(region)%f3d(mmf1)%field(i,j,k) = mixf(region)%f3d(mmf1)%field(i,j,k) + dtime * &
  1513. modfrac(1)
  1514. mixf(region)%f3d(mmf2)%field(i,j,k) = mixf(region)%f3d(mmf2)%field(i,j,k) + dtime * &
  1515. modfrac(2)
  1516. mixf(region)%f3d(mmf3)%field(i,j,k) = mixf(region)%f3d(mmf3)%field(i,j,k) + dtime * &
  1517. modfrac(3)
  1518. mixf(region)%f3d(mmf4)%field(i,j,k) = mixf(region)%f3d(mmf4)%field(i,j,k) + dtime * &
  1519. modfrac(4)
  1520. mixf(region)%f3d(so4pm1)%field(i,j,k) = mixf(region)%f3d(so4pm1)%field(i,j,k) + dtime * &
  1521. dens * (rm(i,j,k,iso4nus)*modfrac(1)+rm(i,j,k,iso4ais)*modfrac(2)+&
  1522. rm(i,j,k,iso4acs)*modfrac(3)+rm(i,j,k,iso4cos)*modfrac(4))*(xms/xmso4)*kg_to_ug
  1523. mixf(region)%f3d(bcpm1)%field(i,j,k) = mixf(region)%f3d(bcpm1)%field(i,j,k) + dtime * &
  1524. dens * (rm(i,j,k,ibcais)*modfrac(2)+&
  1525. rm(i,j,k,ibcacs)*modfrac(3)+rm(i,j,k,ibccos)*modfrac(4)+rm(i,j,k,ibcaii)*modfrac(5))*kg_to_ug*(xmc/xmbc)
  1526. mixf(region)%f3d(orgpm1)%field(i,j,k) = mixf(region)%f3d(orgpm1)%field(i,j,k) + dtime * &
  1527. dens * (rm(i,j,k,isoanus)*modfrac(1)+(rm(i,j,k,isoaais)+rm(i,j,k,ipomais))*modfrac(2)+&
  1528. (rm(i,j,k,isoaacs)+rm(i,j,k,ipomacs))*modfrac(3)+(rm(i,j,k,isoacos)+rm(i,j,k,ipomcos))*modfrac(4)+&
  1529. (rm(i,j,k,isoaaii)+rm(i,j,k,ipomaii))*modfrac(5))*kg_to_ug*(xmc/xmpom)
  1530. mixf(region)%f3d(soapm1)%field(i,j,k) = mixf(region)%f3d(soapm1)%field(i,j,k) + dtime * &
  1531. dens * (rm(i,j,k,isoanus)*modfrac(1)+(rm(i,j,k,isoaais))*modfrac(2)+&
  1532. (rm(i,j,k,isoaacs))*modfrac(3)+(rm(i,j,k,isoacos))*modfrac(4)+&
  1533. (rm(i,j,k,isoaaii))*modfrac(5))*kg_to_ug*(xmc/xmpom)
  1534. mixf(region)%f3d(sspm1)%field(i,j,k) = mixf(region)%f3d(sspm1)%field(i,j,k) + dtime * &
  1535. dens * ( rm(i,j,k,issacs)*modfrac(3)+rm(i,j,k,isscos)*modfrac(4))*kg_to_ug
  1536. mixf(region)%f3d(dupm1)%field(i,j,k) = mixf(region)%f3d(dupm1)%field(i,j,k) + dtime * &
  1537. dens * (rm(i,j,k,iduacs)*modfrac(3)+&
  1538. rm(i,j,k,iducos)*modfrac(4)+rm(i,j,k,iduaci)*modfrac(6)+rm(i,j,k,iducoi)*modfrac(7))*kg_to_ug
  1539. mixf(region)%f3d(nh4pm1)%field(i,j,k) = mixf(region)%f3d(nh4pm1)%field(i,j,k) + dtime * &
  1540. dens * (rm(i,j,k,inh4)*modfrac(3))*kg_to_ug
  1541. mixf(region)%f3d(no3pm1)%field(i,j,k) = mixf(region)%f3d(no3pm1)%field(i,j,k) + dtime * &
  1542. dens * (rm(i,j,k,ino3_a)*modfrac(3))*kg_to_ug
  1543. mixf(region)%f3d(so4)%field(i,j,k) = mixf(region)%f3d(so4)%field(i,j,k) + dtime * &
  1544. dens * (rm(i,j,k,iso4nus)+rm(i,j,k,iso4ais)+&
  1545. rm(i,j,k,iso4acs)+rm(i,j,k,iso4cos))*(xms/xmso4)*kg_to_ug
  1546. mixf(region)%f3d(bc)%field(i,j,k) = mixf(region)%f3d(bc)%field(i,j,k) + dtime * &
  1547. dens * (rm(i,j,k,ibcais)+&
  1548. rm(i,j,k,ibcacs)+rm(i,j,k,ibccos)+rm(i,j,k,ibcaii))*(xmc/xmbc)*kg_to_ug
  1549. mixf(region)%f3d(org)%field(i,j,k) = mixf(region)%f3d(org)%field(i,j,k) + dtime * &
  1550. dens * (rm(i,j,k,isoanus)+(rm(i,j,k,isoaais)+rm(i,j,k,ipomais))+&
  1551. (rm(i,j,k,isoaacs)+rm(i,j,k,ipomacs))+(rm(i,j,k,isoacos)+rm(i,j,k,ipomcos))+&
  1552. (rm(i,j,k,isoaaii)+rm(i,j,k,ipomaii)))*(xmc/xmpom)*kg_to_ug
  1553. mixf(region)%f3d(ss)%field(i,j,k) = mixf(region)%f3d(ss)%field(i,j,k) + dtime * &
  1554. dens * ( rm(i,j,k,issacs)+rm(i,j,k,isscos))*kg_to_ug
  1555. mixf(region)%f3d(du)%field(i,j,k) = mixf(region)%f3d(du)%field(i,j,k) + dtime * &
  1556. dens * (rm(i,j,k,iduacs)+&
  1557. rm(i,j,k,iducos)+rm(i,j,k,iduaci)+rm(i,j,k,iducoi))*kg_to_ug
  1558. mixf(region)%f3d(nh4)%field(i,j,k) = mixf(region)%f3d(nh4)%field(i,j,k) + dtime * &
  1559. dens * (rm(i,j,k,inh4))*kg_to_ug
  1560. mixf(region)%f3d(no3)%field(i,j,k) = mixf(region)%f3d(no3)%field(i,j,k) + dtime * &
  1561. dens * (rm(i,j,k,ino3_a))*kg_to_ug
  1562. sizelimit=3*5.e-9! pm1(1.0 um in diam) in radius (m)
  1563. Do imode = 1, nmod
  1564. ! Calculate the median radius of the volume weighted distribution.
  1565. rad = rw_mode(region,imode)%d3(i,j,k)
  1566. if( rad < 100*TINY(1.0) ) then
  1567. modfrac(imode) = 1.0 ! Should not matter, because if the radius is zero,
  1568. ! there are no aerosols. But in principle, it would
  1569. ! mean that all aerosols are infinitely small, so
  1570. ! they would fit in any PM-class.
  1571. else
  1572. z = ( log(sizelimit) - log(rad) ) / lnsigma(imode)
  1573. ! now calculating larger than sizelimit
  1574. modfrac(imode) = 1-(0.5 + 0.5 * ERF(z*hr2))
  1575. end if
  1576. end do
  1577. mixf(region)%f3d(n3)%field(i,j,k) = mixf(region)%f3d(n3)%field(i,j,k) + dtime * &
  1578. dens *( rm(i,j,k,inus_n)*modfrac(1)+ rm(i,j,k,iais_n)*modfrac(2)+&
  1579. rm(i,j,k,iacs_n)*modfrac(3)+ rm(i,j,k,icos_n)*modfrac(4)+&
  1580. rm(i,j,k,iaii_n)*modfrac(5)+ rm(i,j,k,iaci_n)*modfrac(6)+&
  1581. rm(i,j,k,icoi_n)*modfrac(7))*perm3_to_percm3
  1582. !!$ !50nm
  1583. !!$ do d_ind=1,3
  1584. !!$ sizelimit=N_diam(d_ind)*5.e-9! pm1(1.0 um in diam) in radius (m)
  1585. !!$ Do imode = 1, nmod
  1586. !!$ ! Calculate the median radius of the volume weighted distribution.
  1587. !!$ rad = rw_mode(region,imode)%d3(i,j,k)
  1588. !!$ if( rad < 100*TINY(1.0) ) then
  1589. !!$ modfrac(imode) = 1.0 ! Should not matter, because if the radius is zero,
  1590. !!$ ! there are no aerosols. But in principle, it would
  1591. !!$ ! mean that all aerosols are infinitely small, so
  1592. !!$ ! they would fit in any PM-class.
  1593. !!$ else
  1594. !!$ z = ( log(sizelimit) - log(rad) ) / lnsigma(imode)
  1595. !!$
  1596. !!$ ! now calculating larger than sizelimit
  1597. !!$ modfrac(imode) = 1-(0.5 + 0.5 * ERF(z*hr2))
  1598. !!$ end if
  1599. !!$ end do
  1600. !!$ mixf(region)%f3d(ind_N(d_ind))%field(i,j,k) = mixf(region)%f3d(n3)%field(i,j,k) + dtime * &
  1601. !!$ dens *( rm(i,j,k,inus_n)*modfrac(1)+ rm(i,j,k,iais_n)*modfrac(2)+&
  1602. !!$ rm(i,j,k,iacs_n)*modfrac(3)+ rm(i,j,k,icos_n)*modfrac(4)+&
  1603. !!$ rm(i,j,k,iaii_n)*modfrac(5)+ rm(i,j,k,iaci_n)*modfrac(6)+&
  1604. !!$ rm(i,j,k,icoi_n)*modfrac(7))*perm3_to_percm3
  1605. !!$ end do
  1606. ! CCN under given supersaturation
  1607. IF (nCCNdiag) THEN
  1608. DO iSat=1,nSat
  1609. mixf(region)%f3d(ind_CCN(iSat))%field(i,j,k)= mixf(region)%f3d(ind_CCN(iSat))%field(i,j,k) + dtime * &
  1610. dens * 1.e-06 * CCN(iSat,i,j,k) ! cm-3
  1611. ENDDO
  1612. DO iSat=1,3
  1613. mixf(region)%f3d(ind_HG(iSat))%field(i,j,k)= mixf(region)%f3d(ind_HG(iSat))%field(i,j,k) + dtime * &
  1614. Kappa_r(iSat,i,j,k) ! cm-3
  1615. mixf(region)%f3d(ind_N(iSat))%field(i,j,k)= mixf(region)%f3d(ind_N(iSat))%field(i,j,k) + dtime * &
  1616. dens * 1.e-06 * N_r(iSat,i,j,k) ! cm-3
  1617. ENDDO
  1618. ENDIF
  1619. mixf(region)%f3d(ccn02)%field(i,j,k) = mixf(region)%f3d(ccn02)%field(i,j,k) + dtime * &
  1620. dens * 1.e-06 * CCN(5,i,j,k) ! cm-3 CCN0.2
  1621. mixf(region)%f3d(gph)%field(i,j,k) = mixf(region)%f3d(gph)%field(i,j,k) + gph_dat(region)%data(i,j,k)*dtime
  1622. ! rwet, rdry, h2o data holder indices go from 1-4/7
  1623. ! so use counters, could also add modeindex in mixf
  1624. rwetcounter=1
  1625. rdrycounter=1
  1626. h2ocounter=1
  1627. do nn=1,n_3d_vars
  1628. if (mixf(region)%f3d(nn)%mf%itm5>0)then
  1629. ! transported variables in rm
  1630. if (mixf(region)%f3d(nn)%mf%itm5<=ntracet) then
  1631. mixf(region)%f3d(nn)%field(i,j,k) = mixf(region)%f3d(nn)%field(i,j,k) + dtime * &
  1632. dens * rm(i,j,k,mixf(region)%f3d(nn)%mf%itm5)
  1633. else !non transported variables in rmc
  1634. mixf(region)%f3d(nn)%field(i,j,k) = mixf(region)%f3d(nn)%field(i,j,k) + dtime * &
  1635. dens * rmc(i,j,k,mixf(region)%f3d(nn)%mf%itm5)
  1636. end if
  1637. else ! not a tracer variable
  1638. ! counter to go through 7 modes when outputing rwet
  1639. ! requires that rwet variables are in right order
  1640. ! Wet radius of particles
  1641. if ( mixf(region)%f3d(nn)%mf%vname(1:4)=='RWET')then
  1642. mixf(region)%f3d(nn)%field(i,j,k) = mixf(region)%f3d(nn)%field(i,j,k) + dtime * &
  1643. rw_mode(region,rwetcounter)%d3(i,j,k)
  1644. rwetcounter=rwetcounter+1
  1645. end if
  1646. ! aerosol water
  1647. if ( mixf(region)%f3d(nn)%mf%vname(1:6)=='aerh2o')then
  1648. mixf(region)%f3d(nn)%field(i,j,k) = mixf(region)%f3d(nn)%field(i,j,k) + dtime * &
  1649. dens*h2o_mode(region,h2ocounter)%d3(i,j,k)
  1650. h2ocounter=h2ocounter+1
  1651. end if
  1652. !dry radius of soluble modes
  1653. if ( mixf(region)%f3d(nn)%mf%vname(1:4)=='RDRY')then
  1654. mixf(region)%f3d(nn)%field(i,j,k) = mixf(region)%f3d(nn)%field(i,j,k) + dtime * &
  1655. rwd_mode(region,rdrycounter)%d3(i,j,k)
  1656. rdrycounter=rdrycounter+1
  1657. end if
  1658. end if
  1659. end do
  1660. end do
  1661. end do
  1662. end do
  1663. ! set fields summed in chemistry to 0 after writing
  1664. d_nucle = 0.
  1665. m_nucle_su = 0.
  1666. m_nucle_soa = 0.
  1667. diag_prod(region)%prod(i1:i2,j1:j2,:,1)=0.0
  1668. diag_prod(region)%prod(i1:i2,j1:j2,:,2)=0.0
  1669. diag_prod(region)%prod(i1:i2,j1:j2,:,3)=0.0
  1670. diag_prod(region)%prod(i1:i2,j1:j2,:,4)=0.0
  1671. diag_prod(region)%prod(i1:i2,j1:j2,:,5)=0.0
  1672. diag_prod(region)%prod(i1:i2,j1:j2,:,6)=0.0
  1673. diag_prod(region)%prod(i1:i2,j1:j2,:,7)=0.0
  1674. diag_prod(region)%prod(i1:i2,j1:j2,:,8)=0.0
  1675. diag_prod(region)%prod(i1:i2,j1:j2,:,9)=0.0
  1676. diag_prod(region)%prod(i1:i2,j1:j2,:,10)=0.0
  1677. diag_prod(region)%prod(i1:i2,j1:j2,:,11)=0.0
  1678. diag_prod(region)%prod(i1:i2,j1:j2,:,12)=0.0
  1679. coag_sink_nuc = 0.
  1680. growth1_2 = 0.
  1681. cond1_soa = 0.
  1682. cond2_soa = 0.
  1683. cond3_soa = 0.
  1684. cond4_soa = 0.
  1685. cond5_soa = 0.
  1686. cond1_su = 0.
  1687. ! ----------------------
  1688. ! cycle over horizontal domain
  1689. ! ----------------------
  1690. do j = j1, j2
  1691. do i = i1, i2
  1692. ! -----------------------
  1693. ! SURFACE FIELDS
  1694. ! -----------------------
  1695. k = 1
  1696. ! ----------------------
  1697. ! Physical Parameters
  1698. ! ----------------------
  1699. ! surface pressure [Pa]
  1700. mixf(region)%f2d(ps)%field(i,j) = mixf(region)%f2d(ps)%field(i,j) + dtime * sp_dat(region)%data(i,j,k)
  1701. ! precipitation ([m s-1] --> [kg m-2 s-1] with density of water `rol`)
  1702. mixf(region)%f2d(precip)%field(i,j) = mixf(region)%f2d(precip)%field(i,j) + dtime * (cp_dat(region)%data(i,j,k) + lsp_dat(region)%data(i,j,k)) * rol
  1703. ! density for conversion of aerosol mass densities ( ---> 1/m3 )
  1704. ! (conversion factor 1.E-03 is for g --> kg)
  1705. dens = pres3d(i,j,k) / temper_dat(region)%data(i,j,k) * xmair * 1.E-3 / (m_dat(region)%data(i,j,k) * Rgas)
  1706. ! ----------------------
  1707. ! Surface Concentrations in [kg m-3]
  1708. ! ----------------------
  1709. !TB added nucleation mode oc
  1710. ! POM: (AIS + ACS + COS + AII)
  1711. mixf(region)%f2d(sconcoa)%field(i,j) = mixf(region)%f2d(sconcoa)%field(i,j) + dtime * &
  1712. dens * (rm(i,j,k,iPOMais) + rm(i,j,k,iPOMacs) + rm(i,j,k,iPOMcos) + rm(i,j,k,iPOMaii))
  1713. ! SOA: (NUS + AIS + ACS + COS + AII)
  1714. mixf(region)%f2d(sconcsoa)%field(i,j) = mixf(region)%f2d(sconcsoa)%field(i,j) + dtime * &
  1715. dens * (rm(i,j,k,iSOAnus) + rm(i,j,k,iSOAais) + rm(i,j,k,iSOAacs) + rm(i,j,k,iSOAcos) + rm(i,j,k,iSOAaii))
  1716. ! BC: (AIS + ACS + COS + AII)
  1717. mixf(region)%f2d(sconcbc)%field(i,j) = mixf(region)%f2d(sconcbc)%field(i,j) + dtime * &
  1718. dens * (rm(i,j,k,iBCais) + rm(i,j,k,iBCacs) + rm(i,j,k,iBCcos) + rm(i,j,k,iBCaii))
  1719. ! SO4: (NUS + AIS + ACS + COS)
  1720. mixf(region)%f2d(sconcso4)%field(i,j) = mixf(region)%f2d(sconcso4)%field(i,j) + dtime * &
  1721. dens * (rm(i,j,k,iSO4nus) + rm(i,j,k,iSO4ais) + rm(i,j,k,iSO4acs) + rm(i,j,k,iSO4cos))
  1722. ! Dust:
  1723. mixf(region)%f2d(sconcdust)%field(i,j) = mixf(region)%f2d(sconcdust)%field(i,j) + dtime * &
  1724. dens * (rm(i,j,k,iDUacs) + rm(i,j,k,iDUcos) + rm(i,j,k,iDUaci) + rm(i,j,k,iDUcoi))
  1725. ! Seasalt:
  1726. mixf(region)%f2d(sconcss)%field(i,j) = mixf(region)%f2d(sconcss)%field(i,j) + dtime * &
  1727. dens * (rm(i,j,k,iSSacs) + rm(i,j,k,iSScos))
  1728. ! NO3:
  1729. mixf(region)%f2d(sconcno3)%field(i,j) = mixf(region)%f2d(sconcno3)%field(i,j) + dtime * &
  1730. dens * rm(i,j,k,iNO3_a)
  1731. ! NH4:
  1732. mixf(region)%f2d(sconcnh4)%field(i,j) = mixf(region)%f2d(sconcnh4)%field(i,j) + dtime * &
  1733. dens * rm(i,j,k,iNH4)
  1734. ! MSA:
  1735. mixf(region)%f2d(sconcmsa)%field(i,j) = mixf(region)%f2d(sconcmsa)%field(i,j) + dtime * &
  1736. dens * rm(i,j,k,iMSA)
  1737. ! Mass concentrations
  1738. do nn=68,90
  1739. mixf(region)%f2d(nn)%field(i,j) = mixf(region)%f2d(nn)%field(i,j) + dtime * &
  1740. dens * rm(i,j,k,mixf(region)%f2d(nn)%mf%itm5)
  1741. end do
  1742. !number concentrations
  1743. do nn=91,97
  1744. mixf(region)%f2d(nn)%field(i,j) = mixf(region)%f2d(nn)%field(i,j) + dtime * &
  1745. dens * rm(i,j,k,mixf(region)%f2d(nn)%mf%itm5)
  1746. end do
  1747. !h2o
  1748. h2ocounter=0
  1749. do nn=98,101
  1750. h2ocounter=h2ocounter+1
  1751. mixf(region)%f2d(nn)%field(i,j) = mixf(region)%f2d(nn)%field(i,j) + dtime * &
  1752. dens * h2o_mode(region,h2ocounter)%d3(i,j,k)!rm(i,j,k,mixf(region)%f2d(nn)%mf%itm5)
  1753. end do
  1754. ! RWET for all modes (RDRY=RWET for non-soluble)
  1755. !
  1756. irw=0
  1757. do nn=102,108
  1758. !
  1759. irw=irw+1
  1760. mixf(region)%f2d(nn)%field(i,j) = mixf(region)%f2d(nn)%field(i,j) +dtime *rw_mode(region,irw)%d3(i,j,k)
  1761. end do
  1762. ! RDRY for soluble modes
  1763. irwd=0
  1764. do nn=109,112
  1765. irwd=irwd+1
  1766. mixf(region)%f2d(nn)%field(i,j) = mixf(region)%f2d(nn)%field(i,j) +dtime *rwd_mode(region,irwd)%d3(i,j,k)
  1767. end do
  1768. ! ----------------------
  1769. ! Load in [kg m-2]
  1770. ! ----------------------
  1771. do k = 1, lmr
  1772. !do ll=1,len(load)
  1773. ! POM: (AIS + ACS + COS + AII)
  1774. load_tmp=0.0
  1775. do nn=1,7
  1776. if (mode_end_pom(nn)>0) then
  1777. load_tmp = load_tmp+ rm(i,j,k,mode_end_pom(nn))
  1778. !(rm(i,j,k,iPOMnus) + rm(i,j,k,iPOMais) + rm(i,j,k,iPOMacs) + rm(i,j,k,iPOMcos) + rm(i,j,k,iPOMaii))
  1779. end if
  1780. end do
  1781. mixf(region)%f2d(loadoa)%field(i,j) = mixf(region)%f2d(loadoa)%field(i,j) + load_tmp * dtime / dxyp(j)
  1782. ! SOA: (NUS + AIS + ACS + COS + AII)
  1783. load_tmp=0.0
  1784. do nn=1,7
  1785. if (mode_end_soa(nn)>0) then
  1786. load_tmp = load_tmp+ rm(i,j,k,mode_end_soa(nn))
  1787. ENDIF
  1788. end do
  1789. mixf(region)%f2d(loadsoa)%field(i,j) = mixf(region)%f2d(loadsoa)%field(i,j) + load_tmp * dtime / dxyp(j)
  1790. ! BC: (AIS + ACS + COS + AII)
  1791. load_tmp=0.0
  1792. do nn=1,7
  1793. if (mode_end_bc(nn)>0) then
  1794. load_tmp = load_tmp+ rm(i,j,k,mode_end_bc(nn))
  1795. !load_tmp = (rm(i,j,k,iBCais) + rm(i,j,k,iBCacs) + rm(i,j,k,iBCcos) + rm(i,j,k,iBCaii))
  1796. end if
  1797. end do
  1798. mixf(region)%f2d(loadbc)%field(i,j) = mixf(region)%f2d(loadbc)%field(i,j) + load_tmp * dtime / dxyp(j)
  1799. ! SO4: (NUS + AIS + ACS + COS)
  1800. load_tmp=0.0
  1801. do nn=1,7
  1802. if (mode_end_so4(nn)>0) then
  1803. load_tmp = load_tmp+ rm(i,j,k,mode_end_so4(nn))
  1804. !load_tmp = (rm(i,j,k,iSO4nus) + rm(i,j,k,iSO4ais) + rm(i,j,k,iSO4acs) + rm(i,j,k,iSO4cos))
  1805. end if
  1806. end do
  1807. mixf(region)%f2d(loadso4)%field(i,j) = mixf(region)%f2d(loadso4)%field(i,j) + load_tmp * dtime / dxyp(j)
  1808. ! Dust: (ACS + COS + ACI + COI)
  1809. load_tmp=0.0
  1810. do nn=1,7
  1811. if (mode_end_dust(nn)>0) then
  1812. load_tmp = load_tmp+ rm(i,j,k,mode_end_dust(nn))
  1813. !load_tmp = (rm(i,j,k,iDUacs) + rm(i,j,k,iDUcos) + rm(i,j,k,iDUaci) + rm(i,j,k,iDUcoi))
  1814. end if
  1815. end do
  1816. mixf(region)%f2d(loaddust)%field(i,j) = mixf(region)%f2d(loaddust)%field(i,j) + load_tmp * dtime / dxyp(j)
  1817. ! Seasalt: (ACS + COS)
  1818. load_tmp=0.0
  1819. do nn=1,7
  1820. if (mode_end_ss(nn)>0) then
  1821. load_tmp = load_tmp+ rm(i,j,k,mode_end_ss(nn))
  1822. !load_tmp = (rm(i,j,k,iSSacs) + rm(i,j,k,iSScos))
  1823. end if
  1824. end do
  1825. mixf(region)%f2d(loadss)%field(i,j) = mixf(region)%f2d(loadss)%field(i,j) + load_tmp * dtime / dxyp(j)
  1826. !!$
  1827. ! NO3:
  1828. load_tmp = rm(i,j,k,iNO3_a)
  1829. mixf(region)%f2d(loadno3)%field(i,j) = mixf(region)%f2d(loadno3)%field(i,j) + load_tmp * dtime / dxyp(j)
  1830. !!$
  1831. end do ! k
  1832. end do ! i
  1833. end do ! j
  1834. !!$
  1835. call GO_Timer_Start( itim_opt_out, status )
  1836. IF_NOTOK_RETURN(status=1)
  1837. ! ---------------------
  1838. ! DO OPTICS IN PARALLEL
  1839. ! ---------------------
  1840. ! steps needed for that:
  1841. ! 1) according to the parallelisation there is different container sizes for
  1842. ! the results of the optics; these have to be allocated correctly
  1843. ! (aop_output_ext/a/g/add)
  1844. ! 2) the optics code is called (init/calculate_aop/done), see documentation
  1845. ! in the optics module
  1846. ! 3) the distributed fields (levels/tracers) are reshaped to global fields
  1847. ! (opt_ext/a/g/add), according to parallelisation
  1848. ! 4) fields are communicated such that the result contains the right
  1849. ! total extinctions, albedos, asymmetry factors etc.
  1850. ! 5) post-calculations (AOD etc.) are done and results are written
  1851. ! to mixf%../statf% containers as well as to the AOD dump files
  1852. ! 6) done...
  1853. ! ------------ REMARKS
  1854. ! IMPOSSIBLE / TOO EXPENSIVE (from the GENERAL list of parameters for QUICKLOOK)
  1855. ! - gf @ 90% RH
  1856. ! - "AOD@550nm SOA", "AOD@550nm BB"
  1857. ! ---------------------------------
  1858. ! fill current M7 state into an appropriate container
  1859. ! and allocate output fields (ext,a,g)
  1860. ! ---------------------------------
  1861. ! ----- A T T E N T I O N ---------
  1862. ! in case for a 'split', we need a field big enough to contain
  1863. ! various contributions
  1864. ! (to be synchronously changed with optics_aop_calculate!!)
  1865. ! ncontr is here number of contributors
  1866. ! Total, SO4, BC, OC, SS, DU, NO3, Water, Fine, Fine Dust, Fine SS
  1867. !ncontr = 10
  1868. !ncontr = 11
  1869. ncontr = 12
  1870. ! Additional fields for surface dry aerosol
  1871. ! to be used for validation against in-situ data:
  1872. ! extinction, absorption, asymmetry factor
  1873. ! fine-mode contribution to extinction, absorption
  1874. nadd = 5
  1875. lvec = imr*jmr*lmr
  1876. ! allocate output fields for optics_calculate_aop
  1877. Allocate( aop_output_ext(lvec, size(wdep_out), ncontr ) ) ! extinction
  1878. Allocate( aop_output_a (lvec, size(wdep_out) ) ) ! single scattering albedo
  1879. Allocate( aop_output_g (lvec, size(wdep_out) ) ) ! asymmetry factor
  1880. Allocate( aop_output_add(lvec, size(wdep_out), nadd ) ) ! extinction/absorption due to dry aerosol at surface
  1881. call optics_aop_get(lvec, region, size(wdep_out), wdep_out, ncontr, aop_output_ext, aop_output_a, aop_output_g, &
  1882. status, aop_output_add )
  1883. IF_NOTOK_RETURN(status=1)
  1884. ! allocate here result arrays for ext, abs, ssa, asymmetry parameter, additional parameters (PM10)
  1885. ! ncontr is number of contributors for 'split'
  1886. allocate( opt_ext( i1:i2, j1:j2, lmr, size(wdep_out), ncontr ) ) ; opt_ext = 0.0
  1887. allocate( opt_a ( i1:i2, j1:j2, lmr, size(wdep_out) ) ) ; opt_a = 0.0
  1888. allocate( opt_g ( i1:i2, j1:j2, lmr, size(wdep_out) ) ) ; opt_g = 0.0
  1889. allocate( opt_add( i1:i2, j1:j2, lmr, size(wdep_out), nadd ) ) ; opt_add = 0.0
  1890. ! ---------------------------------
  1891. ! unpack results from calculate_aop
  1892. ! ---------------------------------
  1893. do lwl = 1, size(wdep_out)
  1894. if( wdep_out(lwl)%split ) then
  1895. ! fill the array for the extinction coefficients of contributors
  1896. do lct = 1, ncontr
  1897. opt_ext(:,:,:,lwl,lct) = reshape( aop_output_ext(:,lwl,lct), (/imr,jmr,lmr/) )
  1898. end do
  1899. else
  1900. ! fill only total extinction coefficients
  1901. opt_ext(:,:,:,lwl,1) = reshape( aop_output_ext(:,lwl,1), (/imr,jmr,lmr/) )
  1902. endif
  1903. opt_a(:,:,:,lwl) = reshape( aop_output_a(:,lwl),(/imr,jmr,lmr/) )
  1904. opt_g(:,:,:,lwl) = reshape( aop_output_g(:,lwl),(/imr,jmr,lmr/) )
  1905. if ( wdep_out(lwl)%insitu ) then
  1906. ! additional fields for split
  1907. do lct = 1, nadd
  1908. opt_add(i1:i2,j1:j2,:,lwl,lct) = reshape( aop_output_add(:,lwl,lct),(/imr,jmr,lmr/) )
  1909. end do
  1910. endif
  1911. end do ! lwl
  1912. ! free temporary arrays for results from calculate_aop
  1913. deallocate( aop_output_ext )
  1914. deallocate( aop_output_a )
  1915. deallocate( aop_output_g )
  1916. deallocate( aop_output_add )
  1917. ! the following sections assume that for 550nm there is splitted information
  1918. ! available and that there is *NO* split for other wavelengths!
  1919. if( count( (wdep_out(:)%wl == 0.550) .and. wdep_out(:)%split ) /= 1 ) then
  1920. write(gol,*) 'user_output_general: wrong setup with splitted AOD information.'; call goErr
  1921. TRACEBACK
  1922. status=1; return
  1923. end if
  1924. ! -------------------------------------
  1925. ! here additional calculations and
  1926. ! file writing begin
  1927. ! -------------------------------------
  1928. ! cycle over wavelengths
  1929. do lwl = 1, size(wdep_out)
  1930. if( wdep_out(lwl)%split ) then
  1931. ! for 550nm:
  1932. ! 1) AODs (35 - 44)
  1933. ! fill for contributors (total, SO4, BC, POM, SS, DU, NO3, H2O, fine, fine dust, fine SS)
  1934. ! 2) Absorption for 550nm (45)
  1935. ! Extinction is here the sum of scattering and absorption and
  1936. ! the scattering part is given by the albedo (SSA). Thus the
  1937. ! remainder is absorption: Abs = Ext * (1 - SSA)
  1938. indoffset = od550aer
  1939. allocate(temp2d(i1:i2,j1:j2))
  1940. do lct = 1, ncontr
  1941. temp2d = 0.0
  1942. do j = j1, j2
  1943. do i = i1, i2
  1944. ! multiply with height elements and sum up
  1945. tabs = 0.0
  1946. do l = 1, lmr
  1947. temp2d(i,j) = temp2d(i,j) + opt_ext(i,j,l,lwl,lct) * &
  1948. (gph_dat(region)%data(i,j,l+1) - &
  1949. gph_dat(region)%data(i,j,l ))
  1950. if( lct == 1 ) then
  1951. ! Absorption: do this only once for the totals
  1952. tabs = tabs + opt_ext(i,j,l,lwl,lct) * (1.0 - opt_a(i,j,l,lwl)) * &
  1953. (gph_dat(region)%data(i,j,l+1) - gph_dat(region)%data(i,j,l))
  1954. end if
  1955. end do
  1956. ! Absorption: do this only once for the totals
  1957. if( lct == 1 ) then
  1958. mixf(region)%f2d(abs550aer)%field(i,j) = &
  1959. mixf(region)%f2d(abs550aer)%field(i,j) + tabs * dtime
  1960. end if
  1961. end do
  1962. end do
  1963. ! this here is AODs for different contributors, splitted by volumes
  1964. mixf(region)%f2d(indoffset+lct-1)%field = &
  1965. mixf(region)%f2d(indoffset+lct-1)%field + temp2d * dtime
  1966. end do
  1967. deallocate( temp2d )
  1968. ! Asymmetry Parameter, weighted by AOD and single scattering albedo at each layer
  1969. allocate(temp2d(i1:i2,j1:j2)) ; temp2d = 0.0
  1970. do j = j1, j2
  1971. do i = i1, i2
  1972. wght = 0.0
  1973. do l = 1, lmr
  1974. dwght = opt_ext(i,j,l,lwl,1) * (gph_dat(region)%data(i,j,l+1) - gph_dat(region)%data(i,j,l )) * opt_a(i,j,l,lwl)
  1975. temp2d(i,j) = temp2d(i,j) + opt_g(i,j,l,lwl) * dwght
  1976. wght = wght + dwght
  1977. end do
  1978. temp2d(i,j) = temp2d(i,j) / wght
  1979. end do
  1980. end do
  1981. mixf(region)%f2d(asyaer)%field = mixf(region)%f2d(asyaer)%field + temp2d * dtime
  1982. deallocate(temp2d)
  1983. ! Surface Ambient Aerosol Extinction
  1984. mixf(region)%f2d(ec550aer)%field = &
  1985. mixf(region)%f2d(ec550aer)%field + opt_ext(:,:,1,lwl,1) * dtime
  1986. else
  1987. ! for 440/870/350 nm:
  1988. ! 1) fill total AOD and AAOD and write to containers
  1989. ! 2) dump AOD fields
  1990. if ( wdep_out(lwl)%wl == 0.440 ) then
  1991. indoffset = od440aer
  1992. indabs = abs440aer
  1993. elseif ( wdep_out(lwl)%wl == 0.550 ) then
  1994. indoffset = od550aer
  1995. indabs = abs550aer
  1996. elseif ( wdep_out(lwl)%wl == 0.870 ) then
  1997. indoffset = od870aer
  1998. indabs = abs870aer
  1999. elseif ( wdep_out(lwl)%wl == 0.350 ) then
  2000. indoffset = od350aer
  2001. indabs = abs350aer
  2002. else
  2003. write(gol,*) 'user_output_general: wrong wavelength given for general diagnostics' ; call goErr
  2004. TRACEBACK
  2005. status=1; return
  2006. end if
  2007. ! fill AODs
  2008. allocate(temp2d(i1:i2,j1:j2))
  2009. temp2d = 0.0
  2010. do j = j1, j2
  2011. do i = i1, i2
  2012. ! multiply with height elements and sum up
  2013. tabs = 0.0
  2014. do l = 1, lmr
  2015. temp2d(i,j) = temp2d(i,j) + opt_ext(i,j,l,lwl,1) * &
  2016. (gph_dat(region)%data(i,j,l+1) - &
  2017. gph_dat(region)%data(i,j,l ))
  2018. tabs = tabs + opt_ext(i,j,l,lwl,1) * (1.0 - opt_a(i,j,l,lwl)) * &
  2019. (gph_dat(region)%data(i,j,l+1) - gph_dat(region)%data(i,j,l))
  2020. end do
  2021. mixf(region)%f2d(indabs)%field(i,j) = &
  2022. mixf(region)%f2d(indabs)%field(i,j) + tabs * dtime
  2023. end do
  2024. end do
  2025. ! write to container
  2026. mixf(region)%f2d(indoffset)%field = &
  2027. mixf(region)%f2d(indoffset)%field + temp2d * dtime
  2028. deallocate(temp2d)
  2029. endif
  2030. !!$
  2031. ! 3-D extinction and absorption (m-1)
  2032. if ( aai_output ) then
  2033. if ( wdep_out(lwl)%wl == 0.550 .or. wdep_out(lwl)%wl == 0.350 ) then
  2034. if ( wdep_out(lwl)%wl == 0.550 ) then
  2035. indoffset = ec5503Daer
  2036. elseif ( wdep_out(lwl)%wl == 0.350 ) then
  2037. indoffset = ec3503Daer
  2038. endif
  2039. mixf(region)%f3d(indoffset)%field = &
  2040. mixf(region)%f3d(indoffset)%field + opt_ext(:,:,:,lwl,1) * dtime
  2041. mixf(region)%f3d(indoffset+1)%field = &
  2042. mixf(region)%f3d(indoffset+1)%field + opt_ext(:,:,:,lwl,1) * (1.0 - opt_a(:,:,:,lwl)) * dtime
  2043. endif
  2044. endif
  2045. end do
  2046. ! done
  2047. deallocate( opt_ext, opt_a, opt_g, opt_add )
  2048. nullify(rm)
  2049. nullify(dxyp)
  2050. deallocate( pres3d )
  2051. deallocate( CCN )
  2052. deallocate( dry_rad)
  2053. deallocate( Kappa_r)
  2054. deallocate( N_r)
  2055. call GO_Timer_End( itim_opt_out, status )
  2056. IF_NOTOK_RETURN(status=1)
  2057. call goLabel() ; status = 0
  2058. end subroutine output_general_step
  2059. !EOC
  2060. !--------------------------------------------------------------------------
  2061. ! TM5 !
  2062. !--------------------------------------------------------------------------
  2063. !BOP
  2064. !
  2065. ! !IROUTINE: COLLECT_BUDGETS
  2066. !
  2067. ! !DESCRIPTION: This routine does book keeping of the budget values in
  2068. ! order to extract daily contributions to
  2069. ! emissions / dry deposition / wet deposition.
  2070. !\\
  2071. !\\
  2072. ! !INTERFACE:
  2073. !
  2074. subroutine collect_budgets(region, status)
  2075. !
  2076. ! !USES:
  2077. !
  2078. #ifndef without_chemistry
  2079. use ebischeme, only : buddry_dat => buddep_dat
  2080. #endif
  2081. use wet_deposition, only : buddep_dat
  2082. use emission_data, only : budemi_dat
  2083. use budget_global, only : nbud_vg
  2084. use global_data, only : region_dat
  2085. use chem_param, only : iducoi, iduacs, iducos, iduaci, isscos, issacs
  2086. use chem_param, only : ibccos, ibcaii, ibcacs, ibcais, ino3_a, xmair
  2087. use chem_param, only : iso4nus, iso4acs, iso4cos, iso4ais
  2088. use chem_param, only : ipomcos, ipomaii, ipomacs, ipomais
  2089. use chem_param, only : isoacos, isoaaii, isoaacs, isoaais, isoanus
  2090. use chem_param, only : idms, iso2, ntracet, ntrace,iterp,iisop
  2091. use chem_param, only : xmso2, xmso4, xmdms, xmpom, xmbc, xmdust, xmnacl,xmterp,xmisop
  2092. #ifndef without_sedimentation
  2093. use sedimentation, only : buddep_m7_dat
  2094. use sedimentation, only : nsed, ised
  2095. #endif
  2096. !
  2097. ! !INPUT PARAMETERS:
  2098. !
  2099. integer, intent(in) :: region
  2100. !
  2101. ! !OUTPUT PARAMETERS:
  2102. !
  2103. integer, intent(out) :: status
  2104. !
  2105. ! !REVISION HISTORY:
  2106. ! 29 Nov 2010 - Achim Strunk -
  2107. !
  2108. ! !REMARKS:
  2109. !
  2110. !EOP
  2111. !------------------------------------------------------------------------
  2112. !BOC
  2113. character(len=*), parameter :: rname = mname//'/collect_budgets'
  2114. real, dimension(:,:,:,:), allocatable :: collect4d
  2115. real, dimension(:,:,:), allocatable :: collect3d
  2116. real, dimension(:,:), allocatable :: tmpbud2d
  2117. real, dimension(:), pointer :: dxyp
  2118. integer :: imr, jmr, lmr, j
  2119. integer :: i1, i2, j1, j2
  2120. !>>> TvN
  2121. integer :: l, n
  2122. !<<< TvN
  2123. ! --- begin -------------------------------
  2124. call goLabel(rname)
  2125. ! grid size
  2126. call Get_DistGrid( dgrid(region), I_STRT=i1, I_STOP=i2, J_STRT=j1, J_STOP=j2 )
  2127. imr=i2-i1+1
  2128. jmr=j2-j1+1
  2129. lmr = levi%nlev
  2130. ! this is area element
  2131. dxyp => region_dat(region)%dxyp
  2132. ! --------------
  2133. ! EMISSIONS
  2134. ! --------------
  2135. ! collect emission budget
  2136. allocate( collect4d(i1:i2,j1:j2,nbud_vg,ntracet) ); collect4d = 0.0
  2137. ! emissions are in [mole]
  2138. ! convert first to kilomole per area [k-mole/m2]
  2139. #ifndef without_emission
  2140. do j = j1, j2
  2141. collect4d(:,j,:,:) = budemi_dat(region)%emi(i1:i2,j,:,:) / dxyp(j) * 1.E-03
  2142. end do
  2143. #endif
  2144. allocate( tmpbud2d(i1:i2,j1:j2) )
  2145. ! on the way: convert from kilomole/m2 to kg/m2 via molar mass [g/mole]
  2146. ! POM (AIS + ACS + COS + AII)
  2147. tmpbud2d = ( sum(collect4d(:,:,:,iPOMais),3) + sum(collect4d(:,:,:,iPOMacs),3) + &
  2148. sum(collect4d(:,:,:,iPOMcos),3) + sum(collect4d(:,:,:,iPOMaii),3) ) * xmpom
  2149. mixf(region)%f2d(emioa)%field = tmpbud2d - emission(region)%f2dslast(:,:,1)
  2150. emission(region)%f2dslast(:,:,1) = tmpbud2d
  2151. ! BC (AIS + ACS + COS + AII)
  2152. tmpbud2d = ( sum(collect4d(:,:,:,iBCais ),3) + sum(collect4d(:,:,:,iBCacs ),3) + &
  2153. sum(collect4d(:,:,:,iBCcos ),3) + sum(collect4d(:,:,:,iBCaii ),3) ) * xmbc
  2154. mixf(region)%f2d(emibc)%field = tmpbud2d - emission(region)%f2dslast(:,:,2)
  2155. emission(region)%f2dslast(:,:,2) = tmpbud2d
  2156. ! SO2
  2157. tmpbud2d = sum(collect4d(:,:,:,iSO2 ),3) * xmso2
  2158. mixf(region)%f2d(emiso2)%field = tmpbud2d - emission(region)%f2dslast(:,:,3)
  2159. emission(region)%f2dslast(:,:,3) = tmpbud2d
  2160. ! SO4 (NUS + AIS + ACS + COS)
  2161. tmpbud2d = ( sum(collect4d(:,:,:,iSO4nus),3) + sum(collect4d(:,:,:,iSO4ais),3) + &
  2162. sum(collect4d(:,:,:,iSO4acs),3) + sum(collect4d(:,:,:,iSO4cos),3) ) * xmso4
  2163. mixf(region)%f2d(emiso4)%field = tmpbud2d - emission(region)%f2dslast(:,:,4)
  2164. emission(region)%f2dslast(:,:,4) = tmpbud2d
  2165. ! Dust (ACS + COS + ACI + COI)
  2166. tmpbud2d = ( sum(collect4d(:,:,:,iDUacs ),3) + sum(collect4d(:,:,:,iDUcos ),3) + &
  2167. sum(collect4d(:,:,:,iDUaci ),3) + sum(collect4d(:,:,:,iDUcoi ),3) ) * xmdust
  2168. mixf(region)%f2d(emidust)%field = tmpbud2d - emission(region)%f2dslast(:,:,5)
  2169. emission(region)%f2dslast(:,:,5) = tmpbud2d
  2170. ! DMS
  2171. tmpbud2d = sum(collect4d(:,:,:,iDMS ),3) * xmdms
  2172. mixf(region)%f2d(emidms)%field = tmpbud2d - emission(region)%f2dslast(:,:,6)
  2173. emission(region)%f2dslast(:,:,6) = tmpbud2d
  2174. ! Seasalt: (ACS + COS)
  2175. tmpbud2d = ( sum(collect4d(:,:,:,iSSacs ),3) + sum(collect4d(:,:,:,iSScos ),3) ) * xmnacl
  2176. mixf(region)%f2d(emiss)%field = tmpbud2d - emission(region)%f2dslast(:,:,7)
  2177. emission(region)%f2dslast(:,:,7) = tmpbud2d
  2178. ! terpene:
  2179. tmpbud2d = sum(collect4d(:,:,:,iterp ),3) * xmterp
  2180. mixf(region)%f2d(emiterp)%field = tmpbud2d - emission(region)%f2dslast(:,:,8)
  2181. emission(region)%f2dslast(:,:,8) = tmpbud2d
  2182. ! isoprene:
  2183. tmpbud2d = sum(collect4d(:,:,:,iisop ),3) * xmisop
  2184. mixf(region)%f2d(emiisop)%field = tmpbud2d - emission(region)%f2dslast(:,:,9)
  2185. emission(region)%f2dslast(:,:,9) = tmpbud2d
  2186. deallocate( tmpbud2d )
  2187. deallocate( collect4d )
  2188. ! --------------
  2189. ! DRY DEPOSITION
  2190. ! --------------
  2191. allocate( collect3d(i1:i2,j1:j2,ntrace) ); collect3d = 0.0
  2192. ! deposition is in [mole]
  2193. ! convert first to kilomole per area [k-mole/m2]
  2194. do j = j1, j2
  2195. #ifndef without_chemistry
  2196. collect3d(:,j,:) = buddry_dat(region)%dry(i1:i2,j,:) / dxyp(j) * 1.E-3
  2197. #endif
  2198. ! Add sedimentation at the surface to dry depostion
  2199. ! Sedimentation budgets have to be summed in the vertical
  2200. ! to get the surface contribution.
  2201. #ifndef without_sedimentation
  2202. do l = 1, nbud_vg
  2203. do n = 1, nsed
  2204. collect3d(:,j,ised(n)) = collect3d(:,j,ised(n)) + &
  2205. buddep_m7_dat(region)%sed(i1:i2,j,l,n) / dxyp(j) * 1.E-3
  2206. end do
  2207. end do
  2208. #endif
  2209. end do
  2210. allocate( tmpbud2d(i1:i2,j1:j2) )
  2211. ! on the way: convert from kilomole/m2 to kg/m2 via molar mass [g/mole]
  2212. ! SO2
  2213. tmpbud2d = collect3d(:,:,iSO2) * xmso2
  2214. mixf(region)%f2d(dryso2)%field = tmpbud2d - drydepos(region)%f2dslast(:,:,1)
  2215. drydepos(region)%f2dslast(:,:,1) = tmpbud2d
  2216. ! POM (AIS + ACS + COS + AII)
  2217. tmpbud2d = ( collect3d(:,:,iPOMais ) + collect3d(:,:,iPOMacs ) + &
  2218. collect3d(:,:,iPOMcos ) + collect3d(:,:,iPOMaii )) * xmpom
  2219. mixf(region)%f2d(dryoa)%field = tmpbud2d - drydepos(region)%f2dslast(:,:,2)
  2220. drydepos(region)%f2dslast(:,:,2) = tmpbud2d
  2221. ! SOA (NUS + AIS + ACS + COS + AII)
  2222. tmpbud2d = ( collect3d(:,:,iSOAais ) + collect3d(:,:,iSOAacs ) + &
  2223. collect3d(:,:,iSOAcos ) + collect3d(:,:,iSOAaii ) + &
  2224. collect3d(:,:,iSOAnus )) * xmpom
  2225. mixf(region)%f2d(drysoa)%field = tmpbud2d - drydepos(region)%f2dslast(:,:,8)
  2226. drydepos(region)%f2dslast(:,:,8) = tmpbud2d
  2227. ! BC (AIS + ACS + COS + AII)
  2228. tmpbud2d = ( collect3d(:,:,iBCais ) + collect3d(:,:,iBCacs ) + &
  2229. collect3d(:,:,iBCcos ) + collect3d(:,:,iBCaii ) ) * xmbc
  2230. mixf(region)%f2d(drybc)%field = tmpbud2d - drydepos(region)%f2dslast(:,:,3)
  2231. drydepos(region)%f2dslast(:,:,3) = tmpbud2d
  2232. ! SO4 (NUS + AIS + ACS + COS)
  2233. tmpbud2d = ( collect3d(:,:,iSO4nus) + collect3d(:,:,iSO4ais) + &
  2234. collect3d(:,:,iSO4acs) + collect3d(:,:,iSO4cos) ) * xmso4
  2235. mixf(region)%f2d(dryso4)%field = tmpbud2d - drydepos(region)%f2dslast(:,:,4)
  2236. drydepos(region)%f2dslast(:,:,4) = tmpbud2d
  2237. ! Dust (ACS + COS + ACI + COI)
  2238. tmpbud2d = ( collect3d(:,:,iDUacs) + collect3d(:,:,iDUcos) + &
  2239. collect3d(:,:,iDUaci) + collect3d(:,:,iDUcoi) ) * xmdust
  2240. mixf(region)%f2d(drydust)%field = tmpbud2d - drydepos(region)%f2dslast(:,:,5)
  2241. drydepos(region)%f2dslast(:,:,5) = tmpbud2d
  2242. ! DMS
  2243. ! DMS is NOT deposited in TM5 --> the fields will contain zeros
  2244. tmpbud2d = collect3d(:,:,iDMS) * xmdms
  2245. mixf(region)%f2d(drydms)%field = tmpbud2d - drydepos(region)%f2dslast(:,:,6)
  2246. drydepos(region)%f2dslast(:,:,6) = tmpbud2d
  2247. ! Seasalt: (ACS + COS)
  2248. tmpbud2d = ( collect3d(:,:,iSSacs) + collect3d(:,:,iSScos) ) * xmnacl
  2249. mixf(region)%f2d(dryss)%field = tmpbud2d - drydepos(region)%f2dslast(:,:,7)
  2250. drydepos(region)%f2dslast(:,:,7) = tmpbud2d
  2251. deallocate( tmpbud2d )
  2252. deallocate( collect3d )
  2253. ! --------------
  2254. ! WET DEPOSITION
  2255. ! --------------
  2256. allocate( collect4d (i1:i2,j1:j2,nbud_vg,ntracet) ); collect4d = 0.0
  2257. ! deposition is in [mole]
  2258. ! convert first to kilomole per area [k-mole/m2]
  2259. do j = j1, j2
  2260. collect4d(:,j,:,:) = ( buddep_dat(region)%lsp(i1:i2,j,:,:) + buddep_dat(region)%cp(i1:i2,j,:,:) ) / dxyp(j) * 1.E-3
  2261. end do
  2262. allocate( tmpbud2d(i1:i2,j1:j2) )
  2263. ! on the way: convert from kilomole/m2 to kg/m2 via molar mass [g/mole]
  2264. ! POM (AIS + ACS + COS + AII)
  2265. tmpbud2d = ( sum(collect4d(:,:,:,iPOMais),3) + sum(collect4d(:,:,:,iPOMacs),3) + &
  2266. sum(collect4d(:,:,:,iPOMcos),3) + sum(collect4d(:,:,:,iPOMaii),3)) * xmpom
  2267. mixf(region)%f2d(wetoa)%field = tmpbud2d - wetdepos(region)%f2dslast(:,:,1)
  2268. wetdepos(region)%f2dslast(:,:,1) = tmpbud2d
  2269. ! SOA (NUS + AIS + ACS + COS + AII)
  2270. tmpbud2d = ( sum(collect4d(:,:,:,iSOAais),3) + sum(collect4d(:,:,:,iSOAacs),3) + &
  2271. sum(collect4d(:,:,:,iSOAcos),3) + sum(collect4d(:,:,:,iSOAaii),3) + &
  2272. sum(collect4d(:,:,:,iSOAnus),3)) * xmpom
  2273. mixf(region)%f2d(wetsoa)%field = tmpbud2d - wetdepos(region)%f2dslast(:,:,8)
  2274. wetdepos(region)%f2dslast(:,:,8) = tmpbud2d
  2275. ! BC (AIS + ACS + COS + AII)
  2276. tmpbud2d = ( sum(collect4d(:,:,:,iBCais ),3) + sum(collect4d(:,:,:,iBCacs ),3) + &
  2277. sum(collect4d(:,:,:,iBCcos ),3) + sum(collect4d(:,:,:,iBCaii ),3) ) * xmbc
  2278. mixf(region)%f2d(wetbc)%field = tmpbud2d - wetdepos(region)%f2dslast(:,:,2)
  2279. wetdepos(region)%f2dslast(:,:,2) = tmpbud2d
  2280. ! SO2
  2281. tmpbud2d = sum(collect4d(:,:,:,iSO2 ),3) * xmso2
  2282. mixf(region)%f2d(wetso2)%field = tmpbud2d - wetdepos(region)%f2dslast(:,:,3)
  2283. wetdepos(region)%f2dslast(:,:,3) = tmpbud2d
  2284. ! SO4 (NUS + AIS + ACS + COS)
  2285. tmpbud2d = ( sum(collect4d(:,:,:,iSO4nus),3) + sum(collect4d(:,:,:,iSO4ais),3) + &
  2286. sum(collect4d(:,:,:,iSO4acs),3) + sum(collect4d(:,:,:,iSO4cos),3) ) * xmso4
  2287. mixf(region)%f2d(wetso4)%field = tmpbud2d - wetdepos(region)%f2dslast(:,:,4)
  2288. wetdepos(region)%f2dslast(:,:,4) = tmpbud2d
  2289. ! Dust (ACS + COS + ACI + COI)
  2290. tmpbud2d = ( sum(collect4d(:,:,:,iDUacs ),3) + sum(collect4d(:,:,:,iDUcos ),3) + &
  2291. sum(collect4d(:,:,:,iDUaci ),3) + sum(collect4d(:,:,:,iDUcoi ),3) ) * xmdust
  2292. mixf(region)%f2d(wetdust)%field = tmpbud2d - wetdepos(region)%f2dslast(:,:,5)
  2293. wetdepos(region)%f2dslast(:,:,5) = tmpbud2d
  2294. ! DMS
  2295. ! DMS is NOT deposited in TM5 --> the fields will contain zeros
  2296. tmpbud2d = sum(collect4d(:,:,:,iDMS ),3) * xmdms
  2297. mixf(region)%f2d(wetdms)%field = tmpbud2d - wetdepos(region)%f2dslast(:,:,6)
  2298. wetdepos(region)%f2dslast(:,:,6) = tmpbud2d
  2299. ! Seasalt: (ACS + COS)
  2300. tmpbud2d = ( sum(collect4d(:,:,:,iSSacs ),3) + sum(collect4d(:,:,:,iSScos ),3) ) * xmnacl
  2301. mixf(region)%f2d(wetss)%field = tmpbud2d - wetdepos(region)%f2dslast(:,:,7)
  2302. wetdepos(region)%f2dslast(:,:,7) = tmpbud2d
  2303. deallocate( tmpbud2d )
  2304. deallocate( collect4d )
  2305. nullify(dxyp)
  2306. call goLabel() ; status = 0
  2307. end subroutine collect_budgets
  2308. !EOC
  2309. subroutine add_variable(region,itm5,varname,longname,unit,dims,n_out,status)
  2310. use chem_param, only: mode_end_so4,mode_end_pom,mode_end_bc,mode_end_ss,mode_end_dust
  2311. implicit none
  2312. integer:: itm5
  2313. integer:: fileunit
  2314. integer:: varid
  2315. character(len=*)::varname
  2316. character(len=*)::longname
  2317. character(len=*)::unit
  2318. integer:: dims
  2319. integer:: region
  2320. integer,intent(out)::n_out
  2321. integer,intent(out)::status
  2322. logical :: writeout=.true.
  2323. character(len=*), parameter :: rname = mname//'/output_aerchemmip_add_variable'
  2324. integer ::i1,i2,j1,j2,jmr,imr,lmr
  2325. call goLabel(rname)
  2326. !call GO_Timer_Start( itim_addvar, status )
  2327. !IF_NOTOK_RETURN(status=1)
  2328. !write(gol,'("add_variable1")')
  2329. !call goErr
  2330. if( (n_2d_vars+1>ntracer_2d) .or.(n_3d_vars+1>ntracer_3d) ) then
  2331. status=1
  2332. IF_ERROR_RETURN(status=1)
  2333. end if
  2334. call Get_DistGrid( dgrid(1), I_STRT=i1, I_STOP=i2, J_STRT=j1, J_STOP=j2 )
  2335. ! define sizes for arrays
  2336. imr=i2-i1+1
  2337. jmr=j2-j1+1
  2338. lmr = levi%nlev
  2339. ! 2D variables
  2340. if (dims==2) then
  2341. !init variable
  2342. n_2d_vars=n_2d_vars+1
  2343. mixf(region)%f2d(n_2d_vars)%mf = metafields( itm5 , varname,longname,unit,'','')
  2344. mixf(region)%f2d(n_2d_vars)%writeout=writeout
  2345. !Later make the allocation here
  2346. !allocate( mixf(region)%f2d(n_2d_vars)%field(i1:i2,j1:j2) )
  2347. mixf(region)%f2d(n_2d_vars)%field(i1:i2,j1:j2)=0.0
  2348. n_out=n_2d_vars
  2349. else if (dims==3) then
  2350. !init variable
  2351. n_3d_vars=n_3d_vars+1
  2352. mixf(region)%f3d(n_3d_vars)%mf = metafields( itm5 , varname,longname,unit,'','')
  2353. mixf(region)%f3d(n_3d_vars)%writeout=writeout
  2354. !Later make the allocation here
  2355. !allocate( mixf(region)%f3d(n_3d_vars)%field(i1:i2,j1:j2,lmr) )
  2356. mixf(region)%f3d(n_3d_vars)%field(i1:i2,j1:j2,lmr)=0.0
  2357. n_out=n_3d_vars
  2358. end if
  2359. call goLabel()
  2360. status = 0
  2361. !call GO_Timer_End( itim_addvar, status )
  2362. !IF_NOTOK_RETURN(status=1)
  2363. end subroutine add_variable
  2364. subroutine CCN_Diag(CCN,mass_num,cmr,temper)
  2365. use chem_param, only : iso4ais, iso4acs, iso4cos, ibcais, ibcacs, ibccos, ipomais, ipomacs
  2366. use chem_param, only : ipomcos, issacs, isscos, iduacs, iducos, isoaais, isoaacs, isoacos
  2367. use chem_param, only : iais_n, iacs_n, icos_n, sigma_lognormal
  2368. use chem_param, only : ino3_a, imsa, nh4no3_factor, nh4no3_density, msa_density
  2369. use chem_param, only : SurfTen, mode_tracers
  2370. use chem_param, only : Kap_su, Kap_pom, Kap_soa, Kap_bc, Kap_du, Kap_ss, Kap_na2so4, Kap_no3, Kap_msa
  2371. use chem_param, only : so4_density, pom_density, soa_density, carbon_density, ss_density, dust_density
  2372. use mo_aero_m7, only : cmr2ram, nsol, ram2cmr
  2373. use mo_aero_m7, only : dNaCl, dH2SO4, dNa2SO4, wNaCl, wH2SO4, wNa2SO4, wSO4
  2374. use binas, only : pi, Rgas, xm_h2o, rol
  2375. implicit none
  2376. integer :: iSat, iMode
  2377. real :: CCN(:,:,:,:), mass_num(:,:,:,:), cmr(:,:,:,:), temper(:,:,:)
  2378. real, allocatable :: Vol(:,:,:), Kappa(:,:,:), A_Koehler(:,:,:)
  2379. real, allocatable :: N_act(:,:,:), rc(:,:,:)
  2380. real, allocatable :: nNa(:,:,:), nCl(:,:,:), nNaCl(:,:,:), nH2SO4(:,:,:), nNa2SO4(:,:,:), nSO4(:,:,:)
  2381. CCN(:,:,:,:) = 0.e0
  2382. cmr(:,:,:,:) = 0.e0
  2383. allocate(Vol(size(CCN,2),size(CCN,3),size(CCN,4)))
  2384. allocate(Kappa(size(CCN,2),size(CCN,3),size(CCN,4)))
  2385. allocate(A_Koehler(size(CCN,2),size(CCN,3),size(CCN,4)))
  2386. allocate(N_act(size(CCN,2),size(CCN,3),size(CCN,4)))
  2387. allocate(rc(size(CCN,2),size(CCN,3),size(CCN,4)))
  2388. allocate(nNa(size(CCN,2),size(CCN,3),size(CCN,4)))
  2389. allocate(nCl(size(CCN,2),size(CCN,3),size(CCN,4)))
  2390. allocate(nSO4(size(CCN,2),size(CCN,3),size(CCN,4)))
  2391. allocate(nNaCl(size(CCN,2),size(CCN,3),size(CCN,4)))
  2392. allocate(nNa2SO4(size(CCN,2),size(CCN,3),size(CCN,4)))
  2393. allocate(nH2SO4(size(CCN,2),size(CCN,3),size(CCN,4)))
  2394. do iMode = 2,nsol
  2395. ! Kappa
  2396. SELECT CASE (iMode)
  2397. CASE(2) ! no sea salt and dust in soluble aitken mode
  2398. nSO4= mass_num(:,:,:,iso4ais)/(1.e-3*wSO4)
  2399. nH2SO4 = nSO4
  2400. Vol = ( nH2SO4*1.e-3*wH2SO4/(dH2SO4*1.e3)*(wH2SO4/wSO4) & !mass_num(:,:,:,iso4ais)/so4_density &
  2401. + mass_num(:,:,:,ipomais)/pom_density &
  2402. + mass_num(:,:,:,isoaais)/soa_density &
  2403. + mass_num(:,:,:,ibcais)/carbon_density) ! m3/gridbox
  2404. Kappa= ( Kap_su*nH2SO4*1.e-3*wH2SO4/(dH2SO4*1.e3)*(wH2SO4/wSO4) &!mass_num(:,:,:,iso4ais)/so4_density &
  2405. + Kap_pom*mass_num(:,:,:,ipomais)/pom_density &
  2406. + Kap_soa*mass_num(:,:,:,isoaais)/soa_density &
  2407. + Kap_bc*mass_num(:,:,:,ibcais)/carbon_density) / Vol
  2408. cmr(iMode,:,:,:) = ram2cmr(iMode)*(Vol/mass_num(:,:,:,iais_n)*0.75/pi)**(1./3.) ! m
  2409. CASE(3)
  2410. nNa = mass_num(:,:,:,issacs)/(1.e-3*wNaCl) ! mol/gridbox
  2411. nCl = nNa
  2412. nSO4= mass_num(:,:,:,iso4acs)/(1.e-3*wSO4)
  2413. nNa2SO4 = MIN(nNa/2.e0, nSO4)
  2414. nNa = nNa - 2.e0*nNa2SO4 ! remaining nNa
  2415. nNaCl = MIN(nCl, nNa)
  2416. nCl = nNaCl ! overshoot nCl is supposed to evaporate
  2417. nH2SO4 = nSO4 - nNa2SO4
  2418. Vol = ( nNaCl*1.e-3*wNaCl/(dNaCl*1.e3) &
  2419. + nNa2SO4*1.e-3*wNa2SO4/(dNa2SO4*1.e3) &
  2420. + nH2SO4*1.e-3*wH2SO4/(dH2SO4*1.e3) &
  2421. + mass_num(:,:,:,ipomacs)/pom_density &
  2422. + mass_num(:,:,:,isoaacs)/soa_density &
  2423. + mass_num(:,:,:,ibcacs)/carbon_density &
  2424. + mass_num(:,:,:,iduacs)/dust_density &
  2425. + mass_num(:,:,:,ino3_a)*nh4no3_factor/nh4no3_density &
  2426. + mass_num(:,:,:,imsa)/msa_density) ! m3/gridbox
  2427. Kappa= ( Kap_su*nH2SO4*1.e-3*wH2SO4/(dH2SO4*1.e3) &
  2428. + Kap_na2so4*nNa2SO4*1.e-3*wNa2SO4/(dNa2SO4*1.e3) &
  2429. + Kap_pom*mass_num(:,:,:,ipomacs)/pom_density &
  2430. + Kap_soa*mass_num(:,:,:,isoaacs)/soa_density &
  2431. + Kap_bc*mass_num(:,:,:,ibcacs)/carbon_density &
  2432. + Kap_ss*nNaCl*1.e-3*wNaCl/(dNaCl*1.e3) &
  2433. + Kap_du*mass_num(:,:,:,iduacs)/dust_density &
  2434. + Kap_no3*mass_num(:,:,:,ino3_a)*nh4no3_factor/nh4no3_density &
  2435. + Kap_msa*mass_num(:,:,:,imsa)/msa_density) / Vol
  2436. cmr(iMode,:,:,:) = ( Vol/mass_num(:,:,:,iacs_n)*0.75/pi)**(1./3.)*ram2cmr(iMode) ! m
  2437. CASE(4)
  2438. nNa = mass_num(:,:,:,isscos)/(1.e-3*wNaCl) ! mol/gridbox
  2439. nCl = nNa
  2440. nSO4= mass_num(:,:,:,iso4cos)/(1.e-3*wSO4)
  2441. nNa2SO4 = MIN(nNa/2.e0, nSO4)
  2442. nNa = nNa - 2.e0*nNa2SO4 ! remaining nNa
  2443. nNaCl = MIN(nCl, nNa)
  2444. nCl = nNaCl ! overshoot nCl is supposed to evaporate
  2445. nH2SO4 = nSO4 - nNa2SO4
  2446. Vol = ( nNaCl*1.e-3*wNaCl/(dNaCl*1.e3) &
  2447. + nNa2SO4*1.e-3*wNa2SO4/(dNa2SO4*1.e3) &
  2448. + nH2SO4*1.e-3*wH2SO4/(dH2SO4*1.e3) &
  2449. + mass_num(:,:,:,ipomcos)/pom_density &
  2450. + mass_num(:,:,:,isoacos)/soa_density &
  2451. + mass_num(:,:,:,ibccos)/carbon_density &
  2452. + mass_num(:,:,:,iducos)/dust_density) ! m3/gridbox
  2453. Kappa= ( Kap_su*nH2SO4*1.e-3*wH2SO4/(dH2SO4*1.e3) &
  2454. + Kap_na2so4*nNa2SO4*1.e-3*wNa2SO4/(dNa2SO4*1.e3) &
  2455. + Kap_pom*mass_num(:,:,:,ipomcos)/pom_density &
  2456. + Kap_soa*mass_num(:,:,:,isoacos)/soa_density &
  2457. + Kap_bc*mass_num(:,:,:,ibccos)/carbon_density &
  2458. + Kap_ss*nNaCl*1.e-3*wNaCl/(dNaCl*1.e3) &
  2459. + Kap_du*mass_num(:,:,:,iducos)/dust_density) / Vol
  2460. cmr(iMode,:,:,:) = ( Vol/mass_num(:,:,:,icos_n)*0.75/pi)**(1./3.)*ram2cmr(iMode) ! m
  2461. END SELECT
  2462. where(Kappa < 0.04) Kappa = 0.04
  2463. A_Koehler = 2.0 * xm_h2o * SurfTen / Rgas / rol / temper
  2464. do iSat=1,nSat
  2465. ! critical radius per mode
  2466. rc = A_Koehler/3.0 * (2.0/SuperSat(iSat)/sqrt(Kappa))**(2.0/3.0)
  2467. ! number of activated particles
  2468. N_act = mass_num(:,:,:,mode_tracers(0,iMode)) * 0.5*erfc( log(rc/cmr(iMode,:,:,:)) / &
  2469. sqrt(2.e0)/log(sigma_lognormal(iMode)) )
  2470. CCN(iSat,:,:,:) = CCN(iSat,:,:,:) + N_act ! #/gridbox
  2471. enddo
  2472. enddo
  2473. deallocate(Vol)
  2474. deallocate(Kappa)
  2475. deallocate(A_Koehler)
  2476. deallocate(rc)
  2477. deallocate(N_act)
  2478. end subroutine CCN_Diag
  2479. subroutine Kappa_diag(CCN,mass_num,cmr,temper,N_r,Kappa_r)
  2480. use chem_param, only : iso4ais, iso4acs, iso4cos, ibcais, ibcacs, ibccos, ipomais, ipomacs
  2481. use chem_param, only : ipomcos, issacs, isscos, iduacs, iducos, isoaais, isoaacs, isoacos
  2482. use chem_param, only : iais_n, iacs_n, icos_n, sigma_lognormal
  2483. use chem_param, only : ino3_a, imsa, nh4no3_factor, nh4no3_density, msa_density
  2484. use chem_param, only : SurfTen, mode_tracers
  2485. use chem_param, only : Kap_su, Kap_pom, Kap_soa, Kap_bc, Kap_du, Kap_ss, Kap_na2so4, Kap_no3, Kap_msa
  2486. use chem_param, only : so4_density, pom_density, soa_density, carbon_density, ss_density, dust_density
  2487. use mo_aero_m7, only : cmr2ram, nsol, ram2cmr
  2488. use mo_aero_m7, only : dNaCl, dH2SO4, dNa2SO4, wNaCl, wH2SO4, wNa2SO4, wSO4
  2489. use binas, only : pi, Rgas, xm_h2o, rol
  2490. implicit none
  2491. integer :: iSat, iMode,i_rad
  2492. real :: CCN(:,:,:,:), mass_num(:,:,:,:), cmr(:,:,:,:), temper(:,:,:)
  2493. real :: N_r(:,:,:,:), Kappa_r(:,:,:,:)
  2494. real, allocatable :: Vol(:,:,:), Kappa(:,:,:), A_Koehler(:,:,:)
  2495. real, allocatable :: N_act(:,:,:), rc(:)
  2496. real, allocatable :: nNa(:,:,:), nCl(:,:,:), nNaCl(:,:,:), nH2SO4(:,:,:), nNa2SO4(:,:,:), nSO4(:,:,:)
  2497. real, allocatable :: Volss(:,:,:)
  2498. real, allocatable :: Voldu(:,:,:)
  2499. real, allocatable :: Volsu(:,:,:)
  2500. real, allocatable :: Volbc(:,:,:)
  2501. real, allocatable :: Volpom(:,:,:)
  2502. real, allocatable :: Volsoa(:,:,:)
  2503. real, allocatable :: Volna2so4(:,:,:)
  2504. real, allocatable :: Volmsa(:,:,:)
  2505. real, allocatable :: Volno3(:,:,:)
  2506. real, allocatable :: Volsum(:,:,:)
  2507. real, allocatable :: over_rad_frac(:,:,:)
  2508. ! CCN(:,:,:,:) = 0.e0
  2509. cmr(:,:,:,:) = 0.e0
  2510. N_r(:,:,:,:) = 0.e0
  2511. Kappa_r(:,:,:,:) = 0.e0
  2512. allocate(Vol(size(CCN,2),size(CCN,3),size(CCN,4)))
  2513. allocate(Volsu(size(CCN,2),size(CCN,3),size(CCN,4)))
  2514. allocate(Volss(size(CCN,2),size(CCN,3),size(CCN,4)))
  2515. allocate(Voldu(size(CCN,2),size(CCN,3),size(CCN,4)))
  2516. allocate(Volbc(size(CCN,2),size(CCN,3),size(CCN,4)))
  2517. allocate(Volsoa(size(CCN,2),size(CCN,3),size(CCN,4)))
  2518. allocate(Volpom(size(CCN,2),size(CCN,3),size(CCN,4)))
  2519. allocate(Volna2so4(size(CCN,2),size(CCN,3),size(CCN,4)))
  2520. allocate(Volmsa(size(CCN,2),size(CCN,3),size(CCN,4)))
  2521. allocate(Volno3(size(CCN,2),size(CCN,3),size(CCN,4)))
  2522. allocate(Volsum(size(CCN,2),size(CCN,3),size(CCN,4)))
  2523. allocate(over_rad_frac(size(CCN,2),size(CCN,3),size(CCN,4)))
  2524. volsum(:,:,:)=0.e0
  2525. volss(:,:,:)=0.e0
  2526. voldu(:,:,:)=0.e0
  2527. volbc(:,:,:)=0.e0
  2528. volsu(:,:,:)=0.e0
  2529. volpom(:,:,:)=0.e0
  2530. volsoa(:,:,:)=0.e0
  2531. volna2so4(:,:,:)=0.e0
  2532. volmsa(:,:,:)=0.e0
  2533. volno3(:,:,:)=0.e0
  2534. over_rad_frac(:,:,:)=0.e0
  2535. ! allocate(N_r(3,size(CCN,2),size(CCN,3),size(CCN,4)))
  2536. ! allocate(Kappa_r(size(CCN,2),size(CCN,3),size(CCN,4)))
  2537. allocate(Kappa(size(CCN,2),size(CCN,3),size(CCN,4)))
  2538. allocate(A_Koehler(size(CCN,2),size(CCN,3),size(CCN,4)))
  2539. allocate(N_act(size(CCN,2),size(CCN,3),size(CCN,4)))
  2540. ! allocate(rc(size(CCN,2),size(CCN,3),size(CCN,4)))
  2541. allocate(rc(3))
  2542. allocate(nNa(size(CCN,2),size(CCN,3),size(CCN,4)))
  2543. allocate(nCl(size(CCN,2),size(CCN,3),size(CCN,4)))
  2544. allocate(nSO4(size(CCN,2),size(CCN,3),size(CCN,4)))
  2545. allocate(nNaCl(size(CCN,2),size(CCN,3),size(CCN,4)))
  2546. allocate(nNa2SO4(size(CCN,2),size(CCN,3),size(CCN,4)))
  2547. allocate(nH2SO4(size(CCN,2),size(CCN,3),size(CCN,4)))
  2548. !Diam for N
  2549. !BACCHUS defs D=50,80,120nm->r=25,40,60
  2550. rc(1)= 25.0e-9
  2551. rc(2)= 40.0e-9
  2552. rc(3)= 60.0e-9
  2553. do i_rad =1,3
  2554. !neglect nucleation mode
  2555. do iMode = 2,nsol
  2556. ! Kappa
  2557. SELECT CASE (iMode)
  2558. CASE(2) ! no sea salt and dust in soluble aitken mode
  2559. nSO4= mass_num(:,:,:,iso4ais)/(1.e-3*wSO4)
  2560. nH2SO4 = nSO4
  2561. Vol = ( nH2SO4*1.e-3*wH2SO4/(dH2SO4*1.e3) &! mass_num(:,:,:,iso4ais)/so4_density &
  2562. + mass_num(:,:,:,ipomais)/pom_density &
  2563. + mass_num(:,:,:,isoaais)/soa_density &
  2564. + mass_num(:,:,:,ibcais)/carbon_density) ! m3/gridbox
  2565. Kappa= ( Kap_su*nH2SO4*1.e-3*wH2SO4/(dH2SO4*1.e3) &!mass_num(:,:,:,iso4ais)/so4_density &
  2566. + Kap_pom*mass_num(:,:,:,ipomais)/pom_density &
  2567. + Kap_soa*mass_num(:,:,:,isoaais)/soa_density &
  2568. + Kap_bc*mass_num(:,:,:,ibcais)/carbon_density) / Vol
  2569. cmr(iMode,:,:,:) = ram2cmr(iMode)*(Vol/mass_num(:,:,:,iais_n)*0.75/pi)**(1./3.) ! m
  2570. !fraction over threshold
  2571. over_rad_frac= 0.5*erfc( log(rc(i_rad)/cmr(iMode,:,:,:)) / &
  2572. sqrt(2.e0)/log(sigma_lognormal(iMode)) )
  2573. volsu= volsu + nH2SO4*1.e-3*wH2SO4/(dH2SO4*1.e3) * over_rad_frac
  2574. volpom = volpom + mass_num(:,:,:,ipomais)/pom_density * over_rad_frac
  2575. volsoa = volsoa + mass_num(:,:,:,isoaais)/soa_density * over_rad_frac
  2576. volbc = volbc + mass_num(:,:,:,ibcais)/carbon_density * over_rad_frac
  2577. N_r(i_rad,:,:,:) = N_r(i_rad,:,:,:)+mass_num(:,:,:,mode_tracers(0,iMode)) * 0.5*erfc( log(rc(i_rad)/cmr(iMode,:,:,:)) / &
  2578. sqrt(2.e0)/log(sigma_lognormal(iMode)) )
  2579. CASE(3)
  2580. nNa = mass_num(:,:,:,issacs)/(1.e-3*wNaCl) ! mol/gridbox
  2581. nCl = nNa
  2582. nSO4= mass_num(:,:,:,iso4acs)/(1.e-3*wSO4)
  2583. nNa2SO4 = MIN(nNa/2.e0, nSO4)
  2584. nNa = nNa - 2.e0*nNa2SO4 ! remaining nNa
  2585. nNaCl = MIN(nCl, nNa)
  2586. nCl = nNaCl ! overshoot nCl is supposed to evaporate
  2587. nH2SO4 = nSO4 - nNa2SO4
  2588. Vol = ( nNaCl*1.e-3*wNaCl/(dNaCl*1.e3) &
  2589. + nNa2SO4*1.e-3*wNa2SO4/(dNa2SO4*1.e3) &
  2590. + nH2SO4*1.e-3*wH2SO4/(dH2SO4*1.e3) &
  2591. + mass_num(:,:,:,ipomacs)/pom_density &
  2592. + mass_num(:,:,:,isoaacs)/soa_density &
  2593. + mass_num(:,:,:,ibcacs)/carbon_density &
  2594. + mass_num(:,:,:,iduacs)/dust_density &
  2595. + mass_num(:,:,:,ino3_a)*nh4no3_factor/nh4no3_density &
  2596. + mass_num(:,:,:,imsa)/msa_density) ! m3/gridbox
  2597. Kappa= ( Kap_su*nH2SO4*1.e-3*wH2SO4/(dH2SO4*1.e3) &
  2598. + Kap_na2so4*nNa2SO4*1.e-3*wNa2SO4/(dNa2SO4*1.e3) &
  2599. + Kap_pom*mass_num(:,:,:,ipomacs)/pom_density &
  2600. + Kap_soa*mass_num(:,:,:,isoaacs)/soa_density &
  2601. + Kap_bc*mass_num(:,:,:,ibcacs)/carbon_density &
  2602. + Kap_ss*nNaCl*1.e-3*wNaCl/(dNaCl*1.e3) &
  2603. + Kap_du*mass_num(:,:,:,iduacs)/dust_density &
  2604. + Kap_no3*mass_num(:,:,:,ino3_a)*nh4no3_factor/nh4no3_density &
  2605. + Kap_msa*mass_num(:,:,:,imsa)/msa_density) / Vol
  2606. cmr(iMode,:,:,:) = ( Vol/mass_num(:,:,:,iacs_n)*0.75/pi)**(1./3.)*ram2cmr(iMode) ! m
  2607. over_rad_frac= 0.5*erfc( log(rc(i_rad)/cmr(iMode,:,:,:)) / &
  2608. sqrt(2.e0)/log(sigma_lognormal(iMode)) )
  2609. volsu= volsu + nH2SO4*1.e-3*wH2SO4/(dH2SO4*1.e3) * over_rad_frac
  2610. volna2so4= volna2so4 + nNa2SO4*1.e-3*wNa2SO4/(dNa2SO4*1.e3) * over_rad_frac
  2611. volpom = volpom + mass_num(:,:,:,ipomacs)/pom_density * over_rad_frac
  2612. volsoa = volsoa + mass_num(:,:,:,isoaacs)/soa_density * over_rad_frac
  2613. volbc = volbc + mass_num(:,:,:,ibcacs)/carbon_density * over_rad_frac
  2614. volss =volss + nNaCl*1.e-3*wNaCl/(dNaCl*1.e3) * over_rad_frac
  2615. voldu = voldu + mass_num(:,:,:,iduacs)/dust_density * over_rad_frac
  2616. volno3 = volno3 + mass_num(:,:,:,ino3_a)*nh4no3_factor/nh4no3_density * over_rad_frac
  2617. volmsa = volmsa + mass_num(:,:,:,imsa)/msa_density * over_rad_frac
  2618. N_r(i_rad,:,:,:) = N_r(i_rad,:,:,:)+mass_num(:,:,:,mode_tracers(0,iMode)) * 0.5*erfc( log(rc(i_rad)/cmr(iMode,:,:,:)) / &
  2619. sqrt(2.e0)/log(sigma_lognormal(iMode)) )
  2620. CASE(4)
  2621. nNa = mass_num(:,:,:,isscos)/(1.e-3*wNaCl) ! mol/gridbox
  2622. nCl = nNa
  2623. nSO4= mass_num(:,:,:,iso4cos)/(1.e-3*wSO4)
  2624. nNa2SO4 = MIN(nNa/2.e0, nSO4)
  2625. nNa = nNa - 2.e0*nNa2SO4 ! remaining nNa
  2626. nNaCl = MIN(nCl, nNa)
  2627. nCl = nNaCl ! overshoot nCl is supposed to evaporate
  2628. nH2SO4 = nSO4 - nNa2SO4
  2629. Vol = ( nNaCl*1.e-3*wNaCl/(dNaCl*1.e3) &
  2630. + nNa2SO4*1.e-3*wNa2SO4/(dNa2SO4*1.e3) &
  2631. + nH2SO4*1.e-3*wH2SO4/(dH2SO4*1.e3) &
  2632. + mass_num(:,:,:,ipomcos)/pom_density &
  2633. + mass_num(:,:,:,isoacos)/soa_density &
  2634. + mass_num(:,:,:,ibccos)/carbon_density &
  2635. + mass_num(:,:,:,iducos)/dust_density) ! m3/gridbox
  2636. cmr(iMode,:,:,:) = ( Vol/mass_num(:,:,:,icos_n)*0.75/pi)**(1./3.)*ram2cmr(iMode)! m
  2637. volsu= volsu + nH2SO4*1.e-3*wH2SO4/(dH2SO4*1.e3)
  2638. volna2so4= volna2so4 + nNa2SO4*1.e-3*wNa2SO4/(dNa2SO4*1.e3)
  2639. volpom = volpom + mass_num(:,:,:,ipomcos)/pom_density
  2640. volsoa = volsoa + mass_num(:,:,:,isoacos)/soa_density
  2641. volbc = volbc + mass_num(:,:,:,ibccos)/carbon_density
  2642. volss =volss + nNaCl*1.e-3*wNaCl/(dNaCl*1.e3)
  2643. voldu = voldu + mass_num(:,:,:,iducos)/dust_density
  2644. N_r(i_rad,:,:,:) = N_r(i_rad,:,:,:)+mass_num(:,:,:,mode_tracers(0,iMode)) * 0.5*erfc( log(rc(i_rad)/cmr(iMode,:,:,:)) / &
  2645. sqrt(2.e0)/log(sigma_lognormal(iMode)) )
  2646. END SELECT
  2647. volsum=volsum+vol
  2648. end do
  2649. Kappa_r(i_rad,:,:,:) = (&
  2650. Kap_su*volsu&
  2651. + Kap_na2so4*volna2so4&
  2652. + Kap_pom*volpom&
  2653. + Kap_soa*volsoa&
  2654. + Kap_bc*volbc&
  2655. + Kap_ss*volss&
  2656. + Kap_no3*volno3&
  2657. + Kap_du*voldu&
  2658. ) / volsum
  2659. !where (Kappa_r>1.0)Kappa_r=1.0
  2660. ! where(Kappa_r < 0.04) Kappa_r = 0.04
  2661. ! Kappa_r(i,:,:,:) =kappa(i,:,:,:)+ Kappa/volsum
  2662. end do
  2663. deallocate(Vol)
  2664. deallocate(Volsu)
  2665. deallocate(Volss)
  2666. deallocate(Voldu)
  2667. deallocate(Volbc)
  2668. deallocate(Volsoa)
  2669. deallocate(Volpom)
  2670. deallocate(Volna2so4)
  2671. deallocate(Volmsa)
  2672. deallocate(Volno3)
  2673. deallocate(Volsum)
  2674. deallocate(over_rad_frac)
  2675. deallocate(Kappa)
  2676. deallocate(A_Koehler)
  2677. deallocate(N_act)
  2678. deallocate(rc)
  2679. deallocate(nNa)
  2680. deallocate(nCl)
  2681. deallocate(nSO4)
  2682. deallocate(nNaCl)
  2683. deallocate(nNa2SO4)
  2684. deallocate(nH2SO4)
  2685. end subroutine Kappa_diag
  2686. end module user_output_general