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

source: branches/2013/dev_r3406_CNRS_LIM3/NEMOGCM/NEMO/LIM_SRC_3/limthd_dif.F90 @ 6917

Last change on this file since 6917 was 3938, checked in by flavoni, 11 years ago

dev_r3406_CNRS_LIM3: update LIM3, see ticket #1116

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