boundary.F90 95 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307
  1. #define TRACEBACK write (gol,'("in ",a," (",a,", line",i5,")")') 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. #include "tm5.inc"
  5. !-----------------------------------------------------------------------------
  6. ! TM5 !
  7. !-----------------------------------------------------------------------------
  8. !BOP
  9. !
  10. ! !MODULE: BOUNDARY
  11. !
  12. ! !DESCRIPTION: Set up boundary conditions:
  13. !
  14. ! O3, O3S and CH4 are relaxed to climatology at stratospheric layers
  15. !
  16. ! For O3 we use either
  17. ! CMIP6 ozone 3D mixing ratios 1850-2099 (Hegglin et al., in prep) or
  18. ! Multi Sensor Reanalysis v2
  19. ! Source MSR : www.temis.nl; Allaart, van der A, manuscript in preparation, 2009)
  20. ! Source MSR2: FIXME
  21. !
  22. ! For CH4 we use Climatology HALOE CH4, October 1991 to August 2002 by:
  23. ! Technical note: A stratospheric climatology for O3, H2O, CH4, NOx, HCl
  24. ! and HF derived from HALOE measurements by J.-U. Grooss and J. M.
  25. ! Russell III, Atmospheric Chemistry and Physics, 5, 2797-2807, 2005
  26. ! SRef-ID: 1680-7324/acp/2005-5-2797
  27. !
  28. ! HNO3 is prescribed at level lm using HNO3:03 ratios from ODIN (fallback on UARS).
  29. !
  30. ! CO is nudged using the ODIN ratio of CO/O3 @ 3 levels (JEW, 2014).
  31. !
  32. ! Note about ODIN datasets: a slow relaxation between monthly mean values
  33. ! is incorporated to improve on the large variability which exists between
  34. ! consecutive months (JEW, 2014).
  35. !
  36. ! For all CMIP6 scenarios, see Gidden et al., 2018; https://doi.org/10.5194/gmd-2018-266
  37. !
  38. !\\
  39. !\\
  40. ! !INTERFACE:
  41. !
  42. MODULE BOUNDARY
  43. !
  44. ! !USES:
  45. !
  46. USE GO, ONLY : gol, goPr, goErr, goLabel
  47. USE TM5_DISTGRID, ONLY : dgrid, Get_DistGrid, gather, scatter_i_band
  48. USE DIMS, ONLY : nregions, idate
  49. USE chem_param, ONLY : ntracet
  50. USE global_types, ONLY : d23_data, d3_data
  51. USE Grid, ONLY : TLevelInfo
  52. #ifdef with_budgets
  53. USE budget_global, ONLY : nbudg, nbud_vg, nzon_vg, budg_dat
  54. #endif
  55. IMPLICIT NONE
  56. PRIVATE
  57. PUBLIC :: BOUNDARY_INIT, BOUNDARY_DONE, BOUNDARY_APPLY
  58. !
  59. ! !PUBLIC DATA MEMBERS:
  60. !
  61. LOGICAL, PUBLIC :: use_o3du
  62. TYPE(d23_data), PUBLIC :: o3du(nregions) ! optionally used in photolysis only
  63. LOGICAL, PUBLIC :: LCMIP6_CO2
  64. REAL, PUBLIC :: co2_glob
  65. !
  66. ! !PRIVATE DATA MEMBERS:
  67. !
  68. ! Flags for O3, CO and CH4 stratospheric nudging
  69. LOGICAL :: LCMIP6_O3, LCMIP6_CH4
  70. LOGICAL :: o3_piclim
  71. REAL, ALLOCATABLE :: weight_cmip62tm5(:)
  72. INTEGER, ALLOCATABLE :: jlow_cmip62tm5(:)
  73. LOGICAL :: use_MSR
  74. LOGICAL :: use_HALOE
  75. LOGICAL :: use_ODIN
  76. LOGICAL :: emis_ch4_single, emis_ch4_fix3d
  77. LOGICAL :: o3_fixyear, ch4_fixyear, co2_fixyear
  78. INTEGER :: o3_year, ch4_year, co2_year
  79. LOGICAL :: L1PCTCO2, LA4xCO2
  80. character(len=256) :: o3vmr_dirname
  81. character(len=256) :: o3du_dirname
  82. character(len=256) :: ch4vmr_dirname
  83. character(len=256) :: covmr_dirname
  84. character(len=256) :: cmip6_ch4_dirname_strat
  85. character(len=256) :: cmip6_co2_dirname
  86. !------------------------------
  87. ! SSP scenario name
  88. !------------------------------
  89. character(len=14) :: ssp_name, ssp_name_ch4
  90. logical :: LSSP370_LowCH4
  91. ! Volume Mixing Ratio and Ratio, and values in DU
  92. TYPE(d23_data) :: o3vmrpm(nregions)
  93. TYPE(d23_data) :: o3vmr(nregions)
  94. TYPE(d23_data) :: o3vmrnm(nregions)
  95. TYPE(d23_data) :: ch4vmrpm(nregions)
  96. TYPE(d23_data) :: ch4vmr(nregions)
  97. TYPE(d23_data) :: ch4vmrnm(nregions)
  98. TYPE(d23_data) :: o3ratpm(nregions)
  99. TYPE(d23_data) :: o3rat(nregions)
  100. TYPE(d23_data) :: o3ratnm(nregions)
  101. TYPE(d23_data) :: ch4ratpm(nregions)
  102. TYPE(d23_data) :: ch4rat(nregions)
  103. TYPE(d23_data) :: ch4ratnm(nregions)
  104. TYPE(d23_data) :: odin_hno3_o3(nregions) ! hno3/o3 ratio at 4 pressure levels
  105. TYPE(d23_data) :: odin_hno3_o3_pm(nregions) ! hno3/o3 ratio at 4 pressure levels (previous month)
  106. TYPE(d23_data) :: odin_hno3_o3_nm(nregions) ! hno3/o3 ratio at 4 pressure levels (next month)
  107. TYPE(d23_data) :: odin_co_o3(nregions) ! co/o3 ratio at 4 pressure levels
  108. TYPE(d23_data) :: odin_co_o3_pm(nregions) ! co/o3 ratio at 4 pressure levels (previous month)
  109. TYPE(d23_data) :: odin_co_o3_nm(nregions) ! co/o3 ratio at 4 pressure levels (next month)
  110. TYPE(TLevelInfo) :: LeviX_msr, LeviX_haloe, LeviX_cmip6_o3
  111. real, allocatable :: wrk2d_ML(:,:) ! 2D work array, model levels
  112. real, allocatable :: wrk2d_4L(:,:) ! 2D work array, 4 levels
  113. real, allocatable :: wrk3dpm_ML(:,:,:), wrk3d_ML(:,:,:), wrk3dnm_ML(:,:,:)! 3D work array, model levels
  114. real, allocatable :: wrk3dratio(:,:,:)
  115. real, allocatable :: wrk3dratiopm(:,:,:) ! for smoothing CO and HNO3 values at monthly scale
  116. real, allocatable :: wrk3drationm(:,:,:) ! for smoothing CO and HNO3 values at monthly scale
  117. #ifdef with_budgets
  118. ! REAL, DIMENSION(nregions) :: sum_stratosphere
  119. REAL, PUBLIC :: budstratg(nbudg, nbud_vg, ntracet)
  120. #endif
  121. integer :: itim_init, itim_appl ! Timers id
  122. CHARACTER(len=*), PARAMETER :: mname = 'boundary'
  123. !
  124. ! !REVISION HISTORY:
  125. ! 15 Jun 2012 - P. Le Sager - adapted for lon-lat MPI domain decomposition
  126. ! 03 Mar 2014 - J. E. Williams - added nudging for CO from ODIN measurements
  127. ! Dec 2016 - Mar 2017 - T. van Noije - added options for using CMIP6 data sets
  128. ! for O3, CH4, and CO2
  129. !
  130. ! !REMARKS:
  131. ! (1) All reference to sum_stratosphere have been commented, since the
  132. ! variable is neither printed nor saved nor used to compute something
  133. ! else.
  134. !EOP
  135. !------------------------------------------------------------------------
  136. CONTAINS
  137. !--------------------------------------------------------------------------
  138. ! TM5 !
  139. !--------------------------------------------------------------------------
  140. !BOP
  141. !
  142. ! !IROUTINE: BOUNDARY_INIT
  143. !
  144. ! !DESCRIPTION: Act as both INIT and MONTHLY_UPDATE methods.
  145. !
  146. ! As INIT : read settings from rc file & allocate data.
  147. ! As MONTHLY_UPDATE : read data in.
  148. !
  149. ! Called at run start and at start of every month (from
  150. ! sources_sinks/sources_sinks_init & ss_monthly_update).
  151. !\\
  152. !\\
  153. ! !INTERFACE:
  154. !
  155. SUBROUTINE BOUNDARY_INIT( first, status )
  156. !
  157. ! !USES:
  158. !
  159. USE GO, ONLY : TrcFile, Init, Done, ReadRc
  160. USE GO, ONLY : GO_Timer_Def, GO_Timer_End, GO_Timer_Start
  161. USE dims, ONLY : im, jm, lm, lme, okdebug, idate, iglbsfc
  162. USE dims, ONLY : nregions, nlat180, nlon360
  163. USE dims, ONLY : newyr
  164. USE global_data, ONLY : rcfile, inputdir
  165. USE partools, ONLY : isRoot, par_broadcast
  166. USE MDF, ONLY : MDF_Open, MDF_NETCDF, MDF_READ, MDF_Inq_VarID, MDF_Get_Var, MDF_Close
  167. USE binas, ONLY : p0
  168. USE Grid, ONLY : FillGrid, Fill3D, FillLevels
  169. USE Grid, ONLY : TLevelInfo
  170. USE Grid, ONLY : TllGridInfo, Init
  171. USE MeteoData, ONLY : global_lli, lli_z, levi
  172. !
  173. ! !INPUT PARAMETERS:
  174. !
  175. LOGICAL, INTENT(in) :: first ! is a new run
  176. !
  177. ! !OUTPUT PARAMETERS:
  178. !
  179. INTEGER, INTENT(out) :: status
  180. !
  181. ! !REVISION HISTORY:
  182. ! 13 Dec 2010 - P. Le Sager - bug fix in reading o3du : use correct
  183. ! number of levels to read data, and allow vertical
  184. ! regridding of O3du.
  185. ! 23 Mar 2012 - P. Le Sager - adapted for lon-lat MPI domain decomposition
  186. ! - fixed : now run longer than a month have correct boundary
  187. !
  188. !EOP
  189. !------------------------------------------------------------------------
  190. !BOC
  191. CHARACTER(len=*), PARAMETER :: rname = mname//'/Boundary_Init'
  192. INTEGER, PARAMETER :: avg_field = 1
  193. INTEGER, DIMENSION(2), PARAMETER :: msr2_valid = (/1979, 2015/) ! 2013-15 are GOME2 data
  194. INTEGER, PARAMETER :: nlon_cmip6_o3 = 144
  195. INTEGER, PARAMETER :: nlat_cmip6_o3 = 96
  196. INTEGER, PARAMETER :: nlev_cmip6_o3 = 66
  197. REAL, ALLOCATABLE :: a_cmip6_o3(:),b_cmip6_o3(:)
  198. REAL, ALLOCATABLE :: lat_cmip6_o3(:)
  199. CHARACTER(len=9) :: rgtype
  200. TYPE(TrcFile) :: rcF
  201. character(len=256) :: o3vmr_fnamepm, o3vmr_fname, o3vmr_fnamenm, o3du_fname
  202. character(len=256) :: ch4vmr_fnamepm, ch4vmr_fname, ch4vmr_fnamenm
  203. CHARACTER(len=256) :: filemon
  204. CHARACTER(len=4) :: ecstring
  205. INTEGER :: nmw, i1, i2, j2, j1, hid, varid
  206. INTEGER :: i,j,lmr, inp_levs, k
  207. INTEGER :: valid_year_pm, valid_year, valid_year_nm
  208. REAL*4 :: field3d_r4(nlat180,4,12)
  209. INTEGER :: nm, pm
  210. TYPE(TLevelInfo) :: src_lev
  211. ! some arrays on 1x1 resolution
  212. REAL, ALLOCATABLE :: field3d_pm(:,:,:), field3d(:,:,:), field3d_nm(:,:,:), field3d_h(:,:,:)
  213. REAL, ALLOCATABLE :: sp_z(:,:)
  214. ! CMIP6 ozone fields
  215. REAL, ALLOCATABLE :: field4d_cmip6_h(:,:,:,:)
  216. REAL, ALLOCATABLE :: field3d_cmip6_pm(:,:), field3d_cmip6(:,:), field3d_cmip6_nm(:,:)
  217. REAL :: tm5_lat
  218. INTEGER :: j_cmip6, jlow_cmip6
  219. INTEGER :: l ! TESTING ONLY
  220. ! Scale factors for stratospheric CH4 from HALOE
  221. real :: ch4_scale, ch4_scale_pm, ch4_scale_nm
  222. real :: ch4_ref
  223. integer :: iyear, target_year
  224. ! CMIP6 global annual mean mixing ratios for CH4 and CO2
  225. real*4, allocatable :: ch4_hist(:,:), ch4_sce(:,:), co2_hist(:,:), co2_sce(:,:)
  226. character(len=512) :: ch4_hist_fname, ch4_sce_fname, co2_hist_fname, co2_sce_fname
  227. !
  228. ! Scaling on HALOE climatology from 2000
  229. !
  230. REAL,Dimension(37) :: RCP6_CH4_STRAT ! covers 1999-2035
  231. data RCP6_CH4_STRAT /1.00, 1.00, 1.0043444078, 1.0099155518, 1.0159814566, 1.021545823, 1.0269678609, 1.032430564, &
  232. 1.037717051, 1.0432000868, 1.0489868922, 1.0547802041, 1.0604597888, 1.0660828758, &
  233. 1.071659984, 1.0772118797, 1.0827461809, 1.0882515012, 1.0937098125, 1.0991152047, &
  234. 1.1044713649, 1.1097834167, 1.1150356906, 1.1202446152, 1.1254644653, 1.1307196942, &
  235. 1.1360154799, 1.1413492741, 1.146701693, 1.1520482561, 1.1573782007, 1.1626917436, &
  236. 1.1679937104, 1.1733492199, 1.1788363765, 1.1844880647, 1.1903212557/
  237. ! --- begin ----------------------------------------
  238. CALL goLabel(rname)
  239. !--------------------------------------------------
  240. ! ** TRUE INIT : only once
  241. !--------------------------------------------------
  242. IF ( FIRST ) THEN
  243. ! read settings from rcfile:
  244. CALL Init( rcF, rcfile, status )
  245. IF_NOTOK_RETURN(status=1)
  246. CALL ReadRc( rcF, 'input.conc.o3.cmip6', LCMIP6_O3, status, default=.FALSE. )
  247. IF_ERROR_RETURN(status=1)
  248. IF (LCMIP6_O3) THEN
  249. write(gol,*) 'Stratospheric O3 based on CMIP6 mixing ratios'; call goPr
  250. CALL ReadRc( rcF, 'input.conc.o3.cmip6.dir', o3vmr_dirname, status )
  251. IF_NOTOK_RETURN(status=1)
  252. CALL ReadRc( rcF, 'input.conc.o3.cmip6.piclim', o3_piclim, status, default=.FALSE. )
  253. IF_ERROR_RETURN(status=1)
  254. IF (o3_piclim) THEN
  255. write(gol,*) 'Stratospheric O3 nudged to pre-industrial climatology from CMIP6'; call goPr
  256. ENDIF
  257. ENDIF
  258. CALL ReadRc( rcF, 'input.climat.MSR', use_MSR, status, default=.FALSE. )
  259. IF_ERROR_RETURN(status=1)
  260. IF (use_MSR) THEN
  261. CALL ReadRc( rcF, 'input.climat.o3vmr', o3vmr_dirname, status )
  262. IF_NOTOK_RETURN(status=1)
  263. CALL ReadRc( rcF, 'input.climat.use_o3du', use_o3du, status, default=.FALSE. )
  264. IF_ERROR_RETURN(status=1)
  265. IF (use_o3du) THEN
  266. CALL ReadRc( rcF, 'input.climat.o3du', o3du_dirname, status )
  267. IF_NOTOK_RETURN(status=1)
  268. ENDIF
  269. ENDIF
  270. IF (LCMIP6_O3 .and. use_MSR) THEN
  271. write (gol,'("ERROR - CMIP6 and MSR O3 cannot both be selected")') ; call goErr
  272. status=1; TRACEBACK; return
  273. ENDIF
  274. ! It is now possible to nudge stratospheric O3 mixing ratios
  275. ! to the fields for a fixed year,
  276. ! both for the CMIP6 and MSR data sets.
  277. CALL ReadRc( rcF, 'input.o3.fixyear', o3_fixyear, status, default = .FALSE. )
  278. IF_ERROR_RETURN(status=1)
  279. IF (o3_fixyear) THEN
  280. CALL ReadRc( rcF, 'input.o3.year', o3_year, status )
  281. IF_NOTOK_RETURN(status=1)
  282. IF (LCMIP6_O3) THEN
  283. IF (.not.o3_piclim) THEN
  284. write(gol,*) 'Stratospheric O3 nudged to fixed year: ', o3_year; call goPr
  285. ENDIF
  286. ELSE IF (use_MSR) THEN
  287. ! o3_piclim not defined
  288. write(gol,*) 'Stratospheric O3 nudged to fixed year: ', o3_year; call goPr
  289. ENDIF
  290. ENDIF
  291. CALL ReadRc( rcF, 'input.climat.HALOE', use_HALOE, status, default=.FALSE. )
  292. IF_ERROR_RETURN(status=1)
  293. IF (use_HALOE) THEN
  294. CALL ReadRc( rcF, 'input.climat.ch4vmr', ch4vmr_dirname, status )
  295. IF_NOTOK_RETURN(status=1)
  296. ENDIF
  297. CALL ReadRc( rcF, 'input.conc.ch4.cmip6', LCMIP6_CH4, status, default=.TRUE. )
  298. IF_ERROR_RETURN(status=1)
  299. IF (LCMIP6_CH4) THEN
  300. write(gol,*) 'Stratospheric CH4 scaled based on CMIP6 surface concentration'; call goPr
  301. CALL ReadRc( rcF, 'input.conc.ch4.cmip6.dir.year', cmip6_ch4_dirname_strat, status )
  302. IF_NOTOK_RETURN(status=1)
  303. IF (.not.use_HALOE) THEN
  304. write (gol,'("ERROR - The HALOE stratospheric CH4 climatology should be used with CMIP6 CH4")') ; call goErr
  305. status=1; TRACEBACK; return
  306. ENDIF
  307. ELSE
  308. CALL ReadRc( rcF, 'input.emis.ch4.single', emis_ch4_single, status )
  309. IF_NOTOK_RETURN(status=1)
  310. IF (emis_ch4_single) THEN
  311. call ReadRc( rcF, 'input.emis.ch4.fix3d', emis_ch4_fix3d, status, default=.true. )
  312. IF_NOTOK_RETURN(status=1)
  313. IF ( use_HALOE .and. emis_ch4_fix3d ) THEN
  314. write (gol,'("ERROR - Do not use the HALOE stratospheric CH4 climatology")') ; call goErr
  315. write (gol,'("ERROR - when a single mixing ratio is prescribed in the whole atmosphere")') ; call goErr
  316. status=1; TRACEBACK; return
  317. ENDIF
  318. ENDIF
  319. ENDIF
  320. CALL ReadRc( rcF, 'input.ch4.fixyear', ch4_fixyear, status, default = .FALSE. )
  321. IF_ERROR_RETURN(status=1)
  322. IF (ch4_fixyear) THEN
  323. CALL ReadRc( rcF, 'input.ch4.year', ch4_year, status )
  324. IF_NOTOK_RETURN(status=1)
  325. write(gol,*) 'Base year for stratospheric CH4 scaling: ', ch4_year; call goPr
  326. ENDIF
  327. CALL ReadRc( rcF, 'input.climat.ODIN', use_ODIN, status, default=.FALSE. )
  328. IF_ERROR_RETURN(status=1)
  329. IF (use_ODIN) THEN
  330. CALL ReadRc( rcF, 'input.climat.covmr', covmr_dirname, status )
  331. IF_NOTOK_RETURN(status=1)
  332. ENDIF
  333. CALL ReadRc( rcF, 'input.conc.co2.cmip6', LCMIP6_CO2, status, default=.TRUE. )
  334. IF_ERROR_RETURN(status=1)
  335. IF (LCMIP6_CO2) THEN
  336. write(gol,*) 'Global annual mean CO2 mixing ratios in pH calculation based on CMIP6'; call goPr
  337. CALL ReadRc( rcF, 'input.conc.co2.cmip6.dir', cmip6_co2_dirname, status )
  338. IF_NOTOK_RETURN(status=1)
  339. CALL ReadRc( rcF, 'input.co2.1pct', L1PCTCO2, status, default=.FALSE. )
  340. IF_ERROR_RETURN(status=1)
  341. CALL ReadRc( rcF, 'input.co2.abrupt-4x', LA4xCO2, status, default=.FALSE. )
  342. IF_ERROR_RETURN(status=1)
  343. IF (L1PCTCO2 .AND. LA4xCO2) THEN
  344. write (gol,'("ERROR - L1PCTCO2 and LA4xCO2 both set")') ; call goErr
  345. status=1; TRACEBACK; return
  346. ELSE IF (L1PCTCO2 .OR. LA4xCO2) THEN
  347. !Use co2_fixyear to set reference year to 1850
  348. co2_fixyear=.TRUE.
  349. co2_year=1850
  350. IF (L1PCTCO2) THEN
  351. write(gol,*) 'DECK 1pctCO2 simulation:'; call goPr
  352. write(gol,*) '...A stepwise change of 1% is applied from one year to the next'; call goPr
  353. write(gol,*) '...In the first year a 5% increase is applied compared to the 1850 value'; call goPr
  354. write(gol,*) '...The simulation should start in 1850.'; call goPr
  355. ENDIF
  356. IF (LA4xCO2) THEN
  357. write(gol,*) 'DECK abrupt-4xCO2 simulation: CO2 quadrupled compared to 1850'; call goPr
  358. ENDIF
  359. ELSE
  360. CALL ReadRc( rcF, 'input.co2.fixyear', co2_fixyear, status, default = .FALSE. )
  361. IF_ERROR_RETURN(status=1)
  362. IF (co2_fixyear) THEN
  363. CALL ReadRc( rcF, 'input.co2.year', co2_year, status )
  364. IF_NOTOK_RETURN(status=1)
  365. write(gol,*) 'CO2 mixing ratio fixed to year: ', co2_year; call goPr
  366. ENDIF
  367. ENDIF
  368. ELSE
  369. ! It would be better to change this warning into an error
  370. write (gol,'("WARNING - CO2 mixing ratio in pH calculation fixed to global annual mean for year 2000")') ; call goPr
  371. write (gol,'("WARNING - It is recommended to use the CMIP6 time series")') ; call goPr
  372. ENDIF
  373. IF (LCMIP6_O3 .OR. LCMIP6_CH4 .OR. LCMIP6_CO2) THEN
  374. call ReadRc( rcF, 'input.CMIP6.SSP', ssp_name, status, default='' )
  375. IF_ERROR_RETURN(status=1)
  376. write(gol, '("SSP CMIP6 future scenario for boundary conditions: ",a)') trim(ssp_name); call goPr
  377. IF (LCMIP6_CH4) THEN
  378. call ReadRc( rcF, 'input.CMIP6.SSP370_LowNTCF.ch4', LSSP370_LowCH4, status, default=.FALSE. )
  379. IF_ERROR_RETURN(status=1)
  380. IF (.not.LSSP370_LowCH4) THEN
  381. ssp_name_ch4 = ssp_name
  382. ELSE
  383. ssp_name_ch4 = "SSP3-LowNTCF"
  384. write(gol, '("... but for CH4 use instead: ",a)') trim(ssp_name_ch4); call goPr
  385. ENDIF
  386. ENDIF
  387. ENDIF
  388. CALL Done( rcF, status )
  389. IF_NOTOK_RETURN(status=1)
  390. IF (isRoot) THEN
  391. IF (LCMIP6_O3) THEN
  392. allocate(a_cmip6_o3(0:nlev_cmip6_o3))
  393. allocate(b_cmip6_o3(0:nlev_cmip6_o3))
  394. allocate(lat_cmip6_o3(1:nlat_cmip6_o3))
  395. allocate(jlow_cmip62tm5(1:jm(1)))
  396. allocate(weight_cmip62tm5(1:jm(1)))
  397. ! CMIP6 fields are provided on a pressure grid spanning from 1000 hPa to 0.0001 hPa
  398. ! half-level pressure coefficient a (Pa)
  399. a_cmip6_o3(:) = 100. * &
  400. (/1037.5, 962.5, 887.5, 825.0, 790.0, 765.0, 725.0, 675.0, 625.0, 550.0, &
  401. 475.0, 425.0, 375.0, 325.0, 292.5, 267.5, 225.0, 185.0, 160.0, 140.0, &
  402. 122.5, 107.5, 95.0, 85.0, 75.0, 65.0, 55.0, 45.0, 37.5, 32.5, &
  403. 27.5, 22.5, 17.5, 12.5, 8.5, 6.0, 4.5, 3.5, 2.5, 1.75, &
  404. 1.25, 0.85, 0.6, 0.45, 0.35, 0.25, 0.175, 0.125, 0.085, 0.06, &
  405. 0.045, 0.035, 0.025, 0.0175, 0.0125, 0.0085, 0.006, 0.0045, 0.0035, 0.0025, &
  406. 0.00175, 0.00125, 0.0009, 0.00065, 0.0004, 0.0002, 0.0000 /)
  407. ! half-level pressure coefficient b
  408. b_cmip6_o3(:) = 0.
  409. CALL Init(LeviX_cmip6_o3, nlev_cmip6_o3, a_cmip6_o3, b_cmip6_o3, status)
  410. IF_NOTOK_RETURN(status=1)
  411. ! Calculate weights for interpolation
  412. ! from CMIP6 to model latitudes.
  413. ! Note that in IFS the Cartesian coordinate
  414. ! sin(lat) is used to linearly interpolate
  415. ! to the model's Gaussian grid
  416. ! (see e.g. cmip6_piaer_mxr_interp.F90).
  417. ! For the regular grid of TM5,
  418. ! it is more appropriate to use
  419. ! the latitude coordinate directly.
  420. ! The difference is negligible anyway.
  421. ! The alternative would be to impose
  422. ! local mass conservation,
  423. ! but that is not necessary here.
  424. lat_cmip6_o3(:) = &
  425. (/-90., -88.10526, -86.21053, -84.31579, -82.42105, -80.52631, -78.63158, &
  426. -76.73684, -74.8421 , -72.94736, -71.05264, -69.1579, -67.26316, &
  427. -65.36842, -63.47368, -61.57895, -59.68421, -57.78947, -55.89474, -54., &
  428. -52.10526, -50.21053, -48.31579, -46.42105, -44.52632, -42.63158, &
  429. -40.73684, -38.84211, -36.94737, -35.05263, -33.15789, -31.26316, &
  430. -29.36842, -27.47368, -25.57895, -23.68421, -21.78947, -19.89474, -18., &
  431. -16.10526, -14.21053, -12.31579, -10.42105, -8.526316, -6.631579, &
  432. -4.736842, -2.842105, -0.9473684, 0.9473684, 2.842105, 4.736842, &
  433. 6.631579, 8.526316, 10.42105, 12.31579, 14.21053, 16.10526, 18., 19.89474, &
  434. 21.78947, 23.68421, 25.57895, 27.47368, 29.36842, 31.26316, 33.15789, &
  435. 35.05263, 36.94737, 38.84211, 40.73684, 42.63158, 44.52632, 46.42105, &
  436. 48.31579, 50.21053, 52.10526, 54., 55.89474, 57.78947, 59.68421, 61.57895, &
  437. 63.47368, 65.36842, 67.26316, 69.1579, 71.05264, 72.94736, 74.8421, &
  438. 76.73684, 78.63158, 80.52631, 82.42105, 84.31579, 86.21053, 88.10526, 90./)
  439. jlow_cmip6 = 1
  440. DO j=1,jm(1)
  441. tm5_lat=lli_z(1)%lat_deg(j) ! lat in degrees
  442. ! Since CMIP6 mid-point latitudes run from -90 to +90,
  443. ! the target latitudes of the model always fall within this range
  444. DO j_cmip6=jlow_cmip6,nlat_cmip6_o3
  445. IF ( (tm5_lat .ge. lat_cmip6_o3(j_cmip6)) .and. &
  446. (tm5_lat .lt. lat_cmip6_o3(j_cmip6+1)) ) THEN
  447. jlow_cmip6 = j_cmip6
  448. EXIT
  449. ENDIF
  450. ENDDO
  451. jlow_cmip62tm5(j)=jlow_cmip6
  452. weight_cmip62tm5(j) = (tm5_lat - lat_cmip6_o3(jlow_cmip6)) / &
  453. (lat_cmip6_o3(jlow_cmip6+1) - lat_cmip6_o3(jlow_cmip6))
  454. ENDDO
  455. deallocate(a_cmip6_o3)
  456. deallocate(b_cmip6_o3)
  457. deallocate(lat_cmip6_o3)
  458. ENDIF
  459. IF (use_MSR) THEN
  460. ! Define vertical grid of MSR input files (MSR2 only on 60 levels)
  461. ecstring='ec60'
  462. CALL Init(LeviX_msr, ecstring, status)
  463. IF_NOTOK_RETURN(status=1)
  464. ENDIF
  465. IF (use_HALOE) THEN
  466. ! Define vertical grid of HALOE input files
  467. select case (lme)
  468. case(60)
  469. ! offline TM5 resolution
  470. ecstring='ec60'
  471. case(34, 91, 137)
  472. ! standard EC-Earth3 resolution
  473. ecstring='ec91'
  474. case(40)
  475. ecstring='ec40'
  476. case(62)
  477. ecstring='ec62'
  478. case default
  479. write (gol,'("ERROR - HALOE input files not available for this vertical resolution")') ; call goErr
  480. status=1; TRACEBACK; return
  481. end select
  482. CALL Init(LeviX_haloe, ecstring, status)
  483. IF_NOTOK_RETURN(status=1)
  484. ENDIF
  485. ENDIF
  486. ! Allocate
  487. CALL Get_DistGrid( dgrid(1), J_STRT=j1, J_STOP=j2 ) ! grid size
  488. lmr = lm(1)
  489. IF (use_o3du) THEN
  490. ALLOCATE( o3du(1)%d23(j1:j2, lmr) )
  491. o3du(1)%d23 = 0.0
  492. END IF
  493. allocate( o3ratpm (1)%d23( j1:j2, lmr) )
  494. allocate( o3rat (1)%d23( j1:j2, lmr) )
  495. allocate( o3ratnm (1)%d23( j1:j2, lmr) )
  496. allocate( ch4ratpm (1)%d23( j1:j2, lmr) )
  497. allocate( ch4rat (1)%d23( j1:j2, lmr) )
  498. allocate( ch4ratnm (1)%d23( j1:j2, lmr) )
  499. allocate( odin_hno3_o3 (1)%d23( j1:j2, 4) )
  500. allocate( odin_hno3_o3_pm(1)%d23( j1:j2, 4) )
  501. allocate( odin_hno3_o3_nm(1)%d23( j1:j2, 4) )
  502. allocate( o3vmrpm (1)%d23( j1:j2, lmr) )
  503. allocate( o3vmr (1)%d23( j1:j2, lmr) )
  504. allocate( o3vmrnm (1)%d23( j1:j2, lmr) )
  505. allocate( ch4vmrpm (1)%d23( j1:j2, lmr) )
  506. allocate( ch4vmr (1)%d23( j1:j2, lmr) ) ! only if Haloe
  507. allocate( ch4vmrnm (1)%d23( j1:j2, lmr) )
  508. allocate( odin_co_o3 (1)%d23( j1:j2, 4) )
  509. allocate( odin_co_o3_pm(1)%d23( j1:j2, 4) )
  510. allocate( odin_co_o3_nm(1)%d23( j1:j2, 4) )
  511. ! work arrays
  512. IF (isRoot) THEN
  513. allocate( wrk3dpm_ML (1, jm(1), lmr) )
  514. allocate( wrk3d_ML (1, jm(1), lmr) )
  515. allocate( wrk3dnm_ML (1, jm(1), lmr) )
  516. allocate( wrk3dratio(1, jm(1), 4) )
  517. allocate( wrk3dratiopm(1, jm(1), 4) )
  518. allocate( wrk3drationm(1, jm(1), 4) )
  519. allocate( wrk2d_ML ( jm(1), lmr) )
  520. allocate( wrk2d_4L ( jm(1), 4) )
  521. ELSE
  522. allocate( wrk3dpm_ML (1,1,1) )
  523. allocate( wrk3d_ML (1,1,1) )
  524. allocate( wrk3dnm_ML (1,1,1) )
  525. allocate( wrk3dratio(1,1,1) )
  526. allocate( wrk3dratiopm(1,1,1) )
  527. allocate( wrk3drationm(1,1,1) )
  528. ALLOCATE( wrk2d_ML(1,1) )
  529. ALLOCATE( wrk2d_4L(1,1) )
  530. END IF
  531. ! safety
  532. o3ratpm(1)%d23 = 0.0 ; o3rat(1)%d23 = 0.0 ; o3ratnm(1)%d23 = 0.0
  533. ch4ratpm(1)%d23 = 0.0 ; ch4rat(1)%d23 = 0.0 ; ch4ratnm(1)%d23 = 0.0
  534. odin_hno3_o3_pm(1)%d23 = 0.0 ; odin_hno3_o3(1)%d23 = 0.0 ; odin_hno3_o3_nm(1)%d23 = 0.0
  535. odin_co_o3_pm(1)%d23 = 0.0 ; odin_co_o3 (1)%d23 = 0.0 ; odin_co_o3_nm(1)%d23 = 0.0
  536. ! Budgets init
  537. !--------------------------------------------------
  538. #ifdef with_budgets
  539. ! sum_stratosphere(1) = 0.0
  540. budstratg(:,:,:) = 0.0
  541. #endif
  542. ! Timers
  543. call GO_Timer_Def( itim_init, 'boundary init', status )
  544. IF_NOTOK_RETURN(status=1)
  545. call GO_Timer_Def( itim_appl, 'boundary appl', status )
  546. IF_NOTOK_RETURN(status=1)
  547. ELSE
  548. ! start timing
  549. call GO_Timer_Start( itim_init, status )
  550. IF_NOTOK_RETURN(status=1)
  551. !--------------------------------------------------
  552. ! ** OZONE CLIMATOLOGIES
  553. !--------------------------------------------------
  554. !--------------------------------------------------
  555. ! ** o3 vmr
  556. !--------------------------------------------------
  557. ROOT : IF (isRoot) THEN
  558. IF (LCMIP6_O3) THEN
  559. ! CMIP6 ozone files
  560. ! containing float vmro3(time, plev, lat, lon)
  561. ! with 14 months
  562. allocate( field4d_cmip6_h(nlon_cmip6_o3, nlat_cmip6_o3, nlev_cmip6_o3,3) )
  563. allocate( field3d_cmip6_pm (nlat_cmip6_o3, nlev_cmip6_o3) )
  564. allocate( field3d_cmip6 (nlat_cmip6_o3, nlev_cmip6_o3) )
  565. allocate( field3d_cmip6_nm (nlat_cmip6_o3, nlev_cmip6_o3) )
  566. allocate( field3d_pm (1, jm(1), nlev_cmip6_o3) )
  567. allocate( field3d (1, jm(1), nlev_cmip6_o3) )
  568. allocate( field3d_nm (1, jm(1), nlev_cmip6_o3) )
  569. if (o3_piclim) then
  570. ! pre-industrial control using 1850 O3 climatology
  571. write(o3vmr_fname,'(a,a,i4,a)') TRIM(o3vmr_dirname),'o3_pi/vmro3_input4MIPs_ozone_CMIP6_UReading-CCMI_clim_1850.nc'
  572. else
  573. ! O3 data are only provided up to 2099
  574. if (.not.o3_fixyear) then
  575. target_year = MIN(2099,MAX(idate(1),1850))
  576. else
  577. target_year = MIN(2099,MAX(o3_year,1850))
  578. endif
  579. if ( target_year <= 2014) then
  580. ! 2014 is the last year of the historical period.
  581. ! The last entry of the 2014 file
  582. ! contains the field for January 2015,
  583. ! which is taken from the SSP370 scenario.
  584. ! This is the only scenario implemented in TM5 anyway.
  585. write(o3vmr_fname,'(a,a,i4,a)') TRIM(o3vmr_dirname),'o3_histo/vmro3_input4MIPs_ozone_CMIP6_UReading-CCMI_',target_year,'.nc'
  586. else
  587. ! Consistent with EC-Earth:
  588. ! - use same names
  589. ! - for SSP1-1.9, use ozone from SSP1-2.6
  590. ! - for Extended scenarios, repeat 2100 value of the corresponding non-extended scenario (NOT TESTED)
  591. ! - for Tier-2 scenarios, not available ("SSP4-3.4", "SSP4-6.0", "SSP5-3.4-OS" and its extended "SSP5-3.4-OS-Ext")
  592. ! On top of it, use SSP370 ozone also for SSP370-LowNTCF
  593. select case (trim(ssp_name))
  594. case ("SSP1-1.9", "SSP1-2.6", "SSP1-2.6-Ext")
  595. write(o3vmr_fname,'(a,a,i4,a)') TRIM(o3vmr_dirname),'o3_scenarios/vmro3_input4MIPs_ozone_CMIP6_UReading-CCMI_ssp126_',target_year,'.nc'
  596. case ("SSP2-4.5")
  597. write(o3vmr_fname,'(a,a,i4,a)') TRIM(o3vmr_dirname),'o3_scenarios/vmro3_input4MIPs_ozone_CMIP6_UReading-CCMI_ssp245_',target_year,'.nc'
  598. case ("SSP3-7.0")
  599. write(o3vmr_fname,'(a,a,i4,a)') TRIM(o3vmr_dirname),'o3_scenarios/vmro3_input4MIPs_ozone_CMIP6_UReading-CCMI_ssp370_',target_year,'.nc'
  600. case ("SSP5-8.5","SSP5-8.5-Ext")
  601. write(o3vmr_fname,'(a,a,i4,a)') TRIM(o3vmr_dirname),'o3_scenarios/vmro3_input4MIPs_ozone_CMIP6_UReading-CCMI_ssp585_',target_year,'.nc'
  602. case default
  603. write (gol,'("Ozone fields not implemented for scenario",1x,a)') trim(ssp_name) ; call goErr
  604. status=1; TRACEBACK; return
  605. end select
  606. endif
  607. endif
  608. write(gol,'(" Boundary - reading O3 file: ",a)') trim(o3vmr_fname); call goPr
  609. CALL MDF_Open( TRIM(o3vmr_fname), MDF_NETCDF, MDF_READ, hid, status )
  610. IF_NOTOK_RETURN(status=1)
  611. CALL MDF_Inq_VarID( hid,'vmro3', varid, status )
  612. IF_NOTOK_RETURN(status=1)
  613. ! Ozone input files contain 14 month entries,
  614. ! 1: December previous year
  615. ! 2-13: January to December current year
  616. ! 14: January next year
  617. ! Besides the current month,
  618. ! also the previous and next month are needed.
  619. ! By default, these have indices idate(2), idate(2)+1, and idate(2)+2.
  620. CALL MDF_Get_Var( hid, varid, field4d_cmip6_h, status, start=(/1,1,1,idate(2)/), count=(/nlon_cmip6_o3,nlat_cmip6_o3,nlev_cmip6_o3,3/) )
  621. IF_NOTOK_RETURN(status=1)
  622. ! When a fixed year is used for O3
  623. ! information from the previous or next year
  624. ! should not be used and overwritten
  625. ! with the data for the target year.
  626. ! This is not necessary
  627. ! when the pre-industrial climatology is used.
  628. IF (o3_fixyear .and. .not.o3_piclim) THEN
  629. IF (idate(2).eq.1) THEN
  630. ! overwrite previous month with field for December of the target year
  631. CALL MDF_Get_Var( hid, varid, field4d_cmip6_h(:,:,:,1), status, start=(/1,1,1,13/), count=(/nlon_cmip6_o3,nlat_cmip6_o3,nlev_cmip6_o3,1/) )
  632. ELSE IF (idate(2).eq.12) THEN
  633. ! overwrite next month with field for January of the current year
  634. CALL MDF_Get_Var( hid, varid, field4d_cmip6_h(:,:,:,3), status, start=(/1,1,1,2/), count=(/nlon_cmip6_o3,nlat_cmip6_o3,nlev_cmip6_o3,1/) )
  635. ENDIF
  636. ENDIF
  637. CALL MDF_Close( hid, status )
  638. IF_NOTOK_RETURN(status=1)
  639. ! calculate zonal mean
  640. DO k=1,nlev_cmip6_o3
  641. DO j=1,nlat_cmip6_o3
  642. field3d_cmip6_pm(j,k)= sum(field4d_cmip6_h(:,j,k,1))/float(nlon_cmip6_o3)
  643. field3d_cmip6(j,k) = sum(field4d_cmip6_h(:,j,k,2))/float(nlon_cmip6_o3)
  644. field3d_cmip6_nm(j,k)= sum(field4d_cmip6_h(:,j,k,3))/float(nlon_cmip6_o3)
  645. ENDDO
  646. ENDDO
  647. deallocate( field4d_cmip6_h )
  648. DO j=1,jm(1)
  649. jlow_cmip6=jlow_cmip62tm5(j)
  650. field3d_pm(1,j,:) = &
  651. field3d_cmip6_pm(jlow_cmip6,:) + weight_cmip62tm5(j) * &
  652. ( field3d_cmip6_pm(jlow_cmip6+1,:) - field3d_cmip6_pm(jlow_cmip6,:) )
  653. field3d(1,j,:) = &
  654. field3d_cmip6(jlow_cmip6,:) + weight_cmip62tm5(j) * &
  655. ( field3d_cmip6(jlow_cmip6+1,:) - field3d_cmip6(jlow_cmip6,:) )
  656. field3d_nm(1,j,:) = &
  657. field3d_cmip6_nm(jlow_cmip6,:) + weight_cmip62tm5(j) * &
  658. ( field3d_cmip6_nm(jlow_cmip6+1,:) - field3d_cmip6_nm(jlow_cmip6,:) )
  659. ENDDO
  660. deallocate (field3d_cmip6_pm)
  661. deallocate (field3d_cmip6)
  662. deallocate (field3d_cmip6_nm)
  663. ! convert from mol/mol to ppmv,
  664. ! the unit used in the MSR input files
  665. field3d_pm = 1.e6 * field3d_pm
  666. field3d = 1.e6 * field3d
  667. field3d_nm = 1.e6 * field3d_nm
  668. ! Distribute to model vertical resolution
  669. src_lev = leviX_cmip6_o3
  670. rgtype = 'mass-aver'
  671. ALLOCATE( sp_z(1,jm(1)) ) ! dummy surface pressure:
  672. sp_z = p0 ! 1e5 Pa
  673. CALL FillLevels( levi, 'n', sp_z, wrk3dpm_ML, &
  674. src_lev, field3d_pm, rgtype, status )
  675. CALL FillLevels( levi, 'n', sp_z, wrk3d_ML, &
  676. src_lev, field3d, rgtype, status )
  677. CALL FillLevels( levi, 'n', sp_z, wrk3dnm_ML, &
  678. src_lev, field3d_nm, rgtype, status )
  679. ELSE
  680. IF (use_MSR) THEN
  681. inp_levs = LeviX_msr%nlev
  682. allocate( field3D_pm (1, nlat180, inp_levs) )
  683. allocate( field3D (1, nlat180, inp_levs) )
  684. allocate( field3D_nm (1, nlat180, inp_levs) )
  685. allocate( field3d_h (1, nlat180, inp_levs) )
  686. field3d_pm=0.0 ; field3d=0.0 ; field3d_nm=0.0 ; field3d_h=0.0
  687. nmw=idate(2) ! pick out right month in file
  688. ! filename (includes year and nb of levels)
  689. if (.not.o3_fixyear) then
  690. valid_year = MIN(msr2_valid(2), MAX(idate(1), msr2_valid(1)))
  691. valid_year_pm = MAX(valid_year-1, msr2_valid(1))
  692. valid_year_nm = MIN(valid_year+1, msr2_valid(2))
  693. else
  694. valid_year = MIN(msr2_valid(2), MAX(o3_year, msr2_valid(1)))
  695. valid_year_pm = valid_year
  696. valid_year_nm = valid_year
  697. endif
  698. ! Currently available: 1979-2012
  699. WRITE(o3vmr_fnamepm,'(a,"msr2_o3vmr",i4,"_",i2,".nc4")')TRIM(o3vmr_dirname),valid_year_pm,inp_levs
  700. WRITE(o3vmr_fname,' (a,"msr2_o3vmr",i4,"_",i2,".nc4")')TRIM(o3vmr_dirname),valid_year, inp_levs
  701. WRITE(o3vmr_fnamenm,'(a,"msr2_o3vmr",i4,"_",i2,".nc4")')TRIM(o3vmr_dirname),valid_year_nm,inp_levs
  702. !
  703. ! January
  704. !
  705. if(nmw .eq. 1) then
  706. CALL MDF_Open( TRIM(o3vmr_fnamepm), MDF_NETCDF, MDF_READ, hid, status )
  707. IF_NOTOK_RETURN(status=1)
  708. CALL MDF_Inq_VarID( hid, 'ozone12', varid, status )
  709. IF_NOTOK_RETURN(status=1)
  710. CALL MDF_Get_Var( hid, varid, field3d_h(1,:,:), status )
  711. IF_NOTOK_RETURN(status=1)
  712. CALL MDF_Close( hid, status )
  713. IF_NOTOK_RETURN(status=1)
  714. ! Flip the data over (upside down), since leviX_msr, associated with
  715. ! field3d when regridding below (Fill3D), is flipped w/r/t to levi
  716. ! [it is the case, since ecstring starts with "ec" and not "tm"
  717. ! --see grid_type_hyb.F90--]
  718. DO k=1,inp_levs
  719. field3d_pm(1,:,k)=field3d_h(1,:,inp_levs+1-k)
  720. ENDDO
  721. CALL MDF_Open( TRIM(o3vmr_fname), MDF_NETCDF, MDF_READ, hid, status )
  722. IF_NOTOK_RETURN(status=1)
  723. CALL MDF_Inq_VarID( hid, 'ozone1', varid, status )
  724. IF_NOTOK_RETURN(status=1)
  725. CALL MDF_Get_Var( hid, varid, field3d_h(1,:,:), status )
  726. IF_NOTOK_RETURN(status=1)
  727. DO k=1,inp_levs
  728. field3d(1,:,k)=field3d_h(1,:,inp_levs+1-k)
  729. ENDDO
  730. CALL MDF_Inq_VarID( hid, 'ozone2', varid, status )
  731. IF_NOTOK_RETURN(status=1)
  732. CALL MDF_Get_Var( hid, varid, field3d_h(1,:,:), status )
  733. IF_NOTOK_RETURN(status=1)
  734. CALL MDF_Close( hid, status )
  735. IF_NOTOK_RETURN(status=1)
  736. DO k=1,inp_levs
  737. field3d_nm(1,:,k)=field3d_h(1,:,inp_levs+1-k)
  738. ENDDO
  739. src_lev = leviX_msr
  740. rgtype = 'mass-aver'
  741. deallocate( field3d_h )
  742. endif
  743. !
  744. ! Here the previous and next monthly fields are located in the same year
  745. !
  746. if(nmw .gt. 1 .and. nmw .lt. 12) then
  747. ! field name (has month: ozone1, ozone2, ..., ozone12)
  748. IF (nmw.LT.11) THEN
  749. nmw=idate(2)-1
  750. WRITE(filemon,'(a,i1)')'ozone',nmw
  751. ELSE
  752. nmw=idate(2)-1
  753. WRITE(filemon,'(a,i2)')'ozone',nmw
  754. ENDIF
  755. CALL MDF_Open( TRIM(o3vmr_fname), MDF_NETCDF, MDF_READ, hid, status )
  756. IF_NOTOK_RETURN(status=1)
  757. CALL MDF_Inq_VarID( hid, TRIM(filemon), varid, status )
  758. IF_NOTOK_RETURN(status=1)
  759. CALL MDF_Get_Var( hid, varid, field3d_h(1,:,:), status )
  760. IF_NOTOK_RETURN(status=1)
  761. ! Flip the data over (upside down), since leviX_msr, associated with
  762. ! field3d when regridding below (Fill3D), is flipped w/r/t to levi
  763. ! [it is the case, since ecstring starts with "ec" and not "tm"
  764. ! --see grid_type_hyb.F90--]
  765. DO k=1,inp_levs
  766. field3d_pm(1,:,k)=field3d_h(1,:,inp_levs+1-k)
  767. ENDDO
  768. nmw=idate(2)
  769. ! field name (has month: ozone1, ozone2, ..., ozone12)
  770. IF (nmw.LT.10) THEN
  771. WRITE(filemon,'(a,i1)')'ozone', nmw
  772. ELSE
  773. WRITE(filemon,'(a,i2)')'ozone', nmw
  774. ENDIF
  775. CALL MDF_Inq_VarID( hid, TRIM(filemon), varid, status )
  776. IF_NOTOK_RETURN(status=1)
  777. CALL MDF_Get_Var( hid, varid, field3d_h(1,:,:), status )
  778. IF_NOTOK_RETURN(status=1)
  779. DO k=1,inp_levs
  780. field3d(1,:,k)=field3d_h(1,:,inp_levs+1-k)
  781. ENDDO
  782. ! field name (has month: ozone1, ozone2, ..., ozone12)
  783. IF (nmw.LT.9) THEN
  784. nmw=idate(2)+1
  785. WRITE(filemon,'(a,i1)')'ozone',nmw
  786. ELSE
  787. nmw=idate(2)+1
  788. WRITE(filemon,'(a,i2)')'ozone',nmw
  789. ENDIF
  790. CALL MDF_Inq_VarID( hid, TRIM(filemon), varid, status )
  791. IF_NOTOK_RETURN(status=1)
  792. CALL MDF_Get_Var( hid, varid, field3d_h(1,:,:), status )
  793. IF_NOTOK_RETURN(status=1)
  794. CALL MDF_Close( hid, status )
  795. IF_NOTOK_RETURN(status=1)
  796. DO k=1,inp_levs
  797. field3d_nm(1,:,k)=field3d_h(1,:,inp_levs+1-k)
  798. ENDDO
  799. src_lev = leviX_msr
  800. rgtype = 'mass-aver'
  801. deallocate( field3d_h )
  802. nmw=idate(2)
  803. endif
  804. !
  805. ! December
  806. !
  807. if(nmw .eq. 12) then
  808. nmw=idate(2)-1
  809. WRITE(filemon,'(a,i2)')'ozone',nmw
  810. CALL MDF_Open( TRIM(o3vmr_fname), MDF_NETCDF, MDF_READ, hid, status )
  811. IF_NOTOK_RETURN(status=1)
  812. CALL MDF_Inq_VarID( hid,TRIM(filemon), varid, status )
  813. IF_NOTOK_RETURN(status=1)
  814. CALL MDF_Get_Var( hid, varid, field3d_h(1,:,:), status )
  815. IF_NOTOK_RETURN(status=1)
  816. ! Flip the data over (upside down), since leviX_msr, associated with
  817. ! field3d when regridding below (Fill3D), is flipped w/r/t to levi
  818. ! [it is the case, since ecstring starts with "ec" and not "tm"
  819. ! --see grid_type_hyb.F90--]
  820. DO k=1,inp_levs
  821. field3d_pm(1,:,k)=field3d_h(1,:,inp_levs+1-k)
  822. ENDDO
  823. nmw=12
  824. WRITE(filemon,'(a,i2)')'ozone',nmw
  825. CALL MDF_Inq_VarID( hid,TRIM(filemon) , varid, status )
  826. IF_NOTOK_RETURN(status=1)
  827. CALL MDF_Get_Var( hid, varid, field3d_h(1,:,:), status )
  828. IF_NOTOK_RETURN(status=1)
  829. CALL MDF_Close( hid, status )
  830. IF_NOTOK_RETURN(status=1)
  831. DO k=1,inp_levs
  832. field3d(1,:,k)=field3d_h(1,:,inp_levs+1-k)
  833. ENDDO
  834. nmw=1
  835. WRITE(filemon,'(a,i1)')'ozone',nmw
  836. CALL MDF_Open( TRIM(o3vmr_fnamenm), MDF_NETCDF, MDF_READ, hid, status )
  837. IF_NOTOK_RETURN(status=1)
  838. CALL MDF_Inq_VarID( hid, TRIM(filemon), varid, status )
  839. IF_NOTOK_RETURN(status=1)
  840. CALL MDF_Get_Var( hid, varid, field3d_h(1,:,:), status )
  841. IF_NOTOK_RETURN(status=1)
  842. CALL MDF_Close( hid, status )
  843. IF_NOTOK_RETURN(status=1)
  844. DO k=1,inp_levs
  845. field3d_nm(1,:,k)=field3d_h(1,:,inp_levs+1-k)
  846. ENDDO
  847. src_lev = leviX_msr
  848. rgtype = 'mass-aver'
  849. deallocate( field3d_h )
  850. endif
  851. ELSE ! use other file already remapped to model levels (e.g. o3vmr2000_tropo25.nc4)
  852. allocate( field3d(1, nlat180, lm(1) ))
  853. field3d=0.0
  854. o3vmr_fname=o3vmr_dirname
  855. CALL MDF_Open( TRIM(o3vmr_fname), MDF_NETCDF, MDF_READ, hid, status )
  856. IF_NOTOK_RETURN(status=1)
  857. !FIXME CALL MDF_Inq_VarID( hid, "idate(2)", varid, status )
  858. !FIXME IF_NOTOK_RETURN(status=1)
  859. CALL MDF_Get_Var( hid, varid, field3d(1,:,:), status )
  860. IF_NOTOK_RETURN(status=1)
  861. CALL MDF_Close( hid, status )
  862. IF_NOTOK_RETURN(status=1)
  863. src_lev = levi
  864. rgtype = 'area-aver'
  865. ENDIF
  866. ! Coarsen/distribute to each 1 resolution
  867. ALLOCATE( sp_z(1,jm(1)) ) ! dummy surface pressure:
  868. sp_z = p0 ! 1e5 Pa
  869. CALL Fill3D( lli_z(1), levi, 'n', sp_z, wrk3dpm_ML, &
  870. lli_z(iglbsfc), src_lev, field3d_pm, rgtype, status )
  871. CALL Fill3D( lli_z(1), levi, 'n', sp_z, wrk3d_ML, &
  872. lli_z(iglbsfc), src_lev, field3d, rgtype, status )
  873. CALL Fill3D( lli_z(1), levi, 'n', sp_z, wrk3dnm_ML, &
  874. lli_z(iglbsfc), src_lev, field3d_nm, rgtype, status )
  875. ENDIF
  876. IF_NOTOK_RETURN(status=1)
  877. deallocate( sp_z )
  878. deallocate( field3d_pm)
  879. deallocate( field3d )
  880. deallocate( field3d_nm)
  881. END IF ROOT
  882. ! scatter along latitude direction, then broadcast
  883. wrk2d_ML = wrk3dpm_ML(1,:,:) ! reshape
  884. CALL SCATTER_I_BAND( dgrid(1), o3vmrpm(1)%d23, wrk2d_ML, status )
  885. IF_NOTOK_RETURN(status=1)
  886. CALL PAR_BROADCAST( o3vmrpm(1)%d23, status, row=.TRUE. )
  887. IF_NOTOK_RETURN(status=1)
  888. wrk2d_ML = wrk3d_ML(1,:,:) ! reshape
  889. CALL SCATTER_I_BAND( dgrid(1), o3vmr(1)%d23, wrk2d_ML, status )
  890. IF_NOTOK_RETURN(status=1)
  891. CALL PAR_BROADCAST( o3vmr(1)%d23, status, row=.TRUE. )
  892. IF_NOTOK_RETURN(status=1)
  893. wrk2d_ML = wrk3dnm_ML(1,:,:) ! reshape
  894. CALL SCATTER_I_BAND( dgrid(1), o3vmrnm(1)%d23, wrk2d_ML, status )
  895. IF_NOTOK_RETURN(status=1)
  896. CALL PAR_BROADCAST( o3vmrnm(1)%d23, status, row=.TRUE. )
  897. IF_NOTOK_RETURN(status=1)
  898. !--------------------------------------------------
  899. ! ** O3 DU
  900. !--------------------------------------------------
  901. IF (use_o3du) THEN
  902. IF(isRoot) THEN
  903. ! o3du only required for 40 or 62 levels
  904. inp_levs = lme
  905. ALLOCATE( field3d (1, nlat180, inp_levs) )
  906. ALLOCATE( field3d_h(1, nlat180, inp_levs) )
  907. nmw=idate(2)-1 ! pick out right month in file
  908. WRITE(o3du_fname,'(a,"msr2_o3du",i4,"_",i2,".nc4")')TRIM(o3du_dirname),idate(1),inp_levs
  909. IF (nmw.LT.10) THEN
  910. WRITE(filemon,'(a,i1)')'ozone', idate(2)
  911. ELSE
  912. WRITE(filemon,'(a,i2)')'ozone', idate(2)
  913. ENDIF
  914. CALL MDF_Open( TRIM(o3du_fname), MDF_NETCDF, MDF_READ, hid, status )
  915. IF_NOTOK_RETURN(status=1)
  916. CALL MDF_Inq_VarID( hid, TRIM(filemon), varid, status )
  917. IF_NOTOK_RETURN(status=1)
  918. CALL MDF_Get_Var( hid, varid, field3d_h, status )
  919. IF_NOTOK_RETURN(status=1)
  920. CALL MDF_Close( hid, status )
  921. IF_NOTOK_RETURN(status=1)
  922. ! flip data so that they are on the leviX levels
  923. DO k=1,inp_levs
  924. field3d(1,:,k)=field3d_h(1,:,inp_levs+1-k)
  925. ENDDO
  926. ! remap to model levels
  927. ALLOCATE( sp_z(1,jm(1)) )
  928. sp_z = p0 ! 1e5 Pa
  929. ! Should we really use leviX_msr here?
  930. ! Doesn't seem to match with the use of lme above.
  931. ! Anyway, o3du is normally not used anymore,
  932. ! since the vertical resolution has increased.
  933. CALL Fill3D( lli_z(1), levi, 'n', sp_z, wrk3d_ML, &
  934. lli_z(iglbsfc), leviX_msr, field3d, 'area-aver', status )
  935. IF_NOTOK_RETURN(status=1)
  936. DEALLOCATE( sp_z )
  937. DEALLOCATE( field3d )
  938. DEALLOCATE( field3d_h )
  939. END IF
  940. ! scatter along latitude direction, then broadcast
  941. wrk2d_ML = wrk3d_ML(1,:,:)
  942. CALL SCATTER_I_BAND( dgrid(1), o3du(1)%d23, wrk2d_ML, status )
  943. IF_NOTOK_RETURN(status=1)
  944. CALL PAR_BROADCAST( o3du(1)%d23, status, row=.TRUE. )
  945. IF_NOTOK_RETURN(status=1)
  946. ENDIF ! use_o3du
  947. !--------------------------------------------------
  948. ! ** CH4 HALOE
  949. !--------------------------------------------------
  950. IF (use_HALOE) THEN
  951. IF(isRoot) THEN
  952. inp_levs = LeviX_haloe%nlev
  953. if (LCMIP6_CH4) then
  954. allocate(ch4_hist(1,2015)) ! years 0-2014
  955. WRITE(ch4_hist_fname,'(a,"mole-fraction-of-methane-in-air_input4MIPs_GHGConcentrations_CMIP_UoM-CMIP-1-2-0_gr1-GMNHSH_0000-2014.nc")')TRIM(cmip6_ch4_dirname_strat)
  956. write(gol,'(" Boundary - reading CH4 file: ",a)') trim(ch4_hist_fname); call goPr
  957. CALL MDF_Open( TRIM(ch4_hist_fname), MDF_NETCDF, MDF_READ, hid, status )
  958. IF_NOTOK_RETURN(status=1)
  959. CALL MDF_Inq_VarID( hid, TRIM('mole_fraction_of_methane_in_air'), varid, status )
  960. IF_NOTOK_RETURN(status=1)
  961. CALL MDF_Get_Var( hid, varid, ch4_hist(1,:), status, start = (/1,1/), count = (/1,2015/) )
  962. IF_NOTOK_RETURN(status=1)
  963. CALL MDF_Close( hid, status )
  964. IF_NOTOK_RETURN(status=1)
  965. ! Following the recommendation by Meinshausen et al. (GMDD, 2016),
  966. ! a one year delay is assumed between the surface and the stratosphere.
  967. ! The HALOE climatology is based on measurements
  968. ! from October 1991 to August 2002.
  969. ! HALOE therefore provides the full annual cycle
  970. ! for the 10-year period 1992-2001.
  971. ! Since our scaling is based on annual mean concentrations,
  972. ! we take this period as our reference.
  973. ! To account for the delay of one year,
  974. ! this translates into 1991-2000 at the surface.
  975. ch4_ref=0.
  976. do iyear=1991,2000
  977. ! First year of ch4_hist is the year 0
  978. ch4_ref=ch4_ref+ch4_hist(1,iyear+1)
  979. enddo
  980. ch4_ref=ch4_ref/10.
  981. if ( ( (.not.ch4_fixyear) .and. &
  982. ( (idate(1) == 2015 .and. idate(2) == 12) .or. (idate(1) > 2015 ) ) ) .or. &
  983. ( ch4_fixyear .and. (ch4_year >= 2015) ) ) then
  984. select case (trim(ssp_name_ch4))
  985. case ('SSP1-1.9')
  986. WRITE(ch4_sce_fname,'(a,"mole-fraction-of-methane-in-air_input4MIPs_GHGConcentrations_ScenarioMIP_UoM-IMAGE-ssp119-1-2-1_gr1-GMNHSH_2015-2500.nc")')TRIM(cmip6_ch4_dirname_strat)
  987. case ("SSP1-2.6", "SSP1-2.6-Ext")
  988. WRITE(ch4_sce_fname,'(a,"mole-fraction-of-methane-in-air_input4MIPs_GHGConcentrations_ScenarioMIP_UoM-IMAGE-ssp126-1-2-1_gr1-GMNHSH_2015-2500.nc")')TRIM(cmip6_ch4_dirname_strat)
  989. case ("SSP2-4.5")
  990. WRITE(ch4_sce_fname,'(a,"mole-fraction-of-methane-in-air_input4MIPs_GHGConcentrations_ScenarioMIP_UoM-MESSAGE-GLOBIOM-ssp245-1-2-1_gr1-GMNHSH_2015-2500.nc")')TRIM(cmip6_ch4_dirname_strat)
  991. case ("SSP3-7.0")
  992. WRITE(ch4_sce_fname,'(a,"mole-fraction-of-methane-in-air_input4MIPs_GHGConcentrations_ScenarioMIP_UoM-AIM-ssp370-1-2-1_gr1-GMNHSH_2015-2500.nc")')TRIM(cmip6_ch4_dirname_strat)
  993. case ("SSP3-LowNTCF")
  994. WRITE(ch4_sce_fname,'(a,"mole-fraction-of-methane-in-air_input4MIPs_GHGConcentrations_AerChemMIP_UoM-AIM-ssp370-lowNTCF-1-2-1_gr1-GMNHSH_2015-2500.nc")')TRIM(cmip6_ch4_dirname_strat)
  995. case ("SSP4-3.4")
  996. WRITE(ch4_sce_fname,'(a,"mole-fraction-of-methane-in-air_input4MIPs_GHGConcentrations_ScenarioMIP_UoM-GCAM4-ssp434-1-2-1_gr1-GMNHSH_2015-2500.nc")')TRIM(cmip6_ch4_dirname_strat)
  997. case ("SSP4-6.0")
  998. WRITE(ch4_sce_fname,'(a,"mole-fraction-of-methane-in-air_input4MIPs_GHGConcentrations_ScenarioMIP_UoM-GCAM4-ssp460-1-2-1_gr1-GMNHSH_2015-2500.nc")')TRIM(cmip6_ch4_dirname_strat)
  999. case ("SSP5-3.4-OS", "SSP5-3.4-OS-Ext")
  1000. WRITE(ch4_sce_fname,'(a,"mole-fraction-of-methane-in-air_input4MIPs_GHGConcentrations_ScenarioMIP_UoM-REMIND-MAGPIE-ssp534-over-1-2-1_gr1-GMNHSH_2015-2500.nc")')TRIM(cmip6_ch4_dirname_strat)
  1001. case ("SSP5-8.5","SSP5-8.5-Ext")
  1002. WRITE(ch4_sce_fname,'(a,"mole-fraction-of-methane-in-air_input4MIPs_GHGConcentrations_ScenarioMIP_UoM-REMIND-MAGPIE-ssp585-1-2-1_gr1-GMNHSH_2015-2500.nc")')TRIM(cmip6_ch4_dirname_strat)
  1003. case default
  1004. write (gol,'("CH4 global annual means not implemented for this scenario")') ; call goErr
  1005. status=1; TRACEBACK; return
  1006. end select
  1007. allocate(ch4_sce(1,486)) ! years 2015-2500
  1008. write(gol,'(" Boundary - reading CH4 file: ",a)') trim(ch4_sce_fname); call goPr
  1009. CALL MDF_Open( TRIM(ch4_sce_fname), MDF_NETCDF, MDF_READ, hid, status )
  1010. IF_NOTOK_RETURN(status=1)
  1011. CALL MDF_Inq_VarID( hid, TRIM('mole_fraction_of_methane_in_air'), varid, status )
  1012. IF_NOTOK_RETURN(status=1)
  1013. CALL MDF_Get_Var( hid, varid, ch4_sce(1,:), status, start = (/1,1/), count = (/1,486/) )
  1014. IF_NOTOK_RETURN(status=1)
  1015. CALL MDF_Close( hid, status )
  1016. IF_NOTOK_RETURN(status=1)
  1017. endif
  1018. ! Following CMIP methodology,
  1019. ! surface concentrations before 1850
  1020. ! are set to their 1850 level.
  1021. !
  1022. ! target_year is the year used in the scaling
  1023. ! of surface concentrations.
  1024. ! scale factor for previous month:
  1025. if (.not.ch4_fixyear) then
  1026. target_year = MIN(2500,MAX(idate(1)-1,1850))
  1027. if(idate(2) .eq. 1) then
  1028. target_year = MIN(2500,MAX(idate(1)-2,1850))
  1029. endif
  1030. else
  1031. target_year = MIN(2500,MAX(ch4_year,1850))
  1032. endif
  1033. write (gol,*) 'Stratospheric CH4 year for previous month: ', target_year; call goPr
  1034. if (target_year .le. 2014) then
  1035. ch4_scale_pm=ch4_hist(1,target_year+1)/ch4_ref
  1036. else
  1037. ch4_scale_pm=ch4_sce(1,target_year-2014)/ch4_ref
  1038. endif
  1039. ! scale factor for the current month:
  1040. if (.not.ch4_fixyear) then
  1041. target_year = MIN(2500,MAX(idate(1)-1,1850))
  1042. else
  1043. target_year = MIN(2500,MAX(ch4_year,1850))
  1044. endif
  1045. write (gol,*) 'Stratospheric CH4 year for current month: ', target_year; call goPr
  1046. if (target_year .le. 2014) then
  1047. ch4_scale=ch4_hist(1,target_year+1)/ch4_ref
  1048. else
  1049. ch4_scale=ch4_sce(1,target_year-2014)/ch4_ref
  1050. endif
  1051. ! scale factor for the next month:
  1052. if (.not.ch4_fixyear) then
  1053. target_year = MIN(2500,MAX(idate(1)-1,1850))
  1054. if(idate(2) .eq. 12) then
  1055. target_year = MIN(2500,MAX(idate(1),1850))
  1056. endif
  1057. else
  1058. target_year = MIN(2500,MAX(ch4_year,1850))
  1059. endif
  1060. write (gol,*) 'Stratospheric CH4 year for next month: ', target_year; call goPr
  1061. if (target_year .le. 2014) then
  1062. ch4_scale_nm=ch4_hist(1,target_year+1)/ch4_ref
  1063. else
  1064. ch4_scale_nm=ch4_sce(1,target_year-2014)/ch4_ref
  1065. endif
  1066. deallocate(ch4_hist)
  1067. if (allocated(ch4_sce)) deallocate(ch4_sce)
  1068. else
  1069. ! The pre-CMIP6 calculation of the scale factors is not fully
  1070. ! consistent with the new implementation for CMIP6.
  1071. ! This could be changed, but I haven't done that.
  1072. ! I would propose to use LCMIP6_CH4 by default,
  1073. ! and remove the scaling based on RCP6 from the code.
  1074. write (gol,'("WARNING - Scaling of stratospheric CH4 concentrations from HALOE")') ; call goPr
  1075. write (gol,'("WARNING - based on old implementation, which uses RCP6 for years later than 2005.")') ; call goPr
  1076. if (ch4_fixyear) then
  1077. write (gol,'("ERROR - Fixing CH4 concentrations to a specific year")') ; call goErr
  1078. write (gol,'("ERROR - only works for CMIP6 data")') ; call goErr
  1079. status=1; TRACEBACK; return
  1080. endif
  1081. ! The scale factor for the previous month
  1082. ! used to be based on the previous year
  1083. ! irrespective of the month.
  1084. ! This is incorrect and has been fixed:
  1085. !valid_year = MIN(2035,MAX(idate(1)-1,1999))
  1086. valid_year = MIN(2035,MAX(idate(1),1999))
  1087. if(idate(2) .eq. 1) then
  1088. valid_year = MIN(2035,MAX(idate(1)-1,1999))
  1089. endif
  1090. ch4_scale_pm=RCP6_CH4_STRAT(valid_year-1998)
  1091. ! scale factor for the current month
  1092. valid_year = MIN(2035,MAX(idate(1),1999))
  1093. ch4_scale=RCP6_CH4_STRAT(valid_year-1998)
  1094. ! scale factor for the next month
  1095. valid_year = MIN(2035,MAX(idate(1),1999))
  1096. if(idate(2) .eq. 12) then
  1097. valid_year = MIN(2035,MAX(idate(1)+1,1999))
  1098. endif
  1099. ch4_scale_nm=RCP6_CH4_STRAT(valid_year-1998)
  1100. endif
  1101. allocate( field3d_pm (1, nlat180, inp_levs) )
  1102. allocate( field3d (1, nlat180, inp_levs) )
  1103. allocate( field3d_nm (1, nlat180, inp_levs) )
  1104. allocate( field3d_h (1, nlat180, inp_levs) )
  1105. field3d_pm=0.0 ; field3d=0.0 ; field3d_nm=0.0 ; field3d_h=0.0
  1106. !
  1107. ! For each month, data are read, then flipped over (upside down), otherwise Fill3D
  1108. ! doesn't work properly, and scaled up to account for growth from 2000.
  1109. !
  1110. ! - Previous month
  1111. !
  1112. if(idate(2) .eq. 1) then
  1113. nmw=12
  1114. WRITE(filemon,'(a,i2)')'haloe',nmw
  1115. else
  1116. nmw=idate(2)-1
  1117. if(idate(2) .lt. 11) WRITE(filemon,'(a,i1)')'haloe',nmw
  1118. if(idate(2) .gt. 10) WRITE(filemon,'(a,i2)')'haloe',nmw
  1119. endif
  1120. !
  1121. WRITE(ch4vmr_fname,'(a,"haloe_ch4vmr_",i2,".nc4")')TRIM(ch4vmr_dirname),inp_levs
  1122. CALL MDF_Open( TRIM(ch4vmr_fname), MDF_NETCDF, MDF_READ, hid, status )
  1123. IF_NOTOK_RETURN(status=1)
  1124. CALL MDF_Inq_VarID( hid, TRIM(filemon), varid, status )
  1125. IF_NOTOK_RETURN(status=1)
  1126. CALL MDF_Get_Var( hid, varid, field3d_h(1,:,:), status )
  1127. IF_NOTOK_RETURN(status=1)
  1128. DO k=1,inp_levs
  1129. field3d_pm(1,:,k)=field3d_h(1,:,inp_levs+1-k)*ch4_scale_pm
  1130. ENDDO
  1131. !
  1132. ! - Current month
  1133. !
  1134. nmw=idate(2)
  1135. IF (nmw.LT.10) THEN
  1136. WRITE(filemon,'(a,i1)')'haloe', nmw
  1137. ELSE
  1138. WRITE(filemon,'(a,i2)')'haloe', nmw
  1139. ENDIF
  1140. CALL MDF_Inq_VarID( hid, TRIM(filemon), varid, status )
  1141. IF_NOTOK_RETURN(status=1)
  1142. CALL MDF_Get_Var( hid, varid, field3d_h(1,:,:), status )
  1143. IF_NOTOK_RETURN(status=1)
  1144. DO k=1,inp_levs
  1145. field3d(1,:,k)=field3d_h(1,:,inp_levs+1-k)*ch4_scale
  1146. ENDDO
  1147. !
  1148. ! - Next month
  1149. !
  1150. nmw=idate(2)+1
  1151. if(idate(2) .eq. 12) then
  1152. nmw=1
  1153. endif
  1154. if(nmw .lt. 10) WRITE(filemon,'(a,i1)')'haloe', nmw
  1155. if(nmw .gt. 9) WRITE(filemon,'(a,i2)')'haloe', nmw
  1156. CALL MDF_Inq_VarID( hid, TRIM(filemon), varid, status )
  1157. IF_NOTOK_RETURN(status=1)
  1158. CALL MDF_Get_Var( hid, varid, field3d_h(1,:,:), status )
  1159. IF_NOTOK_RETURN(status=1)
  1160. CALL MDF_Close( hid, status )
  1161. IF_NOTOK_RETURN(status=1)
  1162. DO k=1,inp_levs
  1163. field3d_nm(1,:,k)=field3d_h(1,:,inp_levs+1-k)*ch4_scale_nm
  1164. ENDDO
  1165. !
  1166. ! Coarsen or distribute on region #1 the three datasets
  1167. !
  1168. ALLOCATE( sp_z(1,jm(1)) )
  1169. sp_z = p0 ! 1e5 Pa
  1170. CALL Fill3D( lli_z(1), levi, 'n', sp_z, wrk3dpm_ML, &
  1171. lli_z(iglbsfc), leviX_haloe, field3d_pm, 'mass-aver', status )
  1172. CALL Fill3D( lli_z(1), levi, 'n', sp_z, wrk3d_ML, &
  1173. lli_z(iglbsfc), leviX_haloe, field3d, 'mass-aver', status )
  1174. CALL Fill3D( lli_z(1), levi, 'n', sp_z, wrk3dnm_ML, &
  1175. lli_z(iglbsfc), leviX_haloe, field3d_nm, 'mass-aver', status )
  1176. IF_NOTOK_RETURN(status=1)
  1177. ! clear allocatables
  1178. deallocate( sp_z )
  1179. deallocate( field3d_pm )
  1180. deallocate( field3d )
  1181. deallocate( field3d_nm )
  1182. deallocate( field3d_h )
  1183. END IF ! Read & Regrid on Root
  1184. ! Scatter along latitude direction, then broadcast to other cores in same zonal band
  1185. wrk2d_ML = wrk3dpm_ML(1,:,:)
  1186. CALL SCATTER_I_BAND( dgrid(1), ch4vmrpm(1)%d23, wrk2d_ML, status )
  1187. IF_NOTOK_RETURN(status=1)
  1188. CALL PAR_BROADCAST( ch4vmrpm(1)%d23, status, row=.TRUE. )
  1189. IF_NOTOK_RETURN(status=1)
  1190. wrk2d_ML = wrk3d_ML(1,:,:)
  1191. CALL SCATTER_I_BAND( dgrid(1), ch4vmr(1)%d23, wrk2d_ML, status )
  1192. IF_NOTOK_RETURN(status=1)
  1193. CALL PAR_BROADCAST( ch4vmr(1)%d23, status, row=.TRUE. )
  1194. IF_NOTOK_RETURN(status=1)
  1195. wrk2d_ML = wrk3dnm_ML(1,:,:)
  1196. CALL SCATTER_I_BAND( dgrid(1), ch4vmrnm(1)%d23, wrk2d_ML, status )
  1197. IF_NOTOK_RETURN(status=1)
  1198. CALL PAR_BROADCAST( ch4vmrnm(1)%d23, status, row=.TRUE. )
  1199. IF_NOTOK_RETURN(status=1)
  1200. ENDIF ! use_HALO
  1201. !--------------------------------------------------
  1202. ! ** ODIN climatology : HNO3/O3 and CO/O3 ratios
  1203. !--------------------------------------------------
  1204. IF (use_ODIN) then
  1205. inp_levs=4
  1206. !--------------------------------------------------
  1207. ! * ODIN climatology : HNO3/O3
  1208. !--------------------------------------------------
  1209. IF ( isRoot ) THEN
  1210. ! open, read ratio
  1211. CALL MDF_Open( TRIM(covmr_dirname)//'/ODIN_Climatology_HNO3_O3_4levels.nc4', MDF_NETCDF, MDF_READ, hid, status )
  1212. IF_NOTOK_RETURN(status=1)
  1213. CALL MDF_Inq_VarID( hid, 'Ratio', varid, status )
  1214. IF_NOTOK_RETURN(status=1)
  1215. CALL MDF_Get_Var( hid,varid, field3d_r4, status )
  1216. IF_NOTOK_RETURN(status=1)
  1217. pm=idate(2)-1
  1218. ! previous month
  1219. allocate( field3d(1,nlat180,4) )
  1220. if(idate(2) .eq. 1) field3d(1,:,:)=field3d_r4(:,:,12)
  1221. if(idate(2) .gt. 1) field3d(1,:,:)=field3d_r4(:,:,pm)
  1222. ! remap
  1223. DO i=1,inp_levs
  1224. CALL FillGrid( lli_z(1), 'n', wrk3dratiopm(:,:,i), &
  1225. lli_z(iglbsfc), 'n', field3d(:,:,i), 'area-aver', status )
  1226. IF_NOTOK_RETURN(status=1)
  1227. END DO
  1228. ! current month
  1229. field3d(1,:,:)=field3d_r4(:,:,idate(2))
  1230. ! remap
  1231. DO i=1,inp_levs
  1232. CALL FillGrid( lli_z(1), 'n', wrk3dratio(:,:,i), &
  1233. lli_z(iglbsfc), 'n', field3d(:,:,i), 'area-aver', status )
  1234. IF_NOTOK_RETURN(status=1)
  1235. END DO
  1236. nm=idate(2)+1
  1237. if(idate(2) .lt. 12) field3d(1,:,:)=field3d_r4(:,:,nm)
  1238. if(idate(2) .eq. 12) field3d(1,:,:)=field3d_r4(:,:,1)
  1239. ! remap
  1240. DO i=1,inp_levs
  1241. CALL FillGrid( lli_z(1), 'n', wrk3drationm(:,:,i), &
  1242. lli_z(iglbsfc), 'n', field3d(:,:,i), 'area-aver', status )
  1243. IF_NOTOK_RETURN(status=1)
  1244. END DO
  1245. CALL MDF_Close( hid, status )
  1246. IF_NOTOK_RETURN(status=1)
  1247. DEALLOCATE( field3d )
  1248. END IF ! root
  1249. ! Scatter along latitude direction, then broadcast to other cores in same zonal band
  1250. wrk2d_4L = wrk3dratiopm(1,:,:)
  1251. CALL SCATTER_I_BAND( dgrid(1), odin_hno3_o3_pm(1)%d23(:,:), wrk2d_4L, status )
  1252. IF_NOTOK_RETURN(status=1)
  1253. CALL PAR_BROADCAST( odin_hno3_o3_pm(1)%d23, status, row=.TRUE. )
  1254. IF_NOTOK_RETURN(status=1)
  1255. wrk2d_4L = wrk3dratio(1,:,:)
  1256. CALL SCATTER_I_BAND( dgrid(1), odin_hno3_o3(1)%d23(:,:), wrk2d_4L, status )
  1257. IF_NOTOK_RETURN(status=1)
  1258. CALL PAR_BROADCAST( odin_hno3_o3(1)%d23, status, row=.TRUE. )
  1259. IF_NOTOK_RETURN(status=1)
  1260. wrk2d_4L = wrk3drationm(1,:,:)
  1261. CALL SCATTER_I_BAND( dgrid(1), odin_hno3_o3_nm(1)%d23(:,:), wrk2d_4L, status )
  1262. IF_NOTOK_RETURN(status=1)
  1263. CALL PAR_BROADCAST( odin_hno3_o3_nm(1)%d23, status, row=.TRUE. )
  1264. IF_NOTOK_RETURN(status=1)
  1265. !--------------------------------------------------
  1266. ! * ODIN climatology : CO O3
  1267. !--------------------------------------------------
  1268. IF ( isRoot ) THEN
  1269. ! open, read ratio
  1270. CALL MDF_Open(TRIM(covmr_dirname)//'ODIN_CO_O3_ratio_4levels.nc4', MDF_NETCDF, MDF_READ, hid, status )
  1271. IF_NOTOK_RETURN(status=1)
  1272. CALL MDF_Inq_VarID( hid, 'CO_O3_ratio', varid, status )
  1273. IF_NOTOK_RETURN(status=1)
  1274. CALL MDF_Get_Var( hid, varid, field3d_r4, status )
  1275. IF_NOTOK_RETURN(status=1)
  1276. allocate( field3d(1,nlat180,4) ) ! 1D array along latitude
  1277. pm=idate(2)-1
  1278. ! previous month
  1279. if(idate(2) .eq. 1) field3d(1,:,:)=field3d_r4(:,:,12)
  1280. if(idate(2) .gt. 1) field3d(1,:,:)=field3d_r4(:,:,pm)
  1281. ! remap
  1282. DO i=1,inp_levs
  1283. CALL FillGrid( lli_z(1), 'n', wrk3dratiopm(:,:,i), &
  1284. lli_z(iglbsfc), 'n', field3d(:,:,i), 'area-aver', status )
  1285. IF_NOTOK_RETURN(status=1)
  1286. END DO
  1287. ! current month
  1288. field3d(1,:,:)=field3d_r4(:,:,idate(2))
  1289. ! remap
  1290. DO i=1,inp_levs
  1291. CALL FillGrid( lli_z(1), 'n', wrk3dratio(:,:,i), &
  1292. lli_z(iglbsfc), 'n', field3d(:,:,i), 'area-aver', status )
  1293. IF_NOTOK_RETURN(status=1)
  1294. END DO
  1295. nm=idate(2)+1
  1296. ! correct month
  1297. if(idate(2) .lt. 12) field3d(1,:,:)=field3d_r4(:,:,nm)
  1298. if(idate(2) .eq. 12) field3d(1,:,:)=field3d_r4(:,:,1)
  1299. ! remap
  1300. DO i=1,inp_levs
  1301. CALL FillGrid( lli_z(1), 'n', wrk3drationm(:,:,i), &
  1302. lli_z(iglbsfc), 'n', field3d(:,:,i), 'area-aver', status )
  1303. IF_NOTOK_RETURN(status=1)
  1304. END DO
  1305. CALL MDF_Close( hid, status )
  1306. IF_NOTOK_RETURN(status=1)
  1307. deallocate( field3d )
  1308. END IF ! root
  1309. ! scatter along latitude direction, then broadcast
  1310. wrk2d_4L = wrk3dratiopm(1,:,:)
  1311. CALL SCATTER_I_BAND( dgrid(1), odin_co_o3_pm(1)%d23(:,:), wrk2d_4L, status )
  1312. IF_NOTOK_RETURN(status=1)
  1313. CALL PAR_BROADCAST( odin_co_o3_pm(1)%d23, status, row=.TRUE. )
  1314. IF_NOTOK_RETURN(status=1)
  1315. wrk2d_4L = wrk3dratio(1,:,:)
  1316. CALL SCATTER_I_BAND( dgrid(1), odin_co_o3(1)%d23(:,:), wrk2d_4L, status )
  1317. IF_NOTOK_RETURN(status=1)
  1318. CALL PAR_BROADCAST( odin_co_o3(1)%d23, status, row=.TRUE. )
  1319. IF_NOTOK_RETURN(status=1)
  1320. ! scatter along latitude direction, then broadcast
  1321. wrk2d_4L = wrk3drationm(1,:,:)
  1322. CALL SCATTER_I_BAND( dgrid(1), odin_co_o3_nm(1)%d23(:,:), wrk2d_4L, status )
  1323. IF_NOTOK_RETURN(status=1)
  1324. CALL PAR_BROADCAST( odin_co_o3_nm(1)%d23, status, row=.TRUE. )
  1325. IF_NOTOK_RETURN(status=1)
  1326. ELSE
  1327. !--------------------------------------------------
  1328. ! ** UARS climatology : HNO3 O3 (Fallback on this one if we are not using ODIN)
  1329. !--------------------------------------------------
  1330. IF ( isRoot ) THEN
  1331. ALLOCATE( field3d(1,nlat180,1) ) ! 1D array along latitude
  1332. field3d = 0.0
  1333. CALL MDF_Open( TRIM(inputdir)//'/boundary/HNO3_top/uars_ratio.nc4', MDF_NETCDF, MDF_READ, hid, status )
  1334. IF_NOTOK_RETURN(status=1)
  1335. !FIXME CALL MDF_Inq_VarID( hid, "idate(2)", varid, status )
  1336. !FIXME IF_NOTOK_RETURN(status=1)
  1337. CALL MDF_Get_Var( hid, varid, field3d(:,:,1), status )
  1338. IF_NOTOK_RETURN(status=1)
  1339. CALL MDF_Close( hid, status )
  1340. IF_NOTOK_RETURN(status=1)
  1341. ! remap
  1342. CALL FillGrid( lli_z(1), 'n', wrk3dratio(:,:,1), &
  1343. lli_z(iglbsfc), 'n', field3d(:,:,1), 'area-aver', status )
  1344. IF_NOTOK_RETURN(status=1)
  1345. DEALLOCATE( field3d )
  1346. END IF ! root
  1347. ! scatter along latitude direction, then broadcast
  1348. wrk2d_ML(:,1) = wrk3dratio(1,:,1)
  1349. CALL SCATTER_I_BAND( dgrid(1), odin_hno3_o3(1)%d23(:,1), wrk2d_ML(:,1), status )
  1350. IF_NOTOK_RETURN(status=1)
  1351. CALL PAR_BROADCAST( odin_hno3_o3(1)%d23(:,1), status, row=.TRUE. )
  1352. IF_NOTOK_RETURN(status=1)
  1353. ENDIF
  1354. ! ------------------------------------------------
  1355. ! Annual mean CO2 mixing ratios for pH calculation
  1356. ! used in aqueous chemistry.
  1357. !-------------------------------------------------
  1358. ! To avoid MPI communication,
  1359. ! reading is done on all processors,
  1360. ! but only once per year.
  1361. !-------------------------------------------------
  1362. if (LCMIP6_CO2 .and. newyr) then
  1363. IF ( isRoot ) THEN
  1364. ! Following CMIP methodology,
  1365. ! CO2 mixing ratios before 1850
  1366. ! are set to their 1850 level.
  1367. !
  1368. if (.not.co2_fixyear) then
  1369. target_year = MIN(2500,MAX(idate(1),1850))
  1370. else
  1371. target_year = MIN(2500,MAX(co2_year,1850))
  1372. endif
  1373. write (gol,*) 'In pH calculation, using CO2 for year: ', target_year; call goPr
  1374. if (target_year .le. 2014) then
  1375. allocate(co2_hist(1,2015)) ! years 0-2014
  1376. WRITE(co2_hist_fname,'(a,"mole-fraction-of-carbon-dioxide-in-air_input4MIPs_GHGConcentrations_CMIP_UoM-CMIP-1-2-0_gr1-GMNHSH_0000-2014.nc")')TRIM(cmip6_co2_dirname)
  1377. write(gol,'(" Boundary - reading CO2 file: ",a)') trim(co2_hist_fname); call goPr
  1378. CALL MDF_Open( TRIM(co2_hist_fname), MDF_NETCDF, MDF_READ, hid, status )
  1379. IF_NOTOK_RETURN(status=1)
  1380. CALL MDF_Inq_VarID( hid, TRIM('mole_fraction_of_carbon_dioxide_in_air'), varid, status )
  1381. IF_NOTOK_RETURN(status=1)
  1382. CALL MDF_Get_Var( hid, varid, co2_hist(1,:), status, start = (/1,1/), count = (/1,2015/) )
  1383. IF_NOTOK_RETURN(status=1)
  1384. CALL MDF_Close( hid, status )
  1385. IF_NOTOK_RETURN(status=1)
  1386. co2_glob=co2_hist(1,target_year+1)
  1387. IF (L1PCTCO2) THEN
  1388. ! 1% increase per year starting from the reference value for 1850.
  1389. ! A stepwise increase is applied from year to year.
  1390. ! This is consistent with prescribing CO2 mixing ratios as annual means.
  1391. ! In the first year of the 1pctCO2 simulation
  1392. ! the mixing ratio is increased by 1.01**0.5, i.e. by almost 0.5%.
  1393. ! Consistent with the implementation in IFS,
  1394. ! it is assumed that the 1pctCO2 simulation starts in 1850.
  1395. co2_glob = co2_glob * EXP((idate(1)-1850+0.5)*LOG(1.01))
  1396. ELSE IF (LA4xCO2) THEN
  1397. ! Constant 4x increase compared to the reference 1850 value.
  1398. co2_glob = 4. * co2_glob
  1399. ENDIF
  1400. deallocate(co2_hist)
  1401. else
  1402. select case (trim(ssp_name))
  1403. case ('SSP1-1.9')
  1404. WRITE(co2_sce_fname,'(a,"mole-fraction-of-carbon-dioxide-in-air_input4MIPs_GHGConcentrations_ScenarioMIP_UoM-IMAGE-ssp119-1-2-1_gr1-GMNHSH_2015-2500.nc")')TRIM(cmip6_co2_dirname)
  1405. case ("SSP1-2.6", "SSP1-2.6-Ext")
  1406. WRITE(co2_sce_fname,'(a,"mole-fraction-of-carbon-dioxide-in-air_input4MIPs_GHGConcentrations_ScenarioMIP_UoM-IMAGE-ssp126-1-2-1_gr1-GMNHSH_2015-2500.nc")')TRIM(cmip6_co2_dirname)
  1407. case ("SSP2-4.5")
  1408. WRITE(co2_sce_fname,'(a,"mole-fraction-of-carbon-dioxide-in-air_input4MIPs_GHGConcentrations_ScenarioMIP_UoM-MESSAGE-GLOBIOM-ssp245-1-2-1_gr1-GMNHSH_2015-2500.nc")')TRIM(cmip6_co2_dirname)
  1409. case ("SSP3-7.0")
  1410. WRITE(co2_sce_fname,'(a,"mole-fraction-of-carbon-dioxide-in-air_input4MIPs_GHGConcentrations_ScenarioMIP_UoM-AIM-ssp370-1-2-1_gr1-GMNHSH_2015-2500.nc")')TRIM(cmip6_co2_dirname)
  1411. ! NOT USED IN CMIP6 case ("SSP3-LowNTCF")
  1412. ! NOT USED IN CMIP6 WRITE(co2_sce_fname,'(a,"mole-fraction-of-carbon-dioxide-in-air_input4MIPs_GHGConcentrations_AerChemMIP_UoM-AIM-ssp370-lowNTCF-1-2-1_gr1-GMNHSH_2015-2500.nc")')TRIM(cmip6_co2_dirname)
  1413. case ("SSP4-3.4")
  1414. WRITE(co2_sce_fname,'(a,"mole-fraction-of-carbon-dioxide-in-air_input4MIPs_GHGConcentrations_ScenarioMIP_UoM-GCAM4-ssp434-1-2-1_gr1-GMNHSH_2015-2500.nc")')TRIM(cmip6_co2_dirname)
  1415. case ("SSP4-6.0")
  1416. WRITE(co2_sce_fname,'(a,"mole-fraction-of-carbon-dioxide-in-air_input4MIPs_GHGConcentrations_ScenarioMIP_UoM-GCAM4-ssp460-1-2-1_gr1-GMNHSH_2015-2500.nc")')TRIM(cmip6_co2_dirname)
  1417. case ("SSP5-3.4-OS", "SSP5-3.4-OS-Ext")
  1418. WRITE(co2_sce_fname,'(a,"mole-fraction-of-carbon-dioxide-in-air_input4MIPs_GHGConcentrations_ScenarioMIP_UoM-REMIND-MAGPIE-ssp534-over-1-2-1_gr1-GMNHSH_2015-2500.nc")')TRIM(cmip6_co2_dirname)
  1419. case ("SSP5-8.5","SSP5-8.5-Ext")
  1420. WRITE(co2_sce_fname,'(a,"mole-fraction-of-carbon-dioxide-in-air_input4MIPs_GHGConcentrations_ScenarioMIP_UoM-REMIND-MAGPIE-ssp585-1-2-1_gr1-GMNHSH_2015-2500.nc")')TRIM(cmip6_co2_dirname)
  1421. case default
  1422. write (gol,'("CO2 global annual means not implemented for this scenario")') ; call goErr
  1423. status=1; TRACEBACK; return
  1424. end select
  1425. allocate(co2_sce(1,486)) ! years 2015-2500
  1426. write(gol,'(" Boundary - reading CO2 file: ",a)') trim(co2_sce_fname); call goPr
  1427. CALL MDF_Open( TRIM(co2_sce_fname), MDF_NETCDF, MDF_READ, hid, status )
  1428. IF_NOTOK_RETURN(status=1)
  1429. CALL MDF_Inq_VarID( hid, TRIM('mole_fraction_of_carbon_dioxide_in_air'), varid, status )
  1430. IF_NOTOK_RETURN(status=1)
  1431. CALL MDF_Get_Var( hid, varid, co2_sce(1,:), status, start = (/1,1/), count = (/1,486/) )
  1432. IF_NOTOK_RETURN(status=1)
  1433. CALL MDF_Close( hid, status )
  1434. IF_NOTOK_RETURN(status=1)
  1435. co2_glob=co2_sce(1,target_year-2014)
  1436. deallocate(co2_sce)
  1437. endif
  1438. ENDIF ! root
  1439. CALL PAR_BROADCAST( co2_glob, status )
  1440. IF_NOTOK_RETURN(status=1)
  1441. write (gol,*) 'Annual mean CO2 mixing ratio (ppm) = ', co2_glob; call goPr
  1442. ENDIF
  1443. ! end timing:
  1444. call GO_Timer_End( itim_init, status )
  1445. IF_NOTOK_RETURN(status=1)
  1446. END IF
  1447. CALL goLabel()
  1448. status = 0
  1449. END SUBROUTINE BOUNDARY_INIT
  1450. !EOC
  1451. !--------------------------------------------------------------------------
  1452. ! TM5 !
  1453. !--------------------------------------------------------------------------
  1454. !BOP
  1455. !
  1456. ! !IROUTINE: BOUNDARY_DONE
  1457. !
  1458. ! !DESCRIPTION: deallocate arrays (budgets gathering/reduction is done in
  1459. ! chemistry/chemistry_done)
  1460. !\\
  1461. !\\
  1462. ! !INTERFACE:
  1463. !
  1464. SUBROUTINE BOUNDARY_DONE( status )
  1465. !
  1466. ! !USES:
  1467. !
  1468. USE partools, ONLY : isRoot
  1469. USE Grid, ONLY : Done
  1470. !
  1471. ! !OUTPUT PARAMETERS:
  1472. !
  1473. INTEGER, INTENT(out) :: status
  1474. !
  1475. ! !REVISION HISTORY:
  1476. ! 15 Jun 2012 - P. Le Sager - adapted for lon-lat MPI domain decomposition
  1477. !
  1478. !EOP
  1479. !------------------------------------------------------------------------
  1480. !BOC
  1481. CHARACTER(len=*), PARAMETER :: rname = mname//'/Boundary_Done'
  1482. ! --- begin ----------------------------------------
  1483. CALL goLabel(rname)
  1484. IF (isRoot) THEN
  1485. IF (LCMIP6_O3) THEN
  1486. CALL Done( LeviX_cmip6_o3, status )
  1487. IF_NOTOK_RETURN(status=1)
  1488. ENDIF
  1489. IF (use_MSR) THEN
  1490. CALL Done( LeviX_msr, status )
  1491. IF_NOTOK_RETURN(status=1)
  1492. ENDIF
  1493. IF (use_HALOE) THEN
  1494. CALL Done( LeviX_haloe, status )
  1495. IF_NOTOK_RETURN(status=1)
  1496. ENDIF
  1497. ENDIF
  1498. IF (LCMIP6_O3) THEN
  1499. if (allocated(weight_cmip62tm5)) deallocate (weight_cmip62tm5)
  1500. if (allocated(jlow_cmip62tm5)) deallocate (jlow_cmip62tm5)
  1501. ENDIF
  1502. IF (use_o3du) deallocate( o3du(1)%d23 )
  1503. deallocate( o3vmrpm (1)%d23 )
  1504. deallocate( o3vmr (1)%d23 )
  1505. deallocate( o3vmrnm (1)%d23 )
  1506. deallocate( ch4vmrpm (1)%d23 )
  1507. deallocate( ch4vmr (1)%d23 )
  1508. deallocate( ch4vmrnm (1)%d23 )
  1509. deallocate( o3ratpm (1)%d23 )
  1510. deallocate( o3rat (1)%d23 )
  1511. deallocate( o3ratnm (1)%d23 )
  1512. deallocate( ch4ratpm (1)%d23 )
  1513. deallocate( ch4rat (1)%d23 )
  1514. deallocate( ch4ratnm (1)%d23 )
  1515. deallocate( odin_hno3_o3 (1)%d23 )
  1516. deallocate( odin_hno3_o3_pm(1)%d23 )
  1517. deallocate( odin_hno3_o3_nm(1)%d23 )
  1518. deallocate( odin_co_o3 (1)%d23 )
  1519. deallocate( odin_co_o3_pm (1)%d23 )
  1520. deallocate( odin_co_o3_nm (1)%d23 )
  1521. deallocate( wrk3dpm_ML )
  1522. deallocate( wrk3d_ML )
  1523. deallocate( wrk3dnm_ML )
  1524. deallocate( wrk3dratio )
  1525. deallocate( wrk3dratiopm )
  1526. deallocate( wrk3drationm )
  1527. deallocate( wrk2d_ML )
  1528. deallocate( wrk2d_4L )
  1529. CALL goLabel()
  1530. status = 0
  1531. END SUBROUTINE BOUNDARY_DONE
  1532. !EOC
  1533. !--------------------------------------------------------------------------
  1534. ! TM5 !
  1535. !--------------------------------------------------------------------------
  1536. !BOP
  1537. !
  1538. ! !IROUTINE: BOUNDARY_APPLY
  1539. !
  1540. ! !DESCRIPTION:
  1541. !\\
  1542. !\\
  1543. ! !INTERFACE:
  1544. !
  1545. SUBROUTINE BOUNDARY_APPLY( region, status )
  1546. !
  1547. ! !USES:
  1548. !
  1549. USE dims, ONLY : im, jm, lm
  1550. USE dims, ONLY : ybeg
  1551. USE dims, ONLY : xref, yref, tref
  1552. USE dims, ONLY : at, bt
  1553. USE dims, ONLY : dx, dy
  1554. USE dims, ONLY : nsrce
  1555. USE dims, ONLY : okdebug
  1556. USE dims, ONLY : sec_day,sec_month
  1557. USE toolbox, ONLY : lvlpress
  1558. USE chem_param, ONLY : io3, io3s, ich4, ihno3, ico
  1559. USE chem_param, ONLY : xmair, xmhno3, xmo3, xmch4, xmco, fscale, ra
  1560. USE meteodata, ONLY : m_dat
  1561. USE global_data, ONLY : region_dat, mass_dat
  1562. USE partools, ONLY : par_reduce_element
  1563. use GO, ONLY : GO_Timer_End, GO_Timer_Start
  1564. !
  1565. ! !INPUT PARAMETERS:
  1566. !
  1567. INTEGER, INTENT(in) :: region
  1568. !
  1569. ! !OUTPUT PARAMETERS:
  1570. !
  1571. INTEGER, INTENT(out) :: status
  1572. !
  1573. ! !REVISION HISTORY:
  1574. ! 23 Mar 2012 - P. Le Sager - adapted for lon-lat MPI domain decomposition
  1575. !
  1576. !EOP
  1577. !------------------------------------------------------------------------
  1578. !BOC
  1579. CHARACTER(len=*), PARAMETER :: rname = mname//'/Boundary_Apply'
  1580. ! Nudging coefficients for O3 and CH4
  1581. REAL, PARAMETER :: gnud_pole = 2.894e-6 ! 1 / (4 days)
  1582. REAL, PARAMETER :: gnud_hilat = 3.858e-6 ! 1 / (3 days)
  1583. REAL, PARAMETER :: gnud_trop = 4.630e-6 ! 1 / (2.5 days)
  1584. ! Nudging coefficients for HNO3 and CO (tested by B. Maasakkers, see KNMI internship report)
  1585. REAL, PARAMETER :: gnud_hno3_5hpa = 2.315e-6 ! 1 / (5 days)
  1586. REAL, PARAMETER :: gnud_hno3_10hpa = 5.587e-7 ! 1 / (10 days)
  1587. REAL, PARAMETER :: gnud_hno3_28hpa = 1.987e-7 ! 1 / (60 days)
  1588. REAL, PARAMETER :: gnud_hno3_43hpa = 2.572e-7 ! 1 / (45 days)
  1589. REAL,DIMENSION(:,:,:), POINTER :: m, ppm
  1590. REAL,DIMENSION(:,:,:,:), POINTER :: rm
  1591. REAL,DIMENSION(:,:), ALLOCATABLE :: znl_lcl, zonal_glbl ! zonal (total or average), local and global
  1592. INTEGER :: lmr, nlevels, nudge_lev, daystep
  1593. INTEGER :: i, j, l, ipos, nzone, nzone_v, n, lm_min, nday
  1594. REAL :: pr, dtime, dyy, xlat, gnud, o3za, ch4za, coza
  1595. REAL :: rmold, rmold1, rmold2, z, z1, z2, rmobs, rmobs1, rmobs2
  1596. INTEGER :: lsave, i1, i2, j1, j2
  1597. REAL :: fraction_pm, fraction_cm, fraction_nm, daily_scale
  1598. REAL :: diffmin, pressure(4), gnud_hno3(4), gnud_co(4)
  1599. REAL :: nudgeFactor, tm5_o3_hno3_mix_ratio, tm5_o3_co_mix_ratio
  1600. !
  1601. ! no. days from 20th month till end
  1602. !
  1603. REAL, DIMENSION(12) :: nday_em = (/11.0, 8.0, 11.0, 10.0, 11.0, 10.0, 11.0, 11.0, 10.0, 11.0, 10.0, 11.0/)
  1604. ! --- Begin ----------------------------------
  1605. ! O3, O3S and CH4 are relaxed to climatology at stratospheric layers
  1606. ! HNO3 is prescribed at level lm using ODIN or UARS HNO3:03 ratios
  1607. ! CO is prescribed at level lm using ODIN CO:03 ratios
  1608. ! start timing:
  1609. call GO_Timer_Start( itim_appl, status )
  1610. IF_NOTOK_RETURN(status=1)
  1611. CALL goLabel(rname)
  1612. CALL Get_DistGrid( dgrid(region), I_STRT=i1, I_STOP=i2, J_STRT=j1, J_STOP=j2 )
  1613. lmr=lm(region)
  1614. dtime=nsrce/(2*tref(region))
  1615. dyy=dy/yref(region) !gridsize at current region
  1616. rm => mass_dat(region)%rm
  1617. m => m_dat (region)%data
  1618. nday=sec_month/sec_day
  1619. !
  1620. ! Define the fractions from the previous and next months
  1621. ! For the period 10-20th of each month fraction_cm=1.0
  1622. !
  1623. fraction_pm = 0.0 ; fraction_nm = 0.0 ; fraction_cm = 1.0
  1624. if(idate(3) .lt. 10) then
  1625. fraction_pm = 1.0-((idate(3)+nday_em(idate(2)))/((nday_em(idate(2))+10)))
  1626. fraction_cm = 1.0-fraction_pm
  1627. endif
  1628. if(idate(3) .gt. 20) then
  1629. fraction_nm = 0.5*(real(idate(3))-20.5)/(real(nday)-20.0)
  1630. fraction_cm = 1.0-fraction_nm
  1631. endif
  1632. ! ---------------------------------------------------------------------
  1633. ! Get the NUDGING FACTORS
  1634. ! ---------------------------------------------------------------------
  1635. ! Only for the global domain, for which we are sure a good Zonal Average
  1636. ! can be calculated. The nudging factors are given by the ratio between
  1637. ! the climatological zonal mean and the observed zonal mean.
  1638. IF (region==1) THEN
  1639. ! Calculate the ratio of the climatology and the zonal mean model field.
  1640. ! The concentration at a given longitude is relaxed towards the ratio of
  1641. ! climatology and zonal mean model field multiplied by the model value
  1642. ALLOCATE( zonal_glbl(j1:j2, lm(1)) )
  1643. ALLOCATE( znl_lcl (j1:j2, lm(1)) )
  1644. ALLOCATE( ppm(i1:i2, j1:j2, lm(1)) )
  1645. ! ------ O3
  1646. ppm = 1e6*fscale(io3)*rm(i1:i2,j1:j2,:,io3)/m(i1:i2,j1:j2,:) ! into ppmv
  1647. znl_lcl=sum(ppm,dim=1) ! total zonal O3 in ppmv (local: i.e. only tile is accounted for)
  1648. CALL PAR_REDUCE_ELEMENT(znl_lcl, 'SUM', zonal_glbl, status, all=.true., row=.true.)
  1649. IF_NOTOK_RETURN(status=1)
  1650. ! zonal average
  1651. zonal_glbl = zonal_glbl/im(1)
  1652. DO l=1,lm(1)
  1653. DO j=j1,j2
  1654. !ratio clim/obs
  1655. IF ( zonal_glbl(j,l) == 0.0 ) THEN
  1656. o3ratpm(1)%d23(j,l) = 0.0
  1657. o3rat (1)%d23(j,l) = 0.0
  1658. o3ratnm(1)%d23(j,l) = 0.0
  1659. ELSE
  1660. o3ratpm(1)%d23(j,l) = o3vmrpm(1)%d23(j,l)/zonal_glbl(j,l)
  1661. o3rat (1)%d23(j,l) = o3vmr(1) %d23(j,l)/zonal_glbl(j,l)
  1662. o3ratnm(1)%d23(j,l) = o3vmrnm(1)%d23(j,l)/zonal_glbl(j,l)
  1663. END IF
  1664. ENDDO
  1665. ENDDO
  1666. ! ------ CH4
  1667. IF (use_HALOE) THEN ! else CH4rat remains 0 everywhere
  1668. ppm=1e6*fscale(ich4)*rm(i1:i2,j1:j2,:,ich4)/m(i1:i2,j1:j2,:)
  1669. znl_lcl=sum(ppm,dim=1) ! total zonal (local: i.e. tile only)
  1670. CALL PAR_REDUCE_ELEMENT(znl_lcl, 'SUM', zonal_glbl, status, all=.true., row=.true.)
  1671. IF_NOTOK_RETURN(status=1)
  1672. ! zonal average
  1673. zonal_glbl=zonal_glbl/im(1)
  1674. DO l=1,lm(1)
  1675. DO j=j1, j2
  1676. ! climatology/model ratio
  1677. IF ( zonal_glbl(j,l) == 0.0 ) THEN
  1678. CH4ratpm(1)%d23(j,l) = 0.0
  1679. CH4rat (1)%d23(j,l) = 0.0
  1680. CH4ratnm(1)%d23(j,l) = 0.0
  1681. ELSE
  1682. CH4ratpm(1)%d23(j,l) = ch4vmrpm(1)%d23(j,l)/zonal_glbl(j,l)
  1683. CH4rat (1)%d23(j,l) = ch4vmr (1)%d23(j,l)/zonal_glbl(j,l)
  1684. CH4ratnm(1)%d23(j,l) = ch4vmrnm(1)%d23(j,l)/zonal_glbl(j,l)
  1685. END IF
  1686. ENDDO
  1687. ENDDO
  1688. END IF
  1689. DEALLOCATE( ppm, znl_lcl, zonal_glbl)
  1690. ENDIF
  1691. ! ---------------------------------------------------------------------
  1692. ! Apply to O3 and CH4
  1693. ! ---------------------------------------------------------------------
  1694. DO j=j1,j2
  1695. xlat = ybeg(region) + (j+0.5)*dyy
  1696. IF (ABS(xlat) <= 30.0) THEN
  1697. lm_min = LVLPRESS(region, 4500., 98400.)
  1698. gnud = gnud_trop
  1699. ELSEIF(ABS(xlat)<66.0 ) THEN
  1700. lm_min = LVLPRESS(region, 9500., 98400.)
  1701. gnud = gnud_hilat
  1702. ELSE
  1703. lm_min = LVLPRESS(region, 12000., 98400.)
  1704. gnud = gnud_pole
  1705. ENDIF
  1706. DO l=lm_min,lm(region)
  1707. DO i=i1,i2
  1708. !
  1709. ! CMK: strictly spoken, the procedure om multi PEs is somewhat different.
  1710. ! Now they are independently nudged towards the same ZA!
  1711. ! In the long run, this will be the same! (hopefully) (FIXME : vraag MK wat betekend dat)
  1712. !
  1713. #ifndef without_o3_nudging
  1714. if(idate(3) .lt. 10) &
  1715. daily_scale = ((o3ratpm(region)%d23(j,l)*fraction_pm) + (o3rat(region)%d23(j,l)*fraction_cm))
  1716. if(idate(3) .gt. 9 .and. idate(3) .lt. 21) &
  1717. daily_scale = o3rat(region)%d23(j,l)
  1718. if(idate(3) .gt. 20) &
  1719. daily_scale = ((o3ratnm(region)%d23(j,l)*fraction_nm) + (o3rat(region)%d23(j,l)*fraction_cm))
  1720. rmobs = rm(i,j,l,io3)*daily_scale ! correct za
  1721. rmold = rm(i,j,l,io3) ! uncorrected value
  1722. z = (rmold+dtime*gnud*rmobs)/(1.+dtime*gnud) ! new concentration
  1723. rm(i,j,l,io3) = z
  1724. rmobs1 = rm(i,j,l,io3s)*daily_scale ! correct za
  1725. rmold1 = rm(i,j,l,io3s) ! uncorrected value
  1726. z1 = (rmold1+dtime*gnud*rmobs1)/(1.+dtime*gnud) ! new concentration
  1727. rm(i,j,l,io3s) = z1
  1728. #endif
  1729. if(idate(3) .lt. 10) &
  1730. daily_scale=((ch4ratpm(region)%d23(j,l)*fraction_pm) + (ch4rat(region)%d23(j,l)*fraction_cm))
  1731. if(idate(3) .gt. 9 .and. idate(3) .lt. 21) &
  1732. daily_scale=ch4rat(region)%d23(j,l)
  1733. if(idate(3) .gt. 20) &
  1734. daily_scale=((ch4ratnm(region)%d23(j,l)*fraction_nm)+ (ch4rat(region)%d23(j,l)*fraction_cm))
  1735. rmobs2 = rm(i,j,l,ich4)*daily_scale ! correct za
  1736. rmold2 = rm(i,j,l,ich4) ! uncorrected value
  1737. z2 = (rmold2+dtime*gnud*rmobs2)/(1.+dtime*gnud) ! new concentration
  1738. rm(i,j,l,ich4) = z2
  1739. #ifdef with_budgets
  1740. ! stratospheric budget....
  1741. nzone=budg_dat(region)%nzong(i,j) !global budget
  1742. nzone_v=nzon_vg(l)
  1743. #ifndef without_o3_nudging
  1744. budstratg(nzone,nzone_v,io3) = budstratg(nzone,nzone_v,io3) + (z-rmold)/xmo3*1e3 ! mole
  1745. budstratg(nzone,nzone_v,io3s) = budstratg(nzone,nzone_v,io3s) + (z1-rmold1)/xmo3*1e3 ! mole
  1746. #endif
  1747. budstratg(nzone,nzone_v,ich4) = budstratg(nzone,nzone_v,ich4) + (z2-rmold2)/xmch4*1e3 ! mole
  1748. ! #ifndef without_o3_nudging
  1749. ! IF( io3 == 1 ) THEN
  1750. ! sum_stratosphere(region) = sum_stratosphere(region) + z-rmold
  1751. ! END IF
  1752. ! IF ( io3s == 1 ) THEN
  1753. ! sum_stratosphere(region) = sum_stratosphere(region) + z1-rmold1
  1754. ! END IF
  1755. ! #endif
  1756. ! IF ( ich4 == 1 ) THEN
  1757. ! sum_stratosphere(region) = sum_stratosphere(region) + z2-rmold2
  1758. ! END IF
  1759. #endif /* BUDGETS */
  1760. END DO!i
  1761. END DO !l
  1762. END DO !j
  1763. !-------------------------------------------
  1764. ! set constraints for HNO3
  1765. !-------------------------------------------
  1766. IF (use_ODIN) then
  1767. nlevels=3 ! limit nudging to 3 top levels
  1768. pressure=(/550.0, 1122.0, 2820.0, 4365.0/) ! hPa
  1769. gnud_hno3 = (/gnud_hno3_5hpa, gnud_hno3_10hpa, gnud_hno3_28hpa, 0./)
  1770. ELSE
  1771. nlevels=1
  1772. pressure=(/1000.0, 0., 0., 0./) ! hPa
  1773. gnud_hno3 = (/gnud_hno3_10hpa, 0., 0., 0./)
  1774. ENDIF
  1775. DO nudge_lev=1,nlevels
  1776. lsave = 0 ! locate level closest to pressure[nudge_lev] hPa
  1777. diffmin = 1e10
  1778. DO l=1,lm(region)
  1779. pr = 0.5*(at(l)+at(l+1)) + 0.5*(bt(l)+bt(l+1))*1e5 ! pressure centre box
  1780. IF(ABS(pr-pressure(nudge_lev)) < diffmin) THEN
  1781. diffmin = ABS(pr-pressure(nudge_lev))
  1782. lsave = l
  1783. ENDIF
  1784. ENDDO
  1785. IF (use_ODIN) then
  1786. DO j=j1,j2
  1787. !
  1788. ! Smooth ratio between months to avoid spurious jumps in record
  1789. ! "daily_scale" is the time-interpolated ODIN climatology of the [HNO3]/[O3] ratio of mixing ratios
  1790. !
  1791. if ( idate(3) .lt. 10 ) &
  1792. daily_scale = odin_hno3_o3_pm(region)%d23(j,nudge_lev) * fraction_pm + &
  1793. odin_hno3_o3 (region)%d23(j,nudge_lev) * fraction_cm
  1794. if ( idate(3) .gt. 9 .and. idate(3) .lt. 21 ) &
  1795. daily_scale = odin_hno3_o3(region)%d23(j,nudge_lev)
  1796. if ( idate(3) .gt. 20 ) &
  1797. daily_scale = odin_hno3_o3_nm(region)%d23(j,nudge_lev) * fraction_nm + &
  1798. odin_hno3_o3 (region)%d23(j,nudge_lev) * fraction_cm
  1799. DO i=i1,i2
  1800. ! Include ratio of fscale factors, which convert from mass to mixing ratio
  1801. tm5_o3_hno3_mix_ratio = ( rm(i,j,lsave,io3) * fscale(io3) ) / ( rm(i,j,lsave,ihno3) * fscale(ihno3) )
  1802. nudgeFactor = ( 1.0 + dtime*gnud_hno3(NUDGE_LEV)*daily_scale*tm5_o3_hno3_mix_ratio ) / &
  1803. ( 1.0 + dtime*gnud_hno3(NUDGE_LEV) )
  1804. rmold = rm(i,j,lsave,ihno3)
  1805. z = rmold * nudgeFactor
  1806. rm(i,j,lsave,ihno3) = z
  1807. #ifdef with_budgets
  1808. ! stratospheric budget....
  1809. nzone=budg_dat(region)%nzong(i,j) !global budget
  1810. nzone_v=nzon_vg(lsave)
  1811. budstratg(nzone,nzone_v,ihno3)=budstratg(nzone,nzone_v,ihno3)+(z-rmold)/xmhno3*1e3 !mole
  1812. ! IF(ihno3 ==1) sum_stratosphere(region) = sum_stratosphere(region) + z-rmold
  1813. #endif
  1814. ENDDO!i
  1815. ENDDO!j
  1816. ELSE
  1817. DO j=j1,j2
  1818. DO i=i1,i2
  1819. rmold = rm(i,j,lsave,ihno3)
  1820. rmobs = rm(i,j,lsave,io3) * odin_hno3_o3(region)%d23(j,nudge_lev)
  1821. z = (rmold+dtime*gnud_hno3(NUDGE_LEV)*rmobs) / (1.+dtime*gnud_hno3(NUDGE_LEV)) !new concentration
  1822. rm(i,j,lsave,ihno3) = z
  1823. #ifdef with_budgets
  1824. ! stratospheric budget....
  1825. nzone=budg_dat(region)%nzong(i,j) !global budget
  1826. nzone_v=nzon_vg(lsave)
  1827. budstratg(nzone,nzone_v,ihno3)=budstratg(nzone,nzone_v,ihno3)+(z-rmold)/xmhno3*1e3 !mole
  1828. ! IF(ihno3 ==1) sum_stratosphere(region) = sum_stratosphere(region) + z-rmold
  1829. #endif
  1830. ENDDO!i
  1831. ENDDO!j
  1832. ENDIF
  1833. ENDDO ! nudge levels
  1834. ! This is not used (i.e. the global budget is not printed nor saved) so
  1835. ! this is commented. NOTE also that this should be moved to
  1836. ! chemistry/chemistry_done if ever used [PLS, 23-maart-2012]
  1837. !#ifdef with_budgets
  1838. ! CALL PAR_REDUCE(sum_stratosphere(region), 'SUM', sum_stratosphere(region), status)
  1839. ! IF_NOTOK_RETURN(status=1)
  1840. !#endif
  1841. !-------------------------------------------
  1842. ! Set constraints for CO nudging
  1843. !-------------------------------------------
  1844. IF (USE_ODIN) THEN
  1845. nlevels=3 ! limit nudging to 3 top levels
  1846. pressure=(/550.0, 1122.0, 2820.0, 4365.0/) ! hPa
  1847. gnud_co = (/gnud_hno3_5hpa, gnud_hno3_10hpa, gnud_hno3_28hpa, gnud_hno3_28hpa/)
  1848. DO nudge_lev=1,nlevels
  1849. lsave = 0 ! locate level closest to pressure level that is nudged
  1850. diffmin = 1e10
  1851. DO l=1,lm(region)
  1852. pr = 0.5*(at(l)+at(l+1)) + 0.5*(bt(l)+bt(l+1))*1e5 ! pressure centre box
  1853. IF(ABS(pr-1000.0) < diffmin) THEN
  1854. diffmin = ABS(pr-pressure(nudge_lev))
  1855. lsave = l
  1856. ENDIF
  1857. ENDDO
  1858. DO j=j1,j2
  1859. !
  1860. ! Smooth ratio between months to avoid spurious jumps in record
  1861. ! "daily_scale" is the time-interpolated ODIN climatology of the [CO]/[O3] ratio of mixing ratios
  1862. !
  1863. if ( idate(3) .lt. 10 ) &
  1864. daily_scale = odin_co_o3_pm(region)%d23(j,nudge_lev) * fraction_pm + &
  1865. odin_co_o3 (region)%d23(j,nudge_lev) * fraction_cm
  1866. if ( idate(3) .gt. 9 .and. idate(3) .lt. 21 ) &
  1867. daily_scale = odin_co_o3(region)%d23(j,nudge_lev)
  1868. if ( idate(3) .gt. 20 ) &
  1869. daily_scale = odin_co_o3_nm(region)%d23(j,nudge_lev) * fraction_nm + &
  1870. odin_co_o3 (region)%d23(j,nudge_lev) * fraction_cm
  1871. DO i=i1,i2
  1872. ! Include ratio of fscale factors, which convert from mass to mixing ratio
  1873. tm5_o3_co_mix_ratio = ( rm(i,j,lsave,io3) * fscale(io3) ) / ( rm(i,j,lsave,ico) * fscale(ico) )
  1874. nudgeFactor = ( 1.0 + dtime*gnud_co(NUDGE_LEV)*daily_scale*tm5_o3_co_mix_ratio ) / &
  1875. ( 1.0 + dtime*gnud_co(NUDGE_LEV) )
  1876. rmold = rm(i,j,lsave,ico)
  1877. z = rmold * nudgeFactor
  1878. rm(i,j,lsave,ico) = z
  1879. #ifdef with_budgets
  1880. ! stratospheric budget....
  1881. nzone=budg_dat(region)%nzong(i,j) !global budget
  1882. nzone_v=nzon_vg(lsave)
  1883. budstratg(nzone,nzone_v,ico)=budstratg(nzone,nzone_v,ico)+(z-rmold)/xmco*1e3 !mole
  1884. ! IF(ico ==1) sum_stratosphere(region) = sum_stratosphere(region) + z-rmold
  1885. #endif
  1886. ENDDO!i
  1887. ENDDO!j
  1888. ENDDO ! nudge levels
  1889. ENDIF
  1890. NULLIFY(rm)
  1891. NULLIFY(m)
  1892. ! end timing:
  1893. call GO_Timer_End( itim_appl, status )
  1894. IF_NOTOK_RETURN(status=1)
  1895. CALL goLabel()
  1896. status = 0
  1897. END SUBROUTINE BOUNDARY_APPLY
  1898. !EOC
  1899. END MODULE BOUNDARY