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

source: trunk/NEMOGCM/NEMO/LIM_SRC_3/limthd_dif.F90 @ 3558

Last change on this file since 3558 was 3558, checked in by rblod, 11 years ago

Fix issues when using key_nosignedzeo, see ticket #996

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