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
Line 
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
8   !!            3.3  !  2010-10  (C. Ethe, G. Madec) reorganisation of initialisation phase
9   !!----------------------------------------------------------------------
10#if defined key_zdftmx   ||   defined key_esopa
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
24   USE in_out_manager  ! I/O manager
25   USE iom             ! I/O Manager
26   USE wrk_nemo, ONLY: wrk_in_use, wrk_not_released
27
28   IMPLICIT NONE
29   PRIVATE
30
31   PUBLIC   zdf_tmx         ! called in step module
32   PUBLIC   zdf_tmx_init    ! called in opa module
33   PUBLIC   zdf_tmx_alloc   ! called in nemogcm module
34
35   LOGICAL, PUBLIC, PARAMETER ::   lk_zdftmx = .TRUE.    !: tidal mixing flag
36
37   !                                  !!* Namelist  namzdf_tmx : tidal mixing *
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)
44
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
48
49   !! * Substitutions
50#  include "domzgr_substitute.h90"
51#  include "vectopt_loop_substitute.h90"
52   !!----------------------------------------------------------------------
53   !! NEMO/OPA 4.0 , NEMO Consortium (2011)
54   !! $Id$
55   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
56   !!----------------------------------------------------------------------
57CONTAINS
58
59   INTEGER FUNCTION zdf_tmx_alloc()
60      !!----------------------------------------------------------------------
61      !!                ***  FUNCTION zdf_tmx_alloc  ***
62      !!----------------------------------------------------------------------
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')
67   END FUNCTION zdf_tmx_alloc
68
69
70   SUBROUTINE zdf_tmx( kt )
71      !!----------------------------------------------------------------------
72      !!                  ***  ROUTINE zdf_tmx  ***
73      !!                   
74      !! ** Purpose :   add to the vertical mixing coefficients the effect of
75      !!              tidal mixing (Simmons et al 2004).
76      !!
77      !! ** Method  : - tidal-induced vertical mixing is given by:
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.
88      !!
89      !!              - update av_tide in the Indonesian Through Flow area
90      !!              following Koch-Larrouy et al. (2007) parameterisation
91      !!              (see tmx_itf routine).
92      !!
93      !!              - update the model vertical eddy viscosity and diffusivity:
94      !!                     avt  = avt  +    av_tides
95      !!                     avm  = avm  +    av_tides
96      !!                     avmu = avmu + mi(av_tides)
97      !!                     avmv = avmv + mj(av_tides)
98      !!
99      !! ** Action  :   avt, avm, avmu, avmv   increased by tidal mixing
100      !!
101      !! References : Simmons et al. 2004, Ocean Modelling, 6, 3-4, 245-263.
102      !!              Koch-Larrouy et al. 2007, GRL.
103      !!----------------------------------------------------------------------
104      USE oce, zav_tide  =>   ua    ! use ua as workspace
105      USE wrk_nemo, ONLY: zkz => wrk_2d_1
106      !!
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
113      IF(wrk_in_use(2, 1))THEN
114         CALL ctl_stop('zdf_tmx : requested workspace array unavailable.')   ;   RETURN
115      END IF
116      !                          ! ----------------------- !
117      !                          !  Standard tidal mixing  !  (compute zav_tide)
118      !                          ! ----------------------- !
119      !                             !* First estimation (with n2 bound by rn_n2min) bounded by 60 cm2/s
120      zav_tide(:,:,:) = MIN(  60.e-4, az_tmx(:,:,:) / MAX( rn_n2min, rn2(:,:,:) )  )
121
122      zkz(:,:) = 0.e0               !* Associated potential energy consummed over the whole water column
123      DO jk = 2, jpkm1
124         zkz(:,:) = zkz(:,:) + fse3w(:,:,jk) * MAX( 0.e0, rn2(:,:,jk) ) * rau0 * zav_tide(:,:,jk)* tmask(:,:,jk)
125      END DO
126
127      DO jj = 1, jpj                !* Here zkz should be equal to en_tmx ==> multiply by en_tmx/zkz to recover en_tmx
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
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
135      END DO
136
137      IF( kt == nit000 ) THEN       !* check at first time-step: diagnose the energy consumed by zav_tide
138         ztpc = 0.e0
139         DO jk= 1, jpk
140            DO jj= 1, jpj
141               DO ji= 1, jpi
142                  ztpc = ztpc + fse3w(ji,jj,jk) * e1t(ji,jj) * e2t(ji,jj)   &
143                     &         * MAX( 0.e0, rn2(ji,jj,jk) ) * zav_tide(ji,jj,jk) * tmask(ji,jj,jk) * tmask_i(ji,jj)
144               END DO
145            END DO
146         END DO
147         ztpc= rau0 / ( rn_tfe * rn_me ) * ztpc
148         IF(lwp) WRITE(numout,*) 
149         IF(lwp) WRITE(numout,*) '          N Total power consumption by av_tide    : ztpc = ', ztpc * 1.e-12 ,'TW'
150      ENDIF
151       
152      !                          ! ----------------------- !
153      !                          !    ITF  tidal mixing    !  (update zav_tide)
154      !                          ! ----------------------- !
155      IF( ln_tmx_itf )   CALL tmx_itf( kt, zav_tide )
156
157      !                          ! ----------------------- !
158      !                          !   Update  mixing coefs  !                         
159      !                          ! ----------------------- !
160      DO jk = 2, jpkm1              !* update momentum & tracer diffusivity with tidal mixing
161         avt(:,:,jk) = avt(:,:,jk) + zav_tide(:,:,jk)
162         avm(:,:,jk) = avm(:,:,jk) + zav_tide(:,:,jk)
163         DO jj = 2, jpjm1
164            DO ji = fs_2, fs_jpim1  ! vector opt.
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)
167            END DO
168         END DO
169      END DO
170      CALL lbc_lnk( avmu, 'U', 1. )   ;   CALL lbc_lnk( avmv, 'V', 1. )      ! lateral boundary condition
171
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)
176      !
177      IF(wrk_not_released(2, 1))THEN
178         CALL ctl_stop('zdf_tmx : failed to release workspace array.')
179      END IF
180      !
181   END SUBROUTINE zdf_tmx
182
183
184   SUBROUTINE tmx_itf( kt, pav )
185      !!----------------------------------------------------------------------
186      !!                  ***  ROUTINE tmx_itf  ***
187      !!                   
188      !! ** Purpose :   modify the vertical eddy diffusivity coefficients
189      !!              (pav) in the Indonesian Through Flow area (ITF).
190      !!
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)
199      !!
200      !! ** Action  :   av_tide   updated in the ITF area (msk_itf)
201      !!
202      !! References :  Koch-Larrouy et al. 2007, GRL
203      !!----------------------------------------------------------------------
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      !!
210      INTEGER , INTENT(in   )                         ::   kt   ! ocean time-step
211      REAL(wp), INTENT(inout), DIMENSION(jpi,jpj,jpk) ::   pav  ! Tidal mixing coef.
212      !!
213      INTEGER  ::   ji, jj, jk    ! dummy loop indices
214      REAL(wp) ::   zcoef, ztpc   ! temporary scalar
215      !!----------------------------------------------------------------------
216      !
217      IF( wrk_in_use(2, 2,3,4,5) .OR. wrk_in_use(3, 1,2,3,4,5) )THEN
218         CALL ctl_stop('tmx_itf : requested workspace arrays unavailable.')
219         RETURN
220      END IF
221      !                             ! compute the form function using N2 at each time step
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
226!CDIR NOVERRCHK
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
229      END DO
230      !
231      zsum (:,:) = 0.e0
232      zsum1(:,:) = 0.e0
233      zsum2(:,:) = 0.e0
234      DO jk= 2, jpk
235         zsum1(:,:) = zsum1(:,:) + zempba_3d_1(:,:,jk) * fse3w(:,:,jk)
236         zsum2(:,:) = zsum2(:,:) + zempba_3d_2(:,:,jk) * fse3w(:,:,jk)               
237      END DO
238      DO jj = 1, jpj
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
243      END DO
244
245      DO jk= 1, jpk
246         DO jj = 1, jpj
247            DO ji = 1, jpi
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)
254            END DO
255         END DO
256       END DO
257       DO jj = 1, jpj
258          DO ji = 1, jpi
259             IF( zsum(ji,jj) > 0.e0 )   zsum(ji,jj) = 1.e0 / zsum(ji,jj)               
260          END DO
261       END DO
262
263      !                             ! first estimation bounded by 10 cm2/s (with n2 bounded by rn_n2min)
264      zcoef = rn_tfe_itf / ( rn_tfe * rau0 )
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)  )
268      END DO           
269
270      zkz(:,:) = 0.e0               ! Associated potential energy consummed over the whole water column
271      DO jk = 2, jpkm1
272         zkz(:,:) = zkz(:,:) + fse3w(:,:,jk) * MAX( 0.e0, rn2(:,:,jk) ) * rau0 * zavt_itf(:,:,jk) * tmask(:,:,jk)
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
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
283      END DO
284
285      IF( kt == nit000 ) THEN       ! diagnose the nergy consumed by zavt_itf
286         ztpc = 0.e0
287         DO jk= 1, jpk
288            DO jj= 1, jpj
289               DO ji= 1, jpi
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)
292               END DO
293            END DO
294         END DO
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'
297      ENDIF
298
299      !                             ! Update pav with the ITF mixing coefficient
300      DO jk = 2, jpkm1
301         pav(:,:,jk) = pav     (:,:,jk) * ( 1.e0 - mask_itf(:,:) )   &
302            &        + zavt_itf(:,:,jk) *          mask_itf(:,:) 
303      END DO
304      !
305      IF( wrk_not_released(2, 2,3,4,5) .OR. &
306          wrk_not_released(3, 1,2,3,4,5) )THEN
307         CALL ctl_stop('tmx_itf : failed to release workspace arrays.')
308      END IF
309      !
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
318      !!              of M2 and K1 tidal energy in nc files
319      !!
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      !!
330      !!              - Compute az_tmx, a 3D coefficient that allows to compute
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
338      !!
339      !! ** input   :   - Namlist namtmx
340      !!                - NetCDF file : M2_ORCA2.nc, K1_ORCA2.nc, and mask_itf.nc
341      !!
342      !! ** Action  : - Increase by 1 the nstop flag is setting problem encounter
343      !!              - defined az_tmx used to compute tidal-induced mixing
344      !!
345      !! References : Simmons et al. 2004, Ocean Modelling, 6, 3-4, 245-263.
346      !!              Koch-Larrouy et al. 2007, GRL.
347      !!----------------------------------------------------------------------
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
355      !!
356      INTEGER  ::   ji, jj, jk   ! dummy loop indices
357      INTEGER  ::   inum         ! local integer
358      REAL(wp) ::   ztpc, ze_z   ! local scalars
359      !!
360      NAMELIST/namzdf_tmx/ rn_htmx, rn_n2min, rn_tfe, rn_me, ln_tmx_itf, rn_tfe_itf
361      !!----------------------------------------------------------------------
362
363      IF( wrk_in_use(2, 1,2,3,4,5)  .OR.  wrk_in_use(3, 1)  ) THEN
364         CALL ctl_stop('zdf_tmx_init : requested workspace arrays unavailable.')   ;   RETURN
365      END IF
366
367      REWIND( numnam )               ! Read Namelist namtmx : Tidal Mixing
368      READ  ( numnam, namzdf_tmx )
369
370      IF(lwp) THEN                   ! Control print
371         WRITE(numout,*)
372         WRITE(numout,*) 'zdf_tmx_init : tidal mixing'
373         WRITE(numout,*) '~~~~~~~~~~~~'
374         WRITE(numout,*) '   Namelist namzdf_tmx : set tidal mixing parameters'
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
381      ENDIF
382
383      !                              ! allocate tmx arrays
384      IF( zdf_tmx_alloc() /= 0 )   CALL ctl_stop( 'STOP', 'zdf_tmx_init : unable to allocate tmx arrays' )
385
386      IF( ln_tmx_itf ) THEN          ! read the Indonesian Through Flow mask
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
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
407      ! Vertical structure (az_tmx)
408      DO jj = 1, jpj                ! part independent of the level
409         DO ji = 1, jpi
410            zhdep(ji,jj) = fsdepw(ji,jj,mbkt(ji,jj)+1)       ! depth of the ocean
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
426         ! zpc = rau0 * 1/rn_me * rn2 * zav_tide
427         zav_tide(:,:,:) = 0.e0
428         DO jk = 2, jpkm1
429            zav_tide(:,:,jk) = az_tmx(:,:,jk) / MAX( rn_n2min, rn2(:,:,jk) )
430         END DO
431
432         ztpc = 0.e0
433         zpc(:,:,:) = MAX(rn_n2min,rn2(:,:,:)) * zav_tide(:,:,:)
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
448         zav_tide(:,:,:) = MIN( zav_tide(:,:,:), 60.e-4 )   
449         zkz(:,:) = 0.e0
450         DO jk = 2, jpkm1
451         DO jj = 1, jpj
452            DO ji = 1, jpi
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)
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
476            zav_tide(:,:,jk) = zav_tide(:,:,jk) * MIN( zkz(:,:), 30./6. )   !kz max = 300 cm2/s
477         END DO
478         ztpc = 0.e0
479         zpc(:,:,:) = Max(0.e0,rn2(:,:,:)) * zav_tide(:,:,:)
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
491            ze_z =                  SUM( e1t(:,:) * e2t(:,:) * zav_tide(:,:,jk)     * tmask_i(:,:) )   &
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
496                  IF( zav_tide(ji,jj,jk) /= 0.e0 )   ztpc =Min( ztpc, zav_tide(ji,jj,jk) )
497               END DO
498            END DO
499            WRITE(numout,*) '            N2 min - jk= ', jk,'   ', ze_z * 1.e4,' cm2/s min= ',ztpc*1.e4,   &
500               &       'max= ', MAXVAL(zav_tide(:,:,jk) )*1.e4, ' cm2/s'
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
526      !
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' )
529      !
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
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
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.