emission.F90 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026
  1. #define TRACEBACK write (gol,'("in ",a," (",a,i6,")")') rname, __FILE__, __LINE__ ; call goErr
  2. #define IF_NOTOK_RETURN(action) if (status/=0) then; TRACEBACK; action; return; end if
  3. #define IF_ERROR_RETURN(action) if (status> 0) then; TRACEBACK; action; return; end if
  4. !
  5. #include "tm5.inc"
  6. !
  7. !------------------------------------------------------------------------------
  8. ! TM5 !
  9. !------------------------------------------------------------------------------
  10. !BOP
  11. !
  12. ! !MODULE: EMISSION
  13. !
  14. ! !DESCRIPTION: wrappers around various emissions (init/declare/apply/done)
  15. ! routines, needed for TM5 CBM4 version.
  16. ! Also hold emissions budget variables.
  17. !
  18. !\\
  19. !\\
  20. ! !INTERFACE:
  21. !
  22. MODULE EMISSION
  23. !
  24. ! !USES:
  25. !
  26. USE GO, ONLY : gol, goErr, goPr
  27. use GO, ONLY : GO_Timer_Def, GO_Timer_End, GO_Timer_Start
  28. USE TM5_DISTGRID, ONLY : dgrid, Get_DistGrid, scatter, gather
  29. USE dims, ONLY : nregions, okdebug
  30. USE emission_data, ONLY : plandr, emis2D ! , bmbcycle, bb_lm
  31. #ifdef with_m7
  32. USE emission_data, ONLY : emis_number, emis_mass, emis_temp
  33. #endif
  34. #ifdef with_budgets
  35. USE emission_data, ONLY : budemi_dat, budemi_data, sum_emission
  36. USE budget_global, ONLY : nbud_vg,nbudg
  37. USE chem_param, ONLY : ntracet
  38. #endif
  39. use emission_nox , only : Emission_NOx_Init , Emission_NOx_Done , emission_nox_declare
  40. use emission_co , only : Emission_CO_Init , Emission_CO_Done , emission_co_declare , emission_co_apply
  41. use emission_nmvoc, only : Emission_NMVOC_Init, Emission_NMVOC_Done , emission_nmvoc_declare, emission_nmvoc_apply
  42. use emission_ch4 , only : Emission_CH4_Init , Emission_CH4_Done , emission_ch4_declare , emission_ch4_apply
  43. use emission_nh3 , only : Emission_nh3_Init , Emission_nh3_Done , emission_nh3_declare , emission_nh3_apply
  44. use emission_sox , only : Emission_SOx_Init , Emission_SOx_Done , emission_sox_declare , emission_sox_apply
  45. use emission_dms , only : Emission_DMS_Init , emission_dms_done , emission_dms_declare , emission_dms_apply
  46. use emission_rn222, only : Emission_rn222_Init, emission_rn222_done , emission_rn222_declare, emission_rn222_apply
  47. #ifdef with_online_bvoc
  48. USE emission_bvoc, ONLY : declare_emission_bvoc, free_emission_bvoc, emission_apply_bvoc
  49. #else
  50. use emission_isop , only: Emission_isop_Init , Emission_isop_Done , emission_isop_declare , emission_isop_apply
  51. #endif
  52. #ifdef with_m7
  53. use emission_dust, only : emission_dust_done , emission_dust_declare
  54. use emission_pom , only : Emission_POM_Init, Emission_POM_Done , emission_pom_declare
  55. use emission_bc , only : Emission_BC_Init , Emission_BC_Done , emission_bc_declare
  56. !!$ use emission_ss, only: declare_emission_ss , free_emission_ss
  57. #endif
  58. IMPLICIT NONE
  59. PRIVATE
  60. !
  61. ! !PUBLIC MEMBER FUNCTIONS:
  62. !
  63. PUBLIC :: Emission_Init ! allocate/init budget var; call other emiss-related init
  64. PUBLIC :: Emission_Done ! gather/write final budget
  65. PUBLIC :: Declare_Emission ! allocate emiss var (new run), read emiss data (new month)
  66. PUBLIC :: Emission_Apply !
  67. !
  68. ! !PRIVATE DATA MEMBERS:
  69. !
  70. ! budemig_all (used to sum budemig from all processors) is used in chemistry for its NOx values.
  71. #ifdef with_budgets
  72. REAL, DIMENSION(nbudg, nbud_vg, ntracet) :: budemig
  73. REAL, DIMENSION(nbudg, nbud_vg, ntracet), PUBLIC :: budemig_all ! for buggy MPI (see budget_global.F90)
  74. #endif
  75. integer :: itim_appl, itim_co, itim_voc, itim_nh3, itim_sox, itim_dms, itim_ch4, itim_isop, itim_rn222
  76. CHARACTER(len=*), PARAMETER :: mname = 'emission'
  77. !
  78. ! !REVISION HISTORY:
  79. ! 16 Jul 2010 - P. Le Sager - fix for m7 with GFED_8days
  80. ! 20 Aug 2010 - A. Strunk - Adapted to AR5 emissions + various other changes.
  81. ! 27 Mar 2012 - P. Le Sager - adapted for lon-lat MPI domain decomposition
  82. !
  83. !EOP
  84. !----------------------------------------------------------------------
  85. CONTAINS
  86. !----------------------------------------------------------------------
  87. ! TM5 !
  88. !----------------------------------------------------------------------
  89. !BOP
  90. !
  91. ! !IROUTINE: EMISSION_INIT
  92. !
  93. ! !DESCRIPTION: Initialise emission fields and parameters by reading
  94. ! the rc-file. Allocate and initialize budget variables.
  95. !\\
  96. !\\
  97. ! !INTERFACE:
  98. !
  99. SUBROUTINE EMISSION_INIT( status )
  100. !
  101. ! !USES:
  102. !
  103. use GO, only : TrcFile, Init, Done, ReadRc
  104. use meteodata, only : Set, oro_dat
  105. use dims, only : iglbsfc, nregions, lm
  106. use dims, only : idate, ndyn_max, tref
  107. use global_data, only : inputdir, rcfile
  108. use emission_data, only : emis_input_dir, use_tiedkte
  109. use emission_data, only : emis_input_dir_gfed
  110. use emission_data, only : emis_input_dir_retro
  111. use emission_data, only : emis_input_year
  112. use emission_data, only : LAR5, LAR5BMB, LEDGAR4, LRETROF, LGFED3
  113. use emission_data, only : LLPJ, LHYMN, LMACCITY, LMEGAN, LMACC
  114. #ifdef with_ch4_emis
  115. use emission_data, only : emis_input_dir_natch4
  116. #endif
  117. #ifdef with_m7
  118. use chem_param, only : mode_nm
  119. use emission_data, only : emis_input_dir_aerocom
  120. use emission_data, only : emis_input_dir_dust, emis_input_dust
  121. use mo_aero_m7, only : nmod
  122. #endif
  123. use emission_data, only : emis_input_dir_ar5
  124. use emission_data, only : emis_input_dir_mac
  125. use emission_data, only : emis_input_dir_ed4
  126. use emission_data, only : emis_input_dir_dms
  127. use emission_data, only : emis_input_dir_rn222
  128. use emission_data, only : emis_input_dir_megan
  129. use emission_data, only : emis_ch4_single, emis_ch4_fix3d
  130. use emission_data, only : emis_ch4_fixed_ppb, emis_zch4_fname
  131. use emission_data, only : emis_bb_trop_cycle, bb_cycle, scale_cycle
  132. use emission_read, only : emission_read_init
  133. #ifdef with_online_nox
  134. use online_nox_data, only : input_nox_dir
  135. #endif
  136. !
  137. ! !OUTPUT PARAMETERS:
  138. !
  139. INTEGER, INTENT(out) :: status
  140. !
  141. ! !REVISION HISTORY:
  142. ! 27 Mar 2012 - P. Le Sager - adapted for lon-lat MPI domain decomposition
  143. !
  144. !EOP
  145. !------------------------------------------------------------------------------
  146. !BOC
  147. CHARACTER(len=*), PARAMETER :: rname = mname//'/Emission_Init'
  148. INTEGER :: region, i1, i2, j1, j2, ntim, lmr, imode
  149. TYPE(TrcFile) :: rcF
  150. REAL :: dtime
  151. ! -----------------------------------
  152. ! read settings from rcfile
  153. ! -----------------------------------
  154. call Init( rcF, rcfile, status )
  155. IF_NOTOK_RETURN(status=1)
  156. if (okdebug) then
  157. write(gol,*) "EMISS-INFO - running year : ", idate(1) ; call goPr
  158. end if
  159. ! emission base year (assumption: no run overlapping more than one year)
  160. call ReadRc( rcF, 'input.emis.year', emis_input_year, status, default=idate(1) )
  161. IF_ERROR_RETURN(status=1)
  162. write(gol,*) 'EMISS-INFO - Emissions base year : ', emis_input_year; call goPr
  163. ! default directory for emissions data is "standard input files" dir
  164. emis_input_dir=trim(inputdir)
  165. ! directory of each data provider
  166. call ReadRc( rcF, 'input.emis.dir.AR5', emis_input_dir_ar5, status, default=emis_input_dir )
  167. IF_ERROR_RETURN(status=1)
  168. call ReadRc( rcF, 'input.emis.dir.MACC', emis_input_dir_mac, status, default=emis_input_dir )
  169. IF_ERROR_RETURN(status=1)
  170. call ReadRc( rcF, 'input.emis.dir.ED41', emis_input_dir_ed4, status, default=emis_input_dir )
  171. IF_ERROR_RETURN(status=1)
  172. call ReadRc( rcF, 'input.emis.dir.gfed', emis_input_dir_gfed, status, default=emis_input_dir )
  173. IF_ERROR_RETURN(status=1)
  174. call ReadRc( rcF, 'input.emis.dir.retro', emis_input_dir_retro, status, default=emis_input_dir )
  175. IF_ERROR_RETURN(status=1)
  176. call ReadRc( rcF, 'input.emis.dir.MEGAN', emis_input_dir_megan, status, default=emis_input_dir )
  177. IF_ERROR_RETURN(status=1)
  178. #ifdef with_ch4_emis
  179. ! for both HYMN and LPJ datasets
  180. call ReadRc( rcF, 'input.emis.dir.natch4', emis_input_dir_natch4, status, default=emis_input_dir )
  181. IF_ERROR_RETURN(status=1)
  182. #endif
  183. ! Flags
  184. call ReadRc( rcF, 'use_ar5', LAR5, status, default=.false. )
  185. IF_ERROR_RETURN(status=1)
  186. call ReadRc( rcF, 'use_ar5_fires', LAR5BMB, status, default=.false. )
  187. IF_ERROR_RETURN(status=1)
  188. call ReadRc( rcF, 'use_edgar4', LEDGAR4, status, default=.false. )
  189. IF_ERROR_RETURN(status=1)
  190. call ReadRc( rcF, 'use_retro_fires', LRETROF, status, default=.false. )
  191. IF_ERROR_RETURN(status=1)
  192. call ReadRc( rcF, 'use_gfed3', LGFED3, status, default=.false. )
  193. IF_ERROR_RETURN(status=1)
  194. call ReadRc( rcF, 'use_macc', LMACC, status, default=.false. )
  195. IF_ERROR_RETURN(status=1)
  196. call ReadRc( rcF, 'use_lpj', LLPJ, status, default=.false. )
  197. IF_ERROR_RETURN(status=1)
  198. call ReadRc( rcF, 'use_hymn', LHYMN, status, default=.false. )
  199. IF_ERROR_RETURN(status=1)
  200. call ReadRc( rcF, 'use_maccity', LMACCITY,status, default=.false. )
  201. IF_ERROR_RETURN(status=1)
  202. IF(LMACCITY) LMACC=.true. ! ensure that MACC data are read. LMACCITY just add anthro sector to MACC's sector list.
  203. call ReadRc( rcF, 'use_megan', LMEGAN, status, default=.false. )
  204. IF_ERROR_RETURN(status=1)
  205. ! very basic checks
  206. if (count((/ LAR5, LEDGAR4, LMACCITY /)) > 1) then
  207. write(gol,*) 'You use more than one ANTHROPOGENIC inventory'; call goErr
  208. status=1; TRACEBACK; return
  209. end if
  210. if (count((/ LAR5BMB, LRETROF, LGFED3 /)) > 1) then
  211. write(gol,*) 'You use more than one BIOMASS BURNING inventory'; call goErr
  212. status=1; TRACEBACK; return
  213. end if
  214. ! init providers info
  215. call emission_read_init( rcF, status )
  216. #ifdef with_online_nox
  217. call ReadRc( rcF, 'input.onlinenox.dir', input_nox_dir, status )
  218. IF_NOTOK_RETURN(status=1)
  219. #endif
  220. ! are convection fluxes computed (Tiedkte) or read?
  221. call ReadRc( rcF, 'tiedtke', use_tiedkte, status )
  222. IF_NOTOK_RETURN(status=1)
  223. #ifdef with_m7
  224. call ReadRc( rcF, 'input.emis.dir.aerocom', emis_input_dir_aerocom, status, default=emis_input_dir )
  225. IF_NOTOK_RETURN(status=1)
  226. call ReadRc( rcF, 'input.emis.dust', emis_input_dust, status, default="AEROCOM" )
  227. IF_NOTOK_RETURN(status=1)
  228. call ReadRc( rcF, 'input.emis.dir.dust', emis_input_dir_dust, status, default=emis_input_dir )
  229. IF_NOTOK_RETURN(status=1)
  230. #endif
  231. call ReadRc( rcF, 'input.emis.dir.dms', emis_input_dir_dms, status, default=emis_input_dir )
  232. IF_NOTOK_RETURN(status=1)
  233. call ReadRc( rcF, 'input.emis.dir.rn222', emis_input_dir_rn222, status, default=emis_input_dir )
  234. IF_ERROR_RETURN(status=1)
  235. ! Get biomassburning time splitting factors (same for all constituents)
  236. ! -----------------------------------------------------------------------------------
  237. call ReadRc( rcF, 'input.emis.bb.dailycycle', emis_bb_trop_cycle, status, default=.false. )
  238. IF_ERROR_RETURN(status=1)
  239. if (emis_bb_trop_cycle) then
  240. do region = 1, nregions
  241. dtime = float(ndyn_max)/(2*tref(region)) ! timestep emissions (CMK changed 5/2006)
  242. ntim = 86400/nint(dtime) ! number of timesteps in 24 hours for this region
  243. allocate(bb_cycle(region)%scalef(ntim))
  244. call scale_cycle(ntim, bb_cycle(region)%scalef)
  245. end do
  246. end if
  247. ! CH4
  248. call ReadRc( rcF, 'input.emis.ch4.single', emis_ch4_single, status )
  249. IF_NOTOK_RETURN(status=1)
  250. if( emis_ch4_single ) then
  251. call ReadRc( rcF, 'input.emis.ch4.fixed_ppb', emis_ch4_fixed_ppb, status )
  252. IF_NOTOK_RETURN(status=1)
  253. call ReadRc( rcF, 'input.emis.ch4.fix3d', emis_ch4_fix3d, status )
  254. IF_NOTOK_RETURN(status=1)
  255. if( emis_ch4_fix3d ) then
  256. write (gol,*) 'EMISS-INFO - 3-D CH4 field will be fixed to ', emis_ch4_fixed_ppb, ' ppb'; call goPr
  257. else
  258. write (gol,*) 'EMISS-INFO - surface CH4 will be fixed to ', emis_ch4_fixed_ppb, ' ppb'; call goPr
  259. endif
  260. else
  261. ! root name
  262. call ReadRc( rcF, 'input.emis.ch4.surf', emis_zch4_fname, status )
  263. IF_NOTOK_RETURN(status=1)
  264. write (gol,*) 'EMISS-INFO - surface CH4 will be fixed by a zonal mean surface field'; call goPr
  265. endif ! ch4_single
  266. ! used by vertical distribution:
  267. CALL Set( oro_dat(iglbsfc), status, used=.TRUE. )
  268. ! Allocate data
  269. ! -------------
  270. DO region=1,nregions
  271. CALL GET_DISTGRID( dgrid(region), I_STRT=i1, I_STOP=i2, J_STRT=j1, J_STOP=j2 )
  272. lmr = lm(region)
  273. ALLOCATE( plandr(region)%surf(i1:i2, j1:j2))
  274. ALLOCATE( emis2D(region)%surf(i1:i2, j1:j2))
  275. #ifdef with_m7
  276. ! aerosols (up to lmr instead of bb_lm)
  277. DO imode=1,nmod
  278. ALLOCATE(emis_number(region,imode)%d4( i1:i2, j1:j2, lmr, mode_nm(imode)))
  279. ALLOCATE(emis_mass (region,imode)%d4( i1:i2, j1:j2, lmr, mode_nm(imode)))
  280. ENDDO
  281. ALLOCATE(emis_temp(region)%surf(i1:i2, j1:j2))
  282. #endif
  283. #ifdef with_budgets
  284. ALLOCATE( budemi_dat(region)%emi(i1:i2, j1:j2, nbud_vg, ntracet) )
  285. budemi_dat(region)%emi = 0.0
  286. sum_emission(region) = 0.0
  287. #endif
  288. ENDDO
  289. ! Done
  290. ! -------------
  291. call Done( rcF, status )
  292. IF_NOTOK_RETURN(status=1)
  293. ! define timers:
  294. call GO_Timer_Def( itim_appl, 'emission appl', status )
  295. IF_NOTOK_RETURN(status=1)
  296. call GO_Timer_Def( itim_co, 'emission co', status )
  297. IF_NOTOK_RETURN(status=1)
  298. call GO_Timer_Def( itim_voc, 'emission voc', status )
  299. IF_NOTOK_RETURN(status=1)
  300. call GO_Timer_Def( itim_dms, 'emission dms', status )
  301. IF_NOTOK_RETURN(status=1)
  302. call GO_Timer_Def( itim_nh3, 'emission nh3', status )
  303. IF_NOTOK_RETURN(status=1)
  304. call GO_Timer_Def( itim_sox, 'emission sox', status )
  305. IF_NOTOK_RETURN(status=1)
  306. call GO_Timer_Def( itim_ch4, 'emission ch4 ', status )
  307. IF_NOTOK_RETURN(status=1)
  308. call GO_Timer_Def( itim_isop, 'emission isop', status )
  309. IF_NOTOK_RETURN(status=1)
  310. call GO_Timer_Def( itim_rn222, 'emission rn222', status )
  311. IF_NOTOK_RETURN(status=1)
  312. status = 0
  313. END SUBROUTINE EMISSION_INIT
  314. !EOC
  315. !------------------------------------------------------------------------------
  316. ! TM5 !
  317. !------------------------------------------------------------------------------
  318. !BOP
  319. !
  320. ! !IROUTINE: EMISSION_DONE
  321. !
  322. ! !DESCRIPTION: calculate and write final budgets
  323. !\\
  324. !\\
  325. ! !INTERFACE:
  326. !
  327. SUBROUTINE EMISSION_DONE( status )
  328. !
  329. ! !USES:
  330. !
  331. USE dims, ONLY : nregions, im, jm
  332. #ifdef with_budgets
  333. USE chem_param, ONLY : ntracet, names
  334. USE budget_global, ONLY : budget_file_global, nbud_vg, budg_dat, nbudg, NHAB
  335. USE file_hdf, ONLY : THdfFile, TSds
  336. USE file_hdf, ONLY : Init, Done, WriteAttribute, WriteData, SetDim
  337. USE Dims, ONLY : region_name
  338. USE partools, ONLY : isRoot, par_reduce, par_reduce_element
  339. #endif
  340. use emission_data, only : bb_cycle
  341. use emission_data, only : emis_bb_trop_cycle
  342. !
  343. ! !OUTPUT PARAMETERS:
  344. !
  345. INTEGER, INTENT(out) :: status
  346. !
  347. ! !REVISION HISTORY:
  348. ! 16 Jul 2010 - A. Strunk -
  349. ! 27 Mar 2012 - P. Le Sager - adapted for lon-lat MPI domain decomposition
  350. !
  351. !EOP
  352. !------------------------------------------------------------
  353. !BOC
  354. CHARACTER(len=*), PARAMETER :: rname = mname//'/Emission_Done'
  355. INTEGER :: region, i1, i2, j1, j2
  356. #ifdef with_budgets
  357. TYPE(THdfFile) :: io
  358. TYPE(TSds) :: sds
  359. REAL, DIMENSION(:,:,:,:), ALLOCATABLE :: collect_emissions
  360. INTEGER :: nsend,j,i,n,nzone,nzone_v
  361. real, dimension(nregions) :: sum_emission_all
  362. #endif
  363. ! --- begin ---------------------------------
  364. #ifdef with_budgets
  365. ! add up contribution from all proc
  366. DO region = 1, nregions
  367. CALL PAR_REDUCE(sum_emission(region), 'SUM', sum_emission_all(region), status)
  368. IF_NOTOK_RETURN(status=1)
  369. END DO
  370. ! Write global budget of tracer #1
  371. IF ( isRoot ) THEN
  372. write (gol,'("EMISS-INFO - ----------------------------------------------")'); call goPr
  373. write (gol,'("EMISS-INFO - Budget of tracer ",a," (kg) ")') trim(names(1)) ; call goPr
  374. write (gol,'("EMISS-INFO - ----------------------------------------------")'); call goPr
  375. do region = 1, nregions
  376. write (gol,'(A,E13.6)') 'EMISS-INFO - mass emitted : ',sum_emission_all(region); call goPr
  377. enddo
  378. CALL Init(io, budget_file_global, 'write', status)
  379. IF_NOTOK_RETURN(status=1)
  380. CALL WriteAttribute(io, 'sum_emission', sum_emission_all, status)
  381. IF_NOTOK_RETURN(status=1)
  382. budemig = 0.0
  383. END IF
  384. ! Gather budgets
  385. REG: DO region = 1, nregions
  386. CALL GET_DISTGRID( dgrid(region), I_STRT=i1, I_STOP=i2, J_STRT=j1, J_STOP=j2 )
  387. if (isRoot) then
  388. ALLOCATE(collect_emissions(im(region), jm(region), nbud_vg, ntracet))
  389. else
  390. ALLOCATE(collect_emissions(1,1,1,1) )
  391. end if
  392. CALL GATHER( dgrid(region), budemi_dat(region)%emi, collect_emissions, 0, status)
  393. IF_NOTOK_RETURN(status=1)
  394. ! write Not-Horizontally-Aggregated-Budgets
  395. IF (isRoot.and.NHAB) THEN
  396. CALL Init(Sds,io, 'budemi_dat_'//region_name(region),(/im(region),jm(region),nbud_vg,ntracet/), 'real(4)', status)
  397. CALL SetDim(Sds, 0, 'im_'//region_name(region),'longitude', (/(j, j=1,im(region))/), status)
  398. CALL SetDim(Sds, 1, 'jm_'//region_name(region),'latitude', (/(j, j=1,jm(region))/), status)
  399. CALL SetDim(Sds, 2, 'nbud_vg','vertical layer', (/(j, j=1,nbud_vg)/), status)
  400. CALL SetDim(Sds, 3, 'ntracet','tracer number', (/(j, j=1,ntracet)/), status)
  401. IF_NOTOK_RETURN(status=1)
  402. CALL WriteData(Sds,collect_emissions,status)
  403. IF_NOTOK_RETURN(status=1)
  404. CALL Done(Sds, status)
  405. IF_NOTOK_RETURN(status=1)
  406. ENDIF
  407. ! horizontally aggregates budgets
  408. DO n=1,ntracet
  409. DO nzone_v=1,nbud_vg
  410. DO j=j1,j2
  411. DO i=i1,i2
  412. nzone = budg_dat(region)%nzong(i,j)
  413. budemig(nzone,nzone_v,n) = budemig(nzone,nzone_v,n) + budemi_dat(region)%emi(i,j,nzone_v,n)
  414. END DO
  415. END DO !j
  416. END DO !nzone_v
  417. END DO !nt
  418. DEALLOCATE( collect_emissions )
  419. DEALLOCATE( budemi_dat(region)%emi )
  420. ENDDO REG
  421. CALL PAR_REDUCE_ELEMENT( budemig, 'SUM', budemig_all, status)
  422. IF_NOTOK_RETURN(status=1)
  423. ! Write horizontally aggregated budget
  424. IF ( isRoot ) THEN
  425. CALL Init(Sds,io, 'budemi',(/nbudg,nbud_vg,ntracet/), 'real(8)', status)
  426. IF_NOTOK_RETURN(status=1)
  427. CALL SetDim(Sds, 0, 'nbudg','horizontal region', (/(j, j=1,nbudg)/), status)
  428. CALL SetDim(Sds, 1, 'nbud_vg','vertical layer', (/(j, j=1,nbud_vg)/), status)
  429. CALL SetDim(Sds, 2, 'ntracet','tracer number', (/(j, j=1,ntracet)/), status)
  430. IF_NOTOK_RETURN(status=1)
  431. CALL WriteData(Sds,budemig_all,status)
  432. IF_NOTOK_RETURN(status=1)
  433. CALL Done(Sds, status)
  434. IF_NOTOK_RETURN(status=1)
  435. CALL Done(io, status)
  436. IF_NOTOK_RETURN(status=1)
  437. ENDIF
  438. #endif /* BUDGETS */
  439. ! call other emission_*_done routines
  440. CALL FREE_EMISSION(status)
  441. IF_NOTOK_RETURN(status=1)
  442. ! -----------------------------------------------------------------------------------
  443. ! Free biomassburning time splitting factors (now globally, instead of by constituent)
  444. if( emis_bb_trop_cycle ) then
  445. do region = 1, nregions
  446. deallocate(bb_cycle(region)%scalef)
  447. end do
  448. end if
  449. ! -----------------------------------------------------------------------------------
  450. ! ok
  451. status = 0
  452. END SUBROUTINE EMISSION_DONE
  453. !EOC
  454. !---------------------------------------------------------------------------
  455. ! TM5 !
  456. !---------------------------------------------------------------------------
  457. !BOP
  458. !
  459. ! !IROUTINE: DECLARE_EMISSION
  460. !
  461. ! !DESCRIPTION: Called at run start (init/allocate emiss data) and then at
  462. ! beginning of every month to just read in data.
  463. ! Called from SS_MONTHLY_UPDATE.
  464. !\\
  465. !\\
  466. ! !INTERFACE:
  467. !
  468. SUBROUTINE DECLARE_EMISSION( status )
  469. !
  470. ! !USES:
  471. !
  472. USE Grid, ONLY : FillGrid
  473. USE MDF, ONLY : MDF_Open, MDF_HDF4, MDF_READ, MDF_Inq_VarID, MDF_Get_Var, MDF_Close
  474. USE dims, ONLY : im, jm, lm, newsrun
  475. USE dims, ONLY : nregions, iglbsfc, nlat180, nlon360
  476. USE chem_param
  477. #ifdef with_m7
  478. USE mo_aero_m7, ONLY : nmod
  479. #endif
  480. USE partools, ONLY : isRoot
  481. USE global_data, ONLY : emis_data
  482. USE meteodata, ONLY : global_lli
  483. #ifdef with_online_nox
  484. use Online_NOx, only : Online_NOx_Init
  485. ! use online_nox_data, only : mlai2d_onlinenox
  486. #endif
  487. #ifdef with_online_bvoc
  488. USE Emission_BVOC, ONLY : Online_BVOC_Init
  489. #endif
  490. ! AR5/EDGAR4
  491. use emission_data, only : emis_input_dir
  492. !
  493. ! !OUTPUT PARAMETERS:
  494. !
  495. INTEGER, INTENT(out) :: status
  496. !
  497. ! !REVISION HISTORY:
  498. ! 16 Jul 2010 - A. Strunk - Adapted to revised emission_*.F90 routines
  499. ! 27 Mar 2012 - P. Le Sager - adapted for lon-lat MPI domain decomposition
  500. !
  501. ! !REMARKS:
  502. ! - anything that is done only if it's a newrun, and that does not require meteo data, should go in INIT
  503. !
  504. !EOP
  505. !------------------------------------------------------------------------------
  506. !BOC
  507. CHARACTER(len=*), PARAMETER :: rname = mname//'/declare_emission'
  508. INTEGER :: region, imode, hid
  509. REAL, DIMENSION(:,:), ALLOCATABLE :: pland
  510. type(emis_data), dimension(nregions) :: wrk
  511. ! -----------------
  512. ! Reset M7 emission
  513. ! -----------------
  514. #ifdef with_m7
  515. DO region=1,nregions
  516. DO imode=1,nmod
  517. emis_number(region,imode)%d4 = 0.0
  518. emis_mass (region,imode)%d4 = 0.0
  519. END DO
  520. END DO
  521. #endif
  522. ! ---------------------------------------------------------------
  523. ! ** land fraction
  524. ! ---------------------------------------------------------------
  525. IF( newsrun ) THEN
  526. if(isRoot)then
  527. ALLOCATE( pland(nlon360,nlat180) )
  528. DO region=1,nregions
  529. allocate( wrk(region)%surf(im(region),jm(region)) )
  530. end DO
  531. else
  532. ALLOCATE( pland(1,1) )
  533. DO region=1,nregions
  534. allocate( wrk(region)%surf(1,1))
  535. end DO
  536. end if
  537. if (isRoot)then
  538. CALL MDF_Open( TRIM(emis_input_dir)//'/land/landfraction.hdf', MDF_HDF4, MDF_READ, hid, status )
  539. IF_NOTOK_RETURN(status=1)
  540. ! CALL MDF_Inq_VarID( hid, TRIM(filemon), varid, status ) ! more than one 'landfraction' sds
  541. ! IF_NOTOK_RETURN(status=1)
  542. CALL MDF_Get_Var( hid, 1, pland, status )
  543. IF_NOTOK_RETURN(status=1)
  544. CALL MDF_Close( hid, status )
  545. IF_NOTOK_RETURN(status=1)
  546. ! coarsen or distribute to zoom regions:
  547. DO region = 1, nregions
  548. ! convert grid:
  549. CALL FillGrid( global_lli(region), 'n', wrk(region)%surf, &
  550. global_lli(iglbsfc), 'n', pland, 'area-aver', status )
  551. IF_NOTOK_RETURN(status=1)
  552. END DO
  553. end if
  554. DO region = 1, nregions
  555. call scatter( dgrid(region), plandr(region)%surf, wrk(region)%surf, 0, status)
  556. IF_NOTOK_RETURN(status=1)
  557. DEALLOCATE( wrk(region)%surf )
  558. END DO
  559. DEALLOCATE( pland )
  560. ENDIF
  561. ! ---------------------------------------------------------------
  562. ! ** init each constituent
  563. ! ---------------------------------------------------------------
  564. ! ** 1st time, initialise emissions
  565. IF ( newsrun ) THEN
  566. CALL Emission_NOx_Init( status )
  567. IF_NOTOK_RETURN(status=1)
  568. #ifdef with_online_nox
  569. ! init online nox module:
  570. CALL Online_NOx_Init( status )
  571. IF_NOTOK_RETURN(status=1)
  572. #endif
  573. CALL Emission_NMVOC_Init( status )
  574. IF_NOTOK_RETURN(status=1)
  575. CALL Emission_NH3_Init( status )
  576. IF_NOTOK_RETURN(status=1)
  577. CALL Emission_CO_Init( status )
  578. IF_NOTOK_RETURN(status=1)
  579. CALL Emission_CH4_Init( status )
  580. IF_NOTOK_RETURN(status=1)
  581. CALL Emission_SOx_Init( status )
  582. IF_NOTOK_RETURN(status=1)
  583. CALL Emission_DMS_Init( status )
  584. IF_NOTOK_RETURN(status=1)
  585. CALL Emission_rn222_Init( status )
  586. IF_NOTOK_RETURN(status=1)
  587. #ifdef with_m7
  588. call emission_bc_init( status )
  589. IF_NOTOK_RETURN(status=1)
  590. call emission_pom_init( status )
  591. IF_NOTOK_RETURN(status=1)
  592. #endif
  593. END IF
  594. ! ** every month, read and re-grid
  595. CALL emission_nox_declare( status )
  596. IF_NOTOK_RETURN(status=1)
  597. CALL emission_nmvoc_declare( status )
  598. IF_NOTOK_RETURN(status=1)
  599. CALL emission_nh3_declare( status )
  600. IF_NOTOK_RETURN(status=1)
  601. CALL emission_co_declare( status )
  602. IF_NOTOK_RETURN(status=1)
  603. CALL emission_ch4_declare( status )
  604. IF_NOTOK_RETURN(status=1)
  605. CALL emission_sox_declare( status )
  606. IF_NOTOK_RETURN(status=1)
  607. CALL emission_dms_declare( status )
  608. IF_NOTOK_RETURN(status=1)
  609. ! ** special case of bio voc/isoprene
  610. #ifdef with_online_bvoc
  611. CALL Online_BVOC_Init( status )
  612. IF_NOTOK_RETURN(status=1)
  613. CALL declare_emission_bvoc( status )
  614. #else
  615. IF ( newsrun ) THEN
  616. CALL Emission_isop_Init( status )
  617. IF_NOTOK_RETURN(status=1)
  618. END IF
  619. CALL emission_isop_declare( status )
  620. IF_NOTOK_RETURN(status=1)
  621. #endif
  622. CALL emission_rn222_declare( status )
  623. IF_NOTOK_RETURN(status=1)
  624. #ifdef with_m7
  625. CALL emission_bc_declare( status)
  626. IF_NOTOK_RETURN(status=1)
  627. CALL emission_pom_declare( status )
  628. IF_NOTOK_RETURN(status=1)
  629. CALL emission_dust_declare(status)
  630. IF_NOTOK_RETURN(status=1)
  631. !!$ CALL declare_emission_ss(status)
  632. !!$ IF_NOTOK_RETURN(status=1)
  633. #endif
  634. ! ok
  635. status = 0
  636. END SUBROUTINE DECLARE_EMISSION
  637. !EOC
  638. !-------------------------------------------------------------------
  639. ! TM5 !
  640. !-------------------------------------------------------------------
  641. !BOP
  642. !
  643. ! !IROUTINE: EMISSION_APPLY
  644. !
  645. ! !DESCRIPTION: Call emission_apply methods of constituent modules.
  646. ! --> add current emissions to tracers array.
  647. !\\
  648. !\\
  649. ! !INTERFACE:
  650. !
  651. SUBROUTINE EMISSION_APPLY( region, status )
  652. !
  653. ! !USES:
  654. !
  655. USE chem_param
  656. !
  657. ! !INPUT PARAMETERS:
  658. !
  659. INTEGER, INTENT(in) :: region
  660. !
  661. ! !OUTPUT PARAMETERS:
  662. !
  663. INTEGER, INTENT(out) :: status
  664. !
  665. ! !REVISION HISTORY:
  666. ! 16 Jul 2010 - A. Strunk - Adapted to revised emission_*.F90 routines
  667. ! 27 Mar 2012 - P. Le Sager - cleanup for lat-lon mpi decomposition
  668. !
  669. !EOP
  670. !-----------------------------------------------------------------
  671. !BOC
  672. CHARACTER(len=*), PARAMETER :: rname = mname//'/emission_apply'
  673. ! --- begin --------------------------------------
  674. ! start timing:
  675. call GO_Timer_Start( itim_appl, status )
  676. IF_NOTOK_RETURN(status=1)
  677. IF (okdebug) then
  678. WRITE(gol,*) 'start of emission_apply for region:',region ; call goPr
  679. END IF
  680. ! CO emissions
  681. call GO_Timer_Start( itim_co, status )
  682. IF_NOTOK_RETURN(status=1)
  683. CALL emission_co_apply( region, status )
  684. IF_NOTOK_RETURN(status=1)
  685. call GO_Timer_End( itim_co, status )
  686. IF_NOTOK_RETURN(status=1)
  687. ! CH4 emissions
  688. call GO_Timer_Start( itim_ch4, status )
  689. IF_NOTOK_RETURN(status=1)
  690. CALL emission_ch4_apply(region, status )
  691. IF_NOTOK_RETURN(status=1)
  692. call GO_Timer_End( itim_ch4, status )
  693. IF_NOTOK_RETURN(status=1)
  694. ! biogenic NMHC emissions (isoprene)
  695. call GO_Timer_Start( itim_isop, status )
  696. IF_NOTOK_RETURN(status=1)
  697. #ifdef with_online_bvoc
  698. CALL emission_apply_bvoc( region, status )
  699. #else
  700. CALL emission_isop_apply( region, status )
  701. IF_NOTOK_RETURN(status=1)
  702. #endif
  703. call GO_Timer_End( itim_isop, status )
  704. IF_NOTOK_RETURN(status=1)
  705. ! add di-methyl sulfide emissions:
  706. call GO_Timer_Start( itim_dms, status )
  707. IF_NOTOK_RETURN(status=1)
  708. CALL emission_dms_apply(region, status)
  709. IF_NOTOK_RETURN(status=1)
  710. call GO_Timer_End( itim_dms, status )
  711. IF_NOTOK_RETURN(status=1)
  712. ! add SOx emissions:
  713. call GO_Timer_Start( itim_sox, status )
  714. IF_NOTOK_RETURN(status=1)
  715. CALL emission_sox_apply( region, status )
  716. IF_NOTOK_RETURN(status=1)
  717. call GO_Timer_End( itim_sox, status )
  718. IF_NOTOK_RETURN(status=1)
  719. ! add NH3 emissions:
  720. call GO_Timer_Start( itim_nh3, status )
  721. IF_NOTOK_RETURN(status=1)
  722. CALL emission_nh3_apply(region, status)
  723. IF_NOTOK_RETURN(status=1)
  724. call GO_Timer_End( itim_nh3, status )
  725. IF_NOTOK_RETURN(status=1)
  726. ! add Rn222 emissions:
  727. call GO_Timer_Start( itim_rn222, status )
  728. IF_NOTOK_RETURN(status=1)
  729. CALL emission_rn222_apply(region, status)
  730. IF_NOTOK_RETURN(status=1)
  731. call GO_Timer_End( itim_rn222, status )
  732. IF_NOTOK_RETURN(status=1)
  733. ! black carbon and particulate organic matter emissions are added in the sedimentation routine...
  734. ! seasalt and dust (which also sediment) are added in tracer_after_read...
  735. ! add non-methane voc emissions:
  736. call GO_Timer_Start( itim_voc, status )
  737. IF_NOTOK_RETURN(status=1)
  738. CALL emission_nmvoc_apply( region, status )
  739. IF_NOTOK_RETURN(status=1)
  740. call GO_Timer_End( itim_voc, status )
  741. IF_NOTOK_RETURN(status=1)
  742. IF(okdebug) then
  743. WRITE(gol,*) 'End of adding emission '; call goPr
  744. END IF
  745. ! end timing:
  746. call GO_Timer_End( itim_appl, status )
  747. IF_NOTOK_RETURN(status=1)
  748. ! ok
  749. status = 0
  750. END SUBROUTINE EMISSION_APPLY
  751. !EOC
  752. !----------------------------------------------------------------------------
  753. ! TM5 !
  754. !----------------------------------------------------------------------------
  755. !BOP
  756. !
  757. ! !IROUTINE: FREE_EMISSION
  758. !
  759. ! !DESCRIPTION: Deallocate space needed to handle the emissions by calling
  760. ! *done methods of constituents' modules.
  761. !\\
  762. !\\
  763. ! !INTERFACE:
  764. !
  765. SUBROUTINE FREE_EMISSION( status )
  766. !
  767. ! !USES:
  768. !
  769. USE dims, ONLY : nregions
  770. #ifdef with_m7
  771. USE mo_aero_m7, ONLY : nmod
  772. #endif
  773. #ifdef with_online_nox
  774. USE Online_NOx, ONLY : Online_NOx_Done
  775. #endif
  776. #ifdef with_online_bvoc
  777. USE Emission_BVOC, ONLY : Online_BVOC_Done
  778. #endif
  779. !
  780. ! !OUTPUT PARAMETERS:
  781. !
  782. INTEGER, INTENT(out) :: status
  783. !
  784. ! !REVISION HISTORY:
  785. ! 16 Jul 2010 - A. Strunk - Adapted to revised emission_*.F90 routines
  786. ! 27 Mar 2012 - P. Le Sager - Adapted for lon-lat MPI domain decomposition
  787. !
  788. !EOP
  789. !---------------------------------------------------------------------------
  790. !BOC
  791. CHARACTER(len=*), PARAMETER :: rname = mname//'/free_emission'
  792. INTEGER :: region, imode
  793. ! --- begin -----------------------------------
  794. DO region = 1, nregions
  795. DEALLOCATE(plandr(region)%surf)
  796. DEALLOCATE(emis2D(region)%surf)
  797. #ifdef with_m7
  798. ! aerosols:
  799. DO imode = 1, nmod
  800. DEALLOCATE(emis_number(region,imode)%d4)
  801. DEALLOCATE(emis_mass(region,imode)%d4)
  802. ENDDO
  803. DEALLOCATE(emis_temp(region)%surf)
  804. #endif
  805. ENDDO
  806. CALL Emission_NOx_Done( status )
  807. IF_NOTOK_RETURN(status=1)
  808. #ifdef with_online_nox
  809. CALL Online_NOx_Done( status )
  810. IF_NOTOK_RETURN(status=1)
  811. #endif
  812. CALL emission_nh3_done( status )
  813. IF_NOTOK_RETURN(status=1)
  814. CALL Emission_CO_Done( status )
  815. IF_NOTOK_RETURN(status=1)
  816. CALL Emission_CH4_Done( status )
  817. IF_NOTOK_RETURN(status=1)
  818. CALL Emission_SOx_Done( status )
  819. IF_NOTOK_RETURN(status=1)
  820. CALL emission_dms_done( status )
  821. IF_NOTOK_RETURN(status=1)
  822. #ifdef with_online_bvoc
  823. CALL free_emission_bvoc ( status )
  824. ! done with online bvoc module:
  825. CALL Online_BVOC_Done( status )
  826. IF_NOTOK_RETURN(status=1)
  827. #else
  828. CALL Emission_isop_Done ( status )
  829. IF_NOTOK_RETURN(status=1)
  830. #endif
  831. CALL emission_rn222_done( status )
  832. IF_NOTOK_RETURN(status=1)
  833. #ifdef with_m7
  834. CALL emission_bc_done( status )
  835. IF_NOTOK_RETURN(status=1)
  836. CALL emission_pom_done( status )
  837. IF_NOTOK_RETURN(status=1)
  838. CALL emission_dust_done
  839. !!$ CALL free_emission_ss
  840. #endif
  841. CALL Emission_NMVOC_Done( status )
  842. IF_NOTOK_RETURN(status=1)
  843. ! done
  844. status = 0
  845. END SUBROUTINE FREE_EMISSION
  846. !EOC
  847. END MODULE EMISSION