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.
zdfbfr.F90 in branches/nemo_v3_3_beta/NEMOGCM/NEMO/OPA_SRC/ZDF – NEMO

source: branches/nemo_v3_3_beta/NEMOGCM/NEMO/OPA_SRC/ZDF/zdfbfr.F90 @ 2474

Last change on this file since 2474 was 2450, checked in by gm, 14 years ago

v3.3beta: #766 share the deepest ocean level indices continuaton

  • Property svn:keywords set to Id
File size: 12.7 KB
Line 
1MODULE zdfbfr
2   !!======================================================================
3   !!                       ***  MODULE  zdfbfr  ***
4   !! Ocean physics: Bottom friction
5   !!======================================================================
6   !! History :  OPA  ! 1997-06  (G. Madec, A.-M. Treguier)  Original code
7   !!   NEMO     1.0  ! 2002-06  (G. Madec)  F90: Free form and module
8   !!            3.2  ! 2009-09  (A.C.Coward)  Correction to include barotropic contribution
9   !!            3.3  ! 2010-10  (C. Ethe, G. Madec) reorganisation of initialisation phase
10   !!----------------------------------------------------------------------
11
12   !!----------------------------------------------------------------------
13   !!   zdf_bfr      : update momentum Kz at the ocean bottom due to the type of bottom friction chosen
14   !!   zdf_bfr_init : read in namelist and control the bottom friction parameters.
15   !!   zdf_bfr_2d   : read in namelist and control the bottom friction parameters.
16   !!----------------------------------------------------------------------
17   USE oce             ! ocean dynamics and tracers variables
18   USE dom_oce         ! ocean space and time domain variables
19   USE zdf_oce         ! ocean vertical physics variables
20   USE in_out_manager  ! I/O manager
21   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
22   USE lib_mpp         ! distributed memory computing
23   USE prtctl          ! Print control
24
25   IMPLICIT NONE
26   PRIVATE
27
28   PUBLIC   zdf_bfr         ! called by step.F90
29   PUBLIC   zdf_bfr_init    ! called by opa.F90
30   
31   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   bfrua , bfrva   !: Bottom friction coefficients set in zdfbfr
32#if defined key_zdfgls   ||   defined key_esopa
33   REAL(wp), PUBLIC                     ::   rn_hbro =  0.003_wp  ! Bottom roughness (m)
34   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   wbotu, wbotv         !  Bottom stresses
35#endif
36
37   !                                    !!* Namelist nambfr: bottom friction namelist *
38   INTEGER  ::   nn_bfr    = 0           ! = 0/1/2/3 type of bottom friction
39   REAL(wp) ::   rn_bfri1  = 4.0e-4_wp   ! bottom drag coefficient (linear case)
40   REAL(wp) ::   rn_bfri2  = 1.0e-3_wp   ! bottom drag coefficient (non linear case)
41   REAL(wp) ::   rn_bfeb2  = 2.5e-3_wp   ! background bottom turbulent kinetic energy  [m2/s2]
42   REAL(wp) ::   rn_bfrien = 30._wp      ! local factor to enhance coefficient bfri
43   LOGICAL  ::   ln_bfr2d  = .false.     ! logical switch for 2D enhancement
44   
45   REAL(wp), DIMENSION(jpi,jpj) ::   bfrcoef2d = 1.e-3_wp   ! 2D bottom drag coefficient
46
47   !! * Substitutions
48#  include "vectopt_loop_substitute.h90"
49#  include "domzgr_substitute.h90"
50   !!----------------------------------------------------------------------
51   !! NEMO/OPA 3.3 , NEMO Consortium (2010)
52   !! $Id$
53   !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
54   !!----------------------------------------------------------------------
55
56CONTAINS
57
58   SUBROUTINE zdf_bfr( kt )
59      !!----------------------------------------------------------------------
60      !!                   ***  ROUTINE zdf_bfr  ***
61      !!                 
62      !! ** Purpose :   compute the bottom friction coefficient.
63      !!
64      !! ** Method  :   Calculate and store part of the momentum trend due   
65      !!              to bottom friction following the chosen friction type
66      !!              (free-slip, linear, or quadratic). The component
67      !!              calculated here is multiplied by the bottom velocity in
68      !!              dyn_bfr to provide the trend term.
69      !!                The coefficients are updated at each time step only
70      !!              in the quadratic case.
71      !!
72      !! ** Action  :   bfrua , bfrva   bottom friction coefficients
73      !!----------------------------------------------------------------------
74      INTEGER, INTENT( in ) ::   kt   ! ocean time-step index
75      !!
76      INTEGER  ::   ji, jj       ! dummy loop indices
77      INTEGER  ::   ikbu, ikbv   ! local integers
78      REAL(wp) ::   zvu, zuv, zecu, zecv   ! temporary scalars
79      !!----------------------------------------------------------------------
80
81      IF( nn_bfr == 2 ) THEN                 ! quadratic botton friction
82         ! Calculate and store the quadratic bottom friction coefficient bfrua and bfrva
83         ! where bfrUa = C_d*SQRT(u_bot^2 + v_bot^2 + e_b) {U=[u,v]}
84         ! from these the trend due to bottom friction:  -F_h/e3U  can be calculated
85         ! where -F_h/e3U_bot = bfrUa*Ub/e3U_bot {U=[u,v]}
86         !
87# if defined key_vectopt_loop
88         DO jj = 1, 1
89!CDIR NOVERRCHK
90            DO ji = jpi+2, jpij-jpi-1   ! vector opt. (forced unrolling)
91# else
92!CDIR NOVERRCHK
93         DO jj = 2, jpjm1
94!CDIR NOVERRCHK
95            DO ji = 2, jpim1
96# endif
97               ikbu = mbku(ji,jj)         ! ocean bottom level at u- and v-points
98               ikbv = mbkv(ji,jj)         ! (deepest ocean u- and v-points)
99               !
100               zvu  = 0.25 * (  vn(ji,jj  ,ikbu) + vn(ji+1,jj  ,ikbu)     &
101                  &           + vn(ji,jj-1,ikbu) + vn(ji+1,jj-1,ikbu)  )
102               zuv  = 0.25 * (  un(ji,jj  ,ikbv) + un(ji-1,jj  ,ikbv)     &
103                  &           + un(ji,jj+1,ikbv) + un(ji-1,jj+1,ikbv)  )
104               !
105               zecu = SQRT(  un(ji,jj,ikbu) * un(ji,jj,ikbu) + zvu*zvu + rn_bfeb2  )
106               zecv = SQRT(  vn(ji,jj,ikbv) * vn(ji,jj,ikbv) + zuv*zuv + rn_bfeb2  )
107               !
108               bfrua(ji,jj) = - 0.5_wp * ( bfrcoef2d(ji,jj) + bfrcoef2d(ji+1,jj  ) ) * zecu 
109               bfrva(ji,jj) = - 0.5_wp * ( bfrcoef2d(ji,jj) + bfrcoef2d(ji  ,jj+1) ) * zecv
110            END DO
111         END DO
112         !
113         CALL lbc_lnk( bfrua, 'U', 1. )   ;   CALL lbc_lnk( bfrva, 'V', 1. )      ! Lateral boundary condition
114         !
115         IF(ln_ctl)   CALL prt_ctl( tab2d_1=bfrua, clinfo1=' bfr  - u: ', mask1=umask,        &
116            &                       tab2d_2=bfrva, clinfo2=       ' v: ', mask2=vmask,ovlap=1 )
117      ENDIF
118      !
119
120      !zdfgls case with explicit vertical diffusion scheme: save bottom stress for next time step
121
122#if defined key_zdfgls && defined key_dynspg_exp
123      DO jj = 2, jpjm1
124         DO ji = fs_2, fs_jpim1   ! vector opt.
125            wbotu(ji,jj) = bfrua(ji,jj) * un(ji,jj,mbku(ji,jj)) * umask(ji,jj,mbku(ji,jj))
126            wbotv(ji,jj) = bfrva(ji,jj) * vn(ji,jj,mbkv(ji,jj)) * vmask(ji,jj,mbkv(ji,jj))
127         END DO
128      END DO
129      CALL lbc_lnk( wbotu(:,:), 'U', -1. )   ;   CALL lbc_lnk( wbotv(:,:), 'V', -1. )     ! lateral boundary condition
130#endif
131
132   END SUBROUTINE zdf_bfr
133
134
135   SUBROUTINE zdf_bfr_init
136      !!----------------------------------------------------------------------
137      !!                  ***  ROUTINE zdf_bfr_init  ***
138      !!                   
139      !! ** Purpose :   Initialization of the bottom friction
140      !!
141      !! ** Method  :   Read the nammbf namelist and check their consistency
142      !!              called at the first timestep (nit000)
143      !!----------------------------------------------------------------------
144      USE iom   ! I/O module for ehanced bottom friction file
145      !!
146      INTEGER ::   inum         ! logical unit for enhanced bottom friction file
147      INTEGER ::   ji, jj       ! dummy loop indexes
148      INTEGER ::   ikbu, ikbv   ! temporary integers
149      INTEGER ::   ictu, ictv   !    -          -
150      REAL(wp) ::  zminbfr, zmaxbfr   ! temporary scalars
151      REAL(wp) ::  zfru, zfrv         !    -         -
152      !!
153      NAMELIST/nambfr/ nn_bfr, rn_bfri1, rn_bfri2, rn_bfeb2, ln_bfr2d, rn_bfrien
154      !!----------------------------------------------------------------------
155
156      REWIND ( numnam )               !* Read Namelist nam_bfr : bottom momentum boundary condition
157      READ   ( numnam, nambfr )
158
159      !                               !* Parameter control and print
160      IF(lwp) WRITE(numout,*)
161      IF(lwp) WRITE(numout,*) 'zdf_bfr : momentum bottom friction'
162      IF(lwp) WRITE(numout,*) '~~~~~~~'
163      IF(lwp) WRITE(numout,*) '   Namelist nam_bfr : set bottom friction parameters'
164
165      SELECT CASE (nn_bfr)
166
167      CASE( 0 )
168         IF(lwp) WRITE(numout,*) '      free-slip '
169         bfrua(:,:) = 0.e0
170         bfrva(:,:) = 0.e0
171         !
172      CASE( 1 )
173         IF(lwp) WRITE(numout,*) '      linear botton friction'
174         IF(lwp) WRITE(numout,*) '      friction coef.   rn_bfri1  = ', rn_bfri1
175         IF( ln_bfr2d ) THEN
176            IF(lwp) WRITE(numout,*) '      read coef. enhancement distribution from file   ln_bfr2d  = ', ln_bfr2d
177            IF(lwp) WRITE(numout,*) '      coef rn_bfri2 enhancement factor                rn_bfrien  = ',rn_bfrien
178         ENDIF
179         !
180         bfrcoef2d(:,:) = rn_bfri1  ! initialize bfrcoef2d to the namelist variable
181         !
182         IF(ln_bfr2d) THEN 
183            ! bfr_coef is a coefficient in [0,1] giving the mask where to apply the bfr enhancement
184            CALL iom_open('bfr_coef.nc',inum)
185            CALL iom_get (inum, jpdom_data, 'bfr_coef',bfrcoef2d,1) ! bfrcoef2d is used as tmp array
186            CALL iom_close(inum)
187            bfrcoef2d(:,:)= rn_bfri1 * ( 1 + rn_bfrien * bfrcoef2d(:,:) )
188         ENDIF
189         bfrua(:,:) = - bfrcoef2d(:,:)
190         bfrva(:,:) = - bfrcoef2d(:,:)
191         !
192      CASE( 2 )
193         IF(lwp) WRITE(numout,*) '      quadratic botton friction'
194         IF(lwp) WRITE(numout,*) '      friction coef.   rn_bfri2  = ', rn_bfri2
195         IF(lwp) WRITE(numout,*) '      background tke   rn_bfeb2  = ', rn_bfeb2
196         IF( ln_bfr2d ) THEN
197            IF(lwp) WRITE(numout,*) '      read coef. enhancement distribution from file   ln_bfr2d  = ', ln_bfr2d
198            IF(lwp) WRITE(numout,*) '      coef rn_bfri2 enhancement factor                rn_bfrien  = ',rn_bfrien
199         ENDIF
200         bfrcoef2d(:,:) = rn_bfri2  ! initialize bfrcoef2d to the namelist variable
201         !
202         IF(ln_bfr2d) THEN 
203            ! bfr_coef is a coefficient in [0,1] giving the mask where to apply the bfr enhancement
204            CALL iom_open('bfr_coef.nc',inum)
205            CALL iom_get (inum, jpdom_data, 'bfr_coef',bfrcoef2d,1) ! bfrcoef2d is used as tmp array
206            CALL iom_close(inum)
207            bfrcoef2d(:,:)= rn_bfri2 * ( 1 + rn_bfrien * bfrcoef2d(:,:) )
208         ENDIF
209         !
210      CASE DEFAULT
211         IF(lwp) WRITE(ctmp1,*) '         bad flag value for nn_bfr = ', nn_bfr
212         CALL ctl_stop( ctmp1 )
213         !
214      END SELECT
215      !
216      ! Basic stability check on bottom friction coefficient
217      !
218      ictu = 0               ! counter for stability criterion breaches at U-pts
219      ictv = 0               ! counter for stability criterion breaches at V-pts
220      zminbfr =  1.e10_wp    ! initialise tracker for minimum of bottom friction coefficient
221      zmaxbfr = -1.e10_wp    ! initialise tracker for maximum of bottom friction coefficient
222      !
223#  if defined key_vectopt_loop
224      DO jj = 1, 1
225!CDIR NOVERRCHK
226         DO ji = jpi+2, jpij-jpi-1   ! vector opt. (forced unrolling)
227#  else
228!CDIR NOVERRCHK
229      DO jj = 2, jpjm1
230!CDIR NOVERRCHK
231         DO ji = 2, jpim1
232#  endif
233             ikbu = mbku(ji,jj)       ! deepest ocean level at u- and v-points
234             ikbv = mbkv(ji,jj)
235             zfru = 0.5 * fse3u(ji,jj,ikbu) / rdt
236             zfrv = 0.5 * fse3v(ji,jj,ikbv) / rdt
237             IF( ABS( bfrcoef2d(ji,jj) ) > zfru ) THEN
238                IF( ln_ctl ) THEN
239                   WRITE(numout,*) 'BFR ', narea, nimpp+ji, njmpp+jj, ikbu
240                   WRITE(numout,*) 'BFR ', ABS( bfrcoef2d(ji,jj) ), zfru
241                ENDIF
242                ictu = ictu + 1
243             ENDIF
244             IF( ABS( bfrcoef2d(ji,jj) ) > zfrv ) THEN
245                 IF( ln_ctl ) THEN
246                     WRITE(numout,*) 'BFR ', narea, nimpp+ji, njmpp+jj, ikbv
247                     WRITE(numout,*) 'BFR ', bfrcoef2d(ji,jj), zfrv
248                 ENDIF
249                 ictv = ictv + 1
250             ENDIF
251             zminbfr = MIN(  zminbfr, MIN( zfru, ABS( bfrcoef2d(ji,jj) ) )  )
252             zmaxbfr = MAX(  zmaxbfr, MIN( zfrv, ABS( bfrcoef2d(ji,jj) ) )  )
253         END DO
254      END DO
255      IF( lk_mpp ) THEN
256         CALL mpp_sum( ictu )
257         CALL mpp_sum( ictv )
258         CALL mpp_min( zminbfr )
259         CALL mpp_max( zmaxbfr )
260      ENDIF
261      IF( lwp .AND. ictu + ictv > 0 ) THEN
262         WRITE(numout,*) ' Bottom friction stability check failed at ', ictu, ' U-points '
263         WRITE(numout,*) ' Bottom friction stability check failed at ', ictv, ' V-points '
264         WRITE(numout,*) ' Bottom friction coefficient now ranges from: ', zminbfr, ' to ', zmaxbfr
265         WRITE(numout,*) ' Bottom friction coefficient will be reduced where necessary'
266      ENDIF
267      !
268   END SUBROUTINE zdf_bfr_init
269
270   !!======================================================================
271END MODULE zdfbfr
Note: See TracBrowser for help on using the repository browser.