ldftra_smag.F90 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. MODULE ldftra_smag
  2. !!======================================================================
  3. !! *** MODULE ldftrasmag ***
  4. !! Ocean physics: variable eddy induced velocity coefficients
  5. !!======================================================================
  6. #if defined key_traldf_smag && defined key_traldf_c3d
  7. !!----------------------------------------------------------------------
  8. !! 'key_traldf_smag' and smagorinsky diffusivity
  9. !! 'key_traldf_c3d' 3D tracer lateral mixing coef.
  10. !!----------------------------------------------------------------------
  11. !! ldf_eiv : compute the eddy induced velocity coefficients
  12. !!----------------------------------------------------------------------
  13. !! * Modules used
  14. USE oce ! ocean dynamics and tracers
  15. USE dom_oce ! ocean space and time domain
  16. USE sbc_oce ! surface boundary condition: ocean
  17. USE sbcrnf ! river runoffs
  18. USE ldftra_oce ! ocean tracer lateral physics
  19. USE phycst ! physical constants
  20. USE ldfslp ! iso-neutral slopes
  21. USE in_out_manager ! I/O manager
  22. USE lbclnk ! ocean lateral boundary conditions (or mpp link)
  23. USE prtctl ! Print control
  24. USE iom
  25. USE wrk_nemo
  26. IMPLICIT NONE
  27. PRIVATE
  28. !! * Routine accessibility
  29. PUBLIC ldf_tra_smag ! routine called by step.F90
  30. !!----------------------------------------------------------------------
  31. !! OPA 9.0 , LOCEAN-IPSL (2005)
  32. !! $Id: ldftra_smag.F90 2355 2015-05-20 07:11:50Z ufla $
  33. !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt
  34. !!----------------------------------------------------------------------
  35. !! * Substitutions
  36. # include "domzgr_substitute.h90"
  37. # include "vectopt_loop_substitute.h90"
  38. !!----------------------------------------------------------------------
  39. CONTAINS
  40. !!----------------------------------------------------------------------
  41. !! *** ldf_tra_smag.F90 ***
  42. !!----------------------------------------------------------------------
  43. SUBROUTINE ldf_tra_smag( kt )
  44. !!----------------------------------------------------------------------
  45. !!----------------------------------------------------------------------
  46. !! *** ROUTINE ldf_tra_smag ***
  47. !!
  48. !! ** Purpose : initializations of the horizontal ocean physics
  49. !!
  50. !! ** Method : 3D eddy viscosity coef.
  51. !! M.Griffies, R.Hallberg AMS, 2000
  52. !! for laplacian:
  53. !! Asmag=(C/pi)^2*dx*dy sqrt(D^2), C=1 for tracers, C=3-4 for viscosity
  54. !! D^2= rm_smsh*(du/dx-dv/dy)^2+(dv/dx+du/dy)^2 for Cartesian coordinates
  55. !! IF rm_smsh = 0 , only shear is used, recommended for tidal flows
  56. !! in general case du/dx ==> e2 d(u/e2)/dx; du/dy ==> e1 d(u/e1)/dy;
  57. !! dv/dx ==> e2 d(v/e2)/dx; dv/dy ==> e1 d(v/e1)/dy
  58. !! for bilaplacian: now this option is deleted as unstable or non-conservative
  59. !! - delta{Bsmag (delta(T)} = -Bsmag* delta{delta(T)} - delta(Bsmag)*delta( T )
  60. !! second term is of arbitrary sign on the edge of fronts and can induce instability
  61. !! Bsmag=Asmag*dx*dy/8
  62. !!
  63. !! laplacian operator : ahm1, ahm2 defined at T- and F-points
  64. !! ahm3, ahm4 never used
  65. !! bilaplacian operator : ahm1, ahm2 never used
  66. !! : ahm3, ahm4 defined at U- and V-points
  67. !! ??? explanation of the default is missing
  68. !! last modified : Maria Luneva, October 2012
  69. !!----------------------------------------------------------------------
  70. !!
  71. !!----------------------------------------------------------------------
  72. !! * Modules used
  73. USE ioipsl
  74. REAL ( wp), POINTER , DIMENSION (:,:) :: zux, zvx , zuy , zvy
  75. REAL ( wp), POINTER , DIMENSION (:,:) :: zue1, zue2 , zve1 , zve2
  76. INTEGER, INTENT( in ) :: kt ! ocean time-step inedx
  77. !! * Arguments
  78. INTEGER :: ji,jj,jk
  79. REAL (wp) :: zdeltau, zdeltav, zhsmag ,zsmsh ! temporary scalars
  80. CALL wrk_alloc (jpi,jpj,zux, zvx , zuy , zvy )
  81. CALL wrk_alloc (jpi,jpj,zue1, zue2 , zve1 , zve2 )
  82. !!----------------------------------------------------------------------
  83. IF( kt == nit000 ) THEN
  84. IF(lwp) WRITE(numout,*)
  85. IF(lwp) WRITE(numout,*) ' ldf_tra_smag : 3D eddy smagorinsky diffusivity '
  86. IF(lwp) WRITE(numout,*) ' ~~~~~~~~~~~ -- '
  87. IF(lwp) WRITE(numout,*) ' Coefficients are computed'
  88. IF(lwp) WRITE(numout,*)
  89. IF(lwp) WRITE(numout,*)
  90. ENDIF
  91. zhsmag = rn_chsmag
  92. zsmsh = rn_smsh
  93. zux(:,:)=0._wp ; zuy(:,:)=0._wp ; zvx(:,:)=0._wp ; zvy(:,:)=0._wp
  94. ! -------------------
  95. ahtt(:,:,:) = rn_aht_0
  96. IF( ln_traldf_bilap ) THEN
  97. IF( lwp .AND. kt == nit000) WRITE(numout,* )'ldf_tra_smag :no bilaplacian Smagorinsky diffusivity'
  98. IF( lwp .AND. kt == nit000) WRITE(numout,* )'ldf_tra_smag :bilaplacian diffusivity set to constant'
  99. ENDIF
  100. ! harmonic operator (U-, V-, W-points)
  101. ! -----------------
  102. ahtu(:,:,:) = rn_aht_0 ! set ahtu , ahtv at u- and v-points,
  103. ahtv(:,:,:) = rn_aht_0 ! and ahtw at w-point
  104. ahtw(:,:,:) = rn_aht_0 ! (here example: no space variation)
  105. IF( ln_traldf_lap ) THEN
  106. DO jk=1,jpk
  107. zue2(:,:)=un(:,:,jk)/e2u(:,:)
  108. zve1(:,:)=vn(:,:,jk)/e1v(:,:)
  109. zue1(:,:)=un(:,:,jk)/e1u(:,:)
  110. zve2(:,:)=vn(:,:,jk)/e2v(:,:)
  111. DO jj=2,jpj
  112. DO ji=2,jpi
  113. zux(ji,jj)=(zue2(ji,jj)-zue2(ji-1,jj))/e1t(ji,jj)*e2t(ji,jj)*tmask(ji,jj,jk) * zsmsh
  114. zvy(ji,jj)=(zve1(ji,jj)-zve1(ji,jj-1))/e2t(ji,jj)*e1t(ji,jj)*tmask(ji,jj,jk) * zsmsh
  115. ENDDO
  116. ENDDO
  117. DO jj=1,jpjm1
  118. DO ji=1,jpim1
  119. zuy(ji,jj)=(zue1(ji,jj+1)-zue1(ji,jj))/e2f(ji,jj)*e1f(ji,jj)*fmask(ji,jj,jk)
  120. zvx(ji,jj)=(zve2(ji+1,jj)-zve2(ji,jj))/e1f(ji,jj)*e2f(ji,jj)*fmask(ji,jj,jk)
  121. ENDDO
  122. ENDDO
  123. DO jj=2,jpjm1
  124. DO ji=2,jpim1
  125. zdeltau=2._wp/( e1u(ji,jj)**(-2)+e2u(ji,jj)**(-2) )
  126. zdeltav=2._wp/( e1v(ji,jj)**(-2)+e2v(ji,jj)**(-2) )
  127. ahtu(ji,jj,jk)=MAX( rn_aht_0 , (zhsmag/rpi)**2*zdeltau* &
  128. SQRT(0.25_wp*( zux(ji,jj)+zux(ji+1,jj)-zvy(ji,jj)-zvy(ji+1,jj) )**2+ &
  129. 0.25_wp*( zuy(ji,jj)+zuy(ji,jj-1)+zvx(ji,jj)+zvx(ji,jj-1) )**2) )
  130. ahtv(ji,jj,jk)=MAX( rn_aht_0 , (zhsmag/rpi)**2*zdeltav* &
  131. SQRT(0.25_wp*( zux(ji,jj)+zux(ji,jj+1)-zvy(ji,jj)-zvy(ji,jj+1) )**2+ &
  132. 0.25_wp*( zuy(ji,jj)+zuy(ji-1,jj)+zvx(ji-1,jj)+zvx(ji,jj) )**2) )
  133. !!! stability criteria: aht<delta**2/(4*dt) dt=2*rdt , positiveness require aht<delta**2/(8*dt)
  134. ahtu(ji,jj,jk)=MIN(ahtu(ji,jj,jk),zdeltau/(16*rdt) ,rn_aht_m)
  135. ahtv(ji,jj,jk)=MIN(ahtv(ji,jj,jk),zdeltav/(16*rdt) ,rn_aht_m)
  136. ! so...
  137. ENDDO
  138. ENDDO
  139. ENDDO
  140. ENDIF
  141. ahtu(:,:,jpk) = ahtu(:,:,jpkm1)
  142. ahtv(:,:,jpk) = ahtv(:,:,jpkm1)
  143. CALL lbc_lnk( ahtu, 'U', 1. ) ! Lateral boundary conditions
  144. CALL lbc_lnk( ahtv, 'V', 1. )
  145. IF( kt == nit000 ) THEN
  146. IF(lwp ) THEN ! Control print
  147. WRITE(numout,*)
  148. WRITE(numout,*) 'inildf: ahtu at k = 1'
  149. CALL prihre( ahtu(:,:,1), jpi, jpj, 1, jpi, 1, &
  150. & 1, jpj, 1, 1.e-1, numout )
  151. WRITE(numout,*)
  152. WRITE(numout,*) 'inildf: ahtv at k = 1'
  153. CALL prihre( ahtv(:,:,1), jpi, jpj, 1, jpi, 1, &
  154. & 1, jpj, 1, 1.e-1, numout )
  155. WRITE(numout,*)
  156. WRITE(numout,*) 'inildf: ahtw at k = 1'
  157. CALL prihre( ahtw(:,:,1), jpi, jpj, 1, jpi, 1, &
  158. & 1, jpj, 1, 1.e-1, numout )
  159. ENDIF
  160. ENDIF
  161. CALL wrk_dealloc ( jpi,jpj,zux, zvx , zuy , zvy )
  162. CALL wrk_dealloc ( jpi,jpj,zue1, zue2 , zve1 , zve2 )
  163. END SUBROUTINE ldf_tra_smag
  164. #else
  165. !!----------------------------------------------------------------------
  166. !! Default option Dummy module
  167. !!----------------------------------------------------------------------
  168. CONTAINS
  169. SUBROUTINE ldf_tra_smag( kt ) ! Empty routine
  170. WRITE(*,*) 'ldf_dyn_smag: You should not have seen this print! error? check keys ldf:c3d+smag', kt
  171. END SUBROUTINE ldf_tra_smag
  172. #endif
  173. END MODULE ldftra_smag