limtrp.F90 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530
  1. MODULE limtrp
  2. !!======================================================================
  3. !! *** MODULE limtrp ***
  4. !! LIM transport ice model : sea-ice advection/diffusion
  5. !!======================================================================
  6. !! History : LIM-2 ! 2000-01 (M.A. Morales Maqueda, H. Goosse, and T. Fichefet) Original code
  7. !! 3.0 ! 2005-11 (M. Vancoppenolle) Multi-layer sea ice, salinity variations
  8. !! 4.0 ! 2011-02 (G. Madec) dynamical allocation
  9. !!----------------------------------------------------------------------
  10. #if defined key_lim3
  11. !!----------------------------------------------------------------------
  12. !! 'key_lim3' LIM3 sea-ice model
  13. !!----------------------------------------------------------------------
  14. !! lim_trp : advection/diffusion process of sea ice
  15. !!----------------------------------------------------------------------
  16. USE phycst ! physical constant
  17. USE dom_oce ! ocean domain
  18. USE sbc_oce ! ocean surface boundary condition
  19. USE dom_ice ! ice domain
  20. USE ice ! ice variables
  21. USE limadv ! ice advection
  22. USE limhdf ! ice horizontal diffusion
  23. USE limvar !
  24. !
  25. USE in_out_manager ! I/O manager
  26. USE lbclnk ! lateral boundary conditions -- MPP exchanges
  27. USE lib_mpp ! MPP library
  28. USE wrk_nemo ! work arrays
  29. USE prtctl ! Print control
  30. USE lib_fortran ! Fortran utilities (allows no signed zero when 'key_nosignedzero' defined)
  31. USE timing ! Timing
  32. USE limcons ! conservation tests
  33. USE limctl ! control prints
  34. IMPLICIT NONE
  35. PRIVATE
  36. PUBLIC lim_trp ! called by sbcice_lim
  37. INTEGER :: ncfl ! number of ice time step with CFL>1/2
  38. !! * Substitution
  39. # include "vectopt_loop_substitute.h90"
  40. !!----------------------------------------------------------------------
  41. !! NEMO/LIM3 4.0 , UCL - NEMO Consortium (2011)
  42. !! $Id: limtrp.F90 4990 2014-12-15 16:42:49Z timgraham $
  43. !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
  44. !!----------------------------------------------------------------------
  45. CONTAINS
  46. SUBROUTINE lim_trp( kt )
  47. !!-------------------------------------------------------------------
  48. !! *** ROUTINE lim_trp ***
  49. !!
  50. !! ** purpose : advection/diffusion process of sea ice
  51. !!
  52. !! ** method : variables included in the process are scalar,
  53. !! other values are considered as second order.
  54. !! For advection, a second order Prather scheme is used.
  55. !!
  56. !! ** action :
  57. !!---------------------------------------------------------------------
  58. INTEGER, INTENT(in) :: kt ! number of iteration
  59. !
  60. INTEGER :: ji, jj, jk, jm , jl, jt ! dummy loop indices
  61. INTEGER :: initad ! number of sub-timestep for the advection
  62. REAL(wp) :: zcfl , zusnit ! - -
  63. CHARACTER(len=80) :: cltmp
  64. !
  65. REAL(wp), POINTER, DIMENSION(:,:) :: zsm
  66. REAL(wp), POINTER, DIMENSION(:,:,:) :: z0ice, z0snw, z0ai, z0es , z0smi , z0oi
  67. REAL(wp), POINTER, DIMENSION(:,:,:) :: z0opw
  68. REAL(wp), POINTER, DIMENSION(:,:,:,:) :: z0ei
  69. REAL(wp), POINTER, DIMENSION(:,:,:) :: zviold, zvsold, zsmvold ! old ice volume...
  70. REAL(wp), POINTER, DIMENSION(:,:,:) :: zhimax ! old ice thickness
  71. REAL(wp), POINTER, DIMENSION(:,:) :: zatold, zeiold, zesold ! old concentration, enthalpies
  72. REAL(wp), POINTER, DIMENSION(:,:,:) :: zhdfptab
  73. REAL(wp) :: zdv, zvi, zvs, zsmv, zes, zei
  74. REAL(wp) :: zvi_b, zsmv_b, zei_b, zfs_b, zfw_b, zft_b
  75. !!---------------------------------------------------------------------
  76. INTEGER :: ihdf_vars = 6 !!Number of variables in which we apply horizontal diffusion
  77. !! inside limtrp for each ice category , not counting the
  78. !! variables corresponding to ice_layers
  79. !!---------------------------------------------------------------------
  80. IF( nn_timing == 1 ) CALL timing_start('limtrp')
  81. CALL wrk_alloc( jpi,jpj, zsm, zatold, zeiold, zesold )
  82. CALL wrk_alloc( jpi,jpj,jpl, z0ice, z0snw, z0ai, z0es , z0smi , z0oi )
  83. CALL wrk_alloc( jpi,jpj,1, z0opw )
  84. CALL wrk_alloc( jpi,jpj,nlay_i,jpl, z0ei )
  85. CALL wrk_alloc( jpi,jpj,jpl, zhimax, zviold, zvsold, zsmvold )
  86. CALL wrk_alloc( jpi,jpj,jpl*(ihdf_vars + nlay_i)+1,zhdfptab)
  87. IF( numit == nstart .AND. lwp ) THEN
  88. WRITE(numout,*)
  89. IF( ln_limdyn ) THEN ; WRITE(numout,*) 'lim_trp : Ice transport '
  90. ELSE ; WRITE(numout,*) 'lim_trp : No ice advection as ln_limdyn = ', ln_limdyn
  91. ENDIF
  92. WRITE(numout,*) '~~~~~~~~~~~~'
  93. ncfl = 0 ! nb of time step with CFL > 1/2
  94. ENDIF
  95. zsm(:,:) = e12t(:,:)
  96. ! !-------------------------------------!
  97. IF( ln_limdyn ) THEN ! Advection of sea ice properties !
  98. ! !-------------------------------------!
  99. ! conservation test
  100. IF( ln_limdiahsb ) CALL lim_cons_hsm(0, 'limtrp', zvi_b, zsmv_b, zei_b, zfw_b, zfs_b, zft_b)
  101. ! mass and salt flux init
  102. zviold(:,:,:) = v_i(:,:,:)
  103. zvsold(:,:,:) = v_s(:,:,:)
  104. zsmvold(:,:,:) = smv_i(:,:,:)
  105. zeiold(:,:) = SUM( SUM( e_i(:,:,1:nlay_i,:), dim=4 ), dim=3 )
  106. zesold(:,:) = SUM( SUM( e_s(:,:,1:nlay_s,:), dim=4 ), dim=3 )
  107. !--- Thickness correction init. -------------------------------
  108. zatold(:,:) = SUM( a_i(:,:,:), dim=3 )
  109. DO jl = 1, jpl
  110. DO jj = 1, jpj
  111. DO ji = 1, jpi
  112. rswitch = MAX( 0._wp , SIGN( 1._wp, a_i(ji,jj,jl) - epsi20 ) )
  113. ht_i (ji,jj,jl) = v_i (ji,jj,jl) / MAX( a_i(ji,jj,jl) , epsi20 ) * rswitch
  114. ht_s (ji,jj,jl) = v_s (ji,jj,jl) / MAX( a_i(ji,jj,jl) , epsi20 ) * rswitch
  115. END DO
  116. END DO
  117. END DO
  118. !---------------------------------------------------------------------
  119. ! Record max of the surrounding ice thicknesses for correction
  120. ! in case advection creates ice too thick.
  121. !---------------------------------------------------------------------
  122. zhimax(:,:,:) = ht_i(:,:,:) + ht_s(:,:,:)
  123. DO jl = 1, jpl
  124. DO jj = 2, jpjm1
  125. DO ji = 2, jpim1
  126. zhimax(ji,jj,jl) = MAXVAL( ht_i(ji-1:ji+1,jj-1:jj+1,jl) + ht_s(ji-1:ji+1,jj-1:jj+1,jl) )
  127. END DO
  128. END DO
  129. CALL lbc_lnk(zhimax(:,:,jl),'T',1.)
  130. END DO
  131. !=============================!
  132. !== Prather scheme ==!
  133. !=============================!
  134. ! If ice drift field is too fast, use an appropriate time step for advection.
  135. zcfl = MAXVAL( ABS( u_ice(:,:) ) * rdt_ice * r1_e1u(:,:) ) ! CFL test for stability
  136. zcfl = MAX( zcfl, MAXVAL( ABS( v_ice(:,:) ) * rdt_ice * r1_e2v(:,:) ) )
  137. IF(lk_mpp ) CALL mpp_max( zcfl )
  138. IF( zcfl > 0.5 ) THEN ; initad = 2 ; zusnit = 0.5_wp
  139. ELSE ; initad = 1 ; zusnit = 1.0_wp
  140. ENDIF
  141. IF( zcfl > 0.5_wp .AND. lwp ) ncfl = ncfl + 1
  142. !! IF( lwp ) THEN
  143. !! IF( ncfl > 0 ) THEN
  144. !! WRITE(cltmp,'(i6.1)') ncfl
  145. !! CALL ctl_warn( 'lim_trp: ncfl= ', TRIM(cltmp), 'advective ice time-step using a split in sub-time-step ')
  146. !! ELSE
  147. !! ! WRITE(numout,*) 'lim_trp : CFL criterion for ice advection is always smaller than 1/2 '
  148. !! ENDIF
  149. !! ENDIF
  150. !-------------------------
  151. ! transported fields
  152. !-------------------------
  153. z0opw(:,:,1) = ato_i(:,:) * e12t(:,:) ! Open water area
  154. DO jl = 1, jpl
  155. z0snw (:,:,jl) = v_s (:,:,jl) * e12t(:,:) ! Snow volume
  156. z0ice(:,:,jl) = v_i (:,:,jl) * e12t(:,:) ! Ice volume
  157. z0ai (:,:,jl) = a_i (:,:,jl) * e12t(:,:) ! Ice area
  158. z0smi (:,:,jl) = smv_i(:,:,jl) * e12t(:,:) ! Salt content
  159. z0oi (:,:,jl) = oa_i (:,:,jl) * e12t(:,:) ! Age content
  160. z0es (:,:,jl) = e_s (:,:,1,jl) * e12t(:,:) ! Snow heat content
  161. DO jk = 1, nlay_i
  162. z0ei (:,:,jk,jl) = e_i (:,:,jk,jl) * e12t(:,:) ! Ice heat content
  163. END DO
  164. END DO
  165. IF( MOD( ( kt - 1) / nn_fsbc , 2 ) == 0 ) THEN !== odd ice time step: adv_x then adv_y ==!
  166. DO jt = 1, initad
  167. CALL lim_adv_x( zusnit, u_ice, 1._wp, zsm, z0opw (:,:,1), sxopw(:,:), & !--- ice open water area
  168. & sxxopw(:,:) , syopw(:,:), syyopw(:,:), sxyopw(:,:) )
  169. CALL lim_adv_y( zusnit, v_ice, 0._wp, zsm, z0opw (:,:,1), sxopw(:,:), &
  170. & sxxopw(:,:) , syopw(:,:), syyopw(:,:), sxyopw(:,:) )
  171. DO jl = 1, jpl
  172. CALL lim_adv_x( zusnit, u_ice, 1._wp, zsm, z0ice (:,:,jl), sxice(:,:,jl), & !--- ice volume ---
  173. & sxxice(:,:,jl), syice(:,:,jl), syyice(:,:,jl), sxyice(:,:,jl) )
  174. CALL lim_adv_y( zusnit, v_ice, 0._wp, zsm, z0ice (:,:,jl), sxice(:,:,jl), &
  175. & sxxice(:,:,jl), syice(:,:,jl), syyice(:,:,jl), sxyice(:,:,jl) )
  176. CALL lim_adv_x( zusnit, u_ice, 1._wp, zsm, z0snw (:,:,jl), sxsn (:,:,jl), & !--- snow volume ---
  177. & sxxsn (:,:,jl), sysn (:,:,jl), syysn (:,:,jl), sxysn (:,:,jl) )
  178. CALL lim_adv_y( zusnit, v_ice, 0._wp, zsm, z0snw (:,:,jl), sxsn (:,:,jl), &
  179. & sxxsn (:,:,jl), sysn (:,:,jl), syysn (:,:,jl), sxysn (:,:,jl) )
  180. CALL lim_adv_x( zusnit, u_ice, 1._wp, zsm, z0smi (:,:,jl), sxsal(:,:,jl), & !--- ice salinity ---
  181. & sxxsal(:,:,jl), sysal(:,:,jl), syysal(:,:,jl), sxysal(:,:,jl) )
  182. CALL lim_adv_y( zusnit, v_ice, 0._wp, zsm, z0smi (:,:,jl), sxsal(:,:,jl), &
  183. & sxxsal(:,:,jl), sysal(:,:,jl), syysal(:,:,jl), sxysal(:,:,jl) )
  184. CALL lim_adv_x( zusnit, u_ice, 1._wp, zsm, z0oi (:,:,jl), sxage(:,:,jl), & !--- ice age ---
  185. & sxxage(:,:,jl), syage(:,:,jl), syyage(:,:,jl), sxyage(:,:,jl) )
  186. CALL lim_adv_y( zusnit, v_ice, 0._wp, zsm, z0oi (:,:,jl), sxage(:,:,jl), &
  187. & sxxage(:,:,jl), syage(:,:,jl), syyage(:,:,jl), sxyage(:,:,jl) )
  188. CALL lim_adv_x( zusnit, u_ice, 1._wp, zsm, z0ai (:,:,jl), sxa (:,:,jl), & !--- ice concentrations ---
  189. & sxxa (:,:,jl), sya (:,:,jl), syya (:,:,jl), sxya (:,:,jl) )
  190. CALL lim_adv_y( zusnit, v_ice, 0._wp, zsm, z0ai (:,:,jl), sxa (:,:,jl), &
  191. & sxxa (:,:,jl), sya (:,:,jl), syya (:,:,jl), sxya (:,:,jl) )
  192. CALL lim_adv_x( zusnit, u_ice, 1._wp, zsm, z0es (:,:,jl), sxc0 (:,:,jl), & !--- snow heat contents ---
  193. & sxxc0 (:,:,jl), syc0 (:,:,jl), syyc0 (:,:,jl), sxyc0 (:,:,jl) )
  194. CALL lim_adv_y( zusnit, v_ice, 0._wp, zsm, z0es (:,:,jl), sxc0 (:,:,jl), &
  195. & sxxc0 (:,:,jl), syc0 (:,:,jl), syyc0 (:,:,jl), sxyc0 (:,:,jl) )
  196. DO jk = 1, nlay_i !--- ice heat contents ---
  197. CALL lim_adv_x( zusnit, u_ice, 1._wp, zsm, z0ei(:,:,jk,jl), sxe (:,:,jk,jl), &
  198. & sxxe(:,:,jk,jl), sye (:,:,jk,jl), &
  199. & syye(:,:,jk,jl), sxye(:,:,jk,jl) )
  200. CALL lim_adv_y( zusnit, v_ice, 0._wp, zsm, z0ei(:,:,jk,jl), sxe (:,:,jk,jl), &
  201. & sxxe(:,:,jk,jl), sye (:,:,jk,jl), &
  202. & syye(:,:,jk,jl), sxye(:,:,jk,jl) )
  203. END DO
  204. END DO
  205. END DO
  206. ELSE
  207. DO jt = 1, initad
  208. CALL lim_adv_y( zusnit, v_ice, 1._wp, zsm, z0opw (:,:,1), sxopw(:,:), & !--- ice open water area
  209. & sxxopw(:,:) , syopw(:,:), syyopw(:,:), sxyopw(:,:) )
  210. CALL lim_adv_x( zusnit, u_ice, 0._wp, zsm, z0opw (:,:,1), sxopw(:,:), &
  211. & sxxopw(:,:) , syopw(:,:), syyopw(:,:), sxyopw(:,:) )
  212. DO jl = 1, jpl
  213. CALL lim_adv_y( zusnit, v_ice, 1._wp, zsm, z0ice (:,:,jl), sxice(:,:,jl), & !--- ice volume ---
  214. & sxxice(:,:,jl), syice(:,:,jl), syyice(:,:,jl), sxyice(:,:,jl) )
  215. CALL lim_adv_x( zusnit, u_ice, 0._wp, zsm, z0ice (:,:,jl), sxice(:,:,jl), &
  216. & sxxice(:,:,jl), syice(:,:,jl), syyice(:,:,jl), sxyice(:,:,jl) )
  217. CALL lim_adv_y( zusnit, v_ice, 1._wp, zsm, z0snw (:,:,jl), sxsn (:,:,jl), & !--- snow volume ---
  218. & sxxsn (:,:,jl), sysn (:,:,jl), syysn (:,:,jl), sxysn (:,:,jl) )
  219. CALL lim_adv_x( zusnit, u_ice, 0._wp, zsm, z0snw (:,:,jl), sxsn (:,:,jl), &
  220. & sxxsn (:,:,jl), sysn (:,:,jl), syysn (:,:,jl), sxysn (:,:,jl) )
  221. CALL lim_adv_y( zusnit, v_ice, 1._wp, zsm, z0smi (:,:,jl), sxsal(:,:,jl), & !--- ice salinity ---
  222. & sxxsal(:,:,jl), sysal(:,:,jl), syysal(:,:,jl), sxysal(:,:,jl) )
  223. CALL lim_adv_x( zusnit, u_ice, 0._wp, zsm, z0smi (:,:,jl), sxsal(:,:,jl), &
  224. & sxxsal(:,:,jl), sysal(:,:,jl), syysal(:,:,jl), sxysal(:,:,jl) )
  225. CALL lim_adv_y( zusnit, v_ice, 1._wp, zsm, z0oi (:,:,jl), sxage(:,:,jl), & !--- ice age ---
  226. & sxxage(:,:,jl), syage(:,:,jl), syyage(:,:,jl), sxyage(:,:,jl) )
  227. CALL lim_adv_x( zusnit, u_ice, 0._wp, zsm, z0oi (:,:,jl), sxage(:,:,jl), &
  228. & sxxage(:,:,jl), syage(:,:,jl), syyage(:,:,jl), sxyage(:,:,jl) )
  229. CALL lim_adv_y( zusnit, v_ice, 1._wp, zsm, z0ai (:,:,jl), sxa (:,:,jl), & !--- ice concentrations ---
  230. & sxxa (:,:,jl), sya (:,:,jl), syya (:,:,jl), sxya (:,:,jl) )
  231. CALL lim_adv_x( zusnit, u_ice, 0._wp, zsm, z0ai (:,:,jl), sxa (:,:,jl), &
  232. & sxxa (:,:,jl), sya (:,:,jl), syya (:,:,jl), sxya (:,:,jl) )
  233. CALL lim_adv_y( zusnit, v_ice, 1._wp, zsm, z0es (:,:,jl), sxc0 (:,:,jl), & !--- snow heat contents ---
  234. & sxxc0 (:,:,jl), syc0 (:,:,jl), syyc0 (:,:,jl), sxyc0 (:,:,jl) )
  235. CALL lim_adv_x( zusnit, u_ice, 0._wp, zsm, z0es (:,:,jl), sxc0 (:,:,jl), &
  236. & sxxc0 (:,:,jl), syc0 (:,:,jl), syyc0 (:,:,jl), sxyc0 (:,:,jl) )
  237. DO jk = 1, nlay_i !--- ice heat contents ---
  238. CALL lim_adv_y( zusnit, v_ice, 1._wp, zsm, z0ei(:,:,jk,jl), sxe (:,:,jk,jl), &
  239. & sxxe(:,:,jk,jl), sye (:,:,jk,jl), &
  240. & syye(:,:,jk,jl), sxye(:,:,jk,jl) )
  241. CALL lim_adv_x( zusnit, u_ice, 0._wp, zsm, z0ei(:,:,jk,jl), sxe (:,:,jk,jl), &
  242. & sxxe(:,:,jk,jl), sye (:,:,jk,jl), &
  243. & syye(:,:,jk,jl), sxye(:,:,jk,jl) )
  244. END DO
  245. END DO
  246. END DO
  247. ENDIF
  248. !-------------------------------------------
  249. ! Recover the properties from their contents
  250. !-------------------------------------------
  251. ato_i(:,:) = z0opw(:,:,1) * r1_e12t(:,:)
  252. DO jl = 1, jpl
  253. v_i (:,:,jl) = z0ice(:,:,jl) * r1_e12t(:,:)
  254. v_s (:,:,jl) = z0snw(:,:,jl) * r1_e12t(:,:)
  255. smv_i(:,:,jl) = z0smi(:,:,jl) * r1_e12t(:,:)
  256. oa_i (:,:,jl) = z0oi (:,:,jl) * r1_e12t(:,:)
  257. a_i (:,:,jl) = z0ai (:,:,jl) * r1_e12t(:,:)
  258. e_s (:,:,1,jl) = z0es (:,:,jl) * r1_e12t(:,:)
  259. DO jk = 1, nlay_i
  260. e_i(:,:,jk,jl) = z0ei(:,:,jk,jl) * r1_e12t(:,:)
  261. END DO
  262. END DO
  263. at_i(:,:) = a_i(:,:,1) ! total ice fraction
  264. DO jl = 2, jpl
  265. at_i(:,:) = at_i(:,:) + a_i(:,:,jl)
  266. END DO
  267. !------------------------------------------------------------------------------!
  268. ! Diffusion of Ice fields
  269. !------------------------------------------------------------------------------!
  270. !------------------------------------
  271. ! Diffusion of other ice variables
  272. !------------------------------------
  273. jm=1
  274. DO jl = 1, jpl
  275. ! ! Masked eddy diffusivity coefficient at ocean U- and V-points
  276. ! DO jj = 1, jpjm1 ! NB: has not to be defined on jpj line and jpi row
  277. ! DO ji = 1 , fs_jpim1 ! vector opt.
  278. ! pahu(ji,jj) = ( 1._wp - MAX( 0._wp, SIGN( 1._wp, -a_i(ji ,jj,jl) ) ) ) &
  279. ! & * ( 1._wp - MAX( 0._wp, SIGN( 1._wp, -a_i(ji+1,jj,jl) ) ) ) * ahiu(ji,jj)
  280. ! pahv(ji,jj) = ( 1._wp - MAX( 0._wp, SIGN( 1._wp, -a_i(ji,jj ,jl) ) ) ) &
  281. ! & * ( 1._wp - MAX( 0._wp, SIGN( 1._wp,- a_i(ji,jj+1,jl) ) ) ) * ahiv(ji,jj)
  282. ! END DO
  283. ! END DO
  284. DO jj = 1, jpjm1 ! NB: has not to be defined on jpj line and jpi row
  285. DO ji = 1 , fs_jpim1 ! vector opt.
  286. pahu3D(ji,jj,jl) = ( 1._wp - MAX( 0._wp, SIGN( 1._wp, -a_i(ji ,jj, jl ) ) ) ) &
  287. & * ( 1._wp - MAX( 0._wp, SIGN( 1._wp, -a_i(ji+1,jj, jl ) ) ) ) * ahiu(ji,jj)
  288. pahv3D(ji,jj,jl) = ( 1._wp - MAX( 0._wp, SIGN( 1._wp, -a_i(ji, jj, jl ) ) ) ) &
  289. & * ( 1._wp - MAX( 0._wp, SIGN( 1._wp,- a_i(ji, jj+1,jl ) ) ) ) * ahiv(ji,jj)
  290. END DO
  291. END DO
  292. zhdfptab(:,:,jm)= a_i (:,:, jl); jm = jm + 1
  293. zhdfptab(:,:,jm)= v_i (:,:, jl); jm = jm + 1
  294. zhdfptab(:,:,jm)= v_s (:,:, jl); jm = jm + 1
  295. zhdfptab(:,:,jm)= smv_i(:,:, jl); jm = jm + 1
  296. zhdfptab(:,:,jm)= oa_i (:,:, jl); jm = jm + 1
  297. zhdfptab(:,:,jm)= e_s (:,:,1,jl); jm = jm + 1
  298. ! Sample of adding more variables to apply lim_hdf using lim_hdf optimization---
  299. ! zhdfptab(:,:,jm) = variable_1 (:,:,1,jl); jm = jm + 1
  300. ! zhdfptab(:,:,jm) = variable_2 (:,:,1,jl); jm = jm + 1
  301. !
  302. ! and in this example the parameter ihdf_vars musb be changed to 8 (necessary for allocation)
  303. !----------------------------------------------------------------------------------------
  304. DO jk = 1, nlay_i
  305. zhdfptab(:,:,jm)=e_i(:,:,jk,jl); jm= jm+1
  306. END DO
  307. END DO
  308. !
  309. !--------------------------------
  310. ! diffusion of open water area
  311. !--------------------------------
  312. ! ! Masked eddy diffusivity coefficient at ocean U- and V-points
  313. !DO jj = 1, jpjm1 ! NB: has not to be defined on jpj line and jpi row
  314. ! DO ji = 1 , fs_jpim1 ! vector opt.
  315. ! pahu(ji,jj) = ( 1._wp - MAX( 0._wp, SIGN( 1._wp, -at_i(ji ,jj) ) ) ) &
  316. ! & * ( 1._wp - MAX( 0._wp, SIGN( 1._wp, -at_i(ji+1,jj) ) ) ) * ahiu(ji,jj)
  317. ! pahv(ji,jj) = ( 1._wp - MAX( 0._wp, SIGN( 1._wp, -at_i(ji,jj ) ) ) ) &
  318. ! & * ( 1._wp - MAX( 0._wp, SIGN( 1._wp,- at_i(ji,jj+1) ) ) ) * ahiv(ji,jj)
  319. ! END DO
  320. !END DO
  321. DO jj = 1, jpjm1 ! NB: has not to be defined on jpj line and jpi row
  322. DO ji = 1 , fs_jpim1 ! vector opt.
  323. pahu3D(ji,jj,jpl+1) = ( 1._wp - MAX( 0._wp, SIGN( 1._wp, -at_i(ji ,jj) ) ) ) &
  324. & * ( 1._wp - MAX( 0._wp, SIGN( 1._wp, -at_i(ji+1,jj) ) ) ) * ahiu(ji,jj)
  325. pahv3D(ji,jj,jpl+1) = ( 1._wp - MAX( 0._wp, SIGN( 1._wp, -at_i(ji,jj ) ) ) ) &
  326. & * ( 1._wp - MAX( 0._wp, SIGN( 1._wp,- at_i(ji,jj+1) ) ) ) * ahiv(ji,jj)
  327. END DO
  328. END DO
  329. !
  330. zhdfptab(:,:,jm)= ato_i (:,:);
  331. CALL lim_hdf( zhdfptab, ihdf_vars, jpl, nlay_i)
  332. jm=1
  333. DO jl = 1, jpl
  334. a_i (:,:, jl) = zhdfptab(:,:,jm); jm = jm + 1
  335. v_i (:,:, jl) = zhdfptab(:,:,jm); jm = jm + 1
  336. v_s (:,:, jl) = zhdfptab(:,:,jm); jm = jm + 1
  337. smv_i(:,:, jl) = zhdfptab(:,:,jm); jm = jm + 1
  338. oa_i (:,:, jl) = zhdfptab(:,:,jm); jm = jm + 1
  339. e_s (:,:,1,jl) = zhdfptab(:,:,jm); jm = jm + 1
  340. ! Sample of adding more variables to apply lim_hdf---------
  341. ! variable_1 (:,:,1,jl) = zhdfptab(:,:, jm ) ; jm + 1
  342. ! variable_2 (:,:,1,jl) = zhdfptab(:,:, jm ) ; jm + 1
  343. !-----------------------------------------------------------
  344. DO jk = 1, nlay_i
  345. e_i(:,:,jk,jl) = zhdfptab(:,:,jm);jm= jm + 1
  346. END DO
  347. END DO
  348. ato_i (:,:) = zhdfptab(:,:,jm)
  349. !------------------------------------------------------------------------------!
  350. ! limit ice properties after transport
  351. !------------------------------------------------------------------------------!
  352. !!gm & cr : MAX should not be active if adv scheme is positive !
  353. DO jl = 1, jpl
  354. DO jj = 1, jpj
  355. DO ji = 1, jpi
  356. v_s (ji,jj,jl) = MAX( 0._wp, v_s (ji,jj,jl) )
  357. v_i (ji,jj,jl) = MAX( 0._wp, v_i (ji,jj,jl) )
  358. smv_i(ji,jj,jl) = MAX( 0._wp, smv_i(ji,jj,jl) )
  359. oa_i (ji,jj,jl) = MAX( 0._wp, oa_i (ji,jj,jl) )
  360. a_i (ji,jj,jl) = MAX( 0._wp, a_i (ji,jj,jl) )
  361. e_s (ji,jj,1,jl) = MAX( 0._wp, e_s (ji,jj,1,jl) )
  362. END DO
  363. END DO
  364. DO jk = 1, nlay_i
  365. DO jj = 1, jpj
  366. DO ji = 1, jpi
  367. e_i(ji,jj,jk,jl) = MAX( 0._wp, e_i(ji,jj,jk,jl) )
  368. END DO
  369. END DO
  370. END DO
  371. END DO
  372. !!gm & cr
  373. ! --- diags ---
  374. DO jj = 1, jpj
  375. DO ji = 1, jpi
  376. diag_trp_ei(ji,jj) = ( SUM( e_i(ji,jj,1:nlay_i,:) ) - zeiold(ji,jj) ) * r1_rdtice
  377. diag_trp_es(ji,jj) = ( SUM( e_s(ji,jj,1:nlay_s,:) ) - zesold(ji,jj) ) * r1_rdtice
  378. diag_trp_vi (ji,jj) = SUM( v_i(ji,jj,:) - zviold(ji,jj,:) ) * r1_rdtice
  379. diag_trp_vs (ji,jj) = SUM( v_s(ji,jj,:) - zvsold(ji,jj,:) ) * r1_rdtice
  380. diag_trp_smv(ji,jj) = SUM( smv_i(ji,jj,:) - zsmvold(ji,jj,:) ) * r1_rdtice
  381. END DO
  382. END DO
  383. ! zap small areas
  384. CALL lim_var_zapsmall
  385. !--- Thickness correction in case too high --------------------------------------------------------
  386. DO jl = 1, jpl
  387. DO jj = 1, jpj
  388. DO ji = 1, jpi
  389. IF ( v_i(ji,jj,jl) > 0._wp ) THEN
  390. rswitch = MAX( 0._wp , SIGN( 1._wp, a_i(ji,jj,jl) - epsi20 ) )
  391. ht_i (ji,jj,jl) = v_i (ji,jj,jl) / MAX( a_i(ji,jj,jl) , epsi20 ) * rswitch
  392. ht_s (ji,jj,jl) = v_s (ji,jj,jl) / MAX( a_i(ji,jj,jl) , epsi20 ) * rswitch
  393. zvi = v_i (ji,jj,jl)
  394. zvs = v_s (ji,jj,jl)
  395. zsmv = smv_i(ji,jj,jl)
  396. zes = e_s (ji,jj,1,jl)
  397. zei = SUM( e_i(ji,jj,1:nlay_i,jl) )
  398. zdv = v_i(ji,jj,jl) + v_s(ji,jj,jl) - zviold(ji,jj,jl) - zvsold(ji,jj,jl)
  399. IF ( ( zdv > 0.0 .AND. (ht_i(ji,jj,jl)+ht_s(ji,jj,jl)) > zhimax(ji,jj,jl) .AND. zatold(ji,jj) < 0.80 ) .OR. &
  400. & ( zdv <= 0.0 .AND. (ht_i(ji,jj,jl)+ht_s(ji,jj,jl)) > zhimax(ji,jj,jl) ) ) THEN
  401. rswitch = MAX( 0._wp, SIGN( 1._wp, zhimax(ji,jj,jl) - epsi20 ) )
  402. a_i(ji,jj,jl) = rswitch * ( v_i(ji,jj,jl) + v_s(ji,jj,jl) ) / MAX( zhimax(ji,jj,jl), epsi20 )
  403. ! small correction due to *rswitch for a_i
  404. v_i (ji,jj,jl) = rswitch * v_i (ji,jj,jl)
  405. v_s (ji,jj,jl) = rswitch * v_s (ji,jj,jl)
  406. smv_i(ji,jj,jl) = rswitch * smv_i(ji,jj,jl)
  407. e_s(ji,jj,1,jl) = rswitch * e_s(ji,jj,1,jl)
  408. e_i(ji,jj,1:nlay_i,jl) = rswitch * e_i(ji,jj,1:nlay_i,jl)
  409. ! Update mass fluxes
  410. wfx_res(ji,jj) = wfx_res(ji,jj) - ( v_i(ji,jj,jl) - zvi ) * rhoic * r1_rdtice
  411. wfx_snw(ji,jj) = wfx_snw(ji,jj) - ( v_s(ji,jj,jl) - zvs ) * rhosn * r1_rdtice
  412. sfx_res(ji,jj) = sfx_res(ji,jj) - ( smv_i(ji,jj,jl) - zsmv ) * rhoic * r1_rdtice
  413. hfx_res(ji,jj) = hfx_res(ji,jj) + ( e_s(ji,jj,1,jl) - zes ) * r1_rdtice ! W.m-2 <0
  414. hfx_res(ji,jj) = hfx_res(ji,jj) + ( SUM( e_i(ji,jj,1:nlay_i,jl) ) - zei ) * r1_rdtice ! W.m-2 <0
  415. ENDIF
  416. ENDIF
  417. END DO
  418. END DO
  419. END DO
  420. ! -------------------------------------------------
  421. !--------------------------------------
  422. ! Impose a_i < amax in mono-category
  423. !--------------------------------------
  424. !
  425. IF ( ( nn_monocat == 2 ) .AND. ( jpl == 1 ) ) THEN ! simple conservative piling, comparable with LIM2
  426. DO jj = 1, jpj
  427. DO ji = 1, jpi
  428. a_i(ji,jj,1) = MIN( a_i(ji,jj,1), rn_amax_2d(ji,jj) )
  429. END DO
  430. END DO
  431. ENDIF
  432. ! --- agglomerate variables -----------------
  433. vt_i (:,:) = 0._wp
  434. vt_s (:,:) = 0._wp
  435. at_i (:,:) = 0._wp
  436. DO jl = 1, jpl
  437. DO jj = 1, jpj
  438. DO ji = 1, jpi
  439. vt_i(ji,jj) = vt_i(ji,jj) + v_i(ji,jj,jl)
  440. vt_s(ji,jj) = vt_s(ji,jj) + v_s(ji,jj,jl)
  441. at_i(ji,jj) = at_i(ji,jj) + a_i(ji,jj,jl)
  442. END DO
  443. END DO
  444. END DO
  445. ! --- open water = 1 if at_i=0 --------------------------------
  446. DO jj = 1, jpj
  447. DO ji = 1, jpi
  448. rswitch = MAX( 0._wp , SIGN( 1._wp, - at_i(ji,jj) ) )
  449. ato_i(ji,jj) = rswitch + (1._wp - rswitch ) * ato_i(ji,jj)
  450. END DO
  451. END DO
  452. ! conservation test
  453. IF( ln_limdiahsb ) CALL lim_cons_hsm(1, 'limtrp', zvi_b, zsmv_b, zei_b, zfw_b, zfs_b, zft_b)
  454. ENDIF
  455. ! -------------------------------------------------
  456. ! control prints
  457. ! -------------------------------------------------
  458. IF( ln_icectl ) CALL lim_prt( kt, iiceprt, jiceprt,-1, ' - ice dyn & trp - ' )
  459. !
  460. CALL wrk_dealloc( jpi,jpj, zsm, zatold, zeiold, zesold )
  461. CALL wrk_dealloc( jpi,jpj,jpl, z0ice, z0snw, z0ai, z0es , z0smi , z0oi )
  462. CALL wrk_dealloc( jpi,jpj,1, z0opw )
  463. CALL wrk_dealloc( jpi,jpj,nlay_i,jpl, z0ei )
  464. CALL wrk_dealloc( jpi,jpj,jpl, zviold, zvsold, zhimax, zsmvold )
  465. CALL wrk_dealloc( jpi,jpj,jpl*(ihdf_vars+nlay_i)+1,zhdfptab)
  466. !
  467. IF( nn_timing == 1 ) CALL timing_stop('limtrp')
  468. END SUBROUTINE lim_trp
  469. #else
  470. !!----------------------------------------------------------------------
  471. !! Default option Empty Module No sea-ice model
  472. !!----------------------------------------------------------------------
  473. CONTAINS
  474. SUBROUTINE lim_trp ! Empty routine
  475. END SUBROUTINE lim_trp
  476. #endif
  477. !!======================================================================
  478. END MODULE limtrp