sources_sinks__co2.F90 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387
  1. #define TRACEBACK write (gol,'("in ",a," (",a,i6,")")') rname, __FILE__, __LINE__ ; call goErr
  2. #define IF_NOTOK_RETURN(action) if (status/=0) then; TRACEBACK; action; return; end if
  3. #define IF_ERROR_RETURN(action) if (status> 0) then; TRACEBACK; action; return; end if
  4. !
  5. #include "tm5.inc"
  6. !
  7. !------------------------------------------------------------------------------
  8. ! TM5 !
  9. !------------------------------------------------------------------------------
  10. !BOP
  11. !
  12. ! !MODULE: SOURCES_SINKS
  13. !
  14. ! !DESCRIPTION: Perform all calculations needed for CO2 transport simulation
  15. ! in TM5: this is mainly emissions, process updates after
  16. ! changes in meteo,...
  17. !
  18. !FD: all emission are converted to kg X (fmw) /month exceptions are mentioned in the code
  19. !
  20. !\\
  21. !\\
  22. ! !INTERFACE:
  23. !
  24. MODULE SOURCES_SINKS
  25. !
  26. ! !USES:
  27. !
  28. use GO, only : gol, goErr, goPr, goBug, goLabel
  29. implicit none
  30. private
  31. !
  32. ! !PUBLIC MEMBER FUNCTIONS:
  33. !
  34. PUBLIC :: SOURCES_SINKS_INIT, SOURCES_SINKS_DONE ! Init and Done methods
  35. PUBLIC :: SS_MONTHLY_UPDATE ! monthly initialization (photolysis,..)
  36. PUBLIC :: SS_AFTER_READ_METEO_UPDATE ! Update SS after met fields are updated. Called from modelIntegration/Proces_update
  37. PUBLIC :: SOURCES_SINKS_APPLY ! apply SS
  38. !
  39. ! !PRIVATE DATA MEMBERS:
  40. !
  41. character(len=*), parameter :: mname = 'sources_sinks'
  42. !
  43. ! !REVISION HISTORY:
  44. ! 19 Mar 2012 - P. Le Sager - adapted for lon-lat MPI domain decomposition
  45. ! 14 May 2014 - T. van Noije- made stripped version for CO2 version
  46. !
  47. ! !REMARKS:
  48. !
  49. !EOP
  50. !------------------------------------------------------------------------------
  51. contains
  52. !------------------------------------------------------------------------------
  53. ! TM5 !
  54. !------------------------------------------------------------------------------
  55. !BOP
  56. !
  57. ! !IROUTINE: SOURCES_SINKS_INIT
  58. !
  59. ! !DESCRIPTION: switch ON required meteo; init emissions
  60. !\\
  61. !\\
  62. ! !INTERFACE:
  63. !
  64. SUBROUTINE SOURCES_SINKS_INIT( status )
  65. !
  66. ! !USES:
  67. !
  68. ! use meteo, only : Set
  69. ! use meteodata, only : temper_dat, humid_dat, oro_dat, gph_dat
  70. ! use Meteodata, only : cp_dat, lsp_dat
  71. ! use Meteodata, only : cvl_dat, cvh_dat, tv_dat
  72. ! use Meteodata, only : ci_dat, sd_dat, swvl1_dat
  73. ! use Meteodata, only : t2m_dat, d2m_dat
  74. ! use Meteodata, only : u10m_dat, v10m_dat, lsmask_dat,ci_dat
  75. ! use Meteodata, only : ssr_dat, sshf_dat, slhf_dat, ewss_dat, nsss_dat
  76. ! use Meteodata, only : u10m_dat, v10m_dat, src_dat, albedo_dat, nveg
  77. #ifndef without_emission
  78. use emission, only : Emission_Init
  79. #endif
  80. use GO, only : TrcFile, Init, Done, ReadRc
  81. use global_data, only : rcfile
  82. use dims, only : iglbsfc, nregions
  83. !
  84. ! !OUTPUT PARAMETERS:
  85. !
  86. integer, intent(out) :: status
  87. !
  88. ! !REVISION HISTORY:
  89. !
  90. ! !REMARKS:
  91. !
  92. !EOP
  93. !------------------------------------------------------------------------------
  94. !BOC
  95. integer, parameter :: kr=31 ! standard unit to read auxiliary files
  96. character(len=*), parameter :: rname = mname//'/Sources_Sinks_Init'
  97. type(TrcFile) :: rcF
  98. integer :: region, iveg
  99. ! --- begin ---------------------------------
  100. !--------------------------------------------------
  101. ! ** select meteo (cases not accounted for in the **_init procedures)
  102. !--------------------------------------------------
  103. ! do region = 1, nregions
  104. ! #ifndef without_emission
  105. ! call Set( temper_dat(region), status, used=.true. )
  106. ! call Set( humid_dat(region), status, used=.true. )
  107. ! call Set( oro_dat(region), status, used=.true. )
  108. ! call Set( gph_dat(region), status, used=.true. )
  109. ! #endif
  110. !
  111. ! ! other
  112. ! call Set( cvl_dat(region), status, used=.true. )
  113. ! call Set( cvh_dat(region), status, used=.true. )
  114. ! do iveg=1,nveg
  115. ! call Set( tv_dat(region,nveg), status, used=.true. )
  116. ! enddo
  117. ! call Set( ci_dat(region), status, used=.true. )
  118. ! call Set( sd_dat(region), status, used=.true. )
  119. ! call Set( swvl1_dat(region), status, used=.true. )
  120. ! call Set( t2m_dat(region), status, used=.true. )
  121. ! call Set( d2m_dat(region), status, used=.true. )
  122. ! call Set( ssr_dat(region), status, used=.true. )
  123. ! call Set( sshf_dat(region), status, used=.true. )
  124. ! call Set( slhf_dat(region), status, used=.true. )
  125. ! call Set( ewss_dat(region), status, used=.true. )
  126. ! call Set( nsss_dat(region), status, used=.true. )
  127. ! call Set( u10m_dat(region), status, used=.true. )
  128. ! call Set( v10m_dat(region), status, used=.true. )
  129. ! call Set( src_dat(region), status, used=.true. )
  130. ! call Set( albedo_dat(region), status, used=.true. )
  131. ! enddo
  132. !--------------------------------------------------
  133. ! ** Emissions
  134. !--------------------------------------------------
  135. #ifndef without_emission
  136. call Emission_Init( status )
  137. IF_NOTOK_RETURN(status=1)
  138. #endif /* EMISSIONS */
  139. !--------------------------------------------------
  140. ! ** Done
  141. !--------------------------------------------------
  142. status = 0
  143. END SUBROUTINE SOURCES_SINKS_INIT
  144. !EOC
  145. !------------------------------------------------------------------------------
  146. ! TM5 !
  147. !------------------------------------------------------------------------------
  148. !BOP
  149. !
  150. ! !IROUTINE: SOURCES_SINKS_DONE
  151. !
  152. ! !DESCRIPTION:
  153. !\\
  154. !\\
  155. ! !INTERFACE:
  156. !
  157. SUBROUTINE SOURCES_SINKS_DONE( status )
  158. !
  159. ! !USES:
  160. !
  161. #ifndef without_emission
  162. use emission, only : Emission_Done, free_emission
  163. #endif
  164. !
  165. ! !OUTPUT PARAMETERS:
  166. !
  167. integer, intent(out) :: status
  168. !
  169. ! !REVISION HISTORY:
  170. !
  171. !EOP
  172. !------------------------------------------------------------------------------
  173. !BOC
  174. character(len=*), parameter :: rname = mname//'/Sources_Sinks_Done'
  175. ! --- begin --------------------------------
  176. #ifndef without_emission
  177. call free_emission( status )
  178. IF_NOTOK_RETURN(status=1)
  179. call Emission_Done( status )
  180. IF_NOTOK_RETURN(status=1)
  181. #endif
  182. status = 0
  183. END SUBROUTINE SOURCES_SINKS_DONE
  184. !EOC
  185. !------------------------------------------------------------------------------
  186. ! TM5 !
  187. !------------------------------------------------------------------------------
  188. !BOP
  189. !
  190. ! !IROUTINE: SS_MONTHLY_UPDATE
  191. !
  192. ! !DESCRIPTION: monthly (re)initialisation of sources/sinks
  193. !\\
  194. !\\
  195. ! !INTERFACE:
  196. !
  197. SUBROUTINE SS_MONTHLY_UPDATE( status )
  198. !
  199. ! !USES:
  200. !
  201. ! use GO, only : TrcFile, Init, Done, ReadRc
  202. ! use dims, only : nregions
  203. use dims, only : newmonth, idate, mlen, newsrun
  204. use dims, only : sec_day, sec_month, sec_year
  205. ! use dims, only : okdebug
  206. ! use dims, only : istart
  207. ! use dims, only : region_name
  208. ! use global_data, only : rcfile
  209. use datetime, only : calc_sm
  210. #ifndef without_emission
  211. use emission, only : declare_emission
  212. #endif
  213. !
  214. ! !OUTPUT PARAMETERS:
  215. !
  216. integer, intent(out) :: status
  217. !
  218. ! !REVISION HISTORY:
  219. ! 19 Mar 2012 - P. Le Sager - adapted for lon-lat MPI domain decomposition
  220. !
  221. ! !REMARKS:
  222. ! (1) routine is called at start and at beginning of each month
  223. ! (2) newsrun/newmonth indicate a new simulation/new month
  224. ! (3) ss_monthly_update reads new data that become available every month
  225. !
  226. !EOP
  227. !------------------------------------------------------------------------------
  228. !BOC
  229. character(len=*), parameter :: rname = mname//'/ss_monthly_update'
  230. ! integer :: region, n, imr, jmr, lmr
  231. ! integer, parameter :: kr=31 ! standard unit to read auxiliary files
  232. ! character(len=256) :: fname, fdir
  233. ! type(TrcFile) :: rcF
  234. ! --- begin ------------------------------------
  235. ! calculate some conversion factors related to time...
  236. call calc_sm( mlen, sec_day, sec_month, sec_year )
  237. ! Read monthly emissions
  238. #ifndef without_emission
  239. call declare_emission( status )
  240. IF_NOTOK_RETURN(status=1)
  241. #endif
  242. status = 0
  243. END SUBROUTINE SS_MONTHLY_UPDATE
  244. !EOC
  245. !------------------------------------------------------------------------------
  246. ! TM5 !
  247. !------------------------------------------------------------------------------
  248. !BOP
  249. !
  250. ! !IROUTINE: SS_AFTER_READ_METEO_UPDATE
  251. !
  252. ! !DESCRIPTION: subroutine that is called after reading new met fields (clouds,
  253. ! surface winds, etc.).
  254. ! In this routine, 'chemistry' fields that depend on these
  255. ! data are calculated. Called from modelIntegration/Proces_update.
  256. !\\
  257. !\\
  258. ! !INTERFACE:
  259. !
  260. SUBROUTINE SS_AFTER_READ_METEO_UPDATE( status )
  261. !
  262. ! !USES:
  263. !
  264. use dims, only : okdebug, nregions, im, jm, lm, sec_month
  265. use ParTools, only : isRoot, par_barrier
  266. use tm5_distgrid, only : dgrid, Get_DistGrid
  267. !
  268. ! !OUTPUT PARAMETERS:
  269. !
  270. integer, intent(out) :: status
  271. !
  272. ! !REVISION HISTORY:
  273. ! 19 Mar 2012 - P. Le Sager - adapted for lon-lat MPI domain decomposition
  274. !
  275. ! !REMARKS:
  276. !
  277. !EOP
  278. !------------------------------------------------------------------------------
  279. !BOC
  280. character(len=*), parameter :: rname = 'trace_after_read'
  281. integer :: region, i1, j1
  282. ! --- begin ------------------------------------
  283. call goLabel()
  284. #ifndef without_emission
  285. ! TvN: nothing is done here in CO2 version
  286. #endif /* EMISSIONS */
  287. call goLabel()
  288. ! ok
  289. status = 0
  290. END SUBROUTINE SS_AFTER_READ_METEO_UPDATE
  291. !EOC
  292. !------------------------------------------------------------------------------
  293. ! TM5 !
  294. !------------------------------------------------------------------------------
  295. !BOP
  296. !
  297. ! !IROUTINE: SOURCES_SINKS_APPLY
  298. !
  299. ! !DESCRIPTION: this subroutine changes the tracer mass and its
  300. ! slopes by chemical sources.
  301. !\\
  302. !\\
  303. ! !INTERFACE:
  304. !
  305. SUBROUTINE SOURCES_SINKS_APPLY( region, tr, status )
  306. !
  307. ! !USES:
  308. !
  309. use GO, only : TDate
  310. #ifndef without_emission
  311. use emission, only: emission_apply
  312. #endif
  313. !
  314. ! !INPUT PARAMETERS:
  315. !
  316. integer, intent(in) :: region
  317. type(TDate) :: tr(2)
  318. !
  319. ! !OUTPUT PARAMETERS:
  320. !
  321. integer, intent(out) :: status
  322. !
  323. ! !REVISION HISTORY:
  324. !
  325. ! !REMARKS:
  326. ! - called each time step, during "source" step, by modelIntegration/do_steps
  327. !
  328. !EOP
  329. !------------------------------------------------------------------------------
  330. !BOC
  331. character(len=*), parameter :: rname = mname//'/Sources_sinks_apply'
  332. ! --- begin ----------------------------------
  333. #ifndef without_emission
  334. call emission_apply( region, status )
  335. IF_NOTOK_RETURN(status=1)
  336. #endif
  337. ! ok
  338. status = 0
  339. END SUBROUTINE SOURCES_SINKS_APPLY
  340. !EOC
  341. END MODULE SOURCES_SINKS