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.
icecons.F90 in branches/2017/dev_r8183_ICEMODEL/NEMOGCM/NEMO/LIM_SRC_3 – NEMO

source: branches/2017/dev_r8183_ICEMODEL/NEMOGCM/NEMO/LIM_SRC_3/icecons.F90 @ 8424

Last change on this file since 8424 was 8411, checked in by clem, 7 years ago

continue changing names

File size: 11.8 KB
Line 
1MODULE icecons
2   !!======================================================================
3   !!                   ***  MODULE  icecons  ***
4   !! LIM-3 Sea Ice :   conservation check
5   !!======================================================================
6   !! History :   -   ! Original code from William H. Lipscomb, LANL
7   !!            3.0  ! 2004-06  (M. Vancoppenolle)   Energy Conservation
8   !!            3.5  ! 2011-02  (G. Madec)  add mpp considerations
9   !!             -   ! 2014-05  (C. Rousset) add ice_cons_hsm
10   !!             -   ! 2015-03  (C. Rousset) add ice_cons_final
11   !!----------------------------------------------------------------------
12#if defined key_lim3
13   !!----------------------------------------------------------------------
14   !!   'key_lim3'                                      LIM-3 sea-ice model
15   !!----------------------------------------------------------------------
16   !!    ice_cons     :   checks whether energy, mass and salt are conserved
17   !!----------------------------------------------------------------------
18   USE phycst         ! physical constants
19   USE ice            ! LIM-3 variables
20   USE dom_oce        ! ocean domain
21   USE in_out_manager ! I/O manager
22   USE lib_mpp        ! MPP library
23   USE lib_fortran    ! Fortran utilities (allows no signed zero when 'key_nosignedzero' defined) 
24   USE sbc_oce , ONLY : sfx  ! Surface boundary condition: ocean fields
25   USE sbc_ice , ONLY : qevap_ice
26   
27   IMPLICIT NONE
28   PRIVATE
29
30   PUBLIC   ice_cons_hsm
31   PUBLIC   ice_cons_final
32
33   !!----------------------------------------------------------------------
34   !! NEMO/LIM3 4.0 , UCL - NEMO Consortium (2011)
35   !! $Id: icecons.F90 8409 2017-08-07 15:29:21Z clem $
36   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
37   !!----------------------------------------------------------------------
38CONTAINS
39
40   SUBROUTINE ice_cons_hsm( icount, cd_routine, zvi_b, zsmv_b, zei_b, zfw_b, zfs_b, zft_b )
41      !!--------------------------------------------------------------------------------------------------------
42      !!                                        ***  ROUTINE ice_cons_hsm ***
43      !!
44      !! ** Purpose : Test the conservation of heat, salt and mass for each ice routine
45      !!                     + test if ice concentration and volume are > 0
46      !!
47      !! ** Method  : This is an online diagnostics which can be activated with ln_limdiachk=true
48      !!              It prints in ocean.output if there is a violation of conservation at each time-step
49      !!              The thresholds (zv_sill, zs_sill, zh_sill) which determine violations are set to
50      !!              a minimum of 1 mm of ice (over the ice area) that is lost/gained spuriously during 100 years.
51      !!              For salt and heat thresholds, ice is considered to have a salinity of 10
52      !!              and a heat content of 3e5 J/kg (=latent heat of fusion)
53      !!--------------------------------------------------------------------------------------------------------
54      INTEGER         , INTENT(in)    :: icount        ! determine wether this is the beggining of the routine (0) or the end (1)
55      CHARACTER(len=*), INTENT(in)    :: cd_routine    ! name of the routine
56      REAL(wp)        , INTENT(inout) :: zvi_b, zsmv_b, zei_b, zfs_b, zfw_b, zft_b 
57      REAL(wp)                        :: zvi,   zsmv,   zei,   zfs,   zfw,   zft
58      REAL(wp)                        :: zvmin, zamin, zamax 
59      REAL(wp)                        :: zvtrp, zetrp
60      REAL(wp)                        :: zarea, zv_sill, zs_sill, zh_sill
61      REAL(wp), PARAMETER             :: zconv = 1.e-9 ! convert W to GW and kg to Mt
62
63      IF( icount == 0 ) THEN
64
65         ! salt flux
66         zfs_b  = glob_sum(  ( sfx_bri(:,:) + sfx_bog(:,:) + sfx_bom(:,:) + sfx_sum(:,:) + sfx_sni(:,:) +  &
67            &                  sfx_opw(:,:) + sfx_res(:,:) + sfx_dyn(:,:) + sfx_sub(:,:) + sfx_lam(:,:)    &
68            &                ) *  e1e2t(:,:) * tmask(:,:,1) * zconv )
69
70         ! water flux
71         zfw_b  = glob_sum( -( wfx_bog(:,:) + wfx_bom(:,:)     + wfx_sum(:,:)     + wfx_sni(:,:)     +                     &
72            &                  wfx_opw(:,:) + wfx_res(:,:)     + wfx_dyn(:,:)     + wfx_lam(:,:)     + wfx_ice_sub(:,:) +  &
73            &                  wfx_snw_sni(:,:) + wfx_snw_sum(:,:) + wfx_snw_dyn(:,:) + wfx_snw_sub(:,:) + wfx_spr(:,:)        &
74            &                ) * e1e2t(:,:) * tmask(:,:,1) * zconv )
75
76         ! heat flux
77         zft_b  = glob_sum(  ( hfx_sum(:,:) + hfx_bom(:,:) + hfx_bog(:,:) + hfx_dif(:,:) + hfx_opw(:,:) + hfx_snw(:,:)  & 
78            &                - hfx_thd(:,:) - hfx_dyn(:,:) - hfx_res(:,:) - hfx_sub(:,:) - hfx_spr(:,:)   &
79            &                ) *  e1e2t(:,:) * tmask(:,:,1) * zconv )
80
81         zvi_b  = glob_sum( SUM( v_i * rhoic + v_s * rhosn, dim=3 ) * e1e2t * tmask(:,:,1) * zconv )
82
83         zsmv_b = glob_sum( SUM( smv_i * rhoic            , dim=3 ) * e1e2t * tmask(:,:,1) * zconv )
84
85         zei_b  = glob_sum( ( SUM( SUM( e_i(:,:,1:nlay_i,:), dim=4 ), dim=3 ) +  &
86            &                 SUM( SUM( e_s(:,:,1:nlay_s,:), dim=4 ), dim=3 )    &
87                            ) * e1e2t * tmask(:,:,1) * zconv )
88
89      ELSEIF( icount == 1 ) THEN
90
91         ! salt flux
92         zfs  = glob_sum(  ( sfx_bri(:,:) + sfx_bog(:,:) + sfx_bom(:,:) + sfx_sum(:,:) + sfx_sni(:,:) +  &
93            &                sfx_opw(:,:) + sfx_res(:,:) + sfx_dyn(:,:) + sfx_sub(:,:) + sfx_lam(:,:)    & 
94            &              ) * e1e2t(:,:) * tmask(:,:,1) * zconv ) - zfs_b
95
96         ! water flux
97         zfw  = glob_sum( -( wfx_bog(:,:) + wfx_bom(:,:)     + wfx_sum(:,:)     + wfx_sni(:,:)     +                     &
98            &                wfx_opw(:,:) + wfx_res(:,:)     + wfx_dyn(:,:)     + wfx_lam(:,:)     + wfx_ice_sub(:,:) +  &
99            &                wfx_snw_sni(:,:) + wfx_snw_sum(:,:) + wfx_snw_dyn(:,:) + wfx_snw_sub(:,:) + wfx_spr(:,:)        &
100            &              ) * e1e2t(:,:) * tmask(:,:,1) * zconv ) - zfw_b
101
102         ! heat flux
103         zft  = glob_sum(  ( hfx_sum(:,:) + hfx_bom(:,:) + hfx_bog(:,:) + hfx_dif(:,:) + hfx_opw(:,:) + hfx_snw(:,:)  & 
104            &              - hfx_thd(:,:) - hfx_dyn(:,:) - hfx_res(:,:) - hfx_sub(:,:) - hfx_spr(:,:)   &
105            &              ) * e1e2t(:,:) * tmask(:,:,1) * zconv ) - zft_b
106 
107         ! outputs
108         zvi  = ( ( glob_sum( SUM( v_i * rhoic + v_s * rhosn, dim=3 )  &
109            &                    * e1e2t * tmask(:,:,1) * zconv ) - zvi_b ) * r1_rdtice - zfw ) * rday
110
111         zsmv = ( ( glob_sum( SUM( smv_i * rhoic            , dim=3 )  &
112            &                    * e1e2t * tmask(:,:,1) * zconv ) - zsmv_b ) * r1_rdtice + zfs ) * rday
113
114         zei  = ( glob_sum( ( SUM( SUM( e_i(:,:,1:nlay_i,:), dim=4 ), dim=3 ) +  &
115            &                 SUM( SUM( e_s(:,:,1:nlay_s,:), dim=4 ), dim=3 )    &
116            &                ) * e1e2t * tmask(:,:,1) * zconv ) - zei_b ) * r1_rdtice + zft
117
118         ! zvtrp and zetrp must be close to 0 if the advection scheme is conservative
119         zvtrp = glob_sum( ( diag_trp_vi * rhoic + diag_trp_vs * rhosn ) * e1e2t * tmask(:,:,1) * zconv ) * rday 
120         zetrp = glob_sum( ( diag_trp_ei         + diag_trp_es         ) * e1e2t * tmask(:,:,1) * zconv )
121
122         zvmin = glob_min( v_i )
123         zamax = glob_max( SUM( a_i, dim=3 ) )
124         zamin = glob_min( a_i )
125
126         ! set threshold values and calculate the ice area (+epsi10 to set a threshold > 0 when there is no ice)
127         zarea   = glob_sum( SUM( a_i + epsi10, dim=3 ) * e1e2t * zconv ) ! in 1.e9 m2
128         zv_sill = zarea * 2.5e-5
129         zs_sill = zarea * 25.e-5
130         zh_sill = zarea * 10.e-5
131
132         IF(lwp) THEN
133            IF ( ABS( zvi  ) > zv_sill ) WRITE(numout,*) 'violation volume [Mt/day]     (',cd_routine,') = ',zvi
134            IF ( ABS( zsmv ) > zs_sill ) WRITE(numout,*) 'violation saline [psu*Mt/day] (',cd_routine,') = ',zsmv
135            IF ( ABS( zei  ) > zh_sill ) WRITE(numout,*) 'violation enthalpy [GW]       (',cd_routine,') = ',zei
136            IF ( ABS(zvtrp ) > zv_sill .AND. cd_routine == 'iceadv' ) THEN
137                                         WRITE(numout,*) 'violation vtrp [Mt/day]       (',cd_routine,') = ',zvtrp
138                                         WRITE(numout,*) 'violation etrp [GW]           (',cd_routine,') = ',zetrp
139            ENDIF
140            IF (     zvmin   < -epsi10 ) WRITE(numout,*) 'violation v_i<0  [m]          (',cd_routine,') = ',zvmin
141            IF (     zamax   > MAX( rn_amax_n, rn_amax_s ) + epsi10 .AND. &
142               &                         cd_routine /= 'iceadv' .AND. cd_routine /= 'icerdgrft' ) THEN
143                                         WRITE(numout,*) 'violation a_i>amax            (',cd_routine,') = ',zamax
144            IF (     zamax   > 1._wp   ) WRITE(numout,*) 'violation a_i>1               (',cd_routine,') = ',zamax
145            ENDIF
146            IF (      zamin  < -epsi10 ) WRITE(numout,*) 'violation a_i<0               (',cd_routine,') = ',zamin
147         ENDIF
148
149      ENDIF
150
151   END SUBROUTINE ice_cons_hsm
152
153   SUBROUTINE ice_cons_final( cd_routine )
154      !!---------------------------------------------------------------------------------------------------------
155      !!                                   ***  ROUTINE ice_cons_final ***
156      !!
157      !! ** Purpose : Test the conservation of heat, salt and mass at the end of each ice time-step
158      !!
159      !! ** Method  : This is an online diagnostics which can be activated with ln_limdiachk=true
160      !!              It prints in ocean.output if there is a violation of conservation at each time-step
161      !!              The thresholds (zv_sill, zs_sill, zh_sill) which determine the violation are set to
162      !!              a minimum of 1 mm of ice (over the ice area) that is lost/gained spuriously during 100 years.
163      !!              For salt and heat thresholds, ice is considered to have a salinity of 10
164      !!              and a heat content of 3e5 J/kg (=latent heat of fusion)
165      !!--------------------------------------------------------------------------------------------------------
166      CHARACTER(len=*), INTENT(in)    :: cd_routine    ! name of the routine
167      REAL(wp)                        :: zhfx, zsfx, zvfx
168      REAL(wp)                        :: zarea, zv_sill, zs_sill, zh_sill
169      REAL(wp), PARAMETER             :: zconv = 1.e-9 ! convert W to GW and kg to Mt
170
171      ! heat flux
172      zhfx  = glob_sum( ( hfx_in - hfx_out - diag_heat - diag_trp_ei - diag_trp_es   &
173      !  &              - SUM( qevap_ice * a_i_b, dim=3 )                           & !!clem: I think this line must be commented (but need check)
174         &              ) * e1e2t * tmask(:,:,1) * zconv ) 
175      ! salt flux
176      zsfx  = glob_sum( ( sfx + diag_smvi ) * e1e2t * tmask(:,:,1) * zconv ) * rday
177      ! water flux
178      zvfx  = glob_sum( ( wfx_ice + wfx_snw + wfx_spr + wfx_sub + diag_vice + diag_vsnw ) * e1e2t * tmask(:,:,1) * zconv ) * rday
179
180      ! set threshold values and calculate the ice area (+epsi10 to set a threshold > 0 when there is no ice)
181      zarea   = glob_sum( SUM( a_i + epsi10, dim=3 ) * e1e2t * zconv ) ! in 1.e9 m2
182      zv_sill = zarea * 2.5e-5
183      zs_sill = zarea * 25.e-5
184      zh_sill = zarea * 10.e-5
185
186      IF( ABS( zvfx ) > zv_sill ) WRITE(numout,*) 'violation vfx    [Mt/day]       (',cd_routine,')  = ',(zvfx)
187      IF( ABS( zsfx ) > zs_sill ) WRITE(numout,*) 'violation sfx    [psu*Mt/day]   (',cd_routine,')  = ',(zsfx)
188      IF( ABS( zhfx ) > zh_sill ) WRITE(numout,*) 'violation hfx    [GW]           (',cd_routine,')  = ',(zhfx)
189
190   END SUBROUTINE ice_cons_final
191
192#else
193   !!----------------------------------------------------------------------
194   !!   Default option         Empty module            NO LIM sea-ice model
195   !!----------------------------------------------------------------------
196#endif
197   !!======================================================================
198END MODULE icecons
Note: See TracBrowser for help on using the repository browser.