New URL for NEMO forge!   http://forge.nemo-ocean.eu

Since March 2022 along with NEMO 4.2 release, the code development moved to a self-hosted GitLab.
This present forge is now archived and remained online for history.
limthd_lac.F90 in branches/2017/dev_r8183_ICEMODEL/NEMOGCM/NEMO/LIM_SRC_3 – NEMO

source: branches/2017/dev_r8183_ICEMODEL/NEMOGCM/NEMO/LIM_SRC_3/limthd_lac.F90 @ 8327

Last change on this file since 8327 was 8327, checked in by clem, 7 years ago

STEP4 (3): put all thermodynamics in 1D (limthd_da OK)

  • Property svn:keywords set to Id
File size: 24.7 KB
Line 
1MODULE limthd_lac
2   !!======================================================================
3   !!                       ***  MODULE limthd_lac   ***
4   !!                lateral thermodynamic growth of the ice
5   !!======================================================================
6   !! History :  LIM  ! 2005-12 (M. Vancoppenolle)  Original code
7   !!             -   ! 2006-01 (M. Vancoppenolle)  add ITD
8   !!            3.0  ! 2007-07 (M. Vancoppenolle)  Mass and energy conservation tested
9   !!            4.0  ! 2011-02 (G. Madec) dynamical allocation
10   !!----------------------------------------------------------------------
11#if defined key_lim3
12   !!----------------------------------------------------------------------
13   !!   'key_lim3'                                      LIM3 sea-ice model
14   !!----------------------------------------------------------------------
15   !!   lim_lat_acr   : lateral accretion of ice
16   !!----------------------------------------------------------------------
17   USE par_oce        ! ocean parameters
18   USE dom_oce        ! domain variables
19   USE phycst         ! physical constants
20   USE sbc_oce , ONLY : sss_m
21   USE sbc_ice , ONLY : utau_ice, vtau_ice
22   USE thd_ice        ! LIM thermodynamics
23   USE ice            ! LIM variables
24   USE limtab         ! LIM 2D <==> 1D
25   USE limcons        ! LIM conservation
26   USE in_out_manager ! I/O manager
27   USE lib_mpp        ! MPP library
28   USE wrk_nemo       ! work arrays
29   USE lbclnk         ! ocean lateral boundary conditions (or mpp link)
30   USE lib_fortran    ! Fortran utilities (allows no signed zero when 'key_nosignedzero' defined) 
31   USE limthd_ent
32   USE limvar
33
34   IMPLICIT NONE
35   PRIVATE
36
37   PUBLIC lim_thd_lac     ! called by lim_thd
38
39   !!----------------------------------------------------------------------
40   !! NEMO/LIM3 4.0 , UCL - NEMO Consortium (2011)
41   !! $Id$
42   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
43   !!----------------------------------------------------------------------
44CONTAINS
45
46   SUBROUTINE lim_thd_lac
47      !!-------------------------------------------------------------------
48      !!               ***   ROUTINE lim_thd_lac  ***
49      !! 
50      !! ** Purpose : Computation of the evolution of the ice thickness and
51      !!      concentration as a function of the heat balance in the leads.
52      !!      It is only used for lateral accretion
53      !!       
54      !! ** Method  : Ice is formed in the open water when ocean lose heat
55      !!      (heat budget of open water Bl is negative) .
56      !!      Computation of the increase of 1-A (ice concentration) fol-
57      !!      lowing the law :
58      !!      (dA/dt)acc = F[ (1-A)/(1-a) ] * [ Bl / (Li*h0) ]
59      !!       where - h0 is the thickness of ice created in the lead
60      !!             - a is a minimum fraction for leads
61      !!             - F is a monotonic non-increasing function defined as:
62      !!                  F(X)=( 1 - X**exld )**(1.0/exld)
63      !!             - exld is the exponent closure rate (=2 default val.)
64      !!
65      !! ** Action : - Adjustment of snow and ice thicknesses and heat
66      !!                content in brine pockets
67      !!             - Updating ice internal temperature
68      !!             - Computation of variation of ice volume and mass
69      !!             - Computation of a_i after lateral accretion and
70      !!               update ht_s_1d, ht_i_1d and tbif_1d(:,:)     
71      !!------------------------------------------------------------------------
72      INTEGER  ::   ji,jj,jk,jl      ! dummy loop indices
73      INTEGER  ::   nidx            ! local integers
74      INTEGER  ::   iter     !   -       -
75      REAL(wp) ::   ztmelts, zdv, zfrazb, zweight, zde                          ! local scalars
76      REAL(wp) ::   zgamafr, zvfrx, zvgx, ztaux, ztwogp, zf                     !   -      -
77      REAL(wp) ::   ztenagm, zvfry, zvgy, ztauy, zvrel2, zfp, zsqcd , zhicrit   !   -      -
78
79      REAL(wp) ::   zQm          ! enthalpy exchanged with the ocean (J/m2, >0 towards ocean)
80      REAL(wp) ::   zEi          ! sea ice specific enthalpy (J/kg)
81      REAL(wp) ::   zEw          ! seawater specific enthalpy (J/kg)
82      REAL(wp) ::   zfmdt        ! mass flux x time step (kg/m2, >0 towards ocean)
83     
84      REAL(wp) ::   zv_newfra
85 
86      INTEGER , POINTER, DIMENSION(:) ::   jcat        ! indexes of categories where new ice grows
87      REAL(wp), POINTER, DIMENSION(:) ::   zswinew     ! switch for new ice or not
88
89      REAL(wp), POINTER, DIMENSION(:) ::   zv_newice   ! volume of accreted ice
90      REAL(wp), POINTER, DIMENSION(:) ::   za_newice   ! fractional area of accreted ice
91      REAL(wp), POINTER, DIMENSION(:) ::   zh_newice   ! thickness of accreted ice
92      REAL(wp), POINTER, DIMENSION(:) ::   ze_newice   ! heat content of accreted ice
93      REAL(wp), POINTER, DIMENSION(:) ::   zs_newice   ! salinity of accreted ice
94      REAL(wp), POINTER, DIMENSION(:) ::   zo_newice   ! age of accreted ice
95      REAL(wp), POINTER, DIMENSION(:) ::   zdv_res     ! residual volume in case of excessive heat budget
96      REAL(wp), POINTER, DIMENSION(:) ::   zda_res     ! residual area in case of excessive heat budget
97      REAL(wp), POINTER, DIMENSION(:) ::   zat_i_1d    ! total ice fraction   
98      REAL(wp), POINTER, DIMENSION(:) ::   zv_frazb    ! accretion of frazil ice at the ice bottom
99      REAL(wp), POINTER, DIMENSION(:) ::   zvrel_1d    ! relative ice / frazil velocity (1D vector)
100
101      REAL(wp), POINTER, DIMENSION(:,:) ::   zv_b      ! old volume of ice in category jl
102      REAL(wp), POINTER, DIMENSION(:,:) ::   za_b      ! old area of ice in category jl
103      REAL(wp), POINTER, DIMENSION(:,:) ::   za_i_1d   ! 1-D version of a_i
104      REAL(wp), POINTER, DIMENSION(:,:) ::   zv_i_1d   ! 1-D version of v_i
105      REAL(wp), POINTER, DIMENSION(:,:) ::   zsmv_i_1d ! 1-D version of smv_i
106
107      REAL(wp), POINTER, DIMENSION(:,:,:) ::   ze_i_1d !: 1-D version of e_i
108
109      REAL(wp), POINTER, DIMENSION(:,:) ::   zvrel     ! relative ice / frazil velocity
110
111      REAL(wp) :: zcai = 1.4e-3_wp                     ! ice-air drag (clem: should be dependent on coupling/forcing used)
112      !!-----------------------------------------------------------------------!
113
114      CALL wrk_alloc( jpij, jcat )   ! integer
115      CALL wrk_alloc( jpij, zswinew, zv_newice, za_newice, zh_newice, ze_newice, zs_newice, zo_newice )
116      CALL wrk_alloc( jpij, zdv_res, zda_res, zat_i_1d, zv_frazb, zvrel_1d )
117      CALL wrk_alloc( jpij,jpl, zv_b, za_b, za_i_1d, zv_i_1d, zsmv_i_1d )
118      CALL wrk_alloc( jpij,nlay_i,jpl, ze_i_1d )
119      CALL wrk_alloc( jpi,jpj, zvrel )
120
121      CALL lim_var_agg(1)
122      CALL lim_var_glo2eqv
123
124      !------------------------------------------------------------------------------!
125      ! 3) Collection thickness of ice formed in leads and polynyas
126      !------------------------------------------------------------------------------!   
127      ! hicol is the thickness of new ice formed in open water
128      ! hicol can be either prescribed (frazswi = 0) or computed (frazswi = 1)
129      ! Frazil ice forms in open water, is transported by wind
130      ! accumulates at the edge of the consolidated ice edge
131      ! where it forms aggregates of a specific thickness called
132      ! collection thickness.
133
134      ! Note : the following algorithm currently breaks vectorization
135      !
136
137      zvrel(:,:) = 0._wp
138
139      ! Default new ice thickness
140      WHERE( qlead(:,:) < 0._wp ) ; hicol(:,:) = rn_hnewice
141      ELSEWHERE                   ; hicol(:,:) = 0._wp
142      END WHERE
143
144      IF( ln_frazil ) THEN
145
146         !--------------------
147         ! Physical constants
148         !--------------------
149         hicol(:,:) = 0._wp
150
151         zhicrit = 0.04 ! frazil ice thickness
152         ztwogp  = 2. * rau0 / ( grav * 0.3 * ( rau0 - rhoic ) ) ! reduced grav
153         zsqcd   = 1.0 / SQRT( 1.3 * zcai ) ! 1/SQRT(airdensity*drag)
154         zgamafr = 0.03
155
156         DO jj = 2, jpjm1
157            DO ji = 2, jpim1
158               IF ( qlead(ji,jj) < 0._wp .AND. tau_icebfr(ji,jj) == 0._wp ) THEN ! activated if cooling and no landfast
159                  !-------------
160                  ! Wind stress
161                  !-------------
162                  ! C-grid wind stress components
163                  ztaux         = ( utau_ice(ji-1,jj  ) * umask(ji-1,jj  ,1)   &
164                     &          +   utau_ice(ji  ,jj  ) * umask(ji  ,jj  ,1) ) * 0.5_wp
165                  ztauy         = ( vtau_ice(ji  ,jj-1) * vmask(ji  ,jj-1,1)   &
166                     &          +   vtau_ice(ji  ,jj  ) * vmask(ji  ,jj  ,1) ) * 0.5_wp
167                  ! Square root of wind stress
168                  ztenagm       =  SQRT( SQRT( ztaux * ztaux + ztauy * ztauy ) )
169
170                  !---------------------
171                  ! Frazil ice velocity
172                  !---------------------
173                  rswitch = MAX( 0._wp, SIGN( 1._wp , ztenagm - epsi10 ) )
174                  zvfrx   = rswitch * zgamafr * zsqcd * ztaux / MAX( ztenagm, epsi10 )
175                  zvfry   = rswitch * zgamafr * zsqcd * ztauy / MAX( ztenagm, epsi10 )
176
177                  !-------------------
178                  ! Pack ice velocity
179                  !-------------------
180                  ! C-grid ice velocity
181                  zvgx    = ( u_ice(ji-1,jj  ) * umask(ji-1,jj  ,1)  + u_ice(ji,jj) * umask(ji,jj,1) ) * 0.5_wp
182                  zvgy    = ( v_ice(ji  ,jj-1) * vmask(ji  ,jj-1,1)  + v_ice(ji,jj) * vmask(ji,jj,1) ) * 0.5_wp
183
184                  !-----------------------------------
185                  ! Relative frazil/pack ice velocity
186                  !-----------------------------------
187                  ! absolute relative velocity
188                  rswitch      = MAX( 0._wp, SIGN( 1._wp , at_i(ji,jj) - epsi10 ) )
189                  zvrel2       = MAX(  ( zvfrx - zvgx ) * ( zvfrx - zvgx )   &
190                     &               + ( zvfry - zvgy ) * ( zvfry - zvgy ) , 0.15 * 0.15 ) * rswitch
191                  zvrel(ji,jj) = SQRT( zvrel2 )
192
193                  !---------------------
194                  ! Iterative procedure
195                  !---------------------
196                  hicol(ji,jj) = zhicrit +   ( zhicrit + 0.1 )    &
197                     &                   / ( ( zhicrit + 0.1 ) * ( zhicrit + 0.1 ) -  zhicrit * zhicrit ) * ztwogp * zvrel2
198
199                  iter = 1
200                  DO WHILE ( iter < 20 ) 
201                     zf  = ( hicol(ji,jj) - zhicrit ) * ( hicol(ji,jj) * hicol(ji,jj) - zhicrit * zhicrit ) -   &
202                        &    hicol(ji,jj) * zhicrit * ztwogp * zvrel2
203                     zfp = ( hicol(ji,jj) - zhicrit ) * ( 3.0 * hicol(ji,jj) + zhicrit ) - zhicrit * ztwogp * zvrel2
204
205                     hicol(ji,jj) = hicol(ji,jj) - zf / MAX( zfp, epsi20 )
206                     iter = iter + 1
207                  END DO
208
209               ENDIF ! end of selection of pixels where ice forms
210
211            END DO
212         END DO 
213         !
214         CALL lbc_lnk( zvrel, 'T', 1. )
215         CALL lbc_lnk( hicol, 'T', 1. )
216
217      ENDIF ! End of computation of frazil ice collection thickness
218
219      !------------------------------------------------------------------------------!
220      ! 4) Identify grid points where new ice forms
221      !------------------------------------------------------------------------------!
222
223      !-------------------------------------
224      ! Select points for new ice formation
225      !-------------------------------------
226      ! This occurs if open water energy budget is negative (cooling) and there is no landfast ice
227      nidx = 0 ; idxice(:) = 0
228      DO jj = 2, jpjm1
229         DO ji = 2, jpim1
230            IF ( qlead(ji,jj)  <  0._wp .AND. tau_icebfr(ji,jj) == 0._wp ) THEN
231               nidx = nidx + 1
232               idxice( nidx ) = (jj - 1) * jpi + ji
233            ENDIF
234         END DO
235      END DO
236
237      ! debug point to follow
238      jiindex_1d = 0
239      IF( ln_limctl ) THEN
240         DO ji = mi0(iiceprt), mi1(iiceprt)
241            DO jj = mj0(jiceprt), mj1(jiceprt)
242               IF ( qlead(ji,jj)  <  0._wp ) THEN
243                  jiindex_1d = (jj - 1) * jpi + ji
244               ENDIF
245            END DO
246         END DO
247      ENDIF
248   
249      IF( ln_limctl ) WRITE(numout,*) 'lim_thd_lac : nidx = ', nidx
250
251      !------------------------------
252      ! Move from 2-D to 1-D vectors
253      !------------------------------
254      ! If ocean gains heat do nothing. Otherwise compute new ice formation
255
256      IF ( nidx > 0 ) THEN
257
258         CALL tab_2d_1d( nidx, zat_i_1d  (1:nidx)     , at_i         , jpi, jpj, idxice(1:nidx) )
259         DO jl = 1, jpl
260            CALL tab_2d_1d( nidx, za_i_1d  (1:nidx,jl), a_i  (:,:,jl), jpi, jpj, idxice(1:nidx) )
261            CALL tab_2d_1d( nidx, zv_i_1d  (1:nidx,jl), v_i  (:,:,jl), jpi, jpj, idxice(1:nidx) )
262            CALL tab_2d_1d( nidx, zsmv_i_1d(1:nidx,jl), smv_i(:,:,jl), jpi, jpj, idxice(1:nidx) )
263            DO jk = 1, nlay_i
264               CALL tab_2d_1d( nidx, ze_i_1d(1:nidx,jk,jl), e_i(:,:,jk,jl) , jpi, jpj, idxice(1:nidx) )
265            END DO
266         END DO
267
268         CALL tab_2d_1d( nidx, qlead_1d  (1:nidx)     , qlead     , jpi, jpj, idxice(1:nidx) )
269         CALL tab_2d_1d( nidx, t_bo_1d   (1:nidx)     , t_bo      , jpi, jpj, idxice(1:nidx) )
270         CALL tab_2d_1d( nidx, sfx_opw_1d(1:nidx)     , sfx_opw   , jpi, jpj, idxice(1:nidx) )
271         CALL tab_2d_1d( nidx, wfx_opw_1d(1:nidx)     , wfx_opw   , jpi, jpj, idxice(1:nidx) )
272         CALL tab_2d_1d( nidx, hicol_1d  (1:nidx)     , hicol     , jpi, jpj, idxice(1:nidx) )
273         CALL tab_2d_1d( nidx, zvrel_1d  (1:nidx)     , zvrel     , jpi, jpj, idxice(1:nidx) )
274
275         CALL tab_2d_1d( nidx, hfx_thd_1d(1:nidx)     , hfx_thd   , jpi, jpj, idxice(1:nidx) )
276         CALL tab_2d_1d( nidx, hfx_opw_1d(1:nidx)     , hfx_opw   , jpi, jpj, idxice(1:nidx) )
277         CALL tab_2d_1d( nidx, rn_amax_1d(1:nidx)     , rn_amax_2d, jpi, jpj, idxice(1:nidx) )
278         CALL tab_2d_1d( nidx, sss_1d    (1:nidx)     , sss_m     , jpi, jpj, idxice(1:nidx) )
279
280         !------------------------------------------------------------------------------|
281         ! 2) Convert units for ice internal energy
282         !------------------------------------------------------------------------------|
283         DO jl = 1, jpl
284            DO jk = 1, nlay_i
285               DO ji = 1, nidx
286                  IF( zv_i_1d(ji,jl) > 0._wp )   ze_i_1d(ji,jk,jl) = ze_i_1d(ji,jk,jl) / zv_i_1d(ji,jl) * REAL( nlay_i )
287               END DO
288            END DO
289         END DO
290         !------------------------------------------------------------------------------!
291         ! 5) Compute thickness, salinity, enthalpy, age, area and volume of new ice
292         !------------------------------------------------------------------------------!
293
294         !-----------------------------------------
295         ! Keep old ice areas and volume in memory
296         !-----------------------------------------
297         zv_b(1:nidx,:) = zv_i_1d(1:nidx,:) 
298         za_b(1:nidx,:) = za_i_1d(1:nidx,:)
299
300         !----------------------
301         ! Thickness of new ice
302         !----------------------
303         zh_newice(1:nidx) = hicol_1d(1:nidx)
304
305         !----------------------
306         ! Salinity of new ice
307         !----------------------
308         SELECT CASE ( nn_icesal )
309         CASE ( 1 )                    ! Sice = constant
310            zs_newice(1:nidx) = rn_icesal
311         CASE ( 2 )                    ! Sice = F(z,t) [Vancoppenolle et al (2005)]
312            DO ji = 1, nidx
313               zs_newice(ji) = MIN(  4.606 + 0.91 / zh_newice(ji) , rn_simax , 0.5 * sss_1d(ji) )
314            END DO
315         CASE ( 3 )                    ! Sice = F(z) [multiyear ice]
316            zs_newice(1:nidx) =   2.3
317         END SELECT
318
319         !-------------------------
320         ! Heat content of new ice
321         !-------------------------
322         ! We assume that new ice is formed at the seawater freezing point
323         DO ji = 1, nidx
324            ztmelts       = - tmut * zs_newice(ji) + rt0                  ! Melting point (K)
325            ze_newice(ji) =   rhoic * (  cpic * ( ztmelts - t_bo_1d(ji) )                                         &
326               &                       + lfus * ( 1.0 - ( ztmelts - rt0 ) / MIN( t_bo_1d(ji) - rt0, -epsi10 ) )   &
327               &                       - rcp  *         ( ztmelts - rt0 )  )
328         END DO
329
330         !----------------
331         ! Age of new ice
332         !----------------
333         DO ji = 1, nidx
334            zo_newice(ji) = 0._wp
335         END DO
336
337         !-------------------
338         ! Volume of new ice
339         !-------------------
340         DO ji = 1, nidx
341
342            zEi           = - ze_newice(ji) * r1_rhoic             ! specific enthalpy of forming ice [J/kg]
343
344            zEw           = rcp * ( t_bo_1d(ji) - rt0 )            ! specific enthalpy of seawater at t_bo_1d [J/kg]
345                                                                   ! clem: we suppose we are already at the freezing point (condition qlead<0 is satisfyied)
346                                                                   
347            zdE           = zEi - zEw                              ! specific enthalpy difference [J/kg]
348                                             
349            zfmdt         = - qlead_1d(ji) / zdE                   ! Fm.dt [kg/m2] (<0)
350                                                                   ! clem: we use qlead instead of zqld (limthd) because we suppose we are at the freezing point   
351            zv_newice(ji) = - zfmdt * r1_rhoic
352
353            zQm           = zfmdt * zEw                            ! heat to the ocean >0 associated with mass flux 
354
355            ! Contribution to heat flux to the ocean [W.m-2], >0 
356            hfx_thd_1d(ji) = hfx_thd_1d(ji) + zfmdt * zEw * r1_rdtice
357            ! Total heat flux used in this process [W.m-2] 
358            hfx_opw_1d(ji) = hfx_opw_1d(ji) - zfmdt * zdE * r1_rdtice
359            ! mass flux
360            wfx_opw_1d(ji) = wfx_opw_1d(ji) - zv_newice(ji) * rhoic * r1_rdtice
361            ! salt flux
362            sfx_opw_1d(ji) = sfx_opw_1d(ji) - zv_newice(ji) * rhoic * zs_newice(ji) * r1_rdtice
363         END DO
364         
365         zv_frazb(:) = 0._wp
366         IF( ln_frazil ) THEN
367            ! A fraction zfrazb of frazil ice is accreted at the ice bottom
368            DO ji = 1, nidx
369               rswitch       = 1._wp - MAX( 0._wp, SIGN( 1._wp , - zat_i_1d(ji) ) )
370               zfrazb        = rswitch * ( TANH( rn_Cfrazb * ( zvrel_1d(ji) - rn_vfrazb ) ) + 1.0 ) * 0.5 * rn_maxfrazb
371               zv_frazb(ji)  =         zfrazb   * zv_newice(ji)
372               zv_newice(ji) = ( 1.0 - zfrazb ) * zv_newice(ji)
373            END DO
374         END IF
375         
376         !-----------------
377         ! Area of new ice
378         !-----------------
379         DO ji = 1, nidx
380            za_newice(ji) = zv_newice(ji) / zh_newice(ji)
381         END DO
382
383         !------------------------------------------------------------------------------!
384         ! 6) Redistribute new ice area and volume into ice categories                  !
385         !------------------------------------------------------------------------------!
386
387         !------------------------
388         ! 6.1) lateral ice growth
389         !------------------------
390         ! If lateral ice growth gives an ice concentration gt 1, then
391         ! we keep the excessive volume in memory and attribute it later to bottom accretion
392         DO ji = 1, nidx
393            IF ( za_newice(ji) >  ( rn_amax_1d(ji) - zat_i_1d(ji) ) ) THEN
394               zda_res(ji)   = za_newice(ji) - ( rn_amax_1d(ji) - zat_i_1d(ji) )
395               zdv_res(ji)   = zda_res  (ji) * zh_newice(ji) 
396               za_newice(ji) = za_newice(ji) - zda_res  (ji)
397               zv_newice(ji) = zv_newice(ji) - zdv_res  (ji)
398            ELSE
399               zda_res(ji) = 0._wp
400               zdv_res(ji) = 0._wp
401            ENDIF
402         END DO
403
404         ! find which category to fill
405         zat_i_1d(:) = 0._wp
406         DO jl = 1, jpl
407            DO ji = 1, nidx
408               IF( zh_newice(ji) > hi_max(jl-1) .AND. zh_newice(ji) <= hi_max(jl) ) THEN
409                  za_i_1d (ji,jl) = za_i_1d (ji,jl) + za_newice(ji)
410                  zv_i_1d (ji,jl) = zv_i_1d (ji,jl) + zv_newice(ji)
411                  jcat    (ji)    = jl
412               ENDIF
413               zat_i_1d(ji) = zat_i_1d(ji) + za_i_1d  (ji,jl)
414            END DO
415         END DO
416
417         ! Heat content
418         DO ji = 1, nidx
419            jl = jcat(ji)                                                    ! categroy in which new ice is put
420            zswinew  (ji) = MAX( 0._wp , SIGN( 1._wp , - za_b(ji,jl) ) )   ! 0 if old ice
421         END DO
422
423         DO jk = 1, nlay_i
424            DO ji = 1, nidx
425               jl = jcat(ji)
426               rswitch = MAX( 0._wp, SIGN( 1._wp , zv_i_1d(ji,jl) - epsi20 ) )
427               ze_i_1d(ji,jk,jl) = zswinew(ji)   *   ze_newice(ji) +                                                    &
428                  &        ( 1.0 - zswinew(ji) ) * ( ze_newice(ji) * zv_newice(ji) + ze_i_1d(ji,jk,jl) * zv_b(ji,jl) )  &
429                  &        * rswitch / MAX( zv_i_1d(ji,jl), epsi20 )
430            END DO
431         END DO
432
433         !------------------------------------------------
434         ! 6.2) bottom ice growth + ice enthalpy remapping
435         !------------------------------------------------
436         DO jl = 1, jpl
437
438            ! for remapping
439            h_i_old (1:nidx,0:nlay_i+1) = 0._wp
440            eh_i_old(1:nidx,0:nlay_i+1) = 0._wp
441            DO jk = 1, nlay_i
442               DO ji = 1, nidx
443                  h_i_old (ji,jk) = zv_i_1d(ji,jl) * r1_nlay_i
444                  eh_i_old(ji,jk) = ze_i_1d(ji,jk,jl) * h_i_old(ji,jk)
445               END DO
446            END DO
447
448            ! new volumes including lateral/bottom accretion + residual
449            DO ji = 1, nidx
450               rswitch        = MAX( 0._wp, SIGN( 1._wp , zat_i_1d(ji) - epsi20 ) )
451               zv_newfra      = rswitch * ( zdv_res(ji) + zv_frazb(ji) ) * za_i_1d(ji,jl) / MAX( zat_i_1d(ji) , epsi20 )
452               za_i_1d(ji,jl) = rswitch * za_i_1d(ji,jl)               
453               zv_i_1d(ji,jl) = zv_i_1d(ji,jl) + zv_newfra
454               ! for remapping
455               h_i_old (ji,nlay_i+1) = zv_newfra
456               eh_i_old(ji,nlay_i+1) = ze_newice(ji) * zv_newfra
457            ENDDO
458            ! --- Ice enthalpy remapping --- !
459            CALL lim_thd_ent( 1, nidx, ze_i_1d(1:nidx,:,jl) ) 
460         ENDDO
461
462         !-----------------
463         ! Update salinity
464         !-----------------
465         DO jl = 1, jpl
466            DO ji = 1, nidx
467               zdv   = zv_i_1d(ji,jl) - zv_b(ji,jl)
468               zsmv_i_1d(ji,jl) = zsmv_i_1d(ji,jl) + zdv * zs_newice(ji)
469            END DO
470         END DO
471
472         !------------------------------------------------------------------------------!
473         ! 8) Change units for e_i
474         !------------------------------------------------------------------------------!   
475         DO jl = 1, jpl
476            DO jk = 1, nlay_i
477               DO ji = 1, nidx
478                  ze_i_1d(ji,jk,jl) = ze_i_1d(ji,jk,jl) * zv_i_1d(ji,jl) * r1_nlay_i 
479               END DO
480            END DO
481         END DO
482         !------------------------------------------------------------------------------!
483         ! 7) Change 2D vectors to 1D vectors
484         !------------------------------------------------------------------------------!
485         DO jl = 1, jpl
486            CALL tab_1d_2d( nidx, a_i (:,:,jl), idxice(1:nidx), za_i_1d (1:nidx,jl), jpi, jpj )
487            CALL tab_1d_2d( nidx, v_i (:,:,jl), idxice(1:nidx), zv_i_1d (1:nidx,jl), jpi, jpj )
488            CALL tab_1d_2d( nidx, smv_i (:,:,jl), idxice(1:nidx), zsmv_i_1d(1:nidx,jl) , jpi, jpj )
489            DO jk = 1, nlay_i
490               CALL tab_1d_2d( nidx, e_i(:,:,jk,jl), idxice(1:nidx), ze_i_1d(1:nidx,jk,jl), jpi, jpj )
491            END DO
492         END DO
493         CALL tab_1d_2d( nidx, sfx_opw, idxice(1:nidx), sfx_opw_1d(1:nidx), jpi, jpj )
494         CALL tab_1d_2d( nidx, wfx_opw, idxice(1:nidx), wfx_opw_1d(1:nidx), jpi, jpj )
495         CALL tab_1d_2d( nidx, hfx_thd, idxice(1:nidx), hfx_thd_1d(1:nidx), jpi, jpj )
496         CALL tab_1d_2d( nidx, hfx_opw, idxice(1:nidx), hfx_opw_1d(1:nidx), jpi, jpj )
497         !
498      ENDIF ! nidx > 0
499      !
500      CALL wrk_dealloc( jpij, jcat )   ! integer
501      CALL wrk_dealloc( jpij, zswinew, zv_newice, za_newice, zh_newice, ze_newice, zs_newice, zo_newice )
502      CALL wrk_dealloc( jpij, zdv_res, zda_res, zat_i_1d, zv_frazb, zvrel_1d )
503      CALL wrk_dealloc( jpij,jpl, zv_b, za_b, za_i_1d, zv_i_1d, zsmv_i_1d )
504      CALL wrk_dealloc( jpij,nlay_i,jpl, ze_i_1d )
505      CALL wrk_dealloc( jpi,jpj, zvrel )
506      !
507   END SUBROUTINE lim_thd_lac
508
509#else
510   !!----------------------------------------------------------------------
511   !!   Default option                               NO  LIM3 sea-ice model
512   !!----------------------------------------------------------------------
513CONTAINS
514   SUBROUTINE lim_thd_lac           ! Empty routine
515   END SUBROUTINE lim_thd_lac
516#endif
517
518   !!======================================================================
519END MODULE limthd_lac
Note: See TracBrowser for help on using the repository browser.