sbctide.F90 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. MODULE sbctide
  2. !!======================================================================
  3. !! *** MODULE sbctide ***
  4. !! Initialization of tidal forcing
  5. !!======================================================================
  6. !! History : 9.0 ! 2007 (O. Le Galloudec) Original code
  7. !!----------------------------------------------------------------------
  8. USE oce ! ocean dynamics and tracers variables
  9. USE dom_oce ! ocean space and time domain
  10. USE phycst
  11. USE daymod
  12. USE dynspg_oce
  13. USE tideini
  14. !
  15. USE iom
  16. USE in_out_manager ! I/O units
  17. USE ioipsl ! NetCDF IPSL library
  18. USE lbclnk ! ocean lateral boundary conditions (or mpp link)
  19. IMPLICIT NONE
  20. PUBLIC
  21. REAL(wp), PUBLIC, ALLOCATABLE, DIMENSION(:,:) :: pot_astro !
  22. #if defined key_tide
  23. !!----------------------------------------------------------------------
  24. !! 'key_tide' : tidal potential
  25. !!----------------------------------------------------------------------
  26. !! sbc_tide :
  27. !! tide_init_potential :
  28. !!----------------------------------------------------------------------
  29. LOGICAL, PUBLIC, PARAMETER :: lk_tide = .TRUE.
  30. REAL(wp), ALLOCATABLE, DIMENSION(:,:,:) :: amp_pot, phi_pot
  31. !!----------------------------------------------------------------------
  32. !! NEMO/OPA 3.5 , NEMO Consortium (2013)
  33. !! $Id: sbctide.F90 2355 2015-05-20 07:11:50Z ufla $
  34. !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
  35. !!----------------------------------------------------------------------
  36. CONTAINS
  37. SUBROUTINE sbc_tide( kt )
  38. !!----------------------------------------------------------------------
  39. !! *** ROUTINE sbc_tide ***
  40. !!----------------------------------------------------------------------
  41. INTEGER, INTENT( in ) :: kt ! ocean time-step
  42. INTEGER :: jk ! dummy loop index
  43. !!----------------------------------------------------------------------
  44. IF( nsec_day == NINT(0.5_wp * rdttra(1)) ) THEN ! start a new day
  45. !
  46. IF( kt == nit000 ) THEN
  47. ALLOCATE( amp_pot(jpi,jpj,nb_harmo), &
  48. & phi_pot(jpi,jpj,nb_harmo), pot_astro(jpi,jpj) )
  49. ENDIF
  50. !
  51. amp_pot(:,:,:) = 0._wp
  52. phi_pot(:,:,:) = 0._wp
  53. pot_astro(:,:) = 0._wp
  54. !
  55. CALL tide_harmo( omega_tide, v0tide, utide, ftide, ntide, nb_harmo )
  56. !
  57. kt_tide = kt
  58. !
  59. IF(lwp) THEN
  60. WRITE(numout,*)
  61. WRITE(numout,*) 'sbc_tide : Update of the components and (re)Init. the potential at kt=', kt
  62. WRITE(numout,*) '~~~~~~~~ '
  63. DO jk = 1, nb_harmo
  64. WRITE(numout,*) Wave(ntide(jk))%cname_tide, utide(jk), ftide(jk), v0tide(jk), omega_tide(jk)
  65. END DO
  66. ENDIF
  67. !
  68. IF( ln_tide_pot ) CALL tide_init_potential
  69. !
  70. ENDIF
  71. !
  72. END SUBROUTINE sbc_tide
  73. SUBROUTINE tide_init_potential
  74. !!----------------------------------------------------------------------
  75. !! *** ROUTINE tide_init_potential ***
  76. !!----------------------------------------------------------------------
  77. INTEGER :: ji, jj, jk ! dummy loop indices
  78. REAL(wp) :: zcons, ztmp1, ztmp2, zlat, zlon, ztmp, zamp, zcs ! local scalar
  79. !!----------------------------------------------------------------------
  80. DO jk = 1, nb_harmo
  81. zcons = 0.7_wp * Wave(ntide(jk))%equitide * ftide(jk)
  82. DO ji = 1, jpi
  83. DO jj = 1, jpj
  84. ztmp1 = amp_pot(ji,jj,jk) * COS( phi_pot(ji,jj,jk) )
  85. ztmp2 = -amp_pot(ji,jj,jk) * SIN( phi_pot(ji,jj,jk) )
  86. zlat = gphit(ji,jj)*rad !! latitude en radian
  87. zlon = glamt(ji,jj)*rad !! longitude en radian
  88. ztmp = v0tide(jk) + utide(jk) + Wave(ntide(jk))%nutide * zlon
  89. ! le potentiel est composé des effets des astres:
  90. IF ( Wave(ntide(jk))%nutide == 1 ) THEN ; zcs = zcons * SIN( 2._wp*zlat )
  91. ELSEIF( Wave(ntide(jk))%nutide == 2 ) THEN ; zcs = zcons * COS( zlat )**2
  92. ELSE ; zcs = 0._wp
  93. ENDIF
  94. ztmp1 = ztmp1 + zcs * COS( ztmp )
  95. ztmp2 = ztmp2 - zcs * SIN( ztmp )
  96. zamp = SQRT( ztmp1*ztmp1 + ztmp2*ztmp2 )
  97. amp_pot(ji,jj,jk) = zamp
  98. phi_pot(ji,jj,jk) = ATAN2( -ztmp2 / MAX( 1.e-10_wp , zamp ) , &
  99. & ztmp1 / MAX( 1.e-10_wp, zamp ) )
  100. END DO
  101. END DO
  102. END DO
  103. !
  104. END SUBROUTINE tide_init_potential
  105. #else
  106. !!----------------------------------------------------------------------
  107. !! Default case : Empty module
  108. !!----------------------------------------------------------------------
  109. LOGICAL, PUBLIC, PARAMETER :: lk_tide = .FALSE.
  110. CONTAINS
  111. SUBROUTINE sbc_tide( kt ) ! Empty routine
  112. INTEGER , INTENT(in) :: kt ! ocean time-step
  113. WRITE(*,*) 'sbc_tide: You should not have seen this print! error?', kt
  114. END SUBROUTINE sbc_tide
  115. #endif
  116. !!======================================================================
  117. END MODULE sbctide