limitd_th.F90 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796
  1. MODULE limitd_th
  2. !!======================================================================
  3. !! *** MODULE limitd_th ***
  4. !! LIM3 ice model : ice thickness distribution: Thermodynamics
  5. !!======================================================================
  6. !! History : - ! (W. H. Lipscomb and E.C. Hunke) CICE (c) original code
  7. !! 3.0 ! 2005-12 (M. Vancoppenolle) adaptation to LIM-3
  8. !! - ! 2006-06 (M. Vancoppenolle) adaptation to include salt, age
  9. !! - ! 2007-04 (M. Vancoppenolle) Mass conservation checked
  10. !!----------------------------------------------------------------------
  11. #if defined key_lim3
  12. !!----------------------------------------------------------------------
  13. !! 'key_lim3' : LIM3 sea-ice model
  14. !!----------------------------------------------------------------------
  15. !! lim_itd_th_rem :
  16. !! lim_itd_th_reb :
  17. !! lim_itd_fitline :
  18. !! lim_itd_shiftice :
  19. !!----------------------------------------------------------------------
  20. USE dom_ice ! LIM-3 domain
  21. USE par_oce ! ocean parameters
  22. USE dom_oce ! ocean domain
  23. USE phycst ! physical constants (ocean directory)
  24. USE thd_ice ! LIM-3 thermodynamic variables
  25. USE ice ! LIM-3 variables
  26. USE limvar ! LIM-3 variables
  27. USE prtctl ! Print control
  28. USE in_out_manager ! I/O manager
  29. USE lib_mpp ! MPP library
  30. USE wrk_nemo ! work arrays
  31. USE lib_fortran ! to use key_nosignedzero
  32. USE limcons ! conservation tests
  33. IMPLICIT NONE
  34. PRIVATE
  35. PUBLIC lim_itd_th_rem
  36. PUBLIC lim_itd_th_reb
  37. !!----------------------------------------------------------------------
  38. !! NEMO/LIM3 4.0 , UCL - NEMO Consortium (2010)
  39. !! $Id: limitd_th.F90 4990 2014-12-15 16:42:49Z timgraham $
  40. !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
  41. !!----------------------------------------------------------------------
  42. CONTAINS
  43. SUBROUTINE lim_itd_th_rem( klbnd, kubnd, kt )
  44. !!------------------------------------------------------------------
  45. !! *** ROUTINE lim_itd_th_rem ***
  46. !!
  47. !! ** Purpose : computes the redistribution of ice thickness
  48. !! after thermodynamic growth of ice thickness
  49. !!
  50. !! ** Method : Linear remapping
  51. !!
  52. !! References : W.H. Lipscomb, JGR 2001
  53. !!------------------------------------------------------------------
  54. INTEGER , INTENT (in) :: klbnd ! Start thickness category index point
  55. INTEGER , INTENT (in) :: kubnd ! End point on which the the computation is applied
  56. INTEGER , INTENT (in) :: kt ! Ocean time step
  57. !
  58. INTEGER :: ji, jj, jl ! dummy loop index
  59. INTEGER :: ii, ij ! 2D corresponding indices to ji
  60. INTEGER :: nd ! local integer
  61. REAL(wp) :: zx1, zwk1, zdh0, zetamin, zdamax ! local scalars
  62. REAL(wp) :: zx2, zwk2, zda0, zetamax ! - -
  63. REAL(wp) :: zx3
  64. CHARACTER (len = 15) :: fieldid
  65. INTEGER , POINTER, DIMENSION(:,:,:) :: zdonor ! donor category index
  66. REAL(wp), POINTER, DIMENSION(:,:,:) :: zdhice ! ice thickness increment
  67. REAL(wp), POINTER, DIMENSION(:,:,:) :: g0 ! coefficients for fitting the line of the ITD
  68. REAL(wp), POINTER, DIMENSION(:,:,:) :: g1 ! coefficients for fitting the line of the ITD
  69. REAL(wp), POINTER, DIMENSION(:,:,:) :: hL ! left boundary for the ITD for each thickness
  70. REAL(wp), POINTER, DIMENSION(:,:,:) :: hR ! left boundary for the ITD for each thickness
  71. REAL(wp), POINTER, DIMENSION(:,:,:) :: zht_i_b ! old ice thickness
  72. REAL(wp), POINTER, DIMENSION(:,:,:) :: dummy_es
  73. REAL(wp), POINTER, DIMENSION(:,:,:) :: zdaice, zdvice ! local increment of ice area and volume
  74. REAL(wp), POINTER, DIMENSION(:) :: zvetamin, zvetamax ! maximum values for etas
  75. INTEGER , POINTER, DIMENSION(:) :: nind_i, nind_j ! compressed indices for i/j directions
  76. INTEGER :: nbrem ! number of cells with ice to transfer
  77. REAL(wp) :: zslope ! used to compute local thermodynamic "speeds"
  78. REAL(wp), POINTER, DIMENSION(:,:) :: zhb0, zhb1 ! category boundaries for thinnes categories
  79. REAL(wp), POINTER, DIMENSION(:,:) :: vt_i_init, vt_i_final ! ice volume summed over categories
  80. REAL(wp), POINTER, DIMENSION(:,:) :: vt_s_init, vt_s_final ! snow volume summed over categories
  81. REAL(wp), POINTER, DIMENSION(:,:) :: et_i_init, et_i_final ! ice energy summed over categories
  82. REAL(wp), POINTER, DIMENSION(:,:) :: et_s_init, et_s_final ! snow energy summed over categories
  83. INTEGER , POINTER, DIMENSION(:,:) :: zremap_flag ! compute remapping or not ????
  84. REAL(wp), POINTER, DIMENSION(:,:,:) :: zhbnew ! new boundaries of ice categories
  85. !!------------------------------------------------------------------
  86. CALL wrk_alloc( jpi,jpj, zremap_flag )
  87. CALL wrk_alloc( jpi,jpj,jpl-1, zdonor )
  88. CALL wrk_alloc( jpi,jpj,jpl, zdhice, g0, g1, hL, hR, zht_i_b, dummy_es )
  89. CALL wrk_alloc( jpi,jpj,jpl-1, zdaice, zdvice )
  90. CALL wrk_alloc( jpi,jpj,jpl+1, zhbnew, kkstart = 0 )
  91. CALL wrk_alloc( (jpi+1)*(jpj+1), zvetamin, zvetamax )
  92. CALL wrk_alloc( (jpi+1)*(jpj+1), nind_i, nind_j )
  93. CALL wrk_alloc( jpi,jpj, zhb0,zhb1,vt_i_init,vt_i_final,vt_s_init,vt_s_final,et_i_init,et_i_final,et_s_init,et_s_final )
  94. !!----------------------------------------------------------------------------------------------
  95. !! 0) Conservation checkand changes in each ice category
  96. !!----------------------------------------------------------------------------------------------
  97. IF( con_i ) THEN
  98. CALL lim_column_sum (jpl, v_i, vt_i_init)
  99. CALL lim_column_sum (jpl, v_s, vt_s_init)
  100. CALL lim_column_sum_energy (jpl, nlay_i, e_i, et_i_init)
  101. dummy_es(:,:,:) = e_s(:,:,1,:)
  102. CALL lim_column_sum (jpl, dummy_es(:,:,:) , et_s_init)
  103. ENDIF
  104. !!----------------------------------------------------------------------------------------------
  105. !! 1) Compute thickness and changes in each ice category
  106. !!----------------------------------------------------------------------------------------------
  107. IF( kt == nit000 .AND. lwp) THEN
  108. WRITE(numout,*)
  109. WRITE(numout,*) 'lim_itd_th_rem : Remapping the ice thickness distribution'
  110. WRITE(numout,*) '~~~~~~~~~~~~~~~'
  111. WRITE(numout,*) ' klbnd : ', klbnd
  112. WRITE(numout,*) ' kubnd : ', kubnd
  113. ENDIF
  114. zdhice(:,:,:) = 0._wp
  115. DO jl = klbnd, kubnd
  116. DO jj = 1, jpj
  117. DO ji = 1, jpi
  118. rswitch = MAX( 0.0, SIGN( 1.0, a_i(ji,jj,jl) - epsi10 ) ) !0 if no ice and 1 if yes
  119. ht_i(ji,jj,jl) = v_i(ji,jj,jl) / MAX( a_i(ji,jj,jl), epsi10 ) * rswitch
  120. rswitch = MAX( 0.0, SIGN( 1.0, a_i_b(ji,jj,jl) - epsi10) )
  121. zht_i_b(ji,jj,jl) = v_i_b(ji,jj,jl) / MAX( a_i_b(ji,jj,jl), epsi10 ) * rswitch
  122. IF( a_i(ji,jj,jl) > epsi10 ) zdhice(ji,jj,jl) = ht_i(ji,jj,jl) - zht_i_b(ji,jj,jl) ! clem: useless IF statement?
  123. END DO
  124. END DO
  125. END DO
  126. !-----------------------------------------------------------------------------------------------
  127. ! 2) Compute fractional ice area in each grid cell
  128. !-----------------------------------------------------------------------------------------------
  129. at_i(:,:) = 0._wp
  130. DO jl = klbnd, kubnd
  131. at_i(:,:) = at_i(:,:) + a_i(:,:,jl)
  132. END DO
  133. !-----------------------------------------------------------------------------------------------
  134. ! 3) Identify grid cells with ice
  135. !-----------------------------------------------------------------------------------------------
  136. nbrem = 0
  137. DO jj = 1, jpj
  138. DO ji = 1, jpi
  139. IF ( at_i(ji,jj) > epsi10 ) THEN
  140. nbrem = nbrem + 1
  141. nind_i(nbrem) = ji
  142. nind_j(nbrem) = jj
  143. zremap_flag(ji,jj) = 1
  144. ELSE
  145. zremap_flag(ji,jj) = 0
  146. ENDIF
  147. END DO
  148. END DO
  149. !-----------------------------------------------------------------------------------------------
  150. ! 4) Compute new category boundaries
  151. !-----------------------------------------------------------------------------------------------
  152. !- 4.1 Compute category boundaries
  153. zhbnew(:,:,:) = 0._wp
  154. DO jl = klbnd, kubnd - 1
  155. DO ji = 1, nbrem
  156. ii = nind_i(ji)
  157. ij = nind_j(ji)
  158. !
  159. zhbnew(ii,ij,jl) = hi_max(jl)
  160. IF ( a_i_b(ii,ij,jl) > epsi10 .AND. a_i_b(ii,ij,jl+1) > epsi10 ) THEN
  161. !interpolate between adjacent category growth rates
  162. zslope = ( zdhice(ii,ij,jl+1) - zdhice(ii,ij,jl) ) / ( zht_i_b(ii,ij,jl+1) - zht_i_b(ii,ij,jl) )
  163. zhbnew(ii,ij,jl) = hi_max(jl) + zdhice(ii,ij,jl) + zslope * ( hi_max(jl) - zht_i_b(ii,ij,jl) )
  164. ELSEIF( a_i_b(ii,ij,jl) > epsi10) THEN
  165. zhbnew(ii,ij,jl) = hi_max(jl) + zdhice(ii,ij,jl)
  166. ELSEIF( a_i_b(ii,ij,jl+1) > epsi10) THEN
  167. zhbnew(ii,ij,jl) = hi_max(jl) + zdhice(ii,ij,jl+1)
  168. ENDIF
  169. END DO
  170. !- 4.2 Check that each zhbnew lies between adjacent values of ice thickness
  171. DO ji = 1, nbrem
  172. ii = nind_i(ji)
  173. ij = nind_j(ji)
  174. ! clem: we do not want ht_i to be too close to either HR or HL otherwise a division by nearly 0 is possible
  175. ! in lim_itd_fitline in the case (HR-HL) = 3(Hice - HL) or = 3(HR - Hice)
  176. IF ( a_i(ii,ij,jl ) > epsi10 .AND. ht_i(ii,ij,jl ) > ( zhbnew(ii,ij,jl) - epsi10 ) ) THEN
  177. zremap_flag(ii,ij) = 0
  178. ELSEIF( a_i(ii,ij,jl+1) > epsi10 .AND. ht_i(ii,ij,jl+1) < ( zhbnew(ii,ij,jl) + epsi10 ) ) THEN
  179. zremap_flag(ii,ij) = 0
  180. ENDIF
  181. !- 4.3 Check that each zhbnew does not exceed maximal values hi_max
  182. IF( zhbnew(ii,ij,jl) < hi_max(jl-1) ) zremap_flag(ii,ij) = 0
  183. IF( zhbnew(ii,ij,jl) > hi_max(jl+1) ) zremap_flag(ii,ij) = 0
  184. ! clem bug: why is not the following instead?
  185. !!IF( zhbnew(ii,ij,jl) < hi_max(jl-1) ) zremap_flag(ii,ij) = 0
  186. !!IF( zhbnew(ii,ij,jl) > hi_max(jl ) ) zremap_flag(ii,ij) = 0
  187. END DO
  188. END DO
  189. !-----------------------------------------------------------------------------------------------
  190. ! 5) Identify cells where ITD is to be remapped
  191. !-----------------------------------------------------------------------------------------------
  192. nbrem = 0
  193. DO jj = 1, jpj
  194. DO ji = 1, jpi
  195. IF( zremap_flag(ji,jj) == 1 ) THEN
  196. nbrem = nbrem + 1
  197. nind_i(nbrem) = ji
  198. nind_j(nbrem) = jj
  199. ENDIF
  200. END DO
  201. END DO
  202. !-----------------------------------------------------------------------------------------------
  203. ! 6) Fill arrays with lowermost / uppermost boundaries of 'new' categories
  204. !-----------------------------------------------------------------------------------------------
  205. DO jj = 1, jpj
  206. DO ji = 1, jpi
  207. zhb0(ji,jj) = hi_max(0)
  208. zhb1(ji,jj) = hi_max(1)
  209. IF( a_i(ji,jj,kubnd) > epsi10 ) THEN
  210. zhbnew(ji,jj,kubnd) = MAX( hi_max(kubnd-1), 3._wp * ht_i(ji,jj,kubnd) - 2._wp * zhbnew(ji,jj,kubnd-1) )
  211. ELSE
  212. !clem bug zhbnew(ji,jj,kubnd) = hi_max(kubnd)
  213. zhbnew(ji,jj,kubnd) = hi_max(kubnd-1) ! not used anyway
  214. ENDIF
  215. ! clem: we do not want ht_i_b to be too close to either HR or HL otherwise a division by nearly 0 is possible
  216. ! in lim_itd_fitline in the case (HR-HL) = 3(Hice - HL) or = 3(HR - Hice)
  217. IF ( zht_i_b(ji,jj,klbnd) < ( zhb0(ji,jj) + epsi10 ) ) THEN
  218. zremap_flag(ji,jj) = 0
  219. ELSEIF( zht_i_b(ji,jj,klbnd) > ( zhb1(ji,jj) - epsi10 ) ) THEN
  220. zremap_flag(ji,jj) = 0
  221. ENDIF
  222. END DO
  223. END DO
  224. !-----------------------------------------------------------------------------------------------
  225. ! 7) Compute g(h)
  226. !-----------------------------------------------------------------------------------------------
  227. !- 7.1 g(h) for category 1 at start of time step
  228. CALL lim_itd_fitline( klbnd, zhb0, zhb1, zht_i_b(:,:,klbnd), g0(:,:,klbnd), g1(:,:,klbnd), hL(:,:,klbnd), &
  229. & hR(:,:,klbnd), zremap_flag )
  230. !- 7.2 Area lost due to melting of thin ice (first category, klbnd)
  231. DO ji = 1, nbrem
  232. ii = nind_i(ji)
  233. ij = nind_j(ji)
  234. IF( a_i(ii,ij,klbnd) > epsi10 ) THEN
  235. zdh0 = zdhice(ii,ij,klbnd) !decrease of ice thickness in the lower category
  236. IF( zdh0 < 0.0 ) THEN !remove area from category 1
  237. zdh0 = MIN( -zdh0, hi_max(klbnd) )
  238. !Integrate g(1) from 0 to dh0 to estimate area melted
  239. zetamax = MIN( zdh0, hR(ii,ij,klbnd) ) - hL(ii,ij,klbnd)
  240. IF( zetamax > 0.0 ) THEN
  241. zx1 = zetamax
  242. zx2 = 0.5 * zetamax * zetamax
  243. zda0 = g1(ii,ij,klbnd) * zx2 + g0(ii,ij,klbnd) * zx1 ! ice area removed
  244. zdamax = a_i(ii,ij,klbnd) * (1.0 - ht_i(ii,ij,klbnd) / zht_i_b(ii,ij,klbnd) ) ! Constrain new thickness <= ht_i
  245. zda0 = MIN( zda0, zdamax ) ! ice area lost due to melting
  246. ! of thin ice (zdamax > 0)
  247. ! Remove area, conserving volume
  248. ht_i(ii,ij,klbnd) = ht_i(ii,ij,klbnd) * a_i(ii,ij,klbnd) / ( a_i(ii,ij,klbnd) - zda0 )
  249. a_i(ii,ij,klbnd) = a_i(ii,ij,klbnd) - zda0
  250. v_i(ii,ij,klbnd) = a_i(ii,ij,klbnd) * ht_i(ii,ij,klbnd) ! clem-useless ?
  251. ENDIF
  252. ELSE ! if ice accretion zdh0 > 0
  253. ! zhbnew was 0, and is shifted to the right to account for thin ice growth in openwater (F0 = f1)
  254. zhbnew(ii,ij,klbnd-1) = MIN( zdh0, hi_max(klbnd) )
  255. ENDIF
  256. ENDIF
  257. END DO
  258. !- 7.3 g(h) for each thickness category
  259. DO jl = klbnd, kubnd
  260. CALL lim_itd_fitline( jl, zhbnew(:,:,jl-1), zhbnew(:,:,jl), ht_i(:,:,jl), &
  261. & g0(:,:,jl), g1(:,:,jl), hL(:,:,jl), hR(:,:,jl), zremap_flag )
  262. END DO
  263. !-----------------------------------------------------------------------------------------------
  264. ! 8) Compute area and volume to be shifted across each boundary
  265. !-----------------------------------------------------------------------------------------------
  266. DO jl = klbnd, kubnd - 1
  267. DO jj = 1, jpj
  268. DO ji = 1, jpi
  269. zdonor(ji,jj,jl) = 0
  270. zdaice(ji,jj,jl) = 0.0
  271. zdvice(ji,jj,jl) = 0.0
  272. END DO
  273. END DO
  274. DO ji = 1, nbrem
  275. ii = nind_i(ji)
  276. ij = nind_j(ji)
  277. IF (zhbnew(ii,ij,jl) > hi_max(jl)) THEN ! transfer from jl to jl+1
  278. ! left and right integration limits in eta space
  279. zvetamin(ji) = MAX( hi_max(jl), hL(ii,ij,jl) ) - hL(ii,ij,jl)
  280. zvetamax(ji) = MIN( zhbnew(ii,ij,jl), hR(ii,ij,jl) ) - hL(ii,ij,jl)
  281. zdonor(ii,ij,jl) = jl
  282. ELSE ! zhbnew(jl) <= hi_max(jl) ; transfer from jl+1 to jl
  283. ! left and right integration limits in eta space
  284. zvetamin(ji) = 0.0
  285. zvetamax(ji) = MIN( hi_max(jl), hR(ii,ij,jl+1) ) - hL(ii,ij,jl+1)
  286. zdonor(ii,ij,jl) = jl + 1
  287. ENDIF
  288. zetamax = MAX( zvetamax(ji), zvetamin(ji) ) ! no transfer if etamax < etamin
  289. zetamin = zvetamin(ji)
  290. zx1 = zetamax - zetamin
  291. zwk1 = zetamin * zetamin
  292. zwk2 = zetamax * zetamax
  293. zx2 = 0.5 * ( zwk2 - zwk1 )
  294. zwk1 = zwk1 * zetamin
  295. zwk2 = zwk2 * zetamax
  296. zx3 = 1.0 / 3.0 * ( zwk2 - zwk1 )
  297. nd = zdonor(ii,ij,jl)
  298. zdaice(ii,ij,jl) = g1(ii,ij,nd)*zx2 + g0(ii,ij,nd)*zx1
  299. zdvice(ii,ij,jl) = g1(ii,ij,nd)*zx3 + g0(ii,ij,nd)*zx2 + zdaice(ii,ij,jl)*hL(ii,ij,nd)
  300. END DO
  301. END DO
  302. !!----------------------------------------------------------------------------------------------
  303. !! 9) Shift ice between categories
  304. !!----------------------------------------------------------------------------------------------
  305. CALL lim_itd_shiftice ( klbnd, kubnd, zdonor, zdaice, zdvice )
  306. !!----------------------------------------------------------------------------------------------
  307. !! 10) Make sure ht_i >= minimum ice thickness hi_min
  308. !!----------------------------------------------------------------------------------------------
  309. DO ji = 1, nbrem
  310. ii = nind_i(ji)
  311. ij = nind_j(ji)
  312. IF ( a_i(ii,ij,1) > epsi10 .AND. ht_i(ii,ij,1) < rn_himin ) THEN
  313. a_i (ii,ij,1) = a_i(ii,ij,1) * ht_i(ii,ij,1) / rn_himin
  314. ht_i(ii,ij,1) = rn_himin
  315. ENDIF
  316. END DO
  317. !!----------------------------------------------------------------------------------------------
  318. !! 11) Conservation check
  319. !!----------------------------------------------------------------------------------------------
  320. IF ( con_i ) THEN
  321. CALL lim_column_sum (jpl, v_i, vt_i_final)
  322. fieldid = ' v_i : limitd_th '
  323. CALL lim_cons_check (vt_i_init, vt_i_final, 1.0e-6, fieldid)
  324. CALL lim_column_sum_energy (jpl, nlay_i, e_i, et_i_final)
  325. fieldid = ' e_i : limitd_th '
  326. CALL lim_cons_check (et_i_init, et_i_final, 1.0e-3, fieldid)
  327. CALL lim_column_sum (jpl, v_s, vt_s_final)
  328. fieldid = ' v_s : limitd_th '
  329. CALL lim_cons_check (vt_s_init, vt_s_final, 1.0e-6, fieldid)
  330. dummy_es(:,:,:) = e_s(:,:,1,:)
  331. CALL lim_column_sum (jpl, dummy_es(:,:,:) , et_s_final)
  332. fieldid = ' e_s : limitd_th '
  333. CALL lim_cons_check (et_s_init, et_s_final, 1.0e-3, fieldid)
  334. ENDIF
  335. CALL wrk_dealloc( jpi,jpj, zremap_flag )
  336. CALL wrk_dealloc( jpi,jpj,jpl-1, zdonor )
  337. CALL wrk_dealloc( jpi,jpj,jpl, zdhice, g0, g1, hL, hR, zht_i_b, dummy_es )
  338. CALL wrk_dealloc( jpi,jpj,jpl-1, zdaice, zdvice )
  339. CALL wrk_dealloc( jpi,jpj,jpl+1, zhbnew, kkstart = 0 )
  340. CALL wrk_dealloc( (jpi+1)*(jpj+1), zvetamin, zvetamax )
  341. CALL wrk_dealloc( (jpi+1)*(jpj+1), nind_i, nind_j )
  342. CALL wrk_dealloc( jpi,jpj, zhb0,zhb1,vt_i_init,vt_i_final,vt_s_init,vt_s_final,et_i_init,et_i_final,et_s_init,et_s_final )
  343. END SUBROUTINE lim_itd_th_rem
  344. SUBROUTINE lim_itd_fitline( num_cat, HbL, Hbr, hice, g0, g1, hL, hR, zremap_flag )
  345. !!------------------------------------------------------------------
  346. !! *** ROUTINE lim_itd_fitline ***
  347. !!
  348. !! ** Purpose : fit g(h) with a line using area, volume constraints
  349. !!
  350. !! ** Method : Fit g(h) with a line, satisfying area and volume constraints.
  351. !! To reduce roundoff errors caused by large values of g0 and g1,
  352. !! we actually compute g(eta), where eta = h - hL, and hL is the
  353. !! left boundary.
  354. !!------------------------------------------------------------------
  355. INTEGER , INTENT(in ) :: num_cat ! category index
  356. REAL(wp), DIMENSION(jpi,jpj), INTENT(in ) :: HbL, HbR ! left and right category boundaries
  357. REAL(wp), DIMENSION(jpi,jpj), INTENT(in ) :: hice ! ice thickness
  358. REAL(wp), DIMENSION(jpi,jpj), INTENT( out) :: g0, g1 ! coefficients in linear equation for g(eta)
  359. REAL(wp), DIMENSION(jpi,jpj), INTENT( out) :: hL ! min value of range over which g(h) > 0
  360. REAL(wp), DIMENSION(jpi,jpj), INTENT( out) :: hR ! max value of range over which g(h) > 0
  361. INTEGER , DIMENSION(jpi,jpj), INTENT(in ) :: zremap_flag !
  362. !
  363. INTEGER :: ji,jj ! horizontal indices
  364. REAL(wp) :: zh13 ! HbL + 1/3 * (HbR - HbL)
  365. REAL(wp) :: zh23 ! HbL + 2/3 * (HbR - HbL)
  366. REAL(wp) :: zdhr ! 1 / (hR - hL)
  367. REAL(wp) :: zwk1, zwk2 ! temporary variables
  368. !!------------------------------------------------------------------
  369. !
  370. DO jj = 1, jpj
  371. DO ji = 1, jpi
  372. !
  373. IF( zremap_flag(ji,jj) == 1 .AND. a_i(ji,jj,num_cat) > epsi10 &
  374. & .AND. hice(ji,jj) > 0._wp ) THEN
  375. ! Initialize hL and hR
  376. hL(ji,jj) = HbL(ji,jj)
  377. hR(ji,jj) = HbR(ji,jj)
  378. ! Change hL or hR if hice falls outside central third of range
  379. zh13 = 1.0 / 3.0 * ( 2.0 * hL(ji,jj) + hR(ji,jj) )
  380. zh23 = 1.0 / 3.0 * ( hL(ji,jj) + 2.0 * hR(ji,jj) )
  381. IF ( hice(ji,jj) < zh13 ) THEN ; hR(ji,jj) = 3._wp * hice(ji,jj) - 2._wp * hL(ji,jj)
  382. ELSEIF( hice(ji,jj) > zh23 ) THEN ; hL(ji,jj) = 3._wp * hice(ji,jj) - 2._wp * hR(ji,jj)
  383. ENDIF
  384. ! Compute coefficients of g(eta) = g0 + g1*eta
  385. zdhr = 1._wp / (hR(ji,jj) - hL(ji,jj))
  386. zwk1 = 6._wp * a_i(ji,jj,num_cat) * zdhr
  387. zwk2 = ( hice(ji,jj) - hL(ji,jj) ) * zdhr
  388. g0(ji,jj) = zwk1 * ( 2._wp / 3._wp - zwk2 )
  389. g1(ji,jj) = 2._wp * zdhr * zwk1 * ( zwk2 - 0.5 )
  390. !
  391. ELSE ! remap_flag = .false. or a_i < epsi10
  392. hL(ji,jj) = 0._wp
  393. hR(ji,jj) = 0._wp
  394. g0(ji,jj) = 0._wp
  395. g1(ji,jj) = 0._wp
  396. ENDIF
  397. !
  398. END DO
  399. END DO
  400. !
  401. END SUBROUTINE lim_itd_fitline
  402. SUBROUTINE lim_itd_shiftice( klbnd, kubnd, zdonor, zdaice, zdvice )
  403. !!------------------------------------------------------------------
  404. !! *** ROUTINE lim_itd_shiftice ***
  405. !!
  406. !! ** Purpose : shift ice across category boundaries, conserving everything
  407. !! ( area, volume, energy, age*vol, and mass of salt )
  408. !!
  409. !! ** Method :
  410. !!------------------------------------------------------------------
  411. INTEGER , INTENT(in ) :: klbnd ! Start thickness category index point
  412. INTEGER , INTENT(in ) :: kubnd ! End point on which the the computation is applied
  413. INTEGER , DIMENSION(jpi,jpj,jpl-1), INTENT(in ) :: zdonor ! donor category index
  414. REAL(wp), DIMENSION(jpi,jpj,jpl-1), INTENT(inout) :: zdaice ! ice area transferred across boundary
  415. REAL(wp), DIMENSION(jpi,jpj,jpl-1), INTENT(inout) :: zdvice ! ice volume transferred across boundary
  416. INTEGER :: ji, jj, jl, jl2, jl1, jk ! dummy loop indices
  417. INTEGER :: ii, ij ! indices when changing from 2D-1D is done
  418. REAL(wp), POINTER, DIMENSION(:,:,:) :: zaTsfn
  419. REAL(wp), POINTER, DIMENSION(:,:) :: zworka ! temporary array used here
  420. REAL(wp) :: zdvsnow, zdesnow ! snow volume and energy transferred
  421. REAL(wp) :: zdeice ! ice energy transferred
  422. REAL(wp) :: zdsm_vice ! ice salinity times volume transferred
  423. REAL(wp) :: zdo_aice ! ice age times volume transferred
  424. REAL(wp) :: zdaTsf ! aicen*Tsfcn transferred
  425. INTEGER, POINTER, DIMENSION(:) :: nind_i, nind_j ! compressed indices for i/j directions
  426. INTEGER :: nbrem ! number of cells with ice to transfer
  427. !!------------------------------------------------------------------
  428. CALL wrk_alloc( jpi,jpj,jpl, zaTsfn )
  429. CALL wrk_alloc( jpi,jpj, zworka )
  430. CALL wrk_alloc( (jpi+1)*(jpj+1), nind_i, nind_j )
  431. !----------------------------------------------------------------------------------------------
  432. ! 1) Define a variable equal to a_i*T_su
  433. !----------------------------------------------------------------------------------------------
  434. DO jl = klbnd, kubnd
  435. zaTsfn(:,:,jl) = a_i(:,:,jl) * t_su(:,:,jl)
  436. END DO
  437. !-------------------------------------------------------------------------------
  438. ! 2) Transfer volume and energy between categories
  439. !-------------------------------------------------------------------------------
  440. DO jl = klbnd, kubnd - 1
  441. nbrem = 0
  442. DO jj = 1, jpj
  443. DO ji = 1, jpi
  444. IF (zdaice(ji,jj,jl) > 0.0 ) THEN ! daice(n) can be < puny
  445. nbrem = nbrem + 1
  446. nind_i(nbrem) = ji
  447. nind_j(nbrem) = jj
  448. ENDIF
  449. END DO
  450. END DO
  451. DO ji = 1, nbrem
  452. ii = nind_i(ji)
  453. ij = nind_j(ji)
  454. jl1 = zdonor(ii,ij,jl)
  455. rswitch = MAX( 0._wp , SIGN( 1._wp , v_i(ii,ij,jl1) - epsi10 ) )
  456. zworka(ii,ij) = zdvice(ii,ij,jl) / MAX( v_i(ii,ij,jl1), epsi10 ) * rswitch
  457. IF( jl1 == jl) THEN ; jl2 = jl1+1
  458. ELSE ; jl2 = jl
  459. ENDIF
  460. !--------------
  461. ! Ice areas
  462. !--------------
  463. a_i(ii,ij,jl1) = a_i(ii,ij,jl1) - zdaice(ii,ij,jl)
  464. a_i(ii,ij,jl2) = a_i(ii,ij,jl2) + zdaice(ii,ij,jl)
  465. !--------------
  466. ! Ice volumes
  467. !--------------
  468. v_i(ii,ij,jl1) = v_i(ii,ij,jl1) - zdvice(ii,ij,jl)
  469. v_i(ii,ij,jl2) = v_i(ii,ij,jl2) + zdvice(ii,ij,jl)
  470. !--------------
  471. ! Snow volumes
  472. !--------------
  473. zdvsnow = v_s(ii,ij,jl1) * zworka(ii,ij)
  474. v_s(ii,ij,jl1) = v_s(ii,ij,jl1) - zdvsnow
  475. v_s(ii,ij,jl2) = v_s(ii,ij,jl2) + zdvsnow
  476. !--------------------
  477. ! Snow heat content
  478. !--------------------
  479. zdesnow = e_s(ii,ij,1,jl1) * zworka(ii,ij)
  480. e_s(ii,ij,1,jl1) = e_s(ii,ij,1,jl1) - zdesnow
  481. e_s(ii,ij,1,jl2) = e_s(ii,ij,1,jl2) + zdesnow
  482. !--------------
  483. ! Ice age
  484. !--------------
  485. zdo_aice = oa_i(ii,ij,jl1) * zdaice(ii,ij,jl)
  486. oa_i(ii,ij,jl1) = oa_i(ii,ij,jl1) - zdo_aice
  487. oa_i(ii,ij,jl2) = oa_i(ii,ij,jl2) + zdo_aice
  488. !--------------
  489. ! Ice salinity
  490. !--------------
  491. zdsm_vice = smv_i(ii,ij,jl1) * zworka(ii,ij)
  492. smv_i(ii,ij,jl1) = smv_i(ii,ij,jl1) - zdsm_vice
  493. smv_i(ii,ij,jl2) = smv_i(ii,ij,jl2) + zdsm_vice
  494. !---------------------
  495. ! Surface temperature
  496. !---------------------
  497. zdaTsf = t_su(ii,ij,jl1) * zdaice(ii,ij,jl)
  498. zaTsfn(ii,ij,jl1) = zaTsfn(ii,ij,jl1) - zdaTsf
  499. zaTsfn(ii,ij,jl2) = zaTsfn(ii,ij,jl2) + zdaTsf
  500. END DO
  501. !------------------
  502. ! Ice heat content
  503. !------------------
  504. DO jk = 1, nlay_i
  505. DO ji = 1, nbrem
  506. ii = nind_i(ji)
  507. ij = nind_j(ji)
  508. jl1 = zdonor(ii,ij,jl)
  509. IF (jl1 == jl) THEN
  510. jl2 = jl+1
  511. ELSE ! n1 = n+1
  512. jl2 = jl
  513. ENDIF
  514. zdeice = e_i(ii,ij,jk,jl1) * zworka(ii,ij)
  515. e_i(ii,ij,jk,jl1) = e_i(ii,ij,jk,jl1) - zdeice
  516. e_i(ii,ij,jk,jl2) = e_i(ii,ij,jk,jl2) + zdeice
  517. END DO
  518. END DO
  519. END DO ! boundaries, 1 to ncat-1
  520. !-----------------------------------------------------------------
  521. ! Update ice thickness and temperature
  522. !-----------------------------------------------------------------
  523. DO jl = klbnd, kubnd
  524. DO jj = 1, jpj
  525. DO ji = 1, jpi
  526. IF ( a_i(ji,jj,jl) > epsi10 ) THEN
  527. ht_i(ji,jj,jl) = v_i (ji,jj,jl) / a_i(ji,jj,jl)
  528. t_su(ji,jj,jl) = zaTsfn(ji,jj,jl) / a_i(ji,jj,jl)
  529. ELSE
  530. ht_i(ji,jj,jl) = 0._wp
  531. t_su(ji,jj,jl) = rt0
  532. ENDIF
  533. END DO
  534. END DO
  535. END DO
  536. !
  537. CALL wrk_dealloc( jpi,jpj,jpl, zaTsfn )
  538. CALL wrk_dealloc( jpi,jpj, zworka )
  539. CALL wrk_dealloc( (jpi+1)*(jpj+1), nind_i, nind_j )
  540. !
  541. END SUBROUTINE lim_itd_shiftice
  542. SUBROUTINE lim_itd_th_reb( klbnd, kubnd )
  543. !!------------------------------------------------------------------
  544. !! *** ROUTINE lim_itd_th_reb ***
  545. !!
  546. !! ** Purpose : rebin - rebins thicknesses into defined categories
  547. !!
  548. !! ** Method :
  549. !!------------------------------------------------------------------
  550. INTEGER , INTENT (in) :: klbnd ! Start thickness category index point
  551. INTEGER , INTENT (in) :: kubnd ! End point on which the the computation is applied
  552. !
  553. INTEGER :: ji,jj, jl ! dummy loop indices
  554. INTEGER :: zshiftflag ! = .true. if ice must be shifted
  555. CHARACTER (len = 15) :: fieldid
  556. INTEGER , POINTER, DIMENSION(:,:,:) :: zdonor ! donor category index
  557. REAL(wp), POINTER, DIMENSION(:,:,:) :: zdaice, zdvice ! ice area and volume transferred
  558. REAL(wp), POINTER, DIMENSION(:,:) :: vt_i_init, vt_i_final ! ice volume summed over categories
  559. REAL(wp), POINTER, DIMENSION(:,:) :: vt_s_init, vt_s_final ! snow volume summed over categories
  560. !!------------------------------------------------------------------
  561. CALL wrk_alloc( jpi,jpj,jpl, zdonor ) ! interger
  562. CALL wrk_alloc( jpi,jpj,jpl, zdaice, zdvice )
  563. CALL wrk_alloc( jpi,jpj, vt_i_init, vt_i_final, vt_s_init, vt_s_final )
  564. !
  565. IF( con_i ) THEN ! conservation check
  566. CALL lim_column_sum (jpl, v_i, vt_i_init)
  567. CALL lim_column_sum (jpl, v_s, vt_s_init)
  568. ENDIF
  569. !
  570. !------------------------------------------------------------------------------
  571. ! 1) Compute ice thickness.
  572. !------------------------------------------------------------------------------
  573. DO jl = klbnd, kubnd
  574. DO jj = 1, jpj
  575. DO ji = 1, jpi
  576. rswitch = MAX( 0._wp , SIGN( 1._wp, a_i(ji,jj,jl) - epsi10 ) )
  577. ht_i(ji,jj,jl) = v_i (ji,jj,jl) / MAX( a_i(ji,jj,jl) , epsi10 ) * rswitch
  578. END DO
  579. END DO
  580. END DO
  581. !------------------------------------------------------------------------------
  582. ! 2) If a category thickness is not in bounds, shift the
  583. ! entire area, volume, and energy to the neighboring category
  584. !------------------------------------------------------------------------------
  585. !-------------------------
  586. ! Initialize shift arrays
  587. !-------------------------
  588. DO jl = klbnd, kubnd
  589. zdonor(:,:,jl) = 0
  590. zdaice(:,:,jl) = 0._wp
  591. zdvice(:,:,jl) = 0._wp
  592. END DO
  593. !-------------------------
  594. ! Move thin categories up
  595. !-------------------------
  596. DO jl = klbnd, kubnd - 1 ! loop over category boundaries
  597. !---------------------------------------
  598. ! identify thicknesses that are too big
  599. !---------------------------------------
  600. zshiftflag = 0
  601. DO jj = 1, jpj
  602. DO ji = 1, jpi
  603. IF( a_i(ji,jj,jl) > epsi10 .AND. ht_i(ji,jj,jl) > hi_max(jl) ) THEN
  604. zshiftflag = 1
  605. zdonor(ji,jj,jl) = jl
  606. ! begin TECLIM change
  607. !zdaice(ji,jj,jl) = a_i(ji,jj,jl) * 0.5_wp
  608. !zdvice(ji,jj,jl) = v_i(ji,jj,jl)-zdaice(ji,jj,jl)*(hi_max(jl)+hi_max(jl-1)) * 0.5_wp
  609. ! end TECLIM change
  610. ! clem: how much of a_i you send in cat sup is somewhat arbitrary
  611. zdaice(ji,jj,jl) = a_i(ji,jj,jl) * ( ht_i(ji,jj,jl) - hi_max(jl) + epsi20 ) / ht_i(ji,jj,jl)
  612. zdvice(ji,jj,jl) = v_i(ji,jj,jl) - ( a_i(ji,jj,jl) - zdaice(ji,jj,jl) ) * ( hi_max(jl) - epsi20 )
  613. ENDIF
  614. END DO
  615. END DO
  616. IF(lk_mpp) CALL mpp_max( zshiftflag )
  617. IF( zshiftflag == 1 ) THEN ! Shift ice between categories
  618. CALL lim_itd_shiftice( klbnd, kubnd, zdonor, zdaice, zdvice )
  619. ! Reset shift parameters
  620. zdonor(:,:,jl) = 0
  621. zdaice(:,:,jl) = 0._wp
  622. zdvice(:,:,jl) = 0._wp
  623. ENDIF
  624. !
  625. END DO
  626. !----------------------------
  627. ! Move thick categories down
  628. !----------------------------
  629. DO jl = kubnd - 1, 1, -1 ! loop over category boundaries
  630. !-----------------------------------------
  631. ! Identify thicknesses that are too small
  632. !-----------------------------------------
  633. zshiftflag = 0
  634. DO jj = 1, jpj
  635. DO ji = 1, jpi
  636. IF( a_i(ji,jj,jl+1) > epsi10 .AND. ht_i(ji,jj,jl+1) <= hi_max(jl) ) THEN
  637. !
  638. zshiftflag = 1
  639. zdonor(ji,jj,jl) = jl + 1
  640. zdaice(ji,jj,jl) = a_i(ji,jj,jl+1)
  641. zdvice(ji,jj,jl) = v_i(ji,jj,jl+1)
  642. ENDIF
  643. END DO
  644. END DO
  645. IF(lk_mpp) CALL mpp_max( zshiftflag )
  646. IF( zshiftflag == 1 ) THEN ! Shift ice between categories
  647. CALL lim_itd_shiftice( klbnd, kubnd, zdonor, zdaice, zdvice )
  648. ! Reset shift parameters
  649. zdonor(:,:,jl) = 0
  650. zdaice(:,:,jl) = 0._wp
  651. zdvice(:,:,jl) = 0._wp
  652. ENDIF
  653. END DO
  654. !------------------------------------------------------------------------------
  655. ! 3) Conservation check
  656. !------------------------------------------------------------------------------
  657. IF( con_i ) THEN
  658. CALL lim_column_sum (jpl, v_i, vt_i_final)
  659. fieldid = ' v_i : limitd_reb '
  660. CALL lim_cons_check (vt_i_init, vt_i_final, 1.0e-6, fieldid)
  661. CALL lim_column_sum (jpl, v_s, vt_s_final)
  662. fieldid = ' v_s : limitd_reb '
  663. CALL lim_cons_check (vt_s_init, vt_s_final, 1.0e-6, fieldid)
  664. ENDIF
  665. !
  666. CALL wrk_dealloc( jpi,jpj,jpl, zdonor )
  667. CALL wrk_dealloc( jpi,jpj,jpl, zdaice, zdvice )
  668. CALL wrk_dealloc( jpi,jpj, vt_i_init, vt_i_final, vt_s_init, vt_s_final )
  669. END SUBROUTINE lim_itd_th_reb
  670. #else
  671. !!----------------------------------------------------------------------
  672. !! Default option Dummy module NO LIM sea-ice model
  673. !!----------------------------------------------------------------------
  674. CONTAINS
  675. SUBROUTINE lim_itd_th_rem
  676. END SUBROUTINE lim_itd_th_rem
  677. SUBROUTINE lim_itd_fitline
  678. END SUBROUTINE lim_itd_fitline
  679. SUBROUTINE lim_itd_shiftice
  680. END SUBROUTINE lim_itd_shiftice
  681. SUBROUTINE lim_itd_th_reb
  682. END SUBROUTINE lim_itd_th_reb
  683. #endif
  684. !!======================================================================
  685. END MODULE limitd_th