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

source: trunk/NEMOGCM/NEMO/LIM_SRC_3/limthd_dif.F90 @ 2528

Last change on this file since 2528 was 2528, checked in by rblod, 13 years ago

Update NEMOGCM from branch nemo_v3_3_beta

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