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 NEMO/branches/UKMO/r12083_mix-lyr_diag/src/OCE/ZDF – NEMO

source: NEMO/branches/UKMO/r12083_mix-lyr_diag/src/OCE/ZDF/zdfmxl.F90 @ 12836

Last change on this file since 12836 was 12836, checked in by jcastill, 4 years ago

Bug fix: when coupling with waves, the model crashed with an xios error saying that the mixed layer depth could not be written. This error is usually thrown when xios is trying to write NaNs?, but his was not the case. In this case the error looked to happen because xios did not finish writing a variable, but the variable was updated before xios finished. The do loop where this happened has been changed, and some cleaning of the branch done.

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