emission_rn222.F90 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356
  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_RN222
  14. !
  15. ! !DESCRIPTION: Perform RN222 emissions needed for TM5 CBM4 version.
  16. !\\
  17. !\\
  18. ! !INTERFACE:
  19. !
  20. MODULE EMISSION_RN222
  21. !
  22. ! !USES:
  23. !
  24. use GO, only : gol, goErr, goPr
  25. use tm5_distgrid, only : dgrid, get_distgrid, scatter
  26. use partools, only : isRoot
  27. use global_types, only : emis_data, d3_data
  28. use Dims, only : nregions
  29. IMPLICIT NONE
  30. PRIVATE
  31. !
  32. ! !PUBLIC MEMBER FUNCTIONS:
  33. !
  34. public :: emission_rn222_init ! allocate
  35. public :: emission_rn222_declare ! read monthly input
  36. public :: emission_rn222_apply ! distribute & add emissions to tracer array
  37. public :: emission_rn222_done ! deallocate
  38. !
  39. ! !PRIVATE DATA MEMBERS:
  40. !
  41. character(len=*), parameter :: mname = 'emission_rn222'
  42. type(emis_data), dimension(nregions), target :: emis_rn222
  43. type(emis_data), dimension(nregions), target :: emis_rn222_sec
  44. !
  45. ! !REVISION HISTORY:
  46. ! 1 Oct 2010 - Achim Strunk - standardized routines name, new apply method
  47. ! 28 Mar 2012 - Ph. Le Sager - adapted for lon-lat MPI domain decomposition
  48. !
  49. !EOP
  50. !------------------------------------------------------------------------
  51. CONTAINS
  52. !--------------------------------------------------------------------------
  53. ! TM5 !
  54. !--------------------------------------------------------------------------
  55. !BOP
  56. !
  57. ! !IROUTINE: EMISSION_RN222_INIT
  58. !
  59. ! !DESCRIPTION: Allocate space needed to handle the emissions
  60. !\\
  61. !\\
  62. ! !INTERFACE:
  63. !
  64. SUBROUTINE EMISSION_RN222_INIT( status )
  65. !
  66. ! !OUTPUT PARAMETERS:
  67. !
  68. integer, intent(out) :: status
  69. !
  70. ! !REVISION HISTORY:
  71. ! 1 Oct 2010 - Achim Strunk - extracted from old 'declare' routine
  72. ! 22 Jun 2012 - Ph. Le Sager - adapted for lon-lat MPI domain decomposition
  73. !
  74. !EOP
  75. !------------------------------------------------------------------------
  76. !BOC
  77. character(len=*), parameter :: rname = mname//'/Emission_RN222_Init'
  78. integer :: region
  79. integer :: i1, i2, j1, j2
  80. ! --- begin --------------------------------------
  81. do region = 1, nregions
  82. CALL GET_DISTGRID( dgrid(region), I_STRT=i1, I_STOP=i2, J_STRT=j1, J_STOP=j2 )
  83. allocate(emis_rn222 (region)%surf(i1:i2,j1:j2) )
  84. allocate(emis_rn222_sec(region)%surf(i1:i2,j1:j2) )
  85. enddo
  86. status = 0
  87. END SUBROUTINE EMISSION_RN222_INIT
  88. !EOC
  89. !--------------------------------------------------------------------------
  90. ! TM5 !
  91. !--------------------------------------------------------------------------
  92. !BOP
  93. !
  94. ! !IROUTINE: EMISSION_RN222_DONE
  95. !
  96. ! !DESCRIPTION: Free space after handling of the emissions
  97. !\\
  98. !\\
  99. ! !INTERFACE:
  100. !
  101. SUBROUTINE EMISSION_RN222_DONE( status )
  102. !
  103. ! !OUTPUT PARAMETERS:
  104. !
  105. integer, intent(out) :: status
  106. !
  107. ! !REVISION HISTORY:
  108. ! 1 Oct 2010 - Achim Strunk - rename old 'free_emission_rn222'
  109. !
  110. !EOP
  111. !------------------------------------------------------------------------
  112. !BOC
  113. character(len=*), parameter :: rname = mname//'/Emission_rn222_Done'
  114. integer :: region
  115. ! --- begin ---------------------------------
  116. do region = 1, nregions
  117. deallocate(emis_rn222 (region)%surf)
  118. deallocate(emis_rn222_sec(region)%surf)
  119. end do
  120. status = 0
  121. END SUBROUTINE EMISSION_RN222_DONE
  122. !EOC
  123. !--------------------------------------------------------------------------
  124. ! TM5 !
  125. !--------------------------------------------------------------------------
  126. !BOP
  127. !
  128. ! !IROUTINE: EMISSION_RN222_DECLARE
  129. !
  130. ! !DESCRIPTION: Opens, reads and evaluates input files (per month).
  131. ! Provides emissions on 2d/3d-arrays which are then added
  132. ! to tracers in routine *apply.
  133. !\\
  134. !\\
  135. ! !INTERFACE:
  136. !
  137. SUBROUTINE EMISSION_RN222_DECLARE( status )
  138. !
  139. ! !USES:
  140. !
  141. use dims, only : im, jm, sec_month, sec_year, newsrun, iglbsfc, nlat180, nlon360
  142. USE MDF, ONLY : MDF_Open, MDF_HDF4, MDF_READ, MDF_Inq_VarID, MDF_Get_Var, MDF_Close
  143. use toolbox, only : coarsen_emission
  144. use chem_param, only : irn222, xmrn222
  145. use emission_data, only : emis_input_dir_rn222, msg_emis
  146. !
  147. ! !OUTPUT PARAMETERS:
  148. !
  149. integer, intent(out) :: status
  150. !
  151. ! !REVISION HISTORY:
  152. ! 1 Oct 2010 - Achim Strunk - update for new emission standard; rid of GAIA default
  153. ! 28 Mar 2012 - P. Le Sager - adapted for lon-lat MPI domain decomposition
  154. ! - read only once
  155. ! - use MDF
  156. !
  157. !EOP
  158. !------------------------------------------------------------------------
  159. !BOC
  160. character(len=*), parameter :: rname = mname//'/emission_rn222_declare'
  161. real, dimension(:,:), allocatable :: RN222_temp ! global emiss for reading
  162. type(emis_data), dimension(nregions) :: emis_rn222_glb ! global emiss for coarsening
  163. integer :: region, nlatsrc, nlonsrc
  164. integer, parameter :: add_field = 0
  165. integer, parameter :: amonth=1
  166. character(len=256) :: fname, vname
  167. integer :: varid, hid
  168. ! --- begin -----------------------------------------
  169. ! constant emission : read & regrid once only
  170. if(newsrun) then
  171. write(gol,'(" EMISS-INFO ------------- read Rn222 emissions -------------")'); call goPr
  172. nlatsrc = nlat180 ! or dgrid(iglbsfc)%jm_region, accessible thru get_distgrid(...)
  173. nlonsrc = nlon360 ! or dgrid(iglbsfc)%im_region, accessible thru get_distgrid(...)
  174. ! global array for reading
  175. if(isRoot)then
  176. allocate(RN222_temp(nlonsrc,nlatsrc))
  177. else
  178. allocate(RN222_temp(1,1))
  179. end if
  180. ! global arrays for coarsening
  181. do region = 1, nregions
  182. if (isRoot)then
  183. allocate(emis_rn222_glb(region)%surf(im(region),jm(region)))
  184. else
  185. allocate(emis_rn222_glb(region)%surf(1,1))
  186. end if
  187. enddo
  188. if (isRoot) then ! read data. Units= kg/s/ 1x1grid
  189. fname=trim(emis_input_dir_rn222)//'/RN222_WMO2004.hdf'
  190. vname='Rn222_emis'
  191. CALL MDF_Open( TRIM(fname), MDF_HDF4, MDF_READ, hid, status )
  192. IF_NOTOK_RETURN(status=1)
  193. CALL MDF_Inq_VarID( hid, TRIM(vname), varid, status )
  194. IF_NOTOK_RETURN(status=1)
  195. CALL MDF_Get_Var( hid, varid, RN222_temp, status )
  196. IF_NOTOK_RETURN(status=1)
  197. CALL MDF_Close( hid, status )
  198. IF_NOTOK_RETURN(status=1)
  199. ! info for full year
  200. call msg_emis( amonth, 'WMO','(2004)', 'Rn222', xmrn222, sum(RN222_temp*sec_year) )
  201. call coarsen_emission('Rn222_emis', nlonsrc, nlatsrc, RN222_temp, emis_rn222_glb, add_field, status)
  202. IF_NOTOK_RETURN(status=1)
  203. deallocate(RN222_temp)
  204. endif
  205. do region = 1, nregions
  206. call scatter(dgrid(region), emis_rn222_sec(region)%surf, emis_rn222_glb(region)%surf, 0, status)
  207. IF_NOTOK_RETURN(status=1)
  208. deallocate(emis_rn222_glb(region)%surf)
  209. end do
  210. end if
  211. do region = 1, nregions
  212. emis_rn222(region)%surf = emis_rn222_sec(region)%surf *sec_month ! convert to [kg/month/box]
  213. end do
  214. ! ok
  215. status = 0
  216. END SUBROUTINE EMISSION_RN222_DECLARE
  217. !EOC
  218. !--------------------------------------------------------------------------
  219. ! TM5 !
  220. !--------------------------------------------------------------------------
  221. !BOP
  222. !
  223. ! !IROUTINE: EMISSION_RN222_APPLY
  224. !
  225. ! !DESCRIPTION: Take monthly emissions, and
  226. ! - split them vertically
  227. ! - apply time splitting factors
  228. ! - add them up (add_3d)
  229. !\\
  230. !\\
  231. ! !INTERFACE:
  232. !
  233. SUBROUTINE EMISSION_RN222_APPLY( region, status )
  234. !
  235. ! !USES:
  236. !
  237. use dims, only : okdebug, itaur, nsrce, tref, lm
  238. use datetime, only : tau2date
  239. use emission_data, only : emission_vdist_by_sector
  240. use emission_data, only : do_add_3d
  241. use chem_param, only : irn222, xmrn222
  242. use emission_data, only : vd_class_name_len
  243. !
  244. ! !INPUT PARAMETERS:
  245. !
  246. integer, intent(in) :: region
  247. !
  248. ! !OUTPUT PARAMETERS:
  249. !
  250. integer, intent(out) :: status
  251. !
  252. ! !REVISION HISTORY:
  253. ! 1 Oct 2010 - Achim Strunk - updated to new emission methods
  254. ! 28 Mar 2012 - Ph. Le Sager - adapted for lon-lat MPI domain decomposition
  255. !
  256. !EOP
  257. !------------------------------------------------------------------------
  258. !BOC
  259. character(len=*), parameter :: rname = mname//'/emission_rn222_apply'
  260. integer, dimension(6) :: idater
  261. real :: dtime, fraction
  262. integer :: imr, jmr, lmr, i1, i2, j1, j2
  263. type(d3_data) :: emis3d
  264. character(len=vd_class_name_len) :: splittype
  265. ! --- begin -----------------------------------------
  266. if( okdebug ) then
  267. write(gol,*) 'start of emission_rn222_apply'; call goPr
  268. endif
  269. call tau2date(itaur(region),idater)
  270. dtime=float(nsrce)/(2*tref(region)) ! emissions are added in two steps...XYZECCEZYX.
  271. if( okdebug ) then
  272. write(gol,*) 'emission_rn222_apply in region ',region,' at date: ',idater, ' with time step:', dtime ; call goPr
  273. endif
  274. ! get a working structure for 3d emissions
  275. call get_distgrid( dgrid(region), I_STRT=i1, I_STOP=i2, J_STRT=j1, J_STOP=j2 )
  276. allocate( emis3d%d3(i1:i2,j1:j2,lm(region)) ) ; emis3d%d3 = 0.0
  277. ! default: no additional splitting
  278. fraction = 1.0
  279. ! ----------------------------------------------------------------------------------------
  280. ! distinguish here between sectors and whether they should have additional splitting
  281. ! if( ar5_sectors(lsec)%catname == 'biomassburning' ) fraction = fraction * bb_frac etc...
  282. ! ----------------------------------------------------------------------------------------
  283. splittype = 'surface'
  284. ! vertically distribute according to sector
  285. call emission_vdist_by_sector( splittype, 'RN', region, emis_rn222(region), emis3d, status )
  286. IF_NOTOK_RETURN(status=1;deallocate(emis3d%d3))
  287. ! add dataset
  288. call do_add_3d( region, irn222, i1, j1, emis3d%d3, xmrn222, xmrn222, status, fraction )
  289. IF_NOTOK_RETURN(status=1)
  290. if(okdebug) then
  291. write(gol,*) 'end of emission_apply_rn222'; call goPr
  292. endif
  293. deallocate( emis3d%d3 )
  294. status=0
  295. END SUBROUTINE EMISSION_RN222_APPLY
  296. !EOC
  297. END MODULE EMISSION_RN222