emission_ch4.F90 45 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367
  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_CH4
  14. !
  15. ! !DESCRIPTION: Perform CH4 emissions needed for TM5 CBM4 version.
  16. ! For AR5 runs, fix the CH4 concentration and keep track
  17. ! of the 3D field where CH4 is added
  18. ! (with_ch4_emissions).
  19. !\\
  20. !\\
  21. ! !INTERFACE:
  22. !
  23. MODULE EMISSION_CH4
  24. !
  25. ! !USES:
  26. !
  27. use GO, only : gol, goPr, goErr
  28. use tm5_distgrid, only : dgrid, get_distgrid, scatter, scatter_i_band
  29. use partools, only : isRoot, par_broadcast
  30. use dims, only : nregions, idate, okdebug
  31. use global_types, only : emis_data, d3_data, d2_data, d23_data
  32. use emission_data, only : LCMIP6_CH4
  33. use emission_data, only : emis_ch4_single, emis_ch4_fix3d
  34. use emission_data, only : emis_ch4_fixed_ppb
  35. use emission_read, only : used_providers_ch4, has_ch4_emis
  36. IMPLICIT NONE
  37. PRIVATE
  38. !
  39. ! !PUBLIC MEMBER FUNCTIONS:
  40. !
  41. public :: Emission_CH4_Init
  42. public :: Emission_CH4_Done
  43. public :: emission_ch4_declare
  44. public :: emission_ch4_apply
  45. !
  46. ! !PRIVATE DATA MEMBERS:
  47. !
  48. character(len=*), parameter :: mname = 'emission_ch4'
  49. #ifdef with_ch4_emis
  50. type(emis_data), dimension(:,:), allocatable :: ch4_emis_2d
  51. type(d3_data), dimension(:,:), allocatable :: ch4_emis_3d
  52. integer :: ch4_2dsec, ch4_3dsec
  53. #endif
  54. logical, allocatable :: has_data_3d(:), has_data_2d(:)
  55. type(d2_data), target :: zch4(nregions), tmp2d(nregions)
  56. type(d23_data), target :: wrk_c(nregions)
  57. type(d2_data), target :: zch4_p(nregions) ! previous month
  58. type(d23_data), target :: wrk_p(nregions)
  59. type(d2_data), target :: zch4_n(nregions) ! next month
  60. type(d23_data), target :: wrk_n(nregions)
  61. !
  62. ! !REVISION HISTORY:
  63. ! 1 Oct 2010 - Achim Strunk - overhaul for AR5
  64. ! 28 Jun 2012 - Ph. Le Sager - adapted for lon-lat MPI domain decomposition
  65. ! - made zch4 of type d2_data
  66. ! 20 Nov 2012 - Ph. Le Sager - fix runs longer than a month
  67. !
  68. ! !REMARKS:
  69. !
  70. !EOP
  71. !------------------------------------------------------------------------
  72. CONTAINS
  73. !--------------------------------------------------------------------------
  74. ! TM5 !
  75. !--------------------------------------------------------------------------
  76. !BOP
  77. !
  78. ! !IROUTINE: EMISSION_CH4_INIT
  79. !
  80. ! !DESCRIPTION: Allocate memory.
  81. !\\
  82. !\\
  83. ! !INTERFACE:
  84. !
  85. subroutine Emission_CH4_Init( status )
  86. !
  87. ! !USES:
  88. !
  89. use dims, only : jm, lm
  90. use emission_read, only : providers_def, numb_providers, ed42_nsect_ch4
  91. use emission_data, only : LAR5BMB
  92. use emission_read, only : n_ar5_ant_sec, n_ar5_shp_sec, n_ar5_air_sec, n_ar5_bmb_sec
  93. use emission_read, only : ar5_cat_ant, ar5_cat_shp, ar5_cat_air, ar5_cat_bmb
  94. !
  95. ! !OUTPUT PARAMETERS:
  96. !
  97. integer, intent(out) :: status
  98. !
  99. ! !REVISION HISTORY:
  100. ! 1 Oct 2010 - Achim Strunk - adapted for AR5
  101. ! 28 Jun 2012 - Ph. Le Sager - always allocate zch4
  102. ! - adapted for lon-lat MPI domain decomposition
  103. !
  104. ! !REMARKS:
  105. !
  106. !EOP
  107. !------------------------------------------------------------------------
  108. !BOC
  109. character(len=*), parameter :: rname = mname//'/Emission_CH4_Init'
  110. integer :: region, i1, i2, j1, j2
  111. integer :: jmr, lmr, lsec, lprov
  112. ! --- begin --------------------------------------
  113. #ifdef with_ch4_emis
  114. ! --- count sectors
  115. if(has_ch4_emis) then
  116. ch4_2dsec = 0
  117. ch4_3dsec = 0
  118. do lprov = 1, numb_providers
  119. if (count(used_providers_ch4.eq.providers_def(lprov)%name)/=0) then
  120. if (trim(providers_def(lprov)%name) .eq. 'CMIP6') then
  121. ! Historical emissions of CH4 from aircraft are zero everywhere
  122. ! and it is assumed that this will also be the case for the future scenarios
  123. ch4_2dsec = ch4_2dsec + providers_def(lprov)%nsect2d
  124. elseif (trim(providers_def(lprov)%name) .eq. 'AR5') then
  125. ! nb of available sectors in AR5 depends on category
  126. ch4_2dsec = ch4_2dsec + n_ar5_ant_sec*count('CH4'.eq.ar5_cat_ant) + &
  127. n_ar5_shp_sec*count('CH4'.eq.ar5_cat_shp)
  128. if (LAR5BMB) ch4_2dsec = ch4_2dsec + n_ar5_bmb_sec*count('CH4'.eq.ar5_cat_bmb)
  129. ch4_3dsec = ch4_3dsec + n_ar5_air_sec*count('CH4'.eq.ar5_cat_air)
  130. elseif (trim(providers_def(lprov)%name) .eq. 'ED42') then
  131. ch4_2dsec = ch4_2dsec + ed42_nsect_ch4
  132. ! no 3d sectors in EDGAR 4.2
  133. else
  134. ch4_2dsec = ch4_2dsec + providers_def(lprov)%nsect2d
  135. ch4_3dsec = ch4_3dsec + providers_def(lprov)%nsect3d
  136. endif
  137. endif
  138. enddo
  139. allocate( ch4_emis_2d( nregions, ch4_2dsec ) )
  140. allocate( ch4_emis_3d( nregions, ch4_3dsec ) )
  141. allocate( has_data_2d(ch4_2dsec)) ; has_data_2d=.false.
  142. allocate( has_data_3d(ch4_3dsec)) ; has_data_3d=.false.
  143. end if
  144. #endif
  145. REG: do region=1,nregions
  146. lmr = lm(region) ; jmr = jm(region)
  147. CALL GET_DISTGRID( dgrid(region), i_strt=i1, j_strt=j1, i_stop=i2, j_stop=j2)
  148. #ifdef with_ch4_emis
  149. if(has_ch4_emis) then
  150. ! --- allocate information arrays (2d and 3d)
  151. do lsec=1,ch4_2dsec
  152. allocate( ch4_emis_2d(region,lsec)%surf(i1:i2, j1:j2) )
  153. end do
  154. do lsec=1,ch4_3dsec
  155. allocate( ch4_emis_3d(region,lsec)%d3(i1:i2, j1:j2, lmr) )
  156. end do
  157. end if
  158. #endif
  159. ! 1d-constraining surface array
  160. allocate( zch4(region)%d2(j1:j2) )
  161. allocate( zch4_p(region)%d2(j1:j2) )
  162. allocate( zch4_n(region)%d2(j1:j2) )
  163. allocate( tmp2d(region)%d2(j2-j1+1))
  164. zch4(region)%d2 = 0.0
  165. zch4_p(region)%d2 = 0.0
  166. zch4_n(region)%d2 = 0.0
  167. ! work arrays
  168. if(isRoot) then
  169. allocate( wrk_c(region)%d23(1,jmr))
  170. allocate( wrk_p(region)%d23(1,jmr))
  171. allocate( wrk_n(region)%d23(1,jmr))
  172. else
  173. allocate( wrk_c(region)%d23(1,1))
  174. allocate( wrk_p(region)%d23(1,1))
  175. allocate( wrk_n(region)%d23(1,1))
  176. end if
  177. enddo REG
  178. status = 0
  179. END SUBROUTINE EMISSION_CH4_INIT
  180. !EOC
  181. !--------------------------------------------------------------------------
  182. ! TM5 !
  183. !--------------------------------------------------------------------------
  184. !BOP
  185. !
  186. ! !IROUTINE: EMISSION_CH4_DONE
  187. !
  188. ! !DESCRIPTION: Free memory
  189. !\\
  190. !\\
  191. ! !INTERFACE:
  192. !
  193. subroutine Emission_CH4_Done( status )
  194. !
  195. ! !OUTPUT PARAMETERS:
  196. !
  197. integer, intent(out) :: status
  198. !
  199. ! !REVISION HISTORY:
  200. ! 1 Oct 2010 - Achim Strunk - adapted to new structures
  201. ! 28 Jun 2012 - Ph. Le Sager - adapted for lon-lat MPI domain decomposition
  202. !
  203. !EOP
  204. !------------------------------------------------------------------------
  205. !BOC
  206. character(len=*), parameter :: rname = mname//'/Emission_CH4_Done'
  207. integer :: region, lsec
  208. ! --- begin --------------------------------------
  209. reg: do region = 1, nregions
  210. deallocate( zch4(region)%d2 )
  211. deallocate( zch4_n(region)%d2 )
  212. deallocate( zch4_p(region)%d2 )
  213. deallocate( tmp2d(region)%d2 )
  214. deallocate( wrk_c(region)%d23 )
  215. deallocate( wrk_p(region)%d23 )
  216. deallocate( wrk_n(region)%d23 )
  217. #ifdef with_ch4_emis
  218. if (has_ch4_emis) then
  219. do lsec=1,ch4_2dsec
  220. deallocate( ch4_emis_2d(region,lsec)%surf )
  221. end do
  222. do lsec=1,ch4_3dsec
  223. deallocate( ch4_emis_3d(region,lsec)%d3 )
  224. end do
  225. deallocate( has_data_2d, has_data_3d)
  226. end if
  227. #endif
  228. end do reg
  229. #ifdef with_ch4_emis
  230. if (has_ch4_emis) then
  231. deallocate( ch4_emis_2d )
  232. deallocate( ch4_emis_3d )
  233. end if
  234. #endif
  235. status = 0
  236. end subroutine Emission_CH4_Done
  237. !EOC
  238. !--------------------------------------------------------------------------
  239. ! TM5 !
  240. !--------------------------------------------------------------------------
  241. !BOP
  242. !
  243. ! !IROUTINE: EMISSION_CH4_DECLARE
  244. !
  245. ! !DESCRIPTION: Opens, reads and evaluates input files (per month).
  246. ! Provides emissions on 2d/3d-arrays which are then added
  247. ! to mixing ratios in routine *apply.
  248. !\\
  249. !\\
  250. ! !INTERFACE:
  251. !
  252. SUBROUTINE EMISSION_CH4_DECLARE( status )
  253. !
  254. ! !USES:
  255. !
  256. use toolbox, only : coarsen_emission
  257. use dims, only : im, jm, lm, idate, sec_month, nlon360, nlat180, iglbsfc
  258. use chem_param, only : xmch4, ich4
  259. use emission_data, only : msg_emis, LAR5BMB
  260. ! ---------------- CMIP6 - AR5 - EDGAR4 - ETC
  261. use emission_data, only : ch4_fixyear
  262. use emission_data, only : emis_input_year_ch4, emis_input_year_nat
  263. use emission_data, only : emis_input_dir_retro
  264. use emission_data, only : emis_input_dir_gfed
  265. use emission_data, only : emis_input_dir_ed4
  266. #ifdef with_ch4_emis
  267. use emission_data, only : emis_input_dir_natch4
  268. #endif
  269. use emission_read, only : read_cmip6_zch4
  270. use emission_read, only : emission_ar5_regrid_aircraft
  271. use emission_read, only : emission_cmip6_ReadSector
  272. use emission_read, only : emission_cmip6bmb_ReadSector
  273. use emission_read, only : emission_ar5_ReadSector
  274. use emission_read, only : emission_ed4_ReadSector
  275. use emission_read, only : emission_gfed_ReadSector
  276. use emission_read, only : emission_retro_ReadSector
  277. use emission_read, only : emission_lpj_ReadSector
  278. use emission_read, only : emission_hymn_ReadSector
  279. use emission_read, only : sectors_def, numb_sectors
  280. use emission_read, only : ar5_dim_3ddata
  281. use emission_read, only : ed42_ch4_sectors
  282. use Grid, only : FillGrid
  283. use meteodata, only : lli_z
  284. !
  285. ! !OUTPUT PARAMETERS:
  286. !
  287. integer, intent(out) :: status
  288. !
  289. ! !REVISION HISTORY:
  290. ! 1 Oct 2010 - Achim Strunk - adapted for AR5
  291. ! 1 Dec 2011 - Narcisa Banda - added EDGAR 4.1
  292. ! 28 Jun 2012 - Ph. Le Sager - adapted for lon-lat MPI domain decomposition
  293. !
  294. !EOP
  295. !------------------------------------------------------------------------
  296. !BOC
  297. character(len=*), parameter :: rname = mname//'/emission_ch4_declare'
  298. integer :: region, hasData
  299. integer, parameter :: add_field=0
  300. integer, parameter :: amonth=2
  301. integer :: lsec, nyear, nmon
  302. integer :: target_year, target_month
  303. integer :: lmr, i1, i2, j1, j2
  304. ! Emissions arrays
  305. real, dimension(:,:,:), allocatable :: field3d, field3d_p, field3d_n
  306. type(d3_data), dimension(nregions) :: emis3d, work, work3D
  307. type(emis_data) :: wrk2D(nregions)
  308. integer :: seccount2d, seccount3d
  309. ! --- begin ----------------------------------
  310. #ifdef with_ch4_emis
  311. write(gol,'(" EMISS-INFO ------------- read CH4 emissions -------------")'); call goPr
  312. if(has_ch4_emis) then
  313. do region = 1, nregions
  314. do lsec=1,ch4_2dsec
  315. ch4_emis_2d(region,lsec)%surf = 0.0
  316. end do
  317. do lsec=1,ch4_3dsec
  318. ch4_emis_3d(region,lsec)%d3 = 0.0
  319. end do
  320. CALL GET_DISTGRID( dgrid(region), I_STRT=i1, I_STOP=i2, J_STRT=j1, J_STOP=j2 )
  321. lmr = lm(region)
  322. allocate( work3d(region)%d3 (i1:i2,j1:j2, ar5_dim_3ddata) ) ; work3d(region)%d3 = 0.0
  323. allocate( emis3d(region)%d3 (i1:i2,j1:j2, lmr ) ) ; emis3d(region)%d3 = 0.0
  324. end do
  325. ! global arrays for coarsening
  326. do region = 1, nregions
  327. if (isRoot)then
  328. allocate(work(region)%d3(im(region),jm(region),ar5_dim_3ddata))
  329. else
  330. allocate(work(region)%d3(1,1,1))
  331. end if
  332. enddo
  333. do region = 1, nregions
  334. wrk2D(region)%surf => work(region)%d3(:,:,1)
  335. end do
  336. ! --------------------------------
  337. ! do a loop over available sectors
  338. ! --------------------------------
  339. ! count 2d and 3d sectors
  340. seccount2d = 0
  341. seccount3d = 0
  342. ! always allocate here 3d data set (for 2d sectors it will be filled in first layer only)
  343. if (isRoot) then
  344. allocate( field3d( nlon360, nlat180, ar5_dim_3ddata ) ) ; field3d = 0.0
  345. else
  346. allocate( field3d( 1, 1, 1 ) )
  347. end if
  348. sec : do lsec = 1, numb_sectors
  349. if (count(used_providers_ch4 == sectors_def(lsec)%prov).eq.0) cycle
  350. if ((trim(sectors_def(lsec)%prov).eq.'ED42') .and. (count(ed42_ch4_sectors.eq.sectors_def(lsec)%name) .eq. 0)) cycle
  351. if (associated(sectors_def(lsec)%species)) then ! AR5 checks
  352. if (count('CH4'.eq.sectors_def(lsec)%species).eq.0) cycle
  353. if ((trim(sectors_def(lsec)%catname) .eq. 'biomassburning').and.(.not.LAR5BMB)) cycle
  354. endif
  355. ! Historical emissions of CH4 from aircraft are zero everywhere
  356. ! and it is assumed that this will also be the case for the future scenarios
  357. if ((trim(sectors_def(lsec)%prov).eq.'CMIP6') .and. (trim(sectors_def(lsec)%catname) .eq. 'aircraft')) cycle
  358. field3d = 0.0
  359. if( sectors_def(lsec)%f3d ) then
  360. seccount3d = seccount3d + 1
  361. else
  362. seccount2d = seccount2d + 1
  363. end if
  364. if (isRoot) then ! READ
  365. select case( trim(sectors_def(lsec)%prov) )
  366. case( 'CMIP6' )
  367. call emission_cmip6_ReadSector( 'CH4', emis_input_year_ch4, idate(2), lsec, field3d, status )
  368. IF_NOTOK_RETURN(status=1;deallocate(field3d))
  369. case( 'CMIP6BMB' )
  370. call emission_cmip6bmb_ReadSector( 'CH4', emis_input_year_ch4, idate(2), lsec, field3d, status )
  371. IF_NOTOK_RETURN(status=1;deallocate(field3d))
  372. case( 'AR5' )
  373. ! Screen out solvent sector for CH4,
  374. ! because it is zero in the RCPs
  375. ! and not present in the historical files.
  376. if (trim(sectors_def(lsec)%name) .ne. 'emiss_slv') then
  377. call emission_ar5_ReadSector( 'CH4', emis_input_year_ch4, idate(2), lsec, field3d, status )
  378. IF_NOTOK_RETURN(status=1)
  379. endif
  380. case( 'ED41' )
  381. ! only transport sector (others provided by ED42)
  382. select case(trim(sectors_def(lsec)%name))
  383. case ('1A3b_c_e','1A3d_SHIP','1A3d1')
  384. ! anthropogenic sources (only 2d)
  385. call emission_ed4_ReadSector( emis_input_dir_ed4, 'CH4', 'ch4', emis_input_year_ch4, idate(2), &
  386. lsec, trim(sectors_def(lsec)%prov) , 'kg / s', field3d, status )
  387. IF_NOTOK_RETURN(status=1;deallocate(field3d))
  388. end select
  389. case( 'ED42' )
  390. ! biomass burning (GFED/RETRO/AR5BMB) and transport (ED41) are excluded through ED42_CH4_SECTORS definition
  391. call emission_ed4_ReadSector( emis_input_dir_ed4, 'CH4', 'ch4', emis_input_year_ch4, idate(2), &
  392. lsec, trim(sectors_def(lsec)%prov), 'kg / s', field3d, status )
  393. IF_NOTOK_RETURN(status=1)
  394. case('GFEDv3')
  395. call emission_gfed_ReadSector( emis_input_dir_gfed, 'ch4', emis_input_year_ch4, idate(2), &
  396. sectors_def(lsec)%name, 'kg / s', field3d(:,:,1), status )
  397. IF_NOTOK_RETURN(status=1;deallocate(field3d))
  398. case('RETRO')
  399. call emission_retro_ReadSector( emis_input_dir_retro, 'CH4', emis_input_year_ch4, idate(2), &
  400. sectors_def(lsec)%name, 'kg / s', field3d(:,:,1), status )
  401. IF_NOTOK_RETURN(status=1;deallocate(field3d))
  402. case( 'LPJ' )
  403. ! this here is for natural sources (only 2d)
  404. call emission_lpj_ReadSector( trim(emis_input_dir_natch4)//'/LPJdata-jan2011', emis_input_year_nat, idate(2), &
  405. sectors_def(lsec)%name, 'kg / s', field3d(:,:,1), status )
  406. IF_NOTOK_RETURN(status=1;deallocate(field3d))
  407. case( 'HYMN' )
  408. ! this here is for natural sources (only 2d)
  409. call emission_hymn_ReadSector( trim(emis_input_dir_natch4), &
  410. sectors_def(lsec)%name, 'kg / s', field3d(:,:,1), status )
  411. IF_NOTOK_RETURN(status=1;deallocate(field3d))
  412. case default
  413. write(gol,*) "Error in buidling list of providers USED_PROVIDERS_CH4"; call goErr
  414. status=1; TRACEBACK; return
  415. end select
  416. ! nothing found???
  417. if( sum(field3d) < 100.*TINY(1.0) ) then
  418. if( okdebug ) then
  419. write(gol,'("EMISS-INFO - no CH4 emissions found for ",a," ",a," for month ",i2 )') &
  420. trim(sectors_def(lsec)%prov), trim(sectors_def(lsec)%name), idate(2) ; call goPr
  421. endif
  422. hasData=0
  423. else
  424. if( okdebug ) then
  425. write(gol,'("EMISS-INFO - found CH4 emissions for ",a," ",a," for month ",i2 )') &
  426. trim(sectors_def(lsec)%prov), trim(sectors_def(lsec)%name), idate(2) ; call goPr
  427. endif
  428. ! scale from kg/s to kg/month
  429. field3d = field3d * sec_month ! kg / month
  430. hasData=1
  431. end if
  432. end if
  433. call Par_broadcast(hasData, status)
  434. IF_NOTOK_RETURN(status=1)
  435. if (hasData == 0) then
  436. cycle sec
  437. else
  438. if ( sectors_def(lsec)%f3d ) then
  439. has_data_3d(seccount3d)=.true.
  440. else
  441. has_data_2d(seccount2d)=.true.
  442. end if
  443. end if
  444. ! distinguish 2d/3d sectors
  445. if( sectors_def(lsec)%f3d ) then
  446. ! ---------------------------------------
  447. ! 3d data (AIRCRAFT), available for CMIP6
  448. ! ---------------------------------------
  449. if (isRoot) then
  450. ! write some numbers
  451. call msg_emis( amonth, trim(sectors_def(lsec)%prov), sectors_def(lsec)%name, 'CH4', xmch4, &
  452. sum(field3d) )
  453. ! distribute to work arrays in regions
  454. call Coarsen_Emission( 'CH4 '//trim(sectors_def(lsec)%name), nlon360, nlat180, ar5_dim_3ddata, &
  455. field3d, work, add_field, status )
  456. IF_NOTOK_RETURN(status=1)
  457. end if
  458. ! scatter, sum up on target array
  459. do region = 1, nregions
  460. call scatter(dgrid(region), work3d(region)%d3, work(region)%d3, 0, status)
  461. IF_NOTOK_RETURN( status=1 )
  462. CALL GET_DISTGRID( dgrid(region), I_STRT=i1, J_STRT=j1)
  463. ! aircraft data: regrid vertically to model layers
  464. call emission_ar5_regrid_aircraft( region, i1, j1, work3d(region)%d3, emis3d(region)%d3, status )
  465. IF_NOTOK_RETURN( status=1 )
  466. ch4_emis_3d(region,seccount3d)%d3 = ch4_emis_3d(region,seccount3d)%d3 + emis3d(region)%d3
  467. end do
  468. else
  469. ! ---------------------------
  470. ! 2d data (Anthropogenic, Biomassburning, Natural)
  471. ! ---------------------------
  472. if (isRoot) then ! regrid
  473. ! write some numbers
  474. call msg_emis( amonth, trim(sectors_def(lsec)%prov), sectors_def(lsec)%name, 'CH4', xmch4, &
  475. sum(field3d(:,:,1)) )
  476. call coarsen_emission( 'CH4 '//trim(sectors_def(lsec)%prov)//' '//sectors_def(lsec)%name, &
  477. nlon360, nlat180, field3d(:,:,1), wrk2D, add_field, status )
  478. IF_NOTOK_RETURN(status=1)
  479. end if
  480. do region = 1, nregions
  481. call scatter(dgrid(region), ch4_emis_2d(region,seccount2d)%surf, work(region)%d3(:,:,1), 0, status)
  482. IF_NOTOK_RETURN(status=1)
  483. end do
  484. end if
  485. end do sec ! sectors
  486. deallocate( field3d )
  487. do region = 1, nregions
  488. if (associated(wrk2D(region)%surf)) nullify(wrk2D(region)%surf)
  489. deallocate( work(region)%d3 )
  490. deallocate( work3d(region)%d3 )
  491. deallocate( emis3d(region)%d3 )
  492. end do
  493. ! check sectors found
  494. if( seccount2d /= ch4_2dsec ) then
  495. write(gol,'(80("-"))') ; call goPr
  496. write(gol,'("ERROR: 2d sectors do not equal total number:",i4," /= ",i4," !")') seccount2d, ch4_2dsec ; call goErr
  497. write(gol,'(80("-"))') ; call goPr
  498. status=1; return
  499. end if
  500. if( seccount3d /= ch4_3dsec ) then
  501. write(gol,'(80("-"))') ; call goPr
  502. write(gol,'("ERROR: 3d sectors do not equal total number:",i4," /= ",i4," !")') seccount3d, ch4_3dsec ; call goErr
  503. write(gol,'(80("-"))') ; call goPr
  504. status=1; return
  505. end if
  506. end if
  507. #endif
  508. !
  509. ! Read in either the zonal mean surface field for this year/month, or set to fixed value
  510. !
  511. if (isRoot) then
  512. allocate( field3d(1,nlat180,1) )
  513. allocate( field3d_p(1,nlat180,1) )
  514. allocate( field3d_n(1,nlat180,1) )
  515. field3d = 0.0
  516. field3d_p = 0.0
  517. field3d_n = 0.0
  518. if (LCMIP6_CH4) then
  519. write(gol,'("Reading CMIP6 monthly zonal mean CH4 mixing ratios")'); call goPr
  520. ! previous month
  521. target_month = idate(2)-1
  522. target_year = MIN(2500,MAX(emis_input_year_ch4,1850))
  523. if (idate(2) .eq. 1) then
  524. target_month = 12
  525. if (.not.ch4_fixyear) then
  526. target_year = MIN(2500,MAX(idate(1)-1,1850))
  527. endif
  528. endif
  529. write (gol,*) ' Use year ', target_year,' and month ', target_month,' for previous month'; call goPr
  530. call read_cmip6_zch4(field3d_p(1,:,1),target_year,target_month, status)
  531. ! current month
  532. target_month = idate(2)
  533. target_year = MIN(2500,MAX(emis_input_year_ch4,1850))
  534. write (gol,*) ' Use year ', target_year,' and month ', target_month,' for current month'; call goPr
  535. call read_cmip6_zch4(field3d(1,:,1),target_year,target_month, status)
  536. ! next month
  537. target_month = idate(2)+1
  538. target_year = MIN(2500,MAX(emis_input_year_ch4,1850))
  539. if (idate(2) .eq. 12) then
  540. target_month = 1
  541. if (.not.ch4_fixyear) then
  542. target_year = MIN(2500,MAX(emis_input_year_ch4+1,1850))
  543. endif
  544. endif
  545. write (gol,*) ' Use year ', target_year,' and month ', target_month,' for next month'; call goPr
  546. call read_cmip6_zch4(field3d_n(1,:,1),target_year,target_month, status)
  547. !write (gol,'("STOP AFTER TESTING READING OF CMIP6 CH4")') ; call goErr
  548. !status=1; TRACEBACK; return
  549. else if (emis_ch4_single) then ! fixed value
  550. ! TvN: bug fix
  551. ! unit should be in ppbv as in CMIP6 and NOAA/GMD files
  552. !field3d(:,:,:)=emis_ch4_fixed_ppb*1.0e-9
  553. field3d(:,:,:)=emis_ch4_fixed_ppb
  554. else ! read NOAA/GMD monthly surface latitudinal distribution
  555. call read_bkglat_ch4(field3d(1,:,1),idate(1),idate(2), status)
  556. call prev_mon(idate(1),idate(2),nyear,nmon)
  557. call read_bkglat_ch4(field3d_p(1,:,1),nyear,nmon, status)
  558. call next_mon(idate(1),idate(2),nyear,nmon)
  559. call read_bkglat_ch4(field3d_n(1,:,1),nyear,nmon, status)
  560. endif
  561. ! coarsen or distribute to zoom regions:
  562. do region = 1, nregions
  563. call FillGrid( lli_z(region), 'n', wrk_c(region)%d23(:,:), &
  564. lli_z(iglbsfc), 'n', field3d(:,:,1), 'area-aver', status )
  565. IF_NOTOK_RETURN(status=1)
  566. call FillGrid( lli_z(region), 'n', wrk_p(region)%d23(:,:), &
  567. lli_z(iglbsfc), 'n', field3d_p(:,:,1), 'area-aver', status )
  568. IF_NOTOK_RETURN(status=1)
  569. call FillGrid( lli_z(region), 'n', wrk_n(region)%d23(:,:), &
  570. lli_z(iglbsfc), 'n', field3d_n(:,:,1), 'area-aver', status )
  571. IF_NOTOK_RETURN(status=1)
  572. end do
  573. deallocate( field3d, field3d_p, field3d_n )
  574. end if
  575. ! scatter along latitude direction, then broadcast to all longitudes
  576. DO region = 1, nregions
  577. call SCATTER_I_BAND( dgrid(region), zch4(region)%d2, wrk_c(region)%d23(1,:), status )
  578. IF_NOTOK_RETURN(status=1)
  579. call SCATTER_I_BAND( dgrid(region), zch4_p(region)%d2, wrk_p(region)%d23(1,:), status )
  580. IF_NOTOK_RETURN(status=1)
  581. call SCATTER_I_BAND( dgrid(region), zch4_n(region)%d2, wrk_n(region)%d23(1,:), status )
  582. IF_NOTOK_RETURN(status=1)
  583. tmp2d(region)%d2 = zch4(region)%d2
  584. call PAR_BROADCAST( tmp2d(region)%d2, status, row=.true. )
  585. IF_NOTOK_RETURN(status=1)
  586. zch4(region)%d2 = tmp2d(region)%d2
  587. tmp2d(region)%d2 = zch4_p(region)%d2
  588. call PAR_BROADCAST( tmp2d(region)%d2, status, row=.true. )
  589. IF_NOTOK_RETURN(status=1)
  590. zch4_p(region)%d2 = tmp2d(region)%d2
  591. tmp2d(region)%d2 = zch4_n(region)%d2
  592. call PAR_BROADCAST( tmp2d(region)%d2, status, row=.true. )
  593. IF_NOTOK_RETURN(status=1)
  594. zch4_n(region)%d2 = tmp2d(region)%d2
  595. END DO
  596. ! ok
  597. status = 0
  598. END SUBROUTINE EMISSION_CH4_DECLARE
  599. !EOC
  600. !--------------------------------------------------------------------------
  601. ! TM5 !
  602. !--------------------------------------------------------------------------
  603. !BOP
  604. !
  605. ! !IROUTINE: EMISSION_CH4_APPLY
  606. !
  607. ! !DESCRIPTION: Takes monthly emissions, and
  608. ! - split them vertically
  609. ! - apply time splitting factors
  610. ! - add them up (add_3d)
  611. !\\
  612. !\\
  613. ! !INTERFACE:
  614. !
  615. SUBROUTINE EMISSION_CH4_APPLY( region, status)
  616. !
  617. ! !USES:
  618. !
  619. use binas, only : xmair
  620. use dims, only : itaur, nsrce, tref
  621. use dims, only : im, jm, lm, at, bt
  622. use datetime, only : tau2date
  623. use emission_data, only : emission_vdist_by_sector, LAR5BMB
  624. use emission_data, only : do_add_3d, do_add_3d_cycle, bb_cycle
  625. use emission_data, only : emis_bb_trop_cycle
  626. use emission_read, only : sectors_def, numb_sectors
  627. use emission_read, only : ed42_ch4_sectors
  628. use chem_param, only : ich4, xmch4
  629. ! NB use chem_param, only : ch4_ps
  630. use meteodata, only : m_dat
  631. use global_data, only : region_dat, mass_dat
  632. use toolbox, only : lvlpress
  633. use partools, only : par_reduce_element
  634. #ifdef with_budgets
  635. use budget_global, only : budg_dat, nzon_vg
  636. use emission_data, only : sum_emission, budemi_dat
  637. #endif
  638. !
  639. ! !INPUT PARAMETERS:
  640. !
  641. integer, intent(in) :: region
  642. !
  643. ! !OUTPUT PARAMETERS:
  644. !
  645. integer, intent(out) :: status
  646. !
  647. ! !REVISION HISTORY:
  648. ! 1 Oct 2010 - Achim Strunk - adapted to AR5 emissions structures
  649. ! - added nudging if emissions
  650. ! 28 Jun 2012 - Ph. Le Sager - nudging in case of with_ch4_emis no more
  651. ! limited to 3x2 runs
  652. ! - optimized loop order for case of NO emissions
  653. ! - adapted for lon-lat MPI domain decomposition
  654. !
  655. ! !REMARKS:
  656. !
  657. !EOP
  658. !---------------------------------------------------------------------------
  659. !BOC
  660. character(len=*), parameter :: rname = mname//'/Emission_CH4_apply'
  661. integer, dimension(6) :: idater
  662. real :: dtime, fraction
  663. integer :: imr, jmr, lmr, lsec
  664. integer :: seccount2d, seccount3d
  665. type(d3_data) :: emis3d
  666. type(emis_data) :: emis2d
  667. integer :: i1, j1, i2, j2
  668. real, dimension(:,:,:), allocatable :: field3d
  669. real, dimension(:,:,:,:), pointer :: rm
  670. real, dimension(:,:,:), pointer :: m
  671. real :: ch4ppb, toadd
  672. integer :: nzone_v
  673. real :: zvmr_obs, f_ratio, vmr_min
  674. integer :: i, j, l, lm_ch4, idateline
  675. real, allocatable :: vmr_mod(:,:), zvmrsum_local(:)
  676. real, allocatable :: zvmr_mod(:)
  677. real, parameter :: gnud_ch4 = 4.0e-6 ! ~3day time scale, see below
  678. ! --- begin ---------------------------
  679. call get_distgrid( dgrid(region), i_strt=i1, j_strt=j1, i_stop=i2, j_stop=j2)
  680. nullify(rm)
  681. nullify(m)
  682. rm => mass_dat(region)%rm
  683. m => m_dat(region)%data
  684. allocate(zvmr_mod(j1:j2))
  685. !---------------------------------------------------------------
  686. ! CH4 emissions
  687. !--------------------------------------------------------------
  688. #ifdef with_ch4_emis
  689. if (has_ch4_emis) then
  690. call tau2date(itaur(region),idater)
  691. dtime=float(nsrce)/(2*tref(region)) !emissions are added in two steps...XYZECCEZYX.
  692. if(okdebug) then
  693. write(gol,*)'emission_ch4_apply in region ',region,' at date: ',idater, ' with time step:', dtime
  694. call goPr
  695. end if
  696. ! get a working structure
  697. lmr = lm(region)
  698. allocate( emis3d%d3 (i1:i2, j1:j2, lmr) ) ; emis3d%d3 = 0.0
  699. allocate( emis2d%surf(i1:i2, j1:j2 ) ) ; emis2d%surf = 0.0
  700. ! count 2d and 3d sectors
  701. seccount2d = 0
  702. seccount3d = 0
  703. ! cycle over sectors
  704. do lsec = 1, numb_sectors
  705. if (count(used_providers_ch4.eq.sectors_def(lsec)%prov).eq.0) cycle
  706. if ((trim(sectors_def(lsec)%prov).eq.'ED42') .and. (count(ed42_ch4_sectors.eq.sectors_def(lsec)%name) .eq. 0)) cycle
  707. if (associated(sectors_def(lsec)%species)) then ! AR5 checks
  708. if (count('CH4'.eq.sectors_def(lsec)%species).eq.0) cycle
  709. if ((trim(sectors_def(lsec)%catname) .eq. 'biomassburning').and.(.not.LAR5BMB)) cycle
  710. endif
  711. ! Historical emissions of CH4 from aircraft are zero everywhere
  712. ! and it is assumed that this will also be the case for the future scenarios
  713. if ((trim(sectors_def(lsec)%prov).eq.'CMIP6') .and. (trim(sectors_def(lsec)%catname) .eq. 'aircraft')) cycle
  714. ! default: no additional splitting
  715. fraction = 1.0
  716. ! ----------------------------------------------------------------------------------------
  717. ! distinguish here between sectors and whether they should have additional splitting
  718. ! if( sectors_def(lsec)%catname == 'biomassburning' ) fraction = fraction * bb_frac etc...
  719. ! ----------------------------------------------------------------------------------------
  720. ! distinguish between 2d/3d sectors
  721. if( sectors_def(lsec)%f3d ) then
  722. seccount3d = seccount3d + 1
  723. if (.not.has_data_3d(seccount3d)) cycle
  724. emis3d%d3 = ch4_emis_3d(region,seccount3d)%d3
  725. else
  726. seccount2d = seccount2d + 1
  727. if (.not.has_data_2d(seccount2d)) cycle
  728. emis2d%surf = ch4_emis_2d(region,seccount2d)%surf
  729. ! account for soil sink scale with respect to surface [CH4] over i,j
  730. if (trim(sectors_def(lsec)%name).eq.'soilconsumption') then
  731. do j=j1,j2
  732. do i=i1,i2
  733. if(emis2d%surf(i,j)>0.) &
  734. emis2d%surf(i,j) = ( - emis2d%surf(i,j)) * (rm(i,j,1,ich4)/m(i,j,1)/1.0e-6) * (xmair/xmch4)
  735. enddo
  736. enddo
  737. end if
  738. emis3d%d3 = 0.0
  739. ! vertically distribute according to sector
  740. call emission_vdist_by_sector( sectors_def(lsec)%vdisttype, 'CH4', region, emis2d, emis3d, status )
  741. IF_NOTOK_RETURN(status=1;deallocate(emis3d%d3))
  742. end if
  743. ! add dataset according to sector and category
  744. if( emis_bb_trop_cycle .and. trim(sectors_def(lsec)%catname) == "biomassburning" ) then
  745. call do_add_3d_cycle( region, ich4, i1, j1, emis3d%d3, bb_cycle(region)%scalef, xmch4, xmch4, status,fraction )
  746. IF_NOTOK_RETURN(status=1)
  747. else
  748. call do_add_3d( region, ich4, i1, j1, emis3d%d3, xmch4, xmch4, status, fraction )
  749. IF_NOTOK_RETURN(status=1)
  750. end if
  751. end do
  752. deallocate( emis3d%d3 )
  753. deallocate( emis2d%surf )
  754. end if
  755. #endif /* with_ch4_emis */
  756. !-----------------------------------------------------
  757. ! Fix methane mixing ratio
  758. !-----------------------------------------------------
  759. ! Set highest level for nudging
  760. !------------------------------
  761. #ifdef with_ch4_emis
  762. !apply nuddging up to 550 hpa
  763. lm_ch4 = lvlpress(region,55000.,98400.)
  764. #else
  765. ! default: nudging in the lowest layer
  766. lm_ch4 = 1
  767. if ( emis_ch4_single .and. emis_ch4_fix3d ) then
  768. lm_ch4 = lm(region)
  769. else
  770. ! TvN: in case of a shallow first layer (incl. L60, L91), nudge the lowest 2 layers
  771. if (at(2)+bt(2)*101325. > 101000.) lm_ch4 = 2
  772. endif
  773. #endif
  774. ! In simulations without CH4 emissions,
  775. ! the CH4 mixing ratios are prescribed (not nudged).
  776. !---------------------------------------------------
  777. #ifndef with_ch4_emis
  778. do l = 1, lm_ch4
  779. do j = j1, j2
  780. do i = i1, i2
  781. ! budget for fixing:
  782. ch4ppb = 1e9 * (xmair/xmch4) * rm(i,j,l,ich4) / m(i,j,l)
  783. ! unit of zch4 is in ppb:
  784. toadd = (zch4(region)%d2(j) - ch4ppb) * 1e-9 * m(i,j,l) * 1e3 / xmair ! moles ch4
  785. rm(i,j,l,ich4) = m(i,j,l)/xmair * zch4(region)%d2(j) *1e-9 * xmch4
  786. #ifdef with_budgets
  787. nzone_v=nzon_vg(l)
  788. budemi_dat(region)%emi(i,j,nzone_v,ich4) = budemi_dat(region)%emi(i,j,nzone_v,ich4) + toadd
  789. if(ich4 ==1) sum_emission(region) = sum_emission(region) + toadd*xmch4/1e3 !in kg
  790. #endif
  791. end do
  792. end do
  793. end do
  794. #endif
  795. ! If CH4 emissions are used
  796. ! the CH4 mixing ratios are nudged,
  797. ! to either zonal means from CMIP6 or
  798. ! zonal background values from NOAA/GMD.
  799. !---------------------------------------
  800. #ifdef with_ch4_emis
  801. if (LCMIP6_CH4) then
  802. ! Nudging for CMIP6 based on zonal means
  803. ! adapted from code for nudging to HALOE
  804. allocate(vmr_mod(i1:i2,j1:j2))
  805. allocate(zvmrsum_local(j1:j2))
  806. ! convert CH4 mass to volume mixing ratios (mol/mol)
  807. vmr_mod = (rm(i1:i2,j1:j2,1,ich4)/m(i1:i2,j1:j2,1))*(xmair/xmch4)
  808. zvmrsum_local=sum(vmr_mod,dim=1) ! zonal total for this subdomain
  809. CALL PAR_REDUCE_ELEMENT(zvmrsum_local, 'SUM', zvmr_mod, status, all=.true., row=.true.)
  810. IF_NOTOK_RETURN(status=1)
  811. ! zonal average
  812. zvmr_mod(:)=zvmr_mod(:)/im(1)
  813. deallocate(vmr_mod)
  814. deallocate(zvmrsum_local)
  815. else
  816. ! Nudging to zonal background values from NOAA/GMD
  817. ! nudging full 3D field using surface observations in background atmosphere
  818. ! the observations represent the minimum of rm in the zonal band
  819. ! the unit of zch4 in the netcdf files is in ppb
  820. ! zonal_mod is the zonal minimum volume mixing ratio (mol/mol) in the model
  821. ! use arbitary large initial value
  822. zvmr_mod(:)=3.0e-6
  823. !
  824. ! Use value at the dateline away from major CH4 sources
  825. !
  826. idateline = 1
  827. ! if current processor include dateline
  828. if (i1==1) then
  829. do j=j1,j2
  830. vmr_min = (rm(idateline,j,1,ich4)/m(idateline,j,1))*(xmair/xmch4)
  831. zvmr_mod(j) = min(zvmr_mod(j),vmr_min) ! mimimum CH4 at latitude j
  832. end do
  833. endif
  834. ! broadcast (from proc with i1==1, ie from root of row_communicator, ie 0, ie default broadcaster)
  835. call par_broadcast(zvmr_mod, status, row=.true.)
  836. IF_NOTOK_RETURN(status=1)
  837. endif ! LCMIP6_CH4
  838. ! nudging like in the stratosphere for ozone would be:
  839. ! rm = (rmold+dtime*gnud*zvmr_obs)/(1.+dtime*gnud)
  840. ! nudging used here is done without the approximation:
  841. ! 1 - exp(-dtime*gnud) = dtime*gnud
  842. ! we determine per zonal band the ratio between
  843. ! the CMIP6 mean/observations
  844. ! and the zonal mean/minimum surface model field:
  845. ! f_ratio = zvmr_obs / zvmr_mod
  846. ! we apply the surface ratio to the total 3d field
  847. ! with a slow nudging time scale to distribute the
  848. ! corrections at this latitude band over all heights
  849. ! we use gnud_ch4 = 4.e-7 (1/sec; for ~1 month nudging time scale )
  850. ! The nudging equation is:
  851. ! vmr = vmrold * exp(-dtime*gnud) + zvmr_obs * (1 - exp(-dtime*gnud)) or:
  852. ! vmr = vmrold - (1 - exp(-dtime*gnud))(vmrold - vmrobs) or:
  853. ! vmr = vmrold + vmrold*(f_ratio-1)*(1 - exp(-dtime*gnud))
  854. ! toadd = vmrold*(f_ratio-1)*(1 - exp(-dtime*gnud))
  855. dtime=nsrce/(2*tref(region))
  856. do j = j1, j2
  857. ! interpolate in time and convert to volume mixing ratio (mol/mol)
  858. call interp_zch4(region,j,idater,itaur(region),zvmr_obs)
  859. ! trap bad cases (0. as initial conditions,...)
  860. if (zvmr_mod(j)==0.) then
  861. f_ratio=1.
  862. else
  863. f_ratio = zvmr_obs/zvmr_mod(j) ! f_ratio should be always very close to 1
  864. ! (forcing f_ratio to 1 removes the nudging)
  865. end if
  866. ! expected behavior is nudging within 10%
  867. !PLS: commented since it appears too often and fills log file
  868. !if (f_ratio>1.1 .or. f_ratio<0.9) then
  869. !write(gol,*)"WARNING: CH4 nudging larger than 10% for region/ijl",region,i,j,l; call goPr
  870. !end if
  871. do l = 1, lm_ch4
  872. do i = i1, i2
  873. toadd = rm(i,j,l,ich4) * (f_ratio - 1.) * (1. - exp(- dtime*gnud_ch4)) *1e3 / xmair ! moles ch4
  874. rm(i,j,l,ich4) = rm(i,j,l,ich4) + toadd * xmch4/1e3
  875. #ifdef with_budgets
  876. nzone_v=nzon_vg(l)
  877. ! add the nudging adjustments to the emission budget (now full 3D field filled)
  878. ! the emissions are not added here
  879. budemi_dat(region)%emi(i,j,nzone_v,ich4) = budemi_dat(region)%emi(i,j,nzone_v,ich4) + toadd
  880. #endif
  881. end do
  882. end do
  883. end do
  884. #endif
  885. !-----------------------------------------------------
  886. ! Done
  887. !-----------------------------------------------------
  888. nullify(rm)
  889. nullify(m)
  890. deallocate(zvmr_mod)
  891. status = 0
  892. END SUBROUTINE EMISSION_CH4_APPLY
  893. !EOC
  894. !--------------------------------------------------------------------------
  895. ! TM5 !
  896. !--------------------------------------------------------------------------
  897. !BOP
  898. !
  899. ! !IROUTINE: READ_BKGLAT_CH4
  900. !
  901. ! !DESCRIPTION: Read ERA Interim background surface zonal CH4 for specified
  902. ! year/month
  903. !\\
  904. !\\
  905. ! !INTERFACE:
  906. !
  907. SUBROUTINE READ_BKGLAT_CH4(field, year, month, status)
  908. !
  909. ! !USES:
  910. !
  911. USE MDF, ONLY : MDF_OPEN, MDF_NETCDF, MDF_READ, MDF_Get_Var, MDF_Close, MDF_Inq_VarID
  912. use emission_data, only : emis_zch4_fname
  913. use dims, only : nlat180
  914. !
  915. ! !OUTPUT PARAMETERS:
  916. !
  917. integer, intent(out) :: status
  918. real, dimension(nlat180), intent(out) :: field
  919. !
  920. ! !INPUT PARAMETERS:
  921. !
  922. integer, intent(in) :: year, month
  923. !
  924. ! !REMARKS:
  925. !
  926. !EOP
  927. !------------------------------------------------------------------------
  928. !BOC
  929. character(len=*), parameter :: rname = mname//'/Read_BkgLat_CH4'
  930. character(len=256) :: filemon, emis_zch4_fullname
  931. integer :: fid, varid, year_valid
  932. integer, dimension(2), parameter :: era_interim_avail = (/1989, 2014/)
  933. ! valid year
  934. year_valid = MIN(era_interim_avail(2),MAX(year, era_interim_avail(1)))
  935. ! target file name with year e.g. surface_ch4_zm_1989.nc
  936. write (emis_zch4_fullname,'(a,"/surface_ch4_zm_",i4.4,".nc")') trim(emis_zch4_fname), year_valid
  937. CALL MDF_Open( TRIM(emis_zch4_fullname), MDF_NETCDF, MDF_READ, fid, status )
  938. IF_NOTOK_RETURN(status=1)
  939. ! search for the record for requested month:
  940. if (month < 10) then
  941. write(filemon,'(a,i1)')'CH4_zm', month
  942. else
  943. write(filemon,'(a,i2)')'CH4_zm', month
  944. endif
  945. CALL MDF_Inq_VarID( fid, TRIM(filemon), varid, status )
  946. IF_ERROR_RETURN(status=1)
  947. if ( varid < 0 ) then
  948. write (gol,'("WARNING - no surface CH4 concentrations `",a,"`")') trim(emis_zch4_fullname) ; call goPr
  949. status=1; TRACEBACK; return
  950. else
  951. CALL MDF_Get_Var( fid, varid, field, status )
  952. IF_NOTOK_RETURN(status=1)
  953. endif
  954. CALL MDF_Close( fid, status )
  955. IF_NOTOK_RETURN(status=1)
  956. status = 0
  957. END SUBROUTINE READ_BKGLAT_CH4
  958. !EOC
  959. !--------------------------------------------------------------------------
  960. ! TM5 !
  961. !--------------------------------------------------------------------------
  962. !BOP
  963. !
  964. ! !IROUTINE: INTERP_ZCH4
  965. !
  966. ! !DESCRIPTION:
  967. ! Interpolates in time the latitudinal monthly background CH4
  968. ! concentration. The data are considered representative of the
  969. ! 16th of each month, except February when it is 15th.
  970. !\\
  971. !\\
  972. ! !INTERFACE:
  973. !
  974. SUBROUTINE INTERP_ZCH4(region,j,idater,itau, zch4_obs)
  975. !
  976. ! !USES:
  977. !
  978. use datetime, only : date2tau
  979. !
  980. ! !INPUT PARAMETERS:
  981. !
  982. integer, intent(in) :: region,j
  983. integer, dimension(6), intent(in) :: idater
  984. integer(kind=8), intent(in) :: itau
  985. !
  986. ! !OUTPUT PARAMETERS:
  987. !
  988. real, intent(out) :: zch4_obs
  989. !
  990. ! !REMARKS:
  991. !
  992. !EOP
  993. !------------------------------------------------------------------------
  994. !BOC
  995. integer, dimension(6) :: idate_c, idate_p, idate_n
  996. integer :: nmon, nyear
  997. integer(kind=8) :: itau_c, itau_p, itau_n
  998. idate_c(1) = idater(1)
  999. idate_c(2) = idater(2)
  1000. if (idater(2) == 2) then
  1001. idate_c(3) = 15
  1002. else
  1003. idate_c(3) = 16
  1004. endif
  1005. idate_c(4:6) = 0
  1006. call date2tau(idate_c,itau_c)
  1007. call prev_mon(idater(1),idater(2),nyear,nmon)
  1008. idate_p(1) = nyear
  1009. idate_p(2) = nmon
  1010. if (idate_p(2) == 2) then
  1011. idate_p(3) = 15
  1012. else
  1013. idate_p(3) = 16
  1014. endif
  1015. idate_p(4:6) = 0
  1016. call date2tau(idate_p,itau_p)
  1017. call next_mon(idater(1),idater(2),nyear,nmon)
  1018. idate_n(1) = nyear
  1019. idate_n(2) = nmon
  1020. if (idate_n(2) == 2) then
  1021. idate_n(3) = 15
  1022. else
  1023. idate_n(3) = 16
  1024. endif
  1025. idate_n(4:6) = 0
  1026. call date2tau(idate_n,itau_n)
  1027. if (itau.lt.itau_c) then
  1028. zch4_obs = zch4_p(region)%d2(j) * float(itau_c-itau)/float(itau_c-itau_p) + zch4(region)%d2(j) * float(itau-itau_p)/float(itau_c-itau_p)
  1029. else
  1030. zch4_obs = zch4(region)%d2(j) * float(itau_n-itau)/float(itau_n-itau_c) + zch4_n(region)%d2(j) * float(itau-itau_c)/float(itau_n-itau_c)
  1031. endif
  1032. zch4_obs = zch4_obs *1.e-9
  1033. END SUBROUTINE INTERP_ZCH4
  1034. !EOC
  1035. !--------------------------------------------------------------------------
  1036. ! TM5 !
  1037. !--------------------------------------------------------------------------
  1038. !BOP
  1039. !
  1040. ! !IROUTINE: NEXT_MON
  1041. !
  1042. ! !DESCRIPTION: Return month number and year of next month
  1043. !\\
  1044. !\\
  1045. ! !INTERFACE:
  1046. !
  1047. SUBROUTINE NEXT_MON(year,mon,nyear,nmon)
  1048. !
  1049. ! !INPUT PARAMETERS:
  1050. !
  1051. integer, intent(in) :: year, mon
  1052. !
  1053. ! !OUTPUT PARAMETERS:
  1054. !
  1055. integer, intent(out) :: nyear, nmon
  1056. !
  1057. !EOP
  1058. !------------------------------------------------------------------------
  1059. !BOC
  1060. if (mon.lt.12) then
  1061. nyear = year
  1062. nmon = mon+1
  1063. else
  1064. nyear = year+1
  1065. nmon = 1
  1066. endif
  1067. END SUBROUTINE NEXT_MON
  1068. !EOC
  1069. !--------------------------------------------------------------------------
  1070. ! TM5 !
  1071. !--------------------------------------------------------------------------
  1072. !BOP
  1073. !
  1074. ! !IROUTINE: PREV_MON
  1075. !
  1076. ! !DESCRIPTION: Return month number and year of previous month
  1077. !\\
  1078. !\\
  1079. ! !INTERFACE:
  1080. !
  1081. SUBROUTINE PREV_MON(year,mon,nyear,nmon)
  1082. !
  1083. ! !INPUT PARAMETERS:
  1084. !
  1085. integer, intent(in) :: year, mon
  1086. !
  1087. ! !OUTPUT PARAMETERS:
  1088. !
  1089. integer, intent(out) :: nyear, nmon
  1090. !
  1091. !EOP
  1092. !------------------------------------------------------------------------
  1093. !BOC
  1094. if (mon.gt.1) then
  1095. nyear = year
  1096. nmon = mon-1
  1097. else
  1098. nyear = year-1
  1099. nmon = 12
  1100. endif
  1101. END SUBROUTINE PREV_MON
  1102. !EOC
  1103. END MODULE EMISSION_CH4