sbcwave.F90 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. MODULE sbcwave
  2. !!======================================================================
  3. !! *** MODULE sbcwave ***
  4. !! Wave module
  5. !!======================================================================
  6. !! History : 3.3.1 ! 2011-09 (Adani M) Original code: Drag Coefficient
  7. !! : 3.4 ! 2012-10 (Adani M) Stokes Drift
  8. !!----------------------------------------------------------------------
  9. USE iom ! I/O manager library
  10. USE in_out_manager ! I/O manager
  11. USE lib_mpp ! distribued memory computing library
  12. USE fldread ! read input fields
  13. USE oce
  14. USE sbc_oce ! Surface boundary condition: ocean fields
  15. USE domvvl
  16. !!----------------------------------------------------------------------
  17. !! sbc_wave : read drag coefficient from wave model in netcdf files
  18. !!----------------------------------------------------------------------
  19. IMPLICIT NONE
  20. PRIVATE
  21. PUBLIC sbc_wave ! routine called in sbc_blk_core or sbc_blk_mfs
  22. INTEGER , PARAMETER :: jpfld = 3 ! maximum number of files to read for srokes drift
  23. INTEGER , PARAMETER :: jp_usd = 1 ! index of stokes drift (i-component) (m/s) at T-point
  24. INTEGER , PARAMETER :: jp_vsd = 2 ! index of stokes drift (j-component) (m/s) at T-point
  25. INTEGER , PARAMETER :: jp_wn = 3 ! index of wave number (1/m) at T-point
  26. TYPE(FLD), ALLOCATABLE, DIMENSION(:) :: sf_cd ! structure of input fields (file informations, fields read) Drag Coefficient
  27. TYPE(FLD), ALLOCATABLE, DIMENSION(:) :: sf_sd ! structure of input fields (file informations, fields read) Stokes Drift
  28. REAL(wp),PUBLIC,ALLOCATABLE,DIMENSION (:,:) :: cdn_wave
  29. REAL(wp),ALLOCATABLE,DIMENSION (:,:) :: usd2d,vsd2d,uwavenum,vwavenum
  30. REAL(wp),PUBLIC,ALLOCATABLE,DIMENSION (:,:,:) :: usd3d,vsd3d,wsd3d
  31. !! * Substitutions
  32. # include "domzgr_substitute.h90"
  33. !!----------------------------------------------------------------------
  34. !! NEMO/OPA 4.0 , NEMO Consortium (2011)
  35. !! $Id: sbcwave.F90 2355 2015-05-20 07:11:50Z ufla $
  36. !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
  37. !!----------------------------------------------------------------------
  38. CONTAINS
  39. SUBROUTINE sbc_wave( kt )
  40. !!---------------------------------------------------------------------
  41. !! *** ROUTINE sbc_apr ***
  42. !!
  43. !! ** Purpose : read drag coefficient from wave model in netcdf files.
  44. !!
  45. !! ** Method : - Read namelist namsbc_wave
  46. !! - Read Cd_n10 fields in netcdf files
  47. !! - Read stokes drift 2d in netcdf files
  48. !! - Read wave number in netcdf files
  49. !! - Compute 3d stokes drift using monochromatic
  50. !! ** action :
  51. !!
  52. !!---------------------------------------------------------------------
  53. USE oce, ONLY : un,vn,hdivn,rotn
  54. USE divcur
  55. USE wrk_nemo
  56. #if defined key_bdy
  57. USE bdy_oce, ONLY : bdytmask
  58. #endif
  59. INTEGER, INTENT( in ) :: kt ! ocean time step
  60. INTEGER :: ierror ! return error code
  61. INTEGER :: ifpr, jj,ji,jk
  62. INTEGER :: ios ! Local integer output status for namelist read
  63. REAL(wp),DIMENSION(:,:,:),POINTER :: udummy,vdummy,hdivdummy,rotdummy
  64. REAL :: z2dt,z1_2dt
  65. TYPE(FLD_N), DIMENSION(jpfld) :: slf_i ! array of namelist informations on the fields to read
  66. CHARACTER(len=100) :: cn_dir ! Root directory for location of drag coefficient files
  67. TYPE(FLD_N) :: sn_cdg, sn_usd, sn_vsd, sn_wn ! informations about the fields to be read
  68. !!---------------------------------------------------------------------
  69. NAMELIST/namsbc_wave/ sn_cdg, cn_dir, sn_usd, sn_vsd, sn_wn
  70. !!---------------------------------------------------------------------
  71. !!----------------------------------------------------------------------
  72. !
  73. !
  74. ! ! -------------------- !
  75. IF( kt == nit000 ) THEN ! First call kt=nit000 !
  76. ! ! -------------------- !
  77. REWIND( numnam_ref ) ! Namelist namsbc_wave in reference namelist : File for drag coeff. from wave model
  78. READ ( numnam_ref, namsbc_wave, IOSTAT = ios, ERR = 901)
  79. 901 IF( ios /= 0 ) CALL ctl_nam ( ios , 'namsbc_wave in reference namelist', lwp )
  80. REWIND( numnam_cfg ) ! Namelist namsbc_wave in configuration namelist : File for drag coeff. from wave model
  81. READ ( numnam_cfg, namsbc_wave, IOSTAT = ios, ERR = 902 )
  82. 902 IF( ios /= 0 ) CALL ctl_nam ( ios , 'namsbc_wave in configuration namelist', lwp )
  83. IF(lwm) WRITE ( numond, namsbc_wave )
  84. !
  85. IF ( ln_cdgw ) THEN
  86. ALLOCATE( sf_cd(1), STAT=ierror ) !* allocate and fill sf_wave with sn_cdg
  87. IF( ierror > 0 ) CALL ctl_stop( 'STOP', 'sbc_wave: unable to allocate sf_wave structure' )
  88. !
  89. ALLOCATE( sf_cd(1)%fnow(jpi,jpj,1) )
  90. IF( sn_cdg%ln_tint ) ALLOCATE( sf_cd(1)%fdta(jpi,jpj,1,2) )
  91. CALL fld_fill( sf_cd, (/ sn_cdg /), cn_dir, 'sbc_wave', 'Wave module ', 'namsbc_wave' )
  92. ALLOCATE( cdn_wave(jpi,jpj) )
  93. cdn_wave(:,:) = 0.0
  94. ENDIF
  95. IF ( ln_sdw ) THEN
  96. slf_i(jp_usd) = sn_usd ; slf_i(jp_vsd) = sn_vsd; slf_i(jp_wn) = sn_wn
  97. ALLOCATE( sf_sd(3), STAT=ierror ) !* allocate and fill sf_wave with sn_cdg
  98. IF( ierror > 0 ) CALL ctl_stop( 'STOP', 'sbc_wave: unable to allocate sf_wave structure' )
  99. !
  100. DO ifpr= 1, jpfld
  101. ALLOCATE( sf_sd(ifpr)%fnow(jpi,jpj,1) )
  102. IF( slf_i(ifpr)%ln_tint ) ALLOCATE( sf_sd(ifpr)%fdta(jpi,jpj,1,2) )
  103. END DO
  104. CALL fld_fill( sf_sd, slf_i, cn_dir, 'sbc_wave', 'Wave module ', 'namsbc_wave' )
  105. ALLOCATE( usd2d(jpi,jpj),vsd2d(jpi,jpj),uwavenum(jpi,jpj),vwavenum(jpi,jpj) )
  106. ALLOCATE( usd3d(jpi,jpj,jpk),vsd3d(jpi,jpj,jpk),wsd3d(jpi,jpj,jpk) )
  107. usd2d(:,:) = 0.0 ; vsd2d(:,:) = 0.0 ; uwavenum(:,:) = 0.0 ; vwavenum(:,:) = 0.0
  108. usd3d(:,:,:) = 0.0 ;vsd3d(:,:,:) = 0.0 ; wsd3d(:,:,:) = 0.0
  109. ENDIF
  110. ENDIF
  111. !
  112. !
  113. IF ( ln_cdgw ) THEN
  114. CALL fld_read( kt, nn_fsbc, sf_cd ) !* read drag coefficient from external forcing
  115. cdn_wave(:,:) = sf_cd(1)%fnow(:,:,1)
  116. ENDIF
  117. IF ( ln_sdw ) THEN
  118. CALL fld_read( kt, nn_fsbc, sf_sd ) !* read drag coefficient from external forcing
  119. ! Interpolate wavenumber, stokes drift into the grid_V and grid_V
  120. !-------------------------------------------------
  121. DO jj = 1, jpjm1
  122. DO ji = 1, jpim1
  123. uwavenum(ji,jj)=0.5 * ( 2. - umask(ji,jj,1) ) * ( sf_sd(3)%fnow(ji,jj,1) * tmask(ji,jj,1) &
  124. & + sf_sd(3)%fnow(ji+1,jj,1) * tmask(ji+1,jj,1) )
  125. vwavenum(ji,jj)=0.5 * ( 2. - vmask(ji,jj,1) ) * ( sf_sd(3)%fnow(ji,jj,1) * tmask(ji,jj,1) &
  126. & + sf_sd(3)%fnow(ji,jj+1,1) * tmask(ji,jj+1,1) )
  127. usd2d(ji,jj) = 0.5 * ( 2. - umask(ji,jj,1) ) * ( sf_sd(1)%fnow(ji,jj,1) * tmask(ji,jj,1) &
  128. & + sf_sd(1)%fnow(ji+1,jj,1) * tmask(ji+1,jj,1) )
  129. vsd2d(ji,jj) = 0.5 * ( 2. - vmask(ji,jj,1) ) * ( sf_sd(2)%fnow(ji,jj,1) * tmask(ji,jj,1) &
  130. & + sf_sd(2)%fnow(ji,jj+1,1) * tmask(ji,jj+1,1) )
  131. END DO
  132. END DO
  133. !Computation of the 3d Stokes Drift
  134. DO jk = 1, jpk
  135. DO jj = 1, jpj-1
  136. DO ji = 1, jpi-1
  137. usd3d(ji,jj,jk) = usd2d(ji,jj)*exp(2.0*uwavenum(ji,jj)*(-MIN( gdept_0(ji,jj,jk) , gdept_0(ji+1,jj ,jk))))
  138. vsd3d(ji,jj,jk) = vsd2d(ji,jj)*exp(2.0*vwavenum(ji,jj)*(-MIN( gdept_0(ji,jj,jk) , gdept_0(ji ,jj+1,jk))))
  139. END DO
  140. END DO
  141. usd3d(jpi,:,jk) = usd2d(jpi,:)*exp( 2.0*uwavenum(jpi,:)*(-gdept_0(jpi,:,jk)) )
  142. vsd3d(:,jpj,jk) = vsd2d(:,jpj)*exp( 2.0*vwavenum(:,jpj)*(-gdept_0(:,jpj,jk)) )
  143. END DO
  144. CALL wrk_alloc( jpi,jpj,jpk,udummy,vdummy,hdivdummy,rotdummy)
  145. udummy(:,:,:)=un(:,:,:)
  146. vdummy(:,:,:)=vn(:,:,:)
  147. hdivdummy(:,:,:)=hdivn(:,:,:)
  148. rotdummy(:,:,:)=rotn(:,:,:)
  149. un(:,:,:)=usd3d(:,:,:)
  150. vn(:,:,:)=vsd3d(:,:,:)
  151. CALL div_cur(kt)
  152. ! !------------------------------!
  153. ! ! Now Vertical Velocity !
  154. ! !------------------------------!
  155. z2dt = 2._wp * rdt ! set time step size (Euler/Leapfrog)
  156. z1_2dt = 1.e0 / z2dt
  157. DO jk = jpkm1, 1, -1 ! integrate from the bottom the hor. divergence
  158. ! - ML - need 3 lines here because replacement of fse3t by its expression yields too long lines otherwise
  159. wsd3d(:,:,jk) = wsd3d(:,:,jk+1) - fse3t_n(:,:,jk) * hdivn(:,:,jk) &
  160. & - ( fse3t_a(:,:,jk) - fse3t_b(:,:,jk) ) &
  161. & * tmask(:,:,jk) * z1_2dt
  162. #if defined key_bdy
  163. wsd3d(:,:,jk) = wsd3d(:,:,jk) * bdytmask(:,:)
  164. #endif
  165. END DO
  166. hdivn(:,:,:)=hdivdummy(:,:,:)
  167. rotn(:,:,:)=rotdummy(:,:,:)
  168. vn(:,:,:)=vdummy(:,:,:)
  169. un(:,:,:)=udummy(:,:,:)
  170. CALL wrk_dealloc( jpi,jpj,jpk,udummy,vdummy,hdivdummy,rotdummy)
  171. ENDIF
  172. END SUBROUTINE sbc_wave
  173. !!======================================================================
  174. END MODULE sbcwave