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

source: branches/2012/dev_r3385_NOCS04_HAMF/NEMOGCM/NEMO/LIM_SRC_3/limthd_dif.F90 @ 3517

Last change on this file since 3517 was 3517, checked in by gm, 11 years ago

gm: Branch: dev_r3385_NOCS04_HAMF; #665. update sbccpl ; change LIM3 from equivalent salt flux to salt flux and mass flux

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