user_output_column.F90 64 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476
  1. !#################################################################
  2. !
  3. ! MODULE: user_output_column *************** DUMMY TM5-MP VERSION *******************
  4. !
  5. ! PUBLIC SUBROUTINES:
  6. ! user_output_column_init
  7. ! user_output_column_accum
  8. ! user_output_column_evaluate
  9. ! user_output_column_write
  10. ! user_output_column_reset
  11. ! user_output_column_done
  12. !
  13. ! DESCRIPTION:
  14. ! Write column tracer fields. Called from user_output.F90.
  15. !
  16. ! REVISION HISTORY:
  17. ! Original module written by:
  18. ! Peter Bergamaschi, Maarten Krol, Wouter Peters, others?
  19. !
  20. ! Mike Trudeau, Feb 2012
  21. ! Modified to write NetCDF4 output in NOAA CarbonTracker
  22. ! release format.
  23. !
  24. ! Required rc file keys
  25. ! output.column : [T/F]
  26. ! output.column.dtsec : [integer]
  27. ! output.column.infile : [/path/myColumnList.txt]
  28. ! Obsolete rc file keys
  29. ! output.column.filename : [column.nc]
  30. ! inputdir.column : [/path]
  31. ! output.column.infilename : [myColumnList.txt]
  32. !
  33. ! Mike Trudeau, Feb 2013
  34. ! 1. Modified pressure units (hectopascals to pascals)
  35. ! 2. Removed mean pressure, wind speed, wind direction from
  36. ! the meteo output fields.
  37. ! 3. CO2 tracers written with background subtracted.
  38. ! 4. Total CO2 tracer added to output.
  39. !
  40. ! Andy Jacobson, April 2013
  41. ! Change to ndyn weighting
  42. !
  43. !### macro's #####################################################
  44. !
  45. #define TRACEBACK write (gol,'("in ",a," (",a,", line",i5,")")') rname, __FILE__, __LINE__; call goErr
  46. #define IF_NOTOK_RETURN(action) if (status/=0) then; TRACEBACK; action; return; end if
  47. #define IF_ERROR_RETURN(action) if (status> 0) then; TRACEBACK; action; return; end if
  48. !
  49. #include "tm5.inc"
  50. !
  51. !#################################################################
  52. module user_output_column
  53. use GO, only : gol, goErr, goPr
  54. ! use dims, only : nregions, itaur
  55. ! use dims, only : im, jm, lm, dx, dy, xref, yref, xbeg, ybeg, xend, yend, zbeg, zend
  56. ! use chem_param, only : ntracet, ntrace, names
  57. implicit none
  58. character(len=*), parameter :: mname = 'user_output_column'
  59. private
  60. ! --- public routines ------------------------
  61. public :: user_output_column_init
  62. public :: user_output_column_done
  63. public :: user_output_column_write
  64. public :: user_output_column_accum
  65. public :: user_output_column_reset
  66. public :: user_output_column_evaluate
  67. ! ! --- constants ------------------------------
  68. ! integer, parameter :: nmethods = 3 ! number of column interpolation methods
  69. ! integer, parameter :: nmeteoLvl = 4
  70. ! integer, parameter :: nmeteoBnd = 2
  71. ! integer, parameter :: writeMethod = 2 ! interpolation method output to file
  72. ! ! 1: no interpolation ('grd')
  73. ! ! 2: interpolation based on slopes ('slp')
  74. ! ! 3: 3D linear interpolations ('int')
  75. ! character(len=70), dimension(5), parameter :: comment_species = &
  76. ! (/'background - component due to initial condition (at 2000-01-01)', &
  77. ! 'component due to fossil fuel burning (since 2000-01-01)', &
  78. ! 'component due to air-sea gas exchange (since 2000-01-01)', &
  79. ! 'component due to terrestrial biosphere exchange (since 2000-01-01)', &
  80. ! 'component due to direct fire emissions (since 2000-01-01)'/)
  81. ! character(len=14), dimension(nmeteoLvl), parameter :: name_meteoLvl = &
  82. ! (/'temperature', &
  83. ! 'u', &
  84. ! 'v', &
  85. ! 'blh'/)
  86. ! character(len=13), dimension(nmeteoLvl), parameter :: units_meteoLvl = &
  87. ! (/'Kelvin', &
  88. ! 'meters/second', &
  89. ! 'meters/second', &
  90. ! 'meters'/)
  91. ! character(len=50), dimension(nmeteoLvl), parameter :: standard_name_meteoLvl = &
  92. ! (/'temperature at level center', &
  93. ! 'zonal component of the wind velocity', &
  94. ! 'meridional component of the wind velocity', &
  95. ! 'boundary layer height'/)
  96. ! character(len=14), dimension(nmeteoLvl), parameter :: long_name_meteoLvl = &
  97. ! (/'temperature', &
  98. ! 'u', &
  99. ! 'v', &
  100. ! 'blh'/)
  101. ! character(len=14), dimension(nmeteoBnd), parameter :: name_meteoBnd = &
  102. ! (/'pressure', 'gph'/)
  103. ! character(len=13), dimension(nmeteoBnd), parameter :: units_meteoBnd = &
  104. ! (/'pascals', 'meters'/)
  105. ! character(len=50), dimension(nmeteoBnd), parameter :: standard_name_meteoBnd = &
  106. ! (/'pressure at layer interface', 'geopotential height of layer interface'/)
  107. ! character(len=14), dimension(nmeteoBnd), parameter :: long_name_meteoBnd = &
  108. ! (/'pressure', 'gph'/)
  109. ! ! --- variables ------------------------------
  110. ! integer, dimension(ntrace) :: species
  111. ! integer :: nspecies
  112. ! integer, save :: nstations
  113. ! logical :: evaluated
  114. ! type fieldsType1
  115. ! character(len=13) :: id ! column identifier
  116. ! character(len=50) :: desc ! column name
  117. ! real :: lat ! latitude of column
  118. ! real :: lon ! longitude of column
  119. ! real :: height ! height of column
  120. ! real :: oro ! ground height at station
  121. ! integer :: index ! index of column
  122. ! integer :: region
  123. ! integer :: is
  124. ! integer :: js
  125. ! integer :: ls
  126. ! real,dimension(nmeteoLvl,lm(1)) :: meteoLvl ! meteo (interpolated) at columns
  127. ! real,dimension(:,:,:),pointer :: c_avg ! species, interpolation
  128. ! real,dimension(:,:,:),pointer :: c_std
  129. ! integer :: ndata ! for averages
  130. ! real :: accum_weight ! for averages
  131. ! real,dimension(nmeteoBnd,lm(1)+1) :: meteoBnd ! meteo (interpolated) at columns
  132. ! end type fieldsType1
  133. ! type(fieldsType1), dimension(:), allocatable :: stations
  134. ! type(fieldsType1), dimension(:), allocatable :: stationsRegion
  135. ! type fieldsType2
  136. ! integer, dimension(6) :: idate_start
  137. ! integer, dimension(6) :: idate_end
  138. ! end type fieldsType2
  139. ! type(fieldsType2), dimension(nregions), save :: timestamp
  140. ! ! --- begin -------------------------------
  141. contains
  142. subroutine user_output_column_init( status )
  143. ! use ParTools , only : myid, root
  144. ! use dims, only : nregions, idatei
  145. ! implicit none
  146. ! ! --- in/out ------------------------
  147. ! integer :: region
  148. integer, intent(out) :: status
  149. ! --- constants ---------------------
  150. ! character(len=*), parameter :: rname = mname//'/user_output_column_init'
  151. ! ! --- begin -------------------------------
  152. ! if (myid /= root) return
  153. ! evaluated = .FALSE.
  154. ! ! grab the date
  155. ! do region = 1, nregions
  156. ! timestamp(region)%idate_start = idatei
  157. ! end do
  158. ! ! read user supplied station list
  159. ! call read_columnlist( status )
  160. ! IF_NOTOK_RETURN( status=1 )
  161. ! ! initialize the column output
  162. ! call user_output_column_reset( status )
  163. ! ok
  164. status = 0
  165. end subroutine user_output_column_init
  166. ! subroutine read_columnlist( status )
  167. ! use toolbox, only : escape_tm
  168. ! #ifdef MPI
  169. ! use mpi_const, only: myid, root, mpi_integer, mpi_character, &
  170. ! my_real, mpi_comm_world, ierr
  171. ! #else
  172. ! use ParTools, only: myid, root
  173. ! #endif
  174. ! use GO, only : TrcFile, Init, Done, ReadRc
  175. ! use global_data, only : rcfile
  176. ! implicit none
  177. ! ! --- variables ---------------------
  178. ! integer, intent(out) :: status
  179. ! character(len=1024) :: infile
  180. ! integer :: nchar !string length
  181. ! character(len=200) :: dummy
  182. ! integer :: q
  183. ! integer :: region
  184. ! integer,dimension(6) :: idate_sim
  185. ! integer :: itau_sim, isim, ispec
  186. ! real :: dxr, dyr
  187. ! character(len=8) :: name_spec !CMK changed from 6-->8
  188. ! integer :: sunit0=110
  189. ! type(TrcFile) :: rcF
  190. ! ! --- constants -----------------------
  191. ! character(len=*), parameter :: rname = mname//'/read_columnlist'
  192. ! ! --- begin -----------------------
  193. ! ! start
  194. ! if ( myid == root ) then
  195. ! ! read rc file
  196. ! call Init( rcF, rcfile, status)
  197. ! call ReadRc( rcF, 'output.column.infile', infile, status )
  198. ! IF_NOTOK_RETURN( status=1 )
  199. ! write (gol, *) trim(rname)//'/column file: ', trim(infile); call goPr
  200. ! call Done( rcF, status)
  201. ! ! read columnlist file
  202. ! nchar = len_trim(infile)
  203. ! if ( nchar > 0 ) then
  204. ! !=========================================
  205. ! ! open columnFile (with list of columns)
  206. ! !=========================================
  207. ! open(UNIT=sunit0, FORM='FORMATTED', &
  208. ! FILE=trim(infile), &
  209. ! status='OLD', ERR=1000)
  210. ! read(sunit0, '(a)') dummy
  211. ! ! count number of columns
  212. ! nstations=0
  213. ! stations_loop: DO
  214. ! read(sunit0, '(a)', END=100) dummy
  215. ! if (dummy(1:7) /= 'species') then
  216. ! nstations = nstations+1
  217. ! else
  218. ! nspecies = 0
  219. ! do
  220. ! read(sunit0, '(a8)' , end=100) name_spec ! CMK changed a6-->a8
  221. ! !CMK not allowed yet to write short-lived: TODO
  222. ! specloop: do ispec = 1, ntracet
  223. ! if (name_spec == names(ispec) ) then
  224. ! nspecies = nspecies + 1
  225. ! species(nspecies) = ispec
  226. ! exit specloop
  227. ! endif
  228. ! enddo specloop
  229. ! enddo
  230. ! exit stations_loop
  231. ! end if
  232. ! end do stations_loop
  233. ! 100 continue
  234. ! print *, '_________________________________________________' &
  235. ! //'_______________________________'
  236. ! print *, nstations, ' columns read from file: ', infile
  237. ! print *, nspecies, ' concentrations will be gathered:'
  238. ! if (nspecies == 0) then
  239. ! print *, 'ERROR user_output_column'
  240. ! print *, 'ERROR no species for output'
  241. ! print *, 'ERROR Set column_output to .F. or give valid species name'
  242. ! call escape_tm('Error reading column file')
  243. ! endif
  244. ! do ispec = 1, nspecies
  245. ! print '(2i4,2x,a8)', ispec, species(ispec), & ! CMK change a6--->a8
  246. ! names(species(ispec))
  247. ! enddo
  248. ! print *, '_________________________________________________' &
  249. ! //'_______________________________'
  250. ! allocate(stations(nstations))
  251. ! do q = 1, nstations
  252. ! ! wow, this lm(1) assumes column in region 1, or that
  253. ! ! child regions all have lm(n) <= lm(1)
  254. ! allocate(stations(q)%c_avg(nspecies,nmethods,lm(1)))
  255. ! allocate(stations(q)%c_std(nspecies,nmethods,lm(1)))
  256. ! enddo
  257. ! dyr = dy/yref(1) ! again, as above comment: region 1 assumed.
  258. ! dxr = dx/xref(1) ! " " "
  259. ! !===============
  260. ! ! read columns
  261. ! !===============
  262. ! rewind(sunit0)
  263. ! read(sunit0, '(a)') dummy
  264. ! do q=1, nstations
  265. ! read(sunit0, '(a7,1x,f8.2,f8.2,f8.1,1x,a50)') &
  266. ! stations(q)%id, &
  267. ! stations(q)%lat, &
  268. ! stations(q)%lon, &
  269. ! stations(q)%height, &
  270. ! stations(q)%desc
  271. ! stations(q)%oro = -99999.0
  272. ! stations(q)%index = q
  273. ! ! assume global region as default for average mixing ratios
  274. ! stations(q)%region = 1
  275. ! stations(q)%is = &
  276. ! int((stations(q)%lon-float(xbeg(1)))/dxr + 0.99999)
  277. ! stations(q)%js = &
  278. ! int((stations(q)%lat-float(ybeg(1)))/dyr + 0.99999)
  279. ! end do
  280. ! ! close columnfile
  281. ! close(sunit0)
  282. ! do q=1, nstations
  283. ! do region=1, nregions
  284. ! dyr = dy/yref(region)
  285. ! dxr = dx/xref(region)
  286. ! if ( (stations(q)%lon .ge. xbeg(region) .and. &
  287. ! stations(q)%lon .le. xend(region)) .and. &
  288. ! (stations(q)%lat .ge. ybeg(region) .and. &
  289. ! stations(q)%lat .le. yend(region) ) ) then
  290. ! !=====================
  291. ! ! column is in region
  292. ! !=====================
  293. ! ! determine region with hightes refinement factor
  294. ! if (xref(region) > xref(stations(q)%region)) then
  295. ! stations(q)%region = region
  296. ! stations(q)%is = &
  297. ! int((stations(q)%lon-float(xbeg(region)))/dxr + 0.99999)
  298. ! stations(q)%js = &
  299. ! int((stations(q)%lat-float(ybeg(region)))/dyr + 0.99999)
  300. ! end if
  301. ! end if
  302. ! end do
  303. ! end do
  304. ! do q=1, nstations
  305. ! print '(a7,1x,f8.2,f8.2,f8.1,1x,i4,1x,a50)', &
  306. ! stations(q)%id, &
  307. ! stations(q)%lat, &
  308. ! stations(q)%lon, &
  309. ! stations(q)%height, &
  310. ! stations(q)%region, &
  311. ! stations(q)%desc
  312. ! end do
  313. ! end if
  314. ! end if ! myid = root
  315. ! ! ok
  316. ! status = 0
  317. ! return
  318. ! ! error handling
  319. ! 1000 call escape_tm( 'read_columnlist: could not open '//trim(infile))
  320. ! end subroutine read_columnlist
  321. subroutine user_output_column_accum( region, status )
  322. ! #ifdef MPI
  323. ! use mpi_const !, only: myid, root
  324. ! use mpi_comm, only: gather_tracer_k, gather_tracer_t, gather_tracer_k_3d
  325. ! #endif
  326. ! use ParTools, only: myid, root, root_t, root_k
  327. ! use global_data, only : mass_dat, conv_dat
  328. ! use datetime, only : tau2date
  329. ! use toolbox, only : escape_tm
  330. ! use Meteo, only : gph_dat, oro_dat, temper_dat, pu_dat, pv_dat, m_dat, phlb_dat
  331. ! use dims, only : xcyc,ndyn,ndyn_max
  332. ! use chem_param, only : fscale, uscale
  333. ! use binas, only : ae, twopi
  334. ! implicit none
  335. ! --- in/out ------------------------
  336. integer, intent(out) :: status
  337. ! --- variables -----------------------
  338. integer, intent(in) :: region
  339. ! real,dimension(:,:,:,:),pointer :: rm ! tracer mass
  340. ! real,dimension(:,:,:,:),pointer :: rxm,rym,rzm ! slopes of tracer mass
  341. ! real,dimension(:,:,:) ,pointer :: m ! air mass
  342. ! real,dimension(:,:,:) ,pointer :: gph ! geopotential height
  343. ! real,dimension(:,:) ,pointer :: oro ! orography
  344. ! real, dimension(:,:,:,:), allocatable, target :: rmg ! MPI arrays to gather fields.
  345. ! real, dimension(:,:,:,:), allocatable, target :: rxmg, rymg, rzmg
  346. ! real, dimension(:,:,: ), allocatable, target :: mg
  347. ! integer :: i_interpol ! interpolation procedures:
  348. ! ! 1: no interpolation
  349. ! ! 2: interpolation based on slopes
  350. ! ! 3: 3D linear interpolations
  351. ! integer :: i,j,l ! grid cell indices
  352. ! integer :: is,js,ls ! i,j,l index of grid cell in which column lis located
  353. ! integer :: isn,jsn,lsn ! i,j,l index of grid cell which is taken as neighbour for linear interpolation
  354. ! integer :: lst, lstn ! MPI implementation
  355. ! integer :: js_north, js_south ! j index of grid cell for neighbours for windspeed_v interpolation
  356. ! integer :: is_west ! i index of grid cell for neighbour for windspeed_u interpolation
  357. ! integer :: n ! index of tracer
  358. ! integer :: q ! index of column
  359. ! real :: ris,rjs,rls ! deviation of column from center of the grid cell (-0.5 ... +0.5)
  360. ! real :: wcx,wcy,wcz ! x,y,z-weight of grid cell (1.0 ... 0.5)
  361. ! real :: dxr, dyr ! x,y resolution (in degrees) for current region
  362. ! real,dimension(0:lm(region)) :: height ! height of vertical grid boundaries
  363. ! integer, dimension(6) :: idate_f ! current idate for region
  364. ! integer :: sunit ! unit number for column output file
  365. ! real,dimension(lm(1)) :: rm_interpol ! tracer mass, interpolated to column location
  366. ! integer :: ispec ! index over activated tracers
  367. ! !=============
  368. ! ! meteoLvl output
  369. ! !=============
  370. ! real,dimension(nstations,nmeteoLvl,lm(1)) :: meteoLvl ! meteo (interpolated) at columns
  371. ! real,dimension(:,:,:), pointer :: T ! temperature
  372. ! real,dimension(:,:,:), pointer :: phlb ! pressure grid boundaries
  373. ! real,dimension(:,:,:), pointer :: pu ! mass flux x-direction [kg/s]
  374. ! real,dimension(:,:,:), pointer :: pv ! mass flux y-direction [kg/s]
  375. ! real,dimension(:,:), pointer :: blh ! boundary layer height [m]
  376. ! real,dimension(lm(1)) :: T_interpol ! temperature, interpolated to column location
  377. ! real,dimension(lm(1)) :: p_interpol ! pressure, interpolated to column location
  378. ! real,dimension(lm(1)+1) :: p_interpol_bnd ! boundary pressure, interpolated to column location
  379. ! real,dimension(lm(1)) :: windspeed_u_interpol ! wind speed [m/s] x-direction , interpolated to column location
  380. ! real,dimension(lm(1)) :: windspeed_v_interpol ! wind speed [m/s] y-direction , interpolated to column location
  381. ! real,dimension(lm(1)) :: windspeed_interpol ! wind speed [m/s] , interpolated to column location
  382. ! real,dimension(lm(1)) :: winddir_interpol ! wind direction , interpolated to column location
  383. ! real :: blh_interpol ! boundary layer height , interpolated to column location
  384. ! real :: lat_j ! latitude of grid cell center js [degrees]
  385. ! real :: lat_jn ! latitude of grid cell center jsn [degrees]
  386. ! real :: ddx_j ! x-extension of grid cell js [m]
  387. ! real :: ddx_jn ! x-extension of grid cell jsn [m]
  388. ! real :: ddy ! y-extension of grid cell js [m]
  389. ! real,dimension(lm(1)) :: vmr ! volume mi
  390. ! real :: this_weight
  391. ! integer :: communicator,root_id,lmr,imr,jmr
  392. ! ! start
  393. ! ! assign pointers depending on the paralel status
  394. ! ! (over levels after chemistry!)
  395. ! imr = im(region) ; jmr = jm(region) ; lmr = lm(region)
  396. ! this_weight=real(ndyn)/real(ndyn_max)
  397. ! #ifdef MPI
  398. ! if ( root_k /= root_t ) print *, 'Warning from MPI column output: ', &
  399. ! 'root_k and root_t are not equal'
  400. ! allocate( rmg (-1:imr+2,-1:jmr+2,lmr, ntracet) ) ; rmg = 0.0
  401. ! allocate( rxmg(-1:imr+2,-1:jmr+2,lmr, ntracet) ) ; rxmg = 0.0
  402. ! allocate( rymg(-1:imr+2,-1:jmr+2,lmr, ntracet) ) ; rymg = 0.0
  403. ! allocate( rzmg(-1:imr+2,-1:jmr+2,lmr, ntracet) ) ; rzmg = 0.0
  404. ! allocate( mg (-1:imr+2,-1:jmr+2,lmr ) ) ; mg = 0.0
  405. ! if ( which_par == 'tracer' ) then
  406. ! m => m_dat(region)%data
  407. ! rm => mass_dat(region)%rm_t
  408. ! rxm => mass_dat(region)%rxm_t
  409. ! rym => mass_dat(region)%rym_t
  410. ! rzm => mass_dat(region)%rzm_t
  411. ! call gather_tracer_t(rmg,imr,jmr,lmr,2,2,0,ntracet,rm,.false.)
  412. ! call gather_tracer_t(rxmg,imr,jmr,lmr,2,2,0,ntracet,rxm,.false.)
  413. ! call gather_tracer_t(rymg,imr,jmr,lmr,2,2,0,ntracet,rym,.false.)
  414. ! call gather_tracer_t(rzmg,imr,jmr,lmr,2,2,0,ntracet,rzm,.false.)
  415. ! nullify(rm) ! reassign pointers
  416. ! nullify(rxm)
  417. ! nullify(rym)
  418. ! nullify(rzm)
  419. ! rm => rmg
  420. ! rxm => rxmg
  421. ! rym => rymg
  422. ! rzm => rzmg
  423. ! communicator=com_trac !WP! assign com_trac as communicator
  424. ! root_id=root_t !root_t is the PE that knows the result.
  425. ! else
  426. ! m => m_dat(region)%data
  427. ! rm => mass_dat(region)%rm_k
  428. ! rxm => mass_dat(region)%rxm_k
  429. ! rym => mass_dat(region)%rym_k
  430. ! rzm => mass_dat(region)%rzm_k
  431. ! call gather_tracer_k(rmg,imr,jmr,lmr,2,2,0,ntracet,rm,.false.)
  432. ! call gather_tracer_k(rxmg,imr,jmr,lmr,2,2,0,ntracet,rxm,.false.)
  433. ! call gather_tracer_k(rymg,imr,jmr,lmr,2,2,0,ntracet,rym,.false.)
  434. ! call gather_tracer_k(rzmg,imr,jmr,lmr,2,2,0,ntracet,rzm,.false.)
  435. ! call gather_tracer_k_3d( mg, imr,jmr,lmr, 2,2,0, m, .false.)
  436. ! nullify(m) ! reassign pointers
  437. ! nullify(rm)
  438. ! nullify(rxm)
  439. ! nullify(rym)
  440. ! nullify(rzm)
  441. ! m => mg
  442. ! rm => rmg
  443. ! rxm => rxmg
  444. ! rym => rymg
  445. ! rzm => rzmg
  446. ! communicator=com_lev !WP! assign com_lev as communicator
  447. ! root_id=root_k
  448. ! end if
  449. ! #else
  450. ! m => m_dat(region)%data
  451. ! rm => mass_dat(region)%rm_t
  452. ! rxm => mass_dat(region)%rxm_t
  453. ! rym => mass_dat(region)%rym_t
  454. ! rzm => mass_dat(region)%rzm_t
  455. ! #endif
  456. ! ! assign pointers (METEO)
  457. ! gph => gph_dat(region)%data
  458. ! oro => oro_dat(region)%data(:,:,1)
  459. ! t => temper_dat(region)%data
  460. ! pu => pu_dat(region)%data
  461. ! pv => pv_dat(region)%data
  462. ! blh => conv_dat(region)%blh
  463. ! ! point to pressure paralel over tracers (contains all layers!)
  464. ! phlb => phlb_dat(region)%data
  465. ! if ( myid == root_t ) then
  466. ! ! perform only on root: tracers are already gathered here
  467. ! ! x and y resolution [degrees] for current region
  468. ! dyr = dy/yref(region)
  469. ! dxr = dx/xref(region)
  470. ! ! idate for current region
  471. ! call tau2date(itaur(region),idate_f)
  472. ! !====================
  473. ! ! loop over columns
  474. ! !====================
  475. ! do q=1, nstations
  476. ! IF (stations(q)%region == region)THEN
  477. ! !avoid edges!
  478. ! ris = (stations(q)%lon-float(xbeg(region)))/dxr + 0.99999
  479. ! rjs = (stations(q)%lat-float(ybeg(region)))/dyr + 0.99999
  480. ! is = int(ris) ! i-index of grid cell in which column is located
  481. ! js = int(rjs) ! j-index of grid cell in which column is located
  482. ! ! x-deviation from the center of the grid cell (-0.5...+0.5)
  483. ! ris = ris-is-0.5
  484. ! ! y-deviation from the center of the grid cell (-0.5...+0.5)
  485. ! rjs = rjs-js-0.5
  486. ! !=================================
  487. ! !the neighbour for x interpolation
  488. ! !=================================
  489. ! if ( ris .gt. 0 ) then
  490. ! isn = is+1
  491. ! else
  492. ! isn = is-1
  493. ! endif
  494. ! !=================================
  495. ! !the neighbour for y interpolation
  496. ! !=================================
  497. ! if ( rjs .gt. 0 ) then
  498. ! jsn = js+1
  499. ! else
  500. ! jsn = js-1
  501. ! endif
  502. ! ! x- / y-weighting of grid cell in which column is located
  503. ! wcx = (1.0-abs(ris)) ! 1.0 ... 0.5
  504. ! wcy = (1.0-abs(rjs)) ! 1.0 ... 0.5
  505. ! !=================================================================
  506. ! ! if index of neighbour is exceeding range of region set
  507. ! ! neighbour = current cell (i.e. no interpolation)
  508. ! ! in case of cyclic x-boundaries take corresponding cyclic i index
  509. ! !=================================================================
  510. ! if ( jsn == 0) jsn=1
  511. ! if ( jsn == jm(region)+1 ) jsn=jm(region) ! isn-->jsn (wouter Peters)
  512. ! if ( xcyc(region) == 0 ) then
  513. ! ! non-cyclic boundaries
  514. ! if ( isn == 0) isn=1
  515. ! if ( isn == im(region)+1 ) isn=im(region)
  516. ! else
  517. ! ! cyclic x-boundaries
  518. ! if ( isn == 0 ) isn=im(region)
  519. ! if ( isn == im(region)+1 ) isn=1
  520. ! end if
  521. ! !============================================
  522. ! ! interpolate the gph to xy position of column
  523. ! !============================================
  524. ! !ls = 1 !layer
  525. ! do l=0,lm(region)
  526. ! !CMK note: gph now from 1-->lm+1 (dec 2002)
  527. ! height(l) = wcx * wcy* gph(is,js,l+1) + &
  528. ! (1.0-wcx)* wcy* gph(isn,js,l+1) + &
  529. ! wcx *(1.0-wcy)* gph(is,jsn,l+1) + &
  530. ! (1.0-wcx)*(1.0-wcy)* gph(isn,jsn,l+1)
  531. ! end do
  532. ! !===========================
  533. ! ! determine layer of column
  534. ! !===========================
  535. ! !do l=0,lm(region)
  536. ! ! if(height(l) .gt. stations(q)%height) exit
  537. ! !end do
  538. ! !select case(l)
  539. ! !case(0)
  540. ! ! ! force column to model surface
  541. ! ! ls = 1
  542. ! ! rls = -0.5
  543. ! !case default
  544. ! ! ls = l ! column's layer
  545. ! ! ! the off-set from the center of the layer (-0.5--->+0.5)
  546. ! ! ! (interpolation is in (m))
  547. ! ! rls = (stations(q)%height - height(l-1)) / &
  548. ! ! (height(l)-height(l-1)) - 0.5
  549. ! !end select
  550. ! !stations(q)%ls = ls ! store for output to file
  551. ! rls = 0.0 ! no interpolation
  552. ! wcz = 1.0 ! no interpolation
  553. ! !============================================
  554. ! ! if not yet done, interpolate the orography
  555. ! ! to xy position of column
  556. ! !============================================
  557. ! if (stations(q)%oro < -10000) then
  558. ! stations(q)%oro = wcx * wcy* oro(is,js) + &
  559. ! (1.0-wcx)* wcy* oro(isn,js) + &
  560. ! wcx *(1.0-wcy)* oro(is,jsn) + &
  561. ! (1.0-wcx)*(1.0-wcy)* oro(isn,jsn)
  562. ! endif
  563. ! do ispec=1,nspecies
  564. ! n = species(ispec)
  565. ! lst = ls
  566. ! lstn = lsn
  567. ! !========================================
  568. ! ! value of grid box without interpolation
  569. ! !========================================
  570. ! vmr = rm(is,js,:,n) / m(is,js,:) * fscale(n) * uscale(n)
  571. ! stations(q)%c_avg(ispec,1,:) = &
  572. ! stations(q)%c_avg(ispec,1,:) + this_weight*vmr
  573. ! stations(q)%c_std(ispec,1,:) = &
  574. ! stations(q)%c_std(ispec,1,:) + this_weight*vmr*vmr
  575. ! !========================================
  576. ! ! interpolation using slopes
  577. ! !========================================
  578. ! !rm-value is obtained from rm + slopes.
  579. ! !slope = rxm = (rm*dX/dx *deltaX/2)
  580. ! rm_interpol = rm(is,js,:,n) + 2.0*(ris*rxm(is,js,:,n) + &
  581. ! rjs*rym(is,js,:,n) + &
  582. ! rls*rzm(is,js,:,n) )
  583. ! rm_interpol = max(0.0,rm_interpol)
  584. ! vmr = rm_interpol/m(is,js,:) * fscale(n) * uscale(n)
  585. ! stations(q)%c_avg(ispec,2,:) = &
  586. ! stations(q)%c_avg(ispec,2,:) + this_weight*vmr
  587. ! stations(q)%c_std(ispec,2,:) = &
  588. ! stations(q)%c_std(ispec,2,:) + this_weight*vmr*vmr
  589. ! !========================================
  590. ! ! 3D linear interpolation
  591. ! !========================================
  592. ! ! this PE handles also the neighbour layer
  593. ! !PB if ( lstn >= 1 .and. lstn <= lmr) then
  594. ! !PBi
  595. ! rm_interpol = wcx *wcy *rm(is,js,:,n) /m(is,js,:) + &
  596. ! (1.0-wcx)*wcy *rm(isn,js,:,n) /m(isn,js,:) + &
  597. ! wcx *(1.0-wcy) *rm(is,jsn,:,n) /m(is,jsn,:) + &
  598. ! (1.0-wcx)*(1.0-wcy) *rm(isn,jsn,:,n) /m(isn,jsn,:)
  599. ! vmr = rm_interpol * fscale(n) * uscale(n)
  600. ! stations(q)%c_avg(ispec,3,:) = &
  601. ! stations(q)%c_avg(ispec,3,:) + this_weight*vmr
  602. ! stations(q)%c_std(ispec,3,:) = &
  603. ! stations(q)%c_std(ispec,3,:) + this_weight*vmr*vmr
  604. ! end do !ispec
  605. ! !======================
  606. ! !meteoLvl data at columns
  607. ! !======================
  608. ! !if (output_columns_meteoLvl) then
  609. ! !============================================
  610. ! ! gph already interpolated to xy position of column
  611. ! ! Note that height is defined with index 0:lm(region)
  612. ! ! whereas meteoLvl(8,:) is 1:lm(region)
  613. ! !============================================
  614. ! stations(q)%meteoBnd(2,:) = &
  615. ! stations(q)%meteoBnd(2,:) + this_weight*height(0:(lm(region)))
  616. ! !============================================
  617. ! ! interpolate the blh to xy position of column
  618. ! !============================================
  619. ! blh_interpol = wcx * wcy* blh(is,js) + &
  620. ! (1.0-wcx)* wcy* blh(isn,js) + &
  621. ! wcx *(1.0-wcy)* blh(is,jsn) + &
  622. ! (1.0-wcx)*(1.0-wcy)* blh(isn,jsn)
  623. ! stations(q)%meteoLvl(4,:) = &
  624. ! stations(q)%meteoLvl(4,:) + this_weight*blh_interpol
  625. ! !====================================
  626. ! ! 3D linear interpolation Temperature
  627. ! !====================================
  628. ! T_interpol = &
  629. ! wcx *wcy *wcz *T(is,js,:) + &
  630. ! (1.0-wcx)*wcy *wcz *T(isn,js,:) + &
  631. ! wcx *(1.0-wcy)*wcz *T(is,jsn,:) + &
  632. ! (1.0-wcx)*(1.0-wcy)*wcz *T(isn,jsn,:)
  633. ! stations(q)%meteoLvl(1,:) = &
  634. ! stations(q)%meteoLvl(1,:) + this_weight*T_interpol
  635. ! !====================================
  636. ! ! 3D linear interpolation pressure
  637. ! !====================================
  638. ! p_interpol =(((0.5-rls) * phlb(is,js,1:lm(1)) + (0.5+rls) * phlb(is,js,2:lm(1)+1)) * wcx * wcy + &
  639. ! ((0.5-rls) * phlb(isn,js,1:lm(1)) + (0.5+rls) * phlb(isn,js,2:lm(1)+1)) * (1.0-wcx) * wcy + &
  640. ! ((0.5-rls) * phlb(is,jsn,1:lm(1)) + (0.5+rls) * phlb(is,jsn,2:lm(1)+1)) * wcx * (1.0-wcy) + &
  641. ! ((0.5-rls) * phlb(isn,jsn,1:lm(1))+ (0.5+rls) * phlb(isn,jsn,2:lm(1)+1))* (1.0-wcx) * (1.0-wcy) ) ![Pa]
  642. ! !stations(q)%meteoLvl(2,:) = &
  643. ! ! stations(q)%meteoLvl(2,:) + p_interpol
  644. ! p_interpol_bnd =(phlb(is,js,1:lm(1)+1) * wcx * wcy + &
  645. ! phlb(isn,js,1:lm(1)+1) * (1.0-wcx) * wcy + &
  646. ! phlb(is,jsn,1:lm(1)+1) * wcx * (1.0-wcy) + &
  647. ! phlb(isn,jsn,1:lm(1)+1) * (1.0-wcx) * (1.0-wcy)) ![Pa]
  648. ! stations(q)%meteoBnd(1,:) = &
  649. ! stations(q)%meteoBnd(1,:) + this_weight*p_interpol_bnd
  650. ! !====================================
  651. ! ! 3D windspeed_u_interpol (x-direction)
  652. ! !====================================
  653. ! ! pu is eastward flux through east grid box boundary
  654. ! ! windspeed_u_interpol wind component from east
  655. ! ! latitude of grid cell center js [degrees]
  656. ! lat_j =ybeg(region)+(js -0.5)*dyr
  657. ! ! latitude of grid cell center jsn [degrees]
  658. ! lat_jn=ybeg(region)+(jsn-0.5)*dyr
  659. ! ! x-extension of grid cell js [m]
  660. ! ddx_j =ae * twopi * dxr / 360.0 * cos(lat_j*twopi/360.0)
  661. ! ! x-extension of grid cell jsn [m]
  662. ! ddx_jn=ae * twopi * dxr / 360.0 * cos(lat_jn*twopi/360.0)
  663. ! is_west=is-1
  664. ! if ( xcyc(region) == 0 ) then
  665. ! ! non-cyclic boundaries
  666. ! if ( is_west == 0 ) is_west=1
  667. ! else
  668. ! ! cyclic x-boundaries
  669. ! if ( is_west == 0 ) is_west=im(region)
  670. ! end if
  671. ! !west border !east border
  672. ! windspeed_u_interpol=-(((0.5-ris) * pu(is_west,js,:)/m(is_west,js,:) + &
  673. ! (0.5+ris) * pu(is,js,:)/ m(is,js,:) ) * &
  674. ! ddx_j * wcy * wcz + &
  675. ! ((0.5-ris) * pu(is_west,jsn,:)/m(is_west,jsn,:) + &
  676. ! (0.5+ris) * pu(is,jsn,:)/m(is,jsn,:) ) * &
  677. ! ddx_jn * (1.0-wcy)* wcz + &
  678. ! ((0.5-ris) * pu(is_west,js,:)/m(is_west,js,:) + &
  679. ! (0.5+ris) * pu(is,js,:)/ m(is,js,:)) * &
  680. ! ddx_j * wcy * (1.0-wcz) + &
  681. ! ((0.5-ris) * pu(is_west,jsn,:)/m(is_west,js,:) + &
  682. ! (0.5+ris) * pu(is,jsn,:)/ m(is,jsn,:) ) * &
  683. ! ddx_jn * (1.0-wcy)* (1.0-wcz) )
  684. ! !====================================
  685. ! ! 3D windspeed_v_interpol (y-direction)
  686. ! !====================================
  687. ! ! pv northward flux through south grid box boundary
  688. ! ! windspeed_v_interpol wind component from north
  689. ! ddy =ae * twopi * dyr / 360.0 ! y-extension of grid cell [m]
  690. ! js_south = js-1
  691. ! if (js_south==0) js_south=1
  692. ! js_north = js+1
  693. ! if (js_north==(jm(region)+1)) js_north=jm(region)
  694. ! !south border !north border
  695. ! windspeed_v_interpol=-(( &
  696. ! (0.5-rjs)*pv(is,js,:)/m(is,js_south,:) + &
  697. ! (0.5+rjs)*pv(is,js_north,:)/ m(is,js,:) ) * &
  698. ! wcx * wcz + &
  699. ! ((0.5-rjs)*pv(isn,js,:)/m(isn,js_south,:) + &
  700. ! (0.5+rjs)*pv(isn,js_north,:)/ m(isn,js,:) ) * &
  701. ! (1.0 - wcx)* wcz + &
  702. ! ((0.5-rjs)*pv(is,js,:)/m(is,js_south,:) + &
  703. ! (0.5+rjs)*pv(is,js_north,:)/ m(is,js,:) ) * &
  704. ! wcx * (1.0-wcz) + &
  705. ! ((0.5-rjs)*pv(isn,js,:)/m(isn,js_south,:) + &
  706. ! (0.5+rjs)*pv(isn,js_north,:)/ m(isn,js,:) ) * &
  707. ! (1.0 - wcx)* (1.0-wcz) ) * &
  708. ! ddy
  709. ! !windspeed_interpol = &
  710. ! ! sqrt(windspeed_u_interpol**2 + windspeed_v_interpol**2)
  711. ! stations(q)%meteoLvl(2,:) = &
  712. ! stations(q)%meteoLvl(2,:) + this_weight*windspeed_u_interpol
  713. ! stations(q)%meteoLvl(3,:) = &
  714. ! stations(q)%meteoLvl(3,:) + this_weight*windspeed_v_interpol
  715. ! !endif ! meteoLvl out...
  716. ! stations(q)%ndata = stations(q)%ndata + 1
  717. ! stations(q)%accum_weight = stations(q)%accum_weight + this_weight
  718. ! end if
  719. ! end do ! end q loop
  720. ! endif ! myid = root_t
  721. ! nullify(m)
  722. ! nullify(rm)
  723. ! nullify(rxm)
  724. ! nullify(rym)
  725. ! nullify(rzm)
  726. ! nullify(gph)
  727. ! nullify(oro)
  728. ! nullify(t)
  729. ! nullify(pu)
  730. ! nullify(pv)
  731. ! nullify(phlb)
  732. ! nullify(blh)
  733. ! #ifdef MPI
  734. ! deallocate(rmg)
  735. ! deallocate(rxmg)
  736. ! deallocate(rymg)
  737. ! deallocate(rzmg)
  738. ! deallocate(mg)
  739. ! #endif
  740. ! ok
  741. status = 0
  742. end subroutine user_output_column_accum
  743. subroutine user_output_column_evaluate(status)
  744. !==================================================================
  745. ! evaluate mean concentration and std
  746. !==================================================================
  747. ! use dims, only : idate
  748. ! use ParTools, only: myid, root
  749. ! use toolbox, only : escape_tm
  750. ! use binas, only : twopi
  751. ! implicit none
  752. integer, intent(out) :: status
  753. ! integer q, i, ii,iii
  754. ! integer ndata, isds, nsds, itp
  755. ! real :: accum_weight
  756. ! real temp
  757. ! real, dimension(:,:), allocatable :: cout ! to get output
  758. ! integer, dimension(:,:), allocatable :: iidate
  759. ! real :: windspeed_u_interpol ! wind speed [m/s] x-direction , interpolated to column location
  760. ! real :: windspeed_v_interpol ! wind speed [m/s] y-direction , interpolated to column location
  761. ! real :: windspeed_interpol ! wind speed [m/s] , interpolated to column location
  762. ! real :: winddir_interpol ! wind direction , interpolated to column location
  763. ! if(myid /= root) return
  764. ! if(evaluated) return
  765. ! do q=1, nstations
  766. ! accum_weight = stations(q)%accum_weight
  767. ! if (accum_weight > 0.0) then
  768. ! stations(q)%c_avg(:,:,:) = stations(q)%c_avg(:,:,:) / accum_weight
  769. ! stations(q)%meteoLvl(:,:) = stations(q)%meteoLvl(:,:) / accum_weight
  770. ! stations(q)%meteoBnd(:,:) = stations(q)%meteoBnd(:,:) / accum_weight
  771. ! if (ndata > 1) then
  772. ! do i=1, nspecies
  773. ! do ii= 1, nmethods
  774. ! do iii= 1, lm(1)
  775. ! temp = (((stations(q)%c_std(i,ii,iii)/accum_weight) - real(ndata) * ((stations(q)%c_avg(i,ii,iii))**2) ) / (real(ndata)-1.0) )
  776. ! if(temp > 0) then
  777. ! stations(q)%c_std(i,ii,iii) = sqrt(temp)
  778. ! else
  779. ! stations(q)%c_std(i,ii,iii) = 0.0
  780. ! endif
  781. ! enddo
  782. ! enddo
  783. ! enddo
  784. ! else
  785. ! stations(q)%c_std(:,:,:)=-1.0
  786. ! end if
  787. ! else
  788. ! stations(q)%c_avg(:,:,:)= -1.0
  789. ! stations(q)%c_std(:,:,:) = -1.0
  790. ! stations(q)%meteoLvl(:,:) = -999.
  791. ! stations(q)%meteoBnd(:,:) = -999.
  792. ! end if
  793. ! !do i=1,lm(1)
  794. ! ! windspeed_u_interpol = stations(q)%meteoLvl(3,i)
  795. ! ! windspeed_v_interpol = stations(q)%meteoLvl(4,i)
  796. ! ! windspeed_interpol = stations(q)%meteoLvl(5,i)
  797. ! ! !====================================
  798. ! ! ! wind direction
  799. ! ! !====================================
  800. ! ! ! definition of winddirection:
  801. ! ! ! east : 90
  802. ! ! ! south : 180
  803. ! ! ! west : 270
  804. ! ! ! north : 360
  805. ! ! if ((windspeed_u_interpol > 0) .and. (windspeed_v_interpol > 0))then ! wind from north east (0...90)
  806. ! ! winddir_interpol = atan(windspeed_u_interpol / windspeed_v_interpol) * 360.0 / twopi
  807. ! ! else if ((windspeed_u_interpol > 0) .and. (windspeed_v_interpol < 0)) then ! wind from south east (90...180)
  808. ! ! winddir_interpol = 180.0+atan(windspeed_u_interpol / windspeed_v_interpol) * 360.0 / twopi
  809. ! ! else if ((windspeed_u_interpol > 0) .and. (windspeed_v_interpol == 0)) then ! wind from east (90)
  810. ! ! winddir_interpol = 90.0
  811. ! ! else if ((windspeed_u_interpol < 0) .and. (windspeed_v_interpol > 0)) then ! wind from north west (270... 360)
  812. ! ! winddir_interpol = 360.0+atan(windspeed_u_interpol / windspeed_v_interpol) * 360.0 / twopi
  813. ! ! else if ((windspeed_u_interpol < 0) .and. (windspeed_v_interpol < 0)) then ! wind from south west (180...270)
  814. ! ! winddir_interpol = 180.0+atan(windspeed_u_interpol / windspeed_v_interpol) * 360.0 / twopi
  815. ! ! else if ((windspeed_u_interpol < 0) .and. (windspeed_v_interpol == 0)) then ! wind from west (270)
  816. ! ! winddir_interpol = 270.0
  817. ! ! else if ((windspeed_u_interpol == 0) .and. (windspeed_v_interpol > 0)) then ! wind from north (360)
  818. ! ! winddir_interpol = 360.0
  819. ! ! else if ((windspeed_u_interpol == 0) .and. (windspeed_v_interpol < 0)) then ! wind from south (180)
  820. ! ! winddir_interpol = 180.0
  821. ! ! else if ((windspeed_u_interpol == 0) .and. (windspeed_v_interpol == 0)) then ! no wind
  822. ! ! winddir_interpol = -1.0
  823. ! ! else
  824. ! ! call escape_tm('output_columnconc: error wind direction')
  825. ! ! end if
  826. ! ! stations(q)%meteoLvl(6,i) = winddir_interpol
  827. ! ! end do
  828. ! end do
  829. ! evaluated = .TRUE.
  830. ! ok
  831. status = 0
  832. end subroutine user_output_column_evaluate
  833. subroutine user_output_column_write( region, status )
  834. ! use ParTools, only : myid, root
  835. ! use global_data, only : outdir
  836. ! use dims, only : region_name
  837. ! use datetime, only : tau2date, date2tau, idate2ddate
  838. ! use MDF, only : MDF_Create, MDF_Close, MDF_EndDef
  839. ! use MDF, only : MDF_NETCDF, MDF_REPLACE, MDF_GLOBAL, MDF_INT, MDF_FLOAT, MDF_UNLIMITED, MDF_DOUBLE, MDF_CHAR
  840. ! use MDF, only : MDF_Put_Att, MDF_Def_Dim, MDF_Def_Var, MDF_Put_Var
  841. ! implicit none
  842. ! --- in/out ------------------------
  843. integer, intent(out) :: status
  844. integer, intent(in) :: region
  845. ! --- variables -----------------------
  846. ! character(len=1024) :: outfile
  847. ! integer :: fid
  848. ! integer :: i, ii, q
  849. ! integer :: dimid_stations, dimid_date, dimid_cal, dimid_nchar
  850. ! integer :: dimid_lvl, dimid_bnd
  851. ! integer :: varid_desc, varid_id, varid_date_int, varid_column_int
  852. ! integer :: varid_elapsed, varid_dec, varid_cal_int, varid_oro
  853. ! integer :: varid_lvl, varid_bnd, varid_lon, varid_lat, varid_hgt, varid_total
  854. ! integer, dimension(nspecies, nmethods) :: varid_species
  855. ! integer, dimension(nmeteoLvl) :: varid_meteoLvl
  856. ! integer, dimension(nmeteoBnd) :: varid_meteoBnd
  857. ! integer :: itau_start
  858. ! integer :: itau_end
  859. ! integer :: itau_avg
  860. ! integer :: itau_ref
  861. ! integer :: itau_elapsed
  862. ! real*8 :: ddate_avg
  863. ! real*8 :: days_elapsed
  864. ! integer, dimension(6) :: idate_ref
  865. ! integer, dimension(6) :: idate_avg
  866. ! character(len=256) :: notes
  867. ! character(len=1024) :: disclaimer
  868. ! character(len=256) :: email
  869. ! character(len=256) :: url
  870. ! character(len=256) :: institution
  871. ! character(len=256) :: conventions
  872. ! character(len=256) :: history
  873. ! character(len=256) :: source
  874. ! character(len=256) :: sysdate
  875. ! character(len=256) :: progstring
  876. ! integer, dimension(8) :: isysdate
  877. ! integer :: nstationsRegion
  878. ! integer, dimension(:), allocatable :: idxRegion
  879. ! real, dimension(:,:,:), allocatable :: ncArr ! collect output for ncdf writes
  880. ! real, dimension(:,:,:), allocatable :: ncArr_co2_total ! collect total co2 for ncdf writes
  881. ! ! --- constants -----------------------
  882. ! character(len=*), parameter :: rname = mname//'/user_output_column_write'
  883. ! real*4 :: fillval_r4 = -1e34
  884. ! ! --- begin -------------------------------
  885. ! if(myid /= root) return
  886. ! ! subset column list by region
  887. ! nstationsRegion = count( stations%region == region )
  888. ! allocate(idxRegion(nstationsRegion))
  889. ! allocate(stationsRegion(nstationsRegion))
  890. ! ii = 0
  891. ! do i = 1, nstations ! there must be a better way to do this...
  892. ! if (stations(i)%region == region) then
  893. ! ii = ii + 1
  894. ! idxRegion(ii) = i
  895. ! end if
  896. ! end do
  897. ! stationsRegion = stations(idxRegion)
  898. ! call tau2date(itaur(region), timestamp(region)%idate_end)
  899. ! call date_and_time(values = isysdate)
  900. ! write (sysdate, '(i4.4,"-",i2.2,"-",i2.2," ",i2.2,":",i2.2,":",i2.2," UTC")') &
  901. ! isysdate(1), isysdate(2), isysdate(3), isysdate(5), isysdate(6), isysdate(7)
  902. ! ! Standard file information for CarbonTracker output.
  903. ! notes = "This file contains CarbonTracker time averaged mole fractions for vertical profiles at select sampling locations."
  904. ! disclaimer = "CarbonTracker is an open product of the NOAA Earth System Research \n"//&
  905. ! "Laboratory using data from the Global Monitoring Division greenhouse \n"//&
  906. ! "gas observational network and collaborating institutions. Model results \n"//&
  907. ! "including figures and tabular material found on the CarbonTracker \n"//&
  908. ! "website may be used for non-commercial purposes without restriction,\n"//&
  909. ! "but we request that the following acknowledgement text be included \n"//&
  910. ! "in documents or publications made using CarbonTracker results: \n\n"//&
  911. ! " CarbonTracker results provided by NOAA/ESRL,\n"//&
  912. ! " Boulder, Colorado, USA, http://carbontracker.noaa.gov\n\n"//&
  913. ! "Since we expect to continuously update the CarbonTracker product, it\n"//&
  914. ! "is important to identify which version you are using. To provide\n"//&
  915. ! "accurate citation, please include the version of the CarbonTracker\n"//&
  916. ! "release in any use of these results.\n\n"//&
  917. ! "The CarbonTracker team welcomes special requests for data products not\n"//&
  918. ! "offered by default on this website, and encourages proposals for\n"//&
  919. ! "collaborative activities. Contact us at carbontracker.team@noaa.gov.\n"
  920. ! email = "carbontracker.team@noaa.gov"
  921. ! url = "http://carbontracker.noaa.gov"
  922. ! institution = "NOAA Earth System Research Laboratory"
  923. ! conventions = "CF-1.5"
  924. ! call getarg (0, progstring, status)
  925. ! write(history,'("Created ",a," by ",a,".")') trim(sysdate),trim(progstring)
  926. ! source = "CarbonTracker release CT2012"
  927. ! ! date/time conversions
  928. ! call date2tau(timestamp(region)%idate_start, itau_start)
  929. ! call date2tau(timestamp(region)%idate_end, itau_end)
  930. ! itau_avg = nint(5.0D-1 * dble(itau_start + itau_end))
  931. ! call tau2date(itau_avg, idate_avg)
  932. ! ddate_avg = idate2ddate(idate_avg)
  933. ! idate_ref = (/2000, 1, 1, 0, 0, 0/)
  934. ! call date2tau(idate_ref, itau_ref)
  935. ! itau_elapsed = itau_avg - itau_ref
  936. ! days_elapsed = dble(itau_elapsed) / 86400.0D+0
  937. ! write (outfile, '(a,"/column_",a,"_",i4.4,4i2.2,"_",i4.4,4i2.2,".nc")') &
  938. ! trim(outdir), trim(region_name(region)), timestamp(region)%idate_start(1:5), timestamp(region)%idate_end(1:5)
  939. ! ! create new file
  940. ! call MDF_Create( trim(outfile), MDF_NETCDF, MDF_REPLACE, fid, status )
  941. ! IF_ERROR_RETURN(status=1)
  942. ! ! global attributes
  943. ! call MDF_Put_Att( fid, MDF_GLOBAL, "notes", values=trim(notes), status=status )
  944. ! IF_ERROR_RETURN(status=1)
  945. ! call MDF_Put_Att( fid, MDF_GLOBAL, "disclaimer", values=trim(disclaimer), status=status )
  946. ! IF_ERROR_RETURN(status=1)
  947. ! call MDF_Put_Att( fid, MDF_GLOBAL, "email", values=trim(email), status=status )
  948. ! IF_ERROR_RETURN(status=1)
  949. ! call MDF_Put_Att( fid, MDF_GLOBAL, "url", values=trim(url), status=status )
  950. ! IF_ERROR_RETURN(status=1)
  951. ! call MDF_Put_Att( fid, MDF_GLOBAL, "institution", values=trim(institution), status=status )
  952. ! IF_ERROR_RETURN(status=1)
  953. ! call MDF_Put_Att( fid, MDF_GLOBAL, "conventions", values=trim(conventions), status=status )
  954. ! IF_ERROR_RETURN(status=1)
  955. ! call MDF_Put_Att( fid, MDF_GLOBAL, "history", values=trim(history), status=status )
  956. ! IF_ERROR_RETURN(status=1)
  957. ! call MDF_Put_Att( fid, MDF_GLOBAL, "source", values=trim(source), status=status )
  958. ! IF_ERROR_RETURN(status=1)
  959. ! call MDF_Put_Att( fid, MDF_GLOBAL, "region_name", values=trim(region_name(region)), status=status )
  960. ! IF_ERROR_RETURN(status=1)
  961. ! ! define dimensions
  962. ! call MDF_Def_Dim( fid, 'date', MDF_UNLIMITED, dimid_date, status )
  963. ! IF_ERROR_RETURN(status=1)
  964. ! call MDF_Def_Dim( fid, 'calendar_components', 6, dimid_cal, status )
  965. ! IF_ERROR_RETURN(status=1)
  966. ! call MDF_Def_Dim( fid, "level", lm(region), dimid_lvl, status )
  967. ! IF_ERROR_RETURN(status=1)
  968. ! call MDF_Def_Dim( fid, "boundary", lm(region)+1, dimid_bnd, status )
  969. ! IF_ERROR_RETURN(status=1)
  970. ! call MDF_Def_Dim( fid, "station", nstationsRegion, dimid_stations, status )
  971. ! IF_ERROR_RETURN(status=1)
  972. ! call MDF_Def_Dim( fid, "character_length", 50, dimid_nchar, status ) ! must be GE character lengths defined in column list derived type
  973. ! IF_ERROR_RETURN(status=1)
  974. ! ! dimension variables
  975. ! call MDF_Def_Var( fid, 'date', MDF_DOUBLE, (/dimid_date/), varid_elapsed, status )
  976. ! IF_ERROR_RETURN(status=1)
  977. ! call MDF_Put_Att( fid, varid_elapsed, "units", values="days since 2000-01-01 00:00:00 UTC", status=status )
  978. ! IF_ERROR_RETURN(status=1)
  979. ! call MDF_Put_Att( fid, varid_elapsed, "long_name", values="date", status=status )
  980. ! IF_ERROR_RETURN(status=1)
  981. ! call MDF_Def_Var( fid, 'decimal_date', MDF_DOUBLE, (/dimid_date/), varid_dec, status )
  982. ! IF_ERROR_RETURN(status=1)
  983. ! call MDF_Put_Att( fid, varid_dec, "units", values="years", status=status )
  984. ! IF_ERROR_RETURN(status=1)
  985. ! call MDF_Put_Att( fid, varid_dec, "_FillValue", values=-1e34, status=status )
  986. ! IF_ERROR_RETURN(status=1)
  987. ! call MDF_Def_Var( fid, 'calendar_components', MDF_INT, (/dimid_cal/), varid_cal_int, status )
  988. ! IF_ERROR_RETURN(status=1)
  989. ! call MDF_Put_Att( fid, varid_cal_int, "units", values="none", status=status )
  990. ! IF_ERROR_RETURN(status=1)
  991. ! call MDF_Put_Att( fid, varid_cal_int, "long_name", values="calendar components", status=status )
  992. ! IF_ERROR_RETURN(status=1)
  993. ! call MDF_Def_Var( fid, 'date_components', MDF_INT, (/dimid_cal, dimid_date/), varid_date_int, status )
  994. ! IF_ERROR_RETURN(status=1)
  995. ! call MDF_Put_Att( fid, varid_date_int, "units", values="none", status=status )
  996. ! IF_ERROR_RETURN(status=1)
  997. ! call MDF_Put_Att( fid, varid_date_int, "long_name", values="integer value calendar components of UTC date", status=status )
  998. ! IF_ERROR_RETURN(status=1)
  999. ! call MDF_Put_Att( fid, varid_date_int, "comment", values="year, month, day, hour, minute, second", status=status )
  1000. ! IF_ERROR_RETURN(status=1)
  1001. ! call MDF_Def_Var( fid, 'station_index', MDF_INT, (/dimid_stations/), varid_column_int, status )
  1002. ! IF_ERROR_RETURN(status=1)
  1003. ! call MDF_Put_Att( fid, varid_column_int, "units", values="none", status=status )
  1004. ! IF_ERROR_RETURN(status=1)
  1005. ! call MDF_Put_Att( fid, varid_column_int, "long_name", values="station index", status=status )
  1006. ! IF_ERROR_RETURN(status=1)
  1007. ! call MDF_Def_Var( fid, 'lon', MDF_DOUBLE, (/dimid_stations/), varid_lon, status )
  1008. ! IF_NOTOK_RETURN(status=1)
  1009. ! call MDF_Put_Att( fid, varid_lon, "units", values="degrees east", status=status )
  1010. ! IF_NOTOK_RETURN(status=1)
  1011. ! call MDF_Put_Att( fid, varid_lon, "long_name", values="longitude", status=status )
  1012. ! IF_NOTOK_RETURN(status=1)
  1013. ! call MDF_Put_Att( fid, varid_lon, "actual_range", values=(/xbeg(region), xend(region)/), status=status )
  1014. ! IF_NOTOK_RETURN(status=1)
  1015. ! call MDF_Def_Var( fid, 'lat', MDF_DOUBLE, (/dimid_stations/), varid_lat, status )
  1016. ! IF_NOTOK_RETURN(status=1)
  1017. ! call MDF_Put_Att( fid, varid_lat, "units", values="degrees north", status=status )
  1018. ! IF_NOTOK_RETURN(status=1)
  1019. ! call MDF_Put_Att( fid, varid_lat, "long_name", values="latitude", status=status )
  1020. ! IF_NOTOK_RETURN(status=1)
  1021. ! call MDF_Put_Att( fid, varid_lat, "actual_range", values=(/ybeg(region), yend(region)/), status=status )
  1022. ! IF_NOTOK_RETURN(status=1)
  1023. ! call MDF_Def_Var( fid, 'alt', MDF_DOUBLE, (/dimid_stations/), varid_hgt, status )
  1024. ! IF_NOTOK_RETURN(status=1)
  1025. ! call MDF_Put_Att( fid, varid_hgt, "units", values="meters", status=status )
  1026. ! IF_NOTOK_RETURN(status=1)
  1027. ! call MDF_Put_Att( fid, varid_hgt, "long_name", values="altitude", status=status )
  1028. ! IF_NOTOK_RETURN(status=1)
  1029. ! call MDF_Put_Att( fid, varid_hgt, "actual_range", values=(/zbeg(region), zend(region)/), status=status )
  1030. ! IF_NOTOK_RETURN(status=1)
  1031. ! call MDF_Def_Var( fid, 'level', MDF_INT, (/dimid_lvl/), varid_lvl, status )
  1032. ! IF_NOTOK_RETURN(status=1)
  1033. ! call MDF_Put_Att( fid, varid_lvl, "units", values="none", status=status )
  1034. ! IF_NOTOK_RETURN(status=1)
  1035. ! call MDF_Put_Att( fid, varid_lvl, "long_name", values="level", status=status )
  1036. ! IF_NOTOK_RETURN(status=1)
  1037. ! call MDF_Put_Att( fid, varid_lvl, "positive", values="up", status=status )
  1038. ! IF_NOTOK_RETURN(status=1)
  1039. ! call MDF_Def_Var( fid, 'boundary', MDF_INT, (/dimid_bnd/), varid_bnd, status )
  1040. ! IF_NOTOK_RETURN(status=1)
  1041. ! call MDF_Put_Att( fid, varid_bnd, "units", values="none", status=status )
  1042. ! IF_NOTOK_RETURN(status=1)
  1043. ! call MDF_Put_Att( fid, varid_bnd, "long_name", values="boundary", status=status )
  1044. ! IF_NOTOK_RETURN(status=1)
  1045. ! call MDF_Put_Att( fid, varid_bnd, "positive", values="up", status=status )
  1046. ! IF_NOTOK_RETURN(status=1)
  1047. ! call MDF_Def_Var( fid, 'station_names', MDF_CHAR, (/dimid_nchar, dimid_stations/), varid_desc, status )
  1048. ! IF_ERROR_RETURN(status=1)
  1049. ! call MDF_Put_Att( fid, varid_desc, "long_name", values="station names", status=status )
  1050. ! IF_NOTOK_RETURN(status=1)
  1051. ! call MDF_Put_Att( fid, varid_desc, "standard_name", values="station description", status=status )
  1052. ! IF_NOTOK_RETURN(status=1)
  1053. ! call MDF_Def_Var( fid, 'station_id', MDF_CHAR, (/dimid_nchar, dimid_stations/), varid_id, status )
  1054. ! IF_ERROR_RETURN(status=1)
  1055. ! call MDF_Put_Att( fid, varid_id, "long_name", values="station id", status=status )
  1056. ! IF_NOTOK_RETURN(status=1)
  1057. ! call MDF_Put_Att( fid, varid_id, "standard_name", values="station code", status=status )
  1058. ! IF_NOTOK_RETURN(status=1)
  1059. ! call MDF_Def_Var( fid, 'oro', MDF_FLOAT, (/dimid_stations/), varid_oro, status )
  1060. ! IF_NOTOK_RETURN(status=1)
  1061. ! call MDF_Put_Att( fid, varid_oro, "units", values="m^s/s^2", status=status )
  1062. ! IF_NOTOK_RETURN(status=1)
  1063. ! call MDF_Put_Att( fid, varid_oro, "long_name", values="orography", status=status )
  1064. ! IF_NOTOK_RETURN(status=1)
  1065. ! call MDF_Put_Att( fid, varid_oro, "standard_name", values="surface geopotential", status=status )
  1066. ! IF_NOTOK_RETURN(status=1)
  1067. ! call MDF_Def_Var( fid, 'co2', MDF_FLOAT, (/dimid_stations, dimid_lvl, dimid_date/), varid_total, status )
  1068. ! IF_NOTOK_RETURN(status=1)
  1069. ! call MDF_Put_Att( fid, varid_total, "units", values="micromol mol-1", status=status )
  1070. ! IF_NOTOK_RETURN(status=1)
  1071. ! call MDF_Put_Att( fid, varid_total, "long_name", values="mole fraction of carbon dioxide in air", status=status )
  1072. ! IF_NOTOK_RETURN(status=1)
  1073. ! call MDF_Put_Att( fid, varid_total, "comment", values="total carbon dioxide estimate", status=status )
  1074. ! IF_NOTOK_RETURN(status=1)
  1075. ! do i = 1, nspecies
  1076. ! call MDF_Def_Var( fid, trim(names(species(i))), MDF_FLOAT, (/dimid_stations, dimid_lvl, dimid_date/), varid_species(i, writeMethod), status )
  1077. ! IF_NOTOK_RETURN(status=1)
  1078. ! call MDF_Put_Att( fid, varid_species(i, writeMethod), "units", values='micromol mol-1', status=status )
  1079. ! IF_NOTOK_RETURN(status=1)
  1080. ! call MDF_Put_Att( fid, varid_species(i, writeMethod), "_FillValue", values=fillval_r4, status=status )
  1081. ! IF_NOTOK_RETURN(status=1)
  1082. ! call MDF_Put_Att( fid, varid_species(i, writeMethod), "long_name", values='mole fraction of carbon dioxide in air', status=status )
  1083. ! IF_NOTOK_RETURN(status=1)
  1084. ! call MDF_Put_Att( fid, varid_species(i, writeMethod), "comment", values=comment_species(i), status=status )
  1085. ! IF_NOTOK_RETURN(status=1)
  1086. ! enddo
  1087. ! do i = 1, nmeteoLvl
  1088. ! if (i .eq. 4) then
  1089. ! call MDF_Def_Var( fid, name_meteoLvl(i), MDF_FLOAT, (/dimid_stations, dimid_date/), varid_meteoLvl(i), status )
  1090. ! else
  1091. ! call MDF_Def_Var( fid, name_meteoLvl(i), MDF_FLOAT, (/dimid_stations, dimid_lvl, dimid_date/), varid_meteoLvl(i), status )
  1092. ! endif
  1093. ! IF_NOTOK_RETURN(status=1)
  1094. ! call MDF_Put_Att( fid, varid_meteoLvl(i), "units", values=units_meteoLvl(i), status=status )
  1095. ! IF_NOTOK_RETURN(status=1)
  1096. ! call MDF_Put_Att( fid, varid_meteoLvl(i), "long_name", values=long_name_meteoLvl(i), status=status )
  1097. ! IF_NOTOK_RETURN(status=1)
  1098. ! call MDF_Put_Att( fid, varid_meteoLvl(i), "standard_name", values=standard_name_meteoLvl(i), status=status )
  1099. ! IF_NOTOK_RETURN(status=1)
  1100. ! enddo
  1101. ! do i = 1, nmeteoBnd
  1102. ! call MDF_Def_Var( fid, name_meteoBnd(i), MDF_FLOAT, (/dimid_stations, dimid_bnd, dimid_date/), varid_meteoBnd(i), status )
  1103. ! IF_NOTOK_RETURN(status=1)
  1104. ! call MDF_Put_Att( fid, varid_meteoBnd(i), "units", values=units_meteoBnd(i), status=status )
  1105. ! IF_NOTOK_RETURN(status=1)
  1106. ! call MDF_Put_Att( fid, varid_meteoBnd(i), "long_name", values=long_name_meteoBnd(i), status=status )
  1107. ! IF_NOTOK_RETURN(status=1)
  1108. ! call MDF_Put_Att( fid, varid_meteoBnd(i), "standard_name", values=standard_name_meteoBnd(i), status=status )
  1109. ! IF_NOTOK_RETURN(status=1)
  1110. ! enddo
  1111. ! ! finished definition
  1112. ! call MDF_EndDef( fid, status )
  1113. ! IF_ERROR_RETURN(status=1)
  1114. ! ! write variables
  1115. ! call MDF_Put_Var( fid, varid_elapsed, (/(days_elapsed)/), status )
  1116. ! IF_ERROR_RETURN(status=1)
  1117. ! call MDF_Put_Var( fid, varid_dec, (/(ddate_avg)/), status )
  1118. ! IF_ERROR_RETURN(status=1)
  1119. ! call MDF_Put_Var( fid, varid_cal_int, (/(i,i=1,size(idate_avg))/), status )
  1120. ! IF_ERROR_RETURN(status=1)
  1121. ! call MDF_Put_Var( fid, varid_date_int, idate_avg, status )
  1122. ! IF_ERROR_RETURN(status=1)
  1123. ! call MDF_Put_Var( fid, varid_desc, (/(trim(stationsRegion(i)%desc),i=1,nstationsRegion)/), status )
  1124. ! IF_ERROR_RETURN(status=1)
  1125. ! call MDF_Put_Var( fid, varid_id, (/(trim(stationsRegion(i)%id),i=1,nstationsRegion)/), status )
  1126. ! IF_ERROR_RETURN(status=1)
  1127. ! call MDF_Put_Var( fid, varid_column_int, (/(i,i=1,size(stationsRegion))/), status)
  1128. ! IF_ERROR_RETURN(status=1)
  1129. ! call MDF_Put_Var( fid, varid_lat, stationsRegion%lat, status)
  1130. ! IF_ERROR_RETURN(status=1)
  1131. ! call MDF_Put_Var( fid, varid_lon, stationsRegion%lon, status)
  1132. ! IF_ERROR_RETURN(status=1)
  1133. ! call MDF_Put_Var( fid, varid_lvl, (/(i,i=1,lm(region))/), status)
  1134. ! IF_ERROR_RETURN(status=1)
  1135. ! call MDF_Put_Var( fid, varid_bnd, (/(i,i=1,lm(region)+1)/), status)
  1136. ! IF_ERROR_RETURN(status=1)
  1137. ! call MDF_Put_Var( fid, varid_hgt, stationsRegion%height, status)
  1138. ! IF_ERROR_RETURN(status=1)
  1139. ! call MDF_Put_Var( fid, varid_oro, stationsRegion%oro, status)
  1140. ! IF_ERROR_RETURN(status=1)
  1141. ! allocate(ncArr(nstationsRegion, lm(region), 1))
  1142. ! allocate(ncArr_co2_total(nstationsRegion, lm(region), 1))
  1143. ! ncArr_co2_total = 0.0
  1144. ! do i = 1, nspecies
  1145. ! do q = 1, nstationsRegion
  1146. ! ncArr(q,:,1) = stationsRegion(q)%c_avg(i,writeMethod,:)
  1147. ! ! subtract the background tracer from the others
  1148. ! if (i .gt. 1) then
  1149. ! ncArr(q,:,1) = ncArr(q,:,1) - stationsRegion(q)%c_avg(1,writeMethod,:)
  1150. ! endif
  1151. ! ncArr_co2_total(q,:,1) = ncArr_co2_total(q,:,1) + ncArr(q,:,1)
  1152. ! enddo
  1153. ! call MDF_Put_Var( fid, varid_species(i,writeMethod), ncArr, status )
  1154. ! IF_ERROR_RETURN(status=1)
  1155. ! enddo
  1156. ! call MDF_Put_Var( fid, varid_total, ncArr_co2_total, status )
  1157. ! IF_ERROR_RETURN(status=1)
  1158. ! deallocate(ncArr_co2_total)
  1159. ! do i = 1, nmeteoLvl
  1160. ! do q = 1, nstationsRegion
  1161. ! ncArr(q,:,1) = stationsRegion(q)%meteoLvl(i,:)
  1162. ! enddo
  1163. ! if (i .eq. 4) then
  1164. ! call MDF_Put_Var( fid, varid_meteoLvl(i), ncArr(:,1,:), status )
  1165. ! else
  1166. ! call MDF_Put_Var( fid, varid_meteoLvl(i), ncArr, status )
  1167. ! endif
  1168. ! IF_ERROR_RETURN(status=1)
  1169. ! enddo
  1170. ! deallocate(ncArr)
  1171. ! allocate(ncArr(nstationsRegion, lm(region)+1, 1))
  1172. ! do i = 1, nmeteoBnd
  1173. ! do q = 1, nstationsRegion
  1174. ! ncArr(q,:,1) = stationsRegion(q)%meteoBnd(i,:)
  1175. ! enddo
  1176. ! call MDF_Put_Var( fid, varid_meteoBnd(i), ncArr, status )
  1177. ! IF_ERROR_RETURN(status=1)
  1178. ! enddo
  1179. ! deallocate(ncArr)
  1180. ! ! close file
  1181. ! call MDF_Close( fid, status )
  1182. ! IF_ERROR_RETURN(status=1)
  1183. ! write (gol, '("'//trim(rname)//' Done writing arrays and closing output file.")'); call goPr
  1184. ! timestamp(region)%idate_start = timestamp(region)%idate_end ! end of interval becomes start of next interval
  1185. ! deallocate(idxRegion)
  1186. ! deallocate(stationsRegion)
  1187. ! ok
  1188. status = 0
  1189. end subroutine user_output_column_write
  1190. subroutine user_output_column_reset( region )
  1191. ! use ParTools, only: root_t, myid
  1192. ! implicit none
  1193. integer, intent(in) :: region
  1194. ! integer :: q
  1195. ! if (myid /= root_t) return
  1196. ! do q=1, nstations
  1197. ! stations(q)%c_avg(:,:,:) = 0.0
  1198. ! stations(q)%c_std(:,:,:) = 0.0
  1199. ! stations(q)%meteoLvl(:,:) = 0.0
  1200. ! stations(q)%meteoBnd(:,:) = 0.0
  1201. ! stations(q)%ndata = 0
  1202. ! stations(q)%accum_weight = 0.0
  1203. ! end do
  1204. ! evaluated = .FALSE.
  1205. end subroutine user_output_column_reset
  1206. subroutine user_output_column_done( status )
  1207. ! use Partools, only : myid, root
  1208. ! use dims, only : nregions
  1209. ! implicit none
  1210. ! --- in/out ------------------------
  1211. integer, intent(out) :: status
  1212. ! --- variables ---------------------------
  1213. ! integer :: region
  1214. ! integer :: q
  1215. ! ! --- constants ---------------------------
  1216. ! character(len=*), parameter :: rname = mname//'/user_output_column_done'
  1217. ! ! --- begin -------------------------------
  1218. ! if (myid /= root) return
  1219. ! do region = 1, nregions
  1220. ! call user_output_column_evaluate( status )
  1221. ! IF_NOTOK_RETURN(status=1)
  1222. ! call user_output_column_write( region, status )
  1223. ! IF_NOTOK_RETURN(status=1)
  1224. ! end do
  1225. ! do q = 1, nstations
  1226. ! deallocate(stations(q)%c_avg)
  1227. ! deallocate(stations(q)%c_std)
  1228. ! enddo
  1229. ! deallocate(stations)
  1230. ! ok
  1231. status = 0
  1232. end subroutine user_output_column_done
  1233. end module user_output_column