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.F90 in branches/2013/dev_MERGE_2013/NEMOGCM/NEMO/LIM_SRC_3 – NEMO

source: branches/2013/dev_MERGE_2013/NEMOGCM/NEMO/LIM_SRC_3/limthd.F90 @ 4295

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

change nb of dimensions of fse3t_m

  • Property svn:keywords set to Id
File size: 47.1 KB
Line 
1MODULE limthd
2   !!======================================================================
3   !!                  ***  MODULE limthd   ***
4   !!  LIM-3 :   ice thermodynamic
5   !!======================================================================
6   !! History :  LIM  ! 2000-01 (M.A. Morales Maqueda, H. Goosse, T. Fichefet) LIM-1
7   !!            2.0  ! 2002-07 (C. Ethe, G. Madec)  LIM-2 (F90 rewriting)
8   !!            3.0  ! 2005-11 (M. Vancoppenolle)  LIM-3 : Multi-layer thermodynamics + salinity variations
9   !!             -   ! 2007-04 (M. Vancoppenolle) add lim_thd_glohec, lim_thd_con_dh and lim_thd_con_dif
10   !!            3.2  ! 2009-07 (M. Vancoppenolle, Y. Aksenov, G. Madec) bug correction in rdm_snw
11   !!            3.3  ! 2010-11 (G. Madec) corrected snow melting heat (due to factor betas)
12   !!            4.0  ! 2011-02 (G. Madec) dynamical allocation
13   !!             -   ! 2012-05 (C. Rousset) add penetration solar flux
14   !!----------------------------------------------------------------------
15#if defined key_lim3
16   !!----------------------------------------------------------------------
17   !!   'key_lim3'                                      LIM3 sea-ice model
18   !!----------------------------------------------------------------------
19   !!   lim_thd       : thermodynamic of sea ice
20   !!   lim_thd_init  : initialisation of sea-ice thermodynamic
21   !!----------------------------------------------------------------------
22   USE phycst         ! physical constants
23   USE dom_oce        ! ocean space and time domain variables
24   USE oce     , ONLY :  iatte, oatte
25   USE ice            ! LIM: sea-ice variables
26   USE par_ice        ! LIM: sea-ice parameters
27   USE sbc_oce        ! Surface boundary condition: ocean fields
28   USE sbc_ice        ! Surface boundary condition: ice fields
29   USE thd_ice        ! LIM thermodynamic sea-ice variables
30   USE dom_ice        ! LIM sea-ice domain
31   USE domvvl         ! domain: variable volume level
32   USE limthd_dif     ! LIM: thermodynamics, vertical diffusion
33   USE limthd_dh      ! LIM: thermodynamics, ice and snow thickness variation
34   USE limthd_sal     ! LIM: thermodynamics, ice salinity
35   USE limthd_ent     ! LIM: thermodynamics, ice enthalpy redistribution
36   USE limtab         ! LIM: 1D <==> 2D transformation
37   USE limvar         ! LIM: sea-ice variables
38   USE lbclnk         ! lateral boundary condition - MPP links
39   USE lib_mpp        ! MPP library
40   USE wrk_nemo       ! work arrays
41   USE in_out_manager ! I/O manager
42   USE prtctl         ! Print control
43   USE lib_fortran    ! Fortran utilities (allows no signed zero when 'key_nosignedzero' defined) 
44   USE timing         ! Timing
45
46   IMPLICIT NONE
47   PRIVATE
48
49   PUBLIC   lim_thd        ! called by limstp module
50   PUBLIC   lim_thd_init   ! called by iceini module
51
52   REAL(wp) ::   epsi20 = 1e-20_wp   ! constant values
53   REAL(wp) ::   epsi16 = 1e-16_wp   !
54   REAL(wp) ::   epsi10 = 1e-10_wp   !
55   REAL(wp) ::   epsi06 = 1e-06_wp   !
56   REAL(wp) ::   epsi04 = 1e-04_wp   !
57   REAL(wp) ::   zzero  = 0._wp      !
58   REAL(wp) ::   zone   = 1._wp      !
59
60   !! * Substitutions
61#  include "domzgr_substitute.h90"
62#  include "vectopt_loop_substitute.h90"
63   !!----------------------------------------------------------------------
64   !! NEMO/LIM3 3.3 , UCL - NEMO Consortium (2010)
65   !! $Id$
66   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
67   !!----------------------------------------------------------------------
68CONTAINS
69
70   SUBROUTINE lim_thd( kt )
71      !!-------------------------------------------------------------------
72      !!                ***  ROUTINE lim_thd  ***       
73      !! 
74      !! ** Purpose : This routine manages the ice thermodynamic.
75      !!         
76      !! ** Action : - Initialisation of some variables
77      !!             - Some preliminary computation (oceanic heat flux
78      !!               at the ice base, snow acc.,heat budget of the leads)
79      !!             - selection of the icy points and put them in an array
80      !!             - call lim_vert_ther for vert ice thermodynamic
81      !!             - back to the geographic grid
82      !!             - selection of points for lateral accretion
83      !!             - call lim_lat_acc  for the ice accretion
84      !!             - back to the geographic grid
85      !!     
86      !! ** References : H. Goosse et al. 1996, Bul. Soc. Roy. Sc. Liege, 65, 87-90
87      !!---------------------------------------------------------------------
88      INTEGER, INTENT(in) ::   kt    ! number of iteration
89      !!
90      INTEGER  ::   ji, jj, jk, jl   ! dummy loop indices
91      INTEGER  ::   nbpb             ! nb of icy pts for thermo. cal.
92      REAL(wp) ::   zfric_umin = 5e-03_wp    ! lower bound for the friction velocity
93      REAL(wp) ::   zfric_umax = 2e-02_wp    ! upper bound for the friction velocity
94      REAL(wp) ::   zinda, zindb, zthsnice, zfric_u     ! local scalar
95      REAL(wp) ::   zfntlat, zpareff, zareamin, zcoef   !    -         -
96      REAL(wp), POINTER, DIMENSION(:,:) ::   zqlbsbq   ! link with lead energy budget qldif
97      REAL(wp) :: zchk_v_i, zchk_smv, zchk_fs, zchk_fw, zchk_v_i_b, zchk_smv_b, zchk_fs_b, zchk_fw_b ! Check conservation (C Rousset)
98      REAL(wp) :: zchk_vmin, zchk_amin, zchk_amax ! Check errors (C Rousset)
99      !!-------------------------------------------------------------------
100      IF( nn_timing == 1 )  CALL timing_start('limthd')
101
102      CALL wrk_alloc( jpi, jpj, zqlbsbq )
103   
104      ! -------------------------------
105      !- check conservation (C Rousset)
106      IF (ln_limdiahsb) THEN
107         zchk_v_i_b = glob_sum( SUM(   v_i(:,:,:), dim=3 ) * area(:,:) * tms(:,:) )
108         zchk_smv_b = glob_sum( SUM( smv_i(:,:,:), dim=3 ) * area(:,:) * tms(:,:) )
109         zchk_fw_b  = glob_sum( rdm_ice(:,:) * area(:,:) * tms(:,:) )
110         zchk_fs_b  = glob_sum( ( sfx_bri(:,:) + sfx_thd(:,:) + sfx_res(:,:) + sfx_mec(:,:) ) * area(:,:) * tms(:,:) )
111      ENDIF
112      !- check conservation (C Rousset)
113      ! -------------------------------
114
115      !------------------------------------------------------------------------------!
116      ! 1) Initialization of diagnostic variables                                    !
117      !------------------------------------------------------------------------------!
118
119      !--------------------
120      ! 1.2) Heat content   
121      !--------------------
122      ! Change the units of heat content; from global units to J.m3
123      DO jl = 1, jpl
124         DO jk = 1, nlay_i
125            DO jj = 1, jpj
126               DO ji = 1, jpi
127                  !Energy of melting q(S,T) [J.m-3]
128                  e_i(ji,jj,jk,jl) = e_i(ji,jj,jk,jl) / ( area(ji,jj) * MAX( v_i(ji,jj,jl) , epsi06 ) ) * REAL( nlay_i )
129                  !0 if no ice and 1 if yes
130                  zindb = 1.0 - MAX(  0.0 , SIGN( 1.0 , - ht_i(ji,jj,jl) )  ) 
131                  !convert units ! very important that this line is here
132                  e_i(ji,jj,jk,jl) = e_i(ji,jj,jk,jl) * unit_fac * zindb 
133               END DO
134            END DO
135         END DO
136         DO jk = 1, nlay_s
137            DO jj = 1, jpj
138               DO ji = 1, jpi
139                  !Energy of melting q(S,T) [J.m-3]
140                  e_s(ji,jj,jk,jl) = e_s(ji,jj,jk,jl) / ( area(ji,jj) * MAX( v_s(ji,jj,jl) , epsi06 ) ) * REAL( nlay_s )
141                  !0 if no ice and 1 if yes
142                  zindb = 1.0 - MAX(  0.0 , SIGN( 1.0 , - ht_s(ji,jj,jl) )  ) 
143                  !convert units ! very important that this line is here
144                  e_s(ji,jj,jk,jl) = e_s(ji,jj,jk,jl) * unit_fac * zindb 
145               END DO
146            END DO
147         END DO
148      END DO
149
150      !-----------------------------
151      ! 1.3) Set some dummies to 0
152      !-----------------------------
153      !clem rdvosif(:,:) = 0.e0   ! variation of ice volume at surface
154      !clem rdvobif(:,:) = 0.e0   ! variation of ice volume at bottom
155      !clem fdvolif(:,:) = 0.e0   ! total variation of ice volume
156      !clem rdvonif(:,:) = 0.e0   ! lateral variation of ice volume
157      !clem fstric (:,:) = 0.e0   ! part of solar radiation transmitted through the ice
158      !clem ffltbif(:,:) = 0.e0   ! linked with fstric
159      !clem qfvbq  (:,:) = 0.e0   ! linked with fstric
160      !clem rdm_snw(:,:) = 0.e0   ! variation of snow mass per unit area
161      !clem rdm_ice(:,:) = 0.e0   ! variation of ice mass per unit area
162      !clem hicifp (:,:) = 0.e0   ! daily thermodynamic ice production.
163      !clem sfx_bri(:,:) = 0.e0   ! brine flux contribution to salt flux to the ocean
164      !clem fhbri  (:,:) = 0.e0   ! brine flux contribution to heat flux to the ocean
165      !clem sfx_thd(:,:) = 0.e0   ! equivalent salt flux to the ocean due to ice/growth decay
166
167      !-----------------------------------
168      ! 1.4) Compute global heat content
169      !-----------------------------------
170      qt_i_in  (:,:) = 0.e0
171      qt_s_in  (:,:) = 0.e0
172      qt_i_fin (:,:) = 0.e0
173      qt_s_fin (:,:) = 0.e0
174      sum_fluxq(:,:) = 0.e0
175      fatm     (:,:) = 0.e0
176
177      ! 2) Partial computation of forcing for the thermodynamic sea ice model.      !
178      !-----------------------------------------------------------------------------!
179
180!CDIR NOVERRCHK
181      DO jj = 1, jpj
182!CDIR NOVERRCHK
183         DO ji = 1, jpi
184            phicif(ji,jj)  = vt_i(ji,jj)
185            pfrld(ji,jj)   = 1.0 - at_i(ji,jj)
186            zinda          = tms(ji,jj) * ( 1.0 - MAX( zzero , SIGN( zone , - at_i(ji,jj) ) ) )
187            !
188            !           !  solar irradiance transmission at the mixed layer bottom and used in the lead heat budget
189            !           !  practically no "direct lateral ablation"
190            !           
191            !           !  net downward heat flux from the ice to the ocean, expressed as a function of ocean
192            !           !  temperature and turbulent mixing (McPhee, 1992)
193            ! friction velocity
194            zfric_u        = MAX ( MIN( SQRT( ust2s(ji,jj) ) , zfric_umax ) , zfric_umin ) 
195
196            ! here the drag will depend on ice thickness and type (0.006)
197            fdtcn(ji,jj)  = zinda * rau0 * rcp * 0.006  * zfric_u * ( (sst_m(ji,jj) + rt0) - t_bo(ji,jj) ) 
198            ! also category dependent
199            !           !-- Energy from the turbulent oceanic heat flux heat flux coming in the lead
200            qdtcn(ji,jj)  = zinda * fdtcn(ji,jj) * (1.0 - at_i(ji,jj)) * rdt_ice
201            !                       
202            !           !-- Lead heat budget, qldif (part 1, next one is in limthd_dh)
203            !           !   caution: exponent betas used as more snow can fallinto leads
204            qldif(ji,jj) =  tms(ji,jj) * rdt_ice  * (                             &
205               &   pfrld(ji,jj)        * (  qsr(ji,jj) * oatte(ji,jj)             &   ! solar heat + clem modif
206               &                            + qns(ji,jj)                          &   ! non solar heat
207               &                            + fdtcn(ji,jj)                        &   ! turbulent ice-ocean heat
208               &                            + fsbbq(ji,jj) * ( 1.0 - zinda )  )   &   ! residual heat from previous step
209               & - pfrld(ji,jj)**betas * sprecip(ji,jj) * lfus                    )   ! latent heat of sprecip melting
210            !
211            ! Positive heat budget is used for bottom ablation
212            zfntlat        = 1.0 - MAX( zzero , SIGN( zone ,  - qldif(ji,jj) ) )
213            != 1 if positive heat budget
214            zpareff        = 1.0 - zinda * zfntlat
215            != 0 if ice and positive heat budget and 1 if one of those two is false
216            zqlbsbq(ji,jj) = qldif(ji,jj) * ( 1.0 - zpareff ) / MAX( at_i(ji,jj) * rdt_ice , epsi16 )
217            !
218            ! Heat budget of the lead, energy transferred from ice to ocean
219            qldif  (ji,jj) = zpareff * qldif(ji,jj)
220            qdtcn  (ji,jj) = zpareff * qdtcn(ji,jj)
221            !
222            ! Energy needed to bring ocean surface layer until its freezing (qcmif, limflx)
223            qcmif  (ji,jj) =  rau0 * rcp * fse3t_m(ji,jj) * ( t_bo(ji,jj) - (sst_m(ji,jj) + rt0) )
224            !
225            ! oceanic heat flux (limthd_dh)
226            fbif   (ji,jj) = zinda * (  fsbbq(ji,jj) / MAX( at_i(ji,jj) , epsi20 ) + fdtcn(ji,jj) )
227            !
228         END DO
229      END DO
230
231      !------------------------------------------------------------------------------!
232      ! 3) Select icy points and fulfill arrays for the vectorial grid.           
233      !------------------------------------------------------------------------------!
234
235      DO jl = 1, jpl      !loop over ice categories
236
237         IF( kt == nit000 .AND. lwp ) THEN
238            WRITE(numout,*) ' lim_thd : transfer to 1D vectors. Category no : ', jl 
239            WRITE(numout,*) ' ~~~~~~~~'
240         ENDIF
241
242         zareamin = 1.e-10
243         nbpb = 0
244         DO jj = 1, jpj
245            DO ji = 1, jpi
246               IF ( a_i(ji,jj,jl) .gt. zareamin ) THEN     
247                  nbpb      = nbpb  + 1
248                  npb(nbpb) = (jj - 1) * jpi + ji
249               ENDIF
250               ! debug point to follow
251               IF ( (ji.eq.jiindx).AND.(jj.eq.jjindx) ) THEN
252                  jiindex_1d = nbpb
253               ENDIF
254            END DO
255         END DO
256
257         !------------------------------------------------------------------------------!
258         ! 4) Thermodynamic computation
259         !------------------------------------------------------------------------------!
260
261         IF( lk_mpp )   CALL mpp_ini_ice( nbpb , numout )
262
263         IF( nbpb > 0 ) THEN  ! If there is no ice, do nothing.
264
265            !-------------------------
266            ! 4.1 Move to 1D arrays
267            !-------------------------
268
269            CALL tab_2d_1d( nbpb, at_i_b     (1:nbpb), at_i            , jpi, jpj, npb(1:nbpb) )
270            CALL tab_2d_1d( nbpb, a_i_b      (1:nbpb), a_i(:,:,jl)     , jpi, jpj, npb(1:nbpb) )
271            CALL tab_2d_1d( nbpb, ht_i_b     (1:nbpb), ht_i(:,:,jl)    , jpi, jpj, npb(1:nbpb) )
272            CALL tab_2d_1d( nbpb, ht_s_b     (1:nbpb), ht_s(:,:,jl)    , jpi, jpj, npb(1:nbpb) )
273
274            CALL tab_2d_1d( nbpb, t_su_b     (1:nbpb), t_su(:,:,jl)    , jpi, jpj, npb(1:nbpb) )
275            CALL tab_2d_1d( nbpb, sm_i_b     (1:nbpb), sm_i(:,:,jl)    , jpi, jpj, npb(1:nbpb) )
276            DO jk = 1, nlay_s
277               CALL tab_2d_1d( nbpb, t_s_b(1:nbpb,jk), t_s(:,:,jk,jl)  , jpi, jpj, npb(1:nbpb) )
278               CALL tab_2d_1d( nbpb, q_s_b(1:nbpb,jk), e_s(:,:,jk,jl)  , jpi, jpj, npb(1:nbpb) )
279            END DO
280            DO jk = 1, nlay_i
281               CALL tab_2d_1d( nbpb, t_i_b(1:nbpb,jk), t_i(:,:,jk,jl)  , jpi, jpj, npb(1:nbpb) )
282               CALL tab_2d_1d( nbpb, q_i_b(1:nbpb,jk), e_i(:,:,jk,jl)  , jpi, jpj, npb(1:nbpb) )
283               CALL tab_2d_1d( nbpb, s_i_b(1:nbpb,jk), s_i(:,:,jk,jl)  , jpi, jpj, npb(1:nbpb) )
284            END DO
285
286            CALL tab_2d_1d( nbpb, tatm_ice_1d(1:nbpb), tatm_ice(:,:)   , jpi, jpj, npb(1:nbpb) )
287            CALL tab_2d_1d( nbpb, qsr_ice_1d (1:nbpb), qsr_ice(:,:,jl) , jpi, jpj, npb(1:nbpb) )
288            CALL tab_2d_1d( nbpb, fr1_i0_1d  (1:nbpb), fr1_i0          , jpi, jpj, npb(1:nbpb) )
289            CALL tab_2d_1d( nbpb, fr2_i0_1d  (1:nbpb), fr2_i0          , jpi, jpj, npb(1:nbpb) )
290            CALL tab_2d_1d( nbpb, qnsr_ice_1d(1:nbpb), qns_ice(:,:,jl) , jpi, jpj, npb(1:nbpb) )
291#if ! defined key_coupled
292            CALL tab_2d_1d( nbpb, qla_ice_1d (1:nbpb), qla_ice(:,:,jl) , jpi, jpj, npb(1:nbpb) )
293            CALL tab_2d_1d( nbpb, dqla_ice_1d(1:nbpb), dqla_ice(:,:,jl), jpi, jpj, npb(1:nbpb) )
294#endif
295            CALL tab_2d_1d( nbpb, dqns_ice_1d(1:nbpb), dqns_ice(:,:,jl), jpi, jpj, npb(1:nbpb) )
296            CALL tab_2d_1d( nbpb, t_bo_b     (1:nbpb), t_bo            , jpi, jpj, npb(1:nbpb) )
297            CALL tab_2d_1d( nbpb, sprecip_1d (1:nbpb), sprecip         , jpi, jpj, npb(1:nbpb) ) 
298            CALL tab_2d_1d( nbpb, fbif_1d    (1:nbpb), fbif            , jpi, jpj, npb(1:nbpb) )
299            CALL tab_2d_1d( nbpb, qldif_1d   (1:nbpb), qldif           , jpi, jpj, npb(1:nbpb) )
300            CALL tab_2d_1d( nbpb, rdm_ice_1d (1:nbpb), rdm_ice         , jpi, jpj, npb(1:nbpb) )
301            CALL tab_2d_1d( nbpb, rdm_snw_1d (1:nbpb), rdm_snw         , jpi, jpj, npb(1:nbpb) )
302            CALL tab_2d_1d( nbpb, dmgwi_1d   (1:nbpb), dmgwi           , jpi, jpj, npb(1:nbpb) )
303            CALL tab_2d_1d( nbpb, qlbbq_1d   (1:nbpb), zqlbsbq         , jpi, jpj, npb(1:nbpb) )
304
305            CALL tab_2d_1d( nbpb, sfx_thd_1d (1:nbpb), sfx_thd         , jpi, jpj, npb(1:nbpb) )
306            CALL tab_2d_1d( nbpb, sfx_bri_1d (1:nbpb), sfx_bri         , jpi, jpj, npb(1:nbpb) )
307            CALL tab_2d_1d( nbpb, fhbri_1d   (1:nbpb), fhbri           , jpi, jpj, npb(1:nbpb) )
308            CALL tab_2d_1d( nbpb, fstbif_1d  (1:nbpb), fstric          , jpi, jpj, npb(1:nbpb) )
309            CALL tab_2d_1d( nbpb, qfvbq_1d   (1:nbpb), qfvbq           , jpi, jpj, npb(1:nbpb) )
310
311            CALL tab_2d_1d( nbpb, iatte_1d   (1:nbpb), iatte           , jpi, jpj, npb(1:nbpb) ) ! clem modif
312            CALL tab_2d_1d( nbpb, oatte_1d   (1:nbpb), oatte           , jpi, jpj, npb(1:nbpb) ) ! clem modif
313            !--------------------------------
314            ! 4.3) Thermodynamic processes
315            !--------------------------------
316
317            IF( con_i )   CALL lim_thd_enmelt( 1, nbpb )   ! computes sea ice energy of melting
318            IF( con_i )   CALL lim_thd_glohec( qt_i_in, qt_s_in, q_i_layer_in, 1, nbpb, jl )
319
320            !                                 !---------------------------------!
321            CALL lim_thd_dif( 1, nbpb, jl )   ! Ice/Snow Temperature profile    !
322            !                                 !---------------------------------!
323
324            CALL lim_thd_enmelt( 1, nbpb )    ! computes sea ice energy of melting compulsory for limthd_dh
325
326            IF( con_i )   CALL lim_thd_glohec ( qt_i_fin, qt_s_fin, q_i_layer_fin, 1, nbpb, jl ) 
327            IF( con_i )   CALL lim_thd_con_dif( 1 , nbpb , jl )
328
329            !                                 !---------------------------------!
330            CALL lim_thd_dh( 1, nbpb, jl )    ! Ice/Snow thickness              !
331            !                                 !---------------------------------!
332
333            !                                 !---------------------------------!
334            CALL lim_thd_ent( 1, nbpb, jl )   ! Ice/Snow enthalpy remapping     !
335            !                                 !---------------------------------!
336
337            !                                 !---------------------------------!
338            CALL lim_thd_sal( 1, nbpb )       ! Ice salinity computation        !
339            !                                 !---------------------------------!
340
341            !           CALL lim_thd_enmelt(1,nbpb)   ! computes sea ice energy of melting
342            IF( con_i )   CALL lim_thd_glohec( qt_i_fin, qt_s_fin, q_i_layer_fin, 1, nbpb, jl ) 
343            IF( con_i )   CALL lim_thd_con_dh ( 1 , nbpb , jl )
344
345            !--------------------------------
346            ! 4.4) Move 1D to 2D vectors
347            !--------------------------------
348
349               CALL tab_1d_2d( nbpb, at_i          , npb, at_i_b    (1:nbpb)   , jpi, jpj )
350               CALL tab_1d_2d( nbpb, ht_i(:,:,jl)  , npb, ht_i_b    (1:nbpb)   , jpi, jpj )
351               CALL tab_1d_2d( nbpb, ht_s(:,:,jl)  , npb, ht_s_b    (1:nbpb)   , jpi, jpj )
352               CALL tab_1d_2d( nbpb, a_i (:,:,jl)  , npb, a_i_b     (1:nbpb)   , jpi, jpj )
353               CALL tab_1d_2d( nbpb, t_su(:,:,jl)  , npb, t_su_b    (1:nbpb)   , jpi, jpj )
354               CALL tab_1d_2d( nbpb, sm_i(:,:,jl)  , npb, sm_i_b    (1:nbpb)   , jpi, jpj )
355            DO jk = 1, nlay_s
356               CALL tab_1d_2d( nbpb, t_s(:,:,jk,jl), npb, t_s_b     (1:nbpb,jk), jpi, jpj)
357               CALL tab_1d_2d( nbpb, e_s(:,:,jk,jl), npb, q_s_b     (1:nbpb,jk), jpi, jpj)
358            END DO
359            DO jk = 1, nlay_i
360               CALL tab_1d_2d( nbpb, t_i(:,:,jk,jl), npb, t_i_b     (1:nbpb,jk), jpi, jpj)
361               CALL tab_1d_2d( nbpb, e_i(:,:,jk,jl), npb, q_i_b     (1:nbpb,jk), jpi, jpj)
362               CALL tab_1d_2d( nbpb, s_i(:,:,jk,jl), npb, s_i_b     (1:nbpb,jk), jpi, jpj)
363            END DO
364               CALL tab_1d_2d( nbpb, fstric        , npb, fstbif_1d (1:nbpb)   , jpi, jpj )
365               CALL tab_1d_2d( nbpb, qldif         , npb, qldif_1d  (1:nbpb)   , jpi, jpj )
366               CALL tab_1d_2d( nbpb, qfvbq         , npb, qfvbq_1d  (1:nbpb)   , jpi, jpj )
367               CALL tab_1d_2d( nbpb, rdm_ice       , npb, rdm_ice_1d(1:nbpb)   , jpi, jpj )
368               CALL tab_1d_2d( nbpb, rdm_snw       , npb, rdm_snw_1d(1:nbpb)   , jpi, jpj )
369               CALL tab_1d_2d( nbpb, dmgwi         , npb, dmgwi_1d  (1:nbpb)   , jpi, jpj )
370               CALL tab_1d_2d( nbpb, rdvosif       , npb, dvsbq_1d  (1:nbpb)   , jpi, jpj )
371               CALL tab_1d_2d( nbpb, rdvobif       , npb, dvbbq_1d  (1:nbpb)   , jpi, jpj )
372               CALL tab_1d_2d( nbpb, fdvolif       , npb, dvlbq_1d  (1:nbpb)   , jpi, jpj )
373               CALL tab_1d_2d( nbpb, rdvonif       , npb, dvnbq_1d  (1:nbpb)   , jpi, jpj ) 
374               CALL tab_1d_2d( nbpb, sfx_thd       , npb, sfx_thd_1d(1:nbpb)   , jpi, jpj )
375            !
376            IF( num_sal == 2 ) THEN
377               CALL tab_1d_2d( nbpb, sfx_bri       , npb, sfx_bri_1d(1:nbpb)   , jpi, jpj )
378               CALL tab_1d_2d( nbpb, fhbri         , npb, fhbri_1d  (1:nbpb)   , jpi, jpj )
379            ENDIF
380            !
381            !+++++       temporary stuff for a dummy version
382            CALL tab_1d_2d( nbpb, dh_i_surf2D, npb, dh_i_surf(1:nbpb)      , jpi, jpj )
383            CALL tab_1d_2d( nbpb, dh_i_bott2D, npb, dh_i_bott(1:nbpb)      , jpi, jpj )
384            CALL tab_1d_2d( nbpb, fsup2D     , npb, fsup     (1:nbpb)      , jpi, jpj )
385            CALL tab_1d_2d( nbpb, focea2D    , npb, focea    (1:nbpb)      , jpi, jpj )
386            CALL tab_1d_2d( nbpb, s_i_newice , npb, s_i_new  (1:nbpb)      , jpi, jpj )
387            CALL tab_1d_2d( nbpb, izero(:,:,jl) , npb, i0    (1:nbpb)      , jpi, jpj )
388            CALL tab_1d_2d( nbpb, qns_ice(:,:,jl), npb, qnsr_ice_1d(1:nbpb), jpi, jpj)
389            !+++++
390            !
391            IF( lk_mpp )   CALL mpp_comm_free( ncomm_ice ) !RB necessary ??
392         ENDIF
393         !
394      END DO
395
396      !------------------------------------------------------------------------------!
397      ! 5) Global variables, diagnostics
398      !------------------------------------------------------------------------------!
399
400      !------------------------
401      ! 5.1) Ice heat content             
402      !------------------------
403      ! Enthalpies are global variables we have to readjust the units (heat content in 10^9 Joules)
404      zcoef = 1._wp / ( unit_fac * REAL( nlay_i ) )
405      DO jl = 1, jpl
406         DO jk = 1, nlay_i
407            e_i(:,:,jk,jl) = e_i(:,:,jk,jl) * area(:,:) * a_i(:,:,jl) * ht_i(:,:,jl) * zcoef
408         END DO
409      END DO
410
411      !------------------------
412      ! 5.2) Snow heat content             
413      !------------------------
414      ! Enthalpies are global variables we have to readjust the units (heat content in 10^9 Joules)
415      zcoef = 1._wp / ( unit_fac * REAL( nlay_s ) )
416      DO jl = 1, jpl
417         DO jk = 1, nlay_s
418            e_s(:,:,jk,jl) = e_s(:,:,jk,jl) * area(:,:) * a_i(:,:,jl) * ht_s(:,:,jl) * zcoef
419         END DO
420      END DO
421
422      !----------------------------------
423      ! 5.3) Change thickness to volume
424      !----------------------------------
425      CALL lim_var_eqv2glo
426
427      !--------------------------------------------
428      ! 5.4) Diagnostic thermodynamic growth rates
429      !--------------------------------------------
430!clem@useless      d_v_i_thd(:,:,:) = v_i      (:,:,:) - old_v_i(:,:,:)    ! ice volumes
431!clem@mv-to-itd    dv_dt_thd(:,:,:) = d_v_i_thd(:,:,:) * r1_rdtice * rday
432
433      IF( con_i )   fbif(:,:) = fbif(:,:) + zqlbsbq(:,:)
434
435      IF(ln_ctl) THEN            ! Control print
436         CALL prt_ctl_info(' ')
437         CALL prt_ctl_info(' - Cell values : ')
438         CALL prt_ctl_info('   ~~~~~~~~~~~~~ ')
439         CALL prt_ctl(tab2d_1=area , clinfo1=' lim_thd  : cell area :')
440         CALL prt_ctl(tab2d_1=at_i , clinfo1=' lim_thd  : at_i      :')
441         CALL prt_ctl(tab2d_1=vt_i , clinfo1=' lim_thd  : vt_i      :')
442         CALL prt_ctl(tab2d_1=vt_s , clinfo1=' lim_thd  : vt_s      :')
443         DO jl = 1, jpl
444            CALL prt_ctl_info(' ')
445            CALL prt_ctl_info(' - Category : ', ivar1=jl)
446            CALL prt_ctl_info('   ~~~~~~~~~~')
447            CALL prt_ctl(tab2d_1=a_i   (:,:,jl)   , clinfo1= ' lim_thd  : a_i      : ')
448            CALL prt_ctl(tab2d_1=ht_i  (:,:,jl)   , clinfo1= ' lim_thd  : ht_i     : ')
449            CALL prt_ctl(tab2d_1=ht_s  (:,:,jl)   , clinfo1= ' lim_thd  : ht_s     : ')
450            CALL prt_ctl(tab2d_1=v_i   (:,:,jl)   , clinfo1= ' lim_thd  : v_i      : ')
451            CALL prt_ctl(tab2d_1=v_s   (:,:,jl)   , clinfo1= ' lim_thd  : v_s      : ')
452            CALL prt_ctl(tab2d_1=e_s   (:,:,1,jl) , clinfo1= ' lim_thd  : e_s      : ')
453            CALL prt_ctl(tab2d_1=t_su  (:,:,jl)   , clinfo1= ' lim_thd  : t_su     : ')
454            CALL prt_ctl(tab2d_1=t_s   (:,:,1,jl) , clinfo1= ' lim_thd  : t_snow   : ')
455            CALL prt_ctl(tab2d_1=sm_i  (:,:,jl)   , clinfo1= ' lim_thd  : sm_i     : ')
456            CALL prt_ctl(tab2d_1=smv_i (:,:,jl)   , clinfo1= ' lim_thd  : smv_i    : ')
457            DO jk = 1, nlay_i
458               CALL prt_ctl_info(' ')
459               CALL prt_ctl_info(' - Layer : ', ivar1=jk)
460               CALL prt_ctl_info('   ~~~~~~~')
461               CALL prt_ctl(tab2d_1=t_i(:,:,jk,jl) , clinfo1= ' lim_thd  : t_i      : ')
462               CALL prt_ctl(tab2d_1=e_i(:,:,jk,jl) , clinfo1= ' lim_thd  : e_i      : ')
463            END DO
464         END DO
465      ENDIF
466      !
467      ! -------------------------------
468      !- check conservation (C Rousset)
469      IF (ln_limdiahsb) THEN
470         zchk_fs  = glob_sum( ( sfx_bri(:,:) + sfx_thd(:,:) + sfx_res(:,:) + sfx_mec(:,:) ) * area(:,:) * tms(:,:) ) - zchk_fs_b
471         zchk_fw  = glob_sum( rdm_ice(:,:) * area(:,:) * tms(:,:) ) - zchk_fw_b
472 
473         zchk_v_i = ( glob_sum( SUM(   v_i(:,:,:), dim=3 ) * area(:,:) * tms(:,:) ) - zchk_v_i_b - ( zchk_fw / rhoic ) ) * r1_rdtice
474         zchk_smv = ( glob_sum( SUM( smv_i(:,:,:), dim=3 ) * area(:,:) * tms(:,:) ) - zchk_smv_b ) * r1_rdtice + ( zchk_fs / rhoic )
475
476         zchk_vmin = glob_min(v_i)
477         zchk_amax = glob_max(SUM(a_i,dim=3))
478         zchk_amin = glob_min(a_i)
479       
480         IF(lwp) THEN
481            IF ( ABS( zchk_v_i   ) >  1.e-5 ) WRITE(numout,*) 'violation volume [m3/day]     (limthd) = ',(zchk_v_i * rday)
482            IF ( ABS( zchk_smv   ) >  1.e-4 ) WRITE(numout,*) 'violation saline [psu*m3/day] (limthd) = ',(zchk_smv * rday)
483            IF ( zchk_vmin <  0.            ) WRITE(numout,*) 'violation v_i<0  [mm]         (limthd) = ',(zchk_vmin * 1.e-3)
484            IF ( zchk_amax >  amax+epsi10   ) WRITE(numout,*) 'violation a_i>amax            (limthd) = ',zchk_amax
485            IF ( zchk_amin <  0.            ) WRITE(numout,*) 'violation a_i<0               (limthd) = ',zchk_amin
486         ENDIF
487      ENDIF
488      !- check conservation (C Rousset)
489      ! -------------------------------
490      !
491      CALL wrk_dealloc( jpi, jpj, zqlbsbq )
492      !
493      IF( nn_timing == 1 )  CALL timing_stop('limthd')
494   END SUBROUTINE lim_thd
495
496
497   SUBROUTINE lim_thd_glohec( eti, ets, etilayer, kideb, kiut, jl )
498      !!-----------------------------------------------------------------------
499      !!                   ***  ROUTINE lim_thd_glohec ***
500      !!                 
501      !! ** Purpose :  Compute total heat content for each category
502      !!               Works with 1d vectors only
503      !!-----------------------------------------------------------------------
504      INTEGER , INTENT(in   )                         ::   kideb, kiut   ! bounds for the spatial loop
505      INTEGER , INTENT(in   )                         ::   jl            ! category number
506      REAL(wp), INTENT(  out), DIMENSION (jpij,jpl  ) ::   eti, ets      ! vertically-summed heat content for ice & snow
507      REAL(wp), INTENT(  out), DIMENSION (jpij,jkmax) ::   etilayer      ! heat content for ice layers
508      !!
509      INTEGER  ::   ji,jk   ! loop indices
510      !!-----------------------------------------------------------------------
511      eti(:,:) = 0._wp
512      ets(:,:) = 0._wp
513      !
514      DO jk = 1, nlay_i                ! total q over all layers, ice [J.m-2]
515         DO ji = kideb, kiut
516            etilayer(ji,jk) = q_i_b(ji,jk) * ht_i_b(ji) / REAL( nlay_i )
517            eti     (ji,jl) = eti(ji,jl) + etilayer(ji,jk) 
518         END DO
519      END DO
520      DO ji = kideb, kiut              ! total q over all layers, snow [J.m-2]
521         ets(ji,jl) = ets(ji,jl) + q_s_b(ji,1) * ht_s_b(ji) / REAL( nlay_s )
522      END DO
523      !
524      IF(lwp) WRITE(numout,*) ' lim_thd_glohec '
525      IF(lwp) WRITE(numout,*) ' qt_i_in : ', eti(jiindex_1d,jl) * r1_rdtice
526      IF(lwp) WRITE(numout,*) ' qt_s_in : ', ets(jiindex_1d,jl) * r1_rdtice
527      IF(lwp) WRITE(numout,*) ' qt_in   : ', ( eti(jiindex_1d,jl) + ets(jiindex_1d,jl) ) * r1_rdtice
528      !
529   END SUBROUTINE lim_thd_glohec
530
531
532   SUBROUTINE lim_thd_con_dif( kideb, kiut, jl )
533      !!-----------------------------------------------------------------------
534      !!                   ***  ROUTINE lim_thd_con_dif ***
535      !!                 
536      !! ** Purpose :   Test energy conservation after heat diffusion
537      !!-------------------------------------------------------------------
538      INTEGER , INTENT(in   ) ::   kideb, kiut   ! bounds for the spatial loop
539      INTEGER , INTENT(in   ) ::   jl            ! category number
540
541      INTEGER  ::   ji, jk         ! loop indices
542      INTEGER  ::   ii, ij
543      INTEGER  ::   numce          ! number of points for which conservation is violated
544      REAL(wp) ::   meance         ! mean conservation error
545      REAL(wp) ::   max_cons_err, max_surf_err
546      !!---------------------------------------------------------------------
547
548      max_cons_err =  1.0_wp          ! maximum tolerated conservation error
549      max_surf_err =  0.001_wp        ! maximum tolerated surface error
550
551      !--------------------------
552      ! Increment of energy
553      !--------------------------
554      ! global
555      DO ji = kideb, kiut
556         dq_i(ji,jl) = qt_i_fin(ji,jl) - qt_i_in(ji,jl) + qt_s_fin(ji,jl) - qt_s_in(ji,jl)
557      END DO
558      ! layer by layer
559      dq_i_layer(:,:) = q_i_layer_fin(:,:) - q_i_layer_in(:,:)
560
561      !----------------------------------------
562      ! Atmospheric heat flux, ice heat budget
563      !----------------------------------------
564      DO ji = kideb, kiut
565         ii = MOD( npb(ji) - 1 , jpi ) + 1
566         ij =    ( npb(ji) - 1 ) / jpi + 1
567         fatm     (ji,jl) = qnsr_ice_1d(ji) + ( 1._wp - i0(ji) ) * qsr_ice_1d(ji)
568         sum_fluxq(ji,jl) = fc_su(ji) - fc_bo_i(ji) + qsr_ice_1d(ji) * i0(ji) - fstroc(ii,ij,jl)
569      END DO
570
571      !--------------------
572      ! Conservation error
573      !--------------------
574      DO ji = kideb, kiut
575         cons_error(ji,jl) = ABS( dq_i(ji,jl) * r1_rdtice + sum_fluxq(ji,jl) )
576      END DO
577
578      numce  = 0
579      meance = 0._wp
580      DO ji = kideb, kiut
581         IF ( cons_error(ji,jl) .GT. max_cons_err ) THEN
582            numce = numce + 1
583            meance = meance + cons_error(ji,jl)
584         ENDIF
585      END DO
586      IF( numce > 0 )   meance = meance / numce
587
588      WRITE(numout,*) ' Maximum tolerated conservation error : ', max_cons_err
589      WRITE(numout,*) ' After lim_thd_dif, category : ', jl
590      WRITE(numout,*) ' Mean conservation error on big error points ', meance, numit
591      WRITE(numout,*) ' Number of points where there is a cons err gt than c.e. : ', numce, numit
592
593      !-------------------------------------------------------
594      ! Surface error due to imbalance between Fatm and Fcsu
595      !-------------------------------------------------------
596      numce  = 0
597      meance = 0._wp
598
599      DO ji = kideb, kiut
600         surf_error(ji,jl) = ABS ( fatm(ji,jl) - fc_su(ji) )
601         IF( ( t_su_b(ji) .LT. rtt ) .AND. ( surf_error(ji,jl) .GT. max_surf_err ) ) THEN
602            numce = numce + 1 
603            meance = meance + surf_error(ji,jl)
604         ENDIF
605      ENDDO
606      IF( numce > 0 )   meance = meance / numce
607
608      WRITE(numout,*) ' Maximum tolerated surface error : ', max_surf_err
609      WRITE(numout,*) ' After lim_thd_dif, category : ', jl
610      WRITE(numout,*) ' Mean surface error on big error points ', meance, numit
611      WRITE(numout,*) ' Number of points where there is a surf err gt than surf_err : ', numce, numit
612
613      IF (jiindex_1D.GT.0) WRITE(numout,*) ' fc_su      : ', fc_su(jiindex_1d)
614      IF (jiindex_1D.GT.0) WRITE(numout,*) ' fatm       : ', fatm(jiindex_1d,jl)
615      IF (jiindex_1D.GT.0) WRITE(numout,*) ' t_su       : ', t_su_b(jiindex_1d)
616
617      !---------------------------------------
618      ! Write ice state in case of big errors
619      !---------------------------------------
620      DO ji = kideb, kiut
621         IF ( ( ( t_su_b(ji) .LT. rtt ) .AND. ( surf_error(ji,jl) .GT. max_surf_err ) ) .OR. &
622            ( cons_error(ji,jl) .GT. max_cons_err  ) ) THEN
623            ii                 = MOD( npb(ji) - 1, jpi ) + 1
624            ij                 = ( npb(ji) - 1 ) / jpi + 1
625            !
626            WRITE(numout,*) ' alerte 1     '
627            WRITE(numout,*) ' Untolerated conservation / surface error after '
628            WRITE(numout,*) ' heat diffusion in the ice '
629            WRITE(numout,*) ' Category   : ', jl
630            WRITE(numout,*) ' ii , ij  : ', ii, ij
631            WRITE(numout,*) ' lat, lon   : ', gphit(ii,ij), glamt(ii,ij)
632            WRITE(numout,*) ' cons_error : ', cons_error(ji,jl)
633            WRITE(numout,*) ' surf_error : ', surf_error(ji,jl)
634            WRITE(numout,*) ' dq_i       : ', - dq_i(ji,jl) * r1_rdtice
635            WRITE(numout,*) ' Fdt        : ', sum_fluxq(ji,jl)
636            WRITE(numout,*)
637            !        WRITE(numout,*) ' qt_i_in   : ', qt_i_in(ji,jl)
638            !        WRITE(numout,*) ' qt_s_in   : ', qt_s_in(ji,jl)
639            !        WRITE(numout,*) ' qt_i_fin  : ', qt_i_fin(ji,jl)
640            !        WRITE(numout,*) ' qt_s_fin  : ', qt_s_fin(ji,jl)
641            !        WRITE(numout,*) ' qt        : ', qt_i_fin(ji,jl) + qt_s_fin(ji,jl)
642            WRITE(numout,*) ' ht_i       : ', ht_i_b(ji)
643            WRITE(numout,*) ' ht_s       : ', ht_s_b(ji)
644            WRITE(numout,*) ' t_su       : ', t_su_b(ji)
645            WRITE(numout,*) ' t_s        : ', t_s_b(ji,1)
646            WRITE(numout,*) ' t_i        : ', t_i_b(ji,1:nlay_i)
647            WRITE(numout,*) ' t_bo       : ', t_bo_b(ji)
648            WRITE(numout,*) ' q_i        : ', q_i_b(ji,1:nlay_i)
649            WRITE(numout,*) ' s_i        : ', s_i_b(ji,1:nlay_i)
650            WRITE(numout,*) ' tmelts     : ', rtt - tmut*s_i_b(ji,1:nlay_i)
651            WRITE(numout,*)
652            WRITE(numout,*) ' Fluxes '
653            WRITE(numout,*) ' ~~~~~~ '
654            WRITE(numout,*) ' fatm       : ', fatm(ji,jl)
655            WRITE(numout,*) ' fc_su      : ', fc_su    (ji)
656            WRITE(numout,*) ' fstr_inice : ', qsr_ice_1d(ji)*i0(ji)
657            WRITE(numout,*) ' fc_bo      : ', - fc_bo_i  (ji)
658            WRITE(numout,*) ' foc        : ', fbif_1d(ji)
659            WRITE(numout,*) ' fstroc     : ', fstroc   (ii,ij,jl)
660            WRITE(numout,*) ' i0         : ', i0(ji)
661            WRITE(numout,*) ' qsr_ice    : ', (1.0-i0(ji))*qsr_ice_1d(ji)
662            WRITE(numout,*) ' qns_ice    : ', qnsr_ice_1d(ji)
663            WRITE(numout,*) ' Conduction fluxes : '
664            WRITE(numout,*) ' fc_s      : ', fc_s(ji,0:nlay_s)
665            WRITE(numout,*) ' fc_i      : ', fc_i(ji,0:nlay_i)
666            WRITE(numout,*)
667            WRITE(numout,*) ' Layer by layer ... '
668            WRITE(numout,*) ' dq_snow : ', ( qt_s_fin(ji,jl) - qt_s_in(ji,jl) ) * r1_rdtice
669            WRITE(numout,*) ' dfc_snow  : ', fc_s(ji,1) - fc_s(ji,0)
670            DO jk = 1, nlay_i
671               WRITE(numout,*) ' layer  : ', jk
672               WRITE(numout,*) ' dq_ice : ', dq_i_layer(ji,jk) * r1_rdtice 
673               WRITE(numout,*) ' radab  : ', radab(ji,jk)
674               WRITE(numout,*) ' dfc_i  : ', fc_i(ji,jk) - fc_i(ji,jk-1)
675               WRITE(numout,*) ' tot f  : ', fc_i(ji,jk) - fc_i(ji,jk-1) - radab(ji,jk)
676            END DO
677
678         ENDIF
679         !
680      END DO
681      !
682   END SUBROUTINE lim_thd_con_dif
683
684
685   SUBROUTINE lim_thd_con_dh( kideb, kiut, jl )
686      !!-----------------------------------------------------------------------
687      !!                   ***  ROUTINE lim_thd_con_dh  ***
688      !!                 
689      !! ** Purpose :   Test energy conservation after enthalpy redistr.
690      !!-----------------------------------------------------------------------
691      INTEGER, INTENT(in) ::   kideb, kiut   ! bounds for the spatial loop
692      INTEGER, INTENT(in) ::   jl            ! category number
693      !
694      INTEGER  ::   ji                ! loop indices
695      INTEGER  ::   ii, ij, numce         ! local integers
696      REAL(wp) ::   meance, max_cons_err    !local scalar
697      !!---------------------------------------------------------------------
698
699      max_cons_err = 1._wp
700
701      !--------------------------
702      ! Increment of energy
703      !--------------------------
704      DO ji = kideb, kiut
705         dq_i(ji,jl) = qt_i_fin(ji,jl) - qt_i_in(ji,jl) + qt_s_fin(ji,jl) - qt_s_in(ji,jl)   ! global
706      END DO
707      dq_i_layer(:,:)    = q_i_layer_fin(:,:) - q_i_layer_in(:,:)                            ! layer by layer
708
709      !----------------------------------------
710      ! Atmospheric heat flux, ice heat budget
711      !----------------------------------------
712      DO ji = kideb, kiut
713         ii = MOD( npb(ji) - 1 , jpi ) + 1
714         ij =    ( npb(ji) - 1 ) / jpi + 1
715
716         fatm      (ji,jl) = qnsr_ice_1d(ji) + qsr_ice_1d(ji)                       ! total heat flux
717         sum_fluxq (ji,jl) = fatm(ji,jl) + fbif_1d(ji) - ftotal_fin(ji) - fstroc(ii,ij,jl) 
718         cons_error(ji,jl) = ABS( dq_i(ji,jl) * r1_rdtice + sum_fluxq(ji,jl) )
719      END DO
720
721      !--------------------
722      ! Conservation error
723      !--------------------
724      DO ji = kideb, kiut
725         cons_error(ji,jl) = ABS( dq_i(ji,jl) * r1_rdtice + sum_fluxq(ji,jl) )
726      END DO
727
728      numce = 0
729      meance = 0._wp
730      DO ji = kideb, kiut
731         IF( cons_error(ji,jl) .GT. max_cons_err ) THEN
732            numce = numce + 1
733            meance = meance + cons_error(ji,jl)
734         ENDIF
735      ENDDO
736      IF(numce > 0 ) meance = meance / numce
737
738      WRITE(numout,*) ' Error report - Category : ', jl
739      WRITE(numout,*) ' ~~~~~~~~~~~~ '
740      WRITE(numout,*) ' Maximum tolerated conservation error : ', max_cons_err
741      WRITE(numout,*) ' After lim_thd_ent, category : ', jl
742      WRITE(numout,*) ' Mean conservation error on big error points ', meance, numit
743      WRITE(numout,*) ' Number of points where there is a cons err gt than 0.1 W/m2 : ', numce, numit
744
745      !---------------------------------------
746      ! Write ice state in case of big errors
747      !---------------------------------------
748      DO ji = kideb, kiut
749         IF ( cons_error(ji,jl) .GT. max_cons_err  ) THEN
750            ii = MOD( npb(ji) - 1, jpi ) + 1
751            ij =    ( npb(ji) - 1 ) / jpi + 1
752            !
753            WRITE(numout,*) ' alerte 1 - category : ', jl
754            WRITE(numout,*) ' Untolerated conservation error after limthd_ent '
755            WRITE(numout,*) ' ii , ij  : ', ii, ij
756            WRITE(numout,*) ' lat, lon   : ', gphit(ii,ij), glamt(ii,ij)
757            WRITE(numout,*) ' * '
758            WRITE(numout,*) ' Ftotal     : ', sum_fluxq(ji,jl)
759            WRITE(numout,*) ' dq_t       : ', - dq_i(ji,jl) * r1_rdtice
760            WRITE(numout,*) ' dq_i       : ', - ( qt_i_fin(ji,jl) - qt_i_in(ji,jl) ) * r1_rdtice
761            WRITE(numout,*) ' dq_s       : ', - ( qt_s_fin(ji,jl) - qt_s_in(ji,jl) ) * r1_rdtice
762            WRITE(numout,*) ' cons_error : ', cons_error(ji,jl)
763            WRITE(numout,*) ' * '
764            WRITE(numout,*) ' Fluxes        --- : '
765            WRITE(numout,*) ' fatm       : ', fatm(ji,jl)
766            WRITE(numout,*) ' foce       : ', fbif_1d(ji)
767            WRITE(numout,*) ' fres       : ', ftotal_fin(ji)
768            WRITE(numout,*) ' fhbri      : ', fhbricat(ii,ij,jl)
769            WRITE(numout,*) ' * '
770            WRITE(numout,*) ' Heat contents --- : '
771            WRITE(numout,*) ' qt_s_in    : ', qt_s_in(ji,jl) * r1_rdtice
772            WRITE(numout,*) ' qt_i_in    : ', qt_i_in(ji,jl) * r1_rdtice
773            WRITE(numout,*) ' qt_in      : ', ( qt_i_in(ji,jl) + qt_s_in(ji,jl) ) * r1_rdtice
774            WRITE(numout,*) ' qt_s_fin   : ', qt_s_fin(ji,jl) * r1_rdtice
775            WRITE(numout,*) ' qt_i_fin   : ', qt_i_fin(ji,jl) * r1_rdtice
776            WRITE(numout,*) ' qt_fin     : ', ( qt_i_fin(ji,jl) + qt_s_fin(ji,jl) ) * r1_rdtice
777            WRITE(numout,*) ' * '
778            WRITE(numout,*) ' Ice variables --- : '
779            WRITE(numout,*) ' ht_i       : ', ht_i_b(ji)
780            WRITE(numout,*) ' ht_s       : ', ht_s_b(ji)
781            WRITE(numout,*) ' dh_s_tot  : ', dh_s_tot(ji)
782            WRITE(numout,*) ' dh_snowice: ', dh_snowice(ji)
783            WRITE(numout,*) ' dh_i_surf : ', dh_i_surf(ji)
784            WRITE(numout,*) ' dh_i_bott : ', dh_i_bott(ji)
785         ENDIF
786         !
787      END DO
788      !
789   END SUBROUTINE lim_thd_con_dh
790
791
792   SUBROUTINE lim_thd_enmelt( kideb, kiut )
793      !!-----------------------------------------------------------------------
794      !!                   ***  ROUTINE lim_thd_enmelt ***
795      !!                 
796      !! ** Purpose :   Computes sea ice energy of melting q_i (J.m-3)
797      !!
798      !! ** Method  :   Formula (Bitz and Lipscomb, 1999)
799      !!-------------------------------------------------------------------
800      INTEGER, INTENT(in) ::   kideb, kiut   ! bounds for the spatial loop
801      !!
802      INTEGER  ::   ji, jk   ! dummy loop indices
803      REAL(wp) ::   ztmelts  ! local scalar
804      !!-------------------------------------------------------------------
805      !
806      DO jk = 1, nlay_i             ! Sea ice energy of melting
807         DO ji = kideb, kiut
808            ztmelts      =  - tmut  * s_i_b(ji,jk) + rtt 
809            q_i_b(ji,jk) =    rhoic * ( cpic * ( ztmelts - t_i_b(ji,jk) )                                 &
810               &                      + lfus * ( 1.0 - (ztmelts-rtt) / MIN( t_i_b(ji,jk)-rtt, -epsi10 ) )   &
811               &                      - rcp  * ( ztmelts-rtt  )  ) 
812         END DO
813      END DO
814      DO jk = 1, nlay_s             ! Snow energy of melting
815         DO ji = kideb, kiut
816            q_s_b(ji,jk) = rhosn * ( cpic * ( rtt - t_s_b(ji,jk) ) + lfus )
817         END DO
818      END DO
819      !
820   END SUBROUTINE lim_thd_enmelt
821
822
823   SUBROUTINE lim_thd_init
824      !!-----------------------------------------------------------------------
825      !!                   ***  ROUTINE lim_thd_init ***
826      !!                 
827      !! ** Purpose :   Physical constants and parameters linked to the ice
828      !!              thermodynamics
829      !!
830      !! ** Method  :   Read the namicethd namelist and check the ice-thermo
831      !!              parameter values called at the first timestep (nit000)
832      !!
833      !! ** input   :   Namelist namicether
834      !!-------------------------------------------------------------------
835      INTEGER  ::   ios                 ! Local integer output status for namelist read
836      NAMELIST/namicethd/ hmelt , hiccrit, fraz_swi, maxfrazb, vfrazb, Cfrazb,   &
837         &                hicmin, hiclim,                                        &
838         &                sbeta  , parlat, hakspl, hibspl, exld,                 &
839         &                hakdif, hnzst  , thth  , parsub, alphs, betas,         & 
840         &                kappa_i, nconv_i_thd, maxer_i_thd, thcon_i_swi
841      !!-------------------------------------------------------------------
842      !
843      IF(lwp) THEN
844         WRITE(numout,*)
845         WRITE(numout,*) 'lim_thd : Ice Thermodynamics'
846         WRITE(numout,*) '~~~~~~~'
847      ENDIF
848      !
849      REWIND( numnam_ice_ref )              ! Namelist namicethd in reference namelist : Ice thermodynamics
850      READ  ( numnam_ice_ref, namicethd, IOSTAT = ios, ERR = 901)
851901   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namicethd in reference namelist', lwp )
852
853      REWIND( numnam_ice_cfg )              ! Namelist namicethd in configuration namelist : Ice thermodynamics
854      READ  ( numnam_ice_cfg, namicethd, IOSTAT = ios, ERR = 902 )
855902   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namicethd in configuration namelist', lwp )
856      WRITE ( numoni, namicethd )
857      !
858      IF(lwp) THEN                          ! control print
859         WRITE(numout,*)
860         WRITE(numout,*)'   Namelist of ice parameters for ice thermodynamic computation '
861         WRITE(numout,*)'      maximum melting at the bottom                           hmelt        = ', hmelt
862         WRITE(numout,*)'      ice thick. for lateral accretion in NH (SH)             hiccrit(1/2) = ', hiccrit
863         WRITE(numout,*)'      Frazil ice thickness as a function of wind or not       fraz_swi     = ', fraz_swi
864         WRITE(numout,*)'      Maximum proportion of frazil ice collecting at bottom   maxfrazb     = ', maxfrazb
865         WRITE(numout,*)'      Thresold relative drift speed for collection of frazil  vfrazb       = ', vfrazb
866         WRITE(numout,*)'      Squeezing coefficient for collection of frazil          Cfrazb       = ', Cfrazb
867         WRITE(numout,*)'      ice thick. corr. to max. energy stored in brine pocket  hicmin       = ', hicmin 
868         WRITE(numout,*)'      minimum ice thickness                                   hiclim       = ', hiclim 
869         WRITE(numout,*)'      numerical carac. of the scheme for diffusion in ice '
870         WRITE(numout,*)'      Cranck-Nicholson (=0.5), implicit (=1), explicit (=0)   sbeta        = ', sbeta
871         WRITE(numout,*)'      percentage of energy used for lateral ablation          parlat       = ', parlat
872         WRITE(numout,*)'      slope of distr. for Hakkinen-Mellor lateral melting     hakspl       = ', hakspl 
873         WRITE(numout,*)'      slope of distribution for Hibler lateral melting        hibspl       = ', hibspl
874         WRITE(numout,*)'      exponent for leads-closure rate                         exld         = ', exld
875         WRITE(numout,*)'      coefficient for diffusions of ice and snow              hakdif       = ', hakdif
876         WRITE(numout,*)'      threshold thick. for comp. of eq. thermal conductivity  zhth         = ', thth 
877         WRITE(numout,*)'      thickness of the surf. layer in temp. computation       hnzst        = ', hnzst
878         WRITE(numout,*)'      switch for snow sublimation  (=1) or not (=0)           parsub       = ', parsub 
879         WRITE(numout,*)'      coefficient for snow density when snow ice formation    alphs        = ', alphs
880         WRITE(numout,*)'      coefficient for ice-lead partition of snowfall          betas        = ', betas
881         WRITE(numout,*)'      extinction radiation parameter in sea ice (1.0)         kappa_i      = ', kappa_i
882         WRITE(numout,*)'      maximal n. of iter. for heat diffusion computation      nconv_i_thd  = ', nconv_i_thd
883         WRITE(numout,*)'      maximal err. on T for heat diffusion computation        maxer_i_thd  = ', maxer_i_thd
884         WRITE(numout,*)'      switch for comp. of thermal conductivity in the ice     thcon_i_swi  = ', thcon_i_swi
885      ENDIF
886      !
887      rcdsn = hakdif * rcdsn 
888      rcdic = hakdif * rcdic
889      !
890   END SUBROUTINE lim_thd_init
891
892#else
893   !!----------------------------------------------------------------------
894   !!   Default option         Dummy module          NO  LIM3 sea-ice model
895   !!----------------------------------------------------------------------
896#endif
897
898   !!======================================================================
899END MODULE limthd
Note: See TracBrowser for help on using the repository browser.