user_output.F90 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326
  1. !#################################################################
  2. !
  3. ! contains calls to user-specific output routines, e.g.
  4. ! instantaneous mix files, station output, output of flight tracks etc.
  5. !
  6. !### macro's #####################################################
  7. !
  8. #define TRACEBACK write (gol,'("in ",a," (",a,", line",i5,")")') rname, __FILE__, __LINE__; call goErr
  9. #define IF_NOTOK_RETURN(action) if (status/=0) then; TRACEBACK; action; return; end if
  10. #define IF_ERROR_RETURN(action) if (status> 0) then; TRACEBACK; action; return; end if
  11. !
  12. #include "tm5.inc"
  13. !
  14. !#################################################################
  15. module user_output
  16. use GO, only : gol, goPr, goErr, goBug, goLabel
  17. implicit none
  18. ! --- in/out ------------------------
  19. private
  20. public :: user_output_step, User_output_Init, User_output_Done
  21. public :: user_output_mean
  22. ! --- const -------------------------
  23. character(len=*), parameter :: mname = 'User_output'
  24. ! --- var ---------------------------
  25. ! logical :: flight_data = .false. ! signal for flight output
  26. !
  27. ! logical :: station_data = .true. ! signal for station output
  28. !
  29. ! logical :: mix_data = .false. ! signal for mix output
  30. ! integer :: mix_data_dhour ! every dhour hour
  31. !
  32. logical :: mmix_data = .false. ! signal for mean mix output
  33. !
  34. !#ifdef with_retro_output
  35. ! logical :: output_retro = .false.
  36. ! integer :: output_retro_dhour ! every dhour hour
  37. !#endif
  38. contains
  39. !-------------------------------------------------------------
  40. ! user_output_init:
  41. ! Initialise user-specified model output (all regions)
  42. !-------------------------------------------------------------
  43. ! Now require temperature if mmix_data is true, since it is acumulated in
  44. ! mmix module, and may not be set otherwise
  45. subroutine User_output_Init( status )
  46. use GO, only : TrcFile, Init, Done, ReadRc
  47. use global_data, only : rcfile
  48. use User_Output_Common , only : User_Output_Common_Init
  49. use user_output_mmix, only : mmix_Init
  50. use MeteoData, only : Set, temper_dat
  51. use dims, only : nregions
  52. ! use user_output_station, only : read_stationlist, init_station_output
  53. ! use user_output_mix, only : output_mix_init
  54. !#ifdef with_retro_output
  55. ! use user_output_retro , only : output_retro_init
  56. !#endif
  57. ! --- in/out -----------------------------
  58. integer, intent(inout) :: status
  59. ! --- const ------------------------------
  60. character(len=*), parameter :: rname = mname//'/User_output_Init'
  61. ! --- local -------------------------------
  62. type(TrcFile) :: rcF
  63. integer :: n
  64. ! --- begin -------------------------------
  65. call goLabel(rname)
  66. ! init common stuff:
  67. call User_Output_Common_Init( status )
  68. IF_NOTOK_RETURN(status=1)
  69. call Init( rcF, rcfile, status )
  70. IF_NOTOK_RETURN(status=1)
  71. !
  72. ! call ReadRc( rcF, 'output.station', station_data, status )
  73. ! IF_NOTOK_RETURN(status=1)
  74. ! if ( station_data ) then
  75. ! call read_stationlist(status)
  76. ! IF_NOTOK_RETURN(status=1)
  77. ! call init_station_output(status)
  78. ! IF_NOTOK_RETURN(status=1)
  79. ! end if
  80. !
  81. ! call ReadRc( rcF, 'output.flight', flight_data, status )
  82. ! IF_NOTOK_RETURN(status=1)
  83. !
  84. ! call ReadRc( rcF, 'output.mix', mix_data, status )
  85. ! IF_NOTOK_RETURN(status=1)
  86. ! if ( mix_data ) then
  87. ! call ReadRc( rcF, 'output.mix.dhour', mix_data_dhour, status )
  88. ! write (gol,*) trim(mname)//'/mix_data_dhour:', mix_data_dhour; call goPr
  89. ! IF_NOTOK_RETURN(status=1)
  90. ! call output_mix_init(status)
  91. ! IF_NOTOK_RETURN(status=1)
  92. ! end if
  93. !
  94. ! ! initialise accumulation of the mean mixing ratio fields
  95. call ReadRc( rcF, 'output.mmix', mmix_data, status )
  96. IF_NOTOK_RETURN(status=1)
  97. if ( mmix_data ) then
  98. write (gol,'(a,": init mmix-output ...")') rname; call goPr
  99. call mmix_Init(status)
  100. IF_NOTOK_RETURN(status=1)
  101. ! require temperature then
  102. do n = 1, nregions
  103. call Set( temper_dat(n), status, used=.true. )
  104. end do
  105. end if
  106. !
  107. !#ifdef with_retro_output
  108. ! ! put out in retro format ?
  109. ! call ReadRc( rcF, 'output.retro', output_retro, status, default=.false. )
  110. ! IF_NOTOK_RETURN(status=1)
  111. ! ! init if necessary:
  112. ! if ( output_retro ) then
  113. ! ! init output; return ouptut time step
  114. ! call Output_RETRO_Init( rcF, output_retro_dhour, status )
  115. ! IF_NOTOK_RETURN(status=1)
  116. ! end if
  117. !#endif
  118. !
  119. ! ! close rcfile:
  120. call Done( rcF, status )
  121. IF_NOTOK_RETURN(status=1)
  122. !
  123. ! done
  124. !
  125. ! ok
  126. call goLabel(); status=0
  127. end subroutine User_output_Init
  128. !-------------------------------------------------------------
  129. ! user_output_done:
  130. ! Finalise user-specified model output for the region given
  131. !-------------------------------------------------------------
  132. subroutine User_output_Done( status )
  133. ! use dims, only : nregions
  134. use User_Output_Common , only : User_Output_Common_Done
  135. use user_output_mmix, only : write_mmix, mmix_Done
  136. ! use user_output_station, only : free_stationfields
  137. ! use user_output_mix , only : output_mix_close
  138. !#ifdef with_retro_output
  139. ! use user_output_retro , only : output_retro_done
  140. !#endif
  141. ! --- in/out -----------------------------
  142. integer, intent(out) :: status
  143. ! --- const ------------------------------
  144. character(len=*), parameter :: rname = mname//'/user_output_done'
  145. ! --- begin -----------------------------
  146. call goLabel( rname )
  147. ! ! write the mean mixing ratio fields to file
  148. if ( mmix_data ) then
  149. call write_mmix(status)
  150. IF_NOTOK_RETURN(status=1)
  151. call mmix_Done(status)
  152. IF_NOTOK_RETURN(status=1)
  153. end if
  154. !
  155. ! if ( station_data) then
  156. ! call free_stationfields(status)
  157. ! IF_NOTOK_RETURN(status=1)
  158. ! endif
  159. !
  160. ! if ( mix_data ) then
  161. ! call output_mix_close( status )
  162. ! IF_NOTOK_RETURN(status=1)
  163. ! endif
  164. !
  165. !#ifdef with_retro_output
  166. ! if ( output_retro ) then
  167. ! call Output_Retro_Done( status )
  168. ! IF_NOTOK_RETURN(status=1)
  169. ! end if
  170. !#endif
  171. ! done with common stuff:
  172. call User_Output_Common_Done( status )
  173. IF_NOTOK_RETURN(status=1)
  174. ! ok
  175. call goLabel(); status=0
  176. end subroutine User_output_Done
  177. !-------------------------------------------------------------
  178. ! user_output_step:
  179. ! Define user-specified model output for the region given
  180. ! Called every time step
  181. !-------------------------------------------------------------
  182. subroutine user_output_step( region, status )
  183. ! use dims, only : itaur, newsrun, itaui
  184. ! use datetime, only : tau2date
  185. ! use user_output_station, only : output_stationconc
  186. ! use user_output_flight, only : get_flightdata
  187. ! use user_output_mix, only : output_mix
  188. use user_output_mmix, only : accumulate_mmix
  189. !#ifdef with_retro_output
  190. ! use user_output_retro , only : Output_Retro_Step
  191. !#endif
  192. ! --- in/out ------------------------------
  193. integer, intent(in) :: region
  194. integer, intent(out) :: status
  195. ! --- const ------------------------------
  196. character(len=*), parameter :: rname = mname//'/user_output_step'
  197. ! --- local ------------------------------
  198. ! integer,dimension(6) :: idate_f
  199. ! --- begin ------------------------------
  200. call goLabel( rname )
  201. ! call tau2date(itaur(region),idate_f)
  202. !
  203. if ( mmix_data ) then
  204. call accumulate_mmix( region, status )
  205. IF_NOTOK_RETURN(status=1)
  206. endif
  207. !
  208. ! if ( station_data ) then
  209. ! call output_stationconc(region, status)
  210. ! IF_NOTOK_RETURN(status=1)
  211. ! endif
  212. !
  213. ! if ( flight_data ) call get_flightdata(region,idate_f)
  214. ! if ( mix_data ) then
  215. ! if ( modulo(itaur(region)-itaui,mix_data_dhour*3600) == 0 ) then
  216. ! call output_mix(region, status )
  217. ! IF_NOTOK_RETURN(status=1)
  218. ! endif
  219. ! !call output_mix(region)
  220. ! end if
  221. !
  222. !#ifdef with_retro_output
  223. ! if ( output_retro ) then
  224. ! if ( (modulo(idate_f(4),output_retro_dhour)==0) .and. all(idate_f(5:6)==0) ) then
  225. ! call Output_Retro_Step( region, idate_f, status )
  226. ! IF_NOTOK_RETURN(status=1)
  227. ! end if
  228. ! end if
  229. !#endif
  230. ! ok
  231. call goLabel(); status=0
  232. end subroutine user_output_step
  233. !
  234. ! dummy ...
  235. !
  236. subroutine user_output_mean(status)
  237. ! use dims, only : itau, ndyn_max
  238. ! use user_output_station, only : evaluate_stationconc, reset_stationconc_accumulator, write_stationconc
  239. !
  240. ! implicit none
  241. integer, intent(inout) :: status
  242. character(len=*), parameter :: rname = mname//'/user_output_mean'
  243. ! IF(station_data)THEN
  244. ! IF(mod(itau, ndyn_max) == 0) THEN
  245. ! CALL evaluate_stationconc(status)
  246. ! IF_NOTOK_RETURN(status=1)
  247. ! CALL write_stationconc(status)
  248. ! IF_NOTOK_RETURN(status=1)
  249. ! CALL reset_stationconc_accumulator
  250. ! ENDIF
  251. ! ENDIF
  252. ! ok
  253. call goLabel(); status=0
  254. end subroutine user_output_mean
  255. end module user_output