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 trunk/NEMOGCM/NEMO/LIM_SRC_3 – NEMO

source: trunk/NEMOGCM/NEMO/LIM_SRC_3/limthd_lac.F90 @ 4833

Last change on this file since 4833 was 4833, checked in by flavoni, 9 years ago

fix LIM3 reproducibility problems, see ticket #1398

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