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

source: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/ZDF/zdftmx.F90 @ 2633

Last change on this file since 2633 was 2633, checked in by trackstand2, 13 years ago

Renamed wrk_use => wrk_in_use and wrk_release => wrk_not_released

  • Property svn:keywords set to Id
File size: 26.0 KB
RevLine 
[1418]1MODULE zdftmx
2   !!========================================================================
3   !!                       ***  MODULE  zdftmx  ***
4   !! Ocean physics: vertical tidal mixing coefficient
5   !!========================================================================
6   !! History :  1.0  !  2004-04  (L. Bessieres, G. Madec)  Original code
7   !!             -   !  2006-08  (A. Koch-Larrouy) Indonesian strait
[2528]8   !!            3.3  !  2010-10  (C. Ethe, G. Madec) reorganisation of initialisation phase
[1418]9   !!----------------------------------------------------------------------
[2616]10#if defined key_zdftmx   ||   defined key_esopa
[1418]11   !!----------------------------------------------------------------------
12   !!   'key_zdftmx'                                  Tidal vertical mixing
13   !!----------------------------------------------------------------------
14   !!   zdf_tmx      : global     momentum & tracer Kz with tidal induced Kz
15   !!   tmx_itf      : Indonesian momentum & tracer Kz with tidal induced Kz
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 lbclnk          ! ocean lateral boundary conditions (or mpp link)
21   USE eosbn2          ! ocean equation of state
22   USE phycst          ! physical constants
23   USE prtctl          ! Print control
[1496]24   USE in_out_manager  ! I/O manager
25   USE iom             ! I/O Manager
[2633]26   USE wrk_nemo, ONLY: wrk_in_use, wrk_not_released
[1418]27
28   IMPLICIT NONE
29   PRIVATE
30
[2528]31   PUBLIC   zdf_tmx         ! called in step module
32   PUBLIC   zdf_tmx_init    ! called in opa module
[2590]33   PUBLIC   zdf_tmx_alloc   ! called in nemogcm module
[1418]34
35   LOGICAL, PUBLIC, PARAMETER ::   lk_zdftmx = .TRUE.    !: tidal mixing flag
36
[1601]37   !                                  !!* Namelist  namzdf_tmx : tidal mixing *
[1518]38   REAL(wp) ::  rn_htmx    = 500.      ! vertical decay scale for turbulence (meters)
39   REAL(wp) ::  rn_n2min   = 1.e-8     ! threshold of the Brunt-Vaisala frequency (s-1)
40   REAL(wp) ::  rn_tfe     = 1./3.     ! tidal dissipation efficiency (St Laurent et al. 2002)
41   REAL(wp) ::  rn_me      = 0.2       ! mixing efficiency (Osborn 1980)
42   LOGICAL  ::  ln_tmx_itf = .TRUE.    ! Indonesian Through Flow (ITF): Koch-Larrouy et al. (2007) parameterization
43   REAL(wp) ::  rn_tfe_itf = 1.        ! ITF tidal dissipation efficiency (St Laurent et al. 2002)
[1418]44
[2590]45   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:)   ::   en_tmx     ! energy available for tidal mixing (W/m2)
46   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:)   ::   mask_itf   ! mask to use over Indonesian area
47   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   az_tmx     ! coefficient used to evaluate the tidal induced Kz
[1418]48
49   !! * Substitutions
50#  include "domzgr_substitute.h90"
51#  include "vectopt_loop_substitute.h90"
52   !!----------------------------------------------------------------------
[2616]53   !! NEMO/OPA 4.0 , NEMO Consortium (2011)
[2528]54   !! $Id$
[2616]55   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
[1418]56   !!----------------------------------------------------------------------
57CONTAINS
58
[2616]59   INTEGER FUNCTION zdf_tmx_alloc()
[2590]60      !!----------------------------------------------------------------------
[2616]61      !!                ***  FUNCTION zdf_tmx_alloc  ***
[2590]62      !!----------------------------------------------------------------------
[2616]63      ALLOCATE(en_tmx(jpi,jpj), mask_itf(jpi,jpj), az_tmx(jpi,jpj,jpk), STAT=zdf_tmx_alloc )
64      !
65      IF( lk_mpp             )   CALL mpp_sum ( zdf_tmx_alloc )
66      IF( zdf_tmx_alloc /= 0 )   CALL ctl_warn('zdf_tmx_alloc: failed to allocate arrays')
[2590]67   END FUNCTION zdf_tmx_alloc
68
69
[1418]70   SUBROUTINE zdf_tmx( kt )
71      !!----------------------------------------------------------------------
72      !!                  ***  ROUTINE zdf_tmx  ***
73      !!                   
74      !! ** Purpose :   add to the vertical mixing coefficients the effect of
[1496]75      !!              tidal mixing (Simmons et al 2004).
[1418]76      !!
77      !! ** Method  : - tidal-induced vertical mixing is given by:
[1496]78      !!                  Kz_tides = az_tmx / max( rn_n2min, N^2 )
79      !!              where az_tmx is a coefficient that specified the 3D space
80      !!              distribution of the faction of tidal energy taht is used
81      !!              for mixing. Its expression is set in zdf_tmx_init routine,
82      !!              following Simmons et al. 2004.
83      !!                NB: a specific bounding procedure is performed on av_tide
84      !!              so that the input tidal energy is actually almost used. The
85      !!              basic maximum value is 60 cm2/s, but values of 300 cm2/s
86      !!              can be reached in area where bottom stratification is too
87      !!              weak.
[1418]88      !!
[1496]89      !!              - update av_tide in the Indonesian Through Flow area
90      !!              following Koch-Larrouy et al. (2007) parameterisation
91      !!              (see tmx_itf routine).
[1418]92      !!
[1496]93      !!              - update the model vertical eddy viscosity and diffusivity:
94      !!                     avt  = avt  +    av_tides
[1527]95      !!                     avm  = avm  +    av_tides
[1496]96      !!                     avmu = avmu + mi(av_tides)
97      !!                     avmv = avmv + mj(av_tides)
98      !!
[1527]99      !! ** Action  :   avt, avm, avmu, avmv   increased by tidal mixing
[1496]100      !!
[1418]101      !! References : Simmons et al. 2004, Ocean Modelling, 6, 3-4, 245-263.
[1496]102      !!              Koch-Larrouy et al. 2007, GRL.
[1418]103      !!----------------------------------------------------------------------
[1601]104      USE oce, zav_tide  =>   ua    ! use ua as workspace
[2590]105      USE wrk_nemo, ONLY: zkz => wrk_2d_1
[1546]106      !!
[1418]107      INTEGER, INTENT(in) ::   kt   ! ocean time-step
108      !!
109      INTEGER  ::   ji, jj, jk   ! dummy loop indices
110      REAL(wp) ::   ztpc         ! scalar workspace
111      !!----------------------------------------------------------------------
112
[2633]113      IF(wrk_in_use(2, 1))THEN
[2616]114         CALL ctl_stop('zdf_tmx : requested workspace array unavailable.')   ;   RETURN
[2590]115      END IF
[1546]116      !                          ! ----------------------- !
117      !                          !  Standard tidal mixing  !  (compute zav_tide)
118      !                          ! ----------------------- !
[1496]119      !                             !* First estimation (with n2 bound by rn_n2min) bounded by 60 cm2/s
[1546]120      zav_tide(:,:,:) = MIN(  60.e-4, az_tmx(:,:,:) / MAX( rn_n2min, rn2(:,:,:) )  )
[1418]121
[1496]122      zkz(:,:) = 0.e0               !* Associated potential energy consummed over the whole water column
[1418]123      DO jk = 2, jpkm1
[1546]124         zkz(:,:) = zkz(:,:) + fse3w(:,:,jk) * MAX( 0.e0, rn2(:,:,jk) ) * rau0 * zav_tide(:,:,jk)* tmask(:,:,jk)
[1418]125      END DO
126
[1496]127      DO jj = 1, jpj                !* Here zkz should be equal to en_tmx ==> multiply by en_tmx/zkz to recover en_tmx
[1418]128         DO ji = 1, jpi
129            IF( zkz(ji,jj) /= 0.e0 )   zkz(ji,jj) = en_tmx(ji,jj) / zkz(ji,jj)
130         END DO
131      END DO
132
[1546]133      DO jk = 2, jpkm1              !* Mutiply by zkz to recover en_tmx, BUT bound by 30/6 ==> zav_tide bound by 300 cm2/s
134         zav_tide(:,:,jk) = zav_tide(:,:,jk) * MIN( zkz(:,:), 30./6. )   !kz max = 300 cm2/s
[1418]135      END DO
136
[1546]137      IF( kt == nit000 ) THEN       !* check at first time-step: diagnose the energy consumed by zav_tide
[1418]138         ztpc = 0.e0
139         DO jk= 1, jpk
140            DO jj= 1, jpj
141               DO ji= 1, jpi
[1496]142                  ztpc = ztpc + fse3w(ji,jj,jk) * e1t(ji,jj) * e2t(ji,jj)   &
[1546]143                     &         * MAX( 0.e0, rn2(ji,jj,jk) ) * zav_tide(ji,jj,jk) * tmask(ji,jj,jk) * tmask_i(ji,jj)
[1418]144               END DO
145            END DO
146         END DO
[1495]147         ztpc= rau0 / ( rn_tfe * rn_me ) * ztpc
[1418]148         IF(lwp) WRITE(numout,*) 
[1496]149         IF(lwp) WRITE(numout,*) '          N Total power consumption by av_tide    : ztpc = ', ztpc * 1.e-12 ,'TW'
[1418]150      ENDIF
[1495]151       
[1546]152      !                          ! ----------------------- !
153      !                          !    ITF  tidal mixing    !  (update zav_tide)
154      !                          ! ----------------------- !
155      IF( ln_tmx_itf )   CALL tmx_itf( kt, zav_tide )
[1418]156
[1546]157      !                          ! ----------------------- !
158      !                          !   Update  mixing coefs  !                         
159      !                          ! ----------------------- !
[1495]160      DO jk = 2, jpkm1              !* update momentum & tracer diffusivity with tidal mixing
[1546]161         avt(:,:,jk) = avt(:,:,jk) + zav_tide(:,:,jk)
162         avm(:,:,jk) = avm(:,:,jk) + zav_tide(:,:,jk)
[1418]163         DO jj = 2, jpjm1
164            DO ji = fs_2, fs_jpim1  ! vector opt.
[1546]165               avmu(ji,jj,jk) = avmu(ji,jj,jk) + 0.5 * ( zav_tide(ji,jj,jk) + zav_tide(ji+1,jj  ,jk) ) * umask(ji,jj,jk)
166               avmv(ji,jj,jk) = avmv(ji,jj,jk) + 0.5 * ( zav_tide(ji,jj,jk) + zav_tide(ji  ,jj+1,jk) ) * vmask(ji,jj,jk)
[1418]167            END DO
168         END DO
169      END DO
[1496]170      CALL lbc_lnk( avmu, 'U', 1. )   ;   CALL lbc_lnk( avmv, 'V', 1. )      ! lateral boundary condition
[1418]171
[1546]172      !                             !* output tidal mixing coefficient
173      CALL iom_put( "av_tide", zav_tide )
174
175      IF(ln_ctl)   CALL prt_ctl(tab3d_1=zav_tide , clinfo1=' tmx - av_tide: ', tab3d_2=avt, clinfo2=' avt: ', ovlap=1, kdim=jpk)
[1418]176      !
[2633]177      IF(wrk_not_released(2, 1))THEN
[2590]178         CALL ctl_stop('zdf_tmx : failed to release workspace array.')
179      END IF
180      !
[1418]181   END SUBROUTINE zdf_tmx
182
183
[1546]184   SUBROUTINE tmx_itf( kt, pav )
[1418]185      !!----------------------------------------------------------------------
186      !!                  ***  ROUTINE tmx_itf  ***
187      !!                   
[1496]188      !! ** Purpose :   modify the vertical eddy diffusivity coefficients
[1546]189      !!              (pav) in the Indonesian Through Flow area (ITF).
[1418]190      !!
[1496]191      !! ** Method  : - Following Koch-Larrouy et al. (2007), in the ITF defined
192      !!                by msk_itf (read in a file, see tmx_init), the tidal
193      !!                mixing coefficient is computed with :
194      !!                  * q=1 (i.e. all the tidal energy remains trapped in
195      !!                         the area and thus is used for mixing)
196      !!                  * the vertical distribution of the tifal energy is a
197      !!                    proportional to N above the thermocline (d(N^2)/dz > 0)
198      !!                    and to N^2 below the thermocline (d(N^2)/dz < 0)
[1418]199      !!
[1496]200      !! ** Action  :   av_tide   updated in the ITF area (msk_itf)
[1418]201      !!
202      !! References :  Koch-Larrouy et al. 2007, GRL
203      !!----------------------------------------------------------------------
[2590]204      USE wrk_nemo, ONLY: zkz => wrk_2d_5
205      USE wrk_nemo, ONLY: zsum1 => wrk_2d_2, zsum2 => wrk_2d_3, zsum => wrk_2d_4
206      USE wrk_nemo, ONLY: zempba_3d_1 => wrk_3d_1, zempba_3d_2 => wrk_3d_2
207      USE wrk_nemo, ONLY: zempba_3d   => wrk_3d_3, zdn2dz      => wrk_3d_4
208      USE wrk_nemo, ONLY: zavt_itf    => wrk_3d_5
209      !!
[1546]210      INTEGER , INTENT(in   )                         ::   kt   ! ocean time-step
211      REAL(wp), INTENT(inout), DIMENSION(jpi,jpj,jpk) ::   pav  ! Tidal mixing coef.
[1418]212      !!
[1495]213      INTEGER  ::   ji, jj, jk    ! dummy loop indices
214      REAL(wp) ::   zcoef, ztpc   ! temporary scalar
[1418]215      !!----------------------------------------------------------------------
[2590]216      !
[2633]217      IF( wrk_in_use(2, 2,3,4,5) .OR. wrk_in_use(3, 1,2,3,4,5) )THEN
[2590]218         CALL ctl_stop('tmx_itf : requested workspace arrays unavailable.')
219         RETURN
220      END IF
[1418]221      !                             ! compute the form function using N2 at each time step
[1518]222      zempba_3d_1(:,:,jpk) = 0.e0
223      zempba_3d_2(:,:,jpk) = 0.e0
224      DO jk = 1, jpkm1             
225         zdn2dz     (:,:,jk) = rn2(:,:,jk) - rn2(:,:,jk+1)           ! Vertical profile of dN2/dz
[1495]226!CDIR NOVERRCHK
[1518]227         zempba_3d_1(:,:,jk) = SQRT(  MAX( 0.e0, rn2(:,:,jk) )  )    !    -        -    of N
228         zempba_3d_2(:,:,jk) =        MAX( 0.e0, rn2(:,:,jk) )       !    -        -    of N^2
[1418]229      END DO
[1518]230      !
231      zsum (:,:) = 0.e0
232      zsum1(:,:) = 0.e0
233      zsum2(:,:) = 0.e0
[1418]234      DO jk= 2, jpk
[1518]235         zsum1(:,:) = zsum1(:,:) + zempba_3d_1(:,:,jk) * fse3w(:,:,jk)
236         zsum2(:,:) = zsum2(:,:) + zempba_3d_2(:,:,jk) * fse3w(:,:,jk)               
[1418]237      END DO
238      DO jj = 1, jpj
[1518]239         DO ji = 1, jpi
240            IF( zsum1(ji,jj) /= 0.e0 )   zsum1(ji,jj) = 1.e0 / zsum1(ji,jj)
241            IF( zsum2(ji,jj) /= 0.e0 )   zsum2(ji,jj) = 1.e0 / zsum2(ji,jj)               
242         END DO
[1418]243      END DO
244
245      DO jk= 1, jpk
246         DO jj = 1, jpj
247            DO ji = 1, jpi
[1518]248               zcoef = 0.5 - SIGN( 0.5, zdn2dz(ji,jj,jk) )       ! =0 if dN2/dz > 0, =1 otherwise
249               ztpc  = zempba_3d_1(ji,jj,jk) * zsum1(ji,jj) *        zcoef     &
250                  &  + zempba_3d_2(ji,jj,jk) * zsum2(ji,jj) * ( 1. - zcoef )
251               !
252               zempba_3d(ji,jj,jk) =               ztpc 
253               zsum     (ji,jj)    = zsum(ji,jj) + ztpc * fse3w(ji,jj,jk)
[1418]254            END DO
255         END DO
256       END DO
257       DO jj = 1, jpj
258          DO ji = 1, jpi
[1518]259             IF( zsum(ji,jj) > 0.e0 )   zsum(ji,jj) = 1.e0 / zsum(ji,jj)               
[1418]260          END DO
261       END DO
262
[1495]263      !                             ! first estimation bounded by 10 cm2/s (with n2 bounded by rn_n2min)
264      zcoef = rn_tfe_itf / ( rn_tfe * rau0 )
[1518]265      DO jk = 1, jpk
266         zavt_itf(:,:,jk) = MIN(  10.e-4, zcoef * en_tmx(:,:) * zsum(:,:) * zempba_3d(:,:,jk)   &
267            &                                      / MAX( rn_n2min, rn2(:,:,jk) ) * tmask(:,:,jk)  )
[1495]268      END DO           
[1418]269
270      zkz(:,:) = 0.e0               ! Associated potential energy consummed over the whole water column
271      DO jk = 2, jpkm1
[1495]272         zkz(:,:) = zkz(:,:) + fse3w(:,:,jk) * MAX( 0.e0, rn2(:,:,jk) ) * rau0 * zavt_itf(:,:,jk) * tmask(:,:,jk)
[1418]273      END DO
274
275      DO jj = 1, jpj                ! Here zkz should be equal to en_tmx ==> multiply by en_tmx/zkz to recover en_tmx
276         DO ji = 1, jpi
277            IF( zkz(ji,jj) /= 0.e0 )   zkz(ji,jj) = en_tmx(ji,jj) * rn_tfe_itf / rn_tfe / zkz(ji,jj)
278         END DO
279      END DO
280
[1495]281      DO jk = 2, jpkm1              ! Mutiply by zkz to recover en_tmx, BUT bound by 30/6 ==> zavt_itf bound by 300 cm2/s
282         zavt_itf(:,:,jk) = zavt_itf(:,:,jk) * MIN( zkz(:,:), 120./10. )   ! kz max = 120 cm2/s
[1418]283      END DO
284
[1495]285      IF( kt == nit000 ) THEN       ! diagnose the nergy consumed by zavt_itf
[1418]286         ztpc = 0.e0
287         DO jk= 1, jpk
288            DO jj= 1, jpj
289               DO ji= 1, jpi
[1495]290                  ztpc = ztpc + e1t(ji,jj) * e2t(ji,jj) * fse3w(ji,jj,jk) * MAX( 0.e0, rn2(ji,jj,jk) )   &
291                     &                     * zavt_itf(ji,jj,jk) * tmask(ji,jj,jk) * tmask_i(ji,jj)
[1418]292               END DO
293            END DO
294         END DO
[1495]295         ztpc= rau0 * ztpc / ( rn_me * rn_tfe_itf )
296         IF(lwp) WRITE(numout,*) '          N Total power consumption by zavt_itf: ztpc = ', ztpc * 1.e-12 ,'TW'
[1418]297      ENDIF
298
[1546]299      !                             ! Update pav with the ITF mixing coefficient
[1418]300      DO jk = 2, jpkm1
[1546]301         pav(:,:,jk) = pav     (:,:,jk) * ( 1.e0 - mask_itf(:,:) )   &
302            &        + zavt_itf(:,:,jk) *          mask_itf(:,:) 
[1418]303      END DO
304      !
[2633]305      IF( wrk_not_released(2, 2,3,4,5) .OR. &
306          wrk_not_released(3, 1,2,3,4,5) )THEN
[2590]307         CALL ctl_stop('tmx_itf : failed to release workspace arrays.')
308      END IF
309      !
[1418]310   END SUBROUTINE tmx_itf
311
312
313   SUBROUTINE zdf_tmx_init
314      !!----------------------------------------------------------------------
315      !!                  ***  ROUTINE zdf_tmx_init  ***
316      !!                     
317      !! ** Purpose :   Initialization of the vertical tidal mixing, Reading
[1496]318      !!              of M2 and K1 tidal energy in nc files
[1418]319      !!
[1496]320      !! ** Method  : - Read the namtmx namelist and check the parameters
321      !!
322      !!              - Read the input data in NetCDF files :
323      !!              M2 and K1 tidal energy. The total tidal energy, en_tmx,
324      !!              is the sum of M2, K1 and S2 energy where S2 is assumed
325      !!              to be: S2=(1/2)^2 * M2
326      !!              mask_itf, a mask array that determine where substituing
327      !!              the standard Simmons et al. (2005) formulation with the
328      !!              one of Koch_Larrouy et al. (2007).
329      !!
[1418]330      !!              - Compute az_tmx, a 3D coefficient that allows to compute
[1496]331      !!             the standard tidal-induced vertical mixing as follows:
332      !!                  Kz_tides = az_tmx / max( rn_n2min, N^2 )
333      !!             with az_tmx a bottom intensified coefficient is given by:
334      !!                 az_tmx(z) = en_tmx / ( rau0 * rn_htmx ) * EXP( -(H-z)/rn_htmx )
335      !!                                                  / ( 1. - EXP( - H   /rn_htmx ) )
336      !!             where rn_htmx the characteristic length scale of the bottom
337      !!             intensification, en_tmx the tidal energy, and H the ocean depth
[1418]338      !!
339      !! ** input   :   - Namlist namtmx
[1496]340      !!                - NetCDF file : M2_ORCA2.nc, K1_ORCA2.nc, and mask_itf.nc
[1418]341      !!
342      !! ** Action  : - Increase by 1 the nstop flag is setting problem encounter
343      !!              - defined az_tmx used to compute tidal-induced mixing
[1496]344      !!
345      !! References : Simmons et al. 2004, Ocean Modelling, 6, 3-4, 245-263.
346      !!              Koch-Larrouy et al. 2007, GRL.
[1418]347      !!----------------------------------------------------------------------
[2616]348      USE oce     ,         zav_tide =>  ua         ! ua used as workspace
349      USE wrk_nemo, ONLY:   zem2     =>  wrk_2d_1   ! read M2 and
350      USE wrk_nemo, ONLY:   zek1     =>  wrk_2d_2   ! K1 tidal energy
351      USE wrk_nemo, ONLY:   zkz      =>  wrk_2d_3   ! total M2, K1 and S2 tidal energy
352      USE wrk_nemo, ONLY:   zfact    =>  wrk_2d_4   ! used for vertical structure function
353      USE wrk_nemo, ONLY:   zhdep    =>  wrk_2d_5   ! Ocean depth
354      USE wrk_nemo, ONLY:   zpc      =>  wrk_3d_1   ! power consumption
[1546]355      !!
[2616]356      INTEGER  ::   ji, jj, jk   ! dummy loop indices
357      INTEGER  ::   inum         ! local integer
358      REAL(wp) ::   ztpc, ze_z   ! local scalars
[1496]359      !!
[1601]360      NAMELIST/namzdf_tmx/ rn_htmx, rn_n2min, rn_tfe, rn_me, ln_tmx_itf, rn_tfe_itf
[1418]361      !!----------------------------------------------------------------------
362
[2633]363      IF( wrk_in_use(2, 1,2,3,4,5)  .OR.  wrk_in_use(3, 1)  ) THEN
[2616]364         CALL ctl_stop('zdf_tmx_init : requested workspace arrays unavailable.')   ;   RETURN
[2590]365      END IF
366
[1601]367      REWIND( numnam )               ! Read Namelist namtmx : Tidal Mixing
368      READ  ( numnam, namzdf_tmx )
[1537]369
370      IF(lwp) THEN                   ! Control print
[1418]371         WRITE(numout,*)
372         WRITE(numout,*) 'zdf_tmx_init : tidal mixing'
373         WRITE(numout,*) '~~~~~~~~~~~~'
[1601]374         WRITE(numout,*) '   Namelist namzdf_tmx : set tidal mixing parameters'
[1537]375         WRITE(numout,*) '      Vertical decay scale for turbulence   = ', rn_htmx 
376         WRITE(numout,*) '      Brunt-Vaisala frequency threshold     = ', rn_n2min
377         WRITE(numout,*) '      Tidal dissipation efficiency          = ', rn_tfe
378         WRITE(numout,*) '      Mixing efficiency                     = ', rn_me
379         WRITE(numout,*) '      ITF specific parameterisation         = ', ln_tmx_itf
380         WRITE(numout,*) '      ITF tidal dissipation efficiency      = ', rn_tfe_itf
[1418]381      ENDIF
382
[2616]383      !                              ! allocate tmx arrays
384      IF( zdf_tmx_alloc() /= 0 )   CALL ctl_stop( 'STOP', 'zdf_tmx_init : unable to allocate tmx arrays' )
385
[1537]386      IF( ln_tmx_itf ) THEN          ! read the Indonesian Through Flow mask
[1518]387         CALL iom_open('mask_itf',inum)
388         CALL iom_get (inum, jpdom_data, 'tmaskitf',mask_itf,1) !
389         CALL iom_close(inum)
390      ENDIF
[1418]391
392      ! read M2 tidal energy flux : W/m2  ( zem2 < 0 )
393      CALL iom_open('M2rowdrg',inum)
394      CALL iom_get (inum, jpdom_data, 'field',zem2,1) !
395      CALL iom_close(inum)
396
397      ! read K1 tidal energy flux : W/m2  ( zek1 < 0 )
398      CALL iom_open('K1rowdrg',inum)
399      CALL iom_get (inum, jpdom_data, 'field',zek1,1) !
400      CALL iom_close(inum)
401 
402      ! Total tidal energy ( M2, S2 and K1  with S2=(1/2)^2 * M2 )
403      ! only the energy available for mixing is taken into account,
404      ! (mixing efficiency tidal dissipation efficiency)
405      en_tmx(:,:) = - rn_tfe * rn_me * ( zem2(:,:) * 1.25 + zek1(:,:) ) * tmask(:,:,1)
406
[1496]407      ! Vertical structure (az_tmx)
408      DO jj = 1, jpj                ! part independent of the level
[1418]409         DO ji = 1, jpi
[2528]410            zhdep(ji,jj) = fsdepw(ji,jj,mbkt(ji,jj)+1)       ! depth of the ocean
[1418]411            zfact(ji,jj) = rau0 * rn_htmx * ( 1. - EXP( -zhdep(ji,jj) / rn_htmx ) )
412            IF( zfact(ji,jj) /= 0 )   zfact(ji,jj) = en_tmx(ji,jj) / zfact(ji,jj)
413         END DO
414      END DO
415      DO jk= 1, jpk                 ! complete with the level-dependent part
416         DO jj = 1, jpj
417            DO ji = 1, jpi
418               az_tmx(ji,jj,jk) = zfact(ji,jj) * EXP( -( zhdep(ji,jj)-fsdepw(ji,jj,jk) ) / rn_htmx ) * tmask(ji,jj,jk)
419            END DO
420         END DO
421      END DO
422
423      IF( nprint == 1 .AND. lwp ) THEN
424         ! Control print
425         ! Total power consumption due to vertical mixing
[1546]426         ! zpc = rau0 * 1/rn_me * rn2 * zav_tide
427         zav_tide(:,:,:) = 0.e0
[1418]428         DO jk = 2, jpkm1
[1546]429            zav_tide(:,:,jk) = az_tmx(:,:,jk) / MAX( rn_n2min, rn2(:,:,jk) )
[1418]430         END DO
431
432         ztpc = 0.e0
[1546]433         zpc(:,:,:) = MAX(rn_n2min,rn2(:,:,:)) * zav_tide(:,:,:)
[1418]434         DO jk= 2, jpkm1
435            DO jj = 1, jpj
436               DO ji = 1, jpi
437                  ztpc = ztpc + fse3w(ji,jj,jk) * e1t(ji,jj) * e2t(ji,jj) * zpc(ji,jj,jk) * tmask(ji,jj,jk) * tmask_i(ji,jj)
438               END DO
439            END DO
440         END DO
441         ztpc= rau0 * 1/(rn_tfe * rn_me) * ztpc
442
443         WRITE(numout,*) 
444         WRITE(numout,*) '          Total power consumption of the tidally driven part of Kz : ztpc = ', ztpc * 1.e-12 ,'TW'
445
446
447         ! control print 2
[1546]448         zav_tide(:,:,:) = MIN( zav_tide(:,:,:), 60.e-4 )   
[1418]449         zkz(:,:) = 0.e0
450         DO jk = 2, jpkm1
451         DO jj = 1, jpj
452            DO ji = 1, jpi
[1546]453               zkz(ji,jj) = zkz(ji,jj) + fse3w(ji,jj,jk) * MAX( 0.e0, rn2(ji,jj,jk) ) * rau0 * zav_tide(ji,jj,jk)* tmask(ji,jj,jk)
[1418]454            END DO
455         END DO
456         END DO
457         ! Here zkz should be equal to en_tmx ==> multiply by en_tmx/zkz
458         DO jj = 1, jpj
459            DO ji = 1, jpi
460               IF( zkz(ji,jj) /= 0.e0 )   THEN
461                   zkz(ji,jj) = en_tmx(ji,jj) / zkz(ji,jj)
462               ENDIF
463            END DO
464         END DO
465         ztpc = 1.e50
466         DO jj = 1, jpj
467            DO ji = 1, jpi
468               IF( zkz(ji,jj) /= 0.e0 )   THEN
469                   ztpc = Min( zkz(ji,jj), ztpc)
470               ENDIF
471            END DO
472         END DO
473         WRITE(numout,*) '          Min de zkz ', ztpc, ' Max = ', maxval(zkz(:,:) )
474
475         DO jk = 2, jpkm1
[1546]476            zav_tide(:,:,jk) = zav_tide(:,:,jk) * MIN( zkz(:,:), 30./6. )   !kz max = 300 cm2/s
[1418]477         END DO
478         ztpc = 0.e0
[1546]479         zpc(:,:,:) = Max(0.e0,rn2(:,:,:)) * zav_tide(:,:,:)
[1418]480         DO jk= 1, jpk
481            DO jj = 1, jpj
482               DO ji = 1, jpi
483                  ztpc = ztpc + fse3w(ji,jj,jk) * e1t(ji,jj) * e2t(ji,jj) * zpc(ji,jj,jk) * tmask(ji,jj,jk) * tmask_i(ji,jj)
484               END DO
485            END DO
486         END DO
487         ztpc= rau0 * 1/(rn_tfe * rn_me) * ztpc
488         WRITE(numout,*) '          2 Total power consumption of the tidally driven part of Kz : ztpc = ', ztpc * 1.e-12 ,'TW'
489
490         DO jk = 1, jpk
[1546]491            ze_z =                  SUM( e1t(:,:) * e2t(:,:) * zav_tide(:,:,jk)     * tmask_i(:,:) )   &
[1418]492               &     / MAX( 1.e-20, SUM( e1t(:,:) * e2t(:,:) * tmask (:,:,jk) * tmask_i(:,:) ) )
493            ztpc = 1.E50
494            DO jj = 1, jpj
495               DO ji = 1, jpi
[1546]496                  IF( zav_tide(ji,jj,jk) /= 0.e0 )   ztpc =Min( ztpc, zav_tide(ji,jj,jk) )
[1418]497               END DO
498            END DO
499            WRITE(numout,*) '            N2 min - jk= ', jk,'   ', ze_z * 1.e4,' cm2/s min= ',ztpc*1.e4,   &
[1546]500               &       'max= ', MAXVAL(zav_tide(:,:,jk) )*1.e4, ' cm2/s'
[1418]501         END DO
502
503         WRITE(numout,*) '          e_tide : ', SUM( e1t*e2t*en_tmx ) / ( rn_tfe * rn_me ) * 1.e-12, 'TW'
504         WRITE(numout,*) 
505         WRITE(numout,*) '          Initial profile of tidal vertical mixing'
506         DO jk = 1, jpk
507            DO jj = 1,jpj
508               DO ji = 1,jpi
509                  zkz(ji,jj) = az_tmx(ji,jj,jk) /MAX( rn_n2min, rn2(ji,jj,jk) )
510               END DO
511            END DO
512            ze_z =                  SUM( e1t(:,:) * e2t(:,:) * zkz(:,:)     * tmask_i(:,:) )   &
513               &     / MAX( 1.e-20, SUM( e1t(:,:) * e2t(:,:) * tmask (:,:,jk) * tmask_i(:,:) ) )
514            WRITE(numout,*) '                jk= ', jk,'   ', ze_z * 1.e4,' cm2/s'
515         END DO
516         DO jk = 1, jpk
517            zkz(:,:) = az_tmx(:,:,jk) /rn_n2min
518            ze_z =                  SUM( e1t(:,:) * e2t(:,:) * zkz(:,:)     * tmask_i(:,:) )   &
519               &     / MAX( 1.e-20, SUM( e1t(:,:) * e2t(:,:) * tmask (:,:,jk) * tmask_i(:,:) ) )
520            WRITE(numout,*) 
521            WRITE(numout,*) '          N2 min - jk= ', jk,'   ', ze_z * 1.e4,' cm2/s min= ',MINVAL(zkz)*1.e4,   &
522               &       'max= ', MAXVAL(zkz)*1.e4, ' cm2/s'
523         END DO
524         !
525      ENDIF
[2528]526      !
[2633]527      IF(wrk_not_released(2, 1,2,3,4,5) .OR.   &
528         wrk_not_released(3, 1)          )   CALL ctl_stop( 'zdf_tmx_init : failed to release workspace arrays' )
[2590]529      !
[1418]530   END SUBROUTINE zdf_tmx_init
531
532#else
533   !!----------------------------------------------------------------------
534   !!   Default option          Dummy module                NO Tidal MiXing
535   !!----------------------------------------------------------------------
536   LOGICAL, PUBLIC, PARAMETER ::   lk_zdftmx = .FALSE.   !: tidal mixing flag
537CONTAINS
[2528]538   SUBROUTINE zdf_tmx_init           ! Dummy routine
539      WRITE(*,*) 'zdf_tmx: You should not have seen this print! error?'
540   END SUBROUTINE zdf_tmx_init
541   SUBROUTINE zdf_tmx( kt )          ! Dummy routine
[1418]542      WRITE(*,*) 'zdf_tmx: You should not have seen this print! error?', kt
543   END SUBROUTINE zdf_tmx
544#endif
545
546   !!======================================================================
547END MODULE zdftmx
Note: See TracBrowser for help on using the repository browser.