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 branches/2017/dev_CNRS_2017/NEMOGCM/NEMO/OPA_SRC/BDY – NEMO

source: branches/2017/dev_CNRS_2017/NEMOGCM/NEMO/OPA_SRC/BDY/bdyice.F90 @ 9015

Last change on this file since 9015 was 9015, checked in by acc, 6 years ago

Branch dev_CNRS_2017. Tidy up timing calls. Correct a few inconsistent labels and fix incorrect call in trc_sub_stp. Remove timing from icethd_pnd which is not always called by all processors

File size: 17.8 KB
Line 
1MODULE bdyice
2   !!======================================================================
3   !!                       ***  MODULE  bdyice  ***
4   !! Unstructured Open Boundary Cond. :  Open boundary conditions for sea-ice (LIM3)
5   !!======================================================================
6   !!  History :  3.3  !  2010-09 (D. Storkey)  Original code
7   !!             3.4  !  2011    (D. Storkey)  rewrite in preparation for OBC-BDY merge
8   !!              -   !  2012-01 (C. Rousset)  add lim3 and remove useless jk loop
9   !!----------------------------------------------------------------------
10#if defined key_lim3
11   !!----------------------------------------------------------------------
12   !!   'key_lim3'                                                 LIM-3 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 iceitd          ! sea-ice: rebining
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 limrhg
40
41   !!----------------------------------------------------------------------
42   !! NEMO/OPA 4.0 , NEMO Consortium (2017)
43   !! $Id: bdyice.F90 8306 2017-07-10 10:18:03Z clem $
44   !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
45   !!----------------------------------------------------------------------
46CONTAINS
47
48   SUBROUTINE bdy_ice( kt )
49      !!----------------------------------------------------------------------
50      !!                  ***  SUBROUTINE bdy_ice  ***
51      !!
52      !! ** Purpose : - Apply open boundary conditions for ice (LIM3)
53      !!
54      !!----------------------------------------------------------------------
55      INTEGER, INTENT(in) ::   kt   ! Main time step counter
56      !
57      INTEGER ::   ib_bdy   ! Loop index
58      !!----------------------------------------------------------------------
59      !
60      CALL ice_var_glo2eqv
61      !
62      DO ib_bdy = 1, nb_bdy
63         !
64         SELECT CASE( cn_ice_lim(ib_bdy) )
65         CASE('none')
66            CYCLE
67         CASE('frs')
68            CALL bdy_ice_frs( idx_bdy(ib_bdy), dta_bdy(ib_bdy), kt, ib_bdy )
69         CASE DEFAULT
70            CALL ctl_stop( 'bdy_ice : unrecognised option for open boundaries for ice fields' )
71         END SELECT
72         !
73      END DO
74      !
75                        CALL ice_var_zapsmall
76                        CALL ice_var_agg(1)
77      IF( ln_icectl )   CALL ice_prt( kt, iiceprt, jiceprt, 1, ' - ice thermo bdy - ' )
78      !
79   END SUBROUTINE bdy_ice
80
81
82   SUBROUTINE bdy_ice_frs( idx, dta, kt, ib_bdy )
83      !!------------------------------------------------------------------------------
84      !!                 ***  SUBROUTINE bdy_ice_frs  ***
85      !!                   
86      !! ** Purpose : Apply the Flow Relaxation Scheme for sea-ice fields in the case
87      !!              of unstructured open boundaries.
88      !!
89      !! Reference : Engedahl H., 1995: Use of the flow relaxation scheme in a three-
90      !!             dimensional baroclinic ocean model with realistic topography. Tellus, 365-382.
91      !!------------------------------------------------------------------------------
92      TYPE(OBC_INDEX), INTENT(in) ::   idx     ! OBC indices
93      TYPE(OBC_DATA),  INTENT(in) ::   dta     ! OBC external data
94      INTEGER,         INTENT(in) ::   kt      ! main time-step counter
95      INTEGER,         INTENT(in) ::   ib_bdy  ! BDY set index
96      !
97      INTEGER  ::   jpbound            ! 0 = incoming ice
98      !                                ! 1 = outgoing ice
99      INTEGER  ::   jb, jk, jgrd, jl   ! dummy loop indices
100      INTEGER  ::   ji, jj, ii, ij     ! local scalar
101      REAL(wp) ::   zwgt, zwgt1        ! local scalar
102      REAL(wp) ::   ztmelts, zdh
103      !!------------------------------------------------------------------------------
104      !
105      IF( ln_timing )   CALL timing_start('bdy_ice_frs')
106      !
107      jgrd = 1      ! Everything is at T-points here
108      !
109      DO jl = 1, jpl
110         DO jb = 1, idx%nblenrim(jgrd)
111            ji    = idx%nbi(jb,jgrd)
112            jj    = idx%nbj(jb,jgrd)
113            zwgt  = idx%nbw(jb,jgrd)
114            zwgt1 = 1.e0 - idx%nbw(jb,jgrd)
115            a_i(ji,jj,jl) = ( a_i(ji,jj,jl) * zwgt1 + dta%a_i(jb,jl) * zwgt ) * tmask(ji,jj,1)  ! Leads fraction
116            h_i(ji,jj,jl) = ( h_i(ji,jj,jl) * zwgt1 + dta%h_i(jb,jl) * zwgt ) * tmask(ji,jj,1)  ! Ice depth
117            h_s(ji,jj,jl) = ( h_s(ji,jj,jl) * zwgt1 + dta%h_s(jb,jl) * zwgt ) * tmask(ji,jj,1)  ! Snow depth
118
119            ! -----------------
120            ! Pathological case
121            ! -----------------
122            ! In case a) snow load would be in excess or b) ice is coming into a warmer environment that would lead to
123            ! very large transformation from snow to ice (see icethd_dh.F90)
124
125            ! Then, a) transfer the snow excess into the ice (different from icethd_dh)
126            zdh = MAX( 0._wp, ( rhosn * h_s(ji,jj,jl) + ( rhoic - rau0 ) * h_i(ji,jj,jl) ) * r1_rau0 )
127            ! Or, b) transfer all the snow into ice (if incoming ice is likely to melt as it comes into a warmer environment)
128            !zdh = MAX( 0._wp, h_s(ji,jj,jl) * rhosn / rhoic )
129
130            ! recompute h_i, h_s
131            h_i(ji,jj,jl) = MIN( hi_max(jl), h_i(ji,jj,jl) + zdh )
132            h_s(ji,jj,jl) = MAX( 0._wp, h_s(ji,jj,jl) - zdh * rhoic / rhosn ) 
133
134         ENDDO
135         CALL lbc_bdy_lnk( a_i(:,:,jl), 'T', 1., ib_bdy )
136         CALL lbc_bdy_lnk( h_i(:,:,jl), 'T', 1., ib_bdy )
137         CALL lbc_bdy_lnk( h_s(:,:,jl), 'T', 1., ib_bdy )
138      ENDDO
139      ! retrieve at_i
140      at_i(:,:) = 0._wp
141      DO jl = 1, jpl
142         at_i(:,:) = a_i(:,:,jl) + at_i(:,:)
143      END DO
144
145      DO jl = 1, jpl
146         DO jb = 1, idx%nblenrim(jgrd)
147            ji    = idx%nbi(jb,jgrd)
148            jj    = idx%nbj(jb,jgrd)
149
150            ! condition on ice thickness depends on the ice velocity
151            ! if velocity is outward (strictly), then ice thickness, volume... must be equal to adjacent values
152            jpbound = 0   ;   ii = ji   ;   ij = jj
153            !
154            IF( u_ice(ji+1,jj  ) < 0. .AND. umask(ji-1,jj  ,1) == 0. ) jpbound = 1; ii = ji+1; ij = jj
155            IF( u_ice(ji-1,jj  ) > 0. .AND. umask(ji+1,jj  ,1) == 0. ) jpbound = 1; ii = ji-1; ij = jj
156            IF( v_ice(ji  ,jj+1) < 0. .AND. vmask(ji  ,jj-1,1) == 0. ) jpbound = 1; ii = ji  ; ij = jj+1
157            IF( v_ice(ji  ,jj-1) > 0. .AND. vmask(ji  ,jj+1,1) == 0. ) jpbound = 1; ii = ji  ; ij = jj-1
158            !
159            IF( nn_ice_lim_dta(ib_bdy) == 0 ) jpbound = 0; ii = ji; ij = jj   ! case ice boundaries = initial conditions
160            !                                                                 !      do not make state variables dependent on velocity
161            !
162            rswitch = MAX( 0.0_wp , SIGN ( 1.0_wp , at_i(ii,ij) - 0.01 ) ) ! 0 if no ice
163            !
164            ! concentration and thickness
165            a_i(ji,jj,jl) = a_i(ii,ij,jl) * rswitch
166            h_i(ji,jj,jl) = h_i(ii,ij,jl) * rswitch
167            h_s(ji,jj,jl) = h_s(ii,ij,jl) * rswitch
168            !
169            ! Ice and snow volumes
170            v_i(ji,jj,jl) = h_i(ji,jj,jl) * a_i(ji,jj,jl)
171            v_s(ji,jj,jl) = h_s(ji,jj,jl) * a_i(ji,jj,jl)
172            !
173            SELECT CASE( jpbound )
174            !
175            CASE( 0 )   ! velocity is inward
176               !
177               ! Ice salinity, age, temperature
178               s_i (ji,jj,jl)   = rswitch * rn_ice_sal(ib_bdy)  + ( 1.0 - rswitch ) * rn_simin
179               oa_i(ji,jj,jl)   = rswitch * rn_ice_age(ib_bdy) * a_i(ji,jj,jl)
180               t_su(ji,jj,jl)   = rswitch * rn_ice_tem(ib_bdy)  + ( 1.0 - rswitch ) * rn_ice_tem(ib_bdy)
181               DO jk = 1, nlay_s
182                  t_s(ji,jj,jk,jl) = rswitch * rn_ice_tem(ib_bdy) + ( 1.0 - rswitch ) * rt0
183               END DO
184               DO jk = 1, nlay_i
185                  t_i (ji,jj,jk,jl) = rswitch * rn_ice_tem(ib_bdy) + ( 1.0 - rswitch ) * rt0 
186                  sz_i(ji,jj,jk,jl) = rswitch * rn_ice_sal(ib_bdy) + ( 1.0 - rswitch ) * rn_simin
187               END DO
188               !
189            CASE( 1 )   ! velocity is outward
190               !
191               ! Ice salinity, age, temperature
192               s_i (ji,jj,jl)   = rswitch * s_i (ii,ij,jl)  + ( 1.0 - rswitch ) * rn_simin
193               oa_i(ji,jj,jl)   = rswitch * oa_i(ii,ij,jl)
194               t_su(ji,jj,jl)   = rswitch * t_su(ii,ij,jl)  + ( 1.0 - rswitch ) * rt0
195               DO jk = 1, nlay_s
196                  t_s(ji,jj,jk,jl) = rswitch * t_s(ii,ij,jk,jl) + ( 1.0 - rswitch ) * rt0
197               END DO
198               DO jk = 1, nlay_i
199                  t_i (ji,jj,jk,jl) = rswitch * t_i (ii,ij,jk,jl) + ( 1.0 - rswitch ) * rt0
200                  sz_i(ji,jj,jk,jl) = rswitch * sz_i(ii,ij,jk,jl) + ( 1.0 - rswitch ) * rn_simin
201               END DO
202               !
203            END SELECT
204            !
205            IF( nn_icesal == 1 ) THEN     ! constant salinity : overwrite rn_icesal
206               s_i (ji,jj  ,jl) = rn_icesal
207               sz_i(ji,jj,:,jl) = rn_icesal
208            ENDIF
209            !
210            ! contents
211            sv_i(ji,jj,jl)  = MIN( s_i(ji,jj,jl) , sss_m(ji,jj) ) * v_i(ji,jj,jl)
212            DO jk = 1, nlay_s
213               ! Snow energy of melting
214               e_s(ji,jj,jk,jl) = rswitch * rhosn * ( cpic * ( rt0 - t_s(ji,jj,jk,jl) ) + lfus )
215               ! Multiply by volume, so that heat content in J/m2
216               e_s(ji,jj,jk,jl) = e_s(ji,jj,jk,jl) * v_s(ji,jj,jl) * r1_nlay_s
217            END DO
218            DO jk = 1, nlay_i
219               ztmelts          = - tmut * sz_i(ji,jj,jk,jl) + rt0 !Melting temperature in K                 
220               ! heat content per unit volume
221               e_i(ji,jj,jk,jl) = rswitch * rhoic * &
222                  (   cpic    * ( ztmelts - t_i(ji,jj,jk,jl) ) &
223                  +   lfus    * ( 1.0 - (ztmelts-rt0) / MIN((t_i(ji,jj,jk,jl)-rt0),-epsi20) ) &
224                  - rcp      * ( ztmelts - rt0 ) )
225               ! Mutliply by ice volume, and divide by number of layers to get heat content in J/m2
226               e_i(ji,jj,jk,jl) = e_i(ji,jj,jk,jl) * a_i(ji,jj,jl) * h_i(ji,jj,jl) * r1_nlay_i
227            END DO
228            !
229         END DO
230         !
231         CALL lbc_bdy_lnk( a_i(:,:,jl), 'T', 1., ib_bdy )
232         CALL lbc_bdy_lnk( h_i(:,:,jl), 'T', 1., ib_bdy )
233         CALL lbc_bdy_lnk( h_s(:,:,jl), 'T', 1., ib_bdy )
234         CALL lbc_bdy_lnk( v_i(:,:,jl), 'T', 1., ib_bdy )
235         CALL lbc_bdy_lnk( v_s(:,:,jl), 'T', 1., ib_bdy )
236         !
237         CALL lbc_bdy_lnk( sv_i(:,:,jl), 'T', 1., ib_bdy )
238         CALL lbc_bdy_lnk(  s_i(:,:,jl), 'T', 1., ib_bdy )
239         CALL lbc_bdy_lnk( oa_i(:,:,jl), 'T', 1., ib_bdy )
240         CALL lbc_bdy_lnk( t_su(:,:,jl), 'T', 1., ib_bdy )
241         DO jk = 1, nlay_s
242            CALL lbc_bdy_lnk(t_s(:,:,jk,jl), 'T', 1., ib_bdy )
243            CALL lbc_bdy_lnk(e_s(:,:,jk,jl), 'T', 1., ib_bdy )
244         END DO
245         DO jk = 1, nlay_i
246            CALL lbc_bdy_lnk(t_i(:,:,jk,jl), 'T', 1., ib_bdy )
247            CALL lbc_bdy_lnk(e_i(:,:,jk,jl), 'T', 1., ib_bdy )
248         END DO
249         !
250      END DO !jl
251      !
252      ! --- In case categories are out of bounds, do a remapping --- !
253      !     i.e. inputs have not the same ice thickness distribution
254      !          (set by rn_himean) than the regional simulation
255      IF( jpl > 1 )   CALL ice_itd_reb( kt )
256      !     
257      IF( ln_timing )   CALL timing_stop('bdy_ice_frs')
258      !
259   END SUBROUTINE bdy_ice_frs
260
261
262   SUBROUTINE bdy_ice_dyn( cd_type )
263      !!------------------------------------------------------------------------------
264      !!                 ***  SUBROUTINE bdy_ice_dyn  ***
265      !!                   
266      !! ** Purpose : Apply dynamics boundary conditions for sea-ice in the cas of unstructured open boundaries.
267      !!              u_ice and v_ice are equal to the value of the adjacent grid point if this latter is not ice free
268      !!              if adjacent grid point is ice free, then u_ice and v_ice are equal to ocean velocities
269      !!
270      !! 2013-06 : C. Rousset
271      !!------------------------------------------------------------------------------
272      CHARACTER(len=1), INTENT(in)  ::   cd_type   ! nature of velocity grid-points
273      !
274      INTEGER  ::   jb, jgrd           ! dummy loop indices
275      INTEGER  ::   ji, jj             ! local scalar
276      INTEGER  ::   ib_bdy             ! Loop index
277      REAL(wp) ::   zmsk1, zmsk2, zflag
278      !!------------------------------------------------------------------------------
279      !
280      IF( ln_timing )   CALL timing_start('bdy_ice_dyn')
281      !
282      DO ib_bdy=1, nb_bdy
283         !
284         SELECT CASE( cn_ice_lim(ib_bdy) )
285         !
286         CASE('none')
287            CYCLE
288            !
289         CASE('frs')
290            !
291            IF( nn_ice_lim_dta(ib_bdy) == 0 ) CYCLE            ! case ice boundaries = initial conditions
292            !                                                  !      do not change ice velocity (it is only computed by rheology)
293            SELECT CASE ( cd_type )
294            !     
295            CASE ( 'U' ) 
296               jgrd = 2      ! u velocity
297               DO jb = 1, idx_bdy(ib_bdy)%nblenrim(jgrd)
298                  ji    = idx_bdy(ib_bdy)%nbi(jb,jgrd)
299                  jj    = idx_bdy(ib_bdy)%nbj(jb,jgrd)
300                  zflag = idx_bdy(ib_bdy)%flagu(jb,jgrd)
301                  !
302                  IF ( ABS( zflag ) == 1. ) THEN  ! eastern and western boundaries
303                     ! one of the two zmsk is always 0 (because of zflag)
304                     zmsk1 = 1._wp - MAX( 0.0_wp, SIGN ( 1.0_wp , - vt_i(ji+1,jj) ) ) ! 0 if no ice
305                     zmsk2 = 1._wp - MAX( 0.0_wp, SIGN ( 1.0_wp , - vt_i(ji-1,jj) ) ) ! 0 if no ice
306                     
307                     ! u_ice = u_ice of the adjacent grid point except if this grid point is ice-free (then u_ice = u_oce)
308                     u_ice (ji,jj) = u_ice(ji+1,jj) * 0.5_wp * ABS( zflag + 1._wp ) * zmsk1 + &
309                        &            u_ice(ji-1,jj) * 0.5_wp * ABS( zflag - 1._wp ) * zmsk2 + &
310                        &            u_oce(ji  ,jj) * ( 1._wp - MIN( 1._wp, zmsk1 + zmsk2 ) )
311                  ELSE                             ! everywhere else
312                     !u_ice(ji,jj) = u_oce(ji,jj)
313                     u_ice(ji,jj) = 0._wp
314                  ENDIF
315                  ! mask ice velocities
316                  rswitch = MAX( 0.0_wp , SIGN ( 1.0_wp , at_i(ji,jj) - 0.01_wp ) ) ! 0 if no ice
317                  u_ice(ji,jj) = rswitch * u_ice(ji,jj)
318                  !
319               END DO
320               CALL lbc_bdy_lnk( u_ice(:,:), 'U', -1., ib_bdy )
321               !
322            CASE ( 'V' )
323               jgrd = 3      ! v velocity
324               DO jb = 1, idx_bdy(ib_bdy)%nblenrim(jgrd)
325                  ji    = idx_bdy(ib_bdy)%nbi(jb,jgrd)
326                  jj    = idx_bdy(ib_bdy)%nbj(jb,jgrd)
327                  zflag = idx_bdy(ib_bdy)%flagv(jb,jgrd)
328                  !
329                  IF ( ABS( zflag ) == 1. ) THEN  ! northern and southern boundaries
330                     ! one of the two zmsk is always 0 (because of zflag)
331                     zmsk1 = 1._wp - MAX( 0.0_wp, SIGN ( 1.0_wp , - vt_i(ji,jj+1) ) ) ! 0 if no ice
332                     zmsk2 = 1._wp - MAX( 0.0_wp, SIGN ( 1.0_wp , - vt_i(ji,jj-1) ) ) ! 0 if no ice
333                     
334                     ! u_ice = u_ice of the adjacent grid point except if this grid point is ice-free (then u_ice = u_oce)
335                     v_ice (ji,jj) = v_ice(ji,jj+1) * 0.5_wp * ABS( zflag + 1._wp ) * zmsk1 + &
336                        &            v_ice(ji,jj-1) * 0.5_wp * ABS( zflag - 1._wp ) * zmsk2 + &
337                        &            v_oce(ji,jj  ) * ( 1._wp - MIN( 1._wp, zmsk1 + zmsk2 ) )
338                  ELSE                             ! everywhere else
339                     !v_ice(ji,jj) = v_oce(ji,jj)
340                     v_ice(ji,jj) = 0._wp
341                  ENDIF
342                  ! mask ice velocities
343                  rswitch = MAX( 0.0_wp , SIGN ( 1.0_wp , at_i(ji,jj) - 0.01 ) ) ! 0 if no ice
344                  v_ice(ji,jj) = rswitch * v_ice(ji,jj)
345                  !
346               END DO
347               CALL lbc_bdy_lnk( v_ice(:,:), 'V', -1., ib_bdy )
348               !
349            END SELECT
350            !
351         CASE DEFAULT
352            CALL ctl_stop( 'bdy_ice_dyn : unrecognised option for open boundaries for ice fields' )
353         END SELECT
354         !
355      END DO
356      !
357      IF( ln_timing )   CALL timing_stop('bdy_ice_dyn')
358      !
359    END SUBROUTINE bdy_ice_dyn
360
361#else
362   !!---------------------------------------------------------------------------------
363   !!   Default option                                                    Empty module
364   !!---------------------------------------------------------------------------------
365CONTAINS
366   SUBROUTINE bdy_ice( kt )      ! Empty routine
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.