dynldf.F90 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. MODULE dynldf
  2. !!======================================================================
  3. !! *** MODULE dynldf ***
  4. !! Ocean physics: lateral diffusivity trends
  5. !!=====================================================================
  6. !! History : 9.0 ! 05-11 (G. Madec) Original code (new step architecture)
  7. !!----------------------------------------------------------------------
  8. !!----------------------------------------------------------------------
  9. !! dyn_ldf : update the dynamics trend with the lateral diffusion
  10. !! dyn_ldf_init : initialization, namelist read, and parameters control
  11. !!----------------------------------------------------------------------
  12. USE oce ! ocean dynamics and tracers
  13. USE dom_oce ! ocean space and time domain
  14. USE phycst ! physical constants
  15. USE ldfdyn_oce ! ocean dynamics lateral physics
  16. USE ldftra_oce ! ocean tracers lateral physics
  17. USE ldfslp ! lateral mixing: slopes of mixing orientation
  18. USE dynldf_bilapg ! lateral mixing (dyn_ldf_bilapg routine)
  19. USE dynldf_bilap ! lateral mixing (dyn_ldf_bilap routine)
  20. USE dynldf_iso ! lateral mixing (dyn_ldf_iso routine)
  21. USE dynldf_lap ! lateral mixing (dyn_ldf_lap routine)
  22. USE trd_oce ! trends: ocean variables
  23. USE trddyn ! trend manager: dynamics (trd_dyn routine)
  24. !
  25. USE prtctl ! Print control
  26. USE in_out_manager ! I/O manager
  27. USE lib_mpp ! distribued memory computing library
  28. USE lbclnk ! ocean lateral boundary conditions (or mpp link)
  29. USE wrk_nemo ! Memory Allocation
  30. USE timing ! Timing
  31. IMPLICIT NONE
  32. PRIVATE
  33. PUBLIC dyn_ldf ! called by step module
  34. PUBLIC dyn_ldf_init ! called by opa module
  35. INTEGER :: nldf = -2 ! type of lateral diffusion used defined from ln_dynldf_... namlist logicals)
  36. !! * Substitutions
  37. # include "domzgr_substitute.h90"
  38. # include "vectopt_loop_substitute.h90"
  39. !!----------------------------------------------------------------------
  40. !! NEMO/OPA 3.3 , NEMO Consortium (2010)
  41. !! $Id: dynldf.F90 4990 2014-12-15 16:42:49Z timgraham $
  42. !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
  43. !!----------------------------------------------------------------------
  44. CONTAINS
  45. SUBROUTINE dyn_ldf( kt )
  46. !!----------------------------------------------------------------------
  47. !! *** ROUTINE dyn_ldf ***
  48. !!
  49. !! ** Purpose : compute the lateral ocean dynamics physics.
  50. !!----------------------------------------------------------------------
  51. INTEGER, INTENT(in) :: kt ! ocean time-step index
  52. !
  53. REAL(wp), POINTER, DIMENSION(:,:,:) :: ztrdu, ztrdv
  54. !!----------------------------------------------------------------------
  55. !
  56. IF( nn_timing == 1 ) CALL timing_start('dyn_ldf')
  57. !
  58. IF( l_trddyn ) THEN ! temporary save of ta and sa trends
  59. CALL wrk_alloc( jpi, jpj, jpk, ztrdu, ztrdv )
  60. ztrdu(:,:,:) = ua(:,:,:)
  61. ztrdv(:,:,:) = va(:,:,:)
  62. ENDIF
  63. SELECT CASE ( nldf ) ! compute lateral mixing trend and add it to the general trend
  64. !
  65. CASE ( 0 ) ; CALL dyn_ldf_lap ( kt ) ! iso-level laplacian
  66. CASE ( 1 ) ; CALL dyn_ldf_iso ( kt ) ! rotated laplacian (except dk[ dk[.] ] part)
  67. CASE ( 2 ) ; CALL dyn_ldf_bilap ( kt ) ! iso-level bilaplacian
  68. CASE ( 3 ) ; CALL dyn_ldf_bilapg ( kt ) ! s-coord. horizontal bilaplacian
  69. CASE ( 4 ) ! iso-level laplacian + bilaplacian
  70. CALL dyn_ldf_lap ( kt )
  71. CALL dyn_ldf_bilap ( kt )
  72. CASE ( 5 ) ! rotated laplacian + bilaplacian (s-coord)
  73. CALL dyn_ldf_iso ( kt )
  74. CALL dyn_ldf_bilapg ( kt )
  75. !
  76. CASE ( -1 ) ! esopa: test all possibility with control print
  77. CALL dyn_ldf_lap ( kt )
  78. CALL prt_ctl( tab3d_1=ua, clinfo1=' ldf0 - Ua: ', mask1=umask, &
  79. & tab3d_2=va, clinfo2= ' Va: ', mask2=vmask, clinfo3='dyn' )
  80. CALL dyn_ldf_iso ( kt )
  81. CALL prt_ctl( tab3d_1=ua, clinfo1=' ldf1 - Ua: ', mask1=umask, &
  82. & tab3d_2=va, clinfo2= ' Va: ', mask2=vmask, clinfo3='dyn' )
  83. CALL dyn_ldf_bilap ( kt )
  84. CALL prt_ctl( tab3d_1=ua, clinfo1=' ldf2 - Ua: ', mask1=umask, &
  85. & tab3d_2=va, clinfo2= ' Va: ', mask2=vmask, clinfo3='dyn' )
  86. CALL dyn_ldf_bilapg ( kt )
  87. CALL prt_ctl( tab3d_1=ua, clinfo1=' ldf3 - Ua: ', mask1=umask, &
  88. & tab3d_2=va, clinfo2= ' Va: ', mask2=vmask, clinfo3='dyn' )
  89. !
  90. CASE ( -2 ) ! neither laplacian nor bilaplacian schemes used
  91. IF( kt == nit000 ) THEN
  92. IF(lwp) WRITE(numout,*)
  93. IF(lwp) WRITE(numout,*) 'dyn_ldf : no lateral diffusion on momentum setup'
  94. IF(lwp) WRITE(numout,*) '~~~~~~~ '
  95. ENDIF
  96. END SELECT
  97. IF( l_trddyn ) THEN ! save the horizontal diffusive trends for further diagnostics
  98. ztrdu(:,:,:) = ua(:,:,:) - ztrdu(:,:,:)
  99. ztrdv(:,:,:) = va(:,:,:) - ztrdv(:,:,:)
  100. CALL trd_dyn( ztrdu, ztrdv, jpdyn_ldf, kt )
  101. CALL wrk_dealloc( jpi, jpj, jpk, ztrdu, ztrdv )
  102. ENDIF
  103. ! ! print sum trends (used for debugging)
  104. IF(ln_ctl) CALL prt_ctl( tab3d_1=ua, clinfo1=' ldf - Ua: ', mask1=umask, &
  105. & tab3d_2=va, clinfo2= ' Va: ', mask2=vmask, clinfo3='dyn' )
  106. !
  107. IF( nn_timing == 1 ) CALL timing_stop('dyn_ldf')
  108. !
  109. END SUBROUTINE dyn_ldf
  110. SUBROUTINE dyn_ldf_init
  111. !!----------------------------------------------------------------------
  112. !! *** ROUTINE dyn_ldf_init ***
  113. !!
  114. !! ** Purpose : initializations of the horizontal ocean dynamics physics
  115. !!----------------------------------------------------------------------
  116. INTEGER :: ioptio, ierr ! temporary integers
  117. !!----------------------------------------------------------------------
  118. ! ! Namelist nam_dynldf: already read in ldfdyn module
  119. IF(lwp) THEN ! Namelist print
  120. WRITE(numout,*)
  121. WRITE(numout,*) 'dyn_ldf_init : Choice of the lateral diffusive operator on dynamics'
  122. WRITE(numout,*) '~~~~~~~~~~~'
  123. WRITE(numout,*) ' Namelist nam_dynldf : set lateral mixing parameters (type, direction, coefficients)'
  124. WRITE(numout,*) ' laplacian operator ln_dynldf_lap = ', ln_dynldf_lap
  125. WRITE(numout,*) ' bilaplacian operator ln_dynldf_bilap = ', ln_dynldf_bilap
  126. WRITE(numout,*) ' iso-level ln_dynldf_level = ', ln_dynldf_level
  127. WRITE(numout,*) ' horizontal (geopotential) ln_dynldf_hor = ', ln_dynldf_hor
  128. WRITE(numout,*) ' iso-neutral ln_dynldf_iso = ', ln_dynldf_iso
  129. ENDIF
  130. ! ! control the consistency
  131. ioptio = 0
  132. IF( ln_dynldf_lap ) ioptio = ioptio + 1
  133. IF( ln_dynldf_bilap ) ioptio = ioptio + 1
  134. IF( ioptio < 1 ) CALL ctl_warn( ' neither laplacian nor bilaplacian operator set for dynamics' )
  135. ioptio = 0
  136. IF( ln_dynldf_level ) ioptio = ioptio + 1
  137. IF( ln_dynldf_hor ) ioptio = ioptio + 1
  138. IF( ln_dynldf_iso ) ioptio = ioptio + 1
  139. IF( ioptio > 1 ) CALL ctl_stop( ' use only ONE direction (level/hor/iso)' )
  140. IF( ln_dynldf_iso .AND. ln_traldf_hor ) CALL ctl_stop &
  141. & ( 'Not sensible to use geopotential diffusion for tracers with isoneutral diffusion for dynamics' )
  142. ! ! Set nldf, the type of lateral diffusion, from ln_dynldf_... logicals
  143. ierr = 0
  144. IF ( ln_dynldf_lap ) THEN ! laplacian operator
  145. IF ( ln_zco ) THEN ! z-coordinate
  146. IF ( ln_dynldf_level ) nldf = 0 ! iso-level (no rotation)
  147. IF ( ln_dynldf_hor ) nldf = 0 ! horizontal (no rotation)
  148. IF ( ln_dynldf_iso ) nldf = 1 ! isoneutral ( rotation)
  149. ENDIF
  150. IF ( ln_zps ) THEN ! z-coordinate
  151. IF ( ln_dynldf_level ) ierr = 1 ! iso-level not allowed
  152. IF ( ln_dynldf_hor ) nldf = 0 ! horizontal (no rotation)
  153. IF ( ln_dynldf_iso ) nldf = 1 ! isoneutral ( rotation)
  154. ENDIF
  155. IF ( ln_sco ) THEN ! s-coordinate
  156. IF ( ln_dynldf_level ) nldf = 0 ! iso-level (no rotation)
  157. IF ( ln_dynldf_hor ) nldf = 1 ! horizontal ( rotation)
  158. IF ( ln_dynldf_iso ) nldf = 1 ! isoneutral ( rotation)
  159. ENDIF
  160. ENDIF
  161. IF( ln_dynldf_bilap ) THEN ! bilaplacian operator
  162. IF ( ln_zco ) THEN ! z-coordinate
  163. IF ( ln_dynldf_level ) nldf = 2 ! iso-level (no rotation)
  164. IF ( ln_dynldf_hor ) nldf = 2 ! horizontal (no rotation)
  165. IF ( ln_dynldf_iso ) ierr = 2 ! isoneutral ( rotation)
  166. ENDIF
  167. IF ( ln_zps ) THEN ! z-coordinate
  168. IF ( ln_dynldf_level ) ierr = 1 ! iso-level not allowed
  169. IF ( ln_dynldf_hor ) nldf = 2 ! horizontal (no rotation)
  170. IF ( ln_dynldf_iso ) ierr = 2 ! isoneutral ( rotation)
  171. ENDIF
  172. IF ( ln_sco ) THEN ! s-coordinate
  173. IF ( ln_dynldf_level ) nldf = 2 ! iso-level (no rotation)
  174. IF ( ln_dynldf_hor ) nldf = 3 ! horizontal ( rotation)
  175. IF ( ln_dynldf_iso ) ierr = 2 ! isoneutral ( rotation)
  176. ENDIF
  177. ENDIF
  178. IF( ln_dynldf_lap .AND. ln_dynldf_bilap ) THEN ! mixed laplacian and bilaplacian operators
  179. IF ( ln_zco ) THEN ! z-coordinate
  180. IF ( ln_dynldf_level ) nldf = 4 ! iso-level (no rotation)
  181. IF ( ln_dynldf_hor ) nldf = 4 ! horizontal (no rotation)
  182. IF ( ln_dynldf_iso ) ierr = 2 ! isoneutral ( rotation)
  183. ENDIF
  184. IF ( ln_zps ) THEN ! z-coordinate
  185. IF ( ln_dynldf_level ) ierr = 1 ! iso-level not allowed
  186. IF ( ln_dynldf_hor ) nldf = 4 ! horizontal (no rotation)
  187. IF ( ln_dynldf_iso ) ierr = 2 ! isoneutral ( rotation)
  188. ENDIF
  189. IF ( ln_sco ) THEN ! s-coordinate
  190. IF ( ln_dynldf_level ) nldf = 4 ! iso-level (no rotation)
  191. IF ( ln_dynldf_hor ) nldf = 5 ! horizontal ( rotation)
  192. IF ( ln_dynldf_iso ) ierr = 2 ! isoneutral ( rotation)
  193. ENDIF
  194. ENDIF
  195. IF( lk_esopa ) nldf = -1 ! esopa test
  196. IF( ierr == 1 ) CALL ctl_stop( 'iso-level in z-coordinate - partial step, not allowed' )
  197. IF( ierr == 2 ) CALL ctl_stop( 'isoneutral bilaplacian operator does not exist' )
  198. IF( nldf == 1 .OR. nldf == 3 ) THEN ! rotation
  199. IF( .NOT.lk_ldfslp ) CALL ctl_stop( 'the rotation of the diffusive tensor require key_ldfslp' )
  200. ENDIF
  201. IF(lwp) THEN
  202. WRITE(numout,*)
  203. IF( nldf == -2 ) WRITE(numout,*) ' neither laplacian nor bilaplacian schemes used'
  204. IF( nldf == -1 ) WRITE(numout,*) ' ESOPA test All scheme used'
  205. IF( nldf == 0 ) WRITE(numout,*) ' laplacian operator'
  206. IF( nldf == 1 ) WRITE(numout,*) ' rotated laplacian operator'
  207. IF( nldf == 2 ) WRITE(numout,*) ' bilaplacian operator'
  208. IF( nldf == 3 ) WRITE(numout,*) ' rotated bilaplacian'
  209. IF( nldf == 4 ) WRITE(numout,*) ' laplacian and bilaplacian operators'
  210. IF( nldf == 5 ) WRITE(numout,*) ' rotated laplacian and bilaplacian operators'
  211. ENDIF
  212. !
  213. END SUBROUTINE dyn_ldf_init
  214. !!======================================================================
  215. END MODULE dynldf