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 @ 2281

Last change on this file since 2281 was 2281, checked in by smasson, 14 years ago

set proper svn properties to all files...

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