sbcssr.F90 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422
  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. emp(ji,jj) = emp (ji,jj) + zerp
  178. qns(ji,jj) = qns(ji,jj) - zerp * rcp * sst_m(ji,jj)
  179. erp(ji,jj) = zerp
  180. qrp(ji,jj) = qrp(ji,jj) - zerp * rcp * sst_m(ji,jj)
  181. END_2D
  182. #else
  183. DO_2D( nn_hls, nn_hls, nn_hls, nn_hls )
  184. zerp = zsrp * ( 1. - 2.*rnfmsk(ji,jj) ) & ! No damping in vicinity of river mouths
  185. & * coefice(ji,jj) & ! Optional control of damping under sea-ice
  186. & * ( sss_m(ji,jj) - sf_sss(1)%fnow(ji,jj,1) ) &
  187. & / MAX( sss_m(ji,jj), 1.e-20 ) * tmask(ji,jj,1)
  188. IF( ln_sssr_bnd ) zerp = SIGN( 1.0_wp, zerp ) * MIN( zerp_bnd, ABS(zerp) )
  189. emp(ji,jj) = emp (ji,jj) + zerp
  190. qns(ji,jj) = qns(ji,jj) - zerp * rcp * sst_m(ji,jj)
  191. erp(ji,jj) = zerp
  192. qrp(ji,jj) = qrp(ji,jj) - zerp * rcp * sst_m(ji,jj)
  193. END_2D
  194. #endif
  195. #if defined key_drakkar
  196. ELSEIF ( nn_sssr == 3) THEN
  197. CALL fld_read( kt, nn_fsbc, sf_empc ) ! Read SST data and provides it at kt
  198. DO_2D( nn_hls, nn_hls, nn_hls, nn_hls )
  199. erp(ji,jj) = sf_empc(1)%fnow(ji,jj,1)
  200. emp(ji,jj) = emp(ji,jj) + erp(ji,jj)
  201. qns(ji,jj) = qns(ji,jj) - erp(ji,jj) * rcp * sst_m(ji,jj)
  202. qrp(ji,jj) = qrp(ji,jj) - erp(ji,jj) * rcp * sst_m(ji,jj)
  203. END_2D
  204. #endif
  205. ENDIF
  206. ! outputs
  207. CALL iom_put( 'hflx_ssr_cea', qrp(:,:) )
  208. IF( nn_sssr == 1 ) CALL iom_put( 'sflx_ssr_cea', erp(:,:) * sss_m(:,:) )
  209. IF( nn_sssr == 2 ) CALL iom_put( 'vflx_ssr_cea', -erp(:,:) )
  210. !
  211. ENDIF
  212. !
  213. ENDIF
  214. !
  215. END SUBROUTINE sbc_ssr
  216. SUBROUTINE sbc_ssr_init
  217. !!---------------------------------------------------------------------
  218. !! *** ROUTINE sbc_ssr_init ***
  219. !!
  220. !! ** Purpose : initialisation of surface damping term
  221. !!
  222. !! ** Method : - Read namelist namsbc_ssr
  223. !! - Read observed SST and/or SSS if required
  224. !!---------------------------------------------------------------------
  225. INTEGER :: ji, jj ! dummy loop indices
  226. REAL(wp) :: zerp ! local scalar for evaporation damping
  227. REAL(wp) :: zqrp ! local scalar for heat flux damping
  228. REAL(wp) :: zsrp ! local scalar for unit conversion of rn_deds factor
  229. REAL(wp) :: zerp_bnd ! local scalar for unit conversion of rn_epr_max factor
  230. INTEGER :: ierror ! return error code
  231. #if defined key_drakkar
  232. INTEGER :: ii0, ii1, ii2, ij0, ij1, ij2, inum
  233. REAL(wp) :: zalph
  234. CHARACTER(LEN=100) :: cl_coastfile
  235. TYPE(FLD_N) :: sn_empc
  236. NAMELIST/namsbc_ssr_drk/ ln_sssr_flt, ln_sssr_msk, sn_coast, rn_dist, nn_shap_iter, sn_empc
  237. #endif
  238. !!
  239. CHARACTER(len=100) :: cn_dir ! Root directory for location of ssr files
  240. TYPE(FLD_N) :: sn_sst, sn_sss ! informations about the fields to be read
  241. NAMELIST/namsbc_ssr/ cn_dir, nn_sstr, nn_sssr, rn_dqdt, rn_deds, sn_sst, &
  242. & sn_sss, ln_sssr_bnd, rn_sssr_bnd, nn_sssr_ice
  243. INTEGER :: ios
  244. !!----------------------------------------------------------------------
  245. !
  246. IF(lwp) THEN
  247. WRITE(numout,*)
  248. WRITE(numout,*) 'sbc_ssr : SST and/or SSS damping term '
  249. WRITE(numout,*) '~~~~~~~ '
  250. ENDIF
  251. !
  252. READ ( numnam_ref, namsbc_ssr, IOSTAT = ios, ERR = 901)
  253. 901 IF( ios /= 0 ) CALL ctl_nam ( ios , 'namsbc_ssr in reference namelist' )
  254. READ ( numnam_cfg, namsbc_ssr, IOSTAT = ios, ERR = 902 )
  255. 902 IF( ios > 0 ) CALL ctl_nam ( ios , 'namsbc_ssr in configuration namelist' )
  256. IF(lwm) WRITE ( numond, namsbc_ssr )
  257. #if defined key_drakkar
  258. READ ( numnam_ref, namsbc_ssr_drk, IOSTAT = ios, ERR = 903)
  259. 903 IF( ios /= 0 ) CALL ctl_nam ( ios , 'namsbc_ssr_drk in reference namelist' )
  260. READ ( numnam_cfg, namsbc_ssr_drk, IOSTAT = ios, ERR = 904 )
  261. 904 IF( ios > 0 ) CALL ctl_nam ( ios , 'namsbc_ssr_drk in configuration namelist' )
  262. IF(lwm) WRITE ( numond, namsbc_ssr )
  263. #endif
  264. IF(lwp) THEN !* control print
  265. WRITE(numout,*) ' Namelist namsbc_ssr :'
  266. WRITE(numout,*) ' SST restoring term (Yes=1) nn_sstr = ', nn_sstr
  267. WRITE(numout,*) ' dQ/dT (restoring magnitude on SST) rn_dqdt = ', rn_dqdt, ' W/m2/K'
  268. WRITE(numout,*) ' SSS damping term (Yes=1, salt flux) nn_sssr = ', nn_sssr
  269. WRITE(numout,*) ' (Yes=2, volume flux) '
  270. #if defined key_drakkar
  271. WRITE(numout,*) ' (Yes=3, from input file and as volume flux) '
  272. #endif
  273. WRITE(numout,*) ' dE/dS (restoring magnitude on SST) rn_deds = ', rn_deds, ' mm/day'
  274. WRITE(numout,*) ' flag to bound erp term ln_sssr_bnd = ', ln_sssr_bnd
  275. WRITE(numout,*) ' ABS(Max./Min.) erp threshold rn_sssr_bnd = ', rn_sssr_bnd, ' mm/day'
  276. WRITE(numout,*) ' Cntrl of surface restoration under ice nn_sssr_ice = ', nn_sssr_ice
  277. WRITE(numout,*) ' ( 0 = no restoration under ice)'
  278. WRITE(numout,*) ' ( 1 = restoration everywhere )'
  279. WRITE(numout,*) ' (>1 = enhanced restoration under ice )'
  280. #if defined key_drakkar
  281. IF ( nn_sssr == 3 ) THEN
  282. WRITE(numout,*)
  283. WRITE(numout,*) ' Read sssr term from a forcing (prescribed emp correction).'
  284. WRITE(numout,*)
  285. ELSE
  286. WRITE(numout,*) ' Filtering of sss for restoring ln_sssr_flt = ', ln_sssr_flt
  287. IF ( ln_sssr_flt ) THEN
  288. WRITE(numout,*) ' Number of used Shapiro filter nn_shap_iter = ', nn_shap_iter
  289. ENDIF
  290. WRITE(numout,*) ' Limit sss restoring near the coast ln_sssr_msk = ', ln_sssr_msk
  291. IF ( ln_sssr_msk ) WRITE(numout,*) ' Decaying lenght scale from the coast rn_dist = ', rn_dist, ' km'
  292. END IF
  293. #endif
  294. ENDIF
  295. !
  296. IF( nn_sstr == 1 ) THEN !* set sf_sst structure & allocate arrays
  297. !
  298. ALLOCATE( sf_sst(1), STAT=ierror )
  299. IF( ierror > 0 ) CALL ctl_stop( 'STOP', 'sbc_ssr: unable to allocate sf_sst structure' )
  300. ALLOCATE( sf_sst(1)%fnow(jpi,jpj,1), STAT=ierror )
  301. IF( ierror > 0 ) CALL ctl_stop( 'STOP', 'sbc_ssr: unable to allocate sf_sst now array' )
  302. !
  303. ! fill sf_sst with sn_sst and control print
  304. CALL fld_fill( sf_sst, (/ sn_sst /), cn_dir, 'sbc_ssr', 'SST restoring term toward SST data', 'namsbc_ssr', no_print )
  305. IF( sf_sst(1)%ln_tint ) ALLOCATE( sf_sst(1)%fdta(jpi,jpj,1,2), STAT=ierror )
  306. IF( ierror > 0 ) CALL ctl_stop( 'STOP', 'sbc_ssr: unable to allocate sf_sst data array' )
  307. !
  308. ENDIF
  309. !
  310. #if defined key_drakkar
  311. IF( nn_sssr >= 1 .AND. nn_sssr < 3) THEN
  312. #else
  313. IF( nn_sssr >= 1 ) THEN !* set sf_sss structure & allocate arrays
  314. #endif
  315. !
  316. ALLOCATE( sf_sss(1), STAT=ierror )
  317. IF( ierror > 0 ) CALL ctl_stop( 'STOP', 'sbc_ssr: unable to allocate sf_sss structure' )
  318. ALLOCATE( sf_sss(1)%fnow(jpi,jpj,1), STAT=ierror )
  319. IF( ierror > 0 ) CALL ctl_stop( 'STOP', 'sbc_ssr: unable to allocate sf_sss now array' )
  320. !
  321. ! fill sf_sss with sn_sss and control print
  322. CALL fld_fill( sf_sss, (/ sn_sss /), cn_dir, 'sbc_ssr', 'SSS restoring term toward SSS data', 'namsbc_ssr', no_print )
  323. IF( sf_sss(1)%ln_tint ) ALLOCATE( sf_sss(1)%fdta(jpi,jpj,1,2), STAT=ierror )
  324. IF( ierror > 0 ) CALL ctl_stop( 'STOP', 'sbc_ssr: unable to allocate sf_sss data array' )
  325. !
  326. #if defined key_drakkar
  327. ! if masking of coastal area is used
  328. IF ( ln_sssr_msk ) THEN
  329. ALLOCATE( distcoast(jpi,jpj),STAT=ierror )
  330. IF( ierror > 0 ) CALL ctl_stop( 'STOP', 'sbc_ssr: unable to allocate erp and qrp array' )
  331. WRITE(cl_coastfile,'(a,a)' ) TRIM( cn_dir ), TRIM( sn_coast%clname )
  332. CALL iom_open ( cl_coastfile, inum ) ! open file
  333. CALL iom_get ( inum, jpdom_global, sn_coast%clvar, distcoast, kfill=jpfillcopy ) ! read tcoast in m
  334. CALL iom_close( inum )
  335. ! transform distcoast to weight
  336. rn_dist=rn_dist*1000. ! tranform rn_dist to m
  337. distcoast(:,:)=0.5*(tanh(3.*(distcoast(:,:)*distcoast(:,:)/rn_dist/rn_dist - 1 )) + 1 )
  338. ENDIF
  339. ALLOCATE( erpcoef(jpi,jpj),STAT=ierror )
  340. IF( ierror > 0 ) CALL ctl_stop( 'STOP', 'sbc_ssr: unable to allocate erpcoef' )
  341. ! DRAKKAR { initialize erpcoef to increase erp in the med sea
  342. erpcoef(:,:) = 1._wp
  343. !!! JMM : see how do to it nicely either in a an external file of is a usr_ routine
  344. ! to keep the spirit of NEMO 4
  345. ! IF( cp_cfg == "orca" .AND. jp_cfg == 25 ) THEN ! ORCA R025 configuration
  346. ! !! add extra SSS restoring in the Red Sea
  347. ! ii0= 1280 ; ii1 = 1325
  348. ! ij0= 560 ; ij1 = 625
  349. ! erpcoef( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1)) = 5.0
  350. !! add extra SSS restoring in the Med sea (x3) decreasing to 1 into the alboran sea
  351. ! ii1 = 1145 ; ii2 = 1330
  352. ! ij1 = 626 ; ij2 = 726
  353. ! erpcoef( mi0(ii1):mi1(ii2) , mj0(ij1):mj1(ij2)) = 3.0
  354. !! decrease in alboran sea (along i )
  355. ! ii0= 1128 ; ii1 = 1144
  356. ! ij0= 645 ; ij1 = 670
  357. ! DO jj=mj0(ij0), mj1(ij1)
  358. ! DO ji= mi0(ii0), mi1(ii1)
  359. ! !zalph=( alph1 -alph0 )* (I - ii0 )/(ii1-ii0) + alph0
  360. !zalph=( 3. - 1. )* (I - ii0 )/(ii1-ii0) + 1.
  361. ! zalph= 2. * (mig(ji)-ii0)/(ii1-ii0) + 1.
  362. ! erpcoef(ji,jj) = zalph
  363. ! ENDDO
  364. ! ENDDO
  365. ! ENDIF
  366. ELSEIF ( nn_sssr == 3 ) THEN
  367. ALLOCATE( sf_empc(1), STAT=ierror )
  368. IF( ierror > 0 ) CALL ctl_stop( 'STOP', 'sbc_ssr: unable to allocate sf_empc structure' )
  369. ALLOCATE( sf_empc(1)%fnow(jpi,jpj,1), STAT=ierror )
  370. IF( ierror > 0 ) CALL ctl_stop( 'STOP', 'sbc_ssr: unable to allocate sf_empc now array' )
  371. !
  372. ! fill sf_empc with sn_empc and control print
  373. CALL fld_fill( sf_empc, (/ sn_empc /), cn_dir, 'sbc_ssr', 'SSS restoring term toward SSS data', 'namsbc_ssr', no_print )
  374. IF( sf_empc(1)%ln_tint ) ALLOCATE( sf_empc(1)%fdta(jpi,jpj,1,2), STAT=ierror )
  375. IF( ierror > 0 ) CALL ctl_stop( 'STOP', 'sbc_ssr: unable to allocate sf_empc data array' )
  376. #endif
  377. ENDIF
  378. !
  379. coefice(:,:) = 1._wp ! Initialise coefice to 1._wp ; will not need to be changed if nn_sssr_ice=1
  380. ! !* Initialize qrp and erp if no restoring
  381. IF( nn_sstr /= 1 ) qrp(:,:) = 0._wp
  382. #if defined key_drakkar
  383. IF( nn_sssr > 0 ) erp(:,:) = 0._wp
  384. #else
  385. IF( nn_sssr /= 1 .OR. nn_sssr /= 2 ) erp(:,:) = 0._wp
  386. #endif
  387. !
  388. END SUBROUTINE sbc_ssr_init
  389. INTEGER FUNCTION sbc_ssr_alloc()
  390. !!----------------------------------------------------------------------
  391. !! *** FUNCTION sbc_ssr_alloc ***
  392. !!----------------------------------------------------------------------
  393. sbc_ssr_alloc = 0 ! set to zero if no array to be allocated
  394. IF( .NOT. ALLOCATED( erp ) ) THEN
  395. ALLOCATE( qrp(jpi,jpj), erp(jpi,jpj), coefice(jpi,jpj), STAT= sbc_ssr_alloc )
  396. !
  397. IF( lk_mpp ) CALL mpp_sum ( 'sbcssr', sbc_ssr_alloc )
  398. IF( sbc_ssr_alloc /= 0 ) CALL ctl_warn('sbc_ssr_alloc: failed to allocate arrays.')
  399. !
  400. ENDIF
  401. END FUNCTION
  402. !!======================================================================
  403. END MODULE sbcssr