outpost.f 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310
  1. ! ==================================================================
  2. ! ------------------------------------------------------------------
  3. !
  4. subroutine outpost
  5. use lsgvar
  6. implicit none
  7. !
  8. ! ------------------------------------------------------------------
  9. !
  10. !**** *outpost*
  11. !
  12. ! by U. Mikolajewicz 12/87.
  13. !
  14. ! Purpose.
  15. ! --------
  16. ! *outpost writes output data on tapeunit *nopost*.
  17. ! This file is further processed in the postprocessor.
  18. ! The file is defined during the run.
  19. ! The time for the next output is read from file and the
  20. ! name of the next output file is generated.
  21. !
  22. ! Input.
  23. ! ------
  24. ! common blocks /lsgfie/ and /lsgsur/
  25. ! filpnew file for output to be written on.
  26. !
  27. ! Output.
  28. ! -------
  29. ! File with output data.
  30. ! filpnew new name for the next file with output data.
  31. ! ntnout number of time step to write next output file.
  32. !
  33. ! Interface.
  34. ! ----------
  35. ! *call* *outpost*
  36. !
  37. ! Calls subroutines *datfrnt*.
  38. ! ------------------------------------------------------------------
  39. !
  40. !
  41. ! Dimension of local variables.
  42. ! -----------------------------
  43. integer :: ji,jr,k,iyy,idd,jlev,jl,i,j
  44. real (kind=8) :: zero,zdum,zlen,zprel,zcode,zlev
  45. integer :: iddr(512)
  46. real (kind=8) :: zddr(512)
  47. !
  48. !* 1. Actualize *iddr*.
  49. ! -----------------
  50. zero=0.
  51. zdum=zero
  52. !
  53. ! *iddr* and *zddr* are header fields for output file.
  54. !
  55. do ji=1,512
  56. iddr(ji)=nddr(ji)
  57. zddr(ji)=oddr(ji)
  58. end do
  59. iddr(404)=0
  60. iddr(22)=6*ken+8
  61. iddr(16)=6*ken+8
  62. call datfrnt(nt,iddr(12),iddr(11))
  63. !
  64. ! Pot. temperature in Kelvin.
  65. !
  66. do jr=1,ken
  67. iddr(22+2*jr-1)=-2
  68. end do
  69. do jr=1,ken
  70. !
  71. ! Salinity.
  72. !
  73. iddr(22+2*ken+2*jr-1)=-5
  74. iddr(22+2*ken+2*jr)=nint(du(jr))
  75. !
  76. ! Velocities.
  77. !
  78. iddr(22+4*ken+2*jr-1)=-3
  79. iddr(22+4*ken+2*jr)=nint(du(jr))
  80. iddr(22+6*ken+2*jr-1)=-4
  81. iddr(22+6*ken+2*jr)=nint(du(jr))
  82. iddr(22+8*ken+2*jr-1)=-7
  83. iddr(22+8*ken+2*jr)=nint(dw(jr))
  84. end do
  85. !
  86. ! Barotropic velocities.
  87. !
  88. iddr(22+10*ken+1)=-37
  89. iddr(22+10*ken+2)=-100
  90. iddr(22+10*ken+3)=-38
  91. iddr(22+10*ken+4)=-100
  92. !
  93. ! Surface elevation.
  94. !
  95. iddr(22+10*ken+5)=-1
  96. iddr(22+10*ken+6)=-100
  97. !
  98. ! Ice thickness.
  99. !
  100. iddr(22+10*ken+7)=-13
  101. iddr(22+10*ken+8)=-100
  102. !
  103. ! Topography in vector-points.
  104. !
  105. iddr(22+10*ken+9)=-99
  106. iddr(22+10*ken+10)=-100
  107. !
  108. ! Topography in scalar-points.
  109. !
  110. iddr(22+10*ken+11)=-98
  111. iddr(22+10*ken+12)=-100
  112. !
  113. ! Fresh water fluxes due to Newtonian coupling.
  114. !
  115. iddr(22+10*ken+13)=-67
  116. iddr(22+10*ken+14)=-100
  117. !
  118. ! Heat fluxes due to Newtonian coupling.
  119. !
  120. iddr(22+10*ken+15)=-68
  121. iddr(22+10*ken+16)=-100
  122. !
  123. ! Convective adjustment.
  124. !
  125. iddr(22+10*ken+17)=-69
  126. iddr(22+10*ken+18)=-100
  127. !
  128. ! Horizontal stream function
  129. !
  130. iddr(22+10*ken+19)=-27
  131. iddr(22+10*ken+20)=-100
  132. !
  133. ! Freshwater flux
  134. !
  135. iddr(22+10*ken+21)=-65
  136. iddr(22+10*ken+22)=-100
  137. !
  138. do k=2,ken
  139. if (iddr(22+10*ken+22+(k-1)*2)>=300) cycle
  140. iddr(22+10*ken+21+(k-1)*2)=-69
  141. iddr(22+10*ken+22+(k-1)*2)=nint(dw(k-1))
  142. end do
  143. !
  144. !
  145. !* 2. Write output on file *filpnew*.
  146. ! -------------------------------
  147. !
  148. ! Write *iddr* and *zddr* on file.
  149. !
  150. iyy=iddr(12)
  151. idd=iddr(11)
  152. !
  153. ! Coupled with PlaSim: name without year to be edited by coupled script
  154. write (filpnew,'(a)') 'LSG_outpost'
  155. 9885 format (' OUTPOST: standard output ',a,' on file ',a, &
  156. & ' YYYYY -MMDD :',i5.2,i6.4,' +')
  157. !#ifdef 1
  158. ! write (no6,9885) '(real*4)',filpnew,iyy,idd,ksum
  159. !#else
  160. write (no6,9885) ' ',filpnew,iyy,idd
  161. !#endif
  162. open (nopost,file=filpnew,form="unformatted",position="append")
  163. write (nopost) iddr
  164. write (nopost) zddr
  165. zlen=ien*jen
  166. zprel=6.
  167. !
  168. ! Write temperature.
  169. !
  170. zcode=-2
  171. do jlev=1,ken
  172. write (nopost) zprel,zlen,zcode,zddr(10+jlev-1),zdum,zdum
  173. write (nopost) (((t(jl,jr,jlev)+tkelvin),jl=1,ien),jr=1,jen)
  174. end do
  175. !
  176. ! Salinity.
  177. !
  178. zcode=-5
  179. do jlev=1,ken
  180. write (nopost) zprel,zlen,zcode,zddr(10+jlev-1),zdum,zdum
  181. write (nopost) ((s(jl,jr,jlev),jl=1,ien),jr=1,jen)
  182. end do
  183. !
  184. ! Velocities.
  185. !
  186. zcode=-3
  187. do jlev=1,ken
  188. write (nopost) zprel,zlen,zcode,zddr(10+jlev-1),zdum,zdum
  189. write (nopost) ((utot(jl,jr,jlev),jl=1,ien),jr=1,jen)
  190. end do
  191. !
  192. zcode=-4
  193. do jlev=1,ken
  194. write (nopost) zprel,zlen,zcode,zddr(10+jlev-1),zdum,zdum
  195. write (nopost) ((vtot(jl,jr,jlev),jl=1,ien),jr=1,jen)
  196. end do
  197. !
  198. zcode=-7
  199. do jlev=1,ken
  200. write (nopost) zprel,zlen,zcode,dw(jlev),zdum,zdum
  201. write (nopost) ((w(jl,jr,jlev),jl=1,ien),jr=1,jen)
  202. end do
  203. !
  204. ! Barotropic velocities.
  205. !
  206. zlev=-100.
  207. zcode=-37.
  208. write (nopost) zprel,zlen,zcode,zlev,zdum,zdum
  209. write (nopost) ((ub(jl,jr),jl=1,ien),jr=1,jen)
  210. !
  211. zcode=-38.
  212. write (nopost) zprel,zlen,zcode,zlev,zdum,zdum
  213. write (nopost) ((vb(jl,jr),jl=1,ien),jr=1,jen)
  214. !
  215. ! Surface elevation and ice thickness.
  216. !
  217. zcode=-1.
  218. write (nopost) zprel,zlen,zcode,zlev,zdum,zdum
  219. write (nopost) ((zeta(jl,jr),jl=1,ien),jr=1,jen)
  220. !
  221. zcode=-13.
  222. write (nopost) zprel,zlen,zcode,zlev,zdum,zdum
  223. write (nopost) ((sice(jl,jr),jl=1,ien),jr=1,jen)
  224. !
  225. ! Horizontal barotropic stream function
  226. zcode=-27.
  227. write (nopost) zprel,zlen,zcode,zlev,zdum,zdum
  228. write (nopost) ((psi(jl,jr),jl=1,ien),jr=1,jen)
  229. !
  230. ! Store topography in vector-points.
  231. !
  232. zcode=-99.
  233. write (nopost) zprel,zlen,zcode,zlev,zdum,zdum
  234. write (nopost) ((depth(jl,jr),jl=1,ien),jr=1,jen)
  235. !
  236. ! Store topography in scalar-points.
  237. !
  238. zcode=-98.
  239. write (nopost) zprel,zlen,zcode,zlev,zdum,zdum
  240. write (nopost) ((depp(jl,jr),jl=1,ien),jr=1,jen)
  241. !
  242. ! Store *fluwat*
  243. !
  244. zcode=-65.
  245. write (nopost) zprel,zlen,zcode,zlev,zdum,zdum
  246. write (nopost) fluwat
  247. !
  248. ! Store *flukwat*.
  249. !
  250. zcode=-67.
  251. write (nopost) zprel,zlen,zcode,zlev,zdum,zdum
  252. write (nopost) flukwat
  253. !
  254. ! Store *flukhea*.
  255. !
  256. zcode=-68.
  257. write (nopost) zprel,zlen,zcode,zlev,zdum,zdum
  258. write (nopost) flukhea
  259. !
  260. ! Store convect ice adjustments.
  261. !
  262. zcode=-66.
  263. zlev=-100.
  264. write (nopost) zprel,zlen,zcode,zlev,zdum,zdum
  265. write (nopost) ((convad(jl,jr,1),jl=1,ien),jr=1,jen)
  266. zcode=-69.
  267. do k=2,ken
  268. zlev=dw(k-1)
  269. write (nopost) zprel,zlen,zcode,zlev,zdum,zdum
  270. write (nopost) ((convad(jl,jr,k),jl=1,ien),jr=1,jen)
  271. end do
  272. !
  273. ! Store *taux*.
  274. !
  275. zcode=52.
  276. zlev=-100.
  277. write (nopost) zprel,zlen,zcode,zlev,zdum,zdum
  278. write (nopost) ((taux(i,j)*rhonul,i=1,ien),j=1,jen)
  279. !
  280. ! Store *tauy*.
  281. !
  282. zcode=53.
  283. zlev=-100.
  284. write (nopost) zprel,zlen,zcode,zlev,zdum,zdum
  285. write (nopost) ((tauy(i,j)*rhonul,i=1,ien),j=1,jen)
  286. !
  287. ! Store *tbound*.
  288. !
  289. zcode=-92.
  290. zlev=-100.
  291. write (nopost) zprel,zlen,zcode,zlev,zdum,zdum
  292. write (nopost) ((tbound(i,j)+tkelvin,i=1,ien),j=1,jen)
  293. !
  294. ! Store *fluhea*.
  295. !
  296. zcode=-18.
  297. write (nopost) zprel,zlen,zcode,zlev,zdum,zdum
  298. write (nopost) fluhea
  299. !
  300. !* 3. Store output on file *filpnew*.
  301. ! -------------------------------
  302. close (nopost)
  303. return
  304. end subroutine outpost