traldf_bilap.F90 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. MODULE traldf_bilap
  2. !!==============================================================================
  3. !! *** MODULE traldf_bilap ***
  4. !! Ocean tracers: horizontal component of the lateral tracer mixing trend
  5. !!==============================================================================
  6. !! History : OPA ! 1991-11 (G. Madec) Original code
  7. !! ! 1993-03 (M. Guyon) symetrical conditions
  8. !! ! 1995-11 (G. Madec) suppress volumetric scale factors
  9. !! ! 1996-01 (G. Madec) statement function for e3
  10. !! ! 1996-01 (M. Imbard) mpp exchange
  11. !! ! 1997-07 (G. Madec) optimization, and ahtt
  12. !! 8.5 ! 2002-08 (G. Madec) F90: Free form and module
  13. !! NEMO 1.0 ! 2004-08 (C. Talandier) New trends organization
  14. !! - ! 2005-11 (G. Madec) zps or sco as default option
  15. !! 3.3 ! 2010-05 (C. Ethe, G. Madec) merge TRC-TRA
  16. !!==============================================================================
  17. !!----------------------------------------------------------------------
  18. !! tra_ldf_bilap : update the tracer trend with the horizontal diffusion
  19. !! using a iso-level biharmonic operator
  20. !!----------------------------------------------------------------------
  21. USE oce ! ocean dynamics and active tracers
  22. USE dom_oce ! ocean space and time domain
  23. USE ldftra_oce ! ocean tracer lateral physics
  24. USE in_out_manager ! I/O manager
  25. USE ldfslp ! iso-neutral slopes
  26. USE lbclnk ! ocean lateral boundary conditions (or mpp link)
  27. USE diaptr ! poleward transport diagnostics
  28. USE trc_oce ! share passive tracers/Ocean variables
  29. USE lib_mpp ! MPP library
  30. USE wrk_nemo ! Memory Allocation
  31. USE timing ! Timing
  32. IMPLICIT NONE
  33. PRIVATE
  34. PUBLIC tra_ldf_bilap ! routine called by step.F90
  35. !! * Substitutions
  36. # include "domzgr_substitute.h90"
  37. # include "ldftra_substitute.h90"
  38. # include "ldfeiv_substitute.h90"
  39. # include "vectopt_loop_substitute.h90"
  40. !!----------------------------------------------------------------------
  41. !! NEMO/OPA 3.3 , NEMO Consortium (2010)
  42. !! $Id: traldf_bilap.F90 4990 2014-12-15 16:42:49Z timgraham $
  43. !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
  44. !!----------------------------------------------------------------------
  45. CONTAINS
  46. SUBROUTINE tra_ldf_bilap( kt, kit000, cdtype, pgu, pgv, &
  47. & pgui, pgvi, &
  48. & ptb, pta, kjpt )
  49. !!----------------------------------------------------------------------
  50. !! *** ROUTINE tra_ldf_bilap ***
  51. !!
  52. !! ** Purpose : Compute the before horizontal tracer diffusive
  53. !! trend and add it to the general trend of tracer equation.
  54. !!
  55. !! ** Method : 4th order diffusive operator along model level surfaces
  56. !! evaluated using before fields (forward time scheme). The hor.
  57. !! diffusive trends is given by:
  58. !! Laplacian of tb:
  59. !! zlt = 1/(e1t*e2t*e3t) { di-1[ e2u*e3u/e1u di(tb) ]
  60. !! + dj-1[ e1v*e3v/e2v dj(tb) ] }
  61. !! Multiply by the eddy diffusivity coef. and insure lateral bc:
  62. !! zlt = ahtt * zlt
  63. !! call to lbc_lnk
  64. !! Bilaplacian (laplacian of zlt):
  65. !! difft = 1/(e1t*e2t*e3t) { di-1[ e2u*e3u/e1u di(zlt) ]
  66. !! + dj-1[ e1v*e3v/e2v dj(zlt) ] }
  67. !!
  68. !! Add this trend to the general trend
  69. !! (pta) = (pta) + ( difft )
  70. !!
  71. !! ** Action : - Update pta arrays with the before iso-level
  72. !! biharmonic mixing trend.
  73. !!----------------------------------------------------------------------
  74. USE oce , ONLY: ztu => ua , ztv => va ! (ua,va) used as workspace
  75. !!
  76. INTEGER , INTENT(in ) :: kt ! ocean time-step index
  77. INTEGER , INTENT(in ) :: kit000 ! first time step index
  78. CHARACTER(len=3) , INTENT(in ) :: cdtype ! =TRA or TRC (tracer indicator)
  79. INTEGER , INTENT(in ) :: kjpt ! number of tracers
  80. REAL(wp), DIMENSION(jpi,jpj, kjpt), INTENT(in ) :: pgu , pgv ! tracer gradient at pstep levels
  81. REAL(wp), DIMENSION(jpi,jpj, kjpt), INTENT(in ) :: pgui, pgvi ! tracer gradient at pstep levels
  82. REAL(wp), DIMENSION(jpi,jpj,jpk,kjpt), INTENT(in ) :: ptb ! before and now tracer fields
  83. REAL(wp), DIMENSION(jpi,jpj,jpk,kjpt), INTENT(inout) :: pta ! tracer trend
  84. !!
  85. INTEGER :: ji, jj, jk, jn ! dummy loop indices
  86. REAL(wp) :: zbtr, ztra ! local scalars
  87. REAL(wp), POINTER, DIMENSION(:,:) :: zeeu, zeev, zlt
  88. !!----------------------------------------------------------------------
  89. !
  90. IF( nn_timing == 1 ) CALL timing_start( 'tra_ldf_bilap')
  91. !
  92. CALL wrk_alloc( jpi, jpj, zeeu, zeev, zlt )
  93. !
  94. IF( kt == kit000 ) THEN
  95. IF(lwp) WRITE(numout,*)
  96. IF(lwp) WRITE(numout,*) 'tra_ldf_bilap : iso-level biharmonic operator on ', cdtype
  97. IF(lwp) WRITE(numout,*) '~~~~~~~~~~~~~'
  98. ENDIF
  99. ! ! ===========
  100. DO jn = 1, kjpt ! tracer loop
  101. ! ! ===========
  102. !
  103. DO jk = 1, jpkm1 ! Horizontal slab
  104. !
  105. ! !== Initialization of metric arrays (for z- or s-coordinates) ==!
  106. DO jj = 1, jpjm1
  107. DO ji = 1, fs_jpim1 ! vector opt.
  108. zeeu(ji,jj) = re2u_e1u(ji,jj) * fse3u_n(ji,jj,jk) * umask(ji,jj,jk)
  109. zeev(ji,jj) = re1v_e2v(ji,jj) * fse3v_n(ji,jj,jk) * vmask(ji,jj,jk)
  110. END DO
  111. END DO
  112. ! !== Laplacian ==!
  113. !
  114. DO jj = 1, jpjm1 ! First derivative (gradient)
  115. DO ji = 1, fs_jpim1 ! vector opt.
  116. ztu(ji,jj,jk) = zeeu(ji,jj) * ( ptb(ji+1,jj ,jk,jn) - ptb(ji,jj,jk,jn) )
  117. ztv(ji,jj,jk) = zeev(ji,jj) * ( ptb(ji ,jj+1,jk,jn) - ptb(ji,jj,jk,jn) )
  118. END DO
  119. END DO
  120. !
  121. IF( ln_zps ) THEN ! set gradient at partial step level (last ocean level)
  122. DO jj = 1, jpjm1
  123. DO ji = 1, jpim1
  124. IF( mbku(ji,jj) == jk ) ztu(ji,jj,jk) = zeeu(ji,jj) * pgu(ji,jj,jn)
  125. IF( mbkv(ji,jj) == jk ) ztv(ji,jj,jk) = zeev(ji,jj) * pgv(ji,jj,jn)
  126. END DO
  127. END DO
  128. ENDIF
  129. ! (ISH)
  130. IF( ln_zps .AND. ln_isfcav ) THEN ! set gradient at partial step level (first ocean level in a cavity)
  131. DO jj = 1, jpjm1
  132. DO ji = 1, jpim1
  133. IF( miku(ji,jj) == MAX(jk,2) ) ztu(ji,jj,jk) = zeeu(ji,jj) * pgui(ji,jj,jn)
  134. IF( mikv(ji,jj) == MAX(jk,2) ) ztu(ji,jj,jk) = zeev(ji,jj) * pgvi(ji,jj,jn)
  135. END DO
  136. END DO
  137. ENDIF
  138. !
  139. DO jj = 2, jpjm1 ! Second derivative (divergence) time the eddy diffusivity coefficient
  140. DO ji = fs_2, fs_jpim1 ! vector opt.
  141. zbtr = 1.0 / ( e12t(ji,jj) * fse3t_n(ji,jj,jk) )
  142. zlt(ji,jj) = fsahtt(ji,jj,jk) * zbtr * ( ztu(ji,jj,jk) - ztu(ji-1,jj,jk) &
  143. & + ztv(ji,jj,jk) - ztv(ji,jj-1,jk) )
  144. END DO
  145. END DO
  146. CALL lbc_lnk( zlt, 'T', 1. ) ! Lateral boundary conditions (unchanged sgn)
  147. ! !== Bilaplacian ==!
  148. !
  149. DO jj = 1, jpjm1 ! third derivative (gradient)
  150. DO ji = 1, fs_jpim1 ! vector opt.
  151. ztu(ji,jj,jk) = zeeu(ji,jj) * ( zlt(ji+1,jj ) - zlt(ji,jj) )
  152. ztv(ji,jj,jk) = zeev(ji,jj) * ( zlt(ji ,jj+1) - zlt(ji,jj) )
  153. END DO
  154. END DO
  155. DO jj = 2, jpjm1 ! fourth derivative (divergence) and add to the general tracer trend
  156. DO ji = fs_2, fs_jpim1 ! vector opt.
  157. ! horizontal diffusive trends
  158. zbtr = 1.0 / ( e12t(ji,jj) * fse3t_n(ji,jj,jk) )
  159. ztra = zbtr * ( ztu(ji,jj,jk) - ztu(ji-1,jj,jk) + ztv(ji,jj,jk) - ztv(ji,jj-1,jk) )
  160. ! add it to the general tracer trends
  161. pta(ji,jj,jk,jn) = pta(ji,jj,jk,jn) + ztra
  162. END DO
  163. END DO
  164. !
  165. END DO ! Horizontal slab
  166. !
  167. ! "zonal" mean lateral diffusive heat and salt transport
  168. IF( cdtype == 'TRA' .AND. ln_diaptr ) CALL dia_ptr_ohst_components( jn, 'ldf', ztv(:,:,:) )
  169. ! ! ===========
  170. END DO ! tracer loop
  171. ! ! ===========
  172. IF( nn_timing == 1 ) CALL timing_stop( 'tra_ldf_bilap')
  173. !
  174. CALL wrk_dealloc( jpi, jpj, zeeu, zeev, zlt )
  175. !
  176. END SUBROUTINE tra_ldf_bilap
  177. !!==============================================================================
  178. END MODULE traldf_bilap