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.
zdfmxl.F90 in branches/UKMO/test_moci_test_suite_namelist_read/NEMOGCM/NEMO/OPA_SRC/ZDF – NEMO

source: branches/UKMO/test_moci_test_suite_namelist_read/NEMOGCM/NEMO/OPA_SRC/ZDF/zdfmxl.F90 @ 9366

Last change on this file since 9366 was 9366, checked in by andmirek, 6 years ago

#2050 first version. Compiled OK in moci test suite

File size: 24.2 KB
Line 
1MODULE zdfmxl
2   !!======================================================================
3   !!                       ***  MODULE  zdfmxl  ***
4   !! Ocean physics: mixed layer depth
5   !!======================================================================
6   !! History :  1.0  ! 2003-08  (G. Madec)  original code
7   !!            3.2  ! 2009-07  (S. Masson, G. Madec)  IOM + merge of DO-loop
8   !!            3.7  ! 2012-03  (G. Madec)  make public the density criteria for trdmxl
9   !!             -   ! 2014-02  (F. Roquet)  mixed layer depth calculated using N2 instead of rhop
10   !!----------------------------------------------------------------------
11   !!   zdf_mxl      : Compute the turbocline and mixed layer depths.
12   !!----------------------------------------------------------------------
13   USE oce             ! ocean dynamics and tracers variables
14   USE dom_oce         ! ocean space and time domain variables
15   USE zdf_oce         ! ocean vertical physics
16   USE in_out_manager  ! I/O manager
17   USE prtctl          ! Print control
18   USE phycst          ! physical constants
19   USE iom             ! I/O library
20   USE eosbn2          ! for zdf_mxl_zint
21   USE lib_mpp         ! MPP library
22   USE wrk_nemo        ! work arrays
23   USE timing          ! Timing
24   USE trc_oce, ONLY : lk_offline ! offline flag
25
26   IMPLICIT NONE
27   PRIVATE
28
29   PUBLIC   zdf_mxl       ! called by step.F90
30   PUBLIC   zdf_mxl_alloc ! Used in zdf_tke_init
31   PRIVATE  mxl_namelist
32   PRIVATE  mxl_bcast
33
34   INTEGER , PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   nmln    !: number of level in the mixed layer (used by TOP)
35   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   hmld    !: mixing layer depth (turbocline)      [m]
36   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   hmlp    !: mixed layer depth  (rho=rho0+zdcrit) [m]
37   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   hmlpt   !: mixed layer depth at t-points        [m]
38   REAL(wp), PUBLIC, ALLOCATABLE,       DIMENSION(:,:) ::   hmld_zint  !: vertically-interpolated mixed layer depth   [m]
39   REAL(wp), PUBLIC, ALLOCATABLE,       DIMENSION(:,:) ::   htc_mld    ! Heat content of hmld_zint
40   LOGICAL, PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:)    :: ll_found   ! Is T_b to be found by interpolation ?
41   LOGICAL, PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:)  :: ll_belowml ! Flag points below mixed layer when ll_found=F
42
43   REAL(wp), PUBLIC ::   rho_c = 0.01_wp    !: density criterion for mixed layer depth
44   REAL(wp)         ::   avt_c = 5.e-4_wp   ! Kz criterion for the turbocline depth
45
46   TYPE, PUBLIC :: MXL_ZINT   !: Structure for MLD defs
47      INTEGER   :: mld_type   ! mixed layer type     
48      REAL(wp)  :: zref       ! depth of initial T_ref
49      REAL(wp)  :: dT_crit    ! Critical temp diff
50      REAL(wp)  :: iso_frac   ! Fraction of rn_dT_crit used
51   END TYPE MXL_ZINT
52
53   !! * Substitutions
54#  include "domzgr_substitute.h90"
55   !!----------------------------------------------------------------------
56   !! NEMO/OPA 4.0 , NEMO Consortium (2011)
57   !! $Id$
58   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
59   !!----------------------------------------------------------------------
60CONTAINS
61
62   INTEGER FUNCTION zdf_mxl_alloc()
63      !!----------------------------------------------------------------------
64      !!               ***  FUNCTION zdf_mxl_alloc  ***
65      !!----------------------------------------------------------------------
66      zdf_mxl_alloc = 0      ! set to zero if no array to be allocated
67      IF( .NOT. ALLOCATED( nmln ) ) THEN
68         ALLOCATE( nmln(jpi,jpj), hmld(jpi,jpj), hmlp(jpi,jpj), hmlpt(jpi,jpj), hmld_zint(jpi,jpj),       &
69        &          htc_mld(jpi,jpj),                                                                    &
70        &          ll_found(jpi,jpj), ll_belowml(jpi,jpj,jpk), STAT= zdf_mxl_alloc )
71         !
72         IF( lk_mpp             )   CALL mpp_sum ( zdf_mxl_alloc )
73         IF( zdf_mxl_alloc /= 0 )   CALL ctl_warn('zdf_mxl_alloc: failed to allocate arrays.')
74         !
75      ENDIF
76   END FUNCTION zdf_mxl_alloc
77
78
79   SUBROUTINE zdf_mxl( kt )
80      !!----------------------------------------------------------------------
81      !!                  ***  ROUTINE zdfmxl  ***
82      !!                   
83      !! ** Purpose :   Compute the turbocline depth and the mixed layer depth
84      !!              with density criteria.
85      !!
86      !! ** Method  :   The mixed layer depth is the shallowest W depth with
87      !!      the density of the corresponding T point (just bellow) bellow a
88      !!      given value defined locally as rho(10m) + rho_c
89      !!               The turbocline depth is the depth at which the vertical
90      !!      eddy diffusivity coefficient (resulting from the vertical physics
91      !!      alone, not the isopycnal part, see trazdf.F) fall below a given
92      !!      value defined locally (avt_c here taken equal to 5 cm/s2 by default)
93      !!
94      !! ** Action  :   nmln, hmld, hmlp, hmlpt
95      !!----------------------------------------------------------------------
96      INTEGER, INTENT(in) ::   kt   ! ocean time-step index
97      !
98      INTEGER  ::   ji, jj, jk      ! dummy loop indices
99      INTEGER  ::   iikn, iiki, ikt ! local integer
100      REAL(wp) ::   zN2_c           ! local scalar
101      INTEGER, POINTER, DIMENSION(:,:) ::   imld   ! 2D workspace
102      !!----------------------------------------------------------------------
103      !
104      IF( nn_timing == 1 )  CALL timing_start('zdf_mxl')
105      !
106      CALL wrk_alloc( jpi,jpj, imld )
107
108      IF( kt <= nit000 ) THEN
109         IF(lwp) WRITE(numout,*)
110         IF(lwp) WRITE(numout,*) 'zdf_mxl : mixed layer depth'
111         IF(lwp) WRITE(numout,*) '~~~~~~~ '
112         !                             ! allocate zdfmxl arrays
113         IF( zdf_mxl_alloc() /= 0 )   CALL ctl_stop( 'STOP', 'zdf_mxl : unable to allocate arrays' )
114      ENDIF
115
116      ! w-level of the mixing and mixed layers
117      nmln(:,:)  = nlb10               ! Initialization to the number of w ocean point
118      hmlp(:,:)  = 0._wp               ! here hmlp used as a dummy variable, integrating vertically N^2
119      zN2_c = grav * rho_c * r1_rau0   ! convert density criteria into N^2 criteria
120      DO jk = nlb10, jpkm1
121         DO jj = 1, jpj                ! Mixed layer level: w-level
122            DO ji = 1, jpi
123               ikt = mbkt(ji,jj)
124               hmlp(ji,jj) = hmlp(ji,jj) + MAX( rn2b(ji,jj,jk) , 0._wp ) * fse3w(ji,jj,jk)
125               IF( hmlp(ji,jj) < zN2_c )   nmln(ji,jj) = MIN( jk , ikt ) + 1   ! Mixed layer level
126            END DO
127         END DO
128      END DO
129      !
130      ! w-level of the turbocline
131      imld(:,:) = mbkt(:,:) + 1        ! Initialization to the number of w ocean point
132      DO jk = jpkm1, nlb10, -1         ! from the bottom to nlb10
133         DO jj = 1, jpj
134            DO ji = 1, jpi
135               IF( avt (ji,jj,jk) < avt_c * wmask(ji,jj,jk) )   imld(ji,jj) = jk      ! Turbocline
136            END DO
137         END DO
138      END DO
139      ! depth of the mixing and mixed layers
140      DO jj = 1, jpj
141         DO ji = 1, jpi
142            iiki = imld(ji,jj)
143            iikn = nmln(ji,jj)
144            hmld (ji,jj) = fsdepw(ji,jj,iiki  ) * ssmask(ji,jj)    ! Turbocline depth
145            hmlp (ji,jj) = fsdepw(ji,jj,iikn  ) * ssmask(ji,jj)    ! Mixed layer depth
146            hmlpt(ji,jj) = fsdept(ji,jj,iikn-1) * ssmask(ji,jj)    ! depth of the last T-point inside the mixed layer
147         END DO
148      END DO
149      ! no need to output in offline mode
150      IF( .NOT.lk_offline ) THEN   
151         IF ( iom_use("mldr10_1") ) THEN
152            IF( ln_isfcav ) THEN
153               CALL iom_put( "mldr10_1", hmlp - risfdep)   ! mixed layer thickness
154            ELSE
155               CALL iom_put( "mldr10_1", hmlp )            ! mixed layer depth
156            END IF
157         END IF
158         IF ( iom_use("mldkz5") ) THEN
159            IF( ln_isfcav ) THEN
160               CALL iom_put( "mldkz5"  , hmld - risfdep )   ! turbocline thickness
161            ELSE
162               CALL iom_put( "mldkz5"  , hmld )             ! turbocline depth
163            END IF
164         END IF
165      ENDIF
166     
167      ! Vertically-interpolated mixed-layer depth diagnostic
168      CALL zdf_mxl_zint( kt )
169
170      IF(ln_ctl)   CALL prt_ctl( tab2d_1=REAL(nmln,wp), clinfo1=' nmln : ', tab2d_2=hmlp, clinfo2=' hmlp : ', ovlap=1 )
171      !
172      CALL wrk_dealloc( jpi,jpj, imld )
173      !
174      IF( nn_timing == 1 )  CALL timing_stop('zdf_mxl')
175      !
176   END SUBROUTINE zdf_mxl
177
178   SUBROUTINE zdf_mxl_zint_mld( sf ) 
179      !!----------------------------------------------------------------------------------
180      !!                    ***  ROUTINE zdf_mxl_zint_mld  ***
181      !                                                                       
182      !   Calculate vertically-interpolated mixed layer depth diagnostic.
183      !           
184      !   This routine can calculate the mixed layer depth diagnostic suggested by
185      !   Kara et al, 2000, JGR, 105, 16803, but is more general and can calculate
186      !   vertically-interpolated mixed-layer depth diagnostics with other parameter
187      !   settings set in the namzdf_mldzint namelist. 
188      !
189      !   If mld_type=1 the mixed layer depth is calculated as the depth at which the 
190      !   density has increased by an amount equivalent to a temperature difference of 
191      !   0.8C at the surface.
192      !
193      !   For other values of mld_type the mixed layer is calculated as the depth at 
194      !   which the temperature differs by 0.8C from the surface temperature. 
195      !                                                                       
196      !   David Acreman, Daley Calvert                                     
197      !
198      !!-----------------------------------------------------------------------------------
199
200      TYPE(MXL_ZINT), INTENT(in)  :: sf
201
202      ! Diagnostic criteria
203      INTEGER   :: nn_mld_type   ! mixed layer type     
204      REAL(wp)  :: rn_zref       ! depth of initial T_ref
205      REAL(wp)  :: rn_dT_crit    ! Critical temp diff
206      REAL(wp)  :: rn_iso_frac   ! Fraction of rn_dT_crit used
207
208      ! Local variables
209      REAL(wp), PARAMETER :: zepsilon = 1.e-30          ! local small value
210      INTEGER, POINTER, DIMENSION(:,:) :: ikmt          ! number of active tracer levels
211      INTEGER, POINTER, DIMENSION(:,:) :: ik_ref        ! index of reference level
212      INTEGER, POINTER, DIMENSION(:,:) :: ik_iso        ! index of last uniform temp level
213      REAL, POINTER, DIMENSION(:,:,:)  :: zT            ! Temperature or density
214      REAL, POINTER, DIMENSION(:,:)    :: ppzdep        ! depth for use in calculating d(rho)
215      REAL, POINTER, DIMENSION(:,:)    :: zT_ref        ! reference temperature
216      REAL    :: zT_b                                   ! base temperature
217      REAL, POINTER, DIMENSION(:,:,:)  :: zdTdz         ! gradient of zT
218      REAL, POINTER, DIMENSION(:,:,:)  :: zmoddT        ! Absolute temperature difference
219      REAL    :: zdz                                    ! depth difference
220      REAL    :: zdT                                    ! temperature difference
221      REAL, POINTER, DIMENSION(:,:)    :: zdelta_T      ! difference critereon
222      REAL, POINTER, DIMENSION(:,:)    :: zRHO1, zRHO2  ! Densities
223      INTEGER :: ji, jj, jk                             ! loop counter
224
225      !!-------------------------------------------------------------------------------------
226     
227      CALL wrk_alloc( jpi, jpj, ikmt, ik_ref, ik_iso) 
228      CALL wrk_alloc( jpi, jpj, ppzdep, zT_ref, zdelta_T, zRHO1, zRHO2 ) 
229      CALL wrk_alloc( jpi, jpj, jpk, zT, zdTdz, zmoddT ) 
230
231      ! Unpack structure
232      nn_mld_type = sf%mld_type
233      rn_zref     = sf%zref
234      rn_dT_crit  = sf%dT_crit
235      rn_iso_frac = sf%iso_frac
236
237      ! Set the mixed layer depth criterion at each grid point
238      IF( nn_mld_type == 0 ) THEN
239         zdelta_T(:,:) = rn_dT_crit
240         zT(:,:,:) = rhop(:,:,:)
241      ELSE IF( nn_mld_type == 1 ) THEN
242         ppzdep(:,:)=0.0 
243         call eos ( tsn(:,:,1,:), ppzdep(:,:), zRHO1(:,:) ) 
244! Use zT temporarily as a copy of tsn with rn_dT_crit added to SST
245! [assumes number of tracers less than number of vertical levels]
246         zT(:,:,1:jpts)=tsn(:,:,1,1:jpts) 
247         zT(:,:,jp_tem)=zT(:,:,1)+rn_dT_crit 
248         CALL eos( zT(:,:,1:jpts), ppzdep(:,:), zRHO2(:,:) ) 
249         zdelta_T(:,:) = abs( zRHO1(:,:) - zRHO2(:,:) ) * rau0 
250         ! RHO from eos (2d version) doesn't calculate north or east halo:
251         CALL lbc_lnk( zdelta_T, 'T', 1. ) 
252         zT(:,:,:) = rhop(:,:,:) 
253      ELSE
254         zdelta_T(:,:) = rn_dT_crit                     
255         zT(:,:,:) = tsn(:,:,:,jp_tem)                           
256      END IF 
257
258      ! Calculate the gradient of zT and absolute difference for use later
259      DO jk = 1 ,jpk-2 
260         zdTdz(:,:,jk)  =    ( zT(:,:,jk+1) - zT(:,:,jk) ) / fse3w(:,:,jk+1) 
261         zmoddT(:,:,jk) = abs( zT(:,:,jk+1) - zT(:,:,jk) ) 
262      END DO 
263
264      ! Find density/temperature at the reference level (Kara et al use 10m).         
265      ! ik_ref is the index of the box centre immediately above or at the reference level
266      ! Find rn_zref in the array of model level depths and find the ref   
267      ! density/temperature by linear interpolation.                                   
268      DO jk = jpkm1, 2, -1 
269         WHERE ( fsdept(:,:,jk) > rn_zref ) 
270           ik_ref(:,:) = jk - 1 
271           zT_ref(:,:) = zT(:,:,jk-1) + zdTdz(:,:,jk-1) * ( rn_zref - fsdept(:,:,jk-1) ) 
272         END WHERE
273      END DO 
274
275      ! If the first grid box centre is below the reference level then use the
276      ! top model level to get zT_ref
277      WHERE ( fsdept(:,:,1) > rn_zref ) 
278         zT_ref = zT(:,:,1) 
279         ik_ref = 1 
280      END WHERE 
281
282      ! The number of active tracer levels is 1 less than the number of active w levels
283      ikmt(:,:) = mbathy(:,:) - 1 
284
285      ! Initialize / reset
286      ll_found(:,:) = .false.
287
288      IF ( rn_iso_frac - zepsilon > 0. ) THEN
289         ! Search for a uniform density/temperature region where adjacent levels         
290         ! differ by less than rn_iso_frac * deltaT.                                     
291         ! ik_iso is the index of the last level in the uniform layer 
292         ! ll_found indicates whether the mixed layer depth can be found by interpolation
293         ik_iso(:,:)   = ik_ref(:,:) 
294         DO jj = 1, nlcj 
295            DO ji = 1, nlci 
296!CDIR NOVECTOR
297               DO jk = ik_ref(ji,jj), ikmt(ji,jj)-1 
298                  IF ( zmoddT(ji,jj,jk) > ( rn_iso_frac * zdelta_T(ji,jj) ) ) THEN
299                     ik_iso(ji,jj)   = jk 
300                     ll_found(ji,jj) = ( zmoddT(ji,jj,jk) > zdelta_T(ji,jj) ) 
301                     EXIT
302                  END IF
303               END DO
304            END DO
305         END DO 
306
307         ! Use linear interpolation to find depth of mixed layer base where possible
308         hmld_zint(:,:) = rn_zref 
309         DO jj = 1, jpj 
310            DO ji = 1, jpi 
311               IF (ll_found(ji,jj) .and. tmask(ji,jj,1) == 1.0) THEN
312                  zdz =  abs( zdelta_T(ji,jj) / zdTdz(ji,jj,ik_iso(ji,jj)) ) 
313                  hmld_zint(ji,jj) = fsdept(ji,jj,ik_iso(ji,jj)) + zdz 
314               END IF
315            END DO
316         END DO
317      END IF
318
319      ! If ll_found = .false. then calculate MLD using difference of zdelta_T   
320      ! from the reference density/temperature
321 
322! Prevent this section from working on land points
323      WHERE ( tmask(:,:,1) /= 1.0 ) 
324         ll_found = .true. 
325      END WHERE
326 
327      DO jk=1, jpk 
328         ll_belowml(:,:,jk) = abs( zT(:,:,jk) - zT_ref(:,:) ) >= zdelta_T(:,:) 
329      END DO 
330 
331! Set default value where interpolation cannot be used (ll_found=false) 
332      DO jj = 1, jpj 
333         DO ji = 1, jpi 
334            IF ( .not. ll_found(ji,jj) )  hmld_zint(ji,jj) = fsdept(ji,jj,ikmt(ji,jj)) 
335         END DO
336      END DO
337
338      DO jj = 1, jpj 
339         DO ji = 1, jpi 
340!CDIR NOVECTOR
341            DO jk = ik_ref(ji,jj)+1, ikmt(ji,jj) 
342               IF ( ll_found(ji,jj) ) EXIT
343               IF ( ll_belowml(ji,jj,jk) ) THEN               
344                  zT_b = zT_ref(ji,jj) + zdelta_T(ji,jj) * SIGN(1.0, zdTdz(ji,jj,jk-1) ) 
345                  zdT  = zT_b - zT(ji,jj,jk-1)                                     
346                  zdz  = zdT / zdTdz(ji,jj,jk-1)                                       
347                  hmld_zint(ji,jj) = fsdept(ji,jj,jk-1) + zdz 
348                  EXIT                                                   
349               END IF
350            END DO
351         END DO
352      END DO
353
354      hmld_zint(:,:) = hmld_zint(:,:)*tmask(:,:,1) 
355     
356      CALL wrk_dealloc( jpi, jpj, ikmt, ik_ref, ik_iso) 
357      CALL wrk_dealloc( jpi, jpj, ppzdep, zT_ref, zdelta_T, zRHO1, zRHO2 ) 
358      CALL wrk_dealloc( jpi,jpj, jpk, zT, zdTdz, zmoddT ) 
359      !
360   END SUBROUTINE zdf_mxl_zint_mld
361
362   SUBROUTINE zdf_mxl_zint_htc( kt )
363      !!----------------------------------------------------------------------
364      !!                  ***  ROUTINE zdf_mxl_zint_htc  ***
365      !!
366      !! ** Purpose :   
367      !!
368      !! ** Method  :   
369      !!----------------------------------------------------------------------
370
371      INTEGER, INTENT(in) ::   kt   ! ocean time-step index
372
373      INTEGER :: ji, jj, jk
374      INTEGER :: ikmax
375      REAL(wp) :: zc, zcoef
376      !
377      INTEGER,  ALLOCATABLE, DIMENSION(:,:) ::   ilevel
378      REAL(wp), ALLOCATABLE, DIMENSION(:,:) ::   zthick_0, zthick
379
380      !!----------------------------------------------------------------------
381
382      IF( .NOT. ALLOCATED(ilevel) ) THEN
383         ALLOCATE( ilevel(jpi,jpj), zthick_0(jpi,jpj), &
384         &         zthick(jpi,jpj), STAT=ji )
385         IF( lk_mpp  )   CALL mpp_sum(ji)
386         IF( ji /= 0 )   CALL ctl_stop( 'STOP', 'zdf_mxl_zint_htc : unable to allocate arrays' )
387      ENDIF
388
389      ! Find last whole model T level above the MLD
390      ilevel(:,:)   = 0
391      zthick_0(:,:) = 0._wp
392
393      DO jk = 1, jpkm1 
394         DO jj = 1, jpj
395            DO ji = 1, jpi                   
396               zthick_0(ji,jj) = zthick_0(ji,jj) + fse3t(ji,jj,jk)
397               IF( zthick_0(ji,jj) < hmld_zint(ji,jj) )   ilevel(ji,jj) = jk
398            END DO
399         END DO
400         WRITE(numout,*) 'zthick_0(jk =',jk,') =',zthick_0(2,2)
401         WRITE(numout,*) 'fsdepw(jk+1 =',jk+1,') =',fsdepw(2,2,jk+1)
402      END DO
403
404      ! Surface boundary condition
405      IF( lk_vvl ) THEN   ;   zthick(:,:) = 0._wp       ;   htc_mld(:,:) = 0._wp                                   
406      ELSE                ;   zthick(:,:) = sshn(:,:)   ;   htc_mld(:,:) = tsn(:,:,1,jp_tem) * sshn(:,:) * tmask(:,:,1)   
407      ENDIF
408
409      ! Deepest whole T level above the MLD
410      ikmax = MIN( MAXVAL( ilevel(:,:) ), jpkm1 )
411
412      ! Integration down to last whole model T level
413      DO jk = 1, ikmax
414         DO jj = 1, jpj
415            DO ji = 1, jpi
416               zc = fse3t(ji,jj,jk) * REAL( MIN( MAX( 0, ilevel(ji,jj) - jk + 1 ) , 1  )  )    ! 0 below ilevel
417               zthick(ji,jj) = zthick(ji,jj) + zc
418               htc_mld(ji,jj) = htc_mld(ji,jj) + zc * tsn(ji,jj,jk,jp_tem) * tmask(ji,jj,jk)
419            END DO
420         END DO
421      END DO
422
423      ! Subsequent partial T level
424      zthick(:,:) = hmld_zint(:,:) - zthick(:,:)   !   remaining thickness to reach MLD
425
426      DO jj = 1, jpj
427         DO ji = 1, jpi
428            htc_mld(ji,jj) = htc_mld(ji,jj) + tsn(ji,jj,ilevel(ji,jj)+1,jp_tem)  & 
429      &                      * MIN( fse3t(ji,jj,ilevel(ji,jj)+1), zthick(ji,jj) ) * tmask(ji,jj,ilevel(ji,jj)+1)
430         END DO
431      END DO
432
433      WRITE(numout,*) 'htc_mld(after) =',htc_mld(2,2)
434
435      ! Convert to heat content
436      zcoef = rau0 * rcp
437      htc_mld(:,:) = zcoef * htc_mld(:,:)
438
439   END SUBROUTINE zdf_mxl_zint_htc
440
441   SUBROUTINE zdf_mxl_zint( kt )
442      !!----------------------------------------------------------------------
443      !!                  ***  ROUTINE zdf_mxl_zint  ***
444      !!
445      !! ** Purpose :   
446      !!
447      !! ** Method  :   
448      !!----------------------------------------------------------------------
449
450      INTEGER, INTENT(in) ::   kt   ! ocean time-step index
451
452      INTEGER :: ios
453      INTEGER :: jn
454
455      INTEGER :: nn_mld_diag = 0    ! number of diagnostics
456
457      CHARACTER(len=1) :: cmld
458
459      TYPE(MXL_ZINT) :: sn_mld1, sn_mld2, sn_mld3, sn_mld4, sn_mld5
460      TYPE(MXL_ZINT), SAVE, DIMENSION(5) ::   mld_diags
461
462      NAMELIST/namzdf_mldzint/ nn_mld_diag, sn_mld1, sn_mld2, sn_mld3, sn_mld4, sn_mld5
463
464      !!----------------------------------------------------------------------
465     
466      IF( kt == nit000 ) THEN
467         IF(lwm) THEN
468            REWIND( numnam_ref )              ! Namelist namzdf_mldzint in reference namelist
469            READ  ( numnam_ref, namzdf_mldzint, IOSTAT = ios, ERR = 901)
470901         IF( ios /= 0 ) CALL ctl_nam ( ios , 'namzdf_mldzint in reference namelist', lwm )
471            REWIND( numnam_cfg )              ! Namelist namzdf_mldzint in configuration namelist
472            READ  ( numnam_cfg, namzdf_mldzint, IOSTAT = ios, ERR = 902 )
473902         IF( ios /= 0 ) CALL ctl_nam ( ios , 'namzdf_mldzint in configuration namelist', lwm )
474         ENDIF
475
476         IF(lwm) WRITE ( numond, namzdf_mldzint )
477         
478         CALL mxl_namelist(nn_mld_diag, sn_mld1, sn_mld2, sn_mld3, sn_mld4, sn_mld5)                   !broadcast namelist
479
480         IF( nn_mld_diag > 5 )   CALL ctl_stop( 'STOP', 'zdf_mxl_ini: Specify no more than 5 MLD definitions' )
481
482         mld_diags(1) = sn_mld1
483         mld_diags(2) = sn_mld2
484         mld_diags(3) = sn_mld3
485         mld_diags(4) = sn_mld4
486         mld_diags(5) = sn_mld5
487
488         IF( lwp .AND. (nn_mld_diag > 0) ) THEN
489            WRITE(numout,*) '=============== Vertically-interpolated mixed layer ================'
490            WRITE(numout,*) '(Diagnostic number, nn_mld_type, rn_zref, rn_dT_crit, rn_iso_frac)'
491            DO jn = 1, nn_mld_diag
492               WRITE(numout,*) 'MLD criterion',jn,':'
493               WRITE(numout,*) '    nn_mld_type =', mld_diags(jn)%mld_type
494               WRITE(numout,*) '    rn_zref ='    , mld_diags(jn)%zref
495               WRITE(numout,*) '    rn_dT_crit =' , mld_diags(jn)%dT_crit
496               WRITE(numout,*) '    rn_iso_frac =', mld_diags(jn)%iso_frac
497            END DO
498            WRITE(numout,*) '===================================================================='
499         ENDIF
500      ENDIF
501
502      IF( nn_mld_diag > 0 ) THEN
503         DO jn = 1, nn_mld_diag
504            WRITE(cmld,'(I1)') jn
505            IF( iom_use( "mldzint_"//cmld ) .OR. iom_use( "mldhtc_"//cmld ) ) THEN
506               CALL zdf_mxl_zint_mld( mld_diags(jn) )
507
508               IF( iom_use( "mldzint_"//cmld ) ) THEN
509                  CALL iom_put( "mldzint_"//cmld, hmld_zint(:,:) )
510               ENDIF
511
512               IF( iom_use( "mldhtc_"//cmld ) )  THEN
513                  CALL zdf_mxl_zint_htc( kt )
514                  CALL iom_put( "mldhtc_"//cmld , htc_mld(:,:)   )
515               ENDIF
516            ENDIF
517         END DO
518      ENDIF
519
520   END SUBROUTINE zdf_mxl_zint
521
522   SUBROUTINE mxl_namelist(nd_mld_diag, sd_mld1, sd_mld2, sd_mld3, sd_mld4, sd_mld5)
523     !!---------------------------------------------------------------------
524     !!                   ***  ROUTINE mxl_namelist  ***
525     !!                     
526     !! ** Purpose :   Broadcast namelist variables read by procesor lwp
527     !!
528     !! ** Method  :   use lib_mpp
529     !!----------------------------------------------------------------------
530      TYPE(MXL_ZINT) :: sd_mld1, sd_mld2, sd_mld3, sd_mld4, sd_mld5
531      INTEGER :: nd_mld_diag
532#if defined key_mpp_mpi
533     call mpp_bcast(nd_mld_diag)
534     call mxl_bcast(sd_mld1)
535     call mxl_bcast(sd_mld2)
536     call mxl_bcast(sd_mld3)
537     call mxl_bcast(sd_mld4)
538     call mxl_bcast(sd_mld5)
539#endif
540   END SUBROUTINE mxl_namelist
541
542  SUBROUTINE mxl_bcast(svar)
543     !!---------------------------------------------------------------------
544     !!                   ***  ROUTINE mxl_namelist  ***
545     !!                     
546     !! ** Purpose :   Broadcast namelist type read by procesor lwp
547     !!
548     !! ** Method  :   use lib_mpp
549     !!----------------------------------------------------------------------
550     TYPE(MXL_ZINT), INTENT (INOUT) :: svar
551#if defined key_mpp_mpi
552     call mpp_bcast(svar%mld_type)
553     call mpp_bcast(svar%zref) 
554     call mpp_bcast(svar%dT_crit)
555     call mpp_bcast(svar%iso_frac)
556#endif
557   END SUBROUTINE mxl_bcast
558
559
560   !!======================================================================
561END MODULE zdfmxl
Note: See TracBrowser for help on using the repository browser.