sbcssr.F90 12 KB

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