Skip to content
Snippets Groups Projects
turb_ver.F90 28.3 KiB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416
!     ######spl
      SUBROUTINE TURB_VER(KKA,KKU,KKL,KRR,KRRL,KRRI,                &
                      OCLOSE_OUT,OTURB_FLX,                         &
                      HTURBDIM,HTOM,PIMPL,PEXPL,                    & 
                      PTSTEP_UVW,PTSTEP_MET, PTSTEP_SV,             &
                      HFMFILE,HLUOUT,                               &
                      PDXX,PDYY,PDZZ,PDZX,PDZY,PDIRCOSZW,PZZ,       &
                      PCOSSLOPE,PSINSLOPE,                          &
                      PRHODJ,PTHVREF,                               &
                      PSFTHM,PSFRM,PSFSVM,PSFTHP,PSFRP,PSFSVP,      &
                      PCDUEFF,PTAU11M,PTAU12M,PTAU33M,              &
                      PUM,PVM,PWM,PUSLOPEM,PVSLOPEM,PTHLM,PRM,PSVM, &
                      PTKEM,PLM,PLENGTHM,PLENGTHH,PLEPS,MFMOIST,    &
                      PLOCPEXNM,PATHETA,PAMOIST,PSRCM,PFRAC_ICE,    &
                      PFWTH,PFWR,PFTH2,PFR2,PFTHR,PBL_DEPTH,        &
                      PSBL_DEPTH,PLMO,                              &
                      PRUS,PRVS,PRWS,PRTHLS,PRRS,PRSVS,             &
                      PDP,PTP,PSIGS,PWTH,PWRC,PWSV)
      USE PARKIND1, ONLY : JPRB
      USE YOMHOOK , ONLY : LHOOK, DR_HOOK
      USE MODD_CTURB, ONLY : LHARAT
!     ###############################################################
!
!
!!****  *TURB_VER* -compute the source terms due to the vertical turbulent
!!       fluxes.
!!
!!    PURPOSE
!!    -------
!       The purpose of this routine is to compute the vertical turbulent
!     fluxes of the evolutive variables and give back the source 
!     terms to the main program.	In the case of large horizontal meshes,
!     the divergence of these vertical turbulent fluxes represent the whole
!     effect of the turbulence but when the three-dimensionnal version of
!     the turbulence scheme is activated (CTURBDIM="3DIM"), these divergences
!     are completed in the next routine TURB_HOR. 
!		  An arbitrary degree of implicitness has been implemented for the 
!     temporal treatment of these diffusion terms.
!       The vertical boundary conditions are as follows:
!           *  at the bottom, the surface fluxes are prescribed at the same
!              as the other turbulent fluxes
!           *  at the top, the turbulent fluxes are set to 0.
!       It should be noted that the condensation has been implicitely included
!     in this turbulence scheme by using conservative variables and computing
!     the subgrid variance of a statistical variable s indicating the presence 
!     or not of condensation in a given mesh. 
!
!!**  METHOD
!!    ------
!!      1D type calculations are made;
!!      The vertical turbulent fluxes are computed in an off-centered
!!      implicit scheme (a Crank-Nicholson type with coefficients different
!!      than 0.5), which allows to vary the degree of implicitness of the
!!      formulation.
!!      	 The different prognostic variables are treated one by one. 
!!      The contributions of each turbulent fluxes are cumulated into the 
!!      tendency  PRvarS, and into the dynamic and thermal production of 
!!      TKE if necessary.
!!        
!!			 In section 2 and 3, the thermodynamical fields are considered.
!!      Only the turbulent fluxes of the conservative variables
!!      (Thetal and Rnp stored in PRx(:,:,:,1))  are computed. 
!!       Note that the turbulent fluxes at the vertical 
!!      boundaries are given either by the soil scheme for the surface one
!!      ( at the same instant as the others fluxes) and equal to 0 at the 
!!      top of the model. The thermal production is computed by vertically 
!!      averaging the turbulent flux and multiply this flux at the mass point by
!!      a function ETHETA or EMOIST, which preform the transformation from the
!!      conservative variables to the virtual potential temperature. 
!!     
!! 	    In section 4, the variance of the statistical variable
!!      s indicating presence or not of condensation, is determined in function 
!!      of the turbulent moments of the conservative variables and its
!!      squarred root is stored in PSIGS. This information will be completed in 
!!      the horizontal turbulence if the turbulence dimensionality is not 
!!      equal to "1DIM".
!!
!!			 In section 5, the x component of the stress tensor is computed.
!!      The surface flux <u'w'> is computed from the value of the surface
!!      fluxes computed in axes linked to the orography ( i", j" , k"):
!!        i" is parallel to the surface and in the direction of the maximum
!!           slope
!!        j" is also parallel to the surface and in the normal direction of
!!           the maximum slope
!!        k" is the normal to the surface
!!      In order to prevent numerical instability, the implicit scheme has 
!!      been extended to the surface flux regarding to its dependence in 
!!      function of U. The dependence in function of the other components 
!!      introduced by the different rotations is only explicit.
!!      The turbulent fluxes are used to compute the dynamic production of 
!!      TKE. For the last TKE level ( located at PDZZ(:,:,IKB)/2 from the
!!      ground), an harmonic extrapolation from the dynamic production at 
!!      PDZZ(:,:,IKB) is used to avoid an evaluation of the gradient of U
!!      in the surface layer.
!!
!!         In section 6, the same steps are repeated but for the y direction
!!	and in section 7, a diagnostic computation of the W variance is 
!!      performed.
!!
!!         In section 8, the turbulent fluxes for the scalar variables are 
!!      computed by the same way as the conservative thermodynamical variables
!!
!!            
!!    EXTERNAL
!!    --------
!!      GX_U_M, GY_V_M, GZ_W_M :  cartesian gradient operators 
!!      GX_U_UW,GY_V_VW	         (X,Y,Z) represent the direction of the gradient
!!                               _(M,U,...)_ represent the localization of the 
!!                               field to be derivated
!!                               _(M,UW,...) represent the localization of the 
!!                               field	derivated
!!                               
!!
!!      MXM,MXF,MYM,MYF,MZM,MZF
!!                             :  Shuman functions (mean operators)     
!!      DXF,DYF,DZF,DZM
!!                             :  Shuman functions (difference operators)     
!!                               
!!      SUBROUTINE TRIDIAG     : to compute the splitted implicit evolution
!!                               of a variable located at a mass point
!!
!!      SUBROUTINE TRIDIAG_WIND: to compute the splitted implicit evolution
!!                               of a variable located at a wind point
!!
!!      FUNCTIONs ETHETA and EMOIST  :  
!!            allows to compute:
!!            - the coefficients for the turbulent correlation between
!!            any variable and the virtual potential temperature, of its 
!!            correlations with the conservative potential temperature and 
!!            the humidity conservative variable:
!!            -------              -------              -------
!!            A' Thv'  =  ETHETA   A' Thl'  +  EMOIST   A' Rnp'  
!!
!!
!!    IMPLICIT ARGUMENTS
!!    ------------------
!!      Module MODD_CST : contains physical constants
!!
!!           XG         : gravity constant
!!
!!      Module MODD_CTURB: contains the set of constants for
!!                        the turbulence scheme
!!
!!           XCMFS,XCMFB : cts for the momentum flux
!!           XCSHF       : ct for the sensible heat flux
!!           XCHF        : ct for the moisture flux
!!           XCTV,XCHV   : cts for the T and moisture variances
!!
!!      Module MODD_PARAMETERS
!!
!!           JPVEXT_TURB     : number of vertical external points
!!           JPHEXT     : number of horizontal external points
!!
!!
!!    REFERENCE
!!    ---------
!!      Book 1 of documentation (Chapter: Turbulence)
!!
!!    AUTHOR
!!    ------
!!      Joan Cuxart             * INM and Meteo-France *
!!
!!    MODIFICATIONS
!!    -------------
!!      Original       August   19, 1994
!!      Modifications: February 14, 1995 (J.Cuxart and J.Stein) 
!!                                  Doctorization and Optimization
!!      Modifications: March 21, 1995 (J.M. Carriere) 
!!                                  Introduction of cloud water
!!      Modifications: June  14, 1995 (J.Cuxart and J. Stein) 
!!                                 Phi3 and Psi3 at w-point + bug in the all
!!                                 or nothing condens. 
!!      Modifications: Sept  15, 1995 (J.Cuxart and J. Stein) 
!!                                 Change the DP computation at the ground
!!      Modifications: October 10, 1995 (J.Cuxart and J. Stein) 
!!                                 Psi for scal var and LES tools
!!      Modifications: November 10, 1995 (J. Stein)
!!                                 change the surface	relations 
!!      Modifications: February 20, 1995 (J. Stein) optimization
!!      Modifications: May 21, 1996 (J. Stein) 
!!                                  bug in the vertical flux of the V wind 
!!                                  component for explicit computation
!!      Modifications: May 21, 1996 (N. wood) 
!!                                  modify the computation of the vertical
!!                                   part or the surface tangential flux
!!      Modifications: May 21, 1996 (P. Jabouille)
!!                                  same modification in the Y direction
!!      
!!      Modifications: Sept 17, 1996 (J. Stein) change the moist case by using
!!                                  Pi instead of Piref + use Atheta and Amoist
!!
!!      Modifications: Nov  24, 1997 (V. Masson) removes the DO loops 
!!      Modifications: Mar  31, 1998 (V. Masson) splits the routine TURB_VER 
!!                     Nov  06, 2002 (V. Masson) LES budgets
!!                     Feb  20, 2003 (JP Pinty)  Add PFRAC_ICE
!!                     July     2005 (S. Tomas, V. Masson)
!!                                               Add 3rd order moments and
!!                                               implicitation of PHI3, PSI3
!!                     Oct.2009  (C.Lac) Introduction of different PTSTEP according to the
!!                              advection schemes
!!                     Feb. 2012  (Y. Seity) add possibility to run with
!!                                 reversed vertical levels
!!      Modifications: July,    2015  (Wim de Rooy) switch for HARATU (Racmo turbulence scheme)
!!--------------------------------------------------------------------------
!       
!*      0. DECLARATIONS
!          ------------
!
USE MODD_CST
USE MODD_CTURB
USE MODD_PARAMETERS
USE MODD_LES
USE MODD_NSV, ONLY : NSV
!
USE MODI_PRANDTL
USE MODI_EMOIST
USE MODI_ETHETA
USE MODI_GRADIENT_M
USE MODI_GRADIENT_W
USE MODI_TURB
USE MODI_TURB_VER_THERMO_FLUX
USE MODI_TURB_VER_THERMO_CORR
USE MODI_TURB_VER_DYN_FLUX
USE MODI_TURB_VER_SV_FLUX
USE MODI_TURB_VER_SV_CORR
USE MODI_LES_MEAN_SUBGRID
USE MODI_SBL_DEPTH
!
USE MODE_FMWRIT
USE MODE_PRANDTL
!
IMPLICIT NONE
!
!*      0.1  declarations of arguments
!
!
!
INTEGER,                INTENT(IN)   :: KKA           !near ground array index  
INTEGER,                INTENT(IN)   :: KKU           !uppest atmosphere array index
INTEGER,                INTENT(IN)   :: KKL           !vert. levels type 1=MNH -1=ARO
INTEGER,                INTENT(IN)   :: KRR           ! number of moist var.
INTEGER,                INTENT(IN)   :: KRRL          ! number of liquid water var.
INTEGER,                INTENT(IN)   :: KRRI          ! number of ice water var.
LOGICAL,                INTENT(IN)   ::  OCLOSE_OUT   ! switch for syncronous
                                                      ! file opening       
LOGICAL,                INTENT(IN)   ::  OTURB_FLX    ! switch to write the
                                 ! turbulent fluxes in the syncronous FM-file
CHARACTER*4,            INTENT(IN)   ::  HTURBDIM     ! dimensionality of the 
                                                      ! turbulence scheme
CHARACTER*4,            INTENT(IN)   ::  HTOM         ! type of Third Order Moment
REAL,                   INTENT(IN)   ::  PIMPL, PEXPL ! Coef. for temporal disc.
REAL,                   INTENT(IN)   ::  PTSTEP_UVW   ! Dynamical timestep 
REAL,                   INTENT(IN)   ::  PTSTEP_MET   ! Timestep for meteorological variables                        
REAL,                   INTENT(IN)   ::  PTSTEP_SV    ! Timestep for tracer variables
CHARACTER(LEN=*),       INTENT(IN)   ::  HFMFILE      ! Name of the output
                                                      ! FM-file 
CHARACTER(LEN=*),       INTENT(IN)   ::  HLUOUT       ! Output-listing name for
                                                      ! model n
!
REAL, DIMENSION(:,:,:), INTENT(IN)   ::  PDXX, PDYY, PDZZ, PDZX, PDZY 
                                                      ! Metric coefficients
REAL, DIMENSION(:,:),   INTENT(IN)   ::  PDIRCOSZW    ! Director Cosinus of the
                                                      ! normal to the ground surface
REAL, DIMENSION(:,:,:), INTENT(IN)   ::  PZZ          ! altitudes at flux points
REAL, DIMENSION(:,:),   INTENT(IN)   ::  PCOSSLOPE    ! cosinus of the angle 
                                      ! between i and the slope vector
REAL, DIMENSION(:,:),   INTENT(IN)   ::  PSINSLOPE    ! sinus of the angle 
                                      ! between i and the slope vector
!
REAL, DIMENSION(:,:,:), INTENT(IN)   ::  PRHODJ       ! dry density * grid volum
! MFMOIST used in case of LHARATU
REAL, DIMENSION(:,:,:), INTENT(IN)   ::  MFMOIST       ! moist mass flux dual scheme

REAL, DIMENSION(:,:,:), INTENT(IN)   ::  PTHVREF      ! ref. state Virtual 
                                                      ! Potential Temperature 
!
REAL, DIMENSION(:,:),   INTENT(IN)   ::  PSFTHM,PSFRM ! surface fluxes at time
REAL, DIMENSION(:,:,:), INTENT(IN)   ::  PSFSVM       ! t - deltat 
!
REAL, DIMENSION(:,:),   INTENT(IN)   ::  PSFTHP,PSFRP ! surface fluxes at time
REAL, DIMENSION(:,:,:), INTENT(IN)   ::  PSFSVP       ! t + deltat 
!
REAL, DIMENSION(:,:),   INTENT(IN)   ::  PCDUEFF     ! Cd * || u || at time t
REAL, DIMENSION(:,:),   INTENT(IN)   ::  PTAU11M      ! <uu> in the axes linked 
       ! to the maximum slope direction and the surface normal and the binormal 
       ! at time t - dt
REAL, DIMENSION(:,:),   INTENT(IN)   ::  PTAU12M      ! <uv> in the same axes
REAL, DIMENSION(:,:),   INTENT(IN)   ::  PTAU33M      ! <ww> in the same axes
!
REAL, DIMENSION(:,:,:), INTENT(IN)   ::  PUM,PVM,PWM,PTHLM 
  ! Wind and potential temperature at t-Delta t
REAL, DIMENSION(:,:,:,:), INTENT(IN) ::  PRM          ! Mixing ratios 
                                                      ! at t-Delta t
REAL, DIMENSION(:,:,:,:), INTENT(IN) ::  PSVM         ! scalar var. at t-Delta t
REAL, DIMENSION(:,:),   INTENT(IN)   ::  PUSLOPEM     ! wind component along the 
                                     ! maximum slope direction
REAL, DIMENSION(:,:),   INTENT(IN)   ::  PVSLOPEM     ! wind component along the 
                                     ! direction normal to the maximum slope one
!
REAL, DIMENSION(:,:,:), INTENT(IN)   ::  PTKEM        ! TKE at time t
!
REAL, DIMENSION(:,:,:), INTENT(IN)   ::  PLM          ! Turb. mixing length   
! PLENGTHM PLENGTHH used in case of LHARATU
REAL, DIMENSION(:,:,:), INTENT(IN)   ::  PLENGTHM     ! Turb. mixing length momentum
REAL, DIMENSION(:,:,:), INTENT(IN)   ::  PLENGTHH     ! Turb. mixing length heat/moisture 
REAL, DIMENSION(:,:,:), INTENT(IN)   ::  PLEPS        ! dissipative length
REAL, DIMENSION(:,:,:), INTENT(IN)   ::  PLOCPEXNM    ! Lv(T)/Cp/Exnref at time t-1
REAL, DIMENSION(:,:,:), INTENT(IN)   ::  PATHETA      ! coefficients between 
REAL, DIMENSION(:,:,:), INTENT(IN)   ::  PAMOIST      ! s and Thetal and Rnp
REAL, DIMENSION(:,:,:), INTENT(IN)   ::  PSRCM        ! normalized 
                  ! 2nd-order flux s'r'c/2Sigma_s2 at t-1 multiplied by Lambda_3
REAL, DIMENSION(:,:,:), INTENT(IN)   ::  PFRAC_ICE    ! ri fraction of rc+ri
REAL, DIMENSION(:,:,:), INTENT(IN)   ::  PFWTH        ! d(w'2th' )/dz
REAL, DIMENSION(:,:,:), INTENT(IN)   ::  PFWR         ! d(w'2r'  )/dz
REAL, DIMENSION(:,:,:), INTENT(IN)   ::  PFTH2        ! d(w'th'2 )/dz
REAL, DIMENSION(:,:,:), INTENT(IN)   ::  PFR2         ! d(w'r'2  )/dz
REAL, DIMENSION(:,:,:), INTENT(IN)   ::  PFTHR        ! d(w'th'r')/dz
REAL, DIMENSION(:,:),   INTENT(INOUT)::  PBL_DEPTH    ! BL depth
REAL, DIMENSION(:,:),   INTENT(INOUT)::  PSBL_DEPTH   ! SBL depth
REAL, DIMENSION(:,:),   INTENT(IN)   ::  PLMO         ! Monin-Obukhov length
!
REAL, DIMENSION(:,:,:), INTENT(INOUT)   ::  PRUS, PRVS, PRWS, PRTHLS
REAL, DIMENSION(:,:,:,:), INTENT(INOUT) ::  PRSVS,PRRS
                            ! cumulated sources for the prognostic variables
!
REAL, DIMENSION(:,:,:), INTENT(OUT)  ::  PDP,PTP   ! Dynamic and thermal
                                                   ! TKE production terms
REAL, DIMENSION(:,:,:), INTENT(OUT)  ::  PSIGS     ! Vert. part of Sigma_s at t
REAL, DIMENSION(:,:,:), INTENT(OUT)  :: PWTH      ! heat flux
REAL, DIMENSION(:,:,:), INTENT(OUT)  :: PWRC      ! cloud water flux
REAL, DIMENSION(:,:,:,:),INTENT(OUT) :: PWSV       ! scalar flux

!
!
!
!
!*       0.2  declaration of local variables
!
REAL, DIMENSION(SIZE(PTHLM,1),SIZE(PTHLM,2),SIZE(PTHLM,3))  ::  &
       ZBETA,    & ! buoyancy coefficient
       ZSQRT_TKE,& ! sqrt(e)
       ZDTH_DZ,  & ! d(th)/dz
       ZDR_DZ,   & ! d(rt)/dz
       ZRED2TH3, & ! 3D Redeslperger number R*2_th
       ZRED2R3,  & ! 3D Redeslperger number R*2_r
       ZRED2THR3,& ! 3D Redeslperger number R*2_thr
       ZBLL_O_E, & ! beta * Lk * Leps / tke
       ZETHETA,  & ! Coefficient for theta in theta_v computation
       ZEMOIST,  & ! Coefficient for r in theta_v computation
       ZREDTH1,  & ! 1D Redelsperger number for Th
       ZREDR1,   & ! 1D Redelsperger number for r
       ZPHI3,    & ! phi3 Prandtl number
       ZPSI3,    & ! psi3 Prandtl number for vapor
       ZD,       & ! denominator in phi3 terms
       ZWTHV,    & ! buoyancy flux
       ZWU,      & ! (u'w')
       ZWV,      & ! (v'w')
       ZTHLP,    & ! guess of potential temperature due to vert. turbulent flux
       ZRP         ! guess of total water due to vert. turbulent flux
REAL, DIMENSION(SIZE(PTHLM,1),SIZE(PTHLM,2),SIZE(PTHLM,3),NSV)  ::  &
       ZPSI_SV,  & ! Prandtl number for scalars
       ZREDS1,   & ! 1D Redeslperger number R_sv
       ZRED2THS, & ! 3D Redeslperger number R*2_thsv
       ZRED2RS     ! 3D Redeslperger number R*2_rsv
REAL, DIMENSION(SIZE(PLM,1),SIZE(PLM,2),SIZE(PLM,3))  ::  ZLM
INTEGER             :: IRESP        ! Return code of FM routines 
INTEGER             :: IGRID        ! C-grid indicator in LFIFM file 
INTEGER             :: ILENCH       ! Length of comment string in LFIFM file
CHARACTER (LEN=100) :: YCOMMENT     ! comment string in LFIFM file
CHARACTER (LEN=16)  :: YRECFM       ! Name of the desired field in LFIFM file
!
LOGICAL :: GUSERV    ! flag to use water vapor
INTEGER :: IKB,IKE   ! index value for the Beginning
                     ! and the End of the physical domain for the mass points
INTEGER :: JSV       ! loop counter on scalar variables
REAL    :: ZTIME1
REAL    :: ZTIME2
!----------------------------------------------------------------------------
!
!*       1.   PRELIMINARIES
!             -------------
!
REAL(KIND=JPRB) :: ZHOOK_HANDLE
IF (LHOOK) CALL DR_HOOK('TURB_VER',0,ZHOOK_HANDLE)
PTP (:,:,:) = 0.
PDP (:,:,:) = 0.
!
IKB=KKA+JPVEXT_TURB*KKL
IKE=KKU-JPVEXT_TURB*KKL

!
!
! 3D Redelsperger numbers
!
!
CALL PRANDTL(KKA,KKU,KKL,KRR,KRRI,OCLOSE_OUT,OTURB_FLX,        &
             HTURBDIM,                             &
             HFMFILE,HLUOUT,                       &
             PDXX,PDYY,PDZZ,PDZX,PDZY,             &
             PTHVREF,PLOCPEXNM,PATHETA,PAMOIST,    &
             PLM,PLEPS,PTKEM,PTHLM,PRM,PSVM,PSRCM, &
             ZREDTH1, ZREDR1,                      &
             ZRED2TH3, ZRED2R3, ZRED2THR3,         &
             ZREDS1,ZRED2THS, ZRED2RS,             &
             ZBLL_O_E,                             &
             ZETHETA, ZEMOIST                      )
! Buoyancy coefficient
!
ZBETA = XG/PTHVREF
!
! Square root of Tke
!
ZSQRT_TKE = SQRT(PTKEM)
!
! gradients of mean quantities at previous time-step
!
ZDTH_DZ = GZ_M_W(PTHLM(:,:,:),PDZZ, KKA, KKU, KKL)
IF (KRR>0) ZDR_DZ  = GZ_M_W(PRM(:,:,:,1),PDZZ, KKA, KKU, KKL)
!
!
! Denominator factor in 3rd order terms
!
IF (.NOT. LHARAT) THEN
ZD(:,:,:) = (1.+ZREDTH1+ZREDR1) * (1.+0.5*(ZREDTH1+ZREDR1))
ELSE
ZD(:,:,:) = 1.
ENDIF
!
! Phi3 and Psi3 Prandtl numbers
!
GUSERV = KRR/=0
!
ZPHI3 = PHI3(ZREDTH1,ZREDR1,ZRED2TH3,ZRED2R3,ZRED2THR3,HTURBDIM,GUSERV)
IF(KRR/=0) &
ZPSI3 = PSI3(ZREDR1,ZREDTH1,ZRED2R3,ZRED2TH3,ZRED2THR3,HTURBDIM,GUSERV)
!
! Prandtl numbers for scalars
!
ZPSI_SV = PSI_SV(ZREDTH1,ZREDR1,ZREDS1,ZRED2THS,ZRED2RS,ZPHI3,ZPSI3)
!
! LES diagnostics
!
IF (LLES_CALL) THEN
  CALL SECOND_MNH(ZTIME1)
  CALL LES_MEAN_SUBGRID(ZPHI3,X_LES_SUBGRID_PHI3)
  IF(KRR/=0) THEN
    CALL LES_MEAN_SUBGRID(ZPSI3,X_LES_SUBGRID_PSI3)
  END IF
  CALL SECOND_MNH(ZTIME2)
  XTIME_LES = XTIME_LES + ZTIME2 - ZTIME1
END IF

!ENDIF
!----------------------------------------------------------------------------
!
!
!*       2.   SOURCES OF CONSERVATIVE POTENTIAL TEMPERATURE AND 
!                                                  PARTIAL THERMAL PRODUCTION 
!             ---------------------------------------------------------------
!
!*       3.   SOURCES OF CONSERVATIVE AND CLOUD MIXING RATIO AND 
!                                        COMPLETE THERMAL PRODUCTION 
!             ------------------------------------------------------
!
!*       4.   TURBULENT CORRELATIONS : <w Rc>, <THl THl>, <THl Rnp>, <Rnp Rnp>
!             ----------------------------------------------------------------
!

IF (LHARAT) THEN
ZLM=PLENGTHH
ELSE
ZLM=PLM
ENDIF
!
  CALL  TURB_VER_THERMO_FLUX(KKA,KKU,KKL,KRR,KRRL,KRRI,               &
                        OCLOSE_OUT,OTURB_FLX,HTURBDIM,HTOM,           &
                        PIMPL,PEXPL,                                  &
                        PTSTEP_MET,                                   &
                        HFMFILE,HLUOUT,                               &
                        PDXX,PDYY,PDZZ,PDZX,PDZY,PDIRCOSZW,PZZ,       &
                        PRHODJ,PTHVREF,                               &
                        PSFTHM,PSFRM,PSFTHP,PSFRP,                    &
                        PWM,PTHLM,PRM,PSVM,                           &
                        PTKEM,ZLM,PLEPS,                         &
                        PLOCPEXNM,PATHETA,PAMOIST,PSRCM,PFRAC_ICE,    &
                        ZBETA, ZSQRT_TKE, ZDTH_DZ, ZDR_DZ, ZRED2TH3,  &
                        ZRED2R3, ZRED2THR3, ZBLL_O_E, ZETHETA,        &
                        ZEMOIST, ZREDTH1, ZREDR1, ZPHI3, ZPSI3, ZD,   &
                        PFWTH,PFWR,PFTH2,PFR2,PFTHR,                  &
                        MFMOIST,PBL_DEPTH,ZWTHV,                      &
                        PRTHLS,PRRS,ZTHLP,ZRP,PTP,PWTH,PWRC )
!
!
!
!  Use Lh (=Lq) from vdfexcuhl as input for turb_ver_thermo_corr

  CALL  TURB_VER_THERMO_CORR(KKA,KKU,KKL,KRR,KRRL,KRRI,               &
                        OCLOSE_OUT,OTURB_FLX,HTURBDIM,HTOM,           &
                        PIMPL,PEXPL,                                  &
                        HFMFILE,HLUOUT,                               &
                        PDXX,PDYY,PDZZ,PDZX,PDZY,PDIRCOSZW,           &
                        PRHODJ,PTHVREF,                               &
                        PSFTHM,PSFRM,PSFTHP,PSFRP,                    &
                        PWM,PTHLM,PRM,PSVM,                           &
                        PTKEM,ZLM,PLEPS,                              &
                        PLOCPEXNM,PATHETA,PAMOIST,PSRCM,              &
                        ZBETA, ZSQRT_TKE, ZDTH_DZ, ZDR_DZ, ZRED2TH3,  &
                        ZRED2R3, ZRED2THR3, ZBLL_O_E, ZETHETA,        &
                        ZEMOIST, ZREDTH1, ZREDR1, ZPHI3, ZPSI3, ZD,   &
                        PFWTH,PFWR,PFTH2,PFR2,PFTHR,                  &
                        ZTHLP,ZRP,MFMOIST,PSIGS                  )
!
!----------------------------------------------------------------------------
!
!
!
!*       5.   SOURCES OF U,W WIND COMPONENTS AND PARTIAL DYNAMIC PRODUCTION 
!             -------------------------------------------------------------
!
!*       6.   SOURCES OF V,W WIND COMPONENTS AND COMPLETE 1D DYNAMIC PRODUCTION 
!             -----------------------------------------------------------------
!
!*       7.   DIAGNOSTIC COMPUTATION OF THE 1D <W W> VARIANCE
!             -----------------------------------------------
!
!
IF (LHARAT) THEN
ZLM=PLENGTHM
ENDIF

CALL  TURB_VER_DYN_FLUX(KKA,KKU,KKL,                                &
                      OCLOSE_OUT,OTURB_FLX,KRR,                     &
                      HTURBDIM,PIMPL,PEXPL,                         &
                      PTSTEP_UVW,                                   &
                      HFMFILE,HLUOUT,                               &
                      PDXX,PDYY,PDZZ,PDZX,PDZY,PDIRCOSZW,PZZ,       &
                      PCOSSLOPE,PSINSLOPE,                          &
                      PRHODJ,                                       &
                      PCDUEFF,PTAU11M,PTAU12M,PTAU33M,              &
                      PTHLM,PRM,PSVM,PUM,PVM,PWM,PUSLOPEM,PVSLOPEM, &
                      PTKEM,ZLM,MFMOIST,ZWU,ZWV,                    &
                      PRUS,PRVS,PRWS,                               &
                      PDP,PTP                               )
!
!----------------------------------------------------------------------------
!
!
!*       8.   SOURCES OF PASSIVE SCALAR VARIABLES
!             -----------------------------------
!
IF (LHARAT) THEN
ZLM=PLENGTHH
ENDIF

IF (SIZE(PSVM,4)>0)                                                 &
CALL  TURB_VER_SV_FLUX(KKA,KKU,KKL,                                 &
                      OCLOSE_OUT,OTURB_FLX,HTURBDIM,                &
                      PIMPL,PEXPL,                                  &
                      PTSTEP_SV,                                    &
                      HFMFILE,HLUOUT,                               &
                      PDZZ,PDIRCOSZW,                               &
                      PRHODJ,PWM,                                   &
                      PSFSVM,PSFSVP,                                &
                      PSVM,                                         &
                      PTKEM,ZLM,MFMOIST,ZPSI_SV,                    &
                      PRSVS,PWSV                                    )
!
!
IF (SIZE(PSVM,4)>0 .AND. LLES_CALL)                                 &
CALL  TURB_VER_SV_CORR(KKA,KKU,KKL,KRR,KRRL,KRRI,                               &
                      PDZZ,                                         &
                      PTHLM,PRM,PTHVREF,                            &
                      PLOCPEXNM,PATHETA,PAMOIST,PSRCM,ZPHI3,ZPSI3,  &
                      PWM,PSVM,                                     &
                      PTKEM,ZLM,PLEPS,ZPSI_SV                       )
!
!
!----------------------------------------------------------------------------
!
!*       9.   DIAGNOSTIC OF Surface Boundary Layer Depth
!             ------------------------------------------
!
IF (SIZE(PSBL_DEPTH)>0) CALL SBL_DEPTH(IKB,IKE,PZZ,ZWU,ZWV,ZWTHV,PLMO,PSBL_DEPTH)
!
!----------------------------------------------------------------------------
!
!
!*      10.   PRINTS
!             ------
!
!
IF ( OTURB_FLX .AND. OCLOSE_OUT .AND. .NOT. LHARAT) THEN
!
! stores the Turbulent Prandtl number
! 
  YRECFM  ='PHI3'
  YCOMMENT='X_Y_Z_PHI3 (0)'
  IGRID   = 4
  ILENCH=LEN(YCOMMENT)
  CALL  FMWRIT(HFMFILE,YRECFM,HLUOUT,'XY',ZPHI3,IGRID,ILENCH,YCOMMENT,IRESP)
!
! stores the Turbulent Schmidt number
! 
  YRECFM  ='PSI3'
  YCOMMENT='X_Y_Z_PSI3 (0)'
  IGRID   = 4
  ILENCH=LEN(YCOMMENT)
!
  CALL FMWRIT(HFMFILE,YRECFM,HLUOUT,'XY',ZPSI3,IGRID,ILENCH,YCOMMENT,IRESP)
!
!
! stores the Turbulent Schmidt number for the scalar variables
! 
  DO JSV=1,NSV
    WRITE(YRECFM, '("PSI_SV_",I3.3)') JSV
    YCOMMENT='X_Y_Z_'//YRECFM//' (0)'
    IGRID   = 4
    ILENCH=LEN(YCOMMENT)
    CALL FMWRIT(HFMFILE,YRECFM,HLUOUT,'XY',ZPSI_SV(:,:,:,JSV),   &
                IGRID,ILENCH,YCOMMENT,IRESP)
  END DO

END IF
!
!
!----------------------------------------------------------------------------
IF (LHOOK) CALL DR_HOOK('TURB_VER',1,ZHOOK_HANDLE)
END SUBROUTINE TURB_VER