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

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

source: branches/2015/dev_r5044_CNRS_LIM3CLEAN/NEMOGCM/NEMO/LIM_SRC_3/limthd_dif.F90 @ 5059

Last change on this file since 5059 was 5055, checked in by clem, 9 years ago

LIM3: removing par_ice and put jpl, nlay_i and nlay_s as namelist parameters

  • Property svn:keywords set to Id
File size: 42.7 KB
Line 
1MODULE limthd_dif
2   !!======================================================================
3   !!                       ***  MODULE limthd_dif ***
4   !!                       heat diffusion in sea ice
5   !!                   computation of surface and inner T 
6   !!======================================================================
7   !! History :  LIM  ! 02-2003 (M. Vancoppenolle) original 1D code
8   !!                 ! 06-2005 (M. Vancoppenolle) 3d version
9   !!                 ! 11-2006 (X Fettweis) Vectorization by Xavier
10   !!                 ! 04-2007 (M. Vancoppenolle) Energy conservation
11   !!            4.0  ! 2011-02 (G. Madec) dynamical allocation
12   !!             -   ! 2012-05 (C. Rousset) add penetration solar flux
13   !!----------------------------------------------------------------------
14#if defined key_lim3
15   !!----------------------------------------------------------------------
16   !!   'key_lim3'                                      LIM3 sea-ice model
17   !!----------------------------------------------------------------------
18   USE par_oce        ! ocean parameters
19   USE phycst         ! physical constants (ocean directory)
20   USE ice            ! LIM-3 variables
21   USE thd_ice        ! LIM-3: thermodynamics
22   USE in_out_manager ! I/O manager
23   USE lib_mpp        ! MPP library
24   USE wrk_nemo       ! work arrays
25   USE lib_fortran    ! Fortran utilities (allows no signed zero when 'key_nosignedzero' defined) 
26   USE sbc_oce, ONLY : lk_cpl
27
28   IMPLICIT NONE
29   PRIVATE
30
31   PUBLIC   lim_thd_dif   ! called by lim_thd
32
33   !!----------------------------------------------------------------------
34   !! NEMO/LIM3 4.0 , UCL - NEMO Consortium (2011)
35   !! $Id$
36   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
37   !!----------------------------------------------------------------------
38CONTAINS
39
40   SUBROUTINE lim_thd_dif( kideb , kiut )
41      !!------------------------------------------------------------------
42      !!                ***  ROUTINE lim_thd_dif  ***
43      !! ** Purpose :
44      !!           This routine determines the time evolution of snow and sea-ice
45      !!           temperature profiles.
46      !! ** Method  :
47      !!           This is done by solving the heat equation diffusion with
48      !!           a Neumann boundary condition at the surface and a Dirichlet one
49      !!           at the bottom. Solar radiation is partially absorbed into the ice.
50      !!           The specific heat and thermal conductivities depend on ice salinity
51      !!           and temperature to take into account brine pocket melting. The
52      !!           numerical
53      !!           scheme is an iterative Crank-Nicolson on a non-uniform multilayer grid
54      !!           in the ice and snow system.
55      !!
56      !!           The successive steps of this routine are
57      !!           1.  Thermal conductivity at the interfaces of the ice layers
58      !!           2.  Internal absorbed radiation
59      !!           3.  Scale factors due to non-uniform grid
60      !!           4.  Kappa factors
61      !!           Then iterative procedure begins
62      !!           5.  specific heat in the ice
63      !!           6.  eta factors
64      !!           7.  surface flux computation
65      !!           8.  tridiagonal system terms
66      !!           9.  solving the tridiagonal system with Gauss elimination
67      !!           Iterative procedure ends according to a criterion on evolution
68      !!           of temperature
69      !!
70      !! ** Arguments :
71      !!           kideb , kiut : Starting and ending points on which the
72      !!                         the computation is applied
73      !!
74      !! ** Inputs / Ouputs : (global commons)
75      !!           surface temperature : t_su_1d
76      !!           ice/snow temperatures   : t_i_1d, t_s_1d
77      !!           ice salinities          : s_i_1d
78      !!           number of layers in the ice/snow: nlay_i, nlay_s
79      !!           profile of the ice/snow layers : z_i, z_s
80      !!           total ice/snow thickness : ht_i_1d, ht_s_1d
81      !!
82      !! ** External :
83      !!
84      !! ** References :
85      !!
86      !! ** History :
87      !!           (02-2003) Martin Vancoppenolle, Louvain-la-Neuve, Belgium
88      !!           (06-2005) Martin Vancoppenolle, 3d version
89      !!           (11-2006) Vectorized by Xavier Fettweis (UCL-ASTR)
90      !!           (04-2007) Energy conservation tested by M. Vancoppenolle
91      !!------------------------------------------------------------------
92      INTEGER , INTENT(in) ::   kideb, kiut   ! Start/End point on which the  the computation is applied
93
94      !! * Local variables
95      INTEGER ::   ji          ! spatial loop index
96      INTEGER ::   ii, ij      ! temporary dummy loop index
97      INTEGER ::   numeq       ! current reference number of equation
98      INTEGER ::   jk       ! vertical dummy loop index
99      INTEGER ::   nconv       ! number of iterations in iterative procedure
100      INTEGER ::   minnumeqmin, maxnumeqmax
101     
102      INTEGER, POINTER, DIMENSION(:) ::   numeqmin   ! reference number of top equation
103      INTEGER, POINTER, DIMENSION(:) ::   numeqmax   ! reference number of bottom equation
104      INTEGER, POINTER, DIMENSION(:) ::   isnow      ! switch for presence (1) or absence (0) of snow
105     
106      REAL(wp) ::   zg1s      =  2._wp        ! for the tridiagonal system
107      REAL(wp) ::   zg1       =  2._wp        !
108      REAL(wp) ::   zgamma    =  18009._wp    ! for specific heat
109      REAL(wp) ::   zbeta     =  0.117_wp     ! for thermal conductivity (could be 0.13)
110      REAL(wp) ::   zraext_s  =  10._wp       ! extinction coefficient of radiation in the snow
111      REAL(wp) ::   zkimin    =  0.10_wp      ! minimum ice thermal conductivity
112      REAL(wp) ::   ztsu_err  =  1.e-5_wp     ! range around which t_su is considered as 0°C
113      REAL(wp) ::   ztmelt_i    ! ice melting temperature
114      REAL(wp) ::   zerritmax   ! current maximal error on temperature
115      REAL(wp) ::   zhsu
116     
117      REAL(wp), POINTER, DIMENSION(:)     ::   ztsub       ! old surface temperature (before the iterative procedure )
118      REAL(wp), POINTER, DIMENSION(:)     ::   ztsubit     ! surface temperature at previous iteration
119      REAL(wp), POINTER, DIMENSION(:)     ::   zh_i        ! ice layer thickness
120      REAL(wp), POINTER, DIMENSION(:)     ::   zh_s        ! snow layer thickness
121      REAL(wp), POINTER, DIMENSION(:)     ::   zfsw        ! solar radiation absorbed at the surface
122      REAL(wp), POINTER, DIMENSION(:)     ::   zf          ! surface flux function
123      REAL(wp), POINTER, DIMENSION(:)     ::   dzf         ! derivative of the surface flux function
124      REAL(wp), POINTER, DIMENSION(:)     ::   zerrit      ! current error on temperature
125      REAL(wp), POINTER, DIMENSION(:)     ::   zdifcase    ! case of the equation resolution (1->4)
126      REAL(wp), POINTER, DIMENSION(:)     ::   zftrice     ! solar radiation transmitted through the ice
127      REAL(wp), POINTER, DIMENSION(:)     ::   zihic
128     
129      REAL(wp), POINTER, DIMENSION(:,:)   ::   ztcond_i    ! Ice thermal conductivity
130      REAL(wp), POINTER, DIMENSION(:,:)   ::   zradtr_i    ! Radiation transmitted through the ice
131      REAL(wp), POINTER, DIMENSION(:,:)   ::   zradab_i    ! Radiation absorbed in the ice
132      REAL(wp), POINTER, DIMENSION(:,:)   ::   zkappa_i    ! Kappa factor in the ice
133      REAL(wp), POINTER, DIMENSION(:,:)   ::   ztib        ! Old temperature in the ice
134      REAL(wp), POINTER, DIMENSION(:,:)   ::   zeta_i      ! Eta factor in the ice
135      REAL(wp), POINTER, DIMENSION(:,:)   ::   ztitemp     ! Temporary temperature in the ice to check the convergence
136      REAL(wp), POINTER, DIMENSION(:,:)   ::   zspeche_i   ! Ice specific heat
137      REAL(wp), POINTER, DIMENSION(:,:)   ::   z_i         ! Vertical cotes of the layers in the ice
138      REAL(wp), POINTER, DIMENSION(:,:)   ::   zradtr_s    ! Radiation transmited through the snow
139      REAL(wp), POINTER, DIMENSION(:,:)   ::   zradab_s    ! Radiation absorbed in the snow
140      REAL(wp), POINTER, DIMENSION(:,:)   ::   zkappa_s    ! Kappa factor in the snow
141      REAL(wp), POINTER, DIMENSION(:,:)   ::   zeta_s      ! Eta factor in the snow
142      REAL(wp), POINTER, DIMENSION(:,:)   ::   ztstemp     ! Temporary temperature in the snow to check the convergence
143      REAL(wp), POINTER, DIMENSION(:,:)   ::   ztsb        ! Temporary temperature in the snow
144      REAL(wp), POINTER, DIMENSION(:,:)   ::   z_s         ! Vertical cotes of the layers in the snow
145      REAL(wp), POINTER, DIMENSION(:,:)   ::   zindterm    ! 'Ind'ependent term
146      REAL(wp), POINTER, DIMENSION(:,:)   ::   zindtbis    ! Temporary 'ind'ependent term
147      REAL(wp), POINTER, DIMENSION(:,:)   ::   zdiagbis    ! Temporary 'dia'gonal term
148      REAL(wp), POINTER, DIMENSION(:,:,:) ::   ztrid       ! Tridiagonal system terms
149     
150      ! diag errors on heat
151      REAL(wp), POINTER, DIMENSION(:)     :: zdq, zq_ini, zhfx_err
152     
153      ! Mono-category
154      REAL(wp)                            :: zepsilon      ! determines thres. above which computation of G(h) is done
155      REAL(wp)                            :: zratio_s      ! dummy factor
156      REAL(wp)                            :: zratio_i      ! dummy factor
157      REAL(wp)                            :: zh_thres      ! thickness thres. for G(h) computation
158      REAL(wp)                            :: zhe           ! dummy factor
159      REAL(wp)                            :: zswitch       ! dummy switch
160      REAL(wp)                            :: zkimean       ! mean sea ice thermal conductivity
161      REAL(wp)                            :: zfac          ! dummy factor
162      REAL(wp)                            :: zihe          ! dummy factor
163      REAL(wp)                            :: zheshth       ! dummy factor
164     
165      REAL(wp), POINTER, DIMENSION(:)     :: zghe          ! G(he), th. conduct enhancement factor, mono-cat
166     
167      !!------------------------------------------------------------------     
168      !
169      CALL wrk_alloc( jpij, numeqmin, numeqmax, isnow )
170      CALL wrk_alloc( jpij, ztsub, ztsubit, zh_i, zh_s, zfsw )
171      CALL wrk_alloc( jpij, zf, dzf, zerrit, zdifcase, zftrice, zihic, zghe )
172      CALL wrk_alloc( jpij, nlay_i+1, ztcond_i, zradtr_i, zradab_i, zkappa_i, ztib, zeta_i, ztitemp, z_i, zspeche_i, kjstart=0)
173      CALL wrk_alloc( jpij, nlay_s+1,           zradtr_s, zradab_s, zkappa_s, ztsb, zeta_s, ztstemp, z_s, kjstart=0)
174      CALL wrk_alloc( jpij, nlay_i+3, zindterm, zindtbis, zdiagbis  )
175      CALL wrk_alloc( jpij, nlay_i+3, 3, ztrid )
176
177      CALL wrk_alloc( jpij, zdq, zq_ini, zhfx_err )
178
179      ! --- diag error on heat diffusion - PART 1 --- !
180      zdq(:) = 0._wp ; zq_ini(:) = 0._wp     
181      DO ji = kideb, kiut
182         zq_ini(ji) = ( SUM( q_i_1d(ji,1:nlay_i) ) * ht_i_1d(ji) / REAL( nlay_i ) +  &
183            &           SUM( q_s_1d(ji,1:nlay_s) ) * ht_s_1d(ji) / REAL( nlay_s ) ) 
184      END DO
185
186      !------------------------------------------------------------------------------!
187      ! 1) Initialization                                                            !
188      !------------------------------------------------------------------------------!
189      DO ji = kideb , kiut
190         ! is there snow or not
191         isnow(ji)= NINT(  1._wp - MAX( 0._wp , SIGN(1._wp, - ht_s_1d(ji) ) )  )
192         ! layer thickness
193         zh_i(ji) = ht_i_1d(ji) / REAL( nlay_i )
194         zh_s(ji) = ht_s_1d(ji) / REAL( nlay_s )
195      END DO
196
197      !--------------------
198      ! Ice / snow layers
199      !--------------------
200
201      z_s(:,0) = 0._wp   ! vert. coord. of the up. lim. of the 1st snow layer
202      z_i(:,0) = 0._wp   ! vert. coord. of the up. lim. of the 1st ice layer
203
204      DO jk = 1, nlay_s            ! vert. coord of the up. lim. of the layer-th snow layer
205         DO ji = kideb , kiut
206            z_s(ji,jk) = z_s(ji,jk-1) + ht_s_1d(ji) / REAL( nlay_s )
207         END DO
208      END DO
209
210      DO jk = 1, nlay_i            ! vert. coord of the up. lim. of the layer-th ice layer
211         DO ji = kideb , kiut
212            z_i(ji,jk) = z_i(ji,jk-1) + ht_i_1d(ji) / REAL( nlay_i )
213         END DO
214      END DO
215      !
216      !------------------------------------------------------------------------------|
217      ! 2) Radiation                                               |
218      !------------------------------------------------------------------------------|
219      !
220      !-------------------
221      ! Computation of i0
222      !-------------------
223      ! i0 describes the fraction of solar radiation which does not contribute
224      ! to the surface energy budget but rather penetrates inside the ice.
225      ! We assume that no radiation is transmitted through the snow
226      ! If there is no no snow
227      ! zfsw    = (1-i0).qsr_ice   is absorbed at the surface
228      ! zftrice = io.qsr_ice       is below the surface
229      ! ftr_ice = io.qsr_ice.exp(-k(h_i)) transmitted below the ice
230      ! fr1_i0_1d = i0 for a thin ice cover, fr1_i0_2d = i0 for a thick ice cover
231      zhsu = 0.1_wp ! threshold for the computation of i0
232      DO ji = kideb , kiut
233         ! switches
234         isnow(ji) = NINT(  1._wp - MAX( 0._wp , SIGN( 1._wp , - ht_s_1d(ji) ) )  ) 
235         ! hs > 0, isnow = 1
236         zihic(ji) = MAX( 0._wp , 1._wp - ( ht_i_1d(ji) / zhsu ) )     
237
238         i0(ji)    = REAL( 1 - isnow(ji) ) * ( fr1_i0_1d(ji) + zihic(ji) * fr2_i0_1d(ji) )
239      END DO
240
241      !-------------------------------------------------------
242      ! Solar radiation absorbed / transmitted at the surface
243      ! Derivative of the non solar flux
244      !-------------------------------------------------------
245      DO ji = kideb , kiut
246         zfsw   (ji) =  qsr_ice_1d(ji) * ( 1 - i0(ji) )   ! Shortwave radiation absorbed at surface
247         zftrice(ji) =  qsr_ice_1d(ji) *       i0(ji)     ! Solar radiation transmitted below the surface layer
248         dzf    (ji) = dqns_ice_1d(ji)                    ! derivative of incoming nonsolar flux
249      END DO
250
251      !---------------------------------------------------------
252      ! Transmission - absorption of solar radiation in the ice
253      !---------------------------------------------------------
254
255      DO ji = kideb, kiut           ! snow initialization
256         zradtr_s(ji,0) = zftrice(ji)     ! radiation penetrating through snow
257      END DO
258
259      DO jk = 1, nlay_s          ! Radiation through snow
260         DO ji = kideb, kiut
261            !                             ! radiation transmitted below the layer-th snow layer
262            zradtr_s(ji,jk) = zradtr_s(ji,0) * EXP( - zraext_s * ( MAX ( 0._wp , z_s(ji,jk) ) ) )
263            !                             ! radiation absorbed by the layer-th snow layer
264            zradab_s(ji,jk) = zradtr_s(ji,jk-1) - zradtr_s(ji,jk)
265         END DO
266      END DO
267
268      DO ji = kideb, kiut           ! ice initialization
269         zradtr_i(ji,0) = zradtr_s(ji,nlay_s) * REAL( isnow(ji) ) + zftrice(ji) * REAL( 1 - isnow(ji) )
270      END DO
271
272      DO jk = 1, nlay_i          ! Radiation through ice
273         DO ji = kideb, kiut
274            !                             ! radiation transmitted below the layer-th ice layer
275            zradtr_i(ji,jk) = zradtr_i(ji,0) * EXP( - kappa_i * ( MAX ( 0._wp , z_i(ji,jk) ) ) )
276            !                             ! radiation absorbed by the layer-th ice layer
277            zradab_i(ji,jk) = zradtr_i(ji,jk-1) - zradtr_i(ji,jk)
278         END DO
279      END DO
280
281      DO ji = kideb, kiut           ! Radiation transmitted below the ice
282         ftr_ice_1d(ji) = zradtr_i(ji,nlay_i) 
283      END DO
284
285      !
286      !------------------------------------------------------------------------------|
287      !  3) Iterative procedure begins                                               |
288      !------------------------------------------------------------------------------|
289      !
290      DO ji = kideb, kiut        ! Old surface temperature
291         ztsub  (ji) =  t_su_1d(ji)                              ! temperature at the beg of iter pr.
292         ztsubit(ji) =  t_su_1d(ji)                              ! temperature at the previous iter
293         t_su_1d   (ji) =  MIN( t_su_1d(ji), rtt - ztsu_err )    ! necessary
294         zerrit   (ji) =  1000._wp                               ! initial value of error
295      END DO
296
297      DO jk = 1, nlay_s       ! Old snow temperature
298         DO ji = kideb , kiut
299            ztsb(ji,jk) =  t_s_1d(ji,jk)
300         END DO
301      END DO
302
303      DO jk = 1, nlay_i       ! Old ice temperature
304         DO ji = kideb , kiut
305            ztib(ji,jk) =  t_i_1d(ji,jk)
306         END DO
307      END DO
308
309      nconv     =  0           ! number of iterations
310      zerritmax =  1000._wp    ! maximal value of error on all points
311
312      DO WHILE ( zerritmax > maxer_i_thd .AND. nconv < nconv_i_thd )
313         !
314         nconv = nconv + 1
315         !
316         !------------------------------------------------------------------------------|
317         ! 4) Sea ice thermal conductivity                                              |
318         !------------------------------------------------------------------------------|
319         !
320         IF( thcon_i_swi == 0 ) THEN      ! Untersteiner (1964) formula
321            DO ji = kideb , kiut
322               ztcond_i(ji,0)        = rcdic + zbeta*s_i_1d(ji,1) / MIN(-epsi10,t_i_1d(ji,1)-rtt)
323               ztcond_i(ji,0)        = MAX(ztcond_i(ji,0),zkimin)
324            END DO
325            DO jk = 1, nlay_i-1
326               DO ji = kideb , kiut
327                  ztcond_i(ji,jk) = rcdic + zbeta*( s_i_1d(ji,jk) + s_i_1d(ji,jk+1) ) /  &
328                     MIN(-2.0_wp * epsi10, t_i_1d(ji,jk)+t_i_1d(ji,jk+1) - 2.0_wp * rtt)
329                  ztcond_i(ji,jk) = MAX(ztcond_i(ji,jk),zkimin)
330               END DO
331            END DO
332         ENDIF
333
334         IF( thcon_i_swi == 1 ) THEN      ! Pringle et al formula included: 2.11 + 0.09 S/T - 0.011.T
335            DO ji = kideb , kiut
336               ztcond_i(ji,0) = rcdic + 0.090_wp * s_i_1d(ji,1) / MIN( -epsi10, t_i_1d(ji,1)-rtt )   &
337                  &                   - 0.011_wp * ( t_i_1d(ji,1) - rtt ) 
338               ztcond_i(ji,0) = MAX( ztcond_i(ji,0), zkimin )
339            END DO
340            DO jk = 1, nlay_i-1
341               DO ji = kideb , kiut
342                  ztcond_i(ji,jk) = rcdic +                                                                     & 
343                     &                 0.090_wp * ( s_i_1d(ji,jk) + s_i_1d(ji,jk+1) )                          &
344                     &                 / MIN(-2.0_wp * epsi10, t_i_1d(ji,jk)+t_i_1d(ji,jk+1) - 2.0_wp * rtt)   &
345                     &               - 0.0055_wp* ( t_i_1d(ji,jk) + t_i_1d(ji,jk+1) - 2.0*rtt ) 
346                  ztcond_i(ji,jk) = MAX( ztcond_i(ji,jk), zkimin )
347               END DO
348            END DO
349            DO ji = kideb , kiut
350               ztcond_i(ji,nlay_i) = rcdic + 0.090_wp * s_i_1d(ji,nlay_i) / MIN(-epsi10,t_bo_1d(ji)-rtt)   &
351                  &                        - 0.011_wp * ( t_bo_1d(ji) - rtt ) 
352               ztcond_i(ji,nlay_i) = MAX( ztcond_i(ji,nlay_i), zkimin )
353            END DO
354         ENDIF
355         
356         !
357         !------------------------------------------------------------------------------|
358         !  6) G(he) - enhancement of thermal conductivity in mono-category case        |
359         !------------------------------------------------------------------------------|
360         !
361         ! Computation of effective thermal conductivity G(h)
362         ! Used in mono-category case only to simulate an ITD implicitly
363         ! Fichefet and Morales Maqueda, JGR 1997
364
365         zghe(:) = 0._wp
366
367         SELECT CASE ( nn_monocat )
368
369         CASE (0,2,4)
370
371            zghe(kideb:kiut) = 1._wp
372
373         CASE (1,3) ! LIM3
374
375            zepsilon = 0.1
376            zh_thres = EXP( 1._wp ) * zepsilon / 2.
377
378            DO ji = kideb, kiut
379   
380               ! Mean sea ice thermal conductivity
381               zkimean  = SUM( ztcond_i(ji,0:nlay_i) ) / REAL(nlay_i+1,wp)
382
383               ! Effective thickness he (zhe)
384               zfac     = 1._wp / ( rcdsn + zkimean )
385               zratio_s = rcdsn   * zfac
386               zratio_i = zkimean * zfac
387               zhe      = zratio_s * ht_i_1d(ji) + zratio_i * ht_s_1d(ji)
388
389               ! G(he)
390               zswitch  = MAX( 0._wp , SIGN( 1._wp , zhe - zh_thres ) )  ! =0 if zhe < zh_thres, if >
391               zghe(ji) = ( 1.0 - zswitch ) + zswitch * ( 0.5 + 0.5 * LOG( 2.*zhe / zepsilon ) )
392   
393               ! Impose G(he) < 2.
394               zghe(ji) = MIN( zghe(ji), 2.0 )
395
396            END DO
397
398         END SELECT
399
400         !
401         !------------------------------------------------------------------------------|
402         !  7) kappa factors                                                            |
403         !------------------------------------------------------------------------------|
404         !
405         !--- Snow
406         DO ji = kideb, kiut
407            zfac                  =  1. / MAX( epsi10 , zh_s(ji) )
408            zkappa_s(ji,0)        = zghe(ji) * rcdsn * zfac
409            zkappa_s(ji,nlay_s)   = zghe(ji) * rcdsn * zfac
410         END DO
411
412         DO jk = 1, nlay_s-1
413            DO ji = kideb , kiut
414               zkappa_s(ji,jk)    = zghe(ji) * 2.0 * rcdsn / MAX( epsi10, 2.0*zh_s(ji) )
415            END DO
416         END DO
417
418         !--- Ice
419         DO jk = 1, nlay_i-1
420            DO ji = kideb , kiut
421               zkappa_i(ji,jk)    = zghe(ji) * 2.0 * ztcond_i(ji,jk) / MAX( epsi10 , 2.0*zh_i(ji) )
422            END DO
423         END DO
424
425         !--- Snow-ice interface
426         DO ji = kideb , kiut
427            zfac                  = 1./ MAX( epsi10 , zh_i(ji) )
428            zkappa_i(ji,0)        = zghe(ji) * ztcond_i(ji,0) * zfac
429            zkappa_i(ji,nlay_i)   = zghe(ji) * ztcond_i(ji,nlay_i) * zfac
430            zkappa_s(ji,nlay_s)   = zghe(ji) * zghe(ji) * 2.0 * rcdsn * ztcond_i(ji,0) / & 
431           &                        MAX( epsi10, ( zghe(ji) * ztcond_i(ji,0) * zh_s(ji) + zghe(ji) * rcdsn * zh_i(ji) ) )
432            zkappa_i(ji,0)        = zkappa_s(ji,nlay_s)*REAL( isnow(ji), wp ) + zkappa_i(ji,0)*REAL( 1 - isnow(ji), wp )
433         END DO
434
435         !
436         !------------------------------------------------------------------------------|
437         ! 8) Sea ice specific heat, eta factors                                        |
438         !------------------------------------------------------------------------------|
439         !
440         DO jk = 1, nlay_i
441            DO ji = kideb , kiut
442               ztitemp(ji,jk)   = t_i_1d(ji,jk)
443               zspeche_i(ji,jk) = cpic + zgamma*s_i_1d(ji,jk)/ MAX( (t_i_1d(ji,jk)-rtt)*(ztib(ji,jk)-rtt) , epsi10 )
444               zeta_i(ji,jk)    = rdt_ice / MAX( rhoic*zspeche_i(ji,jk)*zh_i(ji), epsi10 )
445            END DO
446         END DO
447
448         DO jk = 1, nlay_s
449            DO ji = kideb , kiut
450               ztstemp(ji,jk) = t_s_1d(ji,jk)
451               zeta_s(ji,jk)  = rdt_ice / MAX(rhosn*cpic*zh_s(ji),epsi10)
452            END DO
453         END DO
454
455         !
456         !------------------------------------------------------------------------------|
457         ! 9) surface flux computation                                                  |
458         !------------------------------------------------------------------------------|
459         !
460         IF( .NOT. lk_cpl ) THEN   !--- forced atmosphere case
461            DO ji = kideb , kiut
462               ! update of the non solar flux according to the update in T_su
463               qns_ice_1d(ji) = qns_ice_1d(ji) + dqns_ice_1d(ji) * ( t_su_1d(ji) - ztsubit(ji) )
464            END DO
465         ENDIF
466
467         ! Update incoming flux
468         DO ji = kideb , kiut
469            ! update incoming flux
470            zf(ji)    =   zfsw(ji)              & ! net absorbed solar radiation
471               + qns_ice_1d(ji)                   ! non solar total flux
472            ! (LWup, LWdw, SH, LH)
473         END DO
474
475         !
476         !------------------------------------------------------------------------------|
477         ! 10) tridiagonal system terms                                                 |
478         !------------------------------------------------------------------------------|
479         !
480         !!layer denotes the number of the layer in the snow or in the ice
481         !!numeq denotes the reference number of the equation in the tridiagonal
482         !!system, terms of tridiagonal system are indexed as following :
483         !!1 is subdiagonal term, 2 is diagonal and 3 is superdiagonal one
484
485         !!ice interior terms (top equation has the same form as the others)
486
487         DO numeq=1,nlay_i+3
488            DO ji = kideb , kiut
489               ztrid(ji,numeq,1) = 0.
490               ztrid(ji,numeq,2) = 0.
491               ztrid(ji,numeq,3) = 0.
492               zindterm(ji,numeq)= 0.
493               zindtbis(ji,numeq)= 0.
494               zdiagbis(ji,numeq)= 0.
495            ENDDO
496         ENDDO
497
498         DO numeq = nlay_s + 2, nlay_s + nlay_i 
499            DO ji = kideb , kiut
500               jk              = numeq - nlay_s - 1
501               ztrid(ji,numeq,1)  =  - zeta_i(ji,jk)*zkappa_i(ji,jk-1)
502               ztrid(ji,numeq,2)  =  1.0 + zeta_i(ji,jk)*(zkappa_i(ji,jk-1) + &
503                  zkappa_i(ji,jk))
504               ztrid(ji,numeq,3)  =  - zeta_i(ji,jk)*zkappa_i(ji,jk)
505               zindterm(ji,numeq) =  ztib(ji,jk) + zeta_i(ji,jk)* &
506                  zradab_i(ji,jk)
507            END DO
508         ENDDO
509
510         numeq =  nlay_s + nlay_i + 1
511         DO ji = kideb , kiut
512            !!ice bottom term
513            ztrid(ji,numeq,1)  =  - zeta_i(ji,nlay_i)*zkappa_i(ji,nlay_i-1)   
514            ztrid(ji,numeq,2)  =  1.0 + zeta_i(ji,nlay_i)*( zkappa_i(ji,nlay_i)*zg1 &
515               +  zkappa_i(ji,nlay_i-1) )
516            ztrid(ji,numeq,3)  =  0.0
517            zindterm(ji,numeq) =  ztib(ji,nlay_i) + zeta_i(ji,nlay_i)* &
518               ( zradab_i(ji,nlay_i) + zkappa_i(ji,nlay_i)*zg1 &
519               *  t_bo_1d(ji) ) 
520         ENDDO
521
522
523         DO ji = kideb , kiut
524            IF ( ht_s_1d(ji).gt.0.0 ) THEN
525               !
526               !------------------------------------------------------------------------------|
527               !  snow-covered cells                                                          |
528               !------------------------------------------------------------------------------|
529               !
530               !!snow interior terms (bottom equation has the same form as the others)
531               DO numeq = 3, nlay_s + 1
532                  jk =  numeq - 1
533                  ztrid(ji,numeq,1)   =  - zeta_s(ji,jk)*zkappa_s(ji,jk-1)
534                  ztrid(ji,numeq,2)   =  1.0 + zeta_s(ji,jk)*( zkappa_s(ji,jk-1) + &
535                     zkappa_s(ji,jk) )
536                  ztrid(ji,numeq,3)   =  - zeta_s(ji,jk)*zkappa_s(ji,jk)
537                  zindterm(ji,numeq)  =  ztsb(ji,jk) + zeta_s(ji,jk)* &
538                     zradab_s(ji,jk)
539               END DO
540
541               !!case of only one layer in the ice (ice equation is altered)
542               IF ( nlay_i.eq.1 ) THEN
543                  ztrid(ji,nlay_s+2,3)    =  0.0
544                  zindterm(ji,nlay_s+2)   =  zindterm(ji,nlay_s+2) + zkappa_i(ji,1)* &
545                     t_bo_1d(ji) 
546               ENDIF
547
548               IF ( t_su_1d(ji) .LT. rtt ) THEN
549
550                  !------------------------------------------------------------------------------|
551                  !  case 1 : no surface melting - snow present                                  |
552                  !------------------------------------------------------------------------------|
553                  zdifcase(ji)    =  1.0
554                  numeqmin(ji)    =  1
555                  numeqmax(ji)    =  nlay_i + nlay_s + 1
556
557                  !!surface equation
558                  ztrid(ji,1,1) = 0.0
559                  ztrid(ji,1,2) = dzf(ji) - zg1s*zkappa_s(ji,0)
560                  ztrid(ji,1,3) = zg1s*zkappa_s(ji,0)
561                  zindterm(ji,1) = dzf(ji)*t_su_1d(ji)   - zf(ji)
562
563                  !!first layer of snow equation
564                  ztrid(ji,2,1)  =  - zkappa_s(ji,0)*zg1s*zeta_s(ji,1)
565                  ztrid(ji,2,2)  =  1.0 + zeta_s(ji,1)*(zkappa_s(ji,1) + zkappa_s(ji,0)*zg1s)
566                  ztrid(ji,2,3)  =  - zeta_s(ji,1)* zkappa_s(ji,1)
567                  zindterm(ji,2) =  ztsb(ji,1) + zeta_s(ji,1)*zradab_s(ji,1)
568
569               ELSE 
570                  !
571                  !------------------------------------------------------------------------------|
572                  !  case 2 : surface is melting - snow present                                  |
573                  !------------------------------------------------------------------------------|
574                  !
575                  zdifcase(ji)    =  2.0
576                  numeqmin(ji)    =  2
577                  numeqmax(ji)    =  nlay_i + nlay_s + 1
578
579                  !!first layer of snow equation
580                  ztrid(ji,2,1)  =  0.0
581                  ztrid(ji,2,2)  =  1.0 + zeta_s(ji,1) * ( zkappa_s(ji,1) + &
582                     zkappa_s(ji,0) * zg1s )
583                  ztrid(ji,2,3)  =  - zeta_s(ji,1)*zkappa_s(ji,1) 
584                  zindterm(ji,2) = ztsb(ji,1) + zeta_s(ji,1) *            &
585                     ( zradab_s(ji,1) +                         &
586                     zkappa_s(ji,0) * zg1s * t_su_1d(ji) ) 
587               ENDIF
588            ELSE
589               !
590               !------------------------------------------------------------------------------|
591               !  cells without snow                                                          |
592               !------------------------------------------------------------------------------|
593               !
594               IF (t_su_1d(ji) .LT. rtt) THEN
595                  !
596                  !------------------------------------------------------------------------------|
597                  !  case 3 : no surface melting - no snow                                       |
598                  !------------------------------------------------------------------------------|
599                  !
600                  zdifcase(ji)      =  3.0
601                  numeqmin(ji)      =  nlay_s + 1
602                  numeqmax(ji)      =  nlay_i + nlay_s + 1
603
604                  !!surface equation   
605                  ztrid(ji,numeqmin(ji),1)   =  0.0
606                  ztrid(ji,numeqmin(ji),2)   =  dzf(ji) - zkappa_i(ji,0)*zg1   
607                  ztrid(ji,numeqmin(ji),3)   =  zkappa_i(ji,0)*zg1
608                  zindterm(ji,numeqmin(ji))  =  dzf(ji)*t_su_1d(ji) - zf(ji)
609
610                  !!first layer of ice equation
611                  ztrid(ji,numeqmin(ji)+1,1) =  - zkappa_i(ji,0) * zg1 * zeta_i(ji,1)
612                  ztrid(ji,numeqmin(ji)+1,2) =  1.0 + zeta_i(ji,1) * ( zkappa_i(ji,1) & 
613                     + zkappa_i(ji,0) * zg1 )
614                  ztrid(ji,numeqmin(ji)+1,3) =  - zeta_i(ji,1)*zkappa_i(ji,1) 
615                  zindterm(ji,numeqmin(ji)+1)=  ztib(ji,1) + zeta_i(ji,1)*zradab_i(ji,1) 
616
617                  !!case of only one layer in the ice (surface & ice equations are altered)
618
619                  IF (nlay_i.eq.1) THEN
620                     ztrid(ji,numeqmin(ji),1)    =  0.0
621                     ztrid(ji,numeqmin(ji),2)    =  dzf(ji) - zkappa_i(ji,0)*2.0
622                     ztrid(ji,numeqmin(ji),3)    =  zkappa_i(ji,0)*2.0
623                     ztrid(ji,numeqmin(ji)+1,1)  =  -zkappa_i(ji,0)*2.0*zeta_i(ji,1)
624                     ztrid(ji,numeqmin(ji)+1,2)  =  1.0 + zeta_i(ji,1)*(zkappa_i(ji,0)*2.0 + &
625                        zkappa_i(ji,1))
626                     ztrid(ji,numeqmin(ji)+1,3)  =  0.0
627
628                     zindterm(ji,numeqmin(ji)+1) =  ztib(ji,1) + zeta_i(ji,1)* &
629                        ( zradab_i(ji,1) + zkappa_i(ji,1)*t_bo_1d(ji) )
630                  ENDIF
631
632               ELSE
633
634                  !
635                  !------------------------------------------------------------------------------|
636                  ! case 4 : surface is melting - no snow                                        |
637                  !------------------------------------------------------------------------------|
638                  !
639                  zdifcase(ji)    =  4.0
640                  numeqmin(ji)    =  nlay_s + 2
641                  numeqmax(ji)    =  nlay_i + nlay_s + 1
642
643                  !!first layer of ice equation
644                  ztrid(ji,numeqmin(ji),1)      =  0.0
645                  ztrid(ji,numeqmin(ji),2)      =  1.0 + zeta_i(ji,1)*(zkappa_i(ji,1) + zkappa_i(ji,0)* &
646                     zg1) 
647                  ztrid(ji,numeqmin(ji),3)      =  - zeta_i(ji,1) * zkappa_i(ji,1)
648                  zindterm(ji,numeqmin(ji))     =  ztib(ji,1) + zeta_i(ji,1)*( zradab_i(ji,1) + &
649                     zkappa_i(ji,0) * zg1 * t_su_1d(ji) ) 
650
651                  !!case of only one layer in the ice (surface & ice equations are altered)
652                  IF (nlay_i.eq.1) THEN
653                     ztrid(ji,numeqmin(ji),1)  =  0.0
654                     ztrid(ji,numeqmin(ji),2)  =  1.0 + zeta_i(ji,1)*(zkappa_i(ji,0)*2.0 + &
655                        zkappa_i(ji,1))
656                     ztrid(ji,numeqmin(ji),3)  =  0.0
657                     zindterm(ji,numeqmin(ji)) =  ztib(ji,1) + zeta_i(ji,1)* &
658                        (zradab_i(ji,1) + zkappa_i(ji,1)*t_bo_1d(ji)) &
659                        + t_su_1d(ji)*zeta_i(ji,1)*zkappa_i(ji,0)*2.0
660                  ENDIF
661
662               ENDIF
663            ENDIF
664
665         END DO
666
667         !
668         !------------------------------------------------------------------------------|
669         ! 11) tridiagonal system solving                                               |
670         !------------------------------------------------------------------------------|
671         !
672
673         ! Solve the tridiagonal system with Gauss elimination method.
674         ! Thomas algorithm, from Computational fluid Dynamics, J.D. ANDERSON,
675         ! McGraw-Hill 1984. 
676
677         maxnumeqmax = 0
678         minnumeqmin = nlay_i+5
679
680         DO ji = kideb , kiut
681            zindtbis(ji,numeqmin(ji)) =  zindterm(ji,numeqmin(ji))
682            zdiagbis(ji,numeqmin(ji)) =  ztrid(ji,numeqmin(ji),2)
683            minnumeqmin               =  MIN(numeqmin(ji),minnumeqmin)
684            maxnumeqmax               =  MAX(numeqmax(ji),maxnumeqmax)
685         END DO
686
687         DO jk = minnumeqmin+1, maxnumeqmax
688            DO ji = kideb , kiut
689               numeq               =  min(max(numeqmin(ji)+1,jk),numeqmax(ji))
690               zdiagbis(ji,numeq)  =  ztrid(ji,numeq,2) - ztrid(ji,numeq,1)* &
691                  ztrid(ji,numeq-1,3)/zdiagbis(ji,numeq-1)
692               zindtbis(ji,numeq)  =  zindterm(ji,numeq) - ztrid(ji,numeq,1)* &
693                  zindtbis(ji,numeq-1)/zdiagbis(ji,numeq-1)
694            END DO
695         END DO
696
697         DO ji = kideb , kiut
698            ! ice temperatures
699            t_i_1d(ji,nlay_i)    =  zindtbis(ji,numeqmax(ji))/zdiagbis(ji,numeqmax(ji))
700         END DO
701
702         DO numeq = nlay_i + nlay_s + 1, nlay_s + 2, -1
703            DO ji = kideb , kiut
704               jk    =  numeq - nlay_s - 1
705               t_i_1d(ji,jk)  =  (zindtbis(ji,numeq) - ztrid(ji,numeq,3)* &
706                  t_i_1d(ji,jk+1))/zdiagbis(ji,numeq)
707            END DO
708         END DO
709
710         DO ji = kideb , kiut
711            ! snow temperatures     
712            IF (ht_s_1d(ji).GT.0._wp) &
713               t_s_1d(ji,nlay_s)     =  (zindtbis(ji,nlay_s+1) - ztrid(ji,nlay_s+1,3) &
714               *  t_i_1d(ji,1))/zdiagbis(ji,nlay_s+1) &
715               *        MAX(0.0,SIGN(1.0,ht_s_1d(ji))) 
716
717            ! surface temperature
718            isnow(ji)     = NINT(  1.0 - MAX( 0.0 , SIGN( 1.0 , -ht_s_1d(ji) )  )  )
719            ztsubit(ji) = t_su_1d(ji)
720            IF( t_su_1d(ji) < rtt ) &
721               t_su_1d(ji) = ( zindtbis(ji,numeqmin(ji)) - ztrid(ji,numeqmin(ji),3)* ( REAL( isnow(ji) )*t_s_1d(ji,1)   &
722               &          + REAL( 1 - isnow(ji) )*t_i_1d(ji,1) ) ) / zdiagbis(ji,numeqmin(ji)) 
723         END DO
724         !
725         !--------------------------------------------------------------------------
726         !  12) Has the scheme converged ?, end of the iterative procedure         |
727         !--------------------------------------------------------------------------
728         !
729         ! check that nowhere it has started to melt
730         ! zerrit(ji) is a measure of error, it has to be under maxer_i_thd
731         DO ji = kideb , kiut
732            t_su_1d(ji) =  MAX(  MIN( t_su_1d(ji) , rtt ) , 190._wp  )
733            zerrit(ji) =  ABS( t_su_1d(ji) - ztsubit(ji) )     
734         END DO
735
736         DO jk  =  1, nlay_s
737            DO ji = kideb , kiut
738               t_s_1d(ji,jk) = MAX(  MIN( t_s_1d(ji,jk), rtt ), 190._wp  )
739               zerrit(ji)      = MAX(zerrit(ji),ABS(t_s_1d(ji,jk) - ztstemp(ji,jk)))
740            END DO
741         END DO
742
743         DO jk  =  1, nlay_i
744            DO ji = kideb , kiut
745               ztmelt_i        = -tmut * s_i_1d(ji,jk) + rtt 
746               t_i_1d(ji,jk) =  MAX(MIN(t_i_1d(ji,jk),ztmelt_i), 190._wp)
747               zerrit(ji)      =  MAX(zerrit(ji),ABS(t_i_1d(ji,jk) - ztitemp(ji,jk)))
748            END DO
749         END DO
750
751         ! Compute spatial maximum over all errors
752         ! note that this could be optimized substantially by iterating only the non-converging points
753         zerritmax = 0._wp
754         DO ji = kideb, kiut
755            zerritmax = MAX( zerritmax, zerrit(ji) )   
756         END DO
757         IF( lk_mpp ) CALL mpp_max( zerritmax, kcom=ncomm_ice )
758
759      END DO  ! End of the do while iterative procedure
760
761      IF( ln_nicep .AND. lwp ) THEN
762         WRITE(numout,*) ' zerritmax : ', zerritmax
763         WRITE(numout,*) ' nconv     : ', nconv
764      ENDIF
765
766      !
767      !-------------------------------------------------------------------------!
768      !   13) Fluxes at the interfaces                                          !
769      !-------------------------------------------------------------------------!
770      DO ji = kideb, kiut
771         ! forced mode only : update of latent heat fluxes (sublimation) (always >=0, upward flux)
772         IF( .NOT. lk_cpl) qla_ice_1d (ji) = MAX( 0._wp, qla_ice_1d (ji) + dqla_ice_1d(ji) * ( t_su_1d(ji) - ztsub(ji) ) )
773         !                                ! surface ice conduction flux
774         isnow(ji)       = NINT(  1._wp - MAX( 0._wp, SIGN( 1._wp, -ht_s_1d(ji) ) )  )
775         fc_su(ji)       =  -     REAL( isnow(ji) ) * zkappa_s(ji,0) * zg1s * (t_s_1d(ji,1) - t_su_1d(ji))   &
776            &               - REAL( 1 - isnow(ji) ) * zkappa_i(ji,0) * zg1  * (t_i_1d(ji,1) - t_su_1d(ji))
777         !                                ! bottom ice conduction flux
778         fc_bo_i(ji)     =  - zkappa_i(ji,nlay_i) * ( zg1*(t_bo_1d(ji) - t_i_1d(ji,nlay_i)) )
779      END DO
780
781      !-----------------------------------------
782      ! Heat flux used to warm/cool ice in W.m-2
783      !-----------------------------------------
784      DO ji = kideb, kiut
785         IF( t_su_1d(ji) < rtt ) THEN  ! case T_su < 0degC
786            hfx_dif_1d(ji) = hfx_dif_1d(ji)  +   &
787               &            ( qns_ice_1d(ji) + qsr_ice_1d(ji) - zradtr_i(ji,nlay_i) - fc_bo_i(ji) ) * a_i_1d(ji)
788         ELSE                         ! case T_su = 0degC
789            hfx_dif_1d(ji) = hfx_dif_1d(ji) +    &
790               &             ( fc_su(ji) + i0(ji) * qsr_ice_1d(ji) - zradtr_i(ji,nlay_i) - fc_bo_i(ji) ) * a_i_1d(ji)
791         ENDIF
792      END DO
793
794      ! --- computes sea ice energy of melting compulsory for limthd_dh --- !
795      CALL lim_thd_enmelt( kideb, kiut )
796
797      ! --- diag conservation imbalance on heat diffusion - PART 2 --- !
798      DO ji = kideb, kiut
799         zdq(ji)        = - zq_ini(ji) + ( SUM( q_i_1d(ji,1:nlay_i) ) * ht_i_1d(ji) / REAL( nlay_i ) +  &
800            &                              SUM( q_s_1d(ji,1:nlay_s) ) * ht_s_1d(ji) / REAL( nlay_s ) )
801         zhfx_err(ji)   = ( fc_su(ji) + i0(ji) * qsr_ice_1d(ji) - zradtr_i(ji,nlay_i) - fc_bo_i(ji) + zdq(ji) * r1_rdtice ) 
802         hfx_err_1d(ji) = hfx_err_1d(ji) + zhfx_err(ji) * a_i_1d(ji)
803      END DO 
804
805      ! diagnose external surface (forced case) or bottom (forced case) from heat conservation
806      IF( .NOT. lk_cpl ) THEN   ! --- forced case: qns_ice and fc_su are diagnosed
807         !
808         DO ji = kideb, kiut
809            qns_ice_1d(ji) = qns_ice_1d(ji) - zhfx_err(ji)
810            fc_su     (ji) = fc_su(ji)      - zhfx_err(ji)
811         END DO
812         !
813      ELSE                      ! --- coupled case: ocean turbulent heat flux is diagnosed
814         !
815         DO ji = kideb, kiut
816            fhtur_1d  (ji) = fhtur_1d(ji)   - zhfx_err(ji)
817         END DO
818         !
819      ENDIF
820
821      ! --- compute diagnostic net heat flux at the surface of the snow-ice system (W.m2)
822      DO ji = kideb, kiut
823         ii = MOD( npb(ji) - 1, jpi ) + 1 ; ij = ( npb(ji) - 1 ) / jpi + 1
824         hfx_in (ii,ij) = hfx_in (ii,ij) + a_i_1d(ji) * ( qsr_ice_1d(ji) + qns_ice_1d(ji) )
825      END DO
826   
827      !
828      CALL wrk_dealloc( jpij, numeqmin, numeqmax, isnow )
829      CALL wrk_dealloc( jpij, ztsub, ztsubit, zh_i, zh_s, zfsw )
830      CALL wrk_dealloc( jpij, zf, dzf, zerrit, zdifcase, zftrice, zihic, zghe )
831      CALL wrk_dealloc( jpij, nlay_i+1, ztcond_i, zradtr_i, zradab_i, zkappa_i,   &
832         &              ztib, zeta_i, ztitemp, z_i, zspeche_i, kjstart = 0 )
833      CALL wrk_dealloc( jpij, nlay_s+1,           zradtr_s, zradab_s, zkappa_s, ztsb, zeta_s, ztstemp, z_s, kjstart = 0 )
834      CALL wrk_dealloc( jpij, nlay_i+3, zindterm, zindtbis, zdiagbis )
835      CALL wrk_dealloc( jpij, nlay_i+3, 3, ztrid )
836      CALL wrk_dealloc( jpij, zdq, zq_ini, zhfx_err )
837
838   END SUBROUTINE lim_thd_dif
839
840   SUBROUTINE lim_thd_enmelt( kideb, kiut )
841      !!-----------------------------------------------------------------------
842      !!                   ***  ROUTINE lim_thd_enmelt ***
843      !!                 
844      !! ** Purpose :   Computes sea ice energy of melting q_i (J.m-3) from temperature
845      !!
846      !! ** Method  :   Formula (Bitz and Lipscomb, 1999)
847      !!-------------------------------------------------------------------
848      INTEGER, INTENT(in) ::   kideb, kiut   ! bounds for the spatial loop
849      !
850      INTEGER  ::   ji, jk   ! dummy loop indices
851      REAL(wp) ::   ztmelts  ! local scalar
852      !!-------------------------------------------------------------------
853      !
854      DO jk = 1, nlay_i             ! Sea ice energy of melting
855         DO ji = kideb, kiut
856            ztmelts      = - tmut  * s_i_1d(ji,jk) + rtt 
857            rswitch      = MAX( 0._wp , SIGN( 1._wp , -(t_i_1d(ji,jk) - rtt) - epsi10 ) )
858            q_i_1d(ji,jk) = rhoic * ( cpic * ( ztmelts - t_i_1d(ji,jk) )                                             &
859               &                   + lfus * ( 1.0 - rswitch * ( ztmelts-rtt ) / MIN( t_i_1d(ji,jk)-rtt, -epsi10 ) )   &
860               &                   - rcp  *                 ( ztmelts-rtt )  ) 
861         END DO
862      END DO
863      DO jk = 1, nlay_s             ! Snow energy of melting
864         DO ji = kideb, kiut
865            q_s_1d(ji,jk) = rhosn * ( cpic * ( rtt - t_s_1d(ji,jk) ) + lfus )
866         END DO
867      END DO
868      !
869   END SUBROUTINE lim_thd_enmelt
870
871#else
872   !!----------------------------------------------------------------------
873   !!                   Dummy Module                 No LIM-3 sea-ice model
874   !!----------------------------------------------------------------------
875CONTAINS
876   SUBROUTINE lim_thd_dif          ! Empty routine
877   END SUBROUTINE lim_thd_dif
878#endif
879   !!======================================================================
880END MODULE limthd_dif
Note: See TracBrowser for help on using the repository browser.