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.
Changeset 15521 – NEMO

Changeset 15521


Ignore:
Timestamp:
2021-11-18T16:56:15+01:00 (2 years ago)
Author:
dbruciaferri
Message:

Correct mixed-layer diagnostic to be consistent with latest GO8 devs - from fcm:nemo.xm/NEMO/branches/UKMO/NEMO_4.0.4_CO9_package-mix-lyr@15506

Location:
NEMO/branches/UKMO/NEMO_4.0.4_CO9_package/src/OCE
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • NEMO/branches/UKMO/NEMO_4.0.4_CO9_package/src/OCE/SBC/cpl_oasis3.F90

    r14075 r15521  
    2727#if defined key_oasis3 
    2828   USE mod_oasis                    ! OASIS3-MCT module 
     29#endif  
     30#if defined key_iomput && defined key_xios25   
     31   USE xios, ONLY:xios_oasis_enddef 
    2932#endif 
    3033   USE par_oce                      ! ocean parameters 
     
    310313      IF( agrif_fixed() == Agrif_Nb_Fine_Grids() ) THEN 
    311314#endif 
     315      !   
     316#if defined key_iomput && defined key_xios25   
     317!needed for XIOS 2.5   
     318      CALL xios_oasis_enddef()   
     319#endif   
     320      !  
    312321      CALL oasis_enddef(nerror) 
    313322      IF( nerror /= OASIS_Ok )   CALL oasis_abort ( ncomp_id, 'cpl_define', 'Failure in oasis_enddef') 
  • NEMO/branches/UKMO/NEMO_4.0.4_CO9_package/src/OCE/ZDF/zdfmxl.F90

    r14078 r15521  
    2828   PUBLIC   zdf_mxl   ! called by zdfphy.F90 
    2929 
    30    INTEGER , PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   nmln    !: number of level in the mixed layer (used by LDF, ZDF, TRD, TOP) 
    31    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   hmld    !: mixing layer depth (turbocline)      [m]   (used by TOP) 
    32    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   hmlp    !: mixed layer depth  (rho=rho0+zdcrit) [m]   (used by LDF) 
    33    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   hmlpt   !: depth of the last T-point inside the mixed layer [m] (used by LDF) 
    34    REAL(wp), PUBLIC, ALLOCATABLE,       DIMENSION(:,:) ::   hmld_zint  !: vertically-interpolated mixed layer depth   [m] 
    35    REAL(wp), PUBLIC, ALLOCATABLE,       DIMENSION(:,:) ::   htc_mld    ! Heat content of hmld_zint 
    36    LOGICAL, PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:)    :: ll_found   ! Is T_b to be found by interpolation ? 
     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 ?     
    3738   LOGICAL, PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:)  :: ll_belowml ! Flag points below mixed layer when ll_found=F 
    3839 
     
    4748   END TYPE MXL_ZINT 
    4849 
     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 
    4963   !!---------------------------------------------------------------------- 
    5064   !! NEMO/OCE 4.0 , NEMO Consortium (2018) 
     
    6074      zdf_mxl_alloc = 0      ! set to zero if no array to be allocated 
    6175      IF( .NOT. ALLOCATED( nmln ) ) THEN 
    62          ALLOCATE( nmln(jpi,jpj), hmld(jpi,jpj), hmlp(jpi,jpj), hmlpt(jpi,jpj), hmld_zint(jpi,jpj),     & 
    63    &          htc_mld(jpi,jpj), ll_found(jpi,jpj), ll_belowml(jpi,jpj,jpk), STAT= zdf_mxl_alloc )          
     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)) 
    6480         ! 
    6581         CALL mpp_sum ( 'zdfmxl', zdf_mxl_alloc ) 
     
    179195      !!-----------------------------------------------------------------------------------  
    180196 
    181       TYPE(MXL_ZINT), INTENT(in)  :: sf 
     197      TYPE(MXL_ZINT), DIMENSION(MAX_DIAG), INTENT(in)  :: sf 
    182198 
    183199      ! Diagnostic criteria 
     
    202218      REAL, DIMENSION(jpi,jpj)    :: zdelta_T      ! difference critereon  
    203219      REAL, DIMENSION(jpi,jpj)    :: zRHO1, zRHO2  ! Densities  
    204       INTEGER :: ji, jj, jk                             ! loop counter  
     220      INTEGER :: ji, jj, jk, jn                         ! loop counter  
    205221 
    206222      !!-------------------------------------------------------------------------------------  
    207223      !   
    208224      ! Unpack structure 
    209       nn_mld_type = sf%mld_type 
    210       rn_zref     = sf%zref 
    211       rn_dT_crit  = sf%dT_crit 
    212       rn_iso_frac = sf%iso_frac 
    213  
    214       ! Set the mixed layer depth criterion at each grid point  
    215       IF( nn_mld_type == 0 ) THEN 
    216          zdelta_T(:,:) = rn_dT_crit 
    217          zT(:,:,:) = rhop(:,:,:) 
    218       ELSE IF( nn_mld_type == 1 ) THEN 
    219          ppzdep(:,:)=0.0  
    220          call eos ( tsn(:,:,1,:), ppzdep(:,:), zRHO1(:,:) )  
     225      DO jn=1, nn_mld_diag 
     226         IF( cmld_zint(jn) .OR. cmld_mld(jn) ) THEN 
     227            nn_mld_type = sf(jn)%mld_type 
     228            rn_zref     = sf(jn)%zref 
     229            rn_dT_crit  = sf(jn)%dT_crit 
     230            rn_iso_frac = sf(jn)%iso_frac 
     231 
     232            ! Set the mixed layer depth criterion at each grid point  
     233            IF( nn_mld_type == 0 ) THEN 
     234               zdelta_T(:,:) = rn_dT_crit 
     235               zT(:,:,:) = rhop(:,:,:) 
     236            ELSE IF( nn_mld_type == 1 ) THEN 
     237               ppzdep(:,:)=0.0  
     238               call eos ( tsn(:,:,1,:), ppzdep(:,:), zRHO1(:,:) )  
    221239! Use zT temporarily as a copy of tsn with rn_dT_crit added to SST  
    222240! [assumes number of tracers less than number of vertical levels]  
    223          zT(:,:,1:jpts)=tsn(:,:,1,1:jpts)  
    224          zT(:,:,jp_tem)=zT(:,:,1)+rn_dT_crit  
    225          CALL eos( zT(:,:,1:jpts), ppzdep(:,:), zRHO2(:,:) )  
    226          zdelta_T(:,:) = abs( zRHO1(:,:) - zRHO2(:,:) ) * rau0  
    227          ! RHO from eos (2d version) doesn't calculate north or east halo:  
    228          CALL lbc_lnk( 'zdfmxl', zdelta_T, 'T', 1. )  
    229          zT(:,:,:) = rhop(:,:,:)  
    230       ELSE  
    231          zdelta_T(:,:) = rn_dT_crit                       
    232          zT(:,:,:) = tsn(:,:,:,jp_tem)                            
    233       END IF  
    234  
    235       ! Calculate the gradient of zT and absolute difference for use later  
    236       DO jk = 1 ,jpk-2  
    237          zdTdz(:,:,jk)  =    ( zT(:,:,jk+1) - zT(:,:,jk) ) / e3w_n(:,:,jk+1)  
    238          zmoddT(:,:,jk) = abs( zT(:,:,jk+1) - zT(:,:,jk) )  
    239       END DO  
    240  
    241       ! Find density/temperature at the reference level (Kara et al use 10m).           
    242       ! ik_ref is the index of the box centre immediately above or at the reference level  
    243       ! Find rn_zref in the array of model level depths and find the ref     
    244       ! density/temperature by linear interpolation.                                    
    245       DO jk = jpkm1, 2, -1  
    246          WHERE ( gdept_n(:,:,jk) > rn_zref )  
    247            ik_ref(:,:) = jk - 1  
    248            zT_ref(:,:) = zT(:,:,jk-1) + zdTdz(:,:,jk-1) * ( rn_zref - gdept_n(:,:,jk-1) )  
    249          END WHERE  
    250       END DO  
    251  
    252       ! If the first grid box centre is below the reference level then use the  
    253       ! top model level to get zT_ref  
    254       WHERE ( gdept_n(:,:,1) > rn_zref )   
    255          zT_ref = zT(:,:,1)  
    256          ik_ref = 1  
    257       END WHERE  
    258  
    259       ! The number of active tracer levels is 1 less than the number of active w levels  
    260       ikmt(:,:) = mbkt(:,:) - 1  
    261  
    262       ! Initialize / reset 
    263       ll_found(:,:) = .false. 
    264  
    265       IF ( rn_iso_frac - zepsilon > 0. ) THEN 
    266          ! Search for a uniform density/temperature region where adjacent levels           
    267          ! differ by less than rn_iso_frac * deltaT.                                       
    268          ! ik_iso is the index of the last level in the uniform layer   
    269          ! ll_found indicates whether the mixed layer depth can be found by interpolation  
    270          ik_iso(:,:)   = ik_ref(:,:)  
    271          DO jj = 1, nlcj  
    272             DO ji = 1, nlci  
     241               zT(:,:,1:jpts)=tsn(:,:,1,1:jpts)  
     242               zT(:,:,jp_tem)=zT(:,:,1)+rn_dT_crit  
     243               CALL eos( zT(:,:,1:jpts), ppzdep(:,:), zRHO2(:,:) )  
     244               zdelta_T(:,:) = abs( zRHO1(:,:) - zRHO2(:,:) ) * rau0  
     245               ! RHO from eos (2d version) doesn't calculate north or east halo:  
     246               CALL lbc_lnk( 'zdfmxl', zdelta_T, 'T', 1. )  
     247               zT(:,:,:) = rhop(:,:,:)  
     248            ELSE  
     249               zdelta_T(:,:) = rn_dT_crit                       
     250               zT(:,:,:) = tsn(:,:,:,jp_tem)                            
     251            END IF  
     252 
     253            ! Calculate the gradient of zT and absolute difference for use later  
     254            DO jk = 1 ,jpk-2  
     255               zdTdz(:,:,jk)  =    ( zT(:,:,jk+1) - zT(:,:,jk) ) / e3w_n(:,:,jk+1)  
     256               zmoddT(:,:,jk) = abs( zT(:,:,jk+1) - zT(:,:,jk) )  
     257            END DO  
     258 
     259            ! Find density/temperature at the reference level (Kara et al use 10m).           
     260            ! ik_ref is the index of the box centre immediately above or at the reference level  
     261            ! Find rn_zref in the array of model level depths and find the ref     
     262            ! density/temperature by linear interpolation.                                    
     263            DO jk = jpkm1, 2, -1  
     264               WHERE ( gdept_n(:,:,jk) > rn_zref )  
     265                 ik_ref(:,:) = jk - 1  
     266                 zT_ref(:,:) = zT(:,:,jk-1) + zdTdz(:,:,jk-1) * ( rn_zref - gdept_n(:,:,jk-1) )  
     267               END WHERE  
     268            END DO  
     269 
     270            ! If the first grid box centre is below the reference level then use the  
     271            ! top model level to get zT_ref  
     272            WHERE ( gdept_n(:,:,1) > rn_zref )   
     273               zT_ref = zT(:,:,1)  
     274               ik_ref = 1  
     275            END WHERE  
     276 
     277            ! The number of active tracer levels is 1 less than the number of active w levels  
     278            ikmt(:,:) = mbkt(:,:) - 1  
     279 
     280            ! Initialize / reset 
     281            ll_found(:,:) = .false. 
     282 
     283            IF ( rn_iso_frac - zepsilon > 0. ) THEN 
     284               ! Search for a uniform density/temperature region where adjacent levels           
     285               ! differ by less than rn_iso_frac * deltaT.                                       
     286               ! ik_iso is the index of the last level in the uniform layer   
     287               ! ll_found indicates whether the mixed layer depth can be found by interpolation  
     288               ik_iso(:,:)   = ik_ref(:,:)  
     289               DO jj = 1, nlcj  
     290                  DO ji = 1, nlci  
    273291!CDIR NOVECTOR  
    274                DO jk = ik_ref(ji,jj), ikmt(ji,jj)-1  
    275                   IF ( zmoddT(ji,jj,jk) > ( rn_iso_frac * zdelta_T(ji,jj) ) ) THEN  
    276                      ik_iso(ji,jj)   = jk  
    277                      ll_found(ji,jj) = ( zmoddT(ji,jj,jk) > zdelta_T(ji,jj) )  
    278                      EXIT  
    279                   END IF  
     292                     DO jk = ik_ref(ji,jj), ikmt(ji,jj)-1  
     293                        IF ( zmoddT(ji,jj,jk) > ( rn_iso_frac * zdelta_T(ji,jj) ) ) THEN  
     294                           ik_iso(ji,jj)   = jk  
     295                           ll_found(ji,jj) = ( zmoddT(ji,jj,jk) > zdelta_T(ji,jj) )  
     296                           EXIT  
     297                        END IF  
     298                     END DO  
     299                  END DO  
     300               END DO  
     301 
     302               ! Use linear interpolation to find depth of mixed layer base where possible  
     303               hmld_zint(:,:,jn) = rn_zref  
     304               DO jj = 1, jpj  
     305                  DO ji = 1, jpi  
     306                     IF (ll_found(ji,jj) .and. tmask(ji,jj,1) == 1.0) THEN  
     307                        zdz =  abs( zdelta_T(ji,jj) / zdTdz(ji,jj,ik_iso(ji,jj)) )  
     308                        hmld_zint(ji,jj,jn) = gdept_n(ji,jj,ik_iso(ji,jj)) + zdz  
     309                     END IF  
     310                  END DO  
     311               END DO  
     312            END IF 
     313 
     314            ! If ll_found = .false. then calculate MLD using difference of zdelta_T     
     315            ! from the reference density/temperature  
     316 
     317! Prevent this section from working on land points  
     318            WHERE ( tmask(:,:,1) /= 1.0 )  
     319               ll_found = .true.  
     320            END WHERE  
     321 
     322            DO jk=1, jpk  
     323               ll_belowml(:,:,jk) = abs( zT(:,:,jk) - zT_ref(:,:) ) >= zdelta_T(:,:)   
     324            END DO  
     325 
     326! Set default value where interpolation cannot be used (ll_found=false)   
     327            DO jj = 1, jpj  
     328               DO ji = 1, jpi  
     329                  IF ( .not. ll_found(ji,jj) )  hmld_zint(ji,jj,jn) = gdept_n(ji,jj,ikmt(ji,jj))  
    280330               END DO  
    281331            END DO  
    282          END DO  
    283  
    284          ! Use linear interpolation to find depth of mixed layer base where possible  
    285          hmld_zint(:,:) = rn_zref  
    286          DO jj = 1, jpj  
    287             DO ji = 1, jpi  
    288                IF (ll_found(ji,jj) .and. tmask(ji,jj,1) == 1.0) THEN  
    289                   zdz =  abs( zdelta_T(ji,jj) / zdTdz(ji,jj,ik_iso(ji,jj)) )  
    290                   hmld_zint(ji,jj) = gdept_n(ji,jj,ik_iso(ji,jj)) + zdz  
    291                END IF  
     332 
     333            DO jj = 1, jpj  
     334               DO ji = 1, jpi  
     335!CDIR NOVECTOR  
     336                  DO jk = ik_ref(ji,jj)+1, ikmt(ji,jj)  
     337                     IF ( ll_found(ji,jj) ) EXIT  
     338                     IF ( ll_belowml(ji,jj,jk) ) THEN                 
     339                        zT_b = zT_ref(ji,jj) + zdelta_T(ji,jj) * SIGN(1.0, zdTdz(ji,jj,jk-1) )  
     340                        zdT  = zT_b - zT(ji,jj,jk-1)                                       
     341                        zdz  = zdT / zdTdz(ji,jj,jk-1)                                        
     342                        hmld_zint(ji,jj,jn) = gdept_n(ji,jj,jk-1) + zdz  
     343                        EXIT                                                    
     344                     END IF  
     345                  END DO  
     346               END DO  
    292347            END DO  
    293          END DO  
    294       END IF 
    295  
    296       ! If ll_found = .false. then calculate MLD using difference of zdelta_T     
    297       ! from the reference density/temperature  
    298   
    299 ! Prevent this section from working on land points  
    300       WHERE ( tmask(:,:,1) /= 1.0 )  
    301          ll_found = .true.  
    302       END WHERE  
    303   
    304       DO jk=1, jpk  
    305          ll_belowml(:,:,jk) = abs( zT(:,:,jk) - zT_ref(:,:) ) >= zdelta_T(:,:)   
    306       END DO  
    307   
    308 ! Set default value where interpolation cannot be used (ll_found=false)   
    309       DO jj = 1, jpj  
    310          DO ji = 1, jpi  
    311             IF ( .not. ll_found(ji,jj) )  hmld_zint(ji,jj) = gdept_n(ji,jj,ikmt(ji,jj))  
    312          END DO  
    313       END DO  
    314  
    315       DO jj = 1, jpj  
    316          DO ji = 1, jpi  
    317 !CDIR NOVECTOR  
    318             DO jk = ik_ref(ji,jj)+1, ikmt(ji,jj)  
    319                IF ( ll_found(ji,jj) ) EXIT  
    320                IF ( ll_belowml(ji,jj,jk) ) THEN                 
    321                   zT_b = zT_ref(ji,jj) + zdelta_T(ji,jj) * SIGN(1.0, zdTdz(ji,jj,jk-1) )  
    322                   zdT  = zT_b - zT(ji,jj,jk-1)                                       
    323                   zdz  = zdT / zdTdz(ji,jj,jk-1)                                        
    324                   hmld_zint(ji,jj) = gdept_n(ji,jj,jk-1) + zdz  
    325                   EXIT                                                    
    326                END IF  
    327             END DO  
    328          END DO  
    329       END DO  
    330  
    331       hmld_zint(:,:) = hmld_zint(:,:)*tmask(:,:,1)  
     348 
     349            hmld_zint(:,:,jn) = hmld_zint(:,:,jn)*tmask(:,:,1)  
     350         END IF 
     351      END DO 
    332352      !   
    333353   END SUBROUTINE zdf_mxl_zint_mld 
     
    344364      INTEGER, INTENT(in) ::   kt   ! ocean time-step index 
    345365 
    346       INTEGER :: ji, jj, jk 
     366      INTEGER :: ji, jj, jk, jn 
    347367      INTEGER :: ikmax 
    348368      REAL(wp) :: zc, zcoef 
     
    360380      ENDIF 
    361381 
    362       ! Find last whole model T level above the MLD 
    363       ilevel(:,:)   = 0 
    364       zthick_0(:,:) = 0._wp 
    365  
    366       DO jk = 1, jpkm1   
    367          DO jj = 1, jpj 
    368             DO ji = 1, jpi                     
    369                zthick_0(ji,jj) = zthick_0(ji,jj) + e3t_n(ji,jj,jk) 
    370                IF( zthick_0(ji,jj) < hmld_zint(ji,jj) )   ilevel(ji,jj) = jk 
     382      DO jn=1, nn_mld_diag 
     383         IF( cmld_mld(jn) ) THEN 
     384            ! Find last whole model T level above the MLD 
     385            ilevel(:,:)   = 0 
     386            zthick_0(:,:) = 0._wp 
     387 
     388            DO jk = 1, jpkm1   
     389               DO jj = 1, jpj 
     390                  DO ji = 1, jpi                     
     391                     zthick_0(ji,jj) = zthick_0(ji,jj) + e3t_n(ji,jj,jk) 
     392                     IF( zthick_0(ji,jj) < hmld_zint(ji,jj,jn) )   ilevel(ji,jj) = jk 
     393                  END DO 
     394               END DO 
     395               WRITE(numout,*) 'zthick_0(jk =',jk,') =',zthick_0(2,2) 
     396               WRITE(numout,*) 'gdepw_n(jk+1 =',jk+1,') =',gdepw_n(2,2,jk+1) 
    371397            END DO 
    372          END DO 
    373          WRITE(numout,*) 'zthick_0(jk =',jk,') =',zthick_0(2,2) 
    374          WRITE(numout,*) 'gdepw_n(jk+1 =',jk+1,') =',gdepw_n(2,2,jk+1) 
     398 
     399            ! Surface boundary condition 
     400            IF( ln_linssh ) THEN  ;   zthick(:,:) = sshn(:,:)   ;   htc_mld(:,:,jn) = tsn(:,:,1,jp_tem) * sshn(:,:) * tmask(:,:,1) 
     401            ELSE                  ;   zthick(:,:) = 0._wp       ;   htc_mld(:,:,jn) = 0._wp                                    
     402            ENDIF 
     403 
     404            ! Deepest whole T level above the MLD 
     405            ikmax = MIN( MAXVAL( ilevel(:,:) ), jpkm1 ) 
     406 
     407            ! Integration down to last whole model T level 
     408            DO jk = 1, ikmax 
     409               DO jj = 1, jpj 
     410                  DO ji = 1, jpi 
     411                     zc = e3t_n(ji,jj,jk) * REAL( MIN( MAX( 0, ilevel(ji,jj) - jk + 1 ) , 1  )  )    ! 0 below ilevel 
     412                     zthick(ji,jj) = zthick(ji,jj) + zc 
     413                     htc_mld(ji,jj,jn) = htc_mld(ji,jj,jn) + zc * tsn(ji,jj,jk,jp_tem) * tmask(ji,jj,jk) 
     414                  END DO 
     415               END DO 
     416            END DO 
     417 
     418            ! Subsequent partial T level 
     419            zthick(:,:) = hmld_zint(:,:,jn) - zthick(:,:)   !   remaining thickness to reach MLD 
     420 
     421            DO jj = 1, jpj 
     422               DO ji = 1, jpi 
     423                  htc_mld(ji,jj,jn) = htc_mld(ji,jj,jn) + tsn(ji,jj,ilevel(ji,jj)+1,jp_tem)  &  
     424            &                      * MIN( e3t_n(ji,jj,ilevel(ji,jj)+1), zthick(ji,jj) ) * tmask(ji,jj,ilevel(ji,jj)+1) 
     425               END DO 
     426            END DO 
     427 
     428            WRITE(numout,*) 'htc_mld(after) =',htc_mld(2,2,jn) 
     429 
     430            ! Convert to heat content 
     431            zcoef = rau0 * rcp 
     432            htc_mld(:,:,jn) = zcoef * htc_mld(:,:,jn) 
     433         END IF 
    375434      END DO 
    376  
    377       ! Surface boundary condition 
    378       IF( ln_linssh ) THEN  ;   zthick(:,:) = sshn(:,:)   ;   htc_mld(:,:) = tsn(:,:,1,jp_tem) * sshn(:,:) * tmask(:,:,1)    
    379       ELSE                  ;   zthick(:,:) = 0._wp       ;   htc_mld(:,:) = 0._wp                                    
    380       ENDIF 
    381  
    382       ! Deepest whole T level above the MLD 
    383       ikmax = MIN( MAXVAL( ilevel(:,:) ), jpkm1 ) 
    384  
    385       ! Integration down to last whole model T level 
    386       DO jk = 1, ikmax 
    387          DO jj = 1, jpj 
    388             DO ji = 1, jpi 
    389                zc = e3t_n(ji,jj,jk) * REAL( MIN( MAX( 0, ilevel(ji,jj) - jk + 1 ) , 1  )  )    ! 0 below ilevel 
    390                zthick(ji,jj) = zthick(ji,jj) + zc 
    391                htc_mld(ji,jj) = htc_mld(ji,jj) + zc * tsn(ji,jj,jk,jp_tem) * tmask(ji,jj,jk) 
    392             END DO 
    393          END DO 
    394       END DO 
    395  
    396       ! Subsequent partial T level 
    397       zthick(:,:) = hmld_zint(:,:) - zthick(:,:)   !   remaining thickness to reach MLD 
    398  
    399       DO jj = 1, jpj 
    400          DO ji = 1, jpi 
    401             htc_mld(ji,jj) = htc_mld(ji,jj) + tsn(ji,jj,ilevel(ji,jj)+1,jp_tem)  &  
    402       &                      * MIN( e3t_n(ji,jj,ilevel(ji,jj)+1), zthick(ji,jj) ) * tmask(ji,jj,ilevel(ji,jj)+1) 
    403          END DO 
    404       END DO 
    405  
    406       WRITE(numout,*) 'htc_mld(after) =',htc_mld(2,2) 
    407  
    408       ! Convert to heat content 
    409       zcoef = rau0 * rcp 
    410       htc_mld(:,:) = zcoef * htc_mld(:,:) 
    411435 
    412436   END SUBROUTINE zdf_mxl_zint_htc 
     
    426450      INTEGER :: jn 
    427451 
    428       INTEGER :: nn_mld_diag = 0    ! number of diagnostics 
    429  
    430452      CHARACTER(len=1) :: cmld 
    431453 
    432454      TYPE(MXL_ZINT) :: sn_mld1, sn_mld2, sn_mld3, sn_mld4, sn_mld5 
    433       TYPE(MXL_ZINT), SAVE, DIMENSION(5) ::   mld_diags 
     455      TYPE(MXL_ZINT), SAVE, DIMENSION(MAX_DIAG) ::   mld_diags 
    434456 
    435457      NAMELIST/namzdf_mldzint/ nn_mld_diag, sn_mld1, sn_mld2, sn_mld3, sn_mld4, sn_mld5 
     
    447469         IF(lwm) WRITE ( numond, namzdf_mldzint ) 
    448470 
    449          IF( nn_mld_diag > 5 )   CALL ctl_stop( 'STOP', 'zdf_mxl_ini: Specify no more than 5 MLD definitions' ) 
     471         WRITE(cmld,'(I1)') MAX_DIAG  
     472         IF( nn_mld_diag > MAX_DIAG )   CALL ctl_stop( 'STOP', 'zdf_mxl_ini: Specify no more than ', 'cmld', ' MLD definitions' ) 
    450473 
    451474         mld_diags(1) = sn_mld1 
     
    455478         mld_diags(5) = sn_mld5 
    456479 
    457          IF( lwp .AND. (nn_mld_diag > 0) ) THEN 
    458             WRITE(numout,*) '=============== Vertically-interpolated mixed layer ================' 
    459             WRITE(numout,*) '(Diagnostic number, nn_mld_type, rn_zref, rn_dT_crit, rn_iso_frac)' 
     480         cmld_zint=.false. 
     481         cmld_mld=.false. 
     482         IF( nn_mld_diag > 0 ) THEN 
     483            IF( lwp ) THEN 
     484               WRITE(numout,*) '=============== Vertically-interpolated mixed layer ================' 
     485               WRITE(numout,*) '(Diagnostic number, nn_mld_type, rn_zref, rn_dT_crit, rn_iso_frac)' 
     486            END IF 
     487 
    460488            DO jn = 1, nn_mld_diag 
    461                WRITE(numout,*) 'MLD criterion',jn,':' 
    462                WRITE(numout,*) '    nn_mld_type =', mld_diags(jn)%mld_type 
    463                WRITE(numout,*) '    rn_zref ='    , mld_diags(jn)%zref 
    464                WRITE(numout,*) '    rn_dT_crit =' , mld_diags(jn)%dT_crit 
    465                WRITE(numout,*) '    rn_iso_frac =', mld_diags(jn)%iso_frac 
     489               ! Check if the diagnostics is being written to the output 
     490               WRITE(cmld,'(I1)') jn 
     491               IF( iom_use( "mldzint_"//cmld ) ) cmld_zint(jn)=.true.  
     492               IF( iom_use( "mldhtc_"//cmld ) )  cmld_mld(jn) =.true.  
     493 
     494               IF( lwp ) THEN 
     495                  WRITE(numout,*) 'MLD criterion',jn,':' 
     496                  WRITE(numout,*) '    nn_mld_type =', mld_diags(jn)%mld_type 
     497                  WRITE(numout,*) '    rn_zref ='    , mld_diags(jn)%zref 
     498                  WRITE(numout,*) '    rn_dT_crit =' , mld_diags(jn)%dT_crit 
     499                  WRITE(numout,*) '    rn_iso_frac =', mld_diags(jn)%iso_frac 
     500               END IF 
    466501            END DO 
    467502            WRITE(numout,*) '====================================================================' 
     
    470505 
    471506      IF( nn_mld_diag > 0 ) THEN 
     507         CALL zdf_mxl_zint_mld( mld_diags ) 
     508         CALL zdf_mxl_zint_htc( kt ) 
     509 
    472510         DO jn = 1, nn_mld_diag 
    473511            WRITE(cmld,'(I1)') jn 
    474             IF( iom_use( "mldzint_"//cmld ) .OR. iom_use( "mldhtc_"//cmld ) ) THEN 
    475                CALL zdf_mxl_zint_mld( mld_diags(jn) ) 
    476  
    477                IF( iom_use( "mldzint_"//cmld ) ) THEN 
    478                   CALL iom_put( "mldzint_"//cmld, hmld_zint(:,:) ) 
    479                ENDIF 
    480  
    481                IF( iom_use( "mldhtc_"//cmld ) )  THEN 
    482                   CALL zdf_mxl_zint_htc( kt ) 
    483                   CALL iom_put( "mldhtc_"//cmld , htc_mld(:,:)   ) 
    484                ENDIF 
     512            IF( cmld_zint(jn) ) THEN 
     513               CALL iom_put( "mldzint_"//cmld, hmld_zint(:,:,jn) ) 
     514            ENDIF 
     515 
     516            IF( cmld_mld(jn) )  THEN 
     517               CALL iom_put( "mldhtc_"//cmld , htc_mld(:,:,jn)   ) 
    485518            ENDIF 
    486519         END DO 
Note: See TracChangeset for help on using the changeset viewer.