trdvor.F90 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590
  1. MODULE trdvor
  2. !!======================================================================
  3. !! *** MODULE trdvor ***
  4. !! Ocean diagnostics: momentum trends
  5. !!=====================================================================
  6. !! History : 1.0 ! 2006-01 (L. Brunier, A-M. Treguier) Original code
  7. !! 2.0 ! 2008-04 (C. Talandier) New trends organization
  8. !! 3.5 ! 2012-02 (G. Madec) regroup beta.V computation with pvo trend
  9. !!----------------------------------------------------------------------
  10. !!----------------------------------------------------------------------
  11. !! trd_vor : momentum trends averaged over the depth
  12. !! trd_vor_zint : vorticity vertical integration
  13. !! trd_vor_init : initialization step
  14. !!----------------------------------------------------------------------
  15. USE oce ! ocean dynamics and tracers variables
  16. USE dom_oce ! ocean space and time domain variables
  17. USE trd_oce ! trends: ocean variables
  18. USE zdf_oce ! ocean vertical physics
  19. USE sbc_oce ! surface boundary condition: ocean
  20. USE phycst ! Define parameters for the routines
  21. USE ldfdyn_oce ! ocean active tracers: lateral physics
  22. USE dianam ! build the name of file (routine)
  23. USE zdfmxl ! mixed layer depth
  24. USE lbclnk ! ocean lateral boundary conditions (or mpp link)
  25. USE in_out_manager ! I/O manager
  26. USE ioipsl ! NetCDF library
  27. USE lib_mpp ! MPP library
  28. USE wrk_nemo ! Memory allocation
  29. IMPLICIT NONE
  30. PRIVATE
  31. INTERFACE trd_vor_zint
  32. MODULE PROCEDURE trd_vor_zint_2d, trd_vor_zint_3d
  33. END INTERFACE
  34. PUBLIC trd_vor ! routine called by trddyn.F90
  35. PUBLIC trd_vor_init ! routine called by opa.F90
  36. PUBLIC trd_vor_alloc ! routine called by nemogcm.F90
  37. INTEGER :: nh_t, nmoydpvor, nidvor, nhoridvor, ndimvor1, icount ! needs for IOIPSL output
  38. INTEGER, SAVE, ALLOCATABLE, DIMENSION(:) :: ndexvor1 ! needed for IOIPSL output
  39. INTEGER :: ndebug ! (0/1) set it to 1 in case of problem to have more print
  40. REAL(wp), SAVE, ALLOCATABLE, DIMENSION(:,:) :: vor_avr ! average
  41. REAL(wp), SAVE, ALLOCATABLE, DIMENSION(:,:) :: vor_avrb ! before vorticity (kt-1)
  42. REAL(wp), SAVE, ALLOCATABLE, DIMENSION(:,:) :: vor_avrbb ! vorticity at begining of the nwrite-1 timestep averaging period
  43. REAL(wp), SAVE, ALLOCATABLE, DIMENSION(:,:) :: vor_avrbn ! after vorticity at time step after the
  44. REAL(wp), SAVE, ALLOCATABLE, DIMENSION(:,:) :: rotot ! begining of the NWRITE-1 timesteps
  45. REAL(wp), SAVE, ALLOCATABLE, DIMENSION(:,:) :: vor_avrtot !
  46. REAL(wp), SAVE, ALLOCATABLE, DIMENSION(:,:) :: vor_avrres !
  47. REAL(wp), SAVE, ALLOCATABLE, DIMENSION(:,:,:) :: vortrd ! curl of trends
  48. CHARACTER(len=12) :: cvort
  49. !! * Substitutions
  50. # include "domzgr_substitute.h90"
  51. # include "ldfdyn_substitute.h90"
  52. # include "vectopt_loop_substitute.h90"
  53. !!----------------------------------------------------------------------
  54. !! NEMO/OPA 3.3 , NEMO Consortium (2010)
  55. !! $Id: trdvor.F90 4990 2014-12-15 16:42:49Z timgraham $
  56. !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
  57. !!----------------------------------------------------------------------
  58. CONTAINS
  59. INTEGER FUNCTION trd_vor_alloc()
  60. !!----------------------------------------------------------------------------
  61. !! *** ROUTINE trd_vor_alloc ***
  62. !!----------------------------------------------------------------------------
  63. ALLOCATE( vor_avr (jpi,jpj) , vor_avrb(jpi,jpj) , vor_avrbb (jpi,jpj) , &
  64. & vor_avrbn (jpi,jpj) , rotot (jpi,jpj) , vor_avrtot(jpi,jpj) , &
  65. & vor_avrres(jpi,jpj) , vortrd (jpi,jpj,jpltot_vor) , &
  66. & ndexvor1 (jpi*jpj) , STAT= trd_vor_alloc )
  67. !
  68. IF( lk_mpp ) CALL mpp_sum ( trd_vor_alloc )
  69. IF( trd_vor_alloc /= 0 ) CALL ctl_warn('trd_vor_alloc: failed to allocate arrays')
  70. END FUNCTION trd_vor_alloc
  71. SUBROUTINE trd_vor( putrd, pvtrd, ktrd, kt )
  72. !!----------------------------------------------------------------------
  73. !! *** ROUTINE trd_vor ***
  74. !!
  75. !! ** Purpose : computation of cumulated trends over analysis period
  76. !! and make outputs (NetCDF or DIMG format)
  77. !!----------------------------------------------------------------------
  78. REAL(wp), DIMENSION(:,:,:), INTENT(inout) :: putrd, pvtrd ! U and V trends
  79. INTEGER , INTENT(in ) :: ktrd ! trend index
  80. INTEGER , INTENT(in ) :: kt ! time step
  81. !
  82. INTEGER :: ji, jj ! dummy loop indices
  83. REAL(wp), POINTER, DIMENSION(:,:) :: ztswu, ztswv ! 2D workspace
  84. !!----------------------------------------------------------------------
  85. CALL wrk_alloc( jpi, jpj, ztswu, ztswv )
  86. SELECT CASE( ktrd )
  87. CASE( jpdyn_hpg ) ; CALL trd_vor_zint( putrd, pvtrd, jpvor_prg ) ! Hydrostatique Pressure Gradient
  88. CASE( jpdyn_keg ) ; CALL trd_vor_zint( putrd, pvtrd, jpvor_keg ) ! KE Gradient
  89. CASE( jpdyn_rvo ) ; CALL trd_vor_zint( putrd, pvtrd, jpvor_rvo ) ! Relative Vorticity
  90. CASE( jpdyn_pvo ) ; CALL trd_vor_zint( putrd, pvtrd, jpvor_pvo ) ! Planetary Vorticity Term
  91. CASE( jpdyn_ldf ) ; CALL trd_vor_zint( putrd, pvtrd, jpvor_ldf ) ! Horizontal Diffusion
  92. CASE( jpdyn_zad ) ; CALL trd_vor_zint( putrd, pvtrd, jpvor_zad ) ! Vertical Advection
  93. CASE( jpdyn_spg ) ; CALL trd_vor_zint( putrd, pvtrd, jpvor_spg ) ! Surface Pressure Grad.
  94. CASE( jpdyn_zdf ) ! Vertical Diffusion
  95. ztswu(:,:) = 0.e0 ; ztswv(:,:) = 0.e0
  96. DO jj = 2, jpjm1 ! wind stress trends
  97. DO ji = fs_2, fs_jpim1 ! vector opt.
  98. ztswu(ji,jj) = 0.5 * ( utau_b(ji,jj) + utau(ji,jj) ) / ( fse3u(ji,jj,1) * rau0 )
  99. ztswv(ji,jj) = 0.5 * ( vtau_b(ji,jj) + vtau(ji,jj) ) / ( fse3v(ji,jj,1) * rau0 )
  100. END DO
  101. END DO
  102. !
  103. CALL trd_vor_zint( putrd, pvtrd, jpvor_zdf ) ! zdf trend including surf./bot. stresses
  104. CALL trd_vor_zint( ztswu, ztswv, jpvor_swf ) ! surface wind stress
  105. CASE( jpdyn_bfr )
  106. CALL trd_vor_zint( putrd, pvtrd, jpvor_bfr ) ! Bottom stress
  107. !
  108. CASE( jpdyn_atf ) ! last trends: perform the output of 2D vorticity trends
  109. CALL trd_vor_iom( kt )
  110. END SELECT
  111. !
  112. CALL wrk_dealloc( jpi, jpj, ztswu, ztswv )
  113. !
  114. END SUBROUTINE trd_vor
  115. SUBROUTINE trd_vor_zint_2d( putrdvor, pvtrdvor, ktrd )
  116. !!----------------------------------------------------------------------------
  117. !! *** ROUTINE trd_vor_zint ***
  118. !!
  119. !! ** Purpose : computation of vertically integrated vorticity budgets
  120. !! from ocean surface down to control surface (NetCDF output)
  121. !!
  122. !! ** Method/usage : integration done over nwrite-1 time steps
  123. !!
  124. !! ** Action : trends :
  125. !! vortrd (,, 1) = Pressure Gradient Trend
  126. !! vortrd (,, 2) = KE Gradient Trend
  127. !! vortrd (,, 3) = Relative Vorticity Trend
  128. !! vortrd (,, 4) = Coriolis Term Trend
  129. !! vortrd (,, 5) = Horizontal Diffusion Trend
  130. !! vortrd (,, 6) = Vertical Advection Trend
  131. !! vortrd (,, 7) = Vertical Diffusion Trend
  132. !! vortrd (,, 8) = Surface Pressure Grad. Trend
  133. !! vortrd (,, 9) = Beta V
  134. !! vortrd (,,10) = forcing term
  135. !! vortrd (,,11) = bottom friction term
  136. !! rotot(,) : total cumulative trends over nwrite-1 time steps
  137. !! vor_avrtot(,) : first membre of vrticity equation
  138. !! vor_avrres(,) : residual = dh/dt entrainment
  139. !!
  140. !! trends output in netCDF format using ioipsl
  141. !!----------------------------------------------------------------------
  142. INTEGER , INTENT(in ) :: ktrd ! ocean trend index
  143. REAL(wp), DIMENSION(jpi,jpj), INTENT(inout) :: putrdvor ! u vorticity trend
  144. REAL(wp), DIMENSION(jpi,jpj), INTENT(inout) :: pvtrdvor ! v vorticity trend
  145. !
  146. INTEGER :: ji, jj ! dummy loop indices
  147. INTEGER :: ikbu, ikbv ! local integers
  148. REAL(wp), POINTER, DIMENSION(:,:) :: zudpvor, zvdpvor ! total cmulative trends
  149. !!----------------------------------------------------------------------
  150. !
  151. CALL wrk_alloc( jpi, jpj, zudpvor, zvdpvor ) ! Memory allocation
  152. !
  153. zudpvor(:,:) = 0._wp ; zvdpvor(:,:) = 0._wp ! Initialisation
  154. CALL lbc_lnk( putrdvor, 'U', -1. ) ; CALL lbc_lnk( pvtrdvor, 'V', -1. ) ! lateral boundary condition
  155. ! =====================================
  156. ! I vertical integration of 2D trends
  157. ! =====================================
  158. SELECT CASE( ktrd )
  159. !
  160. CASE( jpvor_bfr ) ! bottom friction
  161. DO jj = 2, jpjm1
  162. DO ji = fs_2, fs_jpim1
  163. ikbu = mbkv(ji,jj)
  164. ikbv = mbkv(ji,jj)
  165. zudpvor(ji,jj) = putrdvor(ji,jj) * fse3u(ji,jj,ikbu) * e1u(ji,jj) * umask(ji,jj,ikbu)
  166. zvdpvor(ji,jj) = pvtrdvor(ji,jj) * fse3v(ji,jj,ikbv) * e2v(ji,jj) * vmask(ji,jj,ikbv)
  167. END DO
  168. END DO
  169. !
  170. CASE( jpvor_swf ) ! wind stress
  171. zudpvor(:,:) = putrdvor(:,:) * fse3u(:,:,1) * e1u(:,:) * umask(:,:,1)
  172. zvdpvor(:,:) = pvtrdvor(:,:) * fse3v(:,:,1) * e2v(:,:) * vmask(:,:,1)
  173. !
  174. END SELECT
  175. ! Average except for Beta.V
  176. zudpvor(:,:) = zudpvor(:,:) * hur(:,:)
  177. zvdpvor(:,:) = zvdpvor(:,:) * hvr(:,:)
  178. ! Curl
  179. DO ji = 1, jpim1
  180. DO jj = 1, jpjm1
  181. vortrd(ji,jj,ktrd) = ( zvdpvor(ji+1,jj) - zvdpvor(ji,jj) &
  182. & - ( zudpvor(ji,jj+1) - zudpvor(ji,jj) ) ) / ( e1f(ji,jj) * e2f(ji,jj) )
  183. END DO
  184. END DO
  185. vortrd(:,:,ktrd) = vortrd(:,:,ktrd) * fmask(:,:,1) ! Surface mask
  186. IF( ndebug /= 0 ) THEN
  187. IF(lwp) WRITE(numout,*) ' debuging trd_vor_zint: I done'
  188. CALL FLUSH(numout)
  189. ENDIF
  190. !
  191. CALL wrk_dealloc( jpi, jpj, zudpvor, zvdpvor )
  192. !
  193. END SUBROUTINE trd_vor_zint_2d
  194. SUBROUTINE trd_vor_zint_3d( putrdvor, pvtrdvor, ktrd )
  195. !!----------------------------------------------------------------------------
  196. !! *** ROUTINE trd_vor_zint ***
  197. !!
  198. !! ** Purpose : computation of vertically integrated vorticity budgets
  199. !! from ocean surface down to control surface (NetCDF output)
  200. !!
  201. !! ** Method/usage : integration done over nwrite-1 time steps
  202. !!
  203. !! ** Action : trends :
  204. !! vortrd (,,1) = Pressure Gradient Trend
  205. !! vortrd (,,2) = KE Gradient Trend
  206. !! vortrd (,,3) = Relative Vorticity Trend
  207. !! vortrd (,,4) = Coriolis Term Trend
  208. !! vortrd (,,5) = Horizontal Diffusion Trend
  209. !! vortrd (,,6) = Vertical Advection Trend
  210. !! vortrd (,,7) = Vertical Diffusion Trend
  211. !! vortrd (,,8) = Surface Pressure Grad. Trend
  212. !! vortrd (,,9) = Beta V
  213. !! vortrd (,,10) = forcing term
  214. !! vortrd (,,11) = bottom friction term
  215. !! rotot(,) : total cumulative trends over nwrite-1 time steps
  216. !! vor_avrtot(,) : first membre of vrticity equation
  217. !! vor_avrres(,) : residual = dh/dt entrainment
  218. !!
  219. !! trends output in netCDF format using ioipsl
  220. !!----------------------------------------------------------------------
  221. !
  222. INTEGER , INTENT(in ) :: ktrd ! ocean trend index
  223. REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(inout) :: putrdvor ! u vorticity trend
  224. REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(inout) :: pvtrdvor ! v vorticity trend
  225. !
  226. INTEGER :: ji, jj, jk ! dummy loop indices
  227. REAL(wp), POINTER, DIMENSION(:,:) :: zubet , zvbet ! Beta.V
  228. REAL(wp), POINTER, DIMENSION(:,:) :: zudpvor, zvdpvor ! total cmulative trends
  229. !!----------------------------------------------------------------------
  230. CALL wrk_alloc( jpi,jpj, zubet, zvbet, zudpvor, zvdpvor )
  231. ! Initialization
  232. zubet (:,:) = 0._wp
  233. zvbet (:,:) = 0._wp
  234. zudpvor(:,:) = 0._wp
  235. zvdpvor(:,:) = 0._wp
  236. !
  237. CALL lbc_lnk( putrdvor, 'U', -1. ) ! lateral boundary condition on input momentum trends
  238. CALL lbc_lnk( pvtrdvor, 'V', -1. )
  239. ! =====================================
  240. ! I vertical integration of 3D trends
  241. ! =====================================
  242. ! putrdvor and pvtrdvor terms
  243. DO jk = 1,jpk
  244. zudpvor(:,:) = zudpvor(:,:) + putrdvor(:,:,jk) * fse3u(:,:,jk) * e1u(:,:) * umask(:,:,jk)
  245. zvdpvor(:,:) = zvdpvor(:,:) + pvtrdvor(:,:,jk) * fse3v(:,:,jk) * e2v(:,:) * vmask(:,:,jk)
  246. END DO
  247. ! Planetary vorticity: 2nd computation (Beta.V term) store the vertical sum
  248. ! as Beta.V term need intergration, not average
  249. IF( ktrd == jpvor_pvo ) THEN
  250. zubet(:,:) = zudpvor(:,:)
  251. zvbet(:,:) = zvdpvor(:,:)
  252. DO ji = 1, jpim1
  253. DO jj = 1, jpjm1
  254. vortrd(ji,jj,jpvor_bev) = ( zvbet(ji+1,jj) - zvbet(ji,jj) &
  255. & - ( zubet(ji,jj+1) - zubet(ji,jj) ) ) / ( e1f(ji,jj) * e2f(ji,jj) )
  256. END DO
  257. END DO
  258. ! Average of the Curl and Surface mask
  259. vortrd(:,:,jpvor_bev) = vortrd(:,:,jpvor_bev) * hur(:,:) * fmask(:,:,1)
  260. ENDIF
  261. !
  262. ! Average
  263. zudpvor(:,:) = zudpvor(:,:) * hur(:,:)
  264. zvdpvor(:,:) = zvdpvor(:,:) * hvr(:,:)
  265. !
  266. ! Curl
  267. DO ji=1,jpim1
  268. DO jj=1,jpjm1
  269. vortrd(ji,jj,ktrd) = ( zvdpvor(ji+1,jj) - zvdpvor(ji,jj) &
  270. & - ( zudpvor(ji,jj+1) - zudpvor(ji,jj) ) ) / ( e1f(ji,jj) * e2f(ji,jj) )
  271. END DO
  272. END DO
  273. ! Surface mask
  274. vortrd(:,:,ktrd) = vortrd(:,:,ktrd) * fmask(:,:,1)
  275. IF( ndebug /= 0 ) THEN
  276. IF(lwp) WRITE(numout,*) ' debuging trd_vor_zint: I done'
  277. CALL FLUSH(numout)
  278. ENDIF
  279. !
  280. CALL wrk_dealloc( jpi,jpj, zubet, zvbet, zudpvor, zvdpvor )
  281. !
  282. END SUBROUTINE trd_vor_zint_3d
  283. SUBROUTINE trd_vor_iom( kt )
  284. !!----------------------------------------------------------------------
  285. !! *** ROUTINE trd_vor ***
  286. !!
  287. !! ** Purpose : computation of cumulated trends over analysis period
  288. !! and make outputs (NetCDF or DIMG format)
  289. !!----------------------------------------------------------------------
  290. INTEGER , INTENT(in ) :: kt ! time step
  291. !
  292. INTEGER :: ji, jj, jk, jl ! dummy loop indices
  293. INTEGER :: it, itmod ! local integers
  294. REAL(wp) :: zmean ! local scalars
  295. REAL(wp), POINTER, DIMENSION(:,:) :: zun, zvn
  296. !!----------------------------------------------------------------------
  297. CALL wrk_alloc( jpi, jpj, zun, zvn )
  298. ! =================
  299. ! I. Initialization
  300. ! =================
  301. ! I.1 set before values of vertically average u and v
  302. ! ---------------------------------------------------
  303. IF( kt > nit000 ) vor_avrb(:,:) = vor_avr(:,:)
  304. ! I.2 vertically integrated vorticity
  305. ! ----------------------------------
  306. vor_avr (:,:) = 0._wp
  307. zun (:,:) = 0._wp
  308. zvn (:,:) = 0._wp
  309. vor_avrtot(:,:) = 0._wp
  310. vor_avrres(:,:) = 0._wp
  311. ! Vertically averaged velocity
  312. DO jk = 1, jpk - 1
  313. zun(:,:) = zun(:,:) + e1u(:,:) * un(:,:,jk) * fse3u(:,:,jk)
  314. zvn(:,:) = zvn(:,:) + e2v(:,:) * vn(:,:,jk) * fse3v(:,:,jk)
  315. END DO
  316. zun(:,:) = zun(:,:) * hur(:,:)
  317. zvn(:,:) = zvn(:,:) * hvr(:,:)
  318. ! Curl
  319. DO ji = 1, jpim1
  320. DO jj = 1, jpjm1
  321. vor_avr(ji,jj) = ( ( zvn(ji+1,jj) - zvn(ji,jj) ) &
  322. & - ( zun(ji,jj+1) - zun(ji,jj) ) ) / ( e1f(ji,jj) * e2f(ji,jj) ) * fmask(ji,jj,1)
  323. END DO
  324. END DO
  325. ! =================================
  326. ! II. Cumulated trends
  327. ! =================================
  328. ! II.1 set `before' mixed layer values for kt = nit000+1
  329. ! ------------------------------------------------------
  330. IF( kt == nit000+1 ) THEN
  331. vor_avrbb(:,:) = vor_avrb(:,:)
  332. vor_avrbn(:,:) = vor_avr (:,:)
  333. ENDIF
  334. ! II.2 cumulated trends over analysis period (kt=2 to nwrite)
  335. ! ----------------------
  336. ! trends cumulated over nwrite-2 time steps
  337. IF( kt >= nit000+2 ) THEN
  338. nmoydpvor = nmoydpvor + 1
  339. DO jl = 1, jpltot_vor
  340. IF( jl /= 9 ) THEN
  341. rotot(:,:) = rotot(:,:) + vortrd(:,:,jl)
  342. ENDIF
  343. END DO
  344. ENDIF
  345. ! =============================================
  346. ! III. Output in netCDF + residual computation
  347. ! =============================================
  348. ! define time axis
  349. it = kt
  350. itmod = kt - nit000 + 1
  351. IF( MOD( it, nn_trd ) == 0 ) THEN
  352. ! III.1 compute total trend
  353. ! ------------------------
  354. zmean = 1._wp / ( REAL( nmoydpvor, wp ) * 2._wp * rdt )
  355. vor_avrtot(:,:) = ( vor_avr(:,:) - vor_avrbn(:,:) + vor_avrb(:,:) - vor_avrbb(:,:) ) * zmean
  356. ! III.2 compute residual
  357. ! ---------------------
  358. zmean = 1._wp / REAL( nmoydpvor, wp )
  359. vor_avrres(:,:) = vor_avrtot(:,:) - rotot(:,:) / zmean
  360. ! Boundary conditions
  361. CALL lbc_lnk( vor_avrtot, 'F', 1. )
  362. CALL lbc_lnk( vor_avrres, 'F', 1. )
  363. ! III.3 time evolution array swap
  364. ! ------------------------------
  365. vor_avrbb(:,:) = vor_avrb(:,:)
  366. vor_avrbn(:,:) = vor_avr (:,:)
  367. !
  368. nmoydpvor = 0
  369. !
  370. ENDIF
  371. ! III.4 write trends to output
  372. ! ---------------------------
  373. IF( kt >= nit000+1 ) THEN
  374. IF( lwp .AND. MOD( itmod, nn_trd ) == 0 ) THEN
  375. WRITE(numout,*) ''
  376. WRITE(numout,*) 'trd_vor : write trends in the NetCDF file at kt = ', kt
  377. WRITE(numout,*) '~~~~~~~ '
  378. ENDIF
  379. CALL histwrite( nidvor,"sovortPh",it,vortrd(:,:,jpvor_prg),ndimvor1,ndexvor1) ! grad Ph
  380. CALL histwrite( nidvor,"sovortEk",it,vortrd(:,:,jpvor_keg),ndimvor1,ndexvor1) ! Energy
  381. CALL histwrite( nidvor,"sovozeta",it,vortrd(:,:,jpvor_rvo),ndimvor1,ndexvor1) ! rel vorticity
  382. CALL histwrite( nidvor,"sovortif",it,vortrd(:,:,jpvor_pvo),ndimvor1,ndexvor1) ! coriolis
  383. CALL histwrite( nidvor,"sovodifl",it,vortrd(:,:,jpvor_ldf),ndimvor1,ndexvor1) ! lat diff
  384. CALL histwrite( nidvor,"sovoadvv",it,vortrd(:,:,jpvor_zad),ndimvor1,ndexvor1) ! vert adv
  385. CALL histwrite( nidvor,"sovodifv",it,vortrd(:,:,jpvor_zdf),ndimvor1,ndexvor1) ! vert diff
  386. CALL histwrite( nidvor,"sovortPs",it,vortrd(:,:,jpvor_spg),ndimvor1,ndexvor1) ! grad Ps
  387. CALL histwrite( nidvor,"sovortbv",it,vortrd(:,:,jpvor_bev),ndimvor1,ndexvor1) ! beta.V
  388. CALL histwrite( nidvor,"sovowind",it,vortrd(:,:,jpvor_swf),ndimvor1,ndexvor1) ! wind stress
  389. CALL histwrite( nidvor,"sovobfri",it,vortrd(:,:,jpvor_bfr),ndimvor1,ndexvor1) ! bottom friction
  390. CALL histwrite( nidvor,"1st_mbre",it,vor_avrtot ,ndimvor1,ndexvor1) ! First membre
  391. CALL histwrite( nidvor,"sovorgap",it,vor_avrres ,ndimvor1,ndexvor1) ! gap between 1st and 2 nd mbre
  392. !
  393. IF( ndebug /= 0 ) THEN
  394. WRITE(numout,*) ' debuging trd_vor: III.4 done'
  395. CALL FLUSH(numout)
  396. ENDIF
  397. !
  398. ENDIF
  399. !
  400. IF( MOD( it, nn_trd ) == 0 ) rotot(:,:)=0
  401. !
  402. IF( kt == nitend ) CALL histclo( nidvor )
  403. !
  404. CALL wrk_dealloc( jpi, jpj, zun, zvn )
  405. !
  406. END SUBROUTINE trd_vor_iom
  407. SUBROUTINE trd_vor_init
  408. !!----------------------------------------------------------------------
  409. !! *** ROUTINE trd_vor_init ***
  410. !!
  411. !! ** Purpose : computation of vertically integrated T and S budgets
  412. !! from ocean surface down to control surface (NetCDF output)
  413. !!----------------------------------------------------------------------
  414. REAL(wp) :: zjulian, zsto, zout
  415. CHARACTER (len=40) :: clhstnam
  416. CHARACTER (len=40) :: clop
  417. !!----------------------------------------------------------------------
  418. ! ===================
  419. ! I. initialization
  420. ! ===================
  421. cvort='averaged-vor'
  422. ! Open specifier
  423. ndebug = 0 ! set it to 1 in case of problem to have more Print
  424. IF(lwp) THEN
  425. WRITE(numout,*) ' '
  426. WRITE(numout,*) ' trd_vor_init: vorticity trends'
  427. WRITE(numout,*) ' ~~~~~~~~~~~~'
  428. WRITE(numout,*) ' '
  429. WRITE(numout,*) ' ##########################################################################'
  430. WRITE(numout,*) ' CAUTION: The interpretation of the vorticity trends is'
  431. WRITE(numout,*) ' not obvious, please contact Anne-Marie TREGUIER at: treguier@ifremer.fr '
  432. WRITE(numout,*) ' ##########################################################################'
  433. WRITE(numout,*) ' '
  434. ENDIF
  435. IF( trd_vor_alloc() /= 0 ) CALL ctl_stop( 'STOP', 'trd_vor_init : unable to allocate trdvor arrays' )
  436. ! cumulated trends array init
  437. nmoydpvor = 0
  438. rotot(:,:)=0
  439. vor_avrtot(:,:)=0
  440. vor_avrres(:,:)=0
  441. IF( ndebug /= 0 ) THEN
  442. WRITE(numout,*) ' debuging trd_vor_init: I. done'
  443. CALL FLUSH(numout)
  444. ENDIF
  445. ! =================================
  446. ! II. netCDF output initialization
  447. ! =================================
  448. !-----------------------------------------
  449. ! II.1 Define frequency of output and means
  450. ! -----------------------------------------
  451. IF( ln_mskland ) THEN ; clop = "only(x)" ! put 1.e+20 on land (very expensive!!)
  452. ELSE ; clop = "x" ! no use of the mask value (require less cpu time)
  453. ENDIF
  454. #if defined key_diainstant
  455. zsto = nwrite*rdt
  456. clop = "inst("//TRIM(clop)//")"
  457. #else
  458. zsto = rdt
  459. clop = "ave("//TRIM(clop)//")"
  460. #endif
  461. zout = nn_trd*rdt
  462. IF(lwp) WRITE(numout,*) ' netCDF initialization'
  463. ! II.2 Compute julian date from starting date of the run
  464. ! ------------------------
  465. CALL ymds2ju( nyear, nmonth, nday, rdt, zjulian )
  466. zjulian = zjulian - adatrj ! set calendar origin to the beginning of the experiment
  467. IF(lwp) WRITE(numout,*)' '
  468. IF(lwp) WRITE(numout,*)' Date 0 used :',nit000, &
  469. & ' YEAR ', nyear,' MONTH ' , nmonth, &
  470. & ' DAY ' , nday, 'Julian day : ', zjulian
  471. ! II.3 Define the T grid trend file (nidvor)
  472. ! ---------------------------------
  473. CALL dia_nam( clhstnam, nn_trd, 'vort' ) ! filename
  474. IF(lwp) WRITE(numout,*) ' Name of NETCDF file ', clhstnam
  475. CALL histbeg( clhstnam, jpi, glamf, jpj, gphif,1, jpi, & ! Horizontal grid : glamt and gphit
  476. & 1, jpj, nit000-1, zjulian, rdt, nh_t, nidvor, domain_id=nidom, snc4chunks=snc4set )
  477. CALL wheneq( jpi*jpj, fmask, 1, 1., ndexvor1, ndimvor1 ) ! surface
  478. ! Declare output fields as netCDF variables
  479. CALL histdef( nidvor, "sovortPh", cvort//"grad Ph" , "s-2", & ! grad Ph
  480. & jpi,jpj,nh_t,1,1,1,-99,32,clop,zsto,zout)
  481. CALL histdef( nidvor, "sovortEk", cvort//"Energy", "s-2", & ! Energy
  482. & jpi,jpj,nh_t,1,1,1,-99,32,clop,zsto,zout)
  483. CALL histdef( nidvor, "sovozeta", cvort//"rel vorticity", "s-2", & ! rel vorticity
  484. & jpi,jpj,nh_t,1,1,1,-99,32,clop,zsto,zout)
  485. CALL histdef( nidvor, "sovortif", cvort//"coriolis", "s-2", & ! coriolis
  486. & jpi,jpj,nh_t,1,1,1,-99,32,clop,zsto,zout)
  487. CALL histdef( nidvor, "sovodifl", cvort//"lat diff ", "s-2", & ! lat diff
  488. & jpi,jpj,nh_t,1,1,1,-99,32,clop,zsto,zout)
  489. CALL histdef( nidvor, "sovoadvv", cvort//"vert adv", "s-2", & ! vert adv
  490. & jpi,jpj,nh_t,1,1,1,-99,32,clop,zsto,zout)
  491. CALL histdef( nidvor, "sovodifv", cvort//"vert diff" , "s-2", & ! vert diff
  492. & jpi,jpj,nh_t,1,1,1,-99,32,clop,zsto,zout)
  493. CALL histdef( nidvor, "sovortPs", cvort//"grad Ps", "s-2", & ! grad Ps
  494. & jpi,jpj,nh_t,1,1,1,-99,32,clop,zsto,zout)
  495. CALL histdef( nidvor, "sovortbv", cvort//"Beta V", "s-2", & ! beta.V
  496. & jpi,jpj,nh_t,1,1,1,-99,32,clop,zsto,zout)
  497. CALL histdef( nidvor, "sovowind", cvort//"wind stress", "s-2", & ! wind stress
  498. & jpi,jpj,nh_t,1,1,1,-99,32,clop,zsto,zout)
  499. CALL histdef( nidvor, "sovobfri", cvort//"bottom friction", "s-2", & ! bottom friction
  500. & jpi,jpj,nh_t,1,1,1,-99,32,clop,zsto,zout)
  501. CALL histdef( nidvor, "1st_mbre", cvort//"1st mbre", "s-2", & ! First membre
  502. & jpi,jpj,nh_t,1,1,1,-99,32,clop,zsto,zout)
  503. CALL histdef( nidvor, "sovorgap", cvort//"gap", "s-2", & ! gap between 1st and 2 nd mbre
  504. & jpi,jpj,nh_t,1,1,1,-99,32,clop,zsto,zout)
  505. CALL histend( nidvor, snc4set )
  506. IF( ndebug /= 0 ) THEN
  507. WRITE(numout,*) ' debuging trd_vor_init: II. done'
  508. CALL FLUSH(numout)
  509. ENDIF
  510. !
  511. END SUBROUTINE trd_vor_init
  512. !!======================================================================
  513. END MODULE trdvor