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

source: branches/2013/dev_r4028_CNRS_LIM3/NEMOGCM/NEMO/LIM_SRC_3/limthd_dif.F90 @ 4635

Last change on this file since 4635 was 4634, checked in by clem, 10 years ago

major changes in heat budget

  • Property svn:keywords set to Id
File size: 36.5 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   !!             -   ! 2012-05 (C. Rousset) add penetration solar flux
13   !!----------------------------------------------------------------------
14#if defined key_lim3
15   !!----------------------------------------------------------------------
16   !!   'key_lim3'                                      LIM3 sea-ice model
17   !!----------------------------------------------------------------------
18   USE par_oce        ! ocean parameters
19   USE phycst         ! physical constants (ocean directory)
20   USE ice            ! LIM-3 variables
21   USE par_ice        ! LIM-3 parameters
22   USE thd_ice        ! LIM-3: thermodynamics
23   USE in_out_manager ! I/O manager
24   USE lib_mpp        ! MPP library
25   USE wrk_nemo       ! work arrays
26   USE lib_fortran    ! Fortran utilities (allows no signed zero when 'key_nosignedzero' defined) 
27   USE cpl_oasis3, ONLY : lk_cpl
28
29   IMPLICIT NONE
30   PRIVATE
31
32   PUBLIC   lim_thd_dif   ! called by lim_thd
33
34   REAL(wp) ::   epsi10      =  1.e-10_wp    !
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) ::   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) ::   ztsu_err  =  1.e-5_wp     ! range around which t_su is considered as 0°C
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      REAL(wp) ::   ztemp   ! local scalar
150      !!------------------------------------------------------------------     
151      !
152      !------------------------------------------------------------------------------!
153      ! 1) Initialization                                                            !
154      !------------------------------------------------------------------------------!
155      ! clem clean: replace just ztfs by rtt
156      DO ji = kideb , kiut
157         ! is there snow or not
158         isnow(ji)= NINT(  1._wp - MAX( 0._wp , SIGN(1._wp, - ht_s_b(ji) ) )  )
159         ! surface temperature of fusion
160         ztfs(ji) = REAL( isnow(ji) ) * rtt + REAL( 1 - isnow(ji) ) * rtt
161         ! layer thickness
162         zh_i(ji) = ht_i_b(ji) / REAL( nlay_i )
163         zh_s(ji) = ht_s_b(ji) / REAL( 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) / REAL( 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) / REAL( 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      ! ftr_ice = io.qsr_ice.exp(-k(h_i)) transmitted below the ice
199
200      DO ji = kideb , kiut
201         ! switches
202         isnow(ji) = NINT(  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)    = REAL( 1 - 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) * REAL( isnow(ji) ) + zftrice(ji) * REAL( 1 - 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         !!!ftr_ice_1d(ji) = ftr_ice_1d(ji) + iatte_1d(ji) * zradtr_i(ji,nlay_i) * a_i_b(ji) / at_i_b(ji) ! clem modif
258         ftr_ice_1d(ji) = zradtr_i(ji,nlay_i) 
259      END DO
260
261      !
262      !------------------------------------------------------------------------------|
263      !  3) Iterative procedure begins                                               |
264      !------------------------------------------------------------------------------|
265      !
266      DO ji = kideb, kiut        ! Old surface temperature
267         ztsuold  (ji) =  t_su_b(ji)                              ! temperature at the beg of iter pr.
268         ztsuoldit(ji) =  t_su_b(ji)                              ! temperature at the previous iter
269         t_su_b   (ji) =  MIN( t_su_b(ji), ztfs(ji) - ztsu_err )  ! necessary
270         !!ztsuold  (ji) =  t_su_b(ji)                              ! temperature at the beg of iter pr.
271         !!ztsuoldit(ji) =  t_su_b(ji)                              ! temperature at the previous iter
272         zerrit   (ji) =  1000._wp                                ! initial value of error
273      END DO
274
275      DO layer = 1, nlay_s       ! Old snow temperature
276         DO ji = kideb , kiut
277            ztsold(ji,layer) =  t_s_b(ji,layer)
278         END DO
279      END DO
280
281      DO layer = 1, nlay_i       ! Old ice temperature
282         DO ji = kideb , kiut
283            ztiold(ji,layer) =  t_i_b(ji,layer)
284         END DO
285      END DO
286
287      nconv     =  0           ! number of iterations
288      zerritmax =  1000._wp    ! maximal value of error on all points
289
290      DO WHILE ( zerritmax > maxer_i_thd .AND. nconv < nconv_i_thd )
291         !
292         nconv = nconv + 1
293         !
294         !------------------------------------------------------------------------------|
295         ! 4) Sea ice thermal conductivity                                              |
296         !------------------------------------------------------------------------------|
297         !
298         IF( thcon_i_swi == 0 ) THEN      ! Untersteiner (1964) formula
299            DO ji = kideb , kiut
300               ztcond_i(ji,0)        = rcdic + zbeta*s_i_b(ji,1) / MIN(-epsi10,t_i_b(ji,1)-rtt)
301               ztcond_i(ji,0)        = MAX(ztcond_i(ji,0),zkimin)
302            END DO
303            DO layer = 1, nlay_i-1
304               DO ji = kideb , kiut
305                  ztcond_i(ji,layer) = rcdic + zbeta*( s_i_b(ji,layer) + s_i_b(ji,layer+1) ) /  &
306                     MIN(-2.0_wp * epsi10, t_i_b(ji,layer)+t_i_b(ji,layer+1) - 2.0_wp * rtt)
307                  ztcond_i(ji,layer) = MAX(ztcond_i(ji,layer),zkimin)
308               END DO
309            END DO
310         ENDIF
311
312         IF( thcon_i_swi == 1 ) THEN      ! Pringle et al formula included: 2.11 + 0.09 S/T - 0.011.T
313            DO ji = kideb , kiut
314               ztcond_i(ji,0) = rcdic + 0.090_wp * s_i_b(ji,1) / MIN( -epsi10, t_i_b(ji,1)-rtt )   &
315                  &                   - 0.011_wp * ( 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                  ztemp = t_i_b(ji,layer) + t_i_b(ji,layer+1) - 2._wp * rtt
321                  ztcond_i(ji,layer) = rcdic + 0.0900_wp * ( s_i_b(ji,layer) + s_i_b(ji,layer+1) )   &
322                     &                                   / MIN( -2.0_wp * epsi10, ztemp )   &
323                     &                       - 0.0055_wp * ztemp
324                  ztcond_i(ji,layer) = MAX( ztcond_i(ji,layer), zkimin )
325               END DO
326            END DO
327            DO ji = kideb , kiut
328               ztemp = t_bo_b(ji) - rtt
329               ztcond_i(ji,nlay_i) = rcdic + 0.090_wp * s_i_b(ji,nlay_i) / MIN( -epsi10, ztemp )   &
330                  &                        - 0.011_wp * ztemp 
331               ztcond_i(ji,nlay_i) = MAX( ztcond_i(ji,nlay_i), zkimin )
332            END DO
333         ENDIF
334         !
335         !------------------------------------------------------------------------------|
336         !  5) kappa factors                                                            |
337         !------------------------------------------------------------------------------|
338         !
339         DO ji = kideb, kiut
340
341            !-- Snow kappa factors
342            zkappa_s(ji,0)         = rcdsn / MAX(epsi10,zh_s(ji))
343            zkappa_s(ji,nlay_s)    = rcdsn / MAX(epsi10,zh_s(ji))
344         END DO
345
346         DO layer = 1, nlay_s-1
347            DO ji = kideb , kiut
348               zkappa_s(ji,layer)  = 2.0 * rcdsn / &
349                  MAX(epsi10,2.0*zh_s(ji))
350            END DO
351         END DO
352
353         DO layer = 1, nlay_i-1
354            DO ji = kideb , kiut
355               !-- Ice kappa factors
356               zkappa_i(ji,layer)  = 2.0*ztcond_i(ji,layer)/ &
357                  MAX(epsi10,2.0*zh_i(ji)) 
358            END DO
359         END DO
360
361         DO ji = kideb , kiut
362            zkappa_i(ji,0)        = ztcond_i(ji,0)/MAX(epsi10,zh_i(ji))
363            zkappa_i(ji,nlay_i)   = ztcond_i(ji,nlay_i) / MAX(epsi10,zh_i(ji))
364            !-- Interface
365            zkappa_s(ji,nlay_s)   = 2.0*rcdsn*ztcond_i(ji,0)/MAX(epsi10, &
366               (ztcond_i(ji,0)*zh_s(ji) + rcdsn*zh_i(ji)))
367            zkappa_i(ji,0)        = zkappa_s(ji,nlay_s)*REAL( isnow(ji) ) &
368               + zkappa_i(ji,0)*REAL( 1 - isnow(ji) )
369         END DO
370         !
371         !------------------------------------------------------------------------------|
372         ! 6) Sea ice specific heat, eta factors                                        |
373         !------------------------------------------------------------------------------|
374         !
375         DO layer = 1, nlay_i
376            DO ji = kideb , kiut
377               ztitemp(ji,layer)   = t_i_b(ji,layer)
378               zspeche_i(ji,layer) = cpic + zgamma*s_i_b(ji,layer)/ &
379                  MAX((t_i_b(ji,layer)-rtt)*(ztiold(ji,layer)-rtt),epsi10)
380               zeta_i(ji,layer)    = rdt_ice / MAX(rhoic*zspeche_i(ji,layer)*zh_i(ji), &
381                  epsi10)
382            END DO
383         END DO
384
385         DO layer = 1, nlay_s
386            DO ji = kideb , kiut
387               ztstemp(ji,layer) = t_s_b(ji,layer)
388               zeta_s(ji,layer)  = rdt_ice / MAX(rhosn*cpic*zh_s(ji),epsi10)
389            END DO
390         END DO
391         !
392         !------------------------------------------------------------------------------|
393         ! 7) surface flux computation                                                  |
394         !------------------------------------------------------------------------------|
395         !
396         DO ji = kideb , kiut
397
398            ! update of the non solar flux according to the update in T_su
399            qns_ice_1d(ji) = qns_ice_1d(ji) + dqns_ice_1d(ji) * ( t_su_b(ji) - ztsuoldit(ji) )
400
401            ! update incoming flux
402            zf(ji)    =   zfsw(ji)              & ! net absorbed solar radiation
403               + qns_ice_1d(ji)                  ! non solar total flux
404            ! (LWup, LWdw, SH, LH)
405
406            ! heat flux used to change surface temperature
407            !hfx_tot_1d(ji) = hfx_tot_1d(ji) + dqns_ice_1d(ji) * ( t_su_b(ji) - ztsuoldit(ji) ) * a_i_b(ji)
408         END DO
409
410         !
411         !------------------------------------------------------------------------------|
412         ! 8) tridiagonal system terms                                                  |
413         !------------------------------------------------------------------------------|
414         !
415         !!layer denotes the number of the layer in the snow or in the ice
416         !!numeq denotes the reference number of the equation in the tridiagonal
417         !!system, terms of tridiagonal system are indexed as following :
418         !!1 is subdiagonal term, 2 is diagonal and 3 is superdiagonal one
419
420         !!ice interior terms (top equation has the same form as the others)
421
422         DO numeq=1,jkmax+2
423            DO ji = kideb , kiut
424               ztrid(ji,numeq,1) = 0.
425               ztrid(ji,numeq,2) = 0.
426               ztrid(ji,numeq,3) = 0.
427               zindterm(ji,numeq)= 0.
428               zindtbis(ji,numeq)= 0.
429               zdiagbis(ji,numeq)= 0.
430            ENDDO
431         ENDDO
432
433         DO numeq = nlay_s + 2, nlay_s + nlay_i 
434            DO ji = kideb , kiut
435               layer              = numeq - nlay_s - 1
436               ztrid(ji,numeq,1)  =  - zeta_i(ji,layer)*zkappa_i(ji,layer-1)
437               ztrid(ji,numeq,2)  =  1.0 + zeta_i(ji,layer)*(zkappa_i(ji,layer-1) + &
438                  zkappa_i(ji,layer))
439               ztrid(ji,numeq,3)  =  - zeta_i(ji,layer)*zkappa_i(ji,layer)
440               zindterm(ji,numeq) =  ztiold(ji,layer) + zeta_i(ji,layer)* &
441                  zradab_i(ji,layer)
442            END DO
443         ENDDO
444
445         numeq =  nlay_s + nlay_i + 1
446         DO ji = kideb , kiut
447            !!ice bottom term
448            ztrid(ji,numeq,1)  =  - zeta_i(ji,nlay_i)*zkappa_i(ji,nlay_i-1)   
449            ztrid(ji,numeq,2)  =  1.0 + zeta_i(ji,nlay_i)*( zkappa_i(ji,nlay_i)*zg1 &
450               +  zkappa_i(ji,nlay_i-1) )
451            ztrid(ji,numeq,3)  =  0.0
452            zindterm(ji,numeq) =  ztiold(ji,nlay_i) + zeta_i(ji,nlay_i)* &
453               ( zradab_i(ji,nlay_i) + zkappa_i(ji,nlay_i)*zg1 &
454               *  t_bo_b(ji) ) 
455         ENDDO
456
457
458         DO ji = kideb , kiut
459            IF ( ht_s_b(ji).gt.0.0 ) THEN
460               !
461               !------------------------------------------------------------------------------|
462               !  snow-covered cells                                                          |
463               !------------------------------------------------------------------------------|
464               !
465               !!snow interior terms (bottom equation has the same form as the others)
466               DO numeq = 3, nlay_s + 1
467                  layer =  numeq - 1
468                  ztrid(ji,numeq,1)   =  - zeta_s(ji,layer)*zkappa_s(ji,layer-1)
469                  ztrid(ji,numeq,2)   =  1.0 + zeta_s(ji,layer)*( zkappa_s(ji,layer-1) + &
470                     zkappa_s(ji,layer) )
471                  ztrid(ji,numeq,3)   =  - zeta_s(ji,layer)*zkappa_s(ji,layer)
472                  zindterm(ji,numeq)  =  ztsold(ji,layer) + zeta_s(ji,layer)* &
473                     zradab_s(ji,layer)
474               END DO
475
476               !!case of only one layer in the ice (ice equation is altered)
477               IF ( nlay_i.eq.1 ) THEN
478                  ztrid(ji,nlay_s+2,3)    =  0.0
479                  zindterm(ji,nlay_s+2)   =  zindterm(ji,nlay_s+2) + zkappa_i(ji,1)* &
480                     t_bo_b(ji) 
481               ENDIF
482
483               IF ( t_su_b(ji) .LT. rtt ) THEN
484
485                  !------------------------------------------------------------------------------|
486                  !  case 1 : no surface melting - snow present                                  |
487                  !------------------------------------------------------------------------------|
488                  zdifcase(ji)    =  1.0
489                  numeqmin(ji)    =  1
490                  numeqmax(ji)    =  nlay_i + nlay_s + 1
491
492                  !!surface equation
493                  ztrid(ji,1,1) = 0.0
494                  ztrid(ji,1,2) = dzf(ji) - zg1s*zkappa_s(ji,0)
495                  ztrid(ji,1,3) = zg1s*zkappa_s(ji,0)
496                  zindterm(ji,1) = dzf(ji)*t_su_b(ji)   - zf(ji)
497
498                  !!first layer of snow equation
499                  ztrid(ji,2,1)  =  - zkappa_s(ji,0)*zg1s*zeta_s(ji,1)
500                  ztrid(ji,2,2)  =  1.0 + zeta_s(ji,1)*(zkappa_s(ji,1) + zkappa_s(ji,0)*zg1s)
501                  ztrid(ji,2,3)  =  - zeta_s(ji,1)* zkappa_s(ji,1)
502                  zindterm(ji,2) =  ztsold(ji,1) + zeta_s(ji,1)*zradab_s(ji,1)
503
504               ELSE 
505                  !
506                  !------------------------------------------------------------------------------|
507                  !  case 2 : surface is melting - snow present                                  |
508                  !------------------------------------------------------------------------------|
509                  !
510                  zdifcase(ji)    =  2.0
511                  numeqmin(ji)    =  2
512                  numeqmax(ji)    =  nlay_i + nlay_s + 1
513
514                  !!first layer of snow equation
515                  ztrid(ji,2,1)  =  0.0
516                  ztrid(ji,2,2)  =  1.0 + zeta_s(ji,1) * ( zkappa_s(ji,1) + &
517                     zkappa_s(ji,0) * zg1s )
518                  ztrid(ji,2,3)  =  - zeta_s(ji,1)*zkappa_s(ji,1) 
519                  zindterm(ji,2) = ztsold(ji,1) + zeta_s(ji,1) *            &
520                     ( zradab_s(ji,1) +                         &
521                     zkappa_s(ji,0) * zg1s * t_su_b(ji) ) 
522               ENDIF
523            ELSE
524               !
525               !------------------------------------------------------------------------------|
526               !  cells without snow                                                          |
527               !------------------------------------------------------------------------------|
528               !
529               IF (t_su_b(ji) .LT. rtt) THEN
530                  !
531                  !------------------------------------------------------------------------------|
532                  !  case 3 : no surface melting - no snow                                       |
533                  !------------------------------------------------------------------------------|
534                  !
535                  zdifcase(ji)      =  3.0
536                  numeqmin(ji)      =  nlay_s + 1
537                  numeqmax(ji)      =  nlay_i + nlay_s + 1
538
539                  !!surface equation   
540                  ztrid(ji,numeqmin(ji),1)   =  0.0
541                  ztrid(ji,numeqmin(ji),2)   =  dzf(ji) - zkappa_i(ji,0)*zg1   
542                  ztrid(ji,numeqmin(ji),3)   =  zkappa_i(ji,0)*zg1
543                  zindterm(ji,numeqmin(ji))  =  dzf(ji)*t_su_b(ji) - zf(ji)
544
545                  !!first layer of ice equation
546                  ztrid(ji,numeqmin(ji)+1,1) =  - zkappa_i(ji,0) * zg1 * zeta_i(ji,1)
547                  ztrid(ji,numeqmin(ji)+1,2) =  1.0 + zeta_i(ji,1) * ( zkappa_i(ji,1) & 
548                     + zkappa_i(ji,0) * zg1 )
549                  ztrid(ji,numeqmin(ji)+1,3) =  - zeta_i(ji,1)*zkappa_i(ji,1) 
550                  zindterm(ji,numeqmin(ji)+1)=  ztiold(ji,1) + zeta_i(ji,1)*zradab_i(ji,1) 
551
552                  !!case of only one layer in the ice (surface & ice equations are altered)
553
554                  IF (nlay_i.eq.1) THEN
555                     ztrid(ji,numeqmin(ji),1)    =  0.0
556                     ztrid(ji,numeqmin(ji),2)    =  dzf(ji) - zkappa_i(ji,0)*2.0
557                     ztrid(ji,numeqmin(ji),3)    =  zkappa_i(ji,0)*2.0
558                     ztrid(ji,numeqmin(ji)+1,1)  =  -zkappa_i(ji,0)*2.0*zeta_i(ji,1)
559                     ztrid(ji,numeqmin(ji)+1,2)  =  1.0 + zeta_i(ji,1)*(zkappa_i(ji,0)*2.0 + &
560                        zkappa_i(ji,1))
561                     ztrid(ji,numeqmin(ji)+1,3)  =  0.0
562
563                     zindterm(ji,numeqmin(ji)+1) =  ztiold(ji,1) + zeta_i(ji,1)* &
564                        ( zradab_i(ji,1) + zkappa_i(ji,1)*t_bo_b(ji) )
565                  ENDIF
566
567               ELSE
568
569                  !
570                  !------------------------------------------------------------------------------|
571                  ! case 4 : surface is melting - no snow                                        |
572                  !------------------------------------------------------------------------------|
573                  !
574                  zdifcase(ji)    =  4.0
575                  numeqmin(ji)    =  nlay_s + 2
576                  numeqmax(ji)    =  nlay_i + nlay_s + 1
577
578                  !!first layer of ice equation
579                  ztrid(ji,numeqmin(ji),1)      =  0.0
580                  ztrid(ji,numeqmin(ji),2)      =  1.0 + zeta_i(ji,1)*(zkappa_i(ji,1) + zkappa_i(ji,0)* &
581                     zg1) 
582                  ztrid(ji,numeqmin(ji),3)      =  - zeta_i(ji,1) * zkappa_i(ji,1)
583                  zindterm(ji,numeqmin(ji))     =  ztiold(ji,1) + zeta_i(ji,1)*( zradab_i(ji,1) + &
584                     zkappa_i(ji,0) * zg1 * t_su_b(ji) ) 
585
586                  !!case of only one layer in the ice (surface & ice equations are altered)
587                  IF (nlay_i.eq.1) THEN
588                     ztrid(ji,numeqmin(ji),1)  =  0.0
589                     ztrid(ji,numeqmin(ji),2)  =  1.0 + zeta_i(ji,1)*(zkappa_i(ji,0)*2.0 + &
590                        zkappa_i(ji,1))
591                     ztrid(ji,numeqmin(ji),3)  =  0.0
592                     zindterm(ji,numeqmin(ji)) =  ztiold(ji,1) + zeta_i(ji,1)* &
593                        (zradab_i(ji,1) + zkappa_i(ji,1)*t_bo_b(ji)) &
594                        + t_su_b(ji)*zeta_i(ji,1)*zkappa_i(ji,0)*2.0
595                  ENDIF
596
597               ENDIF
598            ENDIF
599
600         END DO
601
602         !
603         !------------------------------------------------------------------------------|
604         ! 9) tridiagonal system solving                                                |
605         !------------------------------------------------------------------------------|
606         !
607
608         ! Solve the tridiagonal system with Gauss elimination method.
609         ! Thomas algorithm, from Computational fluid Dynamics, J.D. ANDERSON,
610         ! McGraw-Hill 1984. 
611
612         maxnumeqmax = 0
613         minnumeqmin = jkmax+4
614
615         DO ji = kideb , kiut
616            zindtbis(ji,numeqmin(ji)) =  zindterm(ji,numeqmin(ji))
617            zdiagbis(ji,numeqmin(ji)) =  ztrid(ji,numeqmin(ji),2)
618            minnumeqmin               =  MIN(numeqmin(ji),minnumeqmin)
619            maxnumeqmax               =  MAX(numeqmax(ji),maxnumeqmax)
620         END DO
621
622         DO layer = minnumeqmin+1, maxnumeqmax
623            DO ji = kideb , kiut
624               numeq               =  min(max(numeqmin(ji)+1,layer),numeqmax(ji))
625               zdiagbis(ji,numeq)  =  ztrid(ji,numeq,2) - ztrid(ji,numeq,1)* &
626                  ztrid(ji,numeq-1,3)/zdiagbis(ji,numeq-1)
627               zindtbis(ji,numeq)  =  zindterm(ji,numeq) - ztrid(ji,numeq,1)* &
628                  zindtbis(ji,numeq-1)/zdiagbis(ji,numeq-1)
629            END DO
630         END DO
631
632         DO ji = kideb , kiut
633            ! ice temperatures
634            t_i_b(ji,nlay_i)    =  zindtbis(ji,numeqmax(ji))/zdiagbis(ji,numeqmax(ji))
635         END DO
636
637         DO numeq = nlay_i + nlay_s + 1, nlay_s + 2, -1
638            DO ji = kideb , kiut
639               layer    =  numeq - nlay_s - 1
640               t_i_b(ji,layer)  =  (zindtbis(ji,numeq) - ztrid(ji,numeq,3)* &
641                  t_i_b(ji,layer+1))/zdiagbis(ji,numeq)
642            END DO
643         END DO
644
645         DO ji = kideb , kiut
646            ! snow temperatures     
647            IF (ht_s_b(ji).GT.0._wp) &
648               t_s_b(ji,nlay_s)     =  (zindtbis(ji,nlay_s+1) - ztrid(ji,nlay_s+1,3) &
649               *  t_i_b(ji,1))/zdiagbis(ji,nlay_s+1) &
650               *        MAX(0.0,SIGN(1.0,ht_s_b(ji))) 
651
652            ! surface temperature
653            isnow(ji)     = NINT(  1.0 - MAX( 0.0 , SIGN( 1.0 , -ht_s_b(ji) )  )  )
654            ztsuoldit(ji) = t_su_b(ji)
655            IF( t_su_b(ji) < ztfs(ji) ) &
656               t_su_b(ji) = ( zindtbis(ji,numeqmin(ji)) - ztrid(ji,numeqmin(ji),3)* ( REAL( isnow(ji) )*t_s_b(ji,1)   &
657               &          + REAL( 1 - isnow(ji) )*t_i_b(ji,1) ) ) / zdiagbis(ji,numeqmin(ji)) 
658         END DO
659         !
660         !--------------------------------------------------------------------------
661         !  10) Has the scheme converged ?, end of the iterative procedure         |
662         !--------------------------------------------------------------------------
663         !
664         ! check that nowhere it has started to melt
665         ! zerrit(ji) is a measure of error, it has to be under maxer_i_thd
666         DO ji = kideb , kiut
667            t_su_b(ji) =  MAX(  MIN( t_su_b(ji) , ztfs(ji) ) , 190._wp  )
668            zerrit(ji) =  ABS( t_su_b(ji) - ztsuoldit(ji) )     
669         END DO
670
671         DO layer  =  1, nlay_s
672            DO ji = kideb , kiut
673               ii = MOD( npb(ji) - 1, jpi ) + 1
674               ij = ( npb(ji) - 1 ) / jpi + 1
675               t_s_b(ji,layer) = MAX(  MIN( t_s_b(ji,layer), rtt ), 190._wp  )
676               zerrit(ji)      = MAX(zerrit(ji),ABS(t_s_b(ji,layer) - ztstemp(ji,layer)))
677            END DO
678         END DO
679
680         DO layer  =  1, nlay_i
681            DO ji = kideb , kiut
682               ztmelt_i        = -tmut * s_i_b(ji,layer) + rtt 
683               t_i_b(ji,layer) =  MAX(MIN(t_i_b(ji,layer),ztmelt_i), 190._wp)
684               zerrit(ji)      =  MAX(zerrit(ji),ABS(t_i_b(ji,layer) - ztitemp(ji,layer)))
685            END DO
686         END DO
687
688         ! Compute spatial maximum over all errors
689         ! note that this could be optimized substantially by iterating only the non-converging points
690         zerritmax = 0._wp
691         DO ji = kideb, kiut
692            zerritmax = MAX( zerritmax, zerrit(ji) )   
693         END DO
694         IF( lk_mpp ) CALL mpp_max( zerritmax, kcom=ncomm_ice )
695
696      END DO  ! End of the do while iterative procedure
697
698      IF( ln_nicep .AND. lwp ) THEN
699         WRITE(numout,*) ' zerritmax : ', zerritmax
700         WRITE(numout,*) ' nconv     : ', nconv
701      ENDIF
702
703      !
704      !-------------------------------------------------------------------------!
705      !   11) Fluxes at the interfaces                                          !
706      !-------------------------------------------------------------------------!
707      DO ji = kideb, kiut
708         ! forced mode only : update of latent heat fluxes (sublimation) (always >=0, upward flux)
709         IF( .NOT. lk_cpl) qla_ice_1d (ji) = MAX( 0._wp, qla_ice_1d (ji) + dqla_ice_1d(ji) * ( t_su_b(ji) - ztsuold(ji) ) )
710         !                                ! surface ice conduction flux
711         isnow(ji)       = NINT(  1._wp - MAX( 0._wp, SIGN( 1._wp, -ht_s_b(ji) ) )  )
712         fc_su(ji)       =  -     REAL( isnow(ji) ) * zkappa_s(ji,0) * zg1s * (t_s_b(ji,1) - t_su_b(ji))   &
713            &               - REAL( 1 - isnow(ji) ) * zkappa_i(ji,0) * zg1  * (t_i_b(ji,1) - t_su_b(ji))
714         !                                ! bottom ice conduction flux
715         fc_bo_i(ji)     =  - zkappa_i(ji,nlay_i) * ( zg1*(t_bo_b(ji) - t_i_b(ji,nlay_i)) )
716      END DO
717
718      !-----------------------------------------
719      ! Heat flux used to warm/cool ice in W.m-2
720      !-----------------------------------------
721      DO ji = kideb, kiut
722         IF( t_su_b(ji) < rtt ) THEN  ! case T_su < 0degC
723            hfx_tot_1d(ji) = hfx_tot_1d(ji) + ( qns_ice_1d(ji) + qsr_ice_1d(ji) - zradtr_i(ji,nlay_i) - fc_bo_i(ji) ) * a_i_b(ji)
724         ELSE                                    ! case T_su = 0degC
725            hfx_tot_1d(ji) = hfx_tot_1d(ji) + ( fc_su(ji) + i0(ji) * qsr_ice_1d(ji) - zradtr_i(ji,nlay_i) - fc_bo_i(ji) ) * a_i_b(ji)
726         ENDIF
727      END DO
728
729      !
730   END SUBROUTINE lim_thd_dif
731
732#else
733   !!----------------------------------------------------------------------
734   !!                   Dummy Module                 No LIM-3 sea-ice model
735   !!----------------------------------------------------------------------
736CONTAINS
737   SUBROUTINE lim_thd_dif          ! Empty routine
738   END SUBROUTINE lim_thd_dif
739#endif
740   !!======================================================================
741END MODULE limthd_dif
Note: See TracBrowser for help on using the repository browser.