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/2011/dev_NEMO_MERGE_2011/NEMOGCM/NEMO/OPA_SRC/ZDF – NEMO

source: branches/2011/dev_NEMO_MERGE_2011/NEMOGCM/NEMO/OPA_SRC/ZDF/zdfbfr.F90 @ 3195

Last change on this file since 3195 was 3116, checked in by cetlod, 13 years ago

dev_NEMO_MERGE_2011: add in changes dev_NOC_UKMO_MERGE developments

  • Property svn:keywords set to Id
File size: 13.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   !                                    !!* Namelist nambfr: bottom friction namelist *
32   INTEGER  ::   nn_bfr    = 0           ! = 0/1/2/3 type of bottom friction
33   REAL(wp) ::   rn_bfri1  = 4.0e-4_wp   ! bottom drag coefficient (linear case)
34   REAL(wp) ::   rn_bfri2  = 1.0e-3_wp   ! bottom drag coefficient (non linear case)
35   REAL(wp) ::   rn_bfeb2  = 2.5e-3_wp   ! background bottom turbulent kinetic energy  [m2/s2]
36   REAL(wp) ::   rn_bfrien = 30._wp      ! local factor to enhance coefficient bfri
37   LOGICAL  ::   ln_bfr2d  = .false.     ! logical switch for 2D enhancement
38   LOGICAL , PUBLIC                            ::  ln_bfrimp = .false.  ! logical switch for implicit bottom friction
39   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) ::  bfrcoef2d            ! 2D bottom drag coefficient
40
41   !! * Substitutions
42#  include "vectopt_loop_substitute.h90"
43#  include "domzgr_substitute.h90"
44   !!----------------------------------------------------------------------
45   !! NEMO/OPA 4.0 , NEMO Consortium (2011)
46   !! $Id$
47   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
48   !!----------------------------------------------------------------------
49CONTAINS
50
51   INTEGER FUNCTION zdf_bfr_alloc()
52      !!----------------------------------------------------------------------
53      !!                ***  FUNCTION zdf_bfr_alloc  ***
54      !!----------------------------------------------------------------------
55      ALLOCATE( bfrcoef2d(jpi,jpj), STAT=zdf_bfr_alloc )
56      !
57      IF( lk_mpp             )   CALL mpp_sum ( zdf_bfr_alloc )
58      IF( zdf_bfr_alloc /= 0 )   CALL ctl_warn('zdf_bfr_alloc: failed to allocate arrays.')
59   END FUNCTION zdf_bfr_alloc
60
61
62   SUBROUTINE zdf_bfr( kt )
63      !!----------------------------------------------------------------------
64      !!                   ***  ROUTINE zdf_bfr  ***
65      !!                 
66      !! ** Purpose :   compute the bottom friction coefficient.
67      !!
68      !! ** Method  :   Calculate and store part of the momentum trend due   
69      !!              to bottom friction following the chosen friction type
70      !!              (free-slip, linear, or quadratic). The component
71      !!              calculated here is multiplied by the bottom velocity in
72      !!              dyn_bfr to provide the trend term.
73      !!                The coefficients are updated at each time step only
74      !!              in the quadratic case.
75      !!
76      !! ** Action  :   bfrua , bfrva   bottom friction coefficients
77      !!----------------------------------------------------------------------
78      INTEGER, INTENT( in ) ::   kt   ! ocean time-step index
79      !!
80      INTEGER  ::   ji, jj       ! dummy loop indices
81      INTEGER  ::   ikbu, ikbv   ! local integers
82      REAL(wp) ::   zvu, zuv, zecu, zecv   ! temporary scalars
83      !!----------------------------------------------------------------------
84
85      IF( nn_bfr == 2 ) THEN                 ! quadratic botton friction
86         ! Calculate and store the quadratic bottom friction coefficient bfrua and bfrva
87         ! where bfrUa = C_d*SQRT(u_bot^2 + v_bot^2 + e_b) {U=[u,v]}
88         ! from these the trend due to bottom friction:  -F_h/e3U  can be calculated
89         ! where -F_h/e3U_bot = bfrUa*Ub/e3U_bot {U=[u,v]}
90         !
91# if defined key_vectopt_loop
92         DO jj = 1, 1
93!CDIR NOVERRCHK
94            DO ji = jpi+2, jpij-jpi-1   ! vector opt. (forced unrolling)
95# else
96!CDIR NOVERRCHK
97         DO jj = 2, jpjm1
98!CDIR NOVERRCHK
99            DO ji = 2, jpim1
100# endif
101               ikbu = mbku(ji,jj)         ! ocean bottom level at u- and v-points
102               ikbv = mbkv(ji,jj)         ! (deepest ocean u- and v-points)
103               !
104               zvu  = 0.25 * (  vn(ji,jj  ,ikbu) + vn(ji+1,jj  ,ikbu)     &
105                  &           + vn(ji,jj-1,ikbu) + vn(ji+1,jj-1,ikbu)  )
106               zuv  = 0.25 * (  un(ji,jj  ,ikbv) + un(ji-1,jj  ,ikbv)     &
107                  &           + un(ji,jj+1,ikbv) + un(ji-1,jj+1,ikbv)  )
108               !
109               zecu = SQRT(  un(ji,jj,ikbu) * un(ji,jj,ikbu) + zvu*zvu + rn_bfeb2  )
110               zecv = SQRT(  vn(ji,jj,ikbv) * vn(ji,jj,ikbv) + zuv*zuv + rn_bfeb2  )
111               !
112               bfrua(ji,jj) = - 0.5_wp * ( bfrcoef2d(ji,jj) + bfrcoef2d(ji+1,jj  ) ) * zecu 
113               bfrva(ji,jj) = - 0.5_wp * ( 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, ln_bfrimp
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      !                              ! allocate zdfbfr arrays
157      IF( zdf_bfr_alloc() /= 0 )   CALL ctl_stop( 'STOP', 'zdf_bfr_init : unable to allocate arrays' )
158
159      !                              ! Make sure ln_zdfexp=.false. when use implicit bfr
160      IF( ln_bfrimp .AND. ln_zdfexp ) THEN
161         IF(lwp) THEN
162            WRITE(numout,*)
163            WRITE(numout,*) 'Implicit bottom friction can only be used when ln_zdfexp=.false.'
164            WRITE(numout,*) '         but you set: ln_bfrimp=.true. and ln_zdfexp=.true.!!!!'
165            WRITE(ctmp1,*)  '         bad ln_bfrimp value = .true.' 
166            CALL ctl_stop( ctmp1 )
167         END IF
168      END IF
169
170      SELECT CASE (nn_bfr)
171      !
172      CASE( 0 )
173         IF(lwp) WRITE(numout,*) '      free-slip '
174         bfrua(:,:) = 0.e0
175         bfrva(:,:) = 0.e0
176         !
177      CASE( 1 )
178         IF(lwp) WRITE(numout,*) '      linear botton friction'
179         IF(lwp) WRITE(numout,*) '      friction coef.   rn_bfri1  = ', rn_bfri1
180         IF( ln_bfr2d ) THEN
181            IF(lwp) WRITE(numout,*) '      read coef. enhancement distribution from file   ln_bfr2d  = ', ln_bfr2d
182            IF(lwp) WRITE(numout,*) '      coef rn_bfri2 enhancement factor                rn_bfrien  = ',rn_bfrien
183         ENDIF
184         !
185         bfrcoef2d(:,:) = rn_bfri1  ! initialize bfrcoef2d to the namelist variable
186         !
187         IF(ln_bfr2d) THEN 
188            ! bfr_coef is a coefficient in [0,1] giving the mask where to apply the bfr enhancement
189            CALL iom_open('bfr_coef.nc',inum)
190            CALL iom_get (inum, jpdom_data, 'bfr_coef',bfrcoef2d,1) ! bfrcoef2d is used as tmp array
191            CALL iom_close(inum)
192            bfrcoef2d(:,:) = rn_bfri1 * ( 1 + rn_bfrien * bfrcoef2d(:,:) )
193         ENDIF
194         bfrua(:,:) = - bfrcoef2d(:,:)
195         bfrva(:,:) = - bfrcoef2d(:,:)
196         !
197      CASE( 2 )
198         IF(lwp) WRITE(numout,*) '      quadratic botton friction'
199         IF(lwp) WRITE(numout,*) '      friction coef.   rn_bfri2  = ', rn_bfri2
200         IF(lwp) WRITE(numout,*) '      background tke   rn_bfeb2  = ', rn_bfeb2
201         IF( ln_bfr2d ) THEN
202            IF(lwp) WRITE(numout,*) '      read coef. enhancement distribution from file   ln_bfr2d  = ', ln_bfr2d
203            IF(lwp) WRITE(numout,*) '      coef rn_bfri2 enhancement factor                rn_bfrien  = ',rn_bfrien
204         ENDIF
205         bfrcoef2d(:,:) = rn_bfri2  ! initialize bfrcoef2d to the namelist variable
206         !
207         IF(ln_bfr2d) THEN 
208            ! bfr_coef is a coefficient in [0,1] giving the mask where to apply the bfr enhancement
209            CALL iom_open('bfr_coef.nc',inum)
210            CALL iom_get (inum, jpdom_data, 'bfr_coef',bfrcoef2d,1) ! bfrcoef2d is used as tmp array
211            CALL iom_close(inum)
212            bfrcoef2d(:,:)= rn_bfri2 * ( 1 + rn_bfrien * bfrcoef2d(:,:) )
213         ENDIF
214         !
215      CASE DEFAULT
216         IF(lwp) WRITE(ctmp1,*) '         bad flag value for nn_bfr = ', nn_bfr
217         CALL ctl_stop( ctmp1 )
218         !
219      END SELECT
220      IF(lwp) WRITE(numout,*) '      implicit bottom friction switch                ln_bfrimp  = ', ln_bfrimp
221      !
222      ! Basic stability check on bottom friction coefficient
223      !
224      ictu = 0               ! counter for stability criterion breaches at U-pts
225      ictv = 0               ! counter for stability criterion breaches at V-pts
226      zminbfr =  1.e10_wp    ! initialise tracker for minimum of bottom friction coefficient
227      zmaxbfr = -1.e10_wp    ! initialise tracker for maximum of bottom friction coefficient
228      !
229#  if defined key_vectopt_loop
230      DO jj = 1, 1
231!CDIR NOVERRCHK
232         DO ji = jpi+2, jpij-jpi-1   ! vector opt. (forced unrolling)
233#  else
234!CDIR NOVERRCHK
235      DO jj = 2, jpjm1
236!CDIR NOVERRCHK
237         DO ji = 2, jpim1
238#  endif
239             ikbu = mbku(ji,jj)       ! deepest ocean level at u- and v-points
240             ikbv = mbkv(ji,jj)
241             zfru = 0.5 * fse3u(ji,jj,ikbu) / rdt
242             zfrv = 0.5 * fse3v(ji,jj,ikbv) / rdt
243             IF( ABS( bfrcoef2d(ji,jj) ) > zfru ) THEN
244                IF( ln_ctl ) THEN
245                   WRITE(numout,*) 'BFR ', narea, nimpp+ji, njmpp+jj, ikbu
246                   WRITE(numout,*) 'BFR ', ABS( bfrcoef2d(ji,jj) ), zfru
247                ENDIF
248                ictu = ictu + 1
249             ENDIF
250             IF( ABS( bfrcoef2d(ji,jj) ) > zfrv ) THEN
251                 IF( ln_ctl ) THEN
252                     WRITE(numout,*) 'BFR ', narea, nimpp+ji, njmpp+jj, ikbv
253                     WRITE(numout,*) 'BFR ', bfrcoef2d(ji,jj), zfrv
254                 ENDIF
255                 ictv = ictv + 1
256             ENDIF
257             zminbfr = MIN(  zminbfr, MIN( zfru, ABS( bfrcoef2d(ji,jj) ) )  )
258             zmaxbfr = MAX(  zmaxbfr, MIN( zfrv, ABS( bfrcoef2d(ji,jj) ) )  )
259         END DO
260      END DO
261      IF( lk_mpp ) THEN
262         CALL mpp_sum( ictu )
263         CALL mpp_sum( ictv )
264         CALL mpp_min( zminbfr )
265         CALL mpp_max( zmaxbfr )
266      ENDIF
267      IF( lwp .AND. ictu + ictv > 0 ) THEN
268         WRITE(numout,*) ' Bottom friction stability check failed at ', ictu, ' U-points '
269         WRITE(numout,*) ' Bottom friction stability check failed at ', ictv, ' V-points '
270         WRITE(numout,*) ' Bottom friction coefficient now ranges from: ', zminbfr, ' to ', zmaxbfr
271         WRITE(numout,*) ' Bottom friction coefficient will be reduced where necessary'
272      ENDIF
273      !
274   END SUBROUTINE zdf_bfr_init
275
276   !!======================================================================
277END MODULE zdfbfr
Note: See TracBrowser for help on using the repository browser.