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/2019/dev_r11842_SI3-10_EAP/src/ICE – NEMO

source: NEMO/branches/2019/dev_r11842_SI3-10_EAP/src/ICE/icectl.F90 @ 13662

Last change on this file since 13662 was 13662, checked in by clem, 4 years ago

update to almost r4.0.4

  • Property svn:keywords set to Id
File size: 46.3 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 "vectopt_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_rdtice       &
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_rdtice  &
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_rdtice                                                                                           &
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_rdtice                             &
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_rdtice                                                  &
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_rdtice &
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 )
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 jj = 1, jpj
380            DO ji = 1, jpi
381               IF( v_i(ji,jj,jl) > epsi10  ) THEN
382                  IF( sv_i(ji,jj,jl) / v_i(ji,jj,jl) > rn_simax ) THEN
383                     WRITE(numout,*) ' ALERTE :   Very high salinity ',sv_i(ji,jj,jl)/v_i(ji,jj,jl)
384                     WRITE(numout,*) ' at i,j,l = ',ji,jj,jl
385                     inb_alp(ialert_id) = inb_alp(ialert_id) + 1
386                  ENDIF
387               ENDIF
388            END DO
389         END DO
390      END DO
391
392      ! Alert if very low salinity
393      ialert_id = ialert_id + 1 ! reference number of this alert
394      cl_alname(ialert_id) = ' Very low salinity ' ! name of the alert
395      DO jl = 1, jpl
396         DO jj = 1, jpj
397            DO ji = 1, jpi
398               IF( v_i(ji,jj,jl) > epsi10  ) THEN
399                  IF( sv_i(ji,jj,jl) / v_i(ji,jj,jl) < rn_simin ) THEN
400                     WRITE(numout,*) ' ALERTE :   Very low salinity ',sv_i(ji,jj,jl),v_i(ji,jj,jl)
401                     WRITE(numout,*) ' at i,j,l = ',ji,jj,jl
402                     inb_alp(ialert_id) = inb_alp(ialert_id) + 1
403                  ENDIF
404               ENDIF
405            END DO
406         END DO
407      END DO
408
409      ! Alert if very cold ice
410      ialert_id = ialert_id + 1 ! reference number of this alert
411      cl_alname(ialert_id) = ' Very cold ice ' ! name of the alert
412      DO jl = 1, jpl
413         DO jk = 1, nlay_i
414            DO jj = 1, jpj
415               DO ji = 1, jpi
416                  ztmelts    =  -rTmlt * sz_i(ji,jj,jk,jl) + rt0
417                  IF( t_i(ji,jj,jk,jl) < -50.+rt0  .AND.  v_i(ji,jj,jl) > epsi10 ) THEN
418                     WRITE(numout,*) ' ALERTE :   Very cold ice ',(t_i(ji,jj,jk,jl)-rt0)
419                     WRITE(numout,*) ' at i,j,k,l = ',ji,jj,jk,jl
420                    inb_alp(ialert_id) = inb_alp(ialert_id) + 1
421                  ENDIF
422               END DO
423            END DO
424         END DO
425      END DO
426 
427      ! Alert if very warm ice
428      ialert_id = ialert_id + 1 ! reference number of this alert
429      cl_alname(ialert_id) = ' Very warm ice ' ! name of the alert
430      DO jl = 1, jpl
431         DO jk = 1, nlay_i
432            DO jj = 1, jpj
433               DO ji = 1, jpi
434                  ztmelts    =  -rTmlt * sz_i(ji,jj,jk,jl) + rt0
435                  IF( t_i(ji,jj,jk,jl) > ztmelts  .AND.  v_i(ji,jj,jl) > epsi10 ) THEN
436                     WRITE(numout,*) ' ALERTE :   Very warm ice',(t_i(ji,jj,jk,jl)-rt0)
437                     WRITE(numout,*) ' at i,j,k,l = ',ji,jj,jk,jl
438                    inb_alp(ialert_id) = inb_alp(ialert_id) + 1
439                  ENDIF
440               END DO
441            END DO
442         END DO
443      END DO
444     
445      ! Alerte if very thick ice
446      ialert_id = ialert_id + 1 ! reference number of this alert
447      cl_alname(ialert_id) = ' Very thick ice ' ! name of the alert
448      jl = jpl 
449      DO jj = 1, jpj
450         DO ji = 1, jpi
451            IF( h_i(ji,jj,jl) > 50._wp ) THEN
452               WRITE(numout,*) ' ALERTE :   Very thick ice ',h_i(ji,jj,jl)
453               WRITE(numout,*) ' at i,j,l = ',ji,jj,jl
454               inb_alp(ialert_id) = inb_alp(ialert_id) + 1
455            ENDIF
456         END DO
457      END DO
458
459      ! Alerte if very thin ice
460      ialert_id = ialert_id + 1 ! reference number of this alert
461      cl_alname(ialert_id) = ' Very thin ice ' ! name of the alert
462      jl = 1 
463      DO jj = 1, jpj
464         DO ji = 1, jpi
465            IF( h_i(ji,jj,jl) < rn_himin ) THEN
466               WRITE(numout,*) ' ALERTE :   Very thin ice ',h_i(ji,jj,jl)
467               WRITE(numout,*) ' at i,j,l = ',ji,jj,jl
468               inb_alp(ialert_id) = inb_alp(ialert_id) + 1
469            ENDIF
470         END DO
471      END DO
472
473      ! Alert if very fast ice
474      ialert_id = ialert_id + 1 ! reference number of this alert
475      cl_alname(ialert_id) = ' Very fast ice ' ! name of the alert
476      DO jj = 1, jpj
477         DO ji = 1, jpi
478            IF( MAX( ABS( u_ice(ji,jj) ), ABS( v_ice(ji,jj) ) ) > 2. ) THEN
479               WRITE(numout,*) ' ALERTE :   Very fast ice ',MAX( ABS( u_ice(ji,jj) ), ABS( v_ice(ji,jj) ) )
480               WRITE(numout,*) ' at i,j = ',ji,jj
481               inb_alp(ialert_id) = inb_alp(ialert_id) + 1
482            ENDIF
483         END DO
484      END DO
485
486      ! Alert if there is ice on continents
487      ialert_id = ialert_id + 1 ! reference number of this alert
488      cl_alname(ialert_id) = ' Ice on continents ' ! name of the alert
489      DO jj = 1, jpj
490         DO ji = 1, jpi
491            IF( tmask(ji,jj,1) == 0._wp .AND. ( at_i(ji,jj) > 0._wp .OR. vt_i(ji,jj) > 0._wp ) ) THEN
492               WRITE(numout,*) ' ALERTE :   Ice on continents ',at_i(ji,jj),vt_i(ji,jj)
493               WRITE(numout,*) ' at i,j = ',ji,jj
494               inb_alp(ialert_id) = inb_alp(ialert_id) + 1
495            ENDIF
496         END DO
497      END DO
498
499      ! Alert if incompatible ice concentration and volume
500      ialert_id = ialert_id + 1 ! reference number of this alert
501      cl_alname(ialert_id) = ' Incompatible ice conc and vol ' ! name of the alert
502      DO jj = 1, jpj
503         DO ji = 1, jpi
504            IF(  ( vt_i(ji,jj) == 0._wp .AND. at_i(ji,jj) >  0._wp ) .OR. &
505               & ( vt_i(ji,jj) >  0._wp .AND. at_i(ji,jj) == 0._wp ) ) THEN
506               WRITE(numout,*) ' ALERTE :   Incompatible ice conc and vol ',at_i(ji,jj),vt_i(ji,jj)
507               WRITE(numout,*) ' at i,j = ',ji,jj
508               inb_alp(ialert_id) = inb_alp(ialert_id) + 1
509            ENDIF
510         END DO
511      END DO
512
513      ! sum of the alerts on all processors
514      IF( lk_mpp ) THEN
515         DO ja = 1, ialert_id
516            CALL mpp_sum('icectl', inb_alp(ja))
517         END DO
518      ENDIF
519
520      ! print alerts
521      IF( lwp ) THEN
522         WRITE(numout,*) ' time step ',kt
523         WRITE(numout,*) ' All alerts at the end of ice model '
524         DO ja = 1, ialert_id
525            WRITE(numout,*) ja, cl_alname(ja)//' : ', inb_alp(ja), ' times ! '
526         END DO
527      ENDIF
528     !
529   END SUBROUTINE ice_ctl
530 
531   SUBROUTINE ice_prt( kt, ki, kj, kn, cd1 )
532      !!-------------------------------------------------------------------
533      !!                   ***  ROUTINE ice_prt ***
534      !!                 
535      !! ** Purpose :   Writes global ice state on the (i,j) point
536      !!                in ocean.ouput
537      !!                3 possibilities exist
538      !!                n = 1/-1 -> simple ice state
539      !!                n = 2    -> exhaustive state
540      !!                n = 3    -> ice/ocean salt fluxes
541      !!
542      !! ** input   :   point coordinates (i,j)
543      !!                n : number of the option
544      !!-------------------------------------------------------------------
545      INTEGER         , INTENT(in) ::   kt            ! ocean time step
546      INTEGER         , INTENT(in) ::   ki, kj, kn    ! ocean gridpoint indices
547      CHARACTER(len=*), INTENT(in) ::   cd1           !
548      !!
549      INTEGER :: jl, ji, jj
550      !!-------------------------------------------------------------------
551
552      DO ji = mi0(ki), mi1(ki)
553         DO jj = mj0(kj), mj1(kj)
554
555            WRITE(numout,*) ' time step ',kt,' ',cd1             ! print title
556
557            !----------------
558            !  Simple state
559            !----------------
560           
561            IF ( kn == 1 .OR. kn == -1 ) THEN
562               WRITE(numout,*) ' ice_prt - Point : ',ji,jj
563               WRITE(numout,*) ' ~~~~~~~~~~~~~~ '
564               WRITE(numout,*) ' Simple state '
565               WRITE(numout,*) ' masks s,u,v   : ', tmask(ji,jj,1), umask(ji,jj,1), vmask(ji,jj,1)
566               WRITE(numout,*) ' lat - long    : ', gphit(ji,jj), glamt(ji,jj)
567               WRITE(numout,*) ' - Ice drift   '
568               WRITE(numout,*) '   ~~~~~~~~~~~ '
569               WRITE(numout,*) ' u_ice(i-1,j)  : ', u_ice(ji-1,jj)
570               WRITE(numout,*) ' u_ice(i  ,j)  : ', u_ice(ji,jj)
571               WRITE(numout,*) ' v_ice(i  ,j-1): ', v_ice(ji,jj-1)
572               WRITE(numout,*) ' v_ice(i  ,j)  : ', v_ice(ji,jj)
573               WRITE(numout,*) ' strength      : ', strength(ji,jj)
574               WRITE(numout,*) ' - Cell values '
575               WRITE(numout,*) '   ~~~~~~~~~~~ '
576               WRITE(numout,*) ' at_i          : ', at_i(ji,jj)       
577               WRITE(numout,*) ' ato_i         : ', ato_i(ji,jj)       
578               WRITE(numout,*) ' vt_i          : ', vt_i(ji,jj)       
579               WRITE(numout,*) ' vt_s          : ', vt_s(ji,jj)       
580               DO jl = 1, jpl
581                  WRITE(numout,*) ' - Category (', jl,')'
582                  WRITE(numout,*) '   ~~~~~~~~~~~ '
583                  WRITE(numout,*) ' a_i           : ', a_i(ji,jj,jl)
584                  WRITE(numout,*) ' h_i           : ', h_i(ji,jj,jl)
585                  WRITE(numout,*) ' h_s           : ', h_s(ji,jj,jl)
586                  WRITE(numout,*) ' v_i           : ', v_i(ji,jj,jl)
587                  WRITE(numout,*) ' v_s           : ', v_s(ji,jj,jl)
588                  WRITE(numout,*) ' e_s           : ', e_s(ji,jj,1:nlay_s,jl)
589                  WRITE(numout,*) ' e_i           : ', e_i(ji,jj,1:nlay_i,jl)
590                  WRITE(numout,*) ' t_su          : ', t_su(ji,jj,jl)
591                  WRITE(numout,*) ' t_snow        : ', t_s(ji,jj,1:nlay_s,jl)
592                  WRITE(numout,*) ' t_i           : ', t_i(ji,jj,1:nlay_i,jl)
593                  WRITE(numout,*) ' s_i           : ', s_i(ji,jj,jl)
594                  WRITE(numout,*) ' sv_i          : ', sv_i(ji,jj,jl)
595                  WRITE(numout,*)
596               END DO
597            ENDIF
598
599            !--------------------
600            !  Exhaustive state
601            !--------------------
602           
603            IF ( kn .EQ. 2 ) THEN
604               WRITE(numout,*) ' ice_prt - Point : ',ji,jj
605               WRITE(numout,*) ' ~~~~~~~~~~~~~~ '
606               WRITE(numout,*) ' Exhaustive state '
607               WRITE(numout,*) ' lat - long ', gphit(ji,jj), glamt(ji,jj)
608               WRITE(numout,*) 
609               WRITE(numout,*) ' - Cell values '
610               WRITE(numout,*) '   ~~~~~~~~~~~ '
611               WRITE(numout,*) ' at_i          : ', at_i(ji,jj)       
612               WRITE(numout,*) ' vt_i          : ', vt_i(ji,jj)       
613               WRITE(numout,*) ' vt_s          : ', vt_s(ji,jj)       
614               WRITE(numout,*) ' u_ice(i-1,j)  : ', u_ice(ji-1,jj)
615               WRITE(numout,*) ' u_ice(i  ,j)  : ', u_ice(ji,jj)
616               WRITE(numout,*) ' v_ice(i  ,j-1): ', v_ice(ji,jj-1)
617               WRITE(numout,*) ' v_ice(i  ,j)  : ', v_ice(ji,jj)
618               WRITE(numout,*) ' strength      : ', strength(ji,jj)
619               WRITE(numout,*)
620               
621               DO jl = 1, jpl
622                  WRITE(numout,*) ' - Category (',jl,')'
623                  WRITE(numout,*) '   ~~~~~~~~         ' 
624                  WRITE(numout,*) ' h_i        : ', h_i(ji,jj,jl)              , ' h_s        : ', h_s(ji,jj,jl)
625                  WRITE(numout,*) ' t_i        : ', t_i(ji,jj,1:nlay_i,jl)
626                  WRITE(numout,*) ' t_su       : ', t_su(ji,jj,jl)             , ' t_s        : ', t_s(ji,jj,1:nlay_s,jl)
627                  WRITE(numout,*) ' s_i        : ', s_i(ji,jj,jl)              , ' o_i        : ', o_i(ji,jj,jl)
628                  WRITE(numout,*) ' a_i        : ', a_i(ji,jj,jl)              , ' a_i_b      : ', a_i_b(ji,jj,jl)   
629                  WRITE(numout,*) ' v_i        : ', v_i(ji,jj,jl)              , ' v_i_b      : ', v_i_b(ji,jj,jl)   
630                  WRITE(numout,*) ' v_s        : ', v_s(ji,jj,jl)              , ' v_s_b      : ', v_s_b(ji,jj,jl) 
631                  WRITE(numout,*) ' e_i1       : ', e_i(ji,jj,1,jl)            , ' ei1        : ', e_i_b(ji,jj,1,jl) 
632                  WRITE(numout,*) ' e_i2       : ', e_i(ji,jj,2,jl)            , ' ei2_b      : ', e_i_b(ji,jj,2,jl) 
633                  WRITE(numout,*) ' e_snow     : ', e_s(ji,jj,1,jl)            , ' e_snow_b   : ', e_s_b(ji,jj,1,jl) 
634                  WRITE(numout,*) ' sv_i       : ', sv_i(ji,jj,jl)             , ' sv_i_b     : ', sv_i_b(ji,jj,jl)   
635               END DO !jl
636               
637               WRITE(numout,*)
638               WRITE(numout,*) ' - Heat / FW fluxes '
639               WRITE(numout,*) '   ~~~~~~~~~~~~~~~~ '
640               WRITE(numout,*) ' - Heat fluxes in and out the ice ***'
641               WRITE(numout,*) ' qsr_ini       : ', (1._wp-at_i_b(ji,jj)) * qsr(ji,jj) + SUM( a_i_b(ji,jj,:) * qsr_ice(ji,jj,:) )
642               WRITE(numout,*) ' qns_ini       : ', (1._wp-at_i_b(ji,jj)) * qns(ji,jj) + SUM( a_i_b(ji,jj,:) * qns_ice(ji,jj,:) )
643               WRITE(numout,*)
644               WRITE(numout,*) 
645               WRITE(numout,*) ' sst        : ', sst_m(ji,jj) 
646               WRITE(numout,*) ' sss        : ', sss_m(ji,jj) 
647               WRITE(numout,*) 
648               WRITE(numout,*) ' - Stresses '
649               WRITE(numout,*) '   ~~~~~~~~ '
650               WRITE(numout,*) ' utau_ice   : ', utau_ice(ji,jj) 
651               WRITE(numout,*) ' vtau_ice   : ', vtau_ice(ji,jj)
652               WRITE(numout,*) ' utau       : ', utau    (ji,jj) 
653               WRITE(numout,*) ' vtau       : ', vtau    (ji,jj)
654            ENDIF
655           
656            !---------------------
657            ! Salt / heat fluxes
658            !---------------------
659           
660            IF ( kn .EQ. 3 ) THEN
661               WRITE(numout,*) ' ice_prt - Point : ',ji,jj
662               WRITE(numout,*) ' ~~~~~~~~~~~~~~ '
663               WRITE(numout,*) ' - Salt / Heat Fluxes '
664               WRITE(numout,*) '   ~~~~~~~~~~~~~~~~ '
665               WRITE(numout,*) ' lat - long ', gphit(ji,jj), glamt(ji,jj)
666               WRITE(numout,*)
667               WRITE(numout,*) ' - Heat fluxes at bottom interface ***'
668               WRITE(numout,*) ' qsr       : ', qsr(ji,jj)
669               WRITE(numout,*) ' qns       : ', qns(ji,jj)
670               WRITE(numout,*)
671               WRITE(numout,*) ' hfx_mass     : ', hfx_thd(ji,jj) + hfx_dyn(ji,jj) + hfx_snw(ji,jj) + hfx_res(ji,jj)
672               WRITE(numout,*) ' qt_atm_oi    : ', qt_atm_oi(ji,jj)
673               WRITE(numout,*) ' qt_oce_ai    : ', qt_oce_ai(ji,jj)
674               WRITE(numout,*) ' dhc          : ', diag_heat(ji,jj)             
675               WRITE(numout,*)
676               WRITE(numout,*) ' hfx_dyn      : ', hfx_dyn(ji,jj)
677               WRITE(numout,*) ' hfx_thd      : ', hfx_thd(ji,jj)
678               WRITE(numout,*) ' hfx_res      : ', hfx_res(ji,jj)
679               WRITE(numout,*) ' qsb_ice_bot  : ', qsb_ice_bot(ji,jj) 
680               WRITE(numout,*) ' qlead        : ', qlead(ji,jj) * r1_rdtice
681               WRITE(numout,*)
682               WRITE(numout,*) ' - Salt fluxes at bottom interface ***'
683               WRITE(numout,*) ' emp       : ', emp    (ji,jj)
684               WRITE(numout,*) ' sfx       : ', sfx    (ji,jj)
685               WRITE(numout,*) ' sfx_res   : ', sfx_res(ji,jj)
686               WRITE(numout,*) ' sfx_bri   : ', sfx_bri(ji,jj)
687               WRITE(numout,*) ' sfx_dyn   : ', sfx_dyn(ji,jj)
688               WRITE(numout,*)
689               WRITE(numout,*) ' - Momentum fluxes '
690               WRITE(numout,*) ' utau      : ', utau(ji,jj) 
691               WRITE(numout,*) ' vtau      : ', vtau(ji,jj)
692            ENDIF
693            WRITE(numout,*) ' '
694            !
695         END DO
696      END DO
697      !
698   END SUBROUTINE ice_prt
699
700   SUBROUTINE ice_prt3D( cd_routine )
701      !!-------------------------------------------------------------------
702      !!                  ***  ROUTINE ice_prt3D ***
703      !!
704      !! ** Purpose : CTL prints of ice arrays in case ln_ctl is activated
705      !!
706      !!-------------------------------------------------------------------
707      CHARACTER(len=*), INTENT(in) ::   cd_routine    ! name of the routine
708      INTEGER                      ::   jk, jl        ! dummy loop indices
709     
710      CALL prt_ctl_info(' ========== ')
711      CALL prt_ctl_info( cd_routine )
712      CALL prt_ctl_info(' ========== ')
713      CALL prt_ctl_info(' - Cell values : ')
714      CALL prt_ctl_info('   ~~~~~~~~~~~~~ ')
715      CALL prt_ctl(tab2d_1=e1e2t      , clinfo1=' cell area   :')
716      CALL prt_ctl(tab2d_1=at_i       , clinfo1=' at_i        :')
717      CALL prt_ctl(tab2d_1=ato_i      , clinfo1=' ato_i       :')
718      CALL prt_ctl(tab2d_1=vt_i       , clinfo1=' vt_i        :')
719      CALL prt_ctl(tab2d_1=vt_s       , clinfo1=' vt_s        :')
720      CALL prt_ctl(tab2d_1=divu_i     , clinfo1=' divu_i      :')
721      CALL prt_ctl(tab2d_1=delta_i    , clinfo1=' delta_i     :')
722      CALL prt_ctl(tab2d_1=stress1_i  , clinfo1=' stress1_i   :')
723      CALL prt_ctl(tab2d_1=stress2_i  , clinfo1=' stress2_i   :')
724      CALL prt_ctl(tab2d_1=stress12_i , clinfo1=' stress12_i  :')
725      CALL prt_ctl(tab2d_1=strength   , clinfo1=' strength    :')
726      CALL prt_ctl(tab2d_1=delta_i    , clinfo1=' delta_i     :')
727      CALL prt_ctl(tab2d_1=u_ice      , clinfo1=' u_ice       :', tab2d_2=v_ice      , clinfo2=' v_ice       :')
728       
729      DO jl = 1, jpl
730         CALL prt_ctl_info(' ')
731         CALL prt_ctl_info(' - Category : ', ivar1=jl)
732         CALL prt_ctl_info('   ~~~~~~~~~~')
733         CALL prt_ctl(tab2d_1=h_i        (:,:,jl)        , clinfo1= ' h_i         : ')
734         CALL prt_ctl(tab2d_1=h_s        (:,:,jl)        , clinfo1= ' h_s         : ')
735         CALL prt_ctl(tab2d_1=t_su       (:,:,jl)        , clinfo1= ' t_su        : ')
736         CALL prt_ctl(tab2d_1=t_s        (:,:,1,jl)      , clinfo1= ' t_snow      : ')
737         CALL prt_ctl(tab2d_1=s_i        (:,:,jl)        , clinfo1= ' s_i         : ')
738         CALL prt_ctl(tab2d_1=o_i        (:,:,jl)        , clinfo1= ' o_i         : ')
739         CALL prt_ctl(tab2d_1=a_i        (:,:,jl)        , clinfo1= ' a_i         : ')
740         CALL prt_ctl(tab2d_1=v_i        (:,:,jl)        , clinfo1= ' v_i         : ')
741         CALL prt_ctl(tab2d_1=v_s        (:,:,jl)        , clinfo1= ' v_s         : ')
742         CALL prt_ctl(tab2d_1=e_s        (:,:,1,jl)      , clinfo1= ' e_snow      : ')
743         CALL prt_ctl(tab2d_1=sv_i       (:,:,jl)        , clinfo1= ' sv_i        : ')
744         CALL prt_ctl(tab2d_1=oa_i       (:,:,jl)        , clinfo1= ' oa_i        : ')
745         
746         DO jk = 1, nlay_i
747            CALL prt_ctl_info(' - Layer : ', ivar1=jk)
748            CALL prt_ctl(tab2d_1=t_i(:,:,jk,jl) , clinfo1= ' t_i       : ')
749            CALL prt_ctl(tab2d_1=e_i(:,:,jk,jl) , clinfo1= ' e_i       : ')
750         END DO
751      END DO
752     
753      CALL prt_ctl_info(' ')
754      CALL prt_ctl_info(' - Stresses : ')
755      CALL prt_ctl_info('   ~~~~~~~~~~ ')
756      CALL prt_ctl(tab2d_1=utau       , clinfo1= ' utau      : ', tab2d_2=vtau       , clinfo2= ' vtau      : ')
757      CALL prt_ctl(tab2d_1=utau_ice   , clinfo1= ' utau_ice  : ', tab2d_2=vtau_ice   , clinfo2= ' vtau_ice  : ')
758     
759   END SUBROUTINE ice_prt3D
760
761
762   SUBROUTINE ice_drift_wri( kt )
763      !!-------------------------------------------------------------------
764      !!                     ***  ROUTINE ice_drift_wri ***
765      !!
766      !! ** Purpose : conservation of mass, salt and heat
767      !!              write the drift in a ascii file at each time step
768      !!              and the total run drifts
769      !!-------------------------------------------------------------------
770      INTEGER, INTENT(in) ::   kt   ! ice time-step index
771      !
772      INTEGER  ::   ji, jj
773      REAL(wp) ::   zdiag_mass, zdiag_salt, zdiag_heat, zdiag_adv_mass, zdiag_adv_salt, zdiag_adv_heat
774      !!REAL(wp), DIMENSION(jpi,jpj) ::   zdiag_mass2D, zdiag_salt2D, zdiag_heat2D
775      !!-------------------------------------------------------------------
776      !
777      IF( kt == nit000 .AND. lwp ) THEN
778         WRITE(numout,*)
779         WRITE(numout,*) 'ice_drift_wri: sea-ice drifts'
780         WRITE(numout,*) '~~~~~~~~~~~~~'
781      ENDIF
782      !
783      !clem: the following lines check the ice drift in 2D.
784      !      to use this check, uncomment those lines and add the 3 fields in field_def_ice.xml
785      !!! 2D budgets (must be close to 0)
786      !!IF( iom_use('icedrift_mass') .OR. iom_use('icedrift_salt') .OR. iom_use('icedrift_heat') ) THEN
787      !!   DO jj = 1, jpj
788      !!      DO ji = 1, jpi
789      !!         zdiag_mass2D(ji,jj) =   wfx_ice(ji,jj)   + wfx_snw(ji,jj)   + wfx_spr(ji,jj) + wfx_sub(ji,jj) &
790      !!            &                  + diag_vice(ji,jj) + diag_vsnw(ji,jj) - diag_adv_mass(ji,jj)
791      !!         zdiag_salt2D(ji,jj) = sfx(ji,jj) + diag_sice(ji,jj) - diag_adv_salt(ji,jj)
792      !!         zdiag_heat2D(ji,jj) = qt_oce_ai(ji,jj) - qt_atm_oi(ji,jj) + diag_heat(ji,jj) - diag_adv_heat(ji,jj)
793      !!      END DO
794      !!   END DO
795      !!   !
796      !!   ! write outputs
797      !!   CALL iom_put( 'icedrift_mass', zdiag_mass2D )
798      !!   CALL iom_put( 'icedrift_salt', zdiag_salt2D )
799      !!   CALL iom_put( 'icedrift_heat', zdiag_heat2D )
800      !!ENDIF
801
802      ! -- mass diag -- !
803      zdiag_mass     = glob_sum( 'icectl', (  wfx_ice   + wfx_snw   + wfx_spr + wfx_sub &
804         &                                  + diag_vice + diag_vsnw - diag_adv_mass ) * e1e2t ) * rdt_ice
805      zdiag_adv_mass = glob_sum( 'icectl', diag_adv_mass * e1e2t ) * rdt_ice
806
807      ! -- salt diag -- !
808      zdiag_salt     = glob_sum( 'icectl', ( sfx + diag_sice - diag_adv_salt ) * e1e2t ) * rdt_ice * 1.e-3
809      zdiag_adv_salt = glob_sum( 'icectl', diag_adv_salt * e1e2t ) * rdt_ice * 1.e-3
810
811      ! -- heat diag -- !
812      zdiag_heat     = glob_sum( 'icectl', ( qt_oce_ai - qt_atm_oi + diag_heat - diag_adv_heat ) * e1e2t )
813      zdiag_adv_heat = glob_sum( 'icectl', diag_adv_heat * e1e2t )
814
815      !                    ! write out to file
816      IF( lwp ) THEN
817         ! check global drift (must be close to 0)
818         WRITE(numicedrift,FMT='(2x,i6,3x,a19,4x,f25.5)') kt, 'mass drift     [kg]', zdiag_mass
819         WRITE(numicedrift,FMT='(11x,     a19,4x,f25.5)')     'salt drift     [kg]', zdiag_salt
820         WRITE(numicedrift,FMT='(11x,     a19,4x,f25.5)')     'heat drift     [W] ', zdiag_heat
821         ! check drift from advection scheme (can be /=0 with bdy but not sure why)
822         WRITE(numicedrift,FMT='(11x,     a19,4x,f25.5)')     'mass drift adv [kg]', zdiag_adv_mass
823         WRITE(numicedrift,FMT='(11x,     a19,4x,f25.5)')     'salt drift adv [kg]', zdiag_adv_salt
824         WRITE(numicedrift,FMT='(11x,     a19,4x,f25.5)')     'heat drift adv [W] ', zdiag_adv_heat
825      ENDIF
826      !                    ! drifts
827      rdiag_icemass = rdiag_icemass + zdiag_mass
828      rdiag_icesalt = rdiag_icesalt + zdiag_salt
829      rdiag_iceheat = rdiag_iceheat + zdiag_heat
830      rdiag_adv_icemass = rdiag_adv_icemass + zdiag_adv_mass
831      rdiag_adv_icesalt = rdiag_adv_icesalt + zdiag_adv_salt
832      rdiag_adv_iceheat = rdiag_adv_iceheat + zdiag_adv_heat
833      !
834      !                    ! output drifts and close ascii file
835      IF( kt == nitend - nn_fsbc + 1 .AND. lwp ) THEN
836         ! to ascii file
837         WRITE(numicedrift,*) '******************************************'
838         WRITE(numicedrift,FMT='(3x,a23,6x,E10.2)') 'Run mass drift     [kg]', rdiag_icemass
839         WRITE(numicedrift,FMT='(3x,a23,6x,E10.2)') 'Run mass drift adv [kg]', rdiag_adv_icemass
840         WRITE(numicedrift,*) '******************************************'
841         WRITE(numicedrift,FMT='(3x,a23,6x,E10.2)') 'Run salt drift     [kg]', rdiag_icesalt
842         WRITE(numicedrift,FMT='(3x,a23,6x,E10.2)') 'Run salt drift adv [kg]', rdiag_adv_icesalt
843         WRITE(numicedrift,*) '******************************************'
844         WRITE(numicedrift,FMT='(3x,a23,6x,E10.2)') 'Run heat drift     [W] ', rdiag_iceheat
845         WRITE(numicedrift,FMT='(3x,a23,6x,E10.2)') 'Run heat drift adv [W] ', rdiag_adv_iceheat
846         CLOSE( numicedrift )
847         !
848         ! to ocean output
849         WRITE(numout,*)
850         WRITE(numout,*) 'ice_drift_wri: ice drifts information for the run '
851         WRITE(numout,*) '~~~~~~~~~~~~~'
852         ! check global drift (must be close to 0)
853         WRITE(numout,*) '   sea-ice mass drift     [kg] = ', rdiag_icemass
854         WRITE(numout,*) '   sea-ice salt drift     [kg] = ', rdiag_icesalt
855         WRITE(numout,*) '   sea-ice heat drift     [W]  = ', rdiag_iceheat
856         ! check drift from advection scheme (can be /=0 with bdy but not sure why)
857         WRITE(numout,*) '   sea-ice mass drift adv [kg] = ', rdiag_adv_icemass
858         WRITE(numout,*) '   sea-ice salt drift adv [kg] = ', rdiag_adv_icesalt
859         WRITE(numout,*) '   sea-ice heat drift adv [W]  = ', rdiag_adv_iceheat
860      ENDIF
861      !
862   END SUBROUTINE ice_drift_wri
863
864   SUBROUTINE ice_drift_init
865      !!----------------------------------------------------------------------
866      !!                  ***  ROUTINE ice_drift_init  ***
867      !!                   
868      !! ** Purpose :   create output file, initialise arrays
869      !!----------------------------------------------------------------------
870      !
871      IF( .NOT.ln_icediachk ) RETURN ! exit
872      !
873      IF(lwp) THEN
874         WRITE(numout,*)
875         WRITE(numout,*) 'ice_drift_init: Output ice drifts to ',TRIM(clname), ' file'
876         WRITE(numout,*) '~~~~~~~~~~~~~'
877         WRITE(numout,*)
878         !
879         ! create output ascii file
880         CALL ctl_opn( numicedrift, clname, 'UNKNOWN', 'FORMATTED', 'SEQUENTIAL', 1, numout, lwp, narea )
881         WRITE(numicedrift,*) 'Timestep  Drifts'
882         WRITE(numicedrift,*) '******************************************'
883      ENDIF
884      !
885      rdiag_icemass = 0._wp
886      rdiag_icesalt = 0._wp
887      rdiag_iceheat = 0._wp
888      rdiag_adv_icemass = 0._wp
889      rdiag_adv_icesalt = 0._wp
890      rdiag_adv_iceheat = 0._wp
891      !
892   END SUBROUTINE ice_drift_init
893
894#else
895   !!----------------------------------------------------------------------
896   !!   Default option         Empty Module           No SI3 sea-ice model
897   !!----------------------------------------------------------------------
898#endif
899
900   !!======================================================================
901END MODULE icectl
Note: See TracBrowser for help on using the repository browser.