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

source: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/LIM_SRC_3/limthd_dif.F90 @ 2636

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

dynamic mem: #785 ; LIM-3 case: changes required for compilation (continuation)

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