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.
icectl.F90 in NEMO/branches/2020/dev_r13541_TOP-01_rlod_Antarctic_ice_Sheet_Fe_Source/src/ICE – NEMO

source: NEMO/branches/2020/dev_r13541_TOP-01_rlod_Antarctic_ice_Sheet_Fe_Source/src/ICE/icectl.F90 @ 13886

Last change on this file since 13886 was 13886, checked in by rlod, 3 years ago

phasing with trunk at revision r13787

  • Property svn:keywords set to Id
File size: 45.5 KB
Line 
1MODULE icectl
2   !!======================================================================
3   !!                     ***  MODULE  icectl  ***
4   !!   sea-ice : controls and prints
5   !!======================================================================
6   !! History :  3.5  !  2015-01  (M. Vancoppenolle) Original code
7   !!            3.7  !  2016-10  (C. Rousset)       Add routine ice_prt3D
8   !!            4.0  !  2018     (many people)      SI3 [aka Sea Ice cube]
9   !!----------------------------------------------------------------------
10#if defined key_si3
11   !!----------------------------------------------------------------------
12   !!   'key_si3'                                       SI3 sea-ice model
13   !!----------------------------------------------------------------------
14   !!    ice_cons_hsm     : conservation tests on heat, salt and mass during a  time step (global)
15   !!    ice_cons_final   : conservation tests on heat, salt and mass at end of time step (global)
16   !!    ice_cons2D       : conservation tests on heat, salt and mass at each gridcell
17   !!    ice_ctl          : control prints in case of crash
18   !!    ice_prt          : control prints at a given grid point
19   !!    ice_prt3D        : control prints of ice arrays
20   !!----------------------------------------------------------------------
21   USE phycst         ! physical constants
22   USE oce            ! ocean dynamics and tracers
23   USE dom_oce        ! ocean space and time domain
24   USE ice            ! sea-ice: variables
25   USE ice1D          ! sea-ice: thermodynamics variables
26   USE sbc_oce        ! Surface boundary condition: ocean fields
27   USE sbc_ice        ! Surface boundary condition: ice   fields
28   !
29   USE in_out_manager ! I/O manager
30   USE iom            ! I/O manager library
31   USE lib_mpp        ! MPP library
32   USE lib_fortran    ! fortran utilities (glob_sum + no signed zero)
33   USE timing         ! Timing
34   USE prtctl         ! Print control
35
36   IMPLICIT NONE
37   PRIVATE
38
39   PUBLIC   ice_cons_hsm
40   PUBLIC   ice_cons_final
41   PUBLIC   ice_cons2D
42   PUBLIC   ice_ctl
43   PUBLIC   ice_prt
44   PUBLIC   ice_prt3D
45   PUBLIC   ice_drift_wri
46   PUBLIC   ice_drift_init
47
48   ! thresold rates for conservation
49   !    these values are changed by the namelist parameter rn_icechk, so that threshold = zchk * rn_icechk
50   REAL(wp), PARAMETER ::   zchk_m   = 2.5e-7   ! kg/m2/s <=> 1e-6 m of ice per hour spuriously gained/lost
51   REAL(wp), PARAMETER ::   zchk_s   = 2.5e-6   ! g/m2/s  <=> 1e-6 m of ice per hour spuriously gained/lost (considering s=10g/kg)
52   REAL(wp), PARAMETER ::   zchk_t   = 7.5e-2   ! W/m2    <=> 1e-6 m of ice per hour spuriously gained/lost (considering Lf=3e5J/kg)
53
54   ! for drift outputs
55   CHARACTER(LEN=50)   ::   clname="icedrift_diagnostics.ascii"   ! ascii filename
56   INTEGER             ::   numicedrift                           ! outfile unit
57   REAL(wp)            ::   rdiag_icemass, rdiag_icesalt, rdiag_iceheat 
58   REAL(wp)            ::   rdiag_adv_icemass, rdiag_adv_icesalt, rdiag_adv_iceheat 
59   
60   !! * Substitutions
61#  include "do_loop_substitute.h90"
62   !!----------------------------------------------------------------------
63   !! NEMO/ICE 4.0 , NEMO Consortium (2018)
64   !! $Id$
65   !! Software governed by the CeCILL license (see ./LICENSE)
66   !!----------------------------------------------------------------------
67CONTAINS
68
69   SUBROUTINE ice_cons_hsm( icount, cd_routine, pdiag_v, pdiag_s, pdiag_t, pdiag_fv, pdiag_fs, pdiag_ft )
70      !!-------------------------------------------------------------------
71      !!                       ***  ROUTINE ice_cons_hsm ***
72      !!
73      !! ** Purpose : Test the conservation of heat, salt and mass for each ice routine
74      !!                     + test if ice concentration and volume are > 0
75      !!
76      !! ** Method  : This is an online diagnostics which can be activated with ln_icediachk=true
77      !!              It prints in ocean.output if there is a violation of conservation at each time-step
78      !!              The thresholds (zchk_m, zchk_s, zchk_t) determine violations
79      !!              For salt and heat thresholds, ice is considered to have a salinity of 10
80      !!              and a heat content of 3e5 J/kg (=latent heat of fusion)
81      !!-------------------------------------------------------------------
82      INTEGER         , INTENT(in)    ::   icount        ! called at: =0 the begining of the routine, =1  the end
83      CHARACTER(len=*), INTENT(in)    ::   cd_routine    ! name of the routine
84      REAL(wp)        , INTENT(inout) ::   pdiag_v, pdiag_s, pdiag_t, pdiag_fv, pdiag_fs, pdiag_ft
85      !!
86      REAL(wp) ::   zdiag_mass, zdiag_salt, zdiag_heat, &
87         &          zdiag_vmin, zdiag_amin, zdiag_amax, zdiag_eimin, zdiag_esmin, zdiag_smin
88      REAL(wp) ::   zvtrp, zetrp
89      REAL(wp) ::   zarea
90      !!-------------------------------------------------------------------
91      !
92      IF( icount == 0 ) THEN
93
94         pdiag_v = glob_sum( 'icectl',   SUM( v_i * rhoi + v_s * rhos, dim=3 ) * e1e2t )
95         pdiag_s = glob_sum( 'icectl',   SUM( sv_i * rhoi            , dim=3 ) * e1e2t )
96         pdiag_t = glob_sum( 'icectl', ( SUM( SUM( e_i, dim=4 ), dim=3 ) + SUM( SUM( e_s, dim=4 ), dim=3 ) ) * e1e2t )
97
98         ! mass flux
99         pdiag_fv = glob_sum( 'icectl',  &
100            &                         ( wfx_bog + wfx_bom + wfx_sum + wfx_sni + wfx_opw + wfx_res + wfx_dyn + wfx_lam + wfx_pnd + &
101            &                           wfx_snw_sni + wfx_snw_sum + wfx_snw_dyn + wfx_snw_sub + wfx_ice_sub + wfx_spr ) * e1e2t )
102         ! salt flux
103         pdiag_fs = glob_sum( 'icectl',  &
104            &                         ( sfx_bri + sfx_bog + sfx_bom + sfx_sum + sfx_sni + &
105            &                           sfx_opw + sfx_res + sfx_dyn + sfx_sub + sfx_lam ) * e1e2t )
106         ! heat flux
107         pdiag_ft = glob_sum( 'icectl',  &
108            &                         (   hfx_sum + hfx_bom + hfx_bog + hfx_dif + hfx_opw + hfx_snw  &
109            &                           - hfx_thd - hfx_dyn - hfx_res - hfx_sub - hfx_spr ) * e1e2t )
110
111      ELSEIF( icount == 1 ) THEN
112
113         ! -- mass diag -- !
114         zdiag_mass = ( glob_sum( 'icectl', SUM( v_i * rhoi + v_s * rhos, dim=3 ) * e1e2t ) - pdiag_v ) * r1_Dt_ice       &
115            &         + glob_sum( 'icectl', ( wfx_bog + wfx_bom + wfx_sum + wfx_sni + wfx_opw + wfx_res + wfx_dyn +       &
116            &                                 wfx_lam + wfx_pnd + wfx_snw_sni + wfx_snw_sum + wfx_snw_dyn + wfx_snw_sub + &
117            &                                 wfx_ice_sub + wfx_spr ) * e1e2t )                                           &
118            &         - pdiag_fv
119         !
120         ! -- salt diag -- !
121         zdiag_salt = ( glob_sum( 'icectl', SUM( sv_i * rhoi , dim=3 ) * e1e2t ) - pdiag_s ) * r1_Dt_ice  &
122            &         + glob_sum( 'icectl', ( sfx_bri + sfx_bog + sfx_bom + sfx_sum + sfx_sni +           &
123            &                                 sfx_opw + sfx_res + sfx_dyn + sfx_sub + sfx_lam ) * e1e2t ) &
124            &         - pdiag_fs
125         !
126         ! -- heat diag -- !
127         zdiag_heat = ( glob_sum( 'icectl', ( SUM(SUM(e_i, dim=4), dim=3) + SUM(SUM(e_s, dim=4), dim=3) ) * e1e2t ) - pdiag_t &
128            &         ) * r1_Dt_ice                                                                                           &
129            &         + glob_sum( 'icectl', (  hfx_sum + hfx_bom + hfx_bog + hfx_dif + hfx_opw + hfx_snw                      &
130            &                                - hfx_thd - hfx_dyn - hfx_res - hfx_sub - hfx_spr ) * e1e2t )                    &
131            &         - pdiag_ft
132
133         ! -- min/max diag -- !
134         zdiag_amax  = glob_max( 'icectl', SUM( a_i, dim=3 ) )
135         zdiag_vmin  = glob_min( 'icectl', v_i )
136         zdiag_amin  = glob_min( 'icectl', a_i )
137         zdiag_smin  = glob_min( 'icectl', sv_i )
138         zdiag_eimin = glob_min( 'icectl', SUM( e_i, dim=3 ) )
139         zdiag_esmin = glob_min( 'icectl', SUM( e_s, dim=3 ) )
140
141         ! -- advection scheme is conservative? -- !
142         zvtrp = glob_sum( 'icectl', diag_adv_mass * e1e2t )
143         zetrp = glob_sum( 'icectl', diag_adv_heat * e1e2t )
144
145         ! ice area (+epsi10 to set a threshold > 0 when there is no ice)
146         zarea = glob_sum( 'icectl', SUM( a_i + epsi10, dim=3 ) * e1e2t )
147
148         IF( lwp ) THEN
149            ! check conservation issues
150            IF( ABS(zdiag_mass) > zchk_m * rn_icechk_glo * zarea ) &
151               &                   WRITE(numout,*)   cd_routine,' : violation mass cons. [kg] = ',zdiag_mass * rDt_ice
152            IF( ABS(zdiag_salt) > zchk_s * rn_icechk_glo * zarea ) &
153               &                   WRITE(numout,*)   cd_routine,' : violation salt cons. [g]  = ',zdiag_salt * rDt_ice
154            IF( ABS(zdiag_heat) > zchk_t * rn_icechk_glo * zarea ) &
155               &                   WRITE(numout,*)   cd_routine,' : violation heat cons. [J]  = ',zdiag_heat * rDt_ice
156            ! check negative values
157            IF( zdiag_vmin  < 0. ) WRITE(numout,*)   cd_routine,' : violation v_i < 0         = ',zdiag_vmin
158            IF( zdiag_amin  < 0. ) WRITE(numout,*)   cd_routine,' : violation a_i < 0         = ',zdiag_amin
159            IF( zdiag_smin  < 0. ) WRITE(numout,*)   cd_routine,' : violation s_i < 0         = ',zdiag_smin
160            IF( zdiag_eimin < 0. ) WRITE(numout,*)   cd_routine,' : violation e_i < 0         = ',zdiag_eimin
161            IF( zdiag_esmin < 0. ) WRITE(numout,*)   cd_routine,' : violation e_s < 0         = ',zdiag_esmin
162            ! check maximum ice concentration
163            IF( zdiag_amax > MAX(rn_amax_n,rn_amax_s)+epsi10 .AND. cd_routine /= 'icedyn_adv' .AND. cd_routine /= 'icedyn_rdgrft' ) &
164               &                   WRITE(numout,*)   cd_routine,' : violation a_i > amax      = ',zdiag_amax
165            ! check if advection scheme is conservative
166            IF( ABS(zvtrp) > zchk_m * rn_icechk_glo * zarea .AND. cd_routine == 'icedyn_adv' ) &
167               &                   WRITE(numout,*)   cd_routine,' : violation adv scheme [kg] = ',zvtrp * rdt_ice
168            IF( ABS(zetrp) > zchk_t * rn_icechk_glo * zarea .AND. cd_routine == 'icedyn_adv' ) &
169               &                   WRITE(numout,*)   cd_routine,' : violation adv scheme [J]  = ',zetrp * rdt_ice
170         ENDIF
171         !
172      ENDIF
173
174   END SUBROUTINE ice_cons_hsm
175
176   SUBROUTINE ice_cons_final( cd_routine )
177      !!-------------------------------------------------------------------
178      !!                     ***  ROUTINE ice_cons_final ***
179      !!
180      !! ** Purpose : Test the conservation of heat, salt and mass at the end of each ice time-step
181      !!
182      !! ** Method  : This is an online diagnostics which can be activated with ln_icediachk=true
183      !!              It prints in ocean.output if there is a violation of conservation at each time-step
184      !!              The thresholds (zchk_m, zchk_s, zchk_t) determine the violations
185      !!              For salt and heat thresholds, ice is considered to have a salinity of 10
186      !!              and a heat content of 3e5 J/kg (=latent heat of fusion)
187      !!-------------------------------------------------------------------
188      CHARACTER(len=*), INTENT(in) ::   cd_routine    ! name of the routine
189      REAL(wp) ::   zdiag_mass, zdiag_salt, zdiag_heat
190      REAL(wp) ::   zarea
191      !!-------------------------------------------------------------------
192
193      ! water flux
194      ! -- mass diag -- !
195      zdiag_mass = glob_sum( 'icectl', (  wfx_ice   + wfx_snw   + wfx_spr + wfx_sub &
196         &                              + diag_vice + diag_vsnw - diag_adv_mass ) * e1e2t )
197
198      ! -- salt diag -- !
199      zdiag_salt = glob_sum( 'icectl', ( sfx + diag_sice - diag_adv_salt ) * e1e2t )
200
201      ! -- heat diag -- !
202      zdiag_heat  = glob_sum( 'icectl', ( qt_oce_ai - qt_atm_oi + diag_heat - diag_adv_heat ) * e1e2t )
203      ! equivalent to this:
204      !!zdiag_heat = glob_sum( 'icectl', ( -diag_heat + hfx_sum + hfx_bom + hfx_bog + hfx_dif + hfx_opw + hfx_snw &
205      !!   &                                          - hfx_thd - hfx_dyn - hfx_res - hfx_sub - hfx_spr &
206      !!   &                                          ) * e1e2t )
207
208      ! ice area (+epsi10 to set a threshold > 0 when there is no ice)
209      zarea = glob_sum( 'icectl', SUM( a_i + epsi10, dim=3 ) * e1e2t )
210
211      IF( lwp ) THEN
212         IF( ABS(zdiag_mass) > zchk_m * rn_icechk_glo * zarea ) &
213            &                   WRITE(numout,*) cd_routine,' : violation mass cons. [kg] = ',zdiag_mass * rDt_ice
214         IF( ABS(zdiag_salt) > zchk_s * rn_icechk_glo * zarea ) &
215            &                   WRITE(numout,*) cd_routine,' : violation salt cons. [g]  = ',zdiag_salt * rDt_ice
216         IF( ABS(zdiag_heat) > zchk_t * rn_icechk_glo * zarea ) &
217            &                   WRITE(numout,*) cd_routine,' : violation heat cons. [J]  = ',zdiag_heat * rDt_ice
218      ENDIF
219      !
220   END SUBROUTINE ice_cons_final
221
222   SUBROUTINE ice_cons2D( icount, cd_routine, pdiag_v, pdiag_s, pdiag_t, pdiag_fv, pdiag_fs, pdiag_ft )
223      !!-------------------------------------------------------------------
224      !!                       ***  ROUTINE ice_cons2D ***
225      !!
226      !! ** Purpose : Test the conservation of heat, salt and mass for each ice routine
227      !!                     + test if ice concentration and volume are > 0
228      !!
229      !! ** Method  : This is an online diagnostics which can be activated with ln_icediachk=true
230      !!              It stops the code if there is a violation of conservation at any gridcell
231      !!-------------------------------------------------------------------
232      INTEGER         , INTENT(in) ::   icount        ! called at: =0 the begining of the routine, =1  the end
233      CHARACTER(len=*), INTENT(in) ::   cd_routine    ! name of the routine
234      REAL(wp)        , DIMENSION(jpi,jpj), INTENT(inout) ::   pdiag_v, pdiag_s, pdiag_t, pdiag_fv, pdiag_fs, pdiag_ft
235      !!
236      REAL(wp), DIMENSION(jpi,jpj) ::   zdiag_mass, zdiag_salt, zdiag_heat, &
237         &                              zdiag_amin, zdiag_vmin, zdiag_smin, zdiag_emin !!, zdiag_amax 
238      INTEGER ::   jl, jk
239      LOGICAL ::   ll_stop_m = .FALSE.
240      LOGICAL ::   ll_stop_s = .FALSE.
241      LOGICAL ::   ll_stop_t = .FALSE.
242      CHARACTER(len=120) ::   clnam   ! filename for the output
243      !!-------------------------------------------------------------------
244      !
245      IF( icount == 0 ) THEN
246
247         pdiag_v = SUM( v_i  * rhoi + v_s * rhos, dim=3 )
248         pdiag_s = SUM( sv_i * rhoi             , dim=3 )
249         pdiag_t = SUM( SUM( e_i, dim=4 ), dim=3 ) + SUM( SUM( e_s, dim=4 ), dim=3 )
250
251         ! mass flux
252         pdiag_fv = wfx_bog + wfx_bom + wfx_sum + wfx_sni + wfx_opw + wfx_res + wfx_dyn + wfx_lam + wfx_pnd  +  &
253            &       wfx_snw_sni + wfx_snw_sum + wfx_snw_dyn + wfx_snw_sub + wfx_ice_sub + wfx_spr
254         ! salt flux
255         pdiag_fs = sfx_bri + sfx_bog + sfx_bom + sfx_sum + sfx_sni + sfx_opw + sfx_res + sfx_dyn + sfx_sub + sfx_lam 
256         ! heat flux
257         pdiag_ft =   hfx_sum + hfx_bom + hfx_bog + hfx_dif + hfx_opw + hfx_snw  & 
258            &       - hfx_thd - hfx_dyn - hfx_res - hfx_sub - hfx_spr
259
260      ELSEIF( icount == 1 ) THEN
261
262         ! -- mass diag -- !
263         zdiag_mass =   ( SUM( v_i * rhoi + v_s * rhos, dim=3 ) - pdiag_v ) * r1_Dt_ice                             &
264            &         + ( wfx_bog + wfx_bom + wfx_sum + wfx_sni + wfx_opw + wfx_res + wfx_dyn + wfx_lam + wfx_pnd + &
265            &             wfx_snw_sni + wfx_snw_sum + wfx_snw_dyn + wfx_snw_sub + wfx_ice_sub + wfx_spr )           &
266            &         - pdiag_fv
267         IF( MAXVAL( ABS(zdiag_mass) ) > zchk_m * rn_icechk_cel )   ll_stop_m = .TRUE.
268         !
269         ! -- salt diag -- !
270         zdiag_salt =   ( SUM( sv_i * rhoi , dim=3 ) - pdiag_s ) * r1_Dt_ice                                                  &
271            &         + ( sfx_bri + sfx_bog + sfx_bom + sfx_sum + sfx_sni + sfx_opw + sfx_res + sfx_dyn + sfx_sub + sfx_lam ) &
272            &         - pdiag_fs
273         IF( MAXVAL( ABS(zdiag_salt) ) > zchk_s * rn_icechk_cel )   ll_stop_s = .TRUE.
274         !
275         ! -- heat diag -- !
276         zdiag_heat =   ( SUM( SUM( e_i, dim=4 ), dim=3 ) + SUM( SUM( e_s, dim=4 ), dim=3 ) - pdiag_t ) * r1_Dt_ice &
277            &         + (  hfx_sum + hfx_bom + hfx_bog + hfx_dif + hfx_opw + hfx_snw                                & 
278            &            - hfx_thd - hfx_dyn - hfx_res - hfx_sub - hfx_spr )                                        &
279            &         - pdiag_ft
280         IF( MAXVAL( ABS(zdiag_heat) ) > zchk_t * rn_icechk_cel )   ll_stop_t = .TRUE.
281         !
282         ! -- other diags -- !
283         ! a_i < 0
284         zdiag_amin(:,:) = 0._wp
285         DO jl = 1, jpl
286            WHERE( a_i(:,:,jl) < 0._wp )   zdiag_amin(:,:) = 1._wp
287         ENDDO
288         ! v_i < 0
289         zdiag_vmin(:,:) = 0._wp
290         DO jl = 1, jpl
291            WHERE( v_i(:,:,jl) < 0._wp )   zdiag_vmin(:,:) = 1._wp
292         ENDDO
293         ! s_i < 0
294         zdiag_smin(:,:) = 0._wp
295         DO jl = 1, jpl
296            WHERE( s_i(:,:,jl) < 0._wp )   zdiag_smin(:,:) = 1._wp
297         ENDDO
298         ! e_i < 0
299         zdiag_emin(:,:) = 0._wp
300         DO jl = 1, jpl
301            DO jk = 1, nlay_i
302               WHERE( e_i(:,:,jk,jl) < 0._wp )   zdiag_emin(:,:) = 1._wp
303            ENDDO
304         ENDDO
305         ! a_i > amax
306         !WHERE( SUM( a_i, dim=3 ) > ( MAX( rn_amax_n, rn_amax_s ) + epsi10 )   ;   zdiag_amax(:,:) = 1._wp
307         !ELSEWHERE                                                             ;   zdiag_amax(:,:) = 0._wp
308         !END WHERE
309
310         IF( ll_stop_m .OR. ll_stop_s .OR. ll_stop_t ) THEN
311            clnam = 'diag_ice_conservation_'//cd_routine
312            CALL ice_cons_wri( clnam, zdiag_mass, zdiag_salt, zdiag_heat, zdiag_amin, zdiag_vmin, zdiag_smin, zdiag_emin )
313         ENDIF
314
315         IF( ll_stop_m )   CALL ctl_stop( 'STOP', cd_routine//': ice mass conservation issue' )
316         IF( ll_stop_s )   CALL ctl_stop( 'STOP', cd_routine//': ice salt conservation issue' )
317         IF( ll_stop_t )   CALL ctl_stop( 'STOP', cd_routine//': ice heat conservation issue' )
318         
319      ENDIF
320
321   END SUBROUTINE ice_cons2D
322
323   SUBROUTINE ice_cons_wri( cdfile_name, pdiag_mass, pdiag_salt, pdiag_heat, pdiag_amin, pdiag_vmin, pdiag_smin, pdiag_emin )
324      !!---------------------------------------------------------------------
325      !!                 ***  ROUTINE ice_cons_wri  ***
326      !!       
327      !! ** Purpose :   create a NetCDF file named cdfile_name which contains
328      !!                the instantaneous fields when conservation issue occurs
329      !!
330      !! ** Method  :   NetCDF files using ioipsl
331      !!----------------------------------------------------------------------
332      CHARACTER(len=*), INTENT( in ) ::   cdfile_name      ! name of the file created
333      REAL(wp), DIMENSION(:,:), INTENT( in ) ::   pdiag_mass, pdiag_salt, pdiag_heat, &
334         &                                        pdiag_amin, pdiag_vmin, pdiag_smin, pdiag_emin !!, pdiag_amax 
335      !!
336      INTEGER ::   inum
337      !!----------------------------------------------------------------------
338      !
339      IF(lwp) WRITE(numout,*)
340      IF(lwp) WRITE(numout,*) 'ice_cons_wri : single instantaneous ice state'
341      IF(lwp) WRITE(numout,*) '~~~~~~~~~~~~~  named :', cdfile_name, '...nc'
342      IF(lwp) WRITE(numout,*)               
343
344      CALL iom_open( TRIM(cdfile_name), inum, ldwrt = .TRUE., kdlev = jpl, cdcomp = 'ICE' )
345     
346      CALL iom_rstput( 0, 0, inum, 'cons_mass', pdiag_mass(:,:) , ktype = jp_r8 )    ! ice mass spurious lost/gain
347      CALL iom_rstput( 0, 0, inum, 'cons_salt', pdiag_salt(:,:) , ktype = jp_r8 )    ! ice salt spurious lost/gain
348      CALL iom_rstput( 0, 0, inum, 'cons_heat', pdiag_heat(:,:) , ktype = jp_r8 )    ! ice heat spurious lost/gain
349      ! other diags
350      CALL iom_rstput( 0, 0, inum, 'aneg_count', pdiag_amin(:,:) , ktype = jp_r8 )    !
351      CALL iom_rstput( 0, 0, inum, 'vneg_count', pdiag_vmin(:,:) , ktype = jp_r8 )    !
352      CALL iom_rstput( 0, 0, inum, 'sneg_count', pdiag_smin(:,:) , ktype = jp_r8 )    !
353      CALL iom_rstput( 0, 0, inum, 'eneg_count', pdiag_emin(:,:) , ktype = jp_r8 )    !
354     
355      CALL iom_close( inum )
356
357   END SUBROUTINE ice_cons_wri
358   
359   SUBROUTINE ice_ctl( kt )
360      !!-------------------------------------------------------------------
361      !!                   ***  ROUTINE ice_ctl ***
362      !!                 
363      !! ** Purpose :   control checks
364      !!-------------------------------------------------------------------
365      INTEGER, INTENT(in) ::   kt      ! ocean time step
366      INTEGER  ::   ja, ji, jj, jk, jl ! dummy loop indices
367      INTEGER  ::   ialert_id          ! number of the current alert
368      REAL(wp) ::   ztmelts            ! ice layer melting point
369      CHARACTER (len=30), DIMENSION(20) ::   cl_alname   ! name of alert
370      INTEGER           , DIMENSION(20) ::   inb_alp     ! number of alerts positive
371      !!-------------------------------------------------------------------
372      inb_alp(:) = 0
373      ialert_id = 0
374     
375      ! Alert if very high salinity
376      ialert_id = ialert_id + 1 ! reference number of this alert
377      cl_alname(ialert_id) = ' Very high salinity ' ! name of the alert
378      DO jl = 1, jpl
379         DO_2D( 1, 1, 1, 1 )
380            IF( v_i(ji,jj,jl) > epsi10  ) THEN
381               IF( sv_i(ji,jj,jl) / v_i(ji,jj,jl) > rn_simax ) THEN
382                  WRITE(numout,*) ' ALERTE :   Very high salinity ',sv_i(ji,jj,jl)/v_i(ji,jj,jl)
383                  WRITE(numout,*) ' at i,j,l = ',ji,jj,jl
384                  inb_alp(ialert_id) = inb_alp(ialert_id) + 1
385               ENDIF
386            ENDIF
387         END_2D
388      END DO
389
390      ! Alert if very low salinity
391      ialert_id = ialert_id + 1 ! reference number of this alert
392      cl_alname(ialert_id) = ' Very low salinity ' ! name of the alert
393      DO jl = 1, jpl
394         DO_2D( 1, 1, 1, 1 )
395            IF( v_i(ji,jj,jl) > epsi10  ) THEN
396               IF( sv_i(ji,jj,jl) / v_i(ji,jj,jl) < rn_simin ) THEN
397                  WRITE(numout,*) ' ALERTE :   Very low salinity ',sv_i(ji,jj,jl),v_i(ji,jj,jl)
398                  WRITE(numout,*) ' at i,j,l = ',ji,jj,jl
399                  inb_alp(ialert_id) = inb_alp(ialert_id) + 1
400               ENDIF
401            ENDIF
402         END_2D
403      END DO
404
405      ! Alert if very cold ice
406      ialert_id = ialert_id + 1 ! reference number of this alert
407      cl_alname(ialert_id) = ' Very cold ice ' ! name of the alert
408      DO jl = 1, jpl
409         DO_3D( 1, 1, 1, 1, 1, nlay_i )
410            ztmelts    =  -rTmlt * sz_i(ji,jj,jk,jl) + rt0
411            IF( t_i(ji,jj,jk,jl) < -50.+rt0  .AND.  v_i(ji,jj,jl) > epsi10 ) THEN
412               WRITE(numout,*) ' ALERTE :   Very cold ice ',(t_i(ji,jj,jk,jl)-rt0)
413               WRITE(numout,*) ' at i,j,k,l = ',ji,jj,jk,jl
414              inb_alp(ialert_id) = inb_alp(ialert_id) + 1
415            ENDIF
416         END_3D
417      END DO
418 
419      ! Alert if very warm ice
420      ialert_id = ialert_id + 1 ! reference number of this alert
421      cl_alname(ialert_id) = ' Very warm ice ' ! name of the alert
422      DO jl = 1, jpl
423         DO_3D( 1, 1, 1, 1, 1, nlay_i )
424            ztmelts    =  -rTmlt * sz_i(ji,jj,jk,jl) + rt0
425            IF( t_i(ji,jj,jk,jl) > ztmelts  .AND.  v_i(ji,jj,jl) > epsi10 ) THEN
426               WRITE(numout,*) ' ALERTE :   Very warm ice',(t_i(ji,jj,jk,jl)-rt0)
427               WRITE(numout,*) ' at i,j,k,l = ',ji,jj,jk,jl
428              inb_alp(ialert_id) = inb_alp(ialert_id) + 1
429            ENDIF
430         END_3D
431      END DO
432     
433      ! Alerte if very thick ice
434      ialert_id = ialert_id + 1 ! reference number of this alert
435      cl_alname(ialert_id) = ' Very thick ice ' ! name of the alert
436      jl = jpl 
437      DO_2D( 1, 1, 1, 1 )
438         IF( h_i(ji,jj,jl) > 50._wp ) THEN
439            WRITE(numout,*) ' ALERTE :   Very thick ice ',h_i(ji,jj,jl)
440            WRITE(numout,*) ' at i,j,l = ',ji,jj,jl
441            inb_alp(ialert_id) = inb_alp(ialert_id) + 1
442         ENDIF
443      END_2D
444
445      ! Alerte if very thin ice
446      ialert_id = ialert_id + 1 ! reference number of this alert
447      cl_alname(ialert_id) = ' Very thin ice ' ! name of the alert
448      jl = 1 
449      DO_2D( 1, 1, 1, 1 )
450         IF( h_i(ji,jj,jl) < rn_himin ) THEN
451            WRITE(numout,*) ' ALERTE :   Very thin ice ',h_i(ji,jj,jl)
452            WRITE(numout,*) ' at i,j,l = ',ji,jj,jl
453            inb_alp(ialert_id) = inb_alp(ialert_id) + 1
454         ENDIF
455      END_2D
456
457      ! Alert if very fast ice
458      ialert_id = ialert_id + 1 ! reference number of this alert
459      cl_alname(ialert_id) = ' Very fast ice ' ! name of the alert
460      DO_2D( 1, 1, 1, 1 )
461         IF( MAX( ABS( u_ice(ji,jj) ), ABS( v_ice(ji,jj) ) ) > 2. ) THEN
462            WRITE(numout,*) ' ALERTE :   Very fast ice ',MAX( ABS( u_ice(ji,jj) ), ABS( v_ice(ji,jj) ) )
463            WRITE(numout,*) ' at i,j = ',ji,jj
464            inb_alp(ialert_id) = inb_alp(ialert_id) + 1
465         ENDIF
466      END_2D
467
468      ! Alert if there is ice on continents
469      ialert_id = ialert_id + 1 ! reference number of this alert
470      cl_alname(ialert_id) = ' Ice on continents ' ! name of the alert
471      DO_2D( 1, 1, 1, 1 )
472         IF( tmask(ji,jj,1) == 0._wp .AND. ( at_i(ji,jj) > 0._wp .OR. vt_i(ji,jj) > 0._wp ) ) THEN
473            WRITE(numout,*) ' ALERTE :   Ice on continents ',at_i(ji,jj),vt_i(ji,jj)
474            WRITE(numout,*) ' at i,j = ',ji,jj
475            inb_alp(ialert_id) = inb_alp(ialert_id) + 1
476         ENDIF
477      END_2D
478
479      ! Alert if incompatible ice concentration and volume
480      ialert_id = ialert_id + 1 ! reference number of this alert
481      cl_alname(ialert_id) = ' Incompatible ice conc and vol ' ! name of the alert
482      DO_2D( 1, 1, 1, 1 )
483         IF(  ( vt_i(ji,jj) == 0._wp .AND. at_i(ji,jj) >  0._wp ) .OR. &
484            & ( vt_i(ji,jj) >  0._wp .AND. at_i(ji,jj) == 0._wp ) ) THEN
485            WRITE(numout,*) ' ALERTE :   Incompatible ice conc and vol ',at_i(ji,jj),vt_i(ji,jj)
486            WRITE(numout,*) ' at i,j = ',ji,jj
487            inb_alp(ialert_id) = inb_alp(ialert_id) + 1
488         ENDIF
489      END_2D
490
491      ! sum of the alerts on all processors
492      IF( lk_mpp ) THEN
493         DO ja = 1, ialert_id
494            CALL mpp_sum('icectl', inb_alp(ja))
495         END DO
496      ENDIF
497
498      ! print alerts
499      IF( lwp ) THEN
500         WRITE(numout,*) ' time step ',kt
501         WRITE(numout,*) ' All alerts at the end of ice model '
502         DO ja = 1, ialert_id
503            WRITE(numout,*) ja, cl_alname(ja)//' : ', inb_alp(ja), ' times ! '
504         END DO
505      ENDIF
506     !
507   END SUBROUTINE ice_ctl
508 
509   SUBROUTINE ice_prt( kt, ki, kj, kn, cd1 )
510      !!-------------------------------------------------------------------
511      !!                   ***  ROUTINE ice_prt ***
512      !!                 
513      !! ** Purpose :   Writes global ice state on the (i,j) point
514      !!                in ocean.ouput
515      !!                3 possibilities exist
516      !!                n = 1/-1 -> simple ice state
517      !!                n = 2    -> exhaustive state
518      !!                n = 3    -> ice/ocean salt fluxes
519      !!
520      !! ** input   :   point coordinates (i,j)
521      !!                n : number of the option
522      !!-------------------------------------------------------------------
523      INTEGER         , INTENT(in) ::   kt            ! ocean time step
524      INTEGER         , INTENT(in) ::   ki, kj, kn    ! ocean gridpoint indices
525      CHARACTER(len=*), INTENT(in) ::   cd1           !
526      !!
527      INTEGER :: jl, ji, jj
528      !!-------------------------------------------------------------------
529
530      DO ji = mi0(ki), mi1(ki)
531         DO jj = mj0(kj), mj1(kj)
532
533            WRITE(numout,*) ' time step ',kt,' ',cd1             ! print title
534
535            !----------------
536            !  Simple state
537            !----------------
538           
539            IF ( kn == 1 .OR. kn == -1 ) THEN
540               WRITE(numout,*) ' ice_prt - Point : ',ji,jj
541               WRITE(numout,*) ' ~~~~~~~~~~~~~~ '
542               WRITE(numout,*) ' Simple state '
543               WRITE(numout,*) ' masks s,u,v   : ', tmask(ji,jj,1), umask(ji,jj,1), vmask(ji,jj,1)
544               WRITE(numout,*) ' lat - long    : ', gphit(ji,jj), glamt(ji,jj)
545               WRITE(numout,*) ' - Ice drift   '
546               WRITE(numout,*) '   ~~~~~~~~~~~ '
547               WRITE(numout,*) ' u_ice(i-1,j)  : ', u_ice(ji-1,jj)
548               WRITE(numout,*) ' u_ice(i  ,j)  : ', u_ice(ji,jj)
549               WRITE(numout,*) ' v_ice(i  ,j-1): ', v_ice(ji,jj-1)
550               WRITE(numout,*) ' v_ice(i  ,j)  : ', v_ice(ji,jj)
551               WRITE(numout,*) ' strength      : ', strength(ji,jj)
552               WRITE(numout,*) ' - Cell values '
553               WRITE(numout,*) '   ~~~~~~~~~~~ '
554               WRITE(numout,*) ' at_i          : ', at_i(ji,jj)       
555               WRITE(numout,*) ' ato_i         : ', ato_i(ji,jj)       
556               WRITE(numout,*) ' vt_i          : ', vt_i(ji,jj)       
557               WRITE(numout,*) ' vt_s          : ', vt_s(ji,jj)       
558               DO jl = 1, jpl
559                  WRITE(numout,*) ' - Category (', jl,')'
560                  WRITE(numout,*) '   ~~~~~~~~~~~ '
561                  WRITE(numout,*) ' a_i           : ', a_i(ji,jj,jl)
562                  WRITE(numout,*) ' h_i           : ', h_i(ji,jj,jl)
563                  WRITE(numout,*) ' h_s           : ', h_s(ji,jj,jl)
564                  WRITE(numout,*) ' v_i           : ', v_i(ji,jj,jl)
565                  WRITE(numout,*) ' v_s           : ', v_s(ji,jj,jl)
566                  WRITE(numout,*) ' e_s           : ', e_s(ji,jj,1:nlay_s,jl)
567                  WRITE(numout,*) ' e_i           : ', e_i(ji,jj,1:nlay_i,jl)
568                  WRITE(numout,*) ' t_su          : ', t_su(ji,jj,jl)
569                  WRITE(numout,*) ' t_snow        : ', t_s(ji,jj,1:nlay_s,jl)
570                  WRITE(numout,*) ' t_i           : ', t_i(ji,jj,1:nlay_i,jl)
571                  WRITE(numout,*) ' s_i           : ', s_i(ji,jj,jl)
572                  WRITE(numout,*) ' sv_i          : ', sv_i(ji,jj,jl)
573                  WRITE(numout,*)
574               END DO
575            ENDIF
576
577            !--------------------
578            !  Exhaustive state
579            !--------------------
580           
581            IF ( kn .EQ. 2 ) THEN
582               WRITE(numout,*) ' ice_prt - Point : ',ji,jj
583               WRITE(numout,*) ' ~~~~~~~~~~~~~~ '
584               WRITE(numout,*) ' Exhaustive state '
585               WRITE(numout,*) ' lat - long ', gphit(ji,jj), glamt(ji,jj)
586               WRITE(numout,*) 
587               WRITE(numout,*) ' - Cell values '
588               WRITE(numout,*) '   ~~~~~~~~~~~ '
589               WRITE(numout,*) ' at_i          : ', at_i(ji,jj)       
590               WRITE(numout,*) ' vt_i          : ', vt_i(ji,jj)       
591               WRITE(numout,*) ' vt_s          : ', vt_s(ji,jj)       
592               WRITE(numout,*) ' u_ice(i-1,j)  : ', u_ice(ji-1,jj)
593               WRITE(numout,*) ' u_ice(i  ,j)  : ', u_ice(ji,jj)
594               WRITE(numout,*) ' v_ice(i  ,j-1): ', v_ice(ji,jj-1)
595               WRITE(numout,*) ' v_ice(i  ,j)  : ', v_ice(ji,jj)
596               WRITE(numout,*) ' strength      : ', strength(ji,jj)
597               WRITE(numout,*)
598               
599               DO jl = 1, jpl
600                  WRITE(numout,*) ' - Category (',jl,')'
601                  WRITE(numout,*) '   ~~~~~~~~         ' 
602                  WRITE(numout,*) ' h_i        : ', h_i(ji,jj,jl)              , ' h_s        : ', h_s(ji,jj,jl)
603                  WRITE(numout,*) ' t_i        : ', t_i(ji,jj,1:nlay_i,jl)
604                  WRITE(numout,*) ' t_su       : ', t_su(ji,jj,jl)             , ' t_s        : ', t_s(ji,jj,1:nlay_s,jl)
605                  WRITE(numout,*) ' s_i        : ', s_i(ji,jj,jl)              , ' o_i        : ', o_i(ji,jj,jl)
606                  WRITE(numout,*) ' a_i        : ', a_i(ji,jj,jl)              , ' a_i_b      : ', a_i_b(ji,jj,jl)   
607                  WRITE(numout,*) ' v_i        : ', v_i(ji,jj,jl)              , ' v_i_b      : ', v_i_b(ji,jj,jl)   
608                  WRITE(numout,*) ' v_s        : ', v_s(ji,jj,jl)              , ' v_s_b      : ', v_s_b(ji,jj,jl) 
609                  WRITE(numout,*) ' e_i1       : ', e_i(ji,jj,1,jl)            , ' ei1        : ', e_i_b(ji,jj,1,jl) 
610                  WRITE(numout,*) ' e_i2       : ', e_i(ji,jj,2,jl)            , ' ei2_b      : ', e_i_b(ji,jj,2,jl) 
611                  WRITE(numout,*) ' e_snow     : ', e_s(ji,jj,1,jl)            , ' e_snow_b   : ', e_s_b(ji,jj,1,jl) 
612                  WRITE(numout,*) ' sv_i       : ', sv_i(ji,jj,jl)             , ' sv_i_b     : ', sv_i_b(ji,jj,jl)   
613               END DO !jl
614               
615               WRITE(numout,*)
616               WRITE(numout,*) ' - Heat / FW fluxes '
617               WRITE(numout,*) '   ~~~~~~~~~~~~~~~~ '
618               WRITE(numout,*) ' - Heat fluxes in and out the ice ***'
619               WRITE(numout,*) ' qsr_ini       : ', (1._wp-at_i_b(ji,jj)) * qsr(ji,jj) + SUM( a_i_b(ji,jj,:) * qsr_ice(ji,jj,:) )
620               WRITE(numout,*) ' qns_ini       : ', (1._wp-at_i_b(ji,jj)) * qns(ji,jj) + SUM( a_i_b(ji,jj,:) * qns_ice(ji,jj,:) )
621               WRITE(numout,*)
622               WRITE(numout,*) 
623               WRITE(numout,*) ' sst        : ', sst_m(ji,jj) 
624               WRITE(numout,*) ' sss        : ', sss_m(ji,jj) 
625               WRITE(numout,*) 
626               WRITE(numout,*) ' - Stresses '
627               WRITE(numout,*) '   ~~~~~~~~ '
628               WRITE(numout,*) ' utau_ice   : ', utau_ice(ji,jj) 
629               WRITE(numout,*) ' vtau_ice   : ', vtau_ice(ji,jj)
630               WRITE(numout,*) ' utau       : ', utau    (ji,jj) 
631               WRITE(numout,*) ' vtau       : ', vtau    (ji,jj)
632            ENDIF
633           
634            !---------------------
635            ! Salt / heat fluxes
636            !---------------------
637           
638            IF ( kn .EQ. 3 ) THEN
639               WRITE(numout,*) ' ice_prt - Point : ',ji,jj
640               WRITE(numout,*) ' ~~~~~~~~~~~~~~ '
641               WRITE(numout,*) ' - Salt / Heat Fluxes '
642               WRITE(numout,*) '   ~~~~~~~~~~~~~~~~ '
643               WRITE(numout,*) ' lat - long ', gphit(ji,jj), glamt(ji,jj)
644               WRITE(numout,*)
645               WRITE(numout,*) ' - Heat fluxes at bottom interface ***'
646               WRITE(numout,*) ' qsr       : ', qsr(ji,jj)
647               WRITE(numout,*) ' qns       : ', qns(ji,jj)
648               WRITE(numout,*)
649               WRITE(numout,*) ' hfx_mass     : ', hfx_thd(ji,jj) + hfx_dyn(ji,jj) + hfx_snw(ji,jj) + hfx_res(ji,jj)
650               WRITE(numout,*) ' qt_atm_oi    : ', qt_atm_oi(ji,jj)
651               WRITE(numout,*) ' qt_oce_ai    : ', qt_oce_ai(ji,jj)
652               WRITE(numout,*) ' dhc          : ', diag_heat(ji,jj)             
653               WRITE(numout,*)
654               WRITE(numout,*) ' hfx_dyn      : ', hfx_dyn(ji,jj)
655               WRITE(numout,*) ' hfx_thd      : ', hfx_thd(ji,jj)
656               WRITE(numout,*) ' hfx_res      : ', hfx_res(ji,jj)
657               WRITE(numout,*) ' qsb_ice_bot  : ', qsb_ice_bot(ji,jj) 
658               WRITE(numout,*) ' qlead        : ', qlead(ji,jj) * r1_Dt_ice
659               WRITE(numout,*)
660               WRITE(numout,*) ' - Salt fluxes at bottom interface ***'
661               WRITE(numout,*) ' emp       : ', emp    (ji,jj)
662               WRITE(numout,*) ' sfx       : ', sfx    (ji,jj)
663               WRITE(numout,*) ' sfx_res   : ', sfx_res(ji,jj)
664               WRITE(numout,*) ' sfx_bri   : ', sfx_bri(ji,jj)
665               WRITE(numout,*) ' sfx_dyn   : ', sfx_dyn(ji,jj)
666               WRITE(numout,*)
667               WRITE(numout,*) ' - Momentum fluxes '
668               WRITE(numout,*) ' utau      : ', utau(ji,jj) 
669               WRITE(numout,*) ' vtau      : ', vtau(ji,jj)
670            ENDIF
671            WRITE(numout,*) ' '
672            !
673         END DO
674      END DO
675      !
676   END SUBROUTINE ice_prt
677
678   SUBROUTINE ice_prt3D( cd_routine )
679      !!-------------------------------------------------------------------
680      !!                  ***  ROUTINE ice_prt3D ***
681      !!
682      !! ** Purpose : CTL prints of ice arrays in case sn_cfctl%prtctl is activated
683      !!
684      !!-------------------------------------------------------------------
685      CHARACTER(len=*), INTENT(in) ::   cd_routine    ! name of the routine
686      INTEGER                      ::   jk, jl        ! dummy loop indices
687     
688      CALL prt_ctl_info(' ========== ')
689      CALL prt_ctl_info( cd_routine )
690      CALL prt_ctl_info(' ========== ')
691      CALL prt_ctl_info(' - Cell values : ')
692      CALL prt_ctl_info('   ~~~~~~~~~~~~~ ')
693      CALL prt_ctl(tab2d_1=e1e2t      , clinfo1=' cell area   :')
694      CALL prt_ctl(tab2d_1=at_i       , clinfo1=' at_i        :')
695      CALL prt_ctl(tab2d_1=ato_i      , clinfo1=' ato_i       :')
696      CALL prt_ctl(tab2d_1=vt_i       , clinfo1=' vt_i        :')
697      CALL prt_ctl(tab2d_1=vt_s       , clinfo1=' vt_s        :')
698      CALL prt_ctl(tab2d_1=divu_i     , clinfo1=' divu_i      :')
699      CALL prt_ctl(tab2d_1=delta_i    , clinfo1=' delta_i     :')
700      CALL prt_ctl(tab2d_1=stress1_i  , clinfo1=' stress1_i   :')
701      CALL prt_ctl(tab2d_1=stress2_i  , clinfo1=' stress2_i   :')
702      CALL prt_ctl(tab2d_1=stress12_i , clinfo1=' stress12_i  :')
703      CALL prt_ctl(tab2d_1=strength   , clinfo1=' strength    :')
704      CALL prt_ctl(tab2d_1=delta_i    , clinfo1=' delta_i     :')
705      CALL prt_ctl(tab2d_1=u_ice      , clinfo1=' u_ice       :', tab2d_2=v_ice      , clinfo2=' v_ice       :')
706       
707      DO jl = 1, jpl
708         CALL prt_ctl_info(' ')
709         CALL prt_ctl_info(' - Category : ', ivar=jl)
710         CALL prt_ctl_info('   ~~~~~~~~~~')
711         CALL prt_ctl(tab2d_1=h_i        (:,:,jl)        , clinfo1= ' h_i         : ')
712         CALL prt_ctl(tab2d_1=h_s        (:,:,jl)        , clinfo1= ' h_s         : ')
713         CALL prt_ctl(tab2d_1=t_su       (:,:,jl)        , clinfo1= ' t_su        : ')
714         CALL prt_ctl(tab2d_1=t_s        (:,:,1,jl)      , clinfo1= ' t_snow      : ')
715         CALL prt_ctl(tab2d_1=s_i        (:,:,jl)        , clinfo1= ' s_i         : ')
716         CALL prt_ctl(tab2d_1=o_i        (:,:,jl)        , clinfo1= ' o_i         : ')
717         CALL prt_ctl(tab2d_1=a_i        (:,:,jl)        , clinfo1= ' a_i         : ')
718         CALL prt_ctl(tab2d_1=v_i        (:,:,jl)        , clinfo1= ' v_i         : ')
719         CALL prt_ctl(tab2d_1=v_s        (:,:,jl)        , clinfo1= ' v_s         : ')
720         CALL prt_ctl(tab2d_1=e_s        (:,:,1,jl)      , clinfo1= ' e_snow      : ')
721         CALL prt_ctl(tab2d_1=sv_i       (:,:,jl)        , clinfo1= ' sv_i        : ')
722         CALL prt_ctl(tab2d_1=oa_i       (:,:,jl)        , clinfo1= ' oa_i        : ')
723         
724         DO jk = 1, nlay_i
725            CALL prt_ctl_info(' - Layer : ', ivar=jk)
726            CALL prt_ctl(tab2d_1=t_i(:,:,jk,jl) , clinfo1= ' t_i       : ')
727            CALL prt_ctl(tab2d_1=e_i(:,:,jk,jl) , clinfo1= ' e_i       : ')
728         END DO
729      END DO
730     
731      CALL prt_ctl_info(' ')
732      CALL prt_ctl_info(' - Stresses : ')
733      CALL prt_ctl_info('   ~~~~~~~~~~ ')
734      CALL prt_ctl(tab2d_1=utau       , clinfo1= ' utau      : ', tab2d_2=vtau       , clinfo2= ' vtau      : ')
735      CALL prt_ctl(tab2d_1=utau_ice   , clinfo1= ' utau_ice  : ', tab2d_2=vtau_ice   , clinfo2= ' vtau_ice  : ')
736     
737   END SUBROUTINE ice_prt3D
738
739
740   SUBROUTINE ice_drift_wri( kt )
741      !!-------------------------------------------------------------------
742      !!                     ***  ROUTINE ice_drift_wri ***
743      !!
744      !! ** Purpose : conservation of mass, salt and heat
745      !!              write the drift in a ascii file at each time step
746      !!              and the total run drifts
747      !!-------------------------------------------------------------------
748      INTEGER, INTENT(in) ::   kt   ! ice time-step index
749      !
750      INTEGER  ::   ji, jj
751      REAL(wp) ::   zdiag_mass, zdiag_salt, zdiag_heat, zdiag_adv_mass, zdiag_adv_salt, zdiag_adv_heat
752      REAL(wp), DIMENSION(jpi,jpj) ::   zdiag_mass2D, zdiag_salt2D, zdiag_heat2D
753      !!-------------------------------------------------------------------
754      !
755      IF( kt == nit000 .AND. lwp ) THEN
756         WRITE(numout,*)
757         WRITE(numout,*) 'ice_drift_wri: sea-ice drifts'
758         WRITE(numout,*) '~~~~~~~~~~~~~'
759      ENDIF
760      !
761      ! 2D budgets (must be close to 0)
762      IF( iom_use('icedrift_mass') .OR. iom_use('icedrift_salt') .OR. iom_use('icedrift_heat') ) THEN
763         DO_2D( 1, 1, 1, 1 )
764            zdiag_mass2D(ji,jj) =   wfx_ice(ji,jj)   + wfx_snw(ji,jj)   + wfx_spr(ji,jj) + wfx_sub(ji,jj) &
765               &                  + diag_vice(ji,jj) + diag_vsnw(ji,jj) - diag_adv_mass(ji,jj)
766            zdiag_salt2D(ji,jj) = sfx(ji,jj) + diag_sice(ji,jj) - diag_adv_salt(ji,jj)
767            zdiag_heat2D(ji,jj) = qt_oce_ai(ji,jj) - qt_atm_oi(ji,jj) + diag_heat(ji,jj) - diag_adv_heat(ji,jj)
768         END_2D
769         !
770         ! write outputs
771         CALL iom_put( 'icedrift_mass', zdiag_mass2D )
772         CALL iom_put( 'icedrift_salt', zdiag_salt2D )
773         CALL iom_put( 'icedrift_heat', zdiag_heat2D )
774      ENDIF
775
776      ! -- mass diag -- !
777      zdiag_mass     = glob_sum( 'icectl', (  wfx_ice   + wfx_snw   + wfx_spr + wfx_sub &
778         &                                  + diag_vice + diag_vsnw - diag_adv_mass ) * e1e2t ) * rdt_ice
779      zdiag_adv_mass = glob_sum( 'icectl', diag_adv_mass * e1e2t ) * rDt_ice
780
781      ! -- salt diag -- !
782      zdiag_salt     = glob_sum( 'icectl', ( sfx + diag_sice - diag_adv_salt ) * e1e2t ) * rdt_ice * 1.e-3
783      zdiag_adv_salt = glob_sum( 'icectl', diag_adv_salt * e1e2t ) * rDt_ice * 1.e-3
784
785      ! -- heat diag -- !
786      zdiag_heat     = glob_sum( 'icectl', ( qt_oce_ai - qt_atm_oi + diag_heat - diag_adv_heat ) * e1e2t )
787      zdiag_adv_heat = glob_sum( 'icectl', diag_adv_heat * e1e2t )
788
789      !                    ! write out to file
790      IF( lwp ) THEN
791         ! check global drift (must be close to 0)
792         WRITE(numicedrift,FMT='(2x,i6,3x,a19,4x,f25.5)') kt, 'mass drift     [kg]', zdiag_mass
793         WRITE(numicedrift,FMT='(11x,     a19,4x,f25.5)')     'salt drift     [kg]', zdiag_salt
794         WRITE(numicedrift,FMT='(11x,     a19,4x,f25.5)')     'heat drift     [W] ', zdiag_heat
795         ! check drift from advection scheme (can be /=0 with bdy but not sure why)
796         WRITE(numicedrift,FMT='(11x,     a19,4x,f25.5)')     'mass drift adv [kg]', zdiag_adv_mass
797         WRITE(numicedrift,FMT='(11x,     a19,4x,f25.5)')     'salt drift adv [kg]', zdiag_adv_salt
798         WRITE(numicedrift,FMT='(11x,     a19,4x,f25.5)')     'heat drift adv [W] ', zdiag_adv_heat
799      ENDIF
800      !                    ! drifts
801      rdiag_icemass = rdiag_icemass + zdiag_mass
802      rdiag_icesalt = rdiag_icesalt + zdiag_salt
803      rdiag_iceheat = rdiag_iceheat + zdiag_heat
804      rdiag_adv_icemass = rdiag_adv_icemass + zdiag_adv_mass
805      rdiag_adv_icesalt = rdiag_adv_icesalt + zdiag_adv_salt
806      rdiag_adv_iceheat = rdiag_adv_iceheat + zdiag_adv_heat
807      !
808      !                    ! output drifts and close ascii file
809      IF( kt == nitend - nn_fsbc + 1 .AND. lwp ) THEN
810         ! to ascii file
811         WRITE(numicedrift,*) '******************************************'
812         WRITE(numicedrift,FMT='(3x,a23,6x,E10.2)') 'Run mass drift     [kg]', rdiag_icemass
813         WRITE(numicedrift,FMT='(3x,a23,6x,E10.2)') 'Run mass drift adv [kg]', rdiag_adv_icemass
814         WRITE(numicedrift,*) '******************************************'
815         WRITE(numicedrift,FMT='(3x,a23,6x,E10.2)') 'Run salt drift     [kg]', rdiag_icesalt
816         WRITE(numicedrift,FMT='(3x,a23,6x,E10.2)') 'Run salt drift adv [kg]', rdiag_adv_icesalt
817         WRITE(numicedrift,*) '******************************************'
818         WRITE(numicedrift,FMT='(3x,a23,6x,E10.2)') 'Run heat drift     [W] ', rdiag_iceheat
819         WRITE(numicedrift,FMT='(3x,a23,6x,E10.2)') 'Run heat drift adv [W] ', rdiag_adv_iceheat
820         CLOSE( numicedrift )
821         !
822         ! to ocean output
823         WRITE(numout,*)
824         WRITE(numout,*) 'ice_drift_wri: ice drifts information for the run '
825         WRITE(numout,*) '~~~~~~~~~~~~~'
826         ! check global drift (must be close to 0)
827         WRITE(numout,*) '   sea-ice mass drift     [kg] = ', rdiag_icemass
828         WRITE(numout,*) '   sea-ice salt drift     [kg] = ', rdiag_icesalt
829         WRITE(numout,*) '   sea-ice heat drift     [W]  = ', rdiag_iceheat
830         ! check drift from advection scheme (can be /=0 with bdy but not sure why)
831         WRITE(numout,*) '   sea-ice mass drift adv [kg] = ', rdiag_adv_icemass
832         WRITE(numout,*) '   sea-ice salt drift adv [kg] = ', rdiag_adv_icesalt
833         WRITE(numout,*) '   sea-ice heat drift adv [W]  = ', rdiag_adv_iceheat
834      ENDIF
835      !
836   END SUBROUTINE ice_drift_wri
837
838   SUBROUTINE ice_drift_init
839      !!----------------------------------------------------------------------
840      !!                  ***  ROUTINE ice_drift_init  ***
841      !!                   
842      !! ** Purpose :   create output file, initialise arrays
843      !!----------------------------------------------------------------------
844      !
845      IF( .NOT.ln_icediachk ) RETURN ! exit
846      !
847      IF(lwp) THEN
848         WRITE(numout,*)
849         WRITE(numout,*) 'ice_drift_init: Output ice drifts to ',TRIM(clname), ' file'
850         WRITE(numout,*) '~~~~~~~~~~~~~'
851         WRITE(numout,*)
852         !
853         ! create output ascii file
854         CALL ctl_opn( numicedrift, clname, 'UNKNOWN', 'FORMATTED', 'SEQUENTIAL', 1, numout, lwp, narea )
855         WRITE(numicedrift,*) 'Timestep  Drifts'
856         WRITE(numicedrift,*) '******************************************'
857      ENDIF
858      !
859      rdiag_icemass = 0._wp
860      rdiag_icesalt = 0._wp
861      rdiag_iceheat = 0._wp
862      rdiag_adv_icemass = 0._wp
863      rdiag_adv_icesalt = 0._wp
864      rdiag_adv_iceheat = 0._wp
865      !
866   END SUBROUTINE ice_drift_init
867     
868#else
869   !!----------------------------------------------------------------------
870   !!   Default option         Empty Module           No SI3 sea-ice model
871   !!----------------------------------------------------------------------
872#endif
873
874   !!======================================================================
875END MODULE icectl
Note: See TracBrowser for help on using the repository browser.