emission_sox.F90 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887
  1. !
  2. #define TRACEBACK write (gol,'("in ",a," (",a,", line",i5,")")') rname, __FILE__, __LINE__; call goErr
  3. #define IF_NOTOK_RETURN(action) if (status/=0) then; TRACEBACK; action; return; end if
  4. #define IF_ERROR_RETURN(action) if (status> 0) then; TRACEBACK; action; return; end if
  5. !
  6. #include "tm5.inc"
  7. !
  8. !-----------------------------------------------------------------------------
  9. ! TM5 !
  10. !-----------------------------------------------------------------------------
  11. !BOP
  12. !
  13. ! !MODULE: EMISSION_SOX
  14. !
  15. ! !DESCRIPTION: data and methods for SOx emissions.
  16. !
  17. !
  18. ! AR5 (August 2010):
  19. ! - SO2 emissions are used and split into SO2/SO4
  20. ! - in case of M7, additional partitioning is done into given modes
  21. ! E.V.: 2.5 % of SO2 emissions are supposed to be SO4 (AEROCOM) to
  22. ! take into account the sulphate formation in the plumes,
  23. ! as sub-grid effect. For SO2 the remaining 97.5 % are
  24. ! calculated in the do_add routine. For SO4 they are calculated
  25. ! in the main emission_sox routine
  26. !
  27. ! SO4 emissions:
  28. ! industrial: (From Stier et al. 2004)
  29. ! 100% accumulation mode number
  30. ! median radius = 0.075 um sigma = 1.59
  31. ! domestic - transport - biomass burning :
  32. ! 50% Aitken mode number
  33. ! median radius = 0.03 um sigma = 1.59
  34. ! 50% Accumulation mode number
  35. ! median radius = 0.075 um sigma = 1.59
  36. !>>> TvN
  37. ! The size distributions have been changed following
  38. ! the AeroCom recommendations of Dentener et al. (2006),
  39. ! adapted to the M7 modes (Stier et al., ACP, 2005).
  40. ! For emissions from industry, power plants and shipping
  41. ! a number median radius of 0.5 um was recommended,
  42. ! at the boundary between accumulation and coarse mode.
  43. ! Therefore, the emitted mass from these sources
  44. ! is equally divided between these modes,
  45. ! with median radii of 0.075 and 0.75 um, respectively.
  46. ! Emissions from road and off-road transport and the domestic sector
  47. ! are assumed to be in the Aitken mode,
  48. ! and from biomass burning in the accumulation mode.
  49. ! Since only 2.5% of SOx emissions are emitted as particles,
  50. ! these choices have only minor impacts.
  51. ! See also comments in mo_aero.F90.
  52. !<<< TvN
  53. !\\
  54. !\\
  55. ! !INTERFACE:
  56. !
  57. MODULE EMISSION_SOX
  58. !
  59. ! !USES:
  60. !
  61. use GO, only : gol, goErr, goPr
  62. use dims, only : nregions, idate, okdebug
  63. use global_types, only : emis_data, d3_data
  64. use emission_read, only : used_providers, has_emis
  65. use tm5_distgrid, only : dgrid, get_distgrid, scatter
  66. use partools, only : isRoot, par_broadcast
  67. implicit none
  68. private
  69. !
  70. ! !PUBLIC MEMBER FUNCTIONS:
  71. !
  72. public :: Emission_SOx_Init ! allocate dataset
  73. public :: Emission_SOx_Done ! deallocate dataset
  74. public :: Emission_sox_declare ! read monthly input
  75. public :: Emission_sox_apply ! distribute & add emissions to tracer array
  76. !
  77. ! !PRIVATE DATA MEMBERS:
  78. !
  79. character(len=*), parameter :: mname = 'emission_sox'
  80. type( emis_data ), dimension(:,:), allocatable :: so2_emis_2d
  81. type( d3_data ), dimension(:,:), allocatable :: so2_emis_3d
  82. integer :: so2_3dsec, so2_2dsec
  83. logical, allocatable :: has_data_3d(:), has_data_2d(:)
  84. !
  85. ! !REVISION HISTORY:
  86. ! 2005 - Elisabetta Vignati - changed for coupling with M7
  87. ! 1 Oct 2010 - Achim Strunk - AR5
  88. ! 1 Dec 2011 - Narcisa Banda - added EDGAR 4
  89. ! 27 Jun 2012 - P. Le Sager - adapted for lon-lat MPI domain decomposition
  90. !
  91. ! !REMARKS:
  92. !
  93. !EOP
  94. !------------------------------------------------------------------------
  95. CONTAINS
  96. !--------------------------------------------------------------------------
  97. ! TM5 !
  98. !--------------------------------------------------------------------------
  99. !BOP
  100. !
  101. ! !IROUTINE: EMISSION_SOX_INIT
  102. !
  103. ! !DESCRIPTION: allocate memory
  104. !\\
  105. !\\
  106. ! !INTERFACE:
  107. !
  108. SUBROUTINE EMISSION_SOX_INIT( status )
  109. !
  110. ! !USES:
  111. !
  112. use dims, only : lm
  113. use emission_read, only : providers_def, numb_providers, ed42_nsect_so2
  114. use emission_data, only : LAR5BMB
  115. use emission_read, only : n_ar5_ant_sec, n_ar5_shp_sec, n_ar5_air_sec, n_ar5_bmb_sec
  116. use emission_read, only : ar5_cat_ant, ar5_cat_shp, ar5_cat_air, ar5_cat_bmb
  117. !
  118. ! !OUTPUT PARAMETERS:
  119. !
  120. integer, intent(out) :: status
  121. !
  122. ! !REVISION HISTORY:
  123. ! 1 Oct 2010 - Achim Strunk - AR5 format
  124. ! 27 Jun 2012 - P. Le Sager - adapted for lon-lat MPI domain decomposition
  125. !
  126. !EOP
  127. !------------------------------------------------------------------------
  128. !BOC
  129. character(len=*), parameter :: rname = mname//'/Emission_sox_Init'
  130. integer :: region, lsec
  131. integer :: lmr, lprov, i1, i2, j1, j2
  132. ! --- begin --------------------------------------
  133. status = 0
  134. if(.not. has_emis) return
  135. ! nb of sectors
  136. so2_2dsec = 0
  137. so2_3dsec = 0
  138. do lprov = 1, numb_providers
  139. if (count(used_providers.eq.providers_def(lprov)%name)/=0) then
  140. if (trim(providers_def(lprov)%name) .eq. 'AR5') then
  141. ! nb of available sectors in AR5 depends on category
  142. so2_2dsec = so2_2dsec + n_ar5_ant_sec*count('SO2'.eq.ar5_cat_ant) + &
  143. n_ar5_shp_sec*count('SO2'.eq.ar5_cat_shp)
  144. if (LAR5BMB) so2_2dsec = so2_2dsec + n_ar5_bmb_sec*count('SO2'.eq.ar5_cat_bmb)
  145. so2_3dsec = so2_3dsec + n_ar5_air_sec*count('SO2'.eq.ar5_cat_air)
  146. ! so2_2dsec = so2_2dsec + providers_def(lprov)%nsect2d
  147. ! so2_3dsec = so2_3dsec + count('SO2'.eq.ar5_cat_air)
  148. elseif (trim(providers_def(lprov)%name) .eq. 'ED42') then
  149. so2_2dsec = so2_2dsec + ed42_nsect_so2
  150. ! no 3d sectors in EDGAR 4.2
  151. else
  152. so2_2dsec = so2_2dsec + providers_def(lprov)%nsect2d
  153. so2_3dsec = so2_3dsec + providers_def(lprov)%nsect3d
  154. endif
  155. endif
  156. enddo
  157. allocate( so2_emis_2d( nregions, so2_2dsec ) )
  158. allocate( so2_emis_3d( nregions, so2_3dsec ) )
  159. allocate( has_data_2d(so2_2dsec)) ; has_data_2d=.false.
  160. allocate( has_data_3d(so2_3dsec)) ; has_data_3d=.false.
  161. ! allocate information arrays (2d and 3d)
  162. do region=1,nregions
  163. CALL GET_DISTGRID( dgrid(region), I_STRT=i1, I_STOP=i2, J_STRT=j1, J_STOP=j2 )
  164. lmr = lm(region)
  165. do lsec=1,so2_2dsec
  166. allocate( so2_emis_2d(region,lsec)%surf(i1:i2,j1:j2) )
  167. end do
  168. do lsec=1,so2_3dsec
  169. allocate( so2_emis_3d(region,lsec)%d3(i1:i2,j1:j2,lmr) )
  170. end do
  171. enddo
  172. ! ok
  173. status = 0
  174. END SUBROUTINE EMISSION_SOX_INIT
  175. !EOC
  176. !--------------------------------------------------------------------------
  177. ! TM5 !
  178. !--------------------------------------------------------------------------
  179. !BOP
  180. !
  181. ! !IROUTINE: EMISSION_SOX_DONE
  182. !
  183. ! !DESCRIPTION: Free memory.
  184. !\\
  185. !\\
  186. ! !INTERFACE:
  187. !
  188. SUBROUTINE EMISSION_SOX_DONE( status )
  189. !
  190. ! !OUTPUT PARAMETERS:
  191. !
  192. integer, intent(out) :: status
  193. !
  194. ! !REVISION HISTORY:
  195. ! 1 Oct 2010 - Achim Strunk - adapted for AR5
  196. !
  197. !EOP
  198. !------------------------------------------------------------------------
  199. !BOC
  200. character(len=*), parameter :: rname = mname//'/Emission_SOx_Done'
  201. integer :: region, lsec
  202. ! --- begin -----------------------------------------
  203. status = 0
  204. if(.not. has_emis) return
  205. do region = 1, nregions
  206. do lsec=1,so2_2dsec
  207. deallocate( so2_emis_2d(region,lsec)%surf )
  208. end do
  209. do lsec=1,so2_3dsec
  210. deallocate( so2_emis_3d(region,lsec)%d3 )
  211. end do
  212. end do
  213. deallocate( so2_emis_2d, so2_emis_3d )
  214. deallocate( has_data_2d, has_data_3d )
  215. status = 0
  216. END SUBROUTINE EMISSION_SOX_DONE
  217. !EOC
  218. !--------------------------------------------------------------------------
  219. ! TM5 !
  220. !--------------------------------------------------------------------------
  221. !BOP
  222. !
  223. ! !IROUTINE: EMISSION_SOX_DECLARE
  224. !
  225. ! !DESCRIPTION: Opens, reads and evaluates input files (per month).
  226. ! Provides emissions on 2d/3d-arrays which are then added
  227. ! to tracers in routine *apply.
  228. !\\
  229. !\\
  230. ! !INTERFACE:
  231. !
  232. SUBROUTINE EMISSION_SOX_DECLARE( status )
  233. !
  234. ! !USES:
  235. !
  236. use binas, only : pi
  237. use toolbox, only : coarsen_emission
  238. use dims, only : im, jm, lm, idate, sec_month, nlon360, nlat180, iglbsfc
  239. use chem_param, only : xms, xmso2
  240. use emission_data, only : msg_emis, LAR5BMB
  241. #ifdef with_m7
  242. use chem_param, only : mode_ais, mode_acs, mode_cos
  243. use chem_param, only : iso4ais, iso4acs, iso4cos
  244. use chem_param, only : iais_n, iacs_n, icos_n
  245. use chem_param, only : xmso4, xmnumb, sigma_lognormal
  246. use chem_param, only : h2so4_factor
  247. use chem_param, only : rad_so4_ait, rad_so4_acc, rad_so4_coa
  248. use chem_param, only : frac_so4, so4_density
  249. use emission_data, only : emis_mass, emis_number
  250. use emission_data, only : emission_vdist_by_sector
  251. #endif
  252. ! ---------------- AR5 - EDGAR 4 --------------------
  253. use emission_data, only : emis_input_year
  254. use emission_data, only : emis_input_dir_ed4, emis_input_dir_mac
  255. use emission_data, only : emis_input_dir_gfed, emis_input_dir_retro
  256. use emission_read, only : emission_ar5_regrid_aircraft
  257. use emission_read, only : emission_ar5_ReadSector
  258. use emission_read, only : emission_macc_ReadSector
  259. use emission_read, only : emission_ed4_ReadSector
  260. use emission_read, only : emission_gfed_ReadSector
  261. use emission_read, only : emission_retro_ReadSector
  262. use emission_read, only : sectors_def, numb_sectors
  263. use emission_read, only : ar5_dim_3ddata
  264. use emission_read, only : ed42_so2_sectors
  265. !
  266. ! !OUTPUT PARAMETERS:
  267. !
  268. integer, intent(out) :: status
  269. !
  270. ! !REVISION HISTORY:
  271. ! 1 Oct 2010 - Achim Strunk - revamped for AR5
  272. ! 1 Dec 2011 - Narcisa Banda - added EDGAR 4
  273. ! 27 Jun 2012 - P. Le Sager - adapted for lon-lat MPI domain decomposition
  274. !
  275. ! !REMARKS:
  276. !
  277. !EOP
  278. !------------------------------------------------------------------------
  279. !BOC
  280. character(len=*), parameter :: rname = mname//'/emission_sox_declare'
  281. integer :: region, hasData
  282. integer, parameter :: add_field=0
  283. integer, parameter :: ayear=1, amonth=2
  284. integer :: imr, jmr, lmr, lsec, i1, i2, j1, j2
  285. type(d3_data) :: work(nregions)
  286. type(emis_data) :: wrk2D(nregions)
  287. #ifdef with_m7
  288. real :: mass2numb_acs, mass2numb_ais, mass2numb_cos
  289. real :: numbscale, sfacacs, sfacais, sfaccos
  290. type(d3_data) :: emis3d
  291. #endif
  292. ! ---------------------------------------------------------------
  293. ! AR5
  294. real, dimension(:,:,:), allocatable :: field3d, field3d2
  295. integer :: seccount2d, seccount3d
  296. ! --- begin ----------------------------
  297. status = 0
  298. if(.not. has_emis) return
  299. write(gol,'(" EMISS-INFO ------------- read SOx emissions -------------")'); call goPr
  300. do region = 1, nregions
  301. do lsec=1,so2_2dsec
  302. so2_emis_2d(region,lsec)%surf = 0.0
  303. end do
  304. do lsec=1,so2_3dsec
  305. so2_emis_3d(region,lsec)%d3 = 0.0
  306. end do
  307. end do
  308. ! global arrays for coarsening
  309. do region = 1, nregions
  310. if (isRoot)then
  311. allocate(work(region)%d3(im(region),jm(region),lm(region)))
  312. else
  313. allocate(work(region)%d3(1,1,1))
  314. end if
  315. enddo
  316. do region = 1, nregions
  317. wrk2D(region)%surf => work(region)%d3(:,:,1)
  318. end do
  319. ! --------------------------------
  320. ! do a loop over available sectors
  321. ! --------------------------------
  322. ! count 2d and 3d sectors
  323. seccount2d = 0
  324. seccount3d = 0
  325. ! always allocate here 3d data set (for 2d sectors it will be filled in first layer only)
  326. if (isRoot) then
  327. allocate( field3d( nlon360, nlat180, ar5_dim_3ddata ) ) ; field3d = 0.0
  328. else
  329. allocate( field3d( 1, 1, 1 ) )
  330. end if
  331. sec : do lsec = 1, numb_sectors
  332. if (count(used_providers.eq.sectors_def(lsec)%prov).eq.0) cycle
  333. if ((trim(sectors_def(lsec)%prov).eq.'ED42') .and. (count(ed42_so2_sectors.eq.sectors_def(lsec)%name) .eq. 0)) cycle
  334. if (associated(sectors_def(lsec)%species)) then ! AR5 check
  335. if (count('SO2'.eq.sectors_def(lsec)%species).eq.0) cycle
  336. if ((trim(sectors_def(lsec)%catname) .eq. 'biomassburning').and.(.not.LAR5BMB)) cycle
  337. endif
  338. field3d = 0.0
  339. if( sectors_def(lsec)%f3d ) then
  340. seccount3d = seccount3d + 1
  341. else
  342. seccount2d = seccount2d + 1
  343. end if
  344. if (isRoot) then ! READ
  345. select case( trim(sectors_def(lsec)%prov) )
  346. case( 'AR5' )
  347. ! Screen out agricultural and solvent sectors for SO2,
  348. ! because they are zero in the RCPs
  349. ! and not present in the historical files.
  350. if (trim(sectors_def(lsec)%name) .ne. 'emiss_agr' .and. &
  351. trim(sectors_def(lsec)%name) .ne. 'emiss_slv') then
  352. call emission_ar5_ReadSector( 'SO2', emis_input_year, idate(2), lsec, field3d, status )
  353. IF_NOTOK_RETURN(status=1)
  354. endif
  355. case( 'MACC' )
  356. ! screen out sectors w/o SO2 (soil, bio, oc)
  357. if ( ( .not. (trim(sectors_def(lsec)%name) .eq. 'emiss_soil')) .and. &
  358. ( .not. (trim(sectors_def(lsec)%name) .eq. 'emiss_bio') ) .and. &
  359. ( .not. (trim(sectors_def(lsec)%name) .eq. 'emiss_air') ) .and. &
  360. ( .not. (trim(sectors_def(lsec)%name) .eq. 'emiss_oc') ) ) then
  361. call emission_macc_ReadSector( emis_input_dir_mac, 'SO2', emis_input_year, idate(2), &
  362. '0.5x0.5_kg.nc', sectors_def(lsec)%name, 'kg / s', field3d, status )
  363. IF_NOTOK_RETURN(status=1)
  364. endif
  365. case( 'ED41' )
  366. select case(trim(sectors_def(lsec)%name))
  367. case ('1A3b_c_e','1A3d_SHIP','1A3d1')
  368. call emission_ed4_ReadSector( emis_input_dir_ed4, 'SO2', 'so2', 2005, idate(2), &
  369. lsec, trim(sectors_def(lsec)%prov), 'kg / s', field3d, status )
  370. IF_NOTOK_RETURN(status=1)
  371. field3d = field3d * xmso2/xms
  372. end select
  373. case( 'ED42' )
  374. ! biomass burning (GFED/RETRO/AR5BMB) and transport (ED41) are excluded through ED42_SO2_SECTORS definition
  375. call emission_ed4_ReadSector( emis_input_dir_ed4, 'SO2', 'so2', emis_input_year, idate(2), &
  376. lsec, trim(sectors_def(lsec)%prov), 'kg / s', field3d, status )
  377. IF_NOTOK_RETURN(status=1)
  378. field3d = field3d * xmso2/xms
  379. case('GFEDv3')
  380. call emission_gfed_ReadSector( emis_input_dir_gfed, 'so2', emis_input_year, idate(2), &
  381. sectors_def(lsec)%name, 'kg / s', field3d(:,:,1), status )
  382. IF_NOTOK_RETURN(status=1)
  383. case('RETRO')
  384. call emission_retro_ReadSector( emis_input_dir_retro, 'SO2', emis_input_year, idate(2), &
  385. sectors_def(lsec)%name, 'kg / s', field3d(:,:,1), status )
  386. IF_NOTOK_RETURN(status=1)
  387. case('MEGAN')
  388. !
  389. ! No biogenic emission of SO2 in the MEGAN inventory
  390. !
  391. case('DUMMY')
  392. case default
  393. write(gol,*) "Error in buidling list of providers USED_PROVIDERS"; call goErr
  394. status=1; TRACEBACK; return
  395. end select
  396. ! nothing found???
  397. if( sum(field3d) < 100.*TINY(1.0) ) then
  398. if (okdebug) then
  399. write(gol,'("EMISS-INFO - no SO2 emissions found for ",a," ",a," for month ",i2 )') &
  400. trim(sectors_def(lsec)%prov), trim(sectors_def(lsec)%name), idate(2) ; call goPr
  401. endif
  402. hasData=0
  403. else
  404. if (okdebug) then
  405. write(gol,'("EMISS-INFO - found SO2 emissions for ",a," ",a," for month ",i2 )') &
  406. trim(sectors_def(lsec)%prov), trim(sectors_def(lsec)%name), idate(2) ; call goPr
  407. endif
  408. field3d = field3d * sec_month ! from kg(SO2)/s to kg(SO2)/month
  409. hasData=1
  410. end if
  411. end if
  412. call Par_broadcast(hasData, status)
  413. IF_NOTOK_RETURN(status=1)
  414. if (hasData == 0) then
  415. cycle sec
  416. else
  417. if ( sectors_def(lsec)%f3d ) then
  418. has_data_3d(seccount3d)=.true.
  419. else
  420. has_data_2d(seccount2d)=.true.
  421. end if
  422. end if
  423. ! Distinguish 2d/3d sectors
  424. if( sectors_def(lsec)%f3d ) then
  425. write(gol,'("EMISS-ERROR - Unexpected 3D data: Uncomment code below ")'); call goErr
  426. status=1; TRACEBACK; return
  427. ! ---------------------------
  428. ! 3d data (AIRCRAFT)
  429. ! ---------------------------
  430. ! if (isRoot) then ! regrid
  431. ! ! helper array for regridding
  432. ! allocate( field3d2( nlon360,nlat180,lm(1) ) ) ; field3d2 = 0.0
  433. ! ! aircraft data: regrid vertically to model layers
  434. ! call emission_ar5_regrid_aircraft( iglbsfc, field3d, nlon360, nlat180, ar5_dim_3ddata, lm(1), field3d2, status )
  435. ! IF_NOTOK_RETURN(status=1;deallocate(field3d,field3d2))
  436. ! call msg_emis( amonth, trim(sectors_def(lsec)%prov)//' '//sectors_def(lsec)%name//' mass month', &
  437. ! & 'SO2', xmso2, sum(field3d2) )
  438. ! ! distribute to so2_emis in regions
  439. ! call Coarsen_Emission( 'SO2 '//trim(sectors_def(lsec)%name), nlon360, nlat180, lm(1), &
  440. ! field3d2, work, add_field, status )
  441. ! IF_NOTOK_RETURN(status=1;deallocate(field3d,field3d2))
  442. ! deallocate( field3d2 )
  443. ! end if
  444. ! do region = 1, nregions
  445. ! call scatter(dgrid(region), so2_emis_3d(region,seccount3d)%d3, work(region)%d3, 0, status)
  446. ! IF_NOTOK_RETURN(status=1)
  447. ! end do
  448. else ! ar5_sector is 2d
  449. ! ---------------------------
  450. ! 2d data (Anthropogenic, Ships, Biomassburning)
  451. ! ---------------------------
  452. if (isRoot) then ! print total & regrid
  453. call msg_emis( amonth, trim(sectors_def(lsec)%prov),sectors_def(lsec)%name, 'SO2', xmso2, sum(field3d(:,:,1)) )
  454. call coarsen_emission( 'SO2 '//sectors_def(lsec)%name, &
  455. nlon360, nlat180, field3d(:,:,1), wrk2D, add_field, status )
  456. IF_NOTOK_RETURN(status=1)
  457. end if
  458. do region = 1, nregions
  459. call scatter(dgrid(region), so2_emis_2d(region,seccount2d)%surf, work(region)%d3(:,:,1), 0, status)
  460. IF_NOTOK_RETURN(status=1)
  461. end do
  462. end if ! 2D/3D
  463. end do sec ! sectors
  464. ! Cleanup
  465. deallocate( field3d )
  466. do region = 1, nregions
  467. if (associated(wrk2D(region)%surf)) nullify(wrk2D(region)%surf)
  468. deallocate( work(region)%d3 )
  469. end do
  470. ! check sectors found
  471. if( seccount2d /= so2_2dsec ) then
  472. write(gol,'(80("-"))') ; call goPr
  473. write(gol,'("ERROR: 2d sectors do not equal total number:",i4," /= ",i4," !")') seccount2d, so2_2dsec ; call goErr
  474. write(gol,'(80("-"))') ; call goPr
  475. status=1; return
  476. end if
  477. if( seccount3d /= so2_3dsec ) then
  478. write(gol,'(80("-"))') ; call goPr
  479. write(gol,'("ERROR: 3d sectors do not equal total number:",i4," /= ",i4," !")') seccount3d, so2_3dsec ; call goErr
  480. write(gol,'(80("-"))') ; call goPr
  481. status=1; return
  482. end if
  483. #ifdef with_m7
  484. ! do SO4 partitioning from SO2 emissions
  485. ! --------------------------------
  486. ! do a loop over available sectors
  487. ! --------------------------------
  488. ! count 2d and 3d sectors
  489. seccount2d = 0
  490. seccount3d = 0
  491. do lsec = 1, numb_sectors
  492. if (count(used_providers.eq.sectors_def(lsec)%prov).eq.0) cycle
  493. if ((trim(sectors_def(lsec)%prov).eq.'ED42') .and. (count(ed42_so2_sectors.eq.sectors_def(lsec)%name) .eq. 0)) cycle
  494. if (associated(sectors_def(lsec)%species)) then ! AR5 check
  495. if (count('SO2'.eq.sectors_def(lsec)%species).eq.0) cycle
  496. if ((trim(sectors_def(lsec)%catname) .eq. 'biomassburning').and.(.not.LAR5BMB)) cycle
  497. endif
  498. if( sectors_def(lsec)%f3d ) then
  499. seccount3d = seccount3d + 1
  500. if (.not.has_data_3d(seccount3d)) cycle
  501. else
  502. seccount2d = seccount2d + 1
  503. if (.not.has_data_2d(seccount2d)) cycle
  504. end if
  505. !>>> TvN
  506. select case( trim(sectors_def(lsec)%vdisttype) )
  507. !case( 'industry' )
  508. case ( 'industry', 'combenergy' )
  509. sfacais = 0.0 * xmso4 / xmso2 * frac_so4
  510. !sfacacs = 1.0 * xmso4 / xmso2 * frac_so4
  511. sfacacs = 0.5 * xmso4 / xmso2 * frac_so4
  512. sfaccos = 0.5 * xmso4 / xmso2 * frac_so4
  513. case ( 'volcanic' )
  514. sfacais = 0.5 * xmso4 / xmso2 * frac_so4
  515. sfacacs = 0.5 * xmso4 / xmso2 * frac_so4
  516. sfaccos = 0.0 * xmso4 / xmso2 * frac_so4
  517. case default
  518. select case ( trim(sectors_def(lsec)%catname) )
  519. case ('ships')
  520. ! as industry and power plants
  521. sfacais = 0.0 * xmso4 / xmso2 * frac_so4
  522. sfacacs = 0.5 * xmso4 / xmso2 * frac_so4
  523. sfaccos = 0.5 * xmso4 / xmso2 * frac_so4
  524. case ( 'biomassburning')
  525. sfacais = 0.0 * xmso4 / xmso2 * frac_so4
  526. sfacacs = 1.0 * xmso4 / xmso2 * frac_so4
  527. sfaccos = 0.0 * xmso4 / xmso2 * frac_so4
  528. case default
  529. ! e.g. traffic, domestic
  530. sfacais = 1.0 * xmso4 / xmso2 * frac_so4
  531. sfacacs = 0.0 * xmso4 / xmso2 * frac_so4
  532. sfaccos = 0.0 * xmso4 / xmso2 * frac_so4
  533. end select
  534. end select
  535. !<<< TvN
  536. ! mass to number factors for these two modes
  537. !>>> TvN
  538. ! The mass2numb conversion factors have been
  539. ! slightly enhanced to account for the small contribution
  540. ! from the hydrogen ions to the mass,
  541. ! since so4_density is the density of sulfuric acid.
  542. numbscale = rad_so4_ait*EXP(1.5*(LOG(sigma_lognormal(mode_ais)))**2)
  543. mass2numb_ais = h2so4_factor*3./(4.*pi*numbscale**3*so4_density)
  544. numbscale = rad_so4_acc*EXP(1.5*(LOG(sigma_lognormal(mode_acs)))**2)
  545. mass2numb_acs = h2so4_factor*3./(4.*pi*numbscale**3*so4_density)
  546. numbscale = rad_so4_coa*EXP(1.5*(LOG(sigma_lognormal(mode_cos)))**2)
  547. mass2numb_cos = h2so4_factor*3./(4.*pi*numbscale**3*so4_density)
  548. !<<< TvN
  549. do region = 1, nregions
  550. ! allocate helper array
  551. call get_distgrid( dgrid(region), I_STRT=i1, I_STOP=i2, J_STRT=j1, J_STOP=j2 )
  552. lmr = lm(region)
  553. allocate( field3d(i1:i2,j1:j2,lmr) )
  554. ! distinguish 2d/3d sectors
  555. if( sectors_def(lsec)%f3d ) then
  556. field3d = so2_emis_3d(region,seccount3d)%d3
  557. else
  558. ! helper struct for vertical distribution
  559. allocate( emis3d%d3(i1:i2,j1:j2,lm(region)) ) ; emis3d%d3 = 0.0
  560. ! do vertical distribution
  561. call emission_vdist_by_sector( sectors_def(lsec)%vdisttype, 'SO2', region, so2_emis_2d(region,seccount2d), &
  562. emis3d, status )
  563. IF_NOTOK_RETURN(status=1;deallocate(field3d,emis3d%d3))
  564. field3d = emis3d%d3
  565. deallocate(emis3d%d3)
  566. end if
  567. ! finally add it to the emis target arrays according to the splitting above
  568. ! AIS
  569. emis_mass (region,mode_ais)%d4(:,:,:,1) = &
  570. emis_mass (region,mode_ais)%d4(:,:,:,1) + field3d * sfacais
  571. ! scale mass to get number
  572. emis_number(region,mode_ais)%d4(:,:,:,1) = &
  573. emis_number(region,mode_ais)%d4(:,:,:,1) + field3d * sfacais * mass2numb_ais
  574. ! ACS
  575. emis_mass (region,mode_acs)%d4(:,:,:,1) = &
  576. emis_mass (region,mode_acs)%d4(:,:,:,1) + field3d * sfacacs
  577. ! scale mass to get number
  578. emis_number(region,mode_acs)%d4(:,:,:,1) = &
  579. emis_number(region,mode_acs)%d4(:,:,:,1) + field3d * sfacacs * mass2numb_acs
  580. !>>> TvN
  581. ! COS
  582. emis_mass (region,mode_cos)%d4(:,:,:,1) = &
  583. emis_mass (region,mode_cos)%d4(:,:,:,1) + field3d * sfaccos
  584. ! scale mass to get number
  585. emis_number(region,mode_cos)%d4(:,:,:,1) = &
  586. emis_number(region,mode_cos)%d4(:,:,:,1) + field3d * sfaccos * mass2numb_cos
  587. !<<< TvN
  588. deallocate( field3d )
  589. end do ! regions
  590. end do ! sectors
  591. #endif /* ifdef M7 */
  592. END SUBROUTINE EMISSION_SOX_DECLARE
  593. !EOC
  594. !--------------------------------------------------------------------------
  595. ! TM5 !
  596. !--------------------------------------------------------------------------
  597. !BOP
  598. !
  599. ! !IROUTINE: EMISSION_SOX_APPLY
  600. !
  601. ! !DESCRIPTION: Take monthly emissions, and
  602. ! - split them vertically
  603. ! - apply time splitting factors
  604. ! - add them up (add_3d)
  605. !\\
  606. !\\
  607. ! !INTERFACE:
  608. !
  609. SUBROUTINE EMISSION_SOX_APPLY( region, status )
  610. !
  611. ! !USES:
  612. !
  613. use dims, only : itaur, nsrce, tref
  614. use dims, only : im, jm, lm
  615. use datetime, only : tau2date
  616. use emission_data, only : emission_vdist_by_sector, LAR5BMB
  617. use emission_data, only : do_add_3d, do_add_3d_cycle, bb_cycle
  618. use emission_data, only : emis_bb_trop_cycle
  619. use emission_read , only : ed42_so2_sectors
  620. use chem_param, only : inh3, xmnh3, xmn, frac_so4
  621. use emission_read, only : sectors_def, numb_sectors
  622. use chem_param, only : xmso2, xms, iso2, iso4
  623. use chem_param, only : xmh2so4
  624. !
  625. ! !INPUT PARAMETERS:
  626. !
  627. integer, intent(in) :: region
  628. !
  629. ! !OUTPUT PARAMETERS:
  630. !
  631. integer, intent(out) :: status
  632. !
  633. ! !REVISION HISTORY:
  634. ! 1 Oct 2010 - Achim Strunk - AR5 version
  635. ! 27 Jun 2012 - Ph. Le Sager - adapted for lon-lat MPI domain decomposition
  636. !
  637. ! !REMARKS:
  638. !
  639. !EOP
  640. !------------------------------------------------------------------------
  641. !BOC
  642. character(len=*), parameter :: rname = mname//'/emission_sox_apply'
  643. integer, dimension(6) :: idater
  644. real :: dtime, fraction, sfrac
  645. integer :: imr, jmr, lmr, lsec, i1, i2, j1, j2
  646. integer :: seccount2d, seccount3d
  647. type(d3_data) :: emis3d
  648. ! --- begin -----------------------------------------
  649. status = 0
  650. if(.not. has_emis) return
  651. if( okdebug ) then
  652. write(gol,*) 'start of emission_sox_apply'; call goPr
  653. end if
  654. call tau2date(itaur(region),idater)
  655. dtime=float(nsrce)/(2*tref(region)) !emissions are added in two steps...XYZECCEZYX.
  656. ! get a working structure for 3d emissions
  657. call get_distgrid( dgrid(region), I_STRT=i1, I_STOP=i2, J_STRT=j1, J_STOP=j2 )
  658. allocate( emis3d%d3(i1:i2,j1:j2,lm(region)) ) ; emis3d%d3 = 0.0
  659. ! count 2d and 3d sectors
  660. seccount2d = 0
  661. seccount3d = 0
  662. ! cycle over sectors
  663. do lsec = 1, numb_sectors
  664. if (count(used_providers.eq.sectors_def(lsec)%prov).eq.0) cycle
  665. if ((trim(sectors_def(lsec)%prov).eq.'ED42') .and. (count(ed42_so2_sectors.eq.sectors_def(lsec)%name) .eq. 0)) cycle
  666. if (associated(sectors_def(lsec)%species)) then ! AR5 check
  667. if (count('SO2'.eq.sectors_def(lsec)%species).eq.0) cycle
  668. if ((trim(sectors_def(lsec)%catname) .eq. 'biomassburning').and.(.not.LAR5BMB)) cycle
  669. endif
  670. ! default: no additional splitting
  671. fraction = 1.0
  672. ! ----------------------------------------------------------------------------------------
  673. ! distinguish here between sectors and whether they should have additional splitting, e.g.,
  674. ! if( sectors_def(lsec)%catname == 'biomassburning' ) fraction = fraction * bb_frac etc...
  675. ! ----------------------------------------------------------------------------------------
  676. ! distinguish between 2d/3d sectors
  677. if( sectors_def(lsec)%f3d ) then
  678. seccount3d = seccount3d + 1
  679. if (.not.has_data_3d(seccount3d)) cycle
  680. emis3d%d3 = so2_emis_3d(region,seccount3d)%d3
  681. else
  682. seccount2d = seccount2d + 1
  683. if (.not.has_data_2d(seccount2d)) cycle
  684. emis3d%d3 = 0.0
  685. ! vertically distribute according to sector
  686. call emission_vdist_by_sector( sectors_def(lsec)%vdisttype, 'SO2', region, so2_emis_2d(region,seccount2d), emis3d, status)
  687. IF_NOTOK_RETURN(status=1;deallocate(emis3d%d3))
  688. end if
  689. ! SO2: sfrac = fraction * (1.-frac_so4)
  690. sfrac = fraction * (1.0 - frac_so4)
  691. ! add dataset according to sector and category
  692. if( emis_bb_trop_cycle .and. trim(sectors_def(lsec)%catname) == "biomassburning" ) then
  693. call do_add_3d_cycle( region, iso2, i1, j1, emis3d%d3, bb_cycle(region)%scalef, xmso2, xmso2, status, sfrac )
  694. IF_NOTOK_RETURN(status=1)
  695. else
  696. call do_add_3d( region, iso2, i1, j1, emis3d%d3, xmso2, xmso2, status, sfrac )
  697. IF_NOTOK_RETURN(status=1)
  698. end if
  699. #ifndef with_m7
  700. ! SO4: sfrac = fraction * frac_so4
  701. sfrac = fraction * frac_so4
  702. ! add dataset according to sector and category
  703. if( emis_bb_trop_cycle .and. trim(sectors_def(lsec)%catname) == "biomassburning" ) then
  704. call do_add_3d_cycle( region, iso4, i1, j1, emis3d%d3, bb_cycle(region)%scalef, xmh2so4, xmso2, status, sfrac )
  705. IF_NOTOK_RETURN(status=1)
  706. else
  707. call do_add_3d( region, iso4, i1, j1, emis3d%d3, xmh2so4, xmso2, status, sfrac )
  708. IF_NOTOK_RETURN(status=1)
  709. end if
  710. #endif
  711. end do ! sectors_def
  712. deallocate( emis3d%d3 )
  713. if(okdebug) then
  714. write(gol,*) 'end of emission_sox_apply'; call goPr
  715. endif
  716. ! OK
  717. status = 0
  718. END SUBROUTINE EMISSION_SOX_APPLY
  719. !EOC
  720. END MODULE EMISSION_SOX