sbcssr.F90 13 KB

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