sbcssr.F90 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  1. MODULE sbcssr
  2. !!======================================================================
  3. !! *** MODULE sbcssr ***
  4. !! Surface module : heat and fresh water fluxes a restoring term toward targeted SST/SSS
  5. !!======================================================================
  6. !! History : 3.0 ! 2006-06 (G. Madec) Original code
  7. !! 3.2 ! 2009-04 (B. Lemaire) Introduce iom_put
  8. !! 3.6 ! 2018-06 Update from shaconemo
  9. !! 3.6 ! 2018-07 (Y. Ruprich-Robert) restoring ponderated by sea-ice fraction
  10. !! 3.6 ! 2018-07 (Y. Ruprich-Robert) Subregion restoring mask
  11. !! 3.6 ! 2018-10 (Y. Ruprich-Robert) Adaptation from shaconemo changes Revision #6009
  12. !!----------------------------------------------------------------------
  13. !!----------------------------------------------------------------------
  14. !! sbc_ssr : add to sbc a restoring term toward SST/SSS climatology
  15. !! sbc_ssr_init : initialisation of surface restoring
  16. !!----------------------------------------------------------------------
  17. USE oce ! ocean dynamics and tracers
  18. USE dom_oce ! ocean space and time domain
  19. USE sbc_oce ! surface boundary condition
  20. USE phycst ! physical constants
  21. USE sbcrnf ! surface boundary condition : runoffs
  22. !
  23. USE fldread ! read input fields
  24. USE iom ! I/O manager
  25. USE in_out_manager ! I/O manager
  26. USE lib_mpp ! distribued memory computing library
  27. USE lbclnk ! ocean lateral boundary conditions (or mpp link)
  28. USE timing ! Timing
  29. USE lib_fortran ! Fortran utilities (allows no signed zero when 'key_nosignedzero' defined)
  30. IMPLICIT NONE
  31. PRIVATE
  32. PUBLIC sbc_ssr ! routine called in sbcmod
  33. PUBLIC sbc_ssr_init ! routine called in sbcmod
  34. PUBLIC sbc_ssr_alloc ! routine called in sbcmod
  35. REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) :: erp !: evaporation damping [kg/m2/s]
  36. REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) :: qrp !: heat flux damping [w/m2]
  37. REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) :: sf_msk_f !: restoring mask
  38. REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) :: sf_msk_f_init !: initial restoring mask
  39. ! !!* Namelist namsbc_ssr *
  40. INTEGER, PUBLIC :: nn_sstr ! SST/SSS restoring indicator
  41. INTEGER, PUBLIC :: nn_sssr ! SST/SSS restoring indicator
  42. REAL(wp) :: rn_dqdt ! restoring factor on SST and SSS
  43. REAL(wp) :: rn_deds ! restoring factor on SST and SSS
  44. LOGICAL :: ln_sssr_bnd ! flag to bound erp term
  45. REAL(wp) :: rn_sssr_bnd ! ABS(Max./Min.) value of erp term [mm/day]
  46. LOGICAL :: ln_sssd_bnd ! flag to bound S-S* term
  47. REAL(wp) :: rn_sssd_bnd ! ABS(Max./Min.) value of S-S* term [psu]
  48. INTEGER :: nn_icedmp ! Control of surface restoring under ice
  49. INTEGER :: nn_msk ! SST/SSS restoring mask indicator
  50. REAL(wp) , ALLOCATABLE, DIMENSION(:) :: buffer ! Temporary buffer for exchange
  51. TYPE(FLD), ALLOCATABLE, DIMENSION(:) :: sf_sst ! structure of input SST (file informations, fields read)
  52. TYPE(FLD), ALLOCATABLE, DIMENSION(:) :: sf_sss ! structure of input SSS (file informations, fields read)
  53. TYPE(FLD), ALLOCATABLE, DIMENSION(:) :: sf_msk ! structure of input MASK (file informations, fields read)
  54. !! * Substitutions
  55. # include "domzgr_substitute.h90"
  56. !!----------------------------------------------------------------------
  57. !! NEMO/OPA 4.0 , NEMO Consortium (2011)
  58. !! $Id: sbcssr.F90 4990 2014-12-15 16:42:49Z timgraham $
  59. !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
  60. !!----------------------------------------------------------------------
  61. CONTAINS
  62. SUBROUTINE sbc_ssr( kt )
  63. !!---------------------------------------------------------------------
  64. !! *** ROUTINE sbc_ssr ***
  65. !!
  66. !! ** Purpose : Add to heat and/or freshwater fluxes a damping term
  67. !! toward targeted SST and/or SSS.
  68. !!
  69. !! ** Method : - Read namelist namsbc_ssr
  70. !! - Read targeted SST and/or SSS
  71. !! - at each nscb time step
  72. !! add a retroaction term on qns (nn_sstr = 1)
  73. !! add a damping term on sfx (nn_sssr = 1)
  74. !! add a damping term on emp (nn_sssr = 2)
  75. !!---------------------------------------------------------------------
  76. INTEGER, INTENT(in ) :: kt ! ocean time step
  77. !!
  78. INTEGER :: ji, jj ! dummy loop indices
  79. REAL(wp) :: zerp ! local scalar for evaporation damping
  80. REAL(wp) :: zsdif ! local scalar for salinity difference from climatology
  81. REAL(wp) :: zqrp ! local scalar for heat flux damping
  82. REAL(wp) :: zsrp ! local scalar for unit conversion of rn_deds factor
  83. REAL(wp) :: zerp_bnd ! local scalar for unit conversion of rn_epr_max factor
  84. INTEGER :: ierror ! return error code
  85. !!
  86. CHARACTER(len=100) :: cn_dir ! Root directory for location of ssr files
  87. TYPE(FLD_N) :: sn_sst, sn_sss, sn_msk ! informations about the fields to be read
  88. !!----------------------------------------------------------------------
  89. !
  90. IF( nn_timing == 1 ) CALL timing_start('sbc_ssr')
  91. !
  92. IF( nn_sstr + nn_sssr /= 0 ) THEN
  93. !
  94. sf_msk_f = sf_msk_f_init ! initialize mask at time step kt
  95. sf_msk_f = sf_msk_f(:,:) * ( 1.e0 - fr_i(:,:) ) ! decrease of restoring coef with sea-ice fraction
  96. IF( nn_icedmp /= 0 ) THEN ! ponderation of restoring coef by sea-ice fraction (increases with sea-ice)
  97. sf_msk_f = sf_msk_f(:,:) + sf_msk_f_init(:,:) * nn_icedmp*fr_i(:,:)
  98. ENDIF
  99. !
  100. IF( nn_sstr == 1) CALL fld_read( kt, nn_fsbc, sf_sst ) ! Read SST data and provides it at kt
  101. IF( nn_sssr >= 1) CALL fld_read( kt, nn_fsbc, sf_sss ) ! Read SSS data and provides it at kt
  102. !
  103. ! ! ========================= !
  104. IF( MOD( kt-1, nn_fsbc ) == 0 ) THEN ! Add restoring term !
  105. ! ! ========================= !
  106. !
  107. IF( nn_sstr == 1 ) THEN !* Temperature restoring term
  108. DO jj = 1, jpj
  109. DO ji = 1, jpi
  110. zqrp = rn_dqdt * ( sst_m(ji,jj) - sf_sst(1)%fnow(ji,jj,1) ) &
  111. & * sf_msk_f(ji,jj)
  112. qns(ji,jj) = qns(ji,jj) + zqrp
  113. qrp(ji,jj) = zqrp
  114. END DO
  115. END DO
  116. ENDIF
  117. !
  118. IF( nn_sssr == 1 ) THEN !* Salinity damping term (salt flux only (sfx))
  119. zsrp = rn_deds / rday ! from [mm/day] to [kg/m2/s]
  120. !CDIR COLLAPSE
  121. DO jj = 1, jpj
  122. DO ji = 1, jpi
  123. zerp = zsrp * ( 1. - 2.*rnfmsk(ji,jj) ) & ! No damping in vicinity of river mouths
  124. & * sf_msk_f(ji,jj) &
  125. & * ( sss_m(ji,jj) - sf_sss(1)%fnow(ji,jj,1) )
  126. sfx(ji,jj) = sfx(ji,jj) + zerp ! salt flux
  127. erp(ji,jj) = zerp / MAX( sss_m(ji,jj), 1.e-20 ) ! converted into an equivalent volume flux (diagnostic only)
  128. END DO
  129. END DO
  130. !
  131. ELSEIF( nn_sssr == 2 ) THEN !* Salinity damping term (volume flux (emp) and associated heat flux (qns)
  132. zsrp = rn_deds / rday ! from [mm/day] to [kg/m2/s]
  133. zerp_bnd = rn_sssr_bnd / rday ! - -
  134. !CDIR COLLAPSE
  135. DO jj = 1, jpj
  136. DO ji = 1, jpi
  137. zsdif = sss_m(ji,jj) - sf_sss(1)%fnow(ji,jj,1) ! Difference between actual and relaxation SSS
  138. IF( ln_sssd_bnd ) zsdif = SIGN( MIN( ABS( zsdif ) , rn_sssd_bnd ) , zsdif ) ! Optional bound on salinity difference
  139. zerp = zsrp * ( 1. - 2.*rnfmsk(ji,jj) ) & ! No damping in vicinity of river mouths
  140. & * sf_msk_f(ji,jj) &
  141. & * zsdif / MAX( sss_m(ji,jj), 1.e-20 )
  142. IF( ln_sssr_bnd ) zerp = SIGN( 1., zerp ) * MIN( zerp_bnd, ABS(zerp) )
  143. emp(ji,jj) = emp (ji,jj) + zerp
  144. qns(ji,jj) = qns(ji,jj) - zerp * rcp * sst_m(ji,jj)
  145. erp(ji,jj) = zerp
  146. END DO
  147. END DO
  148. ENDIF
  149. !
  150. ENDIF
  151. !
  152. ENDIF
  153. !
  154. IF( nn_timing == 1 ) CALL timing_stop('sbc_ssr')
  155. !
  156. END SUBROUTINE sbc_ssr
  157. SUBROUTINE sbc_ssr_init
  158. !!---------------------------------------------------------------------
  159. !! *** ROUTINE sbc_ssr_init ***
  160. !!
  161. !! ** Purpose : initialisation of surface damping term
  162. !!
  163. !! ** Method : - Read namelist namsbc_ssr
  164. !! - Read observed SST and/or SSS if required
  165. !!---------------------------------------------------------------------
  166. INTEGER :: ji, jj ! dummy loop indices
  167. INTEGER :: ierror ! return error code
  168. !!
  169. CHARACTER(len=100) :: cn_dir ! Root directory for location of ssr files
  170. TYPE(FLD_N) :: sn_sst, sn_sss, sn_msk ! informations about the fields to be read
  171. NAMELIST/namsbc_ssr/ cn_dir, nn_sstr, nn_sssr, nn_icedmp, nn_msk, rn_dqdt, &
  172. & rn_deds, sn_sst, sn_sss, sn_msk, ln_sssr_bnd, &
  173. & rn_sssr_bnd, ln_sssd_bnd, rn_sssd_bnd
  174. INTEGER :: ios
  175. !!----------------------------------------------------------------------
  176. !
  177. REWIND( numnam_ref ) ! Namelist namsbc_ssr in reference namelist :
  178. READ ( numnam_ref, namsbc_ssr, IOSTAT = ios, ERR = 901)
  179. 901 IF( ios /= 0 ) CALL ctl_nam ( ios , 'namsbc_ssr in reference namelist', lwp )
  180. REWIND( numnam_cfg ) ! Namelist namsbc_ssr in configuration namelist :
  181. READ ( numnam_cfg, namsbc_ssr, IOSTAT = ios, ERR = 902 )
  182. 902 IF( ios /= 0 ) CALL ctl_nam ( ios , 'namsbc_ssr in configuration namelist', lwp )
  183. IF(lwm) WRITE ( numond, namsbc_ssr )
  184. IF(lwp) THEN !* control print
  185. WRITE(numout,*)
  186. WRITE(numout,*) 'sbc_ssr : SST and/or SSS damping term '
  187. WRITE(numout,*) '~~~~~~~ '
  188. WRITE(numout,*) ' Namelist namsbc_ssr :'
  189. WRITE(numout,*) ' SST restoring term (Yes=1) nn_sstr = ', nn_sstr
  190. WRITE(numout,*) ' SSS damping term (Yes=1, salt flux) nn_sssr = ', nn_sssr
  191. WRITE(numout,*) ' (Yes=2, volume flux) '
  192. WRITE(numout,*) ' dQ/dT (restoring magnitude on SST) rn_dqdt = ', rn_dqdt, ' W/m2/K'
  193. WRITE(numout,*) ' dE/dS (restoring magnitude on SST) rn_deds = ', rn_deds, ' mm/day'
  194. WRITE(numout,*) ' flag to bound erp term ln_sssr_bnd = ', ln_sssr_bnd
  195. WRITE(numout,*) ' ABS(Max./Min.) erp threshold rn_sssr_bnd = ', rn_sssr_bnd, ' mm/day'
  196. WRITE(numout,*) ' flag to bound S-S* ln_sssd_bnd = ', ln_sssd_bnd
  197. WRITE(numout,*) ' ABS(Max./Min.) S-S* threshold rn_sssd_bnd = ', rn_sssd_bnd, ' psu'
  198. WRITE(numout,*) ' Cntrl of surface restoration under ice nn_icedmp = ', nn_icedmp
  199. WRITE(numout,*) ' ( 0 = no restoration under ice)'
  200. WRITE(numout,*) ' ( 1 = restoration everywhere )'
  201. WRITE(numout,*) ' (>1 = enhanced restoration under ice )'
  202. WRITE(numout,*) ' subregion restoring mask (Yes=1) nn_msk = ', nn_msk
  203. ENDIF
  204. !
  205. IF( nn_sstr + nn_sssr /= 0 ) THEN
  206. !
  207. sf_msk_f_init = tmask(:,:,1)
  208. IF( nn_msk == 1 ) THEN !* set sf_msk structure & allocate arrays
  209. !
  210. ALLOCATE( sf_msk(1), STAT=ierror )
  211. IF( ierror > 0 ) CALL ctl_stop( 'STOP', 'sbc_ssr: unable to allocate sf_msk structure' )
  212. ALLOCATE( sf_msk(1)%fnow(jpi,jpj,1), STAT=ierror )
  213. IF( ierror > 0 ) CALL ctl_stop( 'STOP', 'sbc_ssr: unable to allocate sf_msk now array' )
  214. !
  215. ! fill sf_msk with sn_msk and control print
  216. CALL fld_fill( sf_msk, (/ sn_msk /), cn_dir, 'sbc_ssr', 'mask for sea surface restoring', 'namsbc_ssr' )
  217. IF( ierror > 0 ) CALL ctl_stop( 'STOP', 'sbc_ssr: unable to allocate sf_msk data array' )
  218. !
  219. CALL fld_read( 1, 1, sf_msk ) ! Read mask
  220. sf_msk_f_init = sf_msk(1)%fnow(:,:,1)
  221. !
  222. ENDIF
  223. !
  224. ENDIF
  225. !
  226. IF( nn_sstr == 1 ) THEN !* set sf_sst structure & allocate arrays
  227. !
  228. ALLOCATE( sf_sst(1), STAT=ierror )
  229. IF( ierror > 0 ) CALL ctl_stop( 'STOP', 'sbc_ssr: unable to allocate sf_sst structure' )
  230. ALLOCATE( sf_sst(1)%fnow(jpi,jpj,1), STAT=ierror )
  231. IF( ierror > 0 ) CALL ctl_stop( 'STOP', 'sbc_ssr: unable to allocate sf_sst now array' )
  232. !
  233. ! fill sf_sst with sn_sst and control print
  234. CALL fld_fill( sf_sst, (/ sn_sst /), cn_dir, 'sbc_ssr', 'SST restoring term toward SST data', 'namsbc_ssr' )
  235. IF( sf_sst(1)%ln_tint ) ALLOCATE( sf_sst(1)%fdta(jpi,jpj,1,2), STAT=ierror )
  236. IF( ierror > 0 ) CALL ctl_stop( 'STOP', 'sbc_ssr: unable to allocate sf_sst data array' )
  237. !
  238. ENDIF
  239. !
  240. IF( nn_sssr >= 1 ) THEN !* set sf_sss structure & allocate arrays
  241. !
  242. ALLOCATE( sf_sss(1), STAT=ierror )
  243. IF( ierror > 0 ) CALL ctl_stop( 'STOP', 'sbc_ssr: unable to allocate sf_sss structure' )
  244. ALLOCATE( sf_sss(1)%fnow(jpi,jpj,1), STAT=ierror )
  245. IF( ierror > 0 ) CALL ctl_stop( 'STOP', 'sbc_ssr: unable to allocate sf_sss now array' )
  246. !
  247. ! fill sf_sss with sn_sss and control print
  248. CALL fld_fill( sf_sss, (/ sn_sss /), cn_dir, 'sbc_ssr', 'SSS restoring term toward SSS data', 'namsbc_ssr' )
  249. IF( sf_sss(1)%ln_tint ) ALLOCATE( sf_sss(1)%fdta(jpi,jpj,1,2), STAT=ierror )
  250. IF( ierror > 0 ) CALL ctl_stop( 'STOP', 'sbc_ssr: unable to allocate sf_sss data array' )
  251. !
  252. ENDIF
  253. !
  254. ! !* Initialize qrp and erp if no restoring
  255. IF( nn_sstr /= 1 ) qrp(:,:) = 0._wp
  256. IF( nn_sssr /= 1 .OR. nn_sssr /= 2 ) erp(:,:) = 0._wp
  257. !
  258. END SUBROUTINE sbc_ssr_init
  259. INTEGER FUNCTION sbc_ssr_alloc()
  260. !!----------------------------------------------------------------------
  261. !! *** FUNCTION sbc_ssr_alloc ***
  262. !!----------------------------------------------------------------------
  263. sbc_ssr_alloc = 0 ! set to zero if no array to be allocated
  264. IF( .NOT. ALLOCATED( erp ) ) THEN
  265. ALLOCATE( qrp(jpi,jpj), erp(jpi,jpj), sf_msk_f_init(jpi,jpj), sf_msk_f(jpi,jpj), STAT= sbc_ssr_alloc )
  266. !
  267. IF( lk_mpp ) CALL mpp_sum ( sbc_ssr_alloc )
  268. IF( sbc_ssr_alloc /= 0 ) CALL ctl_warn('sbc_ssr_alloc: failed to allocate arrays.')
  269. !
  270. ENDIF
  271. END FUNCTION
  272. !!======================================================================
  273. END MODULE sbcssr