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/devmercator2010_1/NEMO/OPA_SRC/ZDF – NEMO

source: branches/devmercator2010_1/NEMO/OPA_SRC/ZDF/zdfbfr.F90 @ 2132

Last change on this file since 2132 was 2132, checked in by cbricaud, 14 years ago

add change from DEV_r1784_GLS

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