emission_ch4.F90 40 KB

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