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.
bdyice.F90 in NEMO/branches/2019/fix_vvl_ticket1791/src/OCE/BDY – NEMO

source: NEMO/branches/2019/fix_vvl_ticket1791/src/OCE/BDY/bdyice.F90 @ 11422

Last change on this file since 11422 was 11422, checked in by jchanut, 5 years ago

#1791, merge with trunk

  • Property svn:keywords set to Id
File size: 18.6 KB
Line 
1MODULE bdyice
2   !!======================================================================
3   !!                       ***  MODULE  bdyice  ***
4   !! Unstructured Open Boundary Cond. :  Open boundary conditions for sea-ice (SI3)
5   !!======================================================================
6   !!  History :  3.3  !  2010-09 (D. Storkey)  Original code
7   !!             3.4  !  2012-01 (C. Rousset)  add new sea ice model
8   !!             4.0  !  2018    (C. Rousset)  SI3 compatibility
9   !!----------------------------------------------------------------------
10#if defined key_si3
11   !!----------------------------------------------------------------------
12   !!   'key_si3'                                          SI3 sea ice model
13   !!----------------------------------------------------------------------
14   !!   bdy_ice        : Application of open boundaries to ice
15   !!   bdy_ice_frs    : Application of Flow Relaxation Scheme
16   !!----------------------------------------------------------------------
17   USE oce             ! ocean dynamics and tracers variables
18   USE ice             ! sea-ice: variables
19   USE icevar          ! sea-ice: operations
20   USE icecor          ! sea-ice: corrections
21   USE icectl          ! sea-ice: control prints
22   USE phycst          ! physical constant
23   USE eosbn2          ! equation of state
24   USE par_oce         ! ocean parameters
25   USE dom_oce         ! ocean space and time domain variables
26   USE sbc_oce         ! Surface boundary condition: ocean fields
27   USE bdy_oce         ! ocean open boundary conditions
28   !
29   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
30   USE in_out_manager  ! write to numout file
31   USE lib_mpp         ! distributed memory computing
32   USE lib_fortran     ! to use key_nosignedzero
33   USE timing          ! Timing
34
35   IMPLICIT NONE
36   PRIVATE
37
38   PUBLIC   bdy_ice     ! routine called in sbcmod
39   PUBLIC   bdy_ice_dyn ! routine called in icedyn_rhg_evp
40
41   !!----------------------------------------------------------------------
42   !! NEMO/OCE 4.0 , NEMO Consortium (2018)
43   !! $Id$
44   !! Software governed by the CeCILL license (see ./LICENSE)
45   !!----------------------------------------------------------------------
46CONTAINS
47
48   SUBROUTINE bdy_ice( kt )
49      !!----------------------------------------------------------------------
50      !!                  ***  SUBROUTINE bdy_ice  ***
51      !!
52      !! ** Purpose : Apply open boundary conditions for sea ice
53      !!
54      !!----------------------------------------------------------------------
55      INTEGER, INTENT(in) ::   kt   ! Main time step counter
56      !
57      INTEGER ::   jbdy   ! BDY set index
58      !!----------------------------------------------------------------------
59      ! controls
60      IF( ln_timing    )   CALL timing_start('bdy_ice_thd')                                                            ! timing
61      IF( ln_icediachk )   CALL ice_cons_hsm(0,'bdy_ice_thd', rdiag_v, rdiag_s, rdiag_t, rdiag_fv, rdiag_fs, rdiag_ft) ! conservation
62      !
63      CALL ice_var_glo2eqv
64      !
65      DO jbdy = 1, nb_bdy
66         !
67         SELECT CASE( cn_ice(jbdy) )
68         CASE('none')   ;   CYCLE
69         CASE('frs' )   ;   CALL bdy_ice_frs( idx_bdy(jbdy), dta_bdy(jbdy), kt, jbdy )
70         CASE DEFAULT
71            CALL ctl_stop( 'bdy_ice : unrecognised option for open boundaries for ice fields' )
72         END SELECT
73         !
74      END DO
75      !
76      CALL ice_cor( kt , 0 )      ! -- In case categories are out of bounds, do a remapping
77      !                           !    i.e. inputs have not the same ice thickness distribution (set by rn_himean)
78      !                           !         than the regional simulation
79      CALL ice_var_agg(1)
80      !
81      ! controls
82      IF( ln_icediachk )   CALL ice_cons_hsm(1,'bdy_ice_thd', rdiag_v, rdiag_s, rdiag_t, rdiag_fv, rdiag_fs, rdiag_ft) ! conservation
83      IF( ln_icectl    )   CALL ice_prt     ( kt, iiceprt, jiceprt, 1, ' - ice thermo bdy - ' )                        ! prints
84      IF( ln_timing    )   CALL timing_stop ('bdy_ice_thd')                                                            ! timing
85      !
86   END SUBROUTINE bdy_ice
87
88
89   SUBROUTINE bdy_ice_frs( idx, dta, kt, jbdy )
90      !!------------------------------------------------------------------------------
91      !!                 ***  SUBROUTINE bdy_ice_frs  ***
92      !!                   
93      !! ** Purpose : Apply the Flow Relaxation Scheme for sea-ice fields
94      !!
95      !! Reference : Engedahl H., 1995: Use of the flow relaxation scheme in a three-
96      !!             dimensional baroclinic ocean model with realistic topography. Tellus, 365-382.
97      !!------------------------------------------------------------------------------
98      TYPE(OBC_INDEX), INTENT(in) ::   idx     ! OBC indices
99      TYPE(OBC_DATA),  INTENT(in) ::   dta     ! OBC external data
100      INTEGER,         INTENT(in) ::   kt      ! main time-step counter
101      INTEGER,         INTENT(in) ::   jbdy    ! BDY set index
102      !
103      INTEGER  ::   jpbound            ! 0 = incoming ice
104      !                                ! 1 = outgoing ice
105      INTEGER  ::   i_bdy, jgrd        ! dummy loop indices
106      INTEGER  ::   ji, jj, jk, jl, ib, jb
107      REAL(wp) ::   zwgt, zwgt1        ! local scalar
108      REAL(wp) ::   ztmelts, zdh
109      !!------------------------------------------------------------------------------
110      !
111      jgrd = 1      ! Everything is at T-points here
112      !
113      DO jl = 1, jpl
114         DO i_bdy = 1, idx%nblenrim(jgrd)
115            ji    = idx%nbi(i_bdy,jgrd)
116            jj    = idx%nbj(i_bdy,jgrd)
117            zwgt  = idx%nbw(i_bdy,jgrd)
118            zwgt1 = 1.e0 - idx%nbw(i_bdy,jgrd)
119            a_i(ji,jj,jl) = ( a_i(ji,jj,jl) * zwgt1 + dta%a_i(i_bdy,jl) * zwgt ) * tmask(ji,jj,1)  ! Leads fraction
120            h_i(ji,jj,jl) = ( h_i(ji,jj,jl) * zwgt1 + dta%h_i(i_bdy,jl) * zwgt ) * tmask(ji,jj,1)  ! Ice depth
121            h_s(ji,jj,jl) = ( h_s(ji,jj,jl) * zwgt1 + dta%h_s(i_bdy,jl) * zwgt ) * tmask(ji,jj,1)  ! Snow depth
122
123            ! -----------------
124            ! Pathological case
125            ! -----------------
126            ! In case a) snow load would be in excess or b) ice is coming into a warmer environment that would lead to
127            ! very large transformation from snow to ice (see icethd_dh.F90)
128
129            ! Then, a) transfer the snow excess into the ice (different from icethd_dh)
130            zdh = MAX( 0._wp, ( rhos * h_s(ji,jj,jl) + ( rhoi - rau0 ) * h_i(ji,jj,jl) ) * r1_rau0 )
131            ! Or, b) transfer all the snow into ice (if incoming ice is likely to melt as it comes into a warmer environment)
132            !zdh = MAX( 0._wp, h_s(ji,jj,jl) * rhos / rhoi )
133
134            ! recompute h_i, h_s
135            h_i(ji,jj,jl) = MIN( hi_max(jl), h_i(ji,jj,jl) + zdh )
136            h_s(ji,jj,jl) = MAX( 0._wp, h_s(ji,jj,jl) - zdh * rhoi / rhos ) 
137
138         ENDDO
139      ENDDO
140      CALL lbc_bdy_lnk( 'bdyice', a_i(:,:,:), 'T', 1., jbdy )
141      CALL lbc_bdy_lnk( 'bdyice', h_i(:,:,:), 'T', 1., jbdy )
142      CALL lbc_bdy_lnk( 'bdyice', h_s(:,:,:), 'T', 1., jbdy )
143
144      DO jl = 1, jpl
145         DO i_bdy = 1, idx%nblenrim(jgrd)
146            ji = idx%nbi(i_bdy,jgrd)
147            jj = idx%nbj(i_bdy,jgrd)
148
149            ! condition on ice thickness depends on the ice velocity
150            ! if velocity is outward (strictly), then ice thickness, volume... must be equal to adjacent values
151            jpbound = 0   ;   ib = ji   ;   jb = jj
152            !
153            IF( u_ice(ji  ,jj  ) < 0. .AND. umask(ji-1,jj  ,1) == 0. )   jpbound = 1 ; ib = ji+1
154            IF( u_ice(ji-1,jj  ) > 0. .AND. umask(ji  ,jj  ,1) == 0. )   jpbound = 1 ; ib = ji-1
155            IF( v_ice(ji  ,jj  ) < 0. .AND. vmask(ji  ,jj-1,1) == 0. )   jpbound = 1 ; jb = jj+1
156            IF( v_ice(ji  ,jj-1) > 0. .AND. vmask(ji  ,jj  ,1) == 0. )   jpbound = 1 ; jb = jj-1
157            !
158            IF( nn_ice_dta(jbdy) == 0 )   jpbound = 0 ; ib = ji ; jb = jj   ! case ice boundaries = initial conditions
159            !                                                               !      do not make state variables dependent on velocity
160            !
161            IF( a_i(ib,jb,jl) > 0._wp ) THEN   ! there is ice at the boundary
162               !
163               a_i(ji,jj,jl) = a_i(ib,jb,jl) ! concentration
164               h_i(ji,jj,jl) = h_i(ib,jb,jl) ! thickness ice
165               h_s(ji,jj,jl) = h_s(ib,jb,jl) ! thickness snw
166               !
167               SELECT CASE( jpbound )
168                  !
169               CASE( 0 )   ! velocity is inward
170                  !
171                  oa_i(ji,jj,  jl) = rn_ice_age(jbdy) * a_i(ji,jj,jl) ! age
172                  a_ip(ji,jj,  jl) = 0._wp                            ! pond concentration
173                  v_ip(ji,jj,  jl) = 0._wp                            ! pond volume
174                  t_su(ji,jj,  jl) = rn_ice_tem(jbdy)                 ! temperature surface
175                  t_s (ji,jj,:,jl) = rn_ice_tem(jbdy)                 ! temperature snw
176                  t_i (ji,jj,:,jl) = rn_ice_tem(jbdy)                 ! temperature ice
177                  s_i (ji,jj,  jl) = rn_ice_sal(jbdy)                 ! salinity
178                  sz_i(ji,jj,:,jl) = rn_ice_sal(jbdy)                 ! salinity profile
179                  !
180               CASE( 1 )   ! velocity is outward
181                  !
182                  oa_i(ji,jj,  jl) = oa_i(ib,jb,  jl) ! age
183                  a_ip(ji,jj,  jl) = a_ip(ib,jb,  jl) ! pond concentration
184                  v_ip(ji,jj,  jl) = v_ip(ib,jb,  jl) ! pond volume
185                  t_su(ji,jj,  jl) = t_su(ib,jb,  jl) ! temperature surface
186                  t_s (ji,jj,:,jl) = t_s (ib,jb,:,jl) ! temperature snw
187                  t_i (ji,jj,:,jl) = t_i (ib,jb,:,jl) ! temperature ice
188                  s_i (ji,jj,  jl) = s_i (ib,jb,  jl) ! salinity
189                  sz_i(ji,jj,:,jl) = sz_i(ib,jb,:,jl) ! salinity profile
190                  !
191               END SELECT
192               !
193               IF( nn_icesal == 1 ) THEN     ! if constant salinity
194                  s_i (ji,jj  ,jl) = rn_icesal
195                  sz_i(ji,jj,:,jl) = rn_icesal
196               ENDIF
197               !
198               ! global fields
199               v_i (ji,jj,jl) = h_i(ji,jj,jl) * a_i(ji,jj,jl)                       ! volume ice
200               v_s (ji,jj,jl) = h_s(ji,jj,jl) * a_i(ji,jj,jl)                       ! volume snw
201               sv_i(ji,jj,jl) = MIN( s_i(ji,jj,jl) , sss_m(ji,jj) ) * v_i(ji,jj,jl) ! salt content
202               DO jk = 1, nlay_s
203                  e_s(ji,jj,jk,jl) = rhos * ( rcpi * ( rt0 - t_s(ji,jj,jk,jl) ) + rLfus )   ! enthalpy in J/m3
204                  e_s(ji,jj,jk,jl) = e_s(ji,jj,jk,jl) * v_s(ji,jj,jl) * r1_nlay_s           ! enthalpy in J/m2
205               END DO               
206               DO jk = 1, nlay_i
207                  ztmelts          = - rTmlt  * sz_i(ji,jj,jk,jl)             ! Melting temperature in C
208                  t_i(ji,jj,jk,jl) = MIN( t_i(ji,jj,jk,jl), ztmelts + rt0 )   ! Force t_i to be lower than melting point => likely conservation issue
209                  !
210                  e_i(ji,jj,jk,jl) = rhoi * ( rcpi  * ( ztmelts - ( t_i(ji,jj,jk,jl) - rt0 ) )           &   ! enthalpy in J/m3
211                     &                      + rLfus * ( 1._wp - ztmelts / ( t_i(ji,jj,jk,jl) - rt0 ) )   &
212                     &                      - rcp   *   ztmelts )                 
213                  e_i(ji,jj,jk,jl) = e_i(ji,jj,jk,jl) * v_i(ji,jj,jl) * r1_nlay_i                            ! enthalpy in J/m2
214               END DO
215               !
216            ELSE   ! no ice at the boundary
217               !
218               a_i (ji,jj,  jl) = 0._wp
219               h_i (ji,jj,  jl) = 0._wp
220               h_s (ji,jj,  jl) = 0._wp
221               oa_i(ji,jj,  jl) = 0._wp
222               a_ip(ji,jj,  jl) = 0._wp
223               v_ip(ji,jj,  jl) = 0._wp
224               t_su(ji,jj,  jl) = rt0
225               t_s (ji,jj,:,jl) = rt0
226               t_i (ji,jj,:,jl) = rt0 
227               
228               IF( nn_icesal == 1 ) THEN     ! if constant salinity
229                  s_i (ji,jj  ,jl) = rn_icesal
230                  sz_i(ji,jj,:,jl) = rn_icesal
231               ELSE                          ! if variable salinity
232                  s_i (ji,jj,jl)   = rn_simin
233                  sz_i(ji,jj,:,jl) = rn_simin
234               ENDIF
235               !
236               ! global fields
237               v_i (ji,jj,  jl) = 0._wp
238               v_s (ji,jj,  jl) = 0._wp
239               sv_i(ji,jj,  jl) = 0._wp
240               e_s (ji,jj,:,jl) = 0._wp
241               e_i (ji,jj,:,jl) = 0._wp
242
243            ENDIF
244                       
245         END DO
246         !
247      END DO ! jl
248
249      CALL lbc_bdy_lnk( 'bdyice', a_i (:,:,:)  , 'T', 1., jbdy )
250      CALL lbc_bdy_lnk( 'bdyice', h_i (:,:,:)  , 'T', 1., jbdy )
251      CALL lbc_bdy_lnk( 'bdyice', h_s (:,:,:)  , 'T', 1., jbdy )
252      CALL lbc_bdy_lnk( 'bdyice', oa_i(:,:,:)  , 'T', 1., jbdy )
253      CALL lbc_bdy_lnk( 'bdyice', a_ip(:,:,:)  , 'T', 1., jbdy )
254      CALL lbc_bdy_lnk( 'bdyice', v_ip(:,:,:)  , 'T', 1., jbdy )
255      CALL lbc_bdy_lnk( 'bdyice', s_i (:,:,:)  , 'T', 1., jbdy )
256      CALL lbc_bdy_lnk( 'bdyice', t_su(:,:,:)  , 'T', 1., jbdy )
257      CALL lbc_bdy_lnk( 'bdyice', v_i (:,:,:)  , 'T', 1., jbdy )
258      CALL lbc_bdy_lnk( 'bdyice', v_s (:,:,:)  , 'T', 1., jbdy )
259      CALL lbc_bdy_lnk( 'bdyice', sv_i(:,:,:)  , 'T', 1., jbdy )
260      CALL lbc_bdy_lnk( 'bdyice', t_s (:,:,:,:), 'T', 1., jbdy )
261      CALL lbc_bdy_lnk( 'bdyice', e_s (:,:,:,:), 'T', 1., jbdy )
262      CALL lbc_bdy_lnk( 'bdyice', t_i (:,:,:,:), 'T', 1., jbdy )
263      CALL lbc_bdy_lnk( 'bdyice', e_i (:,:,:,:), 'T', 1., jbdy )
264      !     
265   END SUBROUTINE bdy_ice_frs
266
267
268   SUBROUTINE bdy_ice_dyn( cd_type )
269      !!------------------------------------------------------------------------------
270      !!                 ***  SUBROUTINE bdy_ice_dyn  ***
271      !!                   
272      !! ** Purpose : Apply dynamics boundary conditions for sea-ice.
273      !!
274      !! ** Method :  if this adjacent grid point is not ice free, then u_ice and v_ice take its value
275      !!              if                          is     ice free, then u_ice and v_ice are unchanged by BDY
276      !!                                                           they keep values calculated in rheology
277      !!
278      !!------------------------------------------------------------------------------
279      CHARACTER(len=1), INTENT(in)  ::   cd_type   ! nature of velocity grid-points
280      !
281      INTEGER  ::   i_bdy, jgrd      ! dummy loop indices
282      INTEGER  ::   ji, jj           ! local scalar
283      INTEGER  ::   jbdy             ! BDY set index
284      REAL(wp) ::   zmsk1, zmsk2, zflag
285      !!------------------------------------------------------------------------------
286      IF( ln_timing )   CALL timing_start('bdy_ice_dyn')
287      !
288      DO jbdy=1, nb_bdy
289         !
290         SELECT CASE( cn_ice(jbdy) )
291         !
292         CASE('none')
293            CYCLE
294            !
295         CASE('frs')
296            !
297            IF( nn_ice_dta(jbdy) == 0 ) CYCLE            ! case ice boundaries = initial conditions
298            !                                            !      do not change ice velocity (it is only computed by rheology)
299            SELECT CASE ( cd_type )
300            !     
301            CASE ( 'U' ) 
302               jgrd = 2      ! u velocity
303               DO i_bdy = 1, idx_bdy(jbdy)%nblenrim(jgrd)
304                  ji    = idx_bdy(jbdy)%nbi(i_bdy,jgrd)
305                  jj    = idx_bdy(jbdy)%nbj(i_bdy,jgrd)
306                  zflag = idx_bdy(jbdy)%flagu(i_bdy,jgrd)
307                  !
308                  IF ( ABS( zflag ) == 1. ) THEN  ! eastern and western boundaries
309                     ! one of the two zmsk is always 0 (because of zflag)
310                     zmsk1 = 1._wp - MAX( 0.0_wp, SIGN ( 1.0_wp , - vt_i(ji+1,jj) ) ) ! 0 if no ice
311                     zmsk2 = 1._wp - MAX( 0.0_wp, SIGN ( 1.0_wp , - vt_i(ji,jj) ) )   ! 0 if no ice
312                     
313                     ! u_ice = u_ice of the adjacent grid point except if this grid point is ice-free (then do not change u_ice)
314                     u_ice (ji,jj) = u_ice(ji+1,jj) * 0.5_wp * ABS( zflag + 1._wp ) * zmsk1 + &
315                        &            u_ice(ji-1,jj) * 0.5_wp * ABS( zflag - 1._wp ) * zmsk2 + &
316                        &            u_ice(ji  ,jj) * ( 1._wp - MIN( 1._wp, zmsk1 + zmsk2 ) )
317                  ELSE                             ! everywhere else
318                     u_ice(ji,jj) = 0._wp
319                  ENDIF
320                  !
321               END DO
322               CALL lbc_bdy_lnk( 'bdyice', u_ice(:,:), 'U', -1., jbdy )
323               !
324            CASE ( 'V' )
325               jgrd = 3      ! v velocity
326               DO i_bdy = 1, idx_bdy(jbdy)%nblenrim(jgrd)
327                  ji    = idx_bdy(jbdy)%nbi(i_bdy,jgrd)
328                  jj    = idx_bdy(jbdy)%nbj(i_bdy,jgrd)
329                  zflag = idx_bdy(jbdy)%flagv(i_bdy,jgrd)
330                  !
331                  IF ( ABS( zflag ) == 1. ) THEN  ! northern and southern boundaries
332                     ! one of the two zmsk is always 0 (because of zflag)
333                     zmsk1 = 1._wp - MAX( 0.0_wp, SIGN ( 1.0_wp , - vt_i(ji,jj+1) ) ) ! 0 if no ice
334                     zmsk2 = 1._wp - MAX( 0.0_wp, SIGN ( 1.0_wp , - vt_i(ji,jj) ) )   ! 0 if no ice
335                     
336                     ! v_ice = v_ice of the adjacent grid point except if this grid point is ice-free (then do not change v_ice)
337                     v_ice (ji,jj) = v_ice(ji,jj+1) * 0.5_wp * ABS( zflag + 1._wp ) * zmsk1 + &
338                        &            v_ice(ji,jj-1) * 0.5_wp * ABS( zflag - 1._wp ) * zmsk2 + &
339                        &            v_ice(ji,jj  ) * ( 1._wp - MIN( 1._wp, zmsk1 + zmsk2 ) )
340                  ELSE                             ! everywhere else
341                     v_ice(ji,jj) = 0._wp
342                  ENDIF
343                  !
344               END DO
345               CALL lbc_bdy_lnk( 'bdyice', v_ice(:,:), 'V', -1., jbdy )
346               !
347            END SELECT
348            !
349         CASE DEFAULT
350            CALL ctl_stop( 'bdy_ice_dyn : unrecognised option for open boundaries for ice fields' )
351         END SELECT
352         !
353      END DO
354      !
355      IF( ln_timing )   CALL timing_stop('bdy_ice_dyn')
356      !
357    END SUBROUTINE bdy_ice_dyn
358
359#else
360   !!---------------------------------------------------------------------------------
361   !!   Default option                                                    Empty module
362   !!---------------------------------------------------------------------------------
363CONTAINS
364   SUBROUTINE bdy_ice( kt )      ! Empty routine
365      IMPLICIT NONE
366      INTEGER, INTENT( in ) :: kt
367      WRITE(*,*) 'bdy_ice: You should not have seen this print! error?', kt
368   END SUBROUTINE bdy_ice
369#endif
370
371   !!=================================================================================
372END MODULE bdyice
Note: See TracBrowser for help on using the repository browser.