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 tags/nemo_v3_2_2/NEMO/LIM_SRC_3 – NEMO

source: tags/nemo_v3_2_2/NEMO/LIM_SRC_3/limthd_dif.F90 @ 2720

Last change on this file since 2720 was 2477, checked in by cetlod, 13 years ago

v3.2:remove hardcoded value of num_sal in limrst.F90, see ticket #633

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