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/2018/dev_r10164_HPC09_ESIWACE_PREP_MERGE/src/ICE – NEMO

source: NEMO/branches/2018/dev_r10164_HPC09_ESIWACE_PREP_MERGE/src/ICE/icedyn_rdgrft.F90 @ 10420

Last change on this file since 10420 was 10420, checked in by smasson, 5 years ago

dev_r10164_HPC09_ESIWACE_PREP_MERGE: force STOP when fail to allocate array, see #2133

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