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

Last change on this file since 867 was 864, checked in by rblod, 16 years ago

Come back to previous version since 842 rev of this routine altere results

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