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

source: branches/2011/dev_r2787_LOCEAN3_TRA_TRP/NEMOGCM/NEMO/LIM_SRC_3/limthd_dif.F90 @ 2833

Last change on this file since 2833 was 2777, checked in by smasson, 13 years ago

LIM3 compiling and (partly?) running in v3_3_1, see ticket#817

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