trcsbc.F90 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. MODULE trcsbc
  2. !!==============================================================================
  3. !! *** MODULE trcsbc ***
  4. !! Ocean passive tracers: surface boundary condition
  5. !!======================================================================
  6. !! History : 8.2 ! 1998-10 (G. Madec, G. Roullet, M. Imbard) Original code
  7. !! 8.2 ! 2001-02 (D. Ludicone) sea ice and free surface
  8. !! 8.5 ! 2002-06 (G. Madec) F90: Free form and module
  9. !! 9.0 ! 2004-03 (C. Ethe) adapted for passive tracers
  10. !! ! 2006-08 (C. Deltel) Diagnose ML trends for passive tracers
  11. !!==============================================================================
  12. #if defined key_top
  13. !!----------------------------------------------------------------------
  14. !! 'key_top' TOP models
  15. !!----------------------------------------------------------------------
  16. !! trc_sbc : update the tracer trend at ocean surface
  17. !!----------------------------------------------------------------------
  18. USE oce_trc ! ocean dynamics and active tracers variables
  19. USE trc ! ocean passive tracers variables
  20. USE prtctl_trc ! Print control for debbuging
  21. USE iom
  22. USE trd_oce
  23. USE trdtra
  24. IMPLICIT NONE
  25. PRIVATE
  26. PUBLIC trc_sbc ! routine called by step.F90
  27. REAL(wp) :: r2dt ! time-step at surface
  28. !! * Substitutions
  29. # include "top_substitute.h90"
  30. !!----------------------------------------------------------------------
  31. !! NEMO/TOP 3.3 , NEMO Consortium (2010)
  32. !! $Id: trcsbc.F90 4990 2014-12-15 16:42:49Z timgraham $
  33. !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
  34. !!----------------------------------------------------------------------
  35. CONTAINS
  36. SUBROUTINE trc_sbc ( kt )
  37. !!----------------------------------------------------------------------
  38. !! *** ROUTINE trc_sbc ***
  39. !!
  40. !! ** Purpose : Compute the tracer surface boundary condition trend of
  41. !! (concentration/dilution effect) and add it to the general
  42. !! trend of tracer equations.
  43. !!
  44. !! ** Method :
  45. !! * concentration/dilution effect:
  46. !! The surface freshwater flux modify the ocean volume
  47. !! and thus the concentration of a tracer as :
  48. !! tra = tra + emp * trn / e3t for k=1
  49. !! where emp, the surface freshwater budget (evaporation minus
  50. !! precipitation ) given in kg/m2/s is divided
  51. !! by 1035 kg/m3 (density of ocean water) to obtain m/s.
  52. !!
  53. !! ** Action : - Update the 1st level of tra with the trend associated
  54. !! with the tracer surface boundary condition
  55. !!
  56. !!----------------------------------------------------------------------
  57. !
  58. INTEGER, INTENT( in ) :: kt ! ocean time-step index
  59. !
  60. INTEGER :: ji, jj, jn ! dummy loop indices
  61. REAL(wp) :: zse3t, zrtrn, zratio, zfact ! temporary scalars
  62. REAL(wp) :: zswitch, zftra, zcd, zdtra, ztfx, ztra ! temporary scalars
  63. CHARACTER (len=22) :: charout
  64. REAL(wp), POINTER, DIMENSION(:,: ) :: zsfx
  65. REAL(wp), POINTER, DIMENSION(:,:,:) :: ztrtrd
  66. !!---------------------------------------------------------------------
  67. !
  68. IF( nn_timing == 1 ) CALL timing_start('trc_sbc')
  69. !
  70. ! Allocate temporary workspace
  71. CALL wrk_alloc( jpi, jpj, zsfx )
  72. IF( l_trdtrc ) CALL wrk_alloc( jpi, jpj, jpk, ztrtrd )
  73. !
  74. zrtrn = 1.e-15_wp
  75. SELECT CASE( nn_ice_embd ) ! levitating or embedded sea-ice option
  76. CASE( 0 ) ; zswitch = 1 ! (0) standard levitating sea-ice : salt exchange only
  77. CASE( 1, 2 ) ; zswitch = 0 ! (1) levitating sea-ice: salt and volume exchange but no pressure effect
  78. ! (2) embedded sea-ice : salt and volume fluxes and pressure
  79. END SELECT
  80. IF( ln_top_euler) THEN
  81. r2dt = rdttrc(1) ! = rdttrc (use Euler time stepping)
  82. ELSE
  83. IF( neuler == 0 .AND. kt == nittrc000 ) THEN ! at nittrc000
  84. r2dt = rdttrc(1) ! = rdttrc (restarting with Euler time stepping)
  85. ELSEIF( kt <= nittrc000 + nn_dttrc ) THEN ! at nittrc000 or nittrc000+1
  86. r2dt = 2. * rdttrc(1) ! = 2 rdttrc (leapfrog)
  87. ENDIF
  88. ENDIF
  89. IF( kt == nittrc000 ) THEN
  90. IF(lwp) WRITE(numout,*)
  91. IF(lwp) WRITE(numout,*) 'trc_sbc : Passive tracers surface boundary condition'
  92. IF(lwp) WRITE(numout,*) '~~~~~~~ '
  93. IF( ln_rsttr .AND. .NOT.ln_top_euler .AND. & ! Restart: read in restart file
  94. iom_varid( numrtr, 'sbc_'//TRIM(ctrcnm(1))//'_b', ldstop = .FALSE. ) > 0 ) THEN
  95. IF(lwp) WRITE(numout,*) ' nittrc000-nn_dttrc surface tracer content forcing fields red in the restart file'
  96. zfact = 0.5_wp
  97. DO jn = 1, jptra
  98. CALL iom_get( numrtr, jpdom_autoglo, 'sbc_'//TRIM(ctrcnm(jn))//'_b', sbc_trc_b(:,:,jn) ) ! before tracer content sbc
  99. END DO
  100. ELSE ! No restart or restart not found: Euler forward time stepping
  101. zfact = 1._wp
  102. sbc_trc_b(:,:,:) = 0._wp
  103. ENDIF
  104. ELSE ! Swap of forcing fields
  105. IF( ln_top_euler ) THEN
  106. zfact = 1._wp
  107. sbc_trc_b(:,:,:) = 0._wp
  108. ELSE
  109. zfact = 0.5_wp
  110. sbc_trc_b(:,:,:) = sbc_trc(:,:,:)
  111. ENDIF
  112. !
  113. ENDIF
  114. ! Coupling online : river runoff is added to the horizontal divergence (hdivn) in the subroutine sbc_rnf_div
  115. ! one only consider the concentration/dilution effect due to evaporation minus precipitation + freezing/melting of sea-ice
  116. ! Coupling offline : runoff are in emp which contains E-P-R
  117. !
  118. IF( lk_vvl ) THEN ! linear free surface vvl
  119. zsfx(:,:) = 0._wp
  120. ELSE ! no vvl
  121. zsfx(:,:) = emp(:,:)
  122. ENDIF
  123. ! 0. initialization
  124. DO jn = 1, jptra
  125. !
  126. IF( l_trdtrc ) ztrtrd(:,:,:) = tra(:,:,:,jn) ! save trends
  127. ! ! add the trend to the general tracer trend
  128. IF ( nn_ice_tr == -1 ) THEN ! No tracers in sea ice (null concentration in sea ice)
  129. DO jj = 2, jpj
  130. DO ji = fs_2, fs_jpim1 ! vector opt.
  131. sbc_trc(ji,jj,jn) = zsfx(ji,jj) * r1_rau0 * trn(ji,jj,1,jn)
  132. END DO
  133. END DO
  134. ELSE
  135. DO jj = 2, jpj
  136. DO ji = fs_2, fs_jpim1 ! vector opt.
  137. zse3t = 1. / fse3t(ji,jj,1)
  138. ! tracer flux at the ice/ocean interface (tracer/m2/s)
  139. zftra = - trc_i(ji,jj,jn) * fmmflx(ji,jj) ! uptake of tracer in the sea ice
  140. zcd = trc_o(ji,jj,jn) * fmmflx(ji,jj) ! concentration dilution due to freezing-melting,
  141. ! only used in the levitating sea ice case
  142. ! tracer flux only : add concentration dilution term in net tracer flux, no F-M in volume flux
  143. ! tracer and mass fluxes : no concentration dilution term in net tracer flux, F-M term in volume flux
  144. ztfx = zftra + zswitch * zcd ! net tracer flux (+C/D if no ice/ocean mass exchange)
  145. zdtra = r1_rau0 * ( ztfx + zsfx(ji,jj) * trn(ji,jj,1,jn) )
  146. IF ( zdtra < 0. ) THEN
  147. zratio = -zdtra * zse3t * r2dt / ( trn(ji,jj,1,jn) + zrtrn )
  148. zdtra = MIN(1.0, zratio) * zdtra ! avoid negative concentrations to arise
  149. ENDIF
  150. sbc_trc(ji,jj,jn) = zdtra
  151. END DO
  152. END DO
  153. ENDIF
  154. !
  155. CALL lbc_lnk( sbc_trc(:,:,jn), 'T', 1. )
  156. ! Concentration dilution effect on tracers due to evaporation & precipitation
  157. DO jj = 2, jpj
  158. DO ji = fs_2, fs_jpim1 ! vector opt.
  159. zse3t = zfact / fse3t(ji,jj,1)
  160. tra(ji,jj,1,jn) = tra(ji,jj,1,jn) + ( sbc_trc_b(ji,jj,jn) + sbc_trc(ji,jj,jn) ) * zse3t
  161. END DO
  162. END DO
  163. !
  164. IF( l_trdtrc ) THEN
  165. ztrtrd(:,:,:) = tra(:,:,:,jn) - ztrtrd(:,:,:)
  166. CALL trd_tra( kt, 'TRC', jn, jptra_nsr, ztrtrd )
  167. END IF
  168. ! ! ===========
  169. END DO ! tracer loop
  170. ! ! ===========
  171. ! Write in the tracer restar file
  172. ! *******************************
  173. IF( lrst_trc .AND. .NOT.ln_top_euler ) THEN
  174. IF(lwp) WRITE(numout,*)
  175. IF(lwp) WRITE(numout,*) 'sbc : ocean surface tracer content forcing fields written in tracer restart file ', &
  176. & 'at it= ', kt,' date= ', ndastp
  177. IF(lwp) WRITE(numout,*) '~~~~'
  178. DO jn = 1, jptra
  179. CALL iom_rstput( kt, nitrst, numrtw, 'sbc_'//TRIM(ctrcnm(jn))//'_b', sbc_trc(:,:,jn) )
  180. END DO
  181. ENDIF
  182. !
  183. IF( ln_ctl ) THEN
  184. WRITE(charout, FMT="('sbc ')") ; CALL prt_ctl_trc_info(charout)
  185. CALL prt_ctl_trc( tab4d=tra, mask=tmask, clinfo=ctrcnm, clinfo2='trd' )
  186. ENDIF
  187. CALL wrk_dealloc( jpi, jpj, zsfx )
  188. IF( l_trdtrc ) CALL wrk_dealloc( jpi, jpj, jpk, ztrtrd )
  189. !
  190. IF( nn_timing == 1 ) CALL timing_stop('trc_sbc')
  191. !
  192. END SUBROUTINE trc_sbc
  193. #else
  194. !!----------------------------------------------------------------------
  195. !! Dummy module : NO passive tracer
  196. !!----------------------------------------------------------------------
  197. CONTAINS
  198. SUBROUTINE trc_sbc (kt) ! Empty routine
  199. INTEGER, INTENT(in) :: kt
  200. WRITE(*,*) 'trc_sbc: You should not have seen this print! error?', kt
  201. END SUBROUTINE trc_sbc
  202. #endif
  203. !!======================================================================
  204. END MODULE trcsbc