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 @ 2591

Last change on this file since 2591 was 2591, checked in by gm, 13 years ago

v3.3: #799 , correct a LIM3 small bug (limthd_dif)

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