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

source: trunk/NEMO/LIM_SRC_3/limthd_dif.F90 @ 913

Last change on this file since 913 was 869, checked in by rblod, 16 years ago

Parallelisation of LIM3. This commit seems to ensure the reproducibility mono/mpp. See ticket #77.

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