bdydyn.F90 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. MODULE bdydyn
  2. !!======================================================================
  3. !! *** MODULE bdydyn ***
  4. !! Unstructured Open Boundary Cond. : Apply boundary conditions to velocities
  5. !!======================================================================
  6. !! History : 1.0 ! 2005-02 (J. Chanut, A. Sellar) Original code
  7. !! - ! 2007-07 (D. Storkey) Move Flather implementation to separate routine.
  8. !! 3.0 ! 2008-04 (NEMO team) add in the reference version
  9. !! 3.2 ! 2008-04 (R. Benshila) consider velocity instead of transport
  10. !! 3.3 ! 2010-09 (E.O'Dea) modifications for Shelf configurations
  11. !! 3.3 ! 2010-09 (D.Storkey) add ice boundary conditions
  12. !! 3.4 ! 2011 (D. Storkey) rewrite in preparation for OBC-BDY merge
  13. !!----------------------------------------------------------------------
  14. #if defined key_bdy
  15. !!----------------------------------------------------------------------
  16. !! 'key_bdy' : Unstructured Open Boundary Condition
  17. !!----------------------------------------------------------------------
  18. !! bdy_dyn : split velocities into barotropic and baroclinic parts
  19. !! and call bdy_dyn2d and bdy_dyn3d to apply boundary
  20. !! conditions
  21. !!----------------------------------------------------------------------
  22. USE wrk_nemo ! Memory Allocation
  23. USE timing ! Timing
  24. USE oce ! ocean dynamics and tracers
  25. USE dom_oce ! ocean space and time domain
  26. USE dynspg_oce
  27. USE bdy_oce ! ocean open boundary conditions
  28. USE bdydyn2d ! open boundary conditions for barotropic solution
  29. USE bdydyn3d ! open boundary conditions for baroclinic velocities
  30. USE lbclnk ! ocean lateral boundary conditions (or mpp link)
  31. USE in_out_manager !
  32. USE domvvl ! variable volume
  33. IMPLICIT NONE
  34. PRIVATE
  35. PUBLIC bdy_dyn ! routine called in dynspg_flt (if lk_dynspg_flt) or
  36. ! dyn_nxt (if lk_dynspg_ts or lk_dynspg_exp)
  37. # include "domzgr_substitute.h90"
  38. !!----------------------------------------------------------------------
  39. !! NEMO/OPA 3.3 , NEMO Consortium (2010)
  40. !! $Id: bdydyn.F90 4689 2014-06-24 23:40:18Z clem $
  41. !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
  42. !!----------------------------------------------------------------------
  43. CONTAINS
  44. SUBROUTINE bdy_dyn( kt, dyn3d_only )
  45. !!----------------------------------------------------------------------
  46. !! *** SUBROUTINE bdy_dyn ***
  47. !!
  48. !! ** Purpose : - Wrapper routine for bdy_dyn2d and bdy_dyn3d.
  49. !!
  50. !!----------------------------------------------------------------------
  51. !!
  52. INTEGER, INTENT( in ) :: kt ! Main time step counter
  53. LOGICAL, INTENT( in ), OPTIONAL :: dyn3d_only ! T => only update baroclinic velocities
  54. !!
  55. INTEGER :: jk,ii,ij,ib_bdy,ib,igrd ! Loop counter
  56. LOGICAL :: ll_dyn2d, ll_dyn3d, ll_orlanski
  57. !!
  58. REAL(wp), POINTER, DIMENSION(:,:) :: pua2d, pva2d ! after barotropic velocities
  59. IF( nn_timing == 1 ) CALL timing_start('bdy_dyn')
  60. ll_dyn2d = .true.
  61. ll_dyn3d = .true.
  62. IF( PRESENT(dyn3d_only) ) THEN
  63. IF( dyn3d_only ) ll_dyn2d = .false.
  64. ENDIF
  65. ll_orlanski = .false.
  66. DO ib_bdy = 1, nb_bdy
  67. IF ( cn_dyn2d(ib_bdy) == 'orlanski' .or. cn_dyn2d(ib_bdy) == 'orlanski_npo' &
  68. & .or. cn_dyn3d(ib_bdy) == 'orlanski' .or. cn_dyn3d(ib_bdy) == 'orlanski_npo') ll_orlanski = .true.
  69. ENDDO
  70. !-------------------------------------------------------
  71. ! Set pointers
  72. !-------------------------------------------------------
  73. CALL wrk_alloc(jpi,jpj,pua2d,pva2d)
  74. !-------------------------------------------------------
  75. ! Split velocities into barotropic and baroclinic parts
  76. !-------------------------------------------------------
  77. ! "After" velocities:
  78. pua2d(:,:) = 0.e0
  79. pva2d(:,:) = 0.e0
  80. DO jk = 1, jpkm1
  81. pua2d(:,:) = pua2d(:,:) + fse3u_a(:,:,jk) * umask(:,:,jk) * ua(:,:,jk)
  82. pva2d(:,:) = pva2d(:,:) + fse3v_a(:,:,jk) * vmask(:,:,jk) * va(:,:,jk)
  83. END DO
  84. pua2d(:,:) = pua2d(:,:) * hur_a(:,:)
  85. pva2d(:,:) = pva2d(:,:) * hvr_a(:,:)
  86. DO jk = 1 , jpkm1
  87. ua(:,:,jk) = (ua(:,:,jk) - pua2d(:,:)) * umask(:,:,jk)
  88. va(:,:,jk) = (va(:,:,jk) - pva2d(:,:)) * vmask(:,:,jk)
  89. END DO
  90. ! "Before" velocities (required for Orlanski condition):
  91. IF ( ll_orlanski ) THEN
  92. DO jk = 1 , jpkm1
  93. ub(:,:,jk) = (ub(:,:,jk) - ub_b(:,:)) * umask(:,:,jk)
  94. vb(:,:,jk) = (vb(:,:,jk) - vb_b(:,:)) * vmask(:,:,jk)
  95. END DO
  96. END IF
  97. !-------------------------------------------------------
  98. ! Apply boundary conditions to barotropic and baroclinic
  99. ! parts separately
  100. !-------------------------------------------------------
  101. IF( ll_dyn2d ) CALL bdy_dyn2d( kt, pua2d, pva2d, ub_b, vb_b, hur_a(:,:), hvr_a(:,:), ssha )
  102. IF( ll_dyn3d ) CALL bdy_dyn3d( kt )
  103. !-------------------------------------------------------
  104. ! Recombine velocities
  105. !-------------------------------------------------------
  106. DO jk = 1 , jpkm1
  107. ua(:,:,jk) = ( ua(:,:,jk) + pua2d(:,:) ) * umask(:,:,jk)
  108. va(:,:,jk) = ( va(:,:,jk) + pva2d(:,:) ) * vmask(:,:,jk)
  109. END DO
  110. IF ( ll_orlanski ) THEN
  111. DO jk = 1 , jpkm1
  112. ub(:,:,jk) = ( ub(:,:,jk) + ub_b(:,:) ) * umask(:,:,jk)
  113. vb(:,:,jk) = ( vb(:,:,jk) + vb_b(:,:) ) * vmask(:,:,jk)
  114. END DO
  115. END IF
  116. CALL wrk_dealloc(jpi,jpj,pua2d,pva2d)
  117. IF( nn_timing == 1 ) CALL timing_stop('bdy_dyn')
  118. END SUBROUTINE bdy_dyn
  119. #else
  120. !!----------------------------------------------------------------------
  121. !! Dummy module NO Unstruct Open Boundary Conditions
  122. !!----------------------------------------------------------------------
  123. CONTAINS
  124. SUBROUTINE bdy_dyn( kt ) ! Empty routine
  125. WRITE(*,*) 'bdy_dyn: You should not have seen this print! error?', kt
  126. END SUBROUTINE bdy_dyn
  127. #endif
  128. !!======================================================================
  129. END MODULE bdydyn