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

source: branches/2013/dev_r3406_CNRS_LIM3/NEMOGCM/NEMO/LIM_SRC_3/limthd.F90 @ 3979

Last change on this file since 3979 was 3979, checked in by clem, 11 years ago

bug correction on solar flux penetration

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