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.
icedyn_rdgrft.F90 in NEMO/branches/UKMO/NEMO_4.0_add_pond_lids_prints/src/ICE – NEMO

source: NEMO/branches/UKMO/NEMO_4.0_add_pond_lids_prints/src/ICE/icedyn_rdgrft.F90 @ 12379

Last change on this file since 12379 was 12379, checked in by dancopsey, 4 years ago

Add meltpond lid thickness as a new prognostic.

File size: 52.2 KB
Line 
1MODULE icedyn_rdgrft
2   !!======================================================================
3   !!                       ***  MODULE icedyn_rdgrft ***
4   !!    sea-ice : Mechanical impact on ice thickness distribution     
5   !!======================================================================
6   !! History :       !  2006-02  (M. Vancoppenolle) Original code
7   !!            4.0  !  2018     (many people)      SI3 [aka Sea Ice cube]
8   !!----------------------------------------------------------------------
9#if defined key_si3
10   !!----------------------------------------------------------------------
11   !!   'key_si3'                                       SI3 sea-ice model
12   !!----------------------------------------------------------------------
13   !!   ice_dyn_rdgrft       : ridging/rafting of sea ice
14   !!   ice_dyn_rdgrft_init  : initialization of ridging/rafting of sea ice
15   !!   ice_strength         : ice strength calculation
16   !!----------------------------------------------------------------------
17   USE dom_oce        ! ocean domain
18   USE phycst         ! physical constants (ocean directory)
19   USE sbc_oce , ONLY : sss_m, sst_m   ! surface boundary condition: ocean fields
20   USE ice1D          ! sea-ice: thermodynamics
21   USE ice            ! sea-ice: variables
22   USE icetab         ! sea-ice: 1D <==> 2D transformation
23   USE icevar         ! sea-ice: operations
24   USE icectl         ! sea-ice: control prints
25   !
26   USE in_out_manager ! I/O manager
27   USE iom            ! I/O manager library
28   USE lib_mpp        ! MPP library
29   USE lib_fortran    ! fortran utilities (glob_sum + no signed zero)
30   USE lbclnk         ! lateral boundary conditions (or mpp links)
31   USE timing         ! Timing
32
33   IMPLICIT NONE
34   PRIVATE
35
36   PUBLIC   ice_dyn_rdgrft        ! called by icestp
37   PUBLIC   ice_dyn_rdgrft_init   ! called by icedyn
38   PUBLIC   ice_strength          ! called by icedyn_rhg_evp
39
40   ! Variables shared among ridging subroutines
41   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:)     ::   closing_net     ! net rate at which area is removed    (1/s)
42      !                                                               ! (ridging ice area - area of new ridges) / dt
43   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:)     ::   opning          ! rate of opening due to divergence/shear
44   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:)     ::   closing_gross   ! rate at which area removed, not counting area of new ridges
45   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:)   ::   apartf          ! participation function; fraction of ridging/closing associated w/ category n
46   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:)   ::   hrmin           ! minimum ridge thickness
47   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:)   ::   hrmax           ! maximum ridge thickness
48   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:)   ::   hraft           ! thickness of rafted ice
49   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:)   ::   hi_hrdg         ! thickness of ridging ice / mean ridge thickness
50   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:)   ::   aridge          ! participating ice ridging
51   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:)   ::   araft           ! participating ice rafting
52   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   ze_i_2d
53   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   ze_s_2d
54   !
55   REAL(wp), PARAMETER ::   hrdg_hi_min = 1.1_wp    ! min ridge thickness multiplier: min(hrdg/hi)
56   REAL(wp), PARAMETER ::   hi_hrft     = 0.5_wp    ! rafting multipliyer: (hi/hraft)
57   !
58   ! ** namelist (namdyn_rdgrft) **
59   LOGICAL  ::   ln_str_H79       ! ice strength parameterization (Hibler79)
60   REAL(wp) ::   rn_pstar         ! determines ice strength, Hibler JPO79
61   REAL(wp) ::   rn_csrdg         ! fraction of shearing energy contributing to ridging           
62   LOGICAL  ::   ln_partf_lin     ! participation function linear (Thorndike et al. (1975))
63   REAL(wp) ::   rn_gstar         !    fractional area of young ice contributing to ridging
64   LOGICAL  ::   ln_partf_exp     ! participation function exponential (Lipscomb et al. (2007))
65   REAL(wp) ::   rn_astar         !    equivalent of G* for an exponential participation function
66   LOGICAL  ::   ln_ridging       ! ridging of ice or not                       
67   REAL(wp) ::   rn_hstar         !    thickness that determines the maximal thickness of ridged ice
68   REAL(wp) ::   rn_porordg       !    initial porosity of ridges (0.3 regular value)
69   REAL(wp) ::   rn_fsnwrdg       !    fractional snow loss to the ocean during ridging
70   REAL(wp) ::   rn_fpndrdg       !    fractional pond loss to the ocean during ridging
71   LOGICAL  ::   ln_rafting       ! rafting of ice or not                       
72   REAL(wp) ::   rn_hraft         !    threshold thickness (m) for rafting / ridging
73   REAL(wp) ::   rn_craft         !    coefficient for smoothness of the hyperbolic tangent in rafting
74   REAL(wp) ::   rn_fsnwrft       !    fractional snow loss to the ocean during rafting
75   REAL(wp) ::   rn_fpndrft       !    fractional pond loss to the ocean during rafting
76   !
77   !!----------------------------------------------------------------------
78   !! NEMO/ICE 4.0 , NEMO Consortium (2018)
79   !! $Id$
80   !! Software governed by the CeCILL licence     (./LICENSE)
81   !!----------------------------------------------------------------------
82CONTAINS
83
84   INTEGER FUNCTION ice_dyn_rdgrft_alloc()
85      !!-------------------------------------------------------------------
86      !!                ***  ROUTINE ice_dyn_rdgrft_alloc ***
87      !!-------------------------------------------------------------------
88      ALLOCATE( closing_net(jpij), opning(jpij)   , closing_gross(jpij),   &
89         &      apartf(jpij,0:jpl), hrmin(jpij,jpl), hraft(jpij,jpl)    , aridge(jpij,jpl),   &
90         &      hrmax(jpij,jpl), hi_hrdg(jpij,jpl)  , araft (jpij,jpl),  &
91         &      ze_i_2d(jpij,nlay_i,jpl), ze_s_2d(jpij,nlay_s,jpl), STAT=ice_dyn_rdgrft_alloc )
92
93      CALL mpp_sum ( 'icedyn_rdgrft', ice_dyn_rdgrft_alloc )
94      IF( ice_dyn_rdgrft_alloc /= 0 )   CALL ctl_stop( 'STOP',  'ice_dyn_rdgrft_alloc: failed to allocate arrays'  )
95      !
96   END FUNCTION ice_dyn_rdgrft_alloc
97
98
99   SUBROUTINE ice_dyn_rdgrft( kt )
100      !!-------------------------------------------------------------------
101      !!                ***  ROUTINE ice_dyn_rdgrft ***
102      !!
103      !! ** Purpose :   computes the mechanical redistribution of ice thickness
104      !!
105      !! ** Method  :   Steps :
106      !!       0) Identify grid cells with ice
107      !!       1) Calculate closing rate, divergence and opening
108      !!       2) Identify grid cells with ridging
109      !!       3) Start ridging iterations
110      !!          - prep = ridged and rafted ice + closing_gross
111      !!          - shift = move ice from one category to another
112      !!
113      !! ** Details
114      !!    step1: The net rate of closing is due to convergence and shear, based on Flato and Hibler (1995).
115      !!           The energy dissipation rate is equal to the net closing rate times the ice strength.
116      !!
117      !!    step3: The gross closing rate is equal to the first two terms (open
118      !!           water closing and thin ice ridging) without the third term
119      !!           (thick, newly ridged ice).
120      !!
121      !! References :   Flato, G. M., and W. D. Hibler III, 1995, JGR, 100, 18,611-18,626.
122      !!                Hibler, W. D. III, 1980, MWR, 108, 1943-1973, 1980.
123      !!                Rothrock, D. A., 1975: JGR, 80, 4514-4519.
124      !!                Thorndike et al., 1975, JGR, 80, 4501-4513.
125      !!                Bitz et al., JGR, 2001
126      !!                Amundrud and Melling, JGR 2005
127      !!                Babko et al., JGR 2002
128      !!
129      !!     This routine is based on CICE code and authors William H. Lipscomb,
130      !!     and Elizabeth C. Hunke, LANL are gratefully acknowledged
131      !!-------------------------------------------------------------------
132      INTEGER, INTENT(in) ::   kt     ! number of iteration
133      !!
134      INTEGER  ::   ji, jj, jk, jl             ! dummy loop index
135      INTEGER  ::   iter, iterate_ridging      ! local integer
136      INTEGER  ::   ipti                       ! local integer
137      REAL(wp) ::   zfac                       ! local scalar
138      INTEGER , DIMENSION(jpij) ::   iptidx        ! compute ridge/raft or not
139      REAL(wp), DIMENSION(jpij) ::   zdivu_adv     ! divu as implied by transport scheme  (1/s)
140      REAL(wp), DIMENSION(jpij) ::   zdivu, zdelt  ! 1D divu_i & delta_i
141      !
142      INTEGER, PARAMETER ::   jp_itermax = 20   
143      !!-------------------------------------------------------------------
144      ! controls
145      IF( ln_timing    )   CALL timing_start('icedyn_rdgrft')                                                             ! timing
146      IF( ln_icediachk )   CALL ice_cons_hsm(0, 'icedyn_rdgrft', rdiag_v, rdiag_s, rdiag_t, rdiag_fv, rdiag_fs, rdiag_ft) ! conservation
147
148      IF( kt == nit000 ) THEN
149         IF(lwp) WRITE(numout,*)
150         IF(lwp) WRITE(numout,*)'ice_dyn_rdgrft: ice ridging and rafting'
151         IF(lwp) WRITE(numout,*)'~~~~~~~~~~~~~~'
152      ENDIF     
153
154      !--------------------------------
155      ! 0) Identify grid cells with ice
156      !--------------------------------
157      at_i(:,:) = SUM( a_i, dim=3 )
158      !
159      npti = 0   ;   nptidx(:) = 0
160      ipti = 0   ;   iptidx(:) = 0
161      DO jj = 1, jpj
162         DO ji = 1, jpi
163            IF ( at_i(ji,jj) > epsi10 ) THEN
164               npti           = npti + 1
165               nptidx( npti ) = (jj - 1) * jpi + ji
166            ENDIF
167         END DO
168      END DO
169     
170      !--------------------------------------------------------
171      ! 1) Dynamical inputs (closing rate, divergence, opening)
172      !--------------------------------------------------------
173      IF( npti > 0 ) THEN
174       
175         ! just needed here
176         CALL tab_2d_1d( npti, nptidx(1:npti), zdivu   (1:npti)      , divu_i  )
177         CALL tab_2d_1d( npti, nptidx(1:npti), zdelt   (1:npti)      , delta_i )
178         ! needed here and in the iteration loop
179         CALL tab_3d_2d( npti, nptidx(1:npti), a_i_2d  (1:npti,1:jpl), a_i   )
180         CALL tab_3d_2d( npti, nptidx(1:npti), v_i_2d  (1:npti,1:jpl), v_i   )
181         CALL tab_2d_1d( npti, nptidx(1:npti), ato_i_1d(1:npti)      , ato_i )
182
183         DO ji = 1, npti
184            ! closing_net = rate at which open water area is removed + ice area removed by ridging
185            !                                                        - ice area added in new ridges
186            closing_net(ji) = rn_csrdg * 0.5_wp * ( zdelt(ji) - ABS( zdivu(ji) ) ) - MIN( zdivu(ji), 0._wp )
187            !
188            ! divergence given by the advection scheme
189            !   (which may not be equal to divu as computed from the velocity field)
190            IF    ( ln_adv_Pra ) THEN
191               zdivu_adv(ji) = ( 1._wp - ato_i_1d(ji) - SUM( a_i_2d(ji,:) ) ) * r1_rdtice
192            ELSEIF( ln_adv_UMx ) THEN
193               zdivu_adv(ji) = zdivu(ji)
194            ENDIF
195            !
196            IF( zdivu_adv(ji) < 0._wp )   closing_net(ji) = MAX( closing_net(ji), -zdivu_adv(ji) )   ! make sure the closing rate is large enough
197            !                                                                                        ! to give asum = 1.0 after ridging
198            ! Opening rate (non-negative) that will give asum = 1.0 after ridging.
199            opning(ji) = closing_net(ji) + zdivu_adv(ji)
200         END DO
201         !
202         !------------------------------------
203         ! 2) Identify grid cells with ridging
204         !------------------------------------
205         CALL rdgrft_prep( a_i_2d, v_i_2d, ato_i_1d, closing_net )
206
207         DO ji = 1, npti
208            IF( SUM( apartf(ji,1:jpl) ) > 0._wp .AND. closing_gross(ji) > 0._wp ) THEN
209               ipti = ipti + 1
210               iptidx     (ipti)   = nptidx     (ji)
211               ! adjust to new indices
212               a_i_2d     (ipti,:) = a_i_2d     (ji,:)
213               v_i_2d     (ipti,:) = v_i_2d     (ji,:)
214               ato_i_1d   (ipti)   = ato_i_1d   (ji)
215               closing_net(ipti)   = closing_net(ji)
216               zdivu_adv  (ipti)   = zdivu_adv  (ji)
217               opning     (ipti)   = opning     (ji)
218            ENDIF
219         END DO
220
221      ENDIF
222
223      ! grid cells with ridging
224      nptidx(:) = iptidx(:)
225      npti      = ipti
226
227      !-----------------
228      ! 3) Start ridging
229      !-----------------
230      IF( npti > 0 ) THEN
231         
232         CALL ice_dyn_1d2d( 1 )            ! --- Move to 1D arrays --- !
233
234         iter            = 1
235         iterate_ridging = 1     
236         !                                                        !----------------------!
237         DO WHILE( iterate_ridging > 0 .AND. iter < jp_itermax )  !  ridging iterations  !
238            !                                                     !----------------------!
239            ! Calculate participation function (apartf)
240            !       and transfer      function
241            !       and closing_gross (+correction on opening)
242            CALL rdgrft_prep( a_i_2d, v_i_2d, ato_i_1d, closing_net )
243
244            ! Redistribute area, volume, and energy between categories
245            CALL rdgrft_shift
246
247            ! Do we keep on iterating?
248            !-------------------------
249            ! Check whether a_i + ato_i = 0
250            ! If not, because the closing and opening rates were reduced above, ridge again with new rates
251            iterate_ridging = 0
252            DO ji = 1, npti
253               zfac = 1._wp - ( ato_i_1d(ji) + SUM( a_i_2d(ji,:) ) )
254               IF( ABS( zfac ) < epsi10 ) THEN
255                  closing_net(ji) = 0._wp
256                  opning     (ji) = 0._wp
257                  ato_i_1d   (ji) = MAX( 0._wp, 1._wp - SUM( a_i_2d(ji,:) ) )
258               ELSE
259                  iterate_ridging  = 1
260                  zdivu_adv  (ji) = zfac * r1_rdtice
261                  closing_net(ji) = MAX( 0._wp, -zdivu_adv(ji) )
262                  opning     (ji) = MAX( 0._wp,  zdivu_adv(ji) )
263               ENDIF
264            END DO
265            !
266            iter = iter + 1
267            IF( iter  >  jp_itermax )    CALL ctl_stop( 'STOP',  'icedyn_rdgrft: non-converging ridging scheme'  )
268            !
269         END DO
270
271         CALL ice_dyn_1d2d( 2 )            ! --- Move to 2D arrays --- !
272
273      ENDIF
274   
275      CALL ice_var_agg( 1 ) 
276
277      ! controls
278      IF( ln_icediachk )   CALL ice_cons_hsm(1, 'icedyn_rdgrft', rdiag_v, rdiag_s, rdiag_t, rdiag_fv, rdiag_fs, rdiag_ft) ! conservation
279      IF( ln_ctl       )   CALL ice_prt3D   ('icedyn_rdgrft')                                                             ! prints
280      IF( ln_timing    )   CALL timing_stop ('icedyn_rdgrft')                                                             ! timing
281      !
282   END SUBROUTINE ice_dyn_rdgrft
283
284
285   SUBROUTINE rdgrft_prep( pa_i, pv_i, pato_i, pclosing_net )
286      !!-------------------------------------------------------------------
287      !!                ***  ROUTINE rdgrft_prep ***
288      !!
289      !! ** Purpose :   preparation for ridging calculations
290      !!
291      !! ** Method  :   Compute the thickness distribution of the ice and open water
292      !!                participating in ridging and of the resulting ridges.
293      !!-------------------------------------------------------------------
294      REAL(wp), DIMENSION(:)  , INTENT(in) ::   pato_i, pclosing_net 
295      REAL(wp), DIMENSION(:,:), INTENT(in) ::   pa_i, pv_i 
296      !!
297      INTEGER  ::   ji, jl                     ! dummy loop indices
298      REAL(wp) ::   z1_gstar, z1_astar, zhmean, zfac   ! local scalar
299      REAL(wp), DIMENSION(jpij)        ::   zasum, z1_asum, zaksum   ! sum of a_i+ato_i and reverse
300      REAL(wp), DIMENSION(jpij,jpl)    ::   zhi                      ! ice thickness
301      REAL(wp), DIMENSION(jpij,-1:jpl) ::   zGsum                    ! zGsum(n) = sum of areas in categories 0 to n
302      !--------------------------------------------------------------------
303
304      z1_gstar = 1._wp / rn_gstar
305      z1_astar = 1._wp / rn_astar
306
307      !                       ! Ice thickness needed for rafting
308      WHERE( pa_i(1:npti,:) > epsi20 )   ;   zhi(1:npti,:) = pv_i(1:npti,:) / pa_i(1:npti,:)
309      ELSEWHERE                          ;   zhi(1:npti,:) = 0._wp
310      END WHERE
311
312      ! 1) Participation function (apartf): a(h) = b(h).g(h)
313      !-----------------------------------------------------------------
314      ! Compute the participation function = total area lost due to ridging/closing
315      ! This is analogous to
316      !   a(h) = b(h)g(h) as defined in Thorndike et al. (1975).
317      !   assuming b(h) = (2/Gstar) * (1 - G(h)/Gstar).
318      !
319      ! apartf = integrating b(h)g(h) between the category boundaries
320      ! apartf is always >= 0 and SUM(apartf(0:jpl))=1
321      !-----------------------------------------------------------------
322      !
323      ! Compute total area of ice plus open water.
324      ! This is in general not equal to one because of divergence during transport
325      zasum(1:npti) = pato_i(1:npti) + SUM( pa_i(1:npti,:), dim=2 )
326      !
327      WHERE( zasum(1:npti) > epsi20 )   ;   z1_asum(1:npti) = 1._wp / zasum(1:npti)
328      ELSEWHERE                         ;   z1_asum(1:npti) = 0._wp
329      END WHERE
330      !
331      ! Compute cumulative thickness distribution function
332      ! Compute the cumulative thickness distribution function zGsum,
333      ! where zGsum(n) is the fractional area in categories 0 to n.
334      ! initial value (in h = 0) = open water area
335      zGsum(1:npti,-1) = 0._wp
336      zGsum(1:npti,0 ) = pato_i(1:npti) * z1_asum(1:npti)
337      DO jl = 1, jpl
338         zGsum(1:npti,jl) = ( pato_i(1:npti) + SUM( pa_i(1:npti,1:jl), dim=2 ) ) * z1_asum(1:npti)  ! sum(1:jl) is ok (and not jpl)
339      END DO
340      !
341      IF( ln_partf_lin ) THEN          !--- Linear formulation (Thorndike et al., 1975)
342         DO jl = 0, jpl   
343            DO ji = 1, npti
344               IF    ( zGsum(ji,jl)   < rn_gstar ) THEN
345                  apartf(ji,jl) = z1_gstar * ( zGsum(ji,jl) - zGsum(ji,jl-1) ) * &
346                     &                       ( 2._wp - ( zGsum(ji,jl-1) + zGsum(ji,jl) ) * z1_gstar )
347               ELSEIF( zGsum(ji,jl-1) < rn_gstar ) THEN
348                  apartf(ji,jl) = z1_gstar * ( rn_gstar     - zGsum(ji,jl-1) ) *  &
349                     &                       ( 2._wp - ( zGsum(ji,jl-1) + rn_gstar        ) * z1_gstar )
350               ELSE
351                  apartf(ji,jl) = 0._wp
352               ENDIF
353            END DO
354         END DO
355         !
356      ELSEIF( ln_partf_exp ) THEN      !--- Exponential, more stable formulation (Lipscomb et al, 2007)
357         !                       
358         zfac = 1._wp / ( 1._wp - EXP(-z1_astar) )
359         DO jl = -1, jpl
360            DO ji = 1, npti
361               zGsum(ji,jl) = EXP( -zGsum(ji,jl) * z1_astar ) * zfac
362            END DO
363         END DO
364         DO jl = 0, jpl
365            DO ji = 1, npti
366               apartf(ji,jl) = zGsum(ji,jl-1) - zGsum(ji,jl)
367            END DO
368         END DO
369         !
370      ENDIF
371
372      !                                !--- Ridging and rafting participation concentrations
373      IF( ln_rafting .AND. ln_ridging ) THEN             !- ridging & rafting
374         DO jl = 1, jpl
375            DO ji = 1, npti
376               aridge(ji,jl) = ( 1._wp + TANH ( rn_craft * ( zhi(ji,jl) - rn_hraft ) ) ) * 0.5_wp * apartf(ji,jl)
377               araft (ji,jl) = apartf(ji,jl) - aridge(ji,jl)
378            END DO
379         END DO
380      ELSEIF( ln_ridging .AND. .NOT. ln_rafting ) THEN   !- ridging alone
381         DO jl = 1, jpl
382            DO ji = 1, npti
383               aridge(ji,jl) = apartf(ji,jl)
384               araft (ji,jl) = 0._wp
385            END DO
386         END DO
387      ELSEIF( ln_rafting .AND. .NOT. ln_ridging ) THEN   !- rafting alone   
388         DO jl = 1, jpl
389            DO ji = 1, npti
390               aridge(ji,jl) = 0._wp
391               araft (ji,jl) = apartf(ji,jl)
392            END DO
393         END DO
394      ELSE                                               !- no ridging & no rafting
395         DO jl = 1, jpl
396            DO ji = 1, npti
397               aridge(ji,jl) = 0._wp
398               araft (ji,jl) = 0._wp         
399            END DO
400         END DO
401      ENDIF
402
403      ! 2) Transfer function
404      !-----------------------------------------------------------------
405      ! Compute max and min ridged ice thickness for each ridging category.
406      ! Assume ridged ice is uniformly distributed between hrmin and hrmax.
407      !
408      ! This parameterization is a modified version of Hibler (1980).
409      ! The mean ridging thickness, zhmean, is proportional to hi^(0.5)
410      !  and for very thick ridging ice must be >= hrdg_hi_min*hi
411      !
412      ! The minimum ridging thickness, hrmin, is equal to 2*hi
413      !  (i.e., rafting) and for very thick ridging ice is
414      !  constrained by hrmin <= (zhmean + hi)/2.
415      !
416      ! The maximum ridging thickness, hrmax, is determined by zhmean and hrmin.
417      !
418      ! These modifications have the effect of reducing the ice strength
419      ! (relative to the Hibler formulation) when very thick ice is ridging.
420      !
421      ! zaksum = net area removed/ total area removed
422      ! where total area removed = area of ice that ridges
423      !         net area removed = total area removed - area of new ridges
424      !-----------------------------------------------------------------
425      zfac = 1._wp / hi_hrft
426      zaksum(1:npti) = apartf(1:npti,0)
427      !
428      DO jl = 1, jpl
429         DO ji = 1, npti
430            IF ( apartf(ji,jl) > 0._wp ) THEN
431               zhmean         = MAX( SQRT( rn_hstar * zhi(ji,jl) ), zhi(ji,jl) * hrdg_hi_min )
432               hrmin  (ji,jl) = MIN( 2._wp * zhi(ji,jl), 0.5_wp * ( zhmean + zhi(ji,jl) ) )
433               hrmax  (ji,jl) = 2._wp * zhmean - hrmin(ji,jl)
434               hraft  (ji,jl) = zhi(ji,jl) * zfac
435               hi_hrdg(ji,jl) = zhi(ji,jl) / MAX( zhmean, epsi20 )
436               !
437               ! Normalization factor : zaksum, ensures mass conservation
438               zaksum(ji) = zaksum(ji) + aridge(ji,jl) * ( 1._wp - hi_hrdg(ji,jl) )    &
439                  &                    + araft (ji,jl) * ( 1._wp - hi_hrft )
440            ELSE
441               hrmin  (ji,jl) = 0._wp 
442               hrmax  (ji,jl) = 0._wp 
443               hraft  (ji,jl) = 0._wp 
444               hi_hrdg(ji,jl) = 1._wp
445            ENDIF
446         END DO
447      END DO
448      !
449      ! 3) closing_gross
450      !-----------------
451      ! Based on the ITD of ridging and ridged ice, convert the net closing rate to a gross closing rate. 
452      ! NOTE: 0 < aksum <= 1
453      WHERE( zaksum(1:npti) > epsi20 )   ;   closing_gross(1:npti) = pclosing_net(1:npti) / zaksum(1:npti)
454      ELSEWHERE                          ;   closing_gross(1:npti) = 0._wp
455      END WHERE
456     
457      ! correction to closing rate if excessive ice removal
458      !----------------------------------------------------
459      ! Reduce the closing rate if more than 100% of any ice category would be removed
460      ! Reduce the opening rate in proportion
461      DO jl = 1, jpl
462         DO ji = 1, npti
463            zfac = apartf(ji,jl) * closing_gross(ji) * rdt_ice
464            IF( zfac > pa_i(ji,jl) .AND. apartf(ji,jl) /= 0._wp ) THEN
465               closing_gross(ji) = pa_i(ji,jl) / apartf(ji,jl) * r1_rdtice
466            ENDIF
467         END DO
468      END DO     
469
470      ! 4) correction to opening if excessive open water removal
471      !---------------------------------------------------------
472      ! Reduce the closing rate if more than 100% of the open water would be removed
473      ! Reduce the opening rate in proportion
474      DO ji = 1, npti 
475         zfac = pato_i(ji) + ( opning(ji) - apartf(ji,0) * closing_gross(ji) ) * rdt_ice
476         IF( zfac < 0._wp ) THEN           ! would lead to negative ato_i
477            opning(ji) = apartf(ji,0) * closing_gross(ji) - pato_i(ji) * r1_rdtice 
478         ELSEIF( zfac > zasum(ji) ) THEN   ! would lead to ato_i > asum
479            opning(ji) = apartf(ji,0) * closing_gross(ji) + ( zasum(ji) - pato_i(ji) ) * r1_rdtice 
480         ENDIF
481      END DO
482      !
483   END SUBROUTINE rdgrft_prep
484
485
486   SUBROUTINE rdgrft_shift
487      !!-------------------------------------------------------------------
488      !!                ***  ROUTINE rdgrft_shift ***
489      !!
490      !! ** Purpose :   shift ridging ice among thickness categories of ice thickness
491      !!
492      !! ** Method  :   Remove area, volume, and energy from each ridging category
493      !!                and add to thicker ice categories.
494      !!-------------------------------------------------------------------
495      !
496      INTEGER  ::   ji, jj, jl, jl1, jl2, jk   ! dummy loop indices
497      REAL(wp) ::   hL, hR, farea              ! left and right limits of integration and new area going to jl2
498      REAL(wp) ::   vsw                        ! vol of water trapped into ridges
499      REAL(wp) ::   afrdg, afrft               ! fraction of category area ridged/rafted
500      REAL(wp)                  ::   airdg1, oirdg1, aprdg1, virdg1, sirdg1
501      REAL(wp)                  ::   airft1, oirft1, aprft1
502      REAL(wp), DIMENSION(jpij) ::   airdg2, oirdg2, aprdg2, virdg2, sirdg2, vsrdg, vprdg  ! area etc of new ridges
503      REAL(wp), DIMENSION(jpij) ::   airft2, oirft2, aprft2, virft , sirft , vsrft, vprft  ! area etc of rafted ice
504      !
505      REAL(wp), DIMENSION(jpij) ::   ersw             ! enth of water trapped into ridges
506      REAL(wp), DIMENSION(jpij) ::   zswitch, fvol    ! new ridge volume going to jl2
507      REAL(wp), DIMENSION(jpij) ::   z1_ai            ! 1 / a
508      REAL(wp), DIMENSION(jpij) ::   zvti             ! sum(v_i)
509      !
510      REAL(wp), DIMENSION(jpij,nlay_s) ::   esrft     ! snow energy of rafting ice
511      REAL(wp), DIMENSION(jpij,nlay_i) ::   eirft     ! ice  energy of rafting ice
512      REAL(wp), DIMENSION(jpij,nlay_s) ::   esrdg     ! enth*volume of new ridges     
513      REAL(wp), DIMENSION(jpij,nlay_i) ::   eirdg     ! enth*volume of new ridges
514      !
515      INTEGER , DIMENSION(jpij) ::   itest_rdg, itest_rft   ! test for conservation
516      !!-------------------------------------------------------------------
517      !
518      zvti(1:npti) = SUM( v_i_2d(1:npti,:), dim=2 )   ! total ice volume
519      !
520      ! 1) Change in open water area due to closing and opening
521      !--------------------------------------------------------
522      DO ji = 1, npti
523         ato_i_1d(ji) = MAX( 0._wp, ato_i_1d(ji) + ( opning(ji) - apartf(ji,0) * closing_gross(ji) ) * rdt_ice )
524      END DO
525     
526      ! 2) compute categories in which ice is removed (jl1)
527      !----------------------------------------------------
528      DO jl1 = 1, jpl
529
530         CALL tab_2d_1d( npti, nptidx(1:npti), s_i_1d(1:npti), s_i(:,:,jl1) )
531
532         DO ji = 1, npti
533
534            IF( apartf(ji,jl1) > 0._wp .AND. closing_gross(ji) > 0._wp ) THEN   ! only if ice is ridging
535
536               IF( a_i_2d(ji,jl1) > epsi20 ) THEN   ;   z1_ai(ji) = 1._wp / a_i_2d(ji,jl1)
537               ELSE                                 ;   z1_ai(ji) = 0._wp
538               ENDIF
539               
540               ! area of ridging / rafting ice (airdg1) and of new ridge (airdg2)
541               airdg1 = aridge(ji,jl1) * closing_gross(ji) * rdt_ice
542               airft1 = araft (ji,jl1) * closing_gross(ji) * rdt_ice
543
544               airdg2(ji) = airdg1 * hi_hrdg(ji,jl1)
545               airft2(ji) = airft1 * hi_hrft
546
547               ! ridging /rafting fractions
548               afrdg = airdg1 * z1_ai(ji)
549               afrft = airft1 * z1_ai(ji)
550
551               ! volume and enthalpy (J/m2, >0) of seawater trapped into ridges
552               IF    ( zvti(ji) <= 10. ) THEN ; vsw = v_i_2d(ji,jl1) * afrdg * rn_porordg                                           ! v <= 10m then porosity = rn_porordg
553               ELSEIF( zvti(ji) >= 20. ) THEN ; vsw = 0._wp                                                                         ! v >= 20m then porosity = 0
554               ELSE                           ; vsw = v_i_2d(ji,jl1) * afrdg * rn_porordg * MAX( 0._wp, 2._wp - 0.1_wp * zvti(ji) ) ! v > 10m and v < 20m then porosity = linear transition to 0
555               ENDIF
556               ersw(ji) = -rhoi * vsw * rcp * sst_1d(ji)   ! clem: if sst>0, then ersw <0 (is that possible?)
557
558               ! volume etc of ridging / rafting ice and new ridges (vi, vs, sm, oi, es, ei)
559               virdg1     = v_i_2d (ji,jl1)   * afrdg
560               virdg2(ji) = v_i_2d (ji,jl1)   * afrdg + vsw
561               vsrdg(ji)  = v_s_2d (ji,jl1)   * afrdg
562               sirdg1     = sv_i_2d(ji,jl1)   * afrdg
563               sirdg2(ji) = sv_i_2d(ji,jl1)   * afrdg + vsw * sss_1d(ji)
564               oirdg1     = oa_i_2d(ji,jl1)   * afrdg
565               oirdg2(ji) = oa_i_2d(ji,jl1)   * afrdg * hi_hrdg(ji,jl1) 
566
567               virft(ji)  = v_i_2d (ji,jl1)   * afrft
568               vsrft(ji)  = v_s_2d (ji,jl1)   * afrft
569               sirft(ji)  = sv_i_2d(ji,jl1)   * afrft 
570               oirft1     = oa_i_2d(ji,jl1)   * afrft 
571               oirft2(ji) = oa_i_2d(ji,jl1)   * afrft * hi_hrft 
572
573               IF ( ln_pnd_H12 ) THEN
574                  aprdg1     = a_ip_2d(ji,jl1) * afrdg
575                  aprdg2(ji) = a_ip_2d(ji,jl1) * afrdg * hi_hrdg(ji,jl1)
576                  vprdg (ji) = v_ip_2d(ji,jl1) * afrdg
577                  lhprdg(ji) = lh_ip_2d(ji,jl1) * afrdg
578                  aprft1     = a_ip_2d(ji,jl1) * afrft
579                  aprft2(ji) = a_ip_2d(ji,jl1) * afrft * hi_hrft
580                  vprft (ji) = v_ip_2d(ji,jl1) * afrft
581                  lhprft(ji) = lh_ip_2d(ji,jl1) * afrft
582               ENDIF
583
584               ! Ice-ocean exchanges associated with ice porosity
585               wfx_dyn_1d(ji) = wfx_dyn_1d(ji) - vsw * rhoi * r1_rdtice   ! increase in ice volume due to seawater frozen in voids
586               sfx_dyn_1d(ji) = sfx_dyn_1d(ji) - vsw * sss_1d(ji) * rhoi * r1_rdtice
587               hfx_dyn_1d(ji) = hfx_dyn_1d(ji) + ersw(ji) * r1_rdtice          ! > 0 [W.m-2]
588
589               ! Put the snow lost by ridging into the ocean
590               !  Note that esrdg > 0; the ocean must cool to melt snow. If the ocean temp = Tf already, new ice must grow.
591               wfx_snw_dyn_1d(ji) = wfx_snw_dyn_1d(ji) + ( rhos * vsrdg(ji) * ( 1._wp - rn_fsnwrdg )   &   ! fresh water source for ocean
592                  &                                      + rhos * vsrft(ji) * ( 1._wp - rn_fsnwrft ) ) * r1_rdtice
593
594               ! virtual salt flux to keep salinity constant
595               IF( nn_icesal /= 2 )  THEN
596                  sirdg2(ji)     = sirdg2(ji)     - vsw * ( sss_1d(ji) - s_i_1d(ji) )        ! ridge salinity = s_i
597                  sfx_bri_1d(ji) = sfx_bri_1d(ji) + sss_1d(ji) * vsw * rhoi * r1_rdtice  &  ! put back sss_m into the ocean
598                     &                            - s_i_1d(ji) * vsw * rhoi * r1_rdtice     ! and get  s_i  from the ocean
599               ENDIF
600
601               ! Remove area, volume of new ridge to each category jl1
602               !------------------------------------------------------
603               a_i_2d (ji,jl1) = a_i_2d (ji,jl1) - airdg1    - airft1
604               v_i_2d (ji,jl1) = v_i_2d (ji,jl1) - virdg1    - virft(ji)
605               v_s_2d (ji,jl1) = v_s_2d (ji,jl1) - vsrdg(ji) - vsrft(ji)
606               sv_i_2d(ji,jl1) = sv_i_2d(ji,jl1) - sirdg1    - sirft(ji)
607               oa_i_2d(ji,jl1) = oa_i_2d(ji,jl1) - oirdg1    - oirft1
608               IF ( ln_pnd_H12 ) THEN
609                  a_ip_2d(ji,jl1) = a_ip_2d(ji,jl1) - aprdg1    - aprft1
610                  v_ip_2d(ji,jl1) = v_ip_2d(ji,jl1) - vprdg(ji) - vprft(ji)
611                  lh_ip_2d(ji,jl1) = lh_ip_2d(ji,jl1) - lhprdg(ji) - lhprft(ji)
612               ENDIF
613            ENDIF
614
615         END DO ! ji
616
617         ! special loop for e_s because of layers jk
618         DO jk = 1, nlay_s
619            DO ji = 1, npti
620               IF( apartf(ji,jl1) > 0._wp .AND. closing_gross(ji) > 0._wp ) THEN
621                  ! Compute ridging /rafting fractions
622                  afrdg = aridge(ji,jl1) * closing_gross(ji) * rdt_ice * z1_ai(ji)
623                  afrft = araft (ji,jl1) * closing_gross(ji) * rdt_ice * z1_ai(ji)
624                  ! Compute ridging /rafting ice and new ridges for es
625                  esrdg(ji,jk) = ze_s_2d (ji,jk,jl1) * afrdg
626                  esrft(ji,jk) = ze_s_2d (ji,jk,jl1) * afrft
627                  ! Put the snow lost by ridging into the ocean
628                  hfx_dyn_1d(ji) = hfx_dyn_1d(ji) + ( - esrdg(ji,jk) * ( 1._wp - rn_fsnwrdg )   &                 ! heat sink for ocean (<0, W.m-2)
629                     &                                - esrft(ji,jk) * ( 1._wp - rn_fsnwrft ) ) * r1_rdtice
630                  !
631                  ! Remove energy of new ridge to each category jl1
632                  !-------------------------------------------------
633                  ze_s_2d(ji,jk,jl1) = ze_s_2d(ji,jk,jl1) * ( 1._wp - afrdg - afrft ) 
634               ENDIF
635            END DO
636         END DO
637                 
638         ! special loop for e_i because of layers jk
639         DO jk = 1, nlay_i
640            DO ji = 1, npti
641               IF( apartf(ji,jl1) > 0._wp .AND. closing_gross(ji) > 0._wp ) THEN
642                  ! Compute ridging /rafting fractions
643                  afrdg = aridge(ji,jl1) * closing_gross(ji) * rdt_ice * z1_ai(ji)
644                  afrft = araft (ji,jl1) * closing_gross(ji) * rdt_ice * z1_ai(ji)
645                  ! Compute ridging ice and new ridges for ei
646                  eirdg(ji,jk) = ze_i_2d (ji,jk,jl1) * afrdg + ersw(ji) * r1_nlay_i
647                  eirft(ji,jk) = ze_i_2d (ji,jk,jl1) * afrft
648                  !
649                  ! Remove energy of new ridge to each category jl1
650                  !-------------------------------------------------
651                  ze_i_2d(ji,jk,jl1) = ze_i_2d(ji,jk,jl1) * ( 1._wp - afrdg - afrft ) 
652               ENDIF
653            END DO
654         END DO
655         
656         ! 3) compute categories in which ice is added (jl2)
657         !--------------------------------------------------
658         itest_rdg(1:npti) = 0
659         itest_rft(1:npti) = 0
660         DO jl2  = 1, jpl 
661            !
662            DO ji = 1, npti
663
664               IF( apartf(ji,jl1) > 0._wp .AND. closing_gross(ji) > 0._wp ) THEN
665
666                  ! Compute the fraction of ridged ice area and volume going to thickness category jl2
667                  IF( hrmin(ji,jl1) <= hi_max(jl2) .AND. hrmax(ji,jl1) > hi_max(jl2-1) ) THEN
668                     hL = MAX( hrmin(ji,jl1), hi_max(jl2-1) )
669                     hR = MIN( hrmax(ji,jl1), hi_max(jl2)   )
670                     farea    = ( hR      - hL      ) / ( hrmax(ji,jl1)                 - hrmin(ji,jl1)                 )
671                     fvol(ji) = ( hR * hR - hL * hL ) / ( hrmax(ji,jl1) * hrmax(ji,jl1) - hrmin(ji,jl1) * hrmin(ji,jl1) )
672                     !
673                     itest_rdg(ji) = 1   ! test for conservation
674                  ELSE
675                     farea    = 0._wp 
676                     fvol(ji) = 0._wp                 
677                  ENDIF
678
679                  ! Compute the fraction of rafted ice area and volume going to thickness category jl2
680                  IF( hraft(ji,jl1) <= hi_max(jl2) .AND. hraft(ji,jl1) >  hi_max(jl2-1) ) THEN
681                     zswitch(ji) = 1._wp
682                     !
683                     itest_rft(ji) = 1   ! test for conservation
684                  ELSE
685                     zswitch(ji) = 0._wp
686                  ENDIF
687                  !
688                  ! Patch to ensure perfect conservation if ice thickness goes mad
689                  ! Sometimes thickness is larger than hi_max(jpl) because of advection scheme (for very small areas)
690                  ! Then ice volume is removed from one category but the ridging/rafting scheme
691                  ! does not know where to move it, leading to a conservation issue. 
692                  IF( itest_rdg(ji) == 0 .AND. jl2 == jpl ) THEN   ;   farea = 1._wp   ;   fvol(ji) = 1._wp   ;   ENDIF
693                  IF( itest_rft(ji) == 0 .AND. jl2 == jpl )      zswitch(ji) = 1._wp
694                  !
695                  ! Add area, volume of new ridge to category jl2
696                  !----------------------------------------------
697                  a_i_2d (ji,jl2) = a_i_2d (ji,jl2) + ( airdg2(ji) * farea    + airft2(ji) * zswitch(ji) )
698                  oa_i_2d(ji,jl2) = oa_i_2d(ji,jl2) + ( oirdg2(ji) * farea    + oirft2(ji) * zswitch(ji) )
699                  v_i_2d (ji,jl2) = v_i_2d (ji,jl2) + ( virdg2(ji) * fvol(ji) + virft (ji) * zswitch(ji) )
700                  sv_i_2d(ji,jl2) = sv_i_2d(ji,jl2) + ( sirdg2(ji) * fvol(ji) + sirft (ji) * zswitch(ji) )
701                  v_s_2d (ji,jl2) = v_s_2d (ji,jl2) + ( vsrdg (ji) * rn_fsnwrdg * fvol(ji)  +  &
702                     &                                  vsrft (ji) * rn_fsnwrft * zswitch(ji) )
703                  IF ( ln_pnd_H12 ) THEN
704                     v_ip_2d (ji,jl2) = v_ip_2d(ji,jl2) + (   vprdg (ji) * rn_fpndrdg * fvol   (ji)   &
705                        &                                   + vprft (ji) * rn_fpndrft * zswitch(ji)   )
706                     a_ip_2d (ji,jl2) = a_ip_2d(ji,jl2) + (   aprdg2(ji) * rn_fpndrdg * farea         & 
707                        &                                   + aprft2(ji) * rn_fpndrft * zswitch(ji)   )
708                     lh_ip_2d (ji,jl2) = lh_ip_2d(ji,jl2) + (   lhprdg (ji) * rn_fpndrdg * fvol   (ji)   &
709                        &                                   + lhprft (ji) * rn_fpndrft * zswitch(ji)   )
710                  ENDIF
711                 
712               ENDIF
713
714            END DO
715            ! Add snow energy of new ridge to category jl2
716            !---------------------------------------------
717            DO jk = 1, nlay_s
718               DO ji = 1, npti
719                  IF( apartf(ji,jl1) > 0._wp .AND. closing_gross(ji) > 0._wp )   &
720                     &   ze_s_2d(ji,jk,jl2) = ze_s_2d(ji,jk,jl2) + ( esrdg(ji,jk) * rn_fsnwrdg * fvol(ji)  +  &
721                     &                                               esrft(ji,jk) * rn_fsnwrft * zswitch(ji) )
722               END DO
723            END DO
724            ! Add ice energy of new ridge to category jl2
725            !--------------------------------------------
726            DO jk = 1, nlay_i
727               DO ji = 1, npti
728                  IF( apartf(ji,jl1) > 0._wp .AND. closing_gross(ji) > 0._wp )   &
729                     &   ze_i_2d(ji,jk,jl2) = ze_i_2d(ji,jk,jl2) + eirdg(ji,jk) * fvol(ji) + eirft(ji,jk) * zswitch(ji)                 
730               END DO
731            END DO
732            !
733         END DO ! jl2
734         !
735      END DO ! jl1
736      !
737      ! roundoff errors
738      !----------------
739      ! In case ridging/rafting lead to very small negative values (sometimes it happens)
740      CALL ice_var_roundoff( a_i_2d, v_i_2d, v_s_2d, sv_i_2d, oa_i_2d, a_ip_2d, v_ip_2d, lh_ip_2d, ze_s_2d, ze_i_2d )
741      !
742   END SUBROUTINE rdgrft_shift
743
744
745   SUBROUTINE ice_strength
746      !!----------------------------------------------------------------------
747      !!                ***  ROUTINE ice_strength ***
748      !!
749      !! ** Purpose :   computes ice strength used in dynamics routines of ice thickness
750      !!
751      !! ** Method  :   Compute the strength of the ice pack, defined as the energy (J m-2)
752      !!              dissipated per unit area removed from the ice pack under compression,
753      !!              and assumed proportional to the change in potential energy caused
754      !!              by ridging. Note that only Hibler's formulation is stable and that
755      !!              ice strength has to be smoothed
756      !!----------------------------------------------------------------------
757      INTEGER             ::   ji, jj, jl  ! dummy loop indices
758      INTEGER             ::   ismooth     ! smoothing the resistance to deformation
759      INTEGER             ::   itframe     ! number of time steps for the P smoothing
760      REAL(wp)            ::   zp, z1_3    ! local scalars
761      REAL(wp), DIMENSION(jpi,jpj) ::   zworka           ! temporary array used here
762      REAL(wp), DIMENSION(jpi,jpj) ::   zstrp1, zstrp2   ! strength at previous time steps
763      !!----------------------------------------------------------------------
764      !                              !--------------------------------------------------!
765      IF( ln_str_H79 ) THEN          ! Ice strength => Hibler (1979) method             !
766      !                              !--------------------------------------------------!
767         strength(:,:) = rn_pstar * SUM( v_i(:,:,:), dim=3 ) * EXP( -rn_crhg * ( 1._wp - SUM( a_i(:,:,:), dim=3 ) ) )
768         ismooth = 1
769         !                           !--------------------------------------------------!
770      ELSE                           ! Zero strength                                    !
771         !                           !--------------------------------------------------!
772         strength(:,:) = 0._wp
773         ismooth = 0
774      ENDIF
775      !                              !--------------------------------------------------!
776      SELECT CASE( ismooth )         ! Smoothing ice strength                           !
777      !                              !--------------------------------------------------!
778      CASE( 1 )               !--- Spatial smoothing
779         DO jj = 2, jpjm1
780            DO ji = 2, jpim1
781               IF ( SUM( a_i(ji,jj,:) ) > 0._wp ) THEN
782                  zworka(ji,jj) = ( 4.0 * strength(ji,jj)              &
783                     &                  + strength(ji-1,jj) * tmask(ji-1,jj,1) + strength(ji+1,jj) * tmask(ji+1,jj,1) & 
784                     &                  + strength(ji,jj-1) * tmask(ji,jj-1,1) + strength(ji,jj+1) * tmask(ji,jj+1,1) &
785                     &            ) / ( 4.0 + tmask(ji-1,jj,1) + tmask(ji+1,jj,1) + tmask(ji,jj-1,1) + tmask(ji,jj+1,1) )
786               ELSE
787                  zworka(ji,jj) = 0._wp
788               ENDIF
789            END DO
790         END DO
791         
792         DO jj = 2, jpjm1
793            DO ji = 2, jpim1
794               strength(ji,jj) = zworka(ji,jj)
795            END DO
796         END DO
797         CALL lbc_lnk( 'icedyn_rdgrft', strength, 'T', 1. )
798         !
799      CASE( 2 )               !--- Temporal smoothing
800         IF ( kt_ice == nit000 ) THEN
801            zstrp1(:,:) = 0._wp
802            zstrp2(:,:) = 0._wp
803         ENDIF
804         !
805         DO jj = 2, jpjm1
806            DO ji = 2, jpim1
807               IF ( SUM( a_i(ji,jj,:) ) > 0._wp ) THEN
808                  itframe = 1 ! number of time steps for the running mean
809                  IF ( zstrp1(ji,jj) > 0._wp ) itframe = itframe + 1
810                  IF ( zstrp2(ji,jj) > 0._wp ) itframe = itframe + 1
811                  zp = ( strength(ji,jj) + zstrp1(ji,jj) + zstrp2(ji,jj) ) / itframe
812                  zstrp2  (ji,jj) = zstrp1  (ji,jj)
813                  zstrp1  (ji,jj) = strength(ji,jj)
814                  strength(ji,jj) = zp
815               ENDIF
816            END DO
817         END DO
818         CALL lbc_lnk( 'icedyn_rdgrft', strength, 'T', 1. )
819         !
820      END SELECT
821      !
822   END SUBROUTINE ice_strength
823
824   
825   SUBROUTINE ice_dyn_1d2d( kn )
826      !!-----------------------------------------------------------------------
827      !!                   ***  ROUTINE ice_dyn_1d2d ***
828      !!                 
829      !! ** Purpose :   move arrays from 1d to 2d and the reverse
830      !!-----------------------------------------------------------------------
831      INTEGER, INTENT(in) ::   kn   ! 1= from 2D to 1D   ;   2= from 1D to 2D
832      !
833      INTEGER ::   jl, jk   ! dummy loop indices
834      !!-----------------------------------------------------------------------
835      !
836      SELECT CASE( kn )
837      !                    !---------------------!
838      CASE( 1 )            !==  from 2D to 1D  ==!
839         !                 !---------------------!
840         ! fields used but not modified
841         CALL tab_2d_1d( npti, nptidx(1:npti), sss_1d(1:npti), sss_m(:,:) )
842         CALL tab_2d_1d( npti, nptidx(1:npti), sst_1d(1:npti), sst_m(:,:) )
843         ! the following fields are modified in this routine
844         !!CALL tab_2d_1d( npti, nptidx(1:npti), ato_i_1d(1:npti), ato_i(:,:) )
845         !!CALL tab_3d_2d( npti, nptidx(1:npti), a_i_2d(1:npti,1:jpl), a_i(:,:,:) )
846         !!CALL tab_3d_2d( npti, nptidx(1:npti), v_i_2d  (1:npti,1:jpl), v_i  (:,:,:) )
847         CALL tab_3d_2d( npti, nptidx(1:npti), v_s_2d (1:npti,1:jpl), v_s (:,:,:) )
848         CALL tab_3d_2d( npti, nptidx(1:npti), sv_i_2d(1:npti,1:jpl), sv_i(:,:,:) )
849         CALL tab_3d_2d( npti, nptidx(1:npti), oa_i_2d(1:npti,1:jpl), oa_i(:,:,:) )
850         CALL tab_3d_2d( npti, nptidx(1:npti), a_ip_2d(1:npti,1:jpl), a_ip(:,:,:) )
851         CALL tab_3d_2d( npti, nptidx(1:npti), v_ip_2d(1:npti,1:jpl), v_ip(:,:,:) )
852         CALL tab_3d_2d( npti, nptidx(1:npti), lh_ip_2d(1:npti,1:jpl), lh_ip(:,:,:) )
853         DO jl = 1, jpl
854            DO jk = 1, nlay_s
855               CALL tab_2d_1d( npti, nptidx(1:npti), ze_s_2d(1:npti,jk,jl), e_s(:,:,jk,jl) )
856            END DO
857            DO jk = 1, nlay_i
858               CALL tab_2d_1d( npti, nptidx(1:npti), ze_i_2d(1:npti,jk,jl), e_i(:,:,jk,jl) )
859            END DO
860         END DO
861         CALL tab_2d_1d( npti, nptidx(1:npti), sfx_dyn_1d    (1:npti), sfx_dyn    (:,:) )
862         CALL tab_2d_1d( npti, nptidx(1:npti), sfx_bri_1d    (1:npti), sfx_bri    (:,:) )
863         CALL tab_2d_1d( npti, nptidx(1:npti), wfx_dyn_1d    (1:npti), wfx_dyn    (:,:) )
864         CALL tab_2d_1d( npti, nptidx(1:npti), hfx_dyn_1d    (1:npti), hfx_dyn    (:,:) )
865         CALL tab_2d_1d( npti, nptidx(1:npti), wfx_snw_dyn_1d(1:npti), wfx_snw_dyn(:,:) )
866         CALL tab_2d_1d( npti, nptidx(1:npti), wfx_pnd_1d    (1:npti), wfx_pnd    (:,:) )
867         !
868         !                 !---------------------!
869      CASE( 2 )            !==  from 1D to 2D  ==!
870         !                 !---------------------!
871         CALL tab_1d_2d( npti, nptidx(1:npti), ato_i_1d(1:npti), ato_i(:,:) )
872         CALL tab_2d_3d( npti, nptidx(1:npti), a_i_2d (1:npti,1:jpl), a_i (:,:,:) )
873         CALL tab_2d_3d( npti, nptidx(1:npti), v_i_2d (1:npti,1:jpl), v_i (:,:,:) )
874         CALL tab_2d_3d( npti, nptidx(1:npti), v_s_2d (1:npti,1:jpl), v_s (:,:,:) )
875         CALL tab_2d_3d( npti, nptidx(1:npti), sv_i_2d(1:npti,1:jpl), sv_i(:,:,:) )
876         CALL tab_2d_3d( npti, nptidx(1:npti), oa_i_2d(1:npti,1:jpl), oa_i(:,:,:) )
877         CALL tab_2d_3d( npti, nptidx(1:npti), a_ip_2d(1:npti,1:jpl), a_ip(:,:,:) )
878         CALL tab_2d_3d( npti, nptidx(1:npti), v_ip_2d(1:npti,1:jpl), v_ip(:,:,:) )
879         CALL tab_2d_3d( npti, nptidx(1:npti), lh_ip_2d(1:npti,1:jpl), lh_ip(:,:,:) )
880         DO jl = 1, jpl
881            DO jk = 1, nlay_s
882               CALL tab_1d_2d( npti, nptidx(1:npti), ze_s_2d(1:npti,jk,jl), e_s(:,:,jk,jl) )
883            END DO
884            DO jk = 1, nlay_i
885               CALL tab_1d_2d( npti, nptidx(1:npti), ze_i_2d(1:npti,jk,jl), e_i(:,:,jk,jl) )
886            END DO
887         END DO
888         CALL tab_1d_2d( npti, nptidx(1:npti), sfx_dyn_1d    (1:npti), sfx_dyn    (:,:) )
889         CALL tab_1d_2d( npti, nptidx(1:npti), sfx_bri_1d    (1:npti), sfx_bri    (:,:) )
890         CALL tab_1d_2d( npti, nptidx(1:npti), wfx_dyn_1d    (1:npti), wfx_dyn    (:,:) )
891         CALL tab_1d_2d( npti, nptidx(1:npti), hfx_dyn_1d    (1:npti), hfx_dyn    (:,:) )
892         CALL tab_1d_2d( npti, nptidx(1:npti), wfx_snw_dyn_1d(1:npti), wfx_snw_dyn(:,:) )
893         CALL tab_1d_2d( npti, nptidx(1:npti), wfx_pnd_1d    (1:npti), wfx_pnd    (:,:) )
894         !
895      END SELECT
896      !
897   END SUBROUTINE ice_dyn_1d2d
898   
899
900   SUBROUTINE ice_dyn_rdgrft_init
901      !!-------------------------------------------------------------------
902      !!                  ***  ROUTINE ice_dyn_rdgrft_init ***
903      !!
904      !! ** Purpose :   Physical constants and parameters linked
905      !!                to the mechanical ice redistribution
906      !!
907      !! ** Method  :   Read the namdyn_rdgrft namelist
908      !!                and check the parameters values
909      !!                called at the first timestep (nit000)
910      !!
911      !! ** input   :   Namelist namdyn_rdgrft
912      !!-------------------------------------------------------------------
913      INTEGER :: ios                 ! Local integer output status for namelist read
914      !!
915      NAMELIST/namdyn_rdgrft/ ln_str_H79, rn_pstar, rn_crhg, &
916         &                    rn_csrdg  ,                    &
917         &                    ln_partf_lin, rn_gstar,        &
918         &                    ln_partf_exp, rn_astar,        & 
919         &                    ln_ridging, rn_hstar, rn_porordg, rn_fsnwrdg, rn_fpndrdg,  & 
920         &                    ln_rafting, rn_hraft, rn_craft  , rn_fsnwrft, rn_fpndrft
921      !!-------------------------------------------------------------------
922      !
923      REWIND( numnam_ice_ref )              ! Namelist namicetdme in reference namelist : Ice mechanical ice redistribution
924      READ  ( numnam_ice_ref, namdyn_rdgrft, IOSTAT = ios, ERR = 901)
925901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namdyn_rdgrft in reference namelist', lwp )
926      REWIND( numnam_ice_cfg )              ! Namelist namdyn_rdgrft in configuration namelist : Ice mechanical ice redistribution
927      READ  ( numnam_ice_cfg, namdyn_rdgrft, IOSTAT = ios, ERR = 902 )
928902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namdyn_rdgrft in configuration namelist', lwp )
929      IF(lwm) WRITE ( numoni, namdyn_rdgrft )
930      !
931      IF (lwp) THEN                          ! control print
932         WRITE(numout,*)
933         WRITE(numout,*) 'ice_dyn_rdgrft_init: ice parameters for ridging/rafting '
934         WRITE(numout,*) '~~~~~~~~~~~~~~~~~~'
935         WRITE(numout,*) '   Namelist namdyn_rdgrft:'
936         WRITE(numout,*) '      ice strength parameterization Hibler (1979)              ln_str_H79   = ', ln_str_H79 
937         WRITE(numout,*) '            1st bulk-rheology parameter                        rn_pstar     = ', rn_pstar
938         WRITE(numout,*) '            2nd bulk-rhelogy parameter                         rn_crhg      = ', rn_crhg
939         WRITE(numout,*) '      Fraction of shear energy contributing to ridging         rn_csrdg     = ', rn_csrdg 
940         WRITE(numout,*) '      linear ridging participation function                    ln_partf_lin = ', ln_partf_lin
941         WRITE(numout,*) '            Fraction of ice coverage contributing to ridging   rn_gstar     = ', rn_gstar
942         WRITE(numout,*) '      Exponential ridging participation function               ln_partf_exp = ', ln_partf_exp
943         WRITE(numout,*) '            Equivalent to G* for an exponential function       rn_astar     = ', rn_astar
944         WRITE(numout,*) '      Ridging of ice sheets or not                             ln_ridging   = ', ln_ridging
945         WRITE(numout,*) '            max ridged ice thickness                           rn_hstar     = ', rn_hstar
946         WRITE(numout,*) '            Initial porosity of ridges                         rn_porordg   = ', rn_porordg
947         WRITE(numout,*) '            Fraction of snow volume conserved during ridging   rn_fsnwrdg   = ', rn_fsnwrdg 
948         WRITE(numout,*) '            Fraction of pond volume conserved during ridging   rn_fpndrdg   = ', rn_fpndrdg 
949         WRITE(numout,*) '      Rafting of ice sheets or not                             ln_rafting   = ', ln_rafting
950         WRITE(numout,*) '            Parmeter thickness (threshold between ridge-raft)  rn_hraft     = ', rn_hraft
951         WRITE(numout,*) '            Rafting hyperbolic tangent coefficient             rn_craft     = ', rn_craft 
952         WRITE(numout,*) '            Fraction of snow volume conserved during rafting   rn_fsnwrft   = ', rn_fsnwrft 
953         WRITE(numout,*) '            Fraction of pond volume conserved during rafting   rn_fpndrft   = ', rn_fpndrft 
954      ENDIF
955      !
956      IF ( ( ln_partf_lin .AND. ln_partf_exp ) .OR. ( .NOT.ln_partf_lin .AND. .NOT.ln_partf_exp ) ) THEN
957         CALL ctl_stop( 'ice_dyn_rdgrft_init: choose one and only one participation function (ln_partf_lin or ln_partf_exp)' )
958      ENDIF
959      !
960      IF( .NOT. ln_icethd ) THEN
961         rn_porordg = 0._wp
962         rn_fsnwrdg = 1._wp ; rn_fsnwrft = 1._wp
963         rn_fpndrdg = 1._wp ; rn_fpndrft = 1._wp
964         IF( lwp ) THEN
965            WRITE(numout,*) '      ==> only ice dynamics is activated, thus some parameters must be changed'
966            WRITE(numout,*) '            rn_porordg   = ', rn_porordg
967            WRITE(numout,*) '            rn_fsnwrdg   = ', rn_fsnwrdg 
968            WRITE(numout,*) '            rn_fpndrdg   = ', rn_fpndrdg 
969            WRITE(numout,*) '            rn_fsnwrft   = ', rn_fsnwrft 
970            WRITE(numout,*) '            rn_fpndrft   = ', rn_fpndrft 
971         ENDIF
972      ENDIF
973      !                              ! allocate arrays
974      IF( ice_dyn_rdgrft_alloc() /= 0 )   CALL ctl_stop( 'STOP', 'ice_dyn_rdgrft_init: unable to allocate arrays' )
975      !
976  END SUBROUTINE ice_dyn_rdgrft_init
977
978#else
979   !!----------------------------------------------------------------------
980   !!   Default option         Empty module           NO SI3 sea-ice model
981   !!----------------------------------------------------------------------
982#endif
983
984   !!======================================================================
985END MODULE icedyn_rdgrft
Note: See TracBrowser for help on using the repository browser.