sbcssr.F90 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421
  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 in_out_manager ! I/O manager
  21. USE iom ! I/O manager
  22. USE lib_mpp ! distribued memory computing library
  23. USE lbclnk ! ocean lateral boundary conditions (or mpp link)
  24. USE lib_fortran ! Fortran utilities (allows no signed zero when 'key_nosignedzero' defined)
  25. #if defined key_drakkar
  26. USE shapiro
  27. #endif
  28. IMPLICIT NONE
  29. PRIVATE
  30. PUBLIC sbc_ssr ! routine called in sbcmod
  31. PUBLIC sbc_ssr_init ! routine called in sbcmod
  32. PUBLIC sbc_ssr_alloc ! routine called in sbcmod
  33. REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) :: erp !: evaporation damping [kg/m2/s]
  34. REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) :: qrp !: heat flux damping [w/m2]
  35. REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) :: coefice !: under ice relaxation coefficient
  36. ! !!* Namelist namsbc_ssr *
  37. INTEGER, PUBLIC :: nn_sstr ! SST/SSS restoring indicator
  38. INTEGER, PUBLIC :: nn_sssr ! SST/SSS restoring indicator
  39. REAL(wp) :: rn_dqdt ! restoring factor on SST and SSS
  40. REAL(wp) :: rn_deds ! restoring factor on SST and SSS
  41. LOGICAL :: ln_sssr_bnd ! flag to bound erp term
  42. REAL(wp) :: rn_sssr_bnd ! ABS(Max./Min.) value of erp term [mm/day]
  43. INTEGER :: nn_sssr_ice ! Control of restoring under ice
  44. #if defined key_drakkar
  45. ! local modification of ssr
  46. REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) :: erpcoef !: multiplicating coef for local change to erp
  47. ! filtering of model fields
  48. LOGICAL, PUBLIC :: ln_sssr_flt ! flag to filter sss for restoring
  49. INTEGER, PUBLIC :: nn_shap_iter ! number of iteration for shapiro
  50. ! Limit SSS restoring in coastal areas
  51. LOGICAL :: ln_sssr_msk
  52. TYPE(FLD_N) :: sn_coast
  53. REAL(wp), PUBLIC, ALLOCATABLE, DIMENSION(:,:) :: distcoast ! use to read the distance and then for weight purpose
  54. REAL(wp) :: rn_dist ! (km) decaying lenght scale for SSS restoring near the coast
  55. TYPE(FLD), ALLOCATABLE, DIMENSION(:) :: sf_empc ! structure of input SSS (file informations, fields read)
  56. #endif
  57. REAL(wp) , ALLOCATABLE, DIMENSION(:) :: buffer ! Temporary buffer for exchange
  58. TYPE(FLD), ALLOCATABLE, DIMENSION(:) :: sf_sst ! structure of input SST (file informations, fields read)
  59. TYPE(FLD), ALLOCATABLE, DIMENSION(:) :: sf_sss ! structure of input SSS (file informations, fields read)
  60. !! * Substitutions
  61. # include "do_loop_substitute.h90"
  62. !!----------------------------------------------------------------------
  63. !! NEMO/OCE 4.0 , NEMO Consortium (2018)
  64. !! $Id: sbcssr.F90 14834 2021-05-11 09:24:44Z hadcv $
  65. !! Software governed by the CeCILL license (see ./LICENSE)
  66. !!----------------------------------------------------------------------
  67. CONTAINS
  68. SUBROUTINE sbc_ssr( kt )
  69. !!---------------------------------------------------------------------
  70. !! *** ROUTINE sbc_ssr ***
  71. !!
  72. !! ** Purpose : Add to heat and/or freshwater fluxes a damping term
  73. !! toward observed SST and/or SSS.
  74. !!
  75. !! ** Method : - Read namelist namsbc_ssr
  76. !! - Read observed SST and/or SSS
  77. !! - at each nscb time step
  78. !! add a retroaction term on qns (nn_sstr = 1)
  79. !! add a damping term on sfx (nn_sssr = 1)
  80. !! add a damping term on emp (nn_sssr = 2)
  81. !!---------------------------------------------------------------------
  82. INTEGER, INTENT(in ) :: kt ! ocean time step
  83. !!
  84. INTEGER :: ji, jj ! dummy loop indices
  85. REAL(wp) :: zerp ! local scalar for evaporation damping
  86. REAL(wp) :: zqrp ! local scalar for heat flux damping
  87. REAL(wp) :: zsrp ! local scalar for unit conversion of rn_deds factor
  88. REAL(wp) :: zerp_bnd ! local scalar for unit conversion of rn_epr_max factor
  89. INTEGER :: ierror ! return error code
  90. #if defined key_drakkar
  91. REAL(wp) , DIMENSION (jpi,jpj) :: zsss_m ! temporary array
  92. REAL(wp) , DIMENSION (jpi,jpj) :: zsst_m ! temporary array
  93. TYPE(FLD_N) :: sn_empc ! informations about the fields to be read
  94. #endif
  95. !!
  96. CHARACTER(len=100) :: cn_dir ! Root directory for location of ssr files
  97. TYPE(FLD_N) :: sn_sst, sn_sss ! informations about the fields to be read
  98. !!----------------------------------------------------------------------
  99. !
  100. IF( nn_sstr + nn_sssr /= 0 ) THEN
  101. !
  102. IF( nn_sstr == 1) CALL fld_read( kt, nn_fsbc, sf_sst ) ! Read SST data and provides it at kt
  103. #if defined key_drakkar
  104. IF( nn_sssr <= 2) CALL fld_read( kt, nn_fsbc, sf_sss ) ! Read SSS data and provides it at kt
  105. #else
  106. IF( nn_sssr >= 1) CALL fld_read( kt, nn_fsbc, sf_sss ) ! Read SSS data and provides it at kt
  107. #endif
  108. !
  109. ! ! ========================= !
  110. IF( MOD( kt-1, nn_fsbc ) == 0 ) THEN ! Add restoring term !
  111. ! ! ========================= !
  112. !
  113. qrp(:,:) = 0._wp ! necessary init
  114. erp(:,:) = 0._wp
  115. !
  116. IF( nn_sstr == 1 ) THEN !* Temperature restoring term
  117. DO_2D( nn_hls, nn_hls, nn_hls, nn_hls )
  118. zqrp = rn_dqdt * ( sst_m(ji,jj) - sf_sst(1)%fnow(ji,jj,1) ) * tmask(ji,jj,1)
  119. qns(ji,jj) = qns(ji,jj) + zqrp
  120. qrp(ji,jj) = zqrp
  121. END_2D
  122. ENDIF
  123. !
  124. #if defined key_drakkar
  125. IF( nn_sssr /= 0 .AND. nn_sssr /= 3 .AND. nn_sssr_ice /= 1 ) THEN
  126. #else
  127. IF( nn_sssr /= 0 .AND. nn_sssr_ice /= 1 ) THEN
  128. #endif
  129. ! use fraction of ice ( fr_i ) to adjust relaxation under ice if nn_sssr_ice .ne. 1
  130. ! n.b. coefice is initialised and fixed to 1._wp if nn_sssr_ice = 1
  131. DO_2D( nn_hls, nn_hls, nn_hls, nn_hls )
  132. SELECT CASE ( nn_sssr_ice )
  133. CASE ( 0 ) ; coefice(ji,jj) = 1._wp - fr_i(ji,jj) ! no/reduced damping under ice
  134. CASE DEFAULT ; coefice(ji,jj) = 1._wp + ( nn_sssr_ice - 1 ) * fr_i(ji,jj) ! reinforced damping (x nn_sssr_ice) under ice )
  135. END SELECT
  136. END_2D
  137. ENDIF
  138. !
  139. IF( nn_sssr == 1 ) THEN !* Salinity damping term (salt flux only (sfx))
  140. zsrp = rn_deds / rday ! from [mm/day] to [kg/m2/s]
  141. DO_2D( nn_hls, nn_hls, nn_hls, nn_hls )
  142. zerp = zsrp * ( 1. - 2.*rnfmsk(ji,jj) ) & ! No damping in vicinity of river mouths
  143. & * coefice(ji,jj) & ! Optional control of damping under sea-ice
  144. #if defined key_drakkar
  145. & * ( sss_m(ji,jj) - sf_sss(1)%fnow(ji,jj,1) ) * tmask(ji,jj,1) * erpcoef(ji,jj)
  146. #else
  147. & * ( sss_m(ji,jj) - sf_sss(1)%fnow(ji,jj,1) ) * tmask(ji,jj,1)
  148. #endif
  149. sfx(ji,jj) = sfx(ji,jj) + zerp ! salt flux
  150. erp(ji,jj) = zerp / MAX( sss_m(ji,jj), 1.e-20 ) ! converted into an equivalent volume flux (diagnostic only)
  151. END_2D
  152. !
  153. ELSEIF( nn_sssr == 2 ) THEN !* Salinity damping term (volume flux (emp) and associated heat flux (qns)
  154. zsrp = rn_deds / rday ! from [mm/day] to [kg/m2/s]
  155. zerp_bnd = rn_sssr_bnd / rday ! - -
  156. #if defined key_drakkar
  157. ! fliter model field
  158. IF (ln_sssr_flt ) THEN
  159. CALL Shapiro_1D ( sss_m(:,:), nn_shap_iter, 'ORCA_GLOB', zsss_m )
  160. CALL Shapiro_1D ( sst_m(:,:), nn_shap_iter, 'ORCA_GLOB', zsst_m )
  161. zsss_m = zsss_m * tmask(:,:,1)
  162. zsst_m = zsst_m * tmask(:,:,1)
  163. ELSE
  164. zsss_m = sss_m * tmask(:,:,1)
  165. zsst_m = sst_m * tmask(:,:,1)
  166. ENDIF
  167. DO_2D( nn_hls, nn_hls, nn_hls, nn_hls )
  168. ! use filters model fields and multiply zerp by erpcoef
  169. zerp = zsrp * ( 1. - 2.*rnfmsk(ji,jj) ) & ! No damping in vicinity of river mouths
  170. & * coefice(ji,jj) & ! Optional control of damping under sea-ice
  171. & * ( zsss_m(ji,jj) - sf_sss(1)%fnow(ji,jj,1) ) &
  172. & / MAX( zsss_m(ji,jj), 1.e-20 ) * tmask(ji,jj,1) &
  173. & * erpcoef(ji,jj)
  174. IF( ln_sssr_bnd ) zerp = SIGN( 1., zerp ) * MIN( zerp_bnd, ABS(zerp) )
  175. ! use distance to the coast
  176. IF( ln_sssr_msk ) zerp = zerp * distcoast(ji,jj) ! multiply by weigh to fade zerp out near the coast
  177. qns(ji,jj) = qns(ji,jj) - zerp * rcp * sst_m(ji,jj)
  178. erp(ji,jj) = zerp
  179. qrp(ji,jj) = qrp(ji,jj) - zerp * rcp * sst_m(ji,jj)
  180. END_2D
  181. #else
  182. DO_2D( nn_hls, nn_hls, nn_hls, nn_hls )
  183. zerp = zsrp * ( 1. - 2.*rnfmsk(ji,jj) ) & ! No damping in vicinity of river mouths
  184. & * coefice(ji,jj) & ! Optional control of damping under sea-ice
  185. & * ( sss_m(ji,jj) - sf_sss(1)%fnow(ji,jj,1) ) &
  186. & / MAX( sss_m(ji,jj), 1.e-20 ) * tmask(ji,jj,1)
  187. IF( ln_sssr_bnd ) zerp = SIGN( 1.0_wp, zerp ) * MIN( zerp_bnd, ABS(zerp) )
  188. emp(ji,jj) = emp (ji,jj) + zerp
  189. qns(ji,jj) = qns(ji,jj) - zerp * rcp * sst_m(ji,jj)
  190. erp(ji,jj) = zerp
  191. qrp(ji,jj) = qrp(ji,jj) - zerp * rcp * sst_m(ji,jj)
  192. END_2D
  193. #endif
  194. #if defined key_drakkar
  195. ELSEIF ( nn_sssr == 3) THEN
  196. CALL fld_read( kt, nn_fsbc, sf_empc ) ! Read SST data and provides it at kt
  197. DO_2D( nn_hls, nn_hls, nn_hls, nn_hls )
  198. erp(ji,jj) = sf_empc(1)%fnow(ji,jj,1)
  199. emp(ji,jj) = emp(ji,jj) + erp(ji,jj)
  200. qns(ji,jj) = qns(ji,jj) - erp(ji,jj) * rcp * sst_m(ji,jj)
  201. qrp(ji,jj) = qrp(ji,jj) - erp(ji,jj) * rcp * sst_m(ji,jj)
  202. END_2D
  203. #endif
  204. ENDIF
  205. ! outputs
  206. CALL iom_put( 'hflx_ssr_cea', qrp(:,:) )
  207. IF( nn_sssr == 1 ) CALL iom_put( 'sflx_ssr_cea', erp(:,:) * sss_m(:,:) )
  208. IF( nn_sssr == 2 ) CALL iom_put( 'vflx_ssr_cea', -erp(:,:) )
  209. !
  210. ENDIF
  211. !
  212. ENDIF
  213. !
  214. END SUBROUTINE sbc_ssr
  215. SUBROUTINE sbc_ssr_init
  216. !!---------------------------------------------------------------------
  217. !! *** ROUTINE sbc_ssr_init ***
  218. !!
  219. !! ** Purpose : initialisation of surface damping term
  220. !!
  221. !! ** Method : - Read namelist namsbc_ssr
  222. !! - Read observed SST and/or SSS if required
  223. !!---------------------------------------------------------------------
  224. INTEGER :: ji, jj ! dummy loop indices
  225. REAL(wp) :: zerp ! local scalar for evaporation damping
  226. REAL(wp) :: zqrp ! local scalar for heat flux damping
  227. REAL(wp) :: zsrp ! local scalar for unit conversion of rn_deds factor
  228. REAL(wp) :: zerp_bnd ! local scalar for unit conversion of rn_epr_max factor
  229. INTEGER :: ierror ! return error code
  230. #if defined key_drakkar
  231. INTEGER :: ii0, ii1, ii2, ij0, ij1, ij2, inum
  232. REAL(wp) :: zalph
  233. CHARACTER(LEN=100) :: cl_coastfile
  234. TYPE(FLD_N) :: sn_empc
  235. NAMELIST/namsbc_ssr_drk/ ln_sssr_flt, ln_sssr_msk, sn_coast, rn_dist, nn_shap_iter, sn_empc
  236. #endif
  237. !!
  238. CHARACTER(len=100) :: cn_dir ! Root directory for location of ssr files
  239. TYPE(FLD_N) :: sn_sst, sn_sss ! informations about the fields to be read
  240. NAMELIST/namsbc_ssr/ cn_dir, nn_sstr, nn_sssr, rn_dqdt, rn_deds, sn_sst, &
  241. & sn_sss, ln_sssr_bnd, rn_sssr_bnd, nn_sssr_ice
  242. INTEGER :: ios
  243. !!----------------------------------------------------------------------
  244. !
  245. IF(lwp) THEN
  246. WRITE(numout,*)
  247. WRITE(numout,*) 'sbc_ssr : SST and/or SSS damping term '
  248. WRITE(numout,*) '~~~~~~~ '
  249. ENDIF
  250. !
  251. READ ( numnam_ref, namsbc_ssr, IOSTAT = ios, ERR = 901)
  252. 901 IF( ios /= 0 ) CALL ctl_nam ( ios , 'namsbc_ssr in reference namelist' )
  253. READ ( numnam_cfg, namsbc_ssr, IOSTAT = ios, ERR = 902 )
  254. 902 IF( ios > 0 ) CALL ctl_nam ( ios , 'namsbc_ssr in configuration namelist' )
  255. IF(lwm) WRITE ( numond, namsbc_ssr )
  256. #if defined key_drakkar
  257. READ ( numnam_ref, namsbc_ssr_drk, IOSTAT = ios, ERR = 903)
  258. 903 IF( ios /= 0 ) CALL ctl_nam ( ios , 'namsbc_ssr_drk in reference namelist' )
  259. READ ( numnam_cfg, namsbc_ssr_drk, IOSTAT = ios, ERR = 904 )
  260. 904 IF( ios > 0 ) CALL ctl_nam ( ios , 'namsbc_ssr_drk in configuration namelist' )
  261. IF(lwm) WRITE ( numond, namsbc_ssr )
  262. #endif
  263. IF(lwp) THEN !* control print
  264. WRITE(numout,*) ' Namelist namsbc_ssr :'
  265. WRITE(numout,*) ' SST restoring term (Yes=1) nn_sstr = ', nn_sstr
  266. WRITE(numout,*) ' dQ/dT (restoring magnitude on SST) rn_dqdt = ', rn_dqdt, ' W/m2/K'
  267. WRITE(numout,*) ' SSS damping term (Yes=1, salt flux) nn_sssr = ', nn_sssr
  268. WRITE(numout,*) ' (Yes=2, volume flux) '
  269. #if defined key_drakkar
  270. WRITE(numout,*) ' (Yes=3, from input file and as volume flux) '
  271. #endif
  272. WRITE(numout,*) ' dE/dS (restoring magnitude on SST) rn_deds = ', rn_deds, ' mm/day'
  273. WRITE(numout,*) ' flag to bound erp term ln_sssr_bnd = ', ln_sssr_bnd
  274. WRITE(numout,*) ' ABS(Max./Min.) erp threshold rn_sssr_bnd = ', rn_sssr_bnd, ' mm/day'
  275. WRITE(numout,*) ' Cntrl of surface restoration under ice nn_sssr_ice = ', nn_sssr_ice
  276. WRITE(numout,*) ' ( 0 = no restoration under ice)'
  277. WRITE(numout,*) ' ( 1 = restoration everywhere )'
  278. WRITE(numout,*) ' (>1 = enhanced restoration under ice )'
  279. #if defined key_drakkar
  280. IF ( nn_sssr == 3 ) THEN
  281. WRITE(numout,*)
  282. WRITE(numout,*) ' Read sssr term from a forcing (prescribed emp correction).'
  283. WRITE(numout,*)
  284. ELSE
  285. WRITE(numout,*) ' Filtering of sss for restoring ln_sssr_flt = ', ln_sssr_flt
  286. IF ( ln_sssr_flt ) THEN
  287. WRITE(numout,*) ' Number of used Shapiro filter nn_shap_iter = ', nn_shap_iter
  288. ENDIF
  289. WRITE(numout,*) ' Limit sss restoring near the coast ln_sssr_msk = ', ln_sssr_msk
  290. IF ( ln_sssr_msk ) WRITE(numout,*) ' Decaying lenght scale from the coast rn_dist = ', rn_dist, ' km'
  291. END IF
  292. #endif
  293. ENDIF
  294. !
  295. IF( nn_sstr == 1 ) THEN !* set sf_sst structure & allocate arrays
  296. !
  297. ALLOCATE( sf_sst(1), STAT=ierror )
  298. IF( ierror > 0 ) CALL ctl_stop( 'STOP', 'sbc_ssr: unable to allocate sf_sst structure' )
  299. ALLOCATE( sf_sst(1)%fnow(jpi,jpj,1), STAT=ierror )
  300. IF( ierror > 0 ) CALL ctl_stop( 'STOP', 'sbc_ssr: unable to allocate sf_sst now array' )
  301. !
  302. ! fill sf_sst with sn_sst and control print
  303. CALL fld_fill( sf_sst, (/ sn_sst /), cn_dir, 'sbc_ssr', 'SST restoring term toward SST data', 'namsbc_ssr', no_print )
  304. IF( sf_sst(1)%ln_tint ) ALLOCATE( sf_sst(1)%fdta(jpi,jpj,1,2), STAT=ierror )
  305. IF( ierror > 0 ) CALL ctl_stop( 'STOP', 'sbc_ssr: unable to allocate sf_sst data array' )
  306. !
  307. ENDIF
  308. !
  309. #if defined key_drakkar
  310. IF( nn_sssr >= 1 .AND. nn_sssr < 3) THEN
  311. #else
  312. IF( nn_sssr >= 1 ) THEN !* set sf_sss structure & allocate arrays
  313. #endif
  314. !
  315. ALLOCATE( sf_sss(1), STAT=ierror )
  316. IF( ierror > 0 ) CALL ctl_stop( 'STOP', 'sbc_ssr: unable to allocate sf_sss structure' )
  317. ALLOCATE( sf_sss(1)%fnow(jpi,jpj,1), STAT=ierror )
  318. IF( ierror > 0 ) CALL ctl_stop( 'STOP', 'sbc_ssr: unable to allocate sf_sss now array' )
  319. !
  320. ! fill sf_sss with sn_sss and control print
  321. CALL fld_fill( sf_sss, (/ sn_sss /), cn_dir, 'sbc_ssr', 'SSS restoring term toward SSS data', 'namsbc_ssr', no_print )
  322. IF( sf_sss(1)%ln_tint ) ALLOCATE( sf_sss(1)%fdta(jpi,jpj,1,2), STAT=ierror )
  323. IF( ierror > 0 ) CALL ctl_stop( 'STOP', 'sbc_ssr: unable to allocate sf_sss data array' )
  324. !
  325. #if defined key_drakkar
  326. ! if masking of coastal area is used
  327. IF ( ln_sssr_msk ) THEN
  328. ALLOCATE( distcoast(jpi,jpj),STAT=ierror )
  329. IF( ierror > 0 ) CALL ctl_stop( 'STOP', 'sbc_ssr: unable to allocate erp and qrp array' )
  330. WRITE(cl_coastfile,'(a,a)' ) TRIM( cn_dir ), TRIM( sn_coast%clname )
  331. CALL iom_open ( cl_coastfile, inum ) ! open file
  332. CALL iom_get ( inum, jpdom_global, sn_coast%clvar, distcoast, kfill=jpfillcopy ) ! read tcoast in m
  333. CALL iom_close( inum )
  334. ! transform distcoast to weight
  335. rn_dist=rn_dist*1000. ! tranform rn_dist to m
  336. distcoast(:,:)=0.5*(tanh(3.*(distcoast(:,:)*distcoast(:,:)/rn_dist/rn_dist - 1 )) + 1 )
  337. ENDIF
  338. ALLOCATE( erpcoef(jpi,jpj),STAT=ierror )
  339. IF( ierror > 0 ) CALL ctl_stop( 'STOP', 'sbc_ssr: unable to allocate erpcoef' )
  340. ! DRAKKAR { initialize erpcoef to increase erp in the med sea
  341. erpcoef(:,:) = 1._wp
  342. !!! JMM : see how do to it nicely either in a an external file of is a usr_ routine
  343. ! to keep the spirit of NEMO 4
  344. ! IF( cp_cfg == "orca" .AND. jp_cfg == 25 ) THEN ! ORCA R025 configuration
  345. ! !! add extra SSS restoring in the Red Sea
  346. ! ii0= 1280 ; ii1 = 1325
  347. ! ij0= 560 ; ij1 = 625
  348. ! erpcoef( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1)) = 5.0
  349. !! add extra SSS restoring in the Med sea (x3) decreasing to 1 into the alboran sea
  350. ! ii1 = 1145 ; ii2 = 1330
  351. ! ij1 = 626 ; ij2 = 726
  352. ! erpcoef( mi0(ii1):mi1(ii2) , mj0(ij1):mj1(ij2)) = 3.0
  353. !! decrease in alboran sea (along i )
  354. ! ii0= 1128 ; ii1 = 1144
  355. ! ij0= 645 ; ij1 = 670
  356. ! DO jj=mj0(ij0), mj1(ij1)
  357. ! DO ji= mi0(ii0), mi1(ii1)
  358. ! !zalph=( alph1 -alph0 )* (I - ii0 )/(ii1-ii0) + alph0
  359. !zalph=( 3. - 1. )* (I - ii0 )/(ii1-ii0) + 1.
  360. ! zalph= 2. * (mig(ji)-ii0)/(ii1-ii0) + 1.
  361. ! erpcoef(ji,jj) = zalph
  362. ! ENDDO
  363. ! ENDDO
  364. ! ENDIF
  365. ELSEIF ( nn_sssr == 3 ) THEN
  366. ALLOCATE( sf_empc(1), STAT=ierror )
  367. IF( ierror > 0 ) CALL ctl_stop( 'STOP', 'sbc_ssr: unable to allocate sf_empc structure' )
  368. ALLOCATE( sf_empc(1)%fnow(jpi,jpj,1), STAT=ierror )
  369. IF( ierror > 0 ) CALL ctl_stop( 'STOP', 'sbc_ssr: unable to allocate sf_empc now array' )
  370. !
  371. ! fill sf_empc with sn_empc and control print
  372. CALL fld_fill( sf_empc, (/ sn_empc /), cn_dir, 'sbc_ssr', 'SSS restoring term toward SSS data', 'namsbc_ssr', no_print )
  373. IF( sf_empc(1)%ln_tint ) ALLOCATE( sf_empc(1)%fdta(jpi,jpj,1,2), STAT=ierror )
  374. IF( ierror > 0 ) CALL ctl_stop( 'STOP', 'sbc_ssr: unable to allocate sf_empc data array' )
  375. #endif
  376. ENDIF
  377. !
  378. coefice(:,:) = 1._wp ! Initialise coefice to 1._wp ; will not need to be changed if nn_sssr_ice=1
  379. ! !* Initialize qrp and erp if no restoring
  380. IF( nn_sstr /= 1 ) qrp(:,:) = 0._wp
  381. #if defined key_drakkar
  382. IF( nn_sssr > 0 ) erp(:,:) = 0._wp
  383. #else
  384. IF( nn_sssr /= 1 .OR. nn_sssr /= 2 ) erp(:,:) = 0._wp
  385. #endif
  386. !
  387. END SUBROUTINE sbc_ssr_init
  388. INTEGER FUNCTION sbc_ssr_alloc()
  389. !!----------------------------------------------------------------------
  390. !! *** FUNCTION sbc_ssr_alloc ***
  391. !!----------------------------------------------------------------------
  392. sbc_ssr_alloc = 0 ! set to zero if no array to be allocated
  393. IF( .NOT. ALLOCATED( erp ) ) THEN
  394. ALLOCATE( qrp(jpi,jpj), erp(jpi,jpj), coefice(jpi,jpj), STAT= sbc_ssr_alloc )
  395. !
  396. IF( lk_mpp ) CALL mpp_sum ( 'sbcssr', sbc_ssr_alloc )
  397. IF( sbc_ssr_alloc /= 0 ) CALL ctl_warn('sbc_ssr_alloc: failed to allocate arrays.')
  398. !
  399. ENDIF
  400. END FUNCTION
  401. !!======================================================================
  402. END MODULE sbcssr