user_output_general.F90 127 KB

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