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 15603 for branches/UKMO/dev_r5518_GO6_starthour_obsoper/NEMOGCM/NEMO/OPA_SRC/ZDF – NEMO

Ignore:
Timestamp:
2021-12-16T10:39:55+01:00 (3 years ago)
Author:
mattmartin
Message:

Updated NEMO branch for coupled NWP at GO6 to include stochastic model perturbations.
For more info see ticket: https://code.metoffice.gov.uk/trac/nwpscience/ticket/1125.

Location:
branches/UKMO/dev_r5518_GO6_starthour_obsoper/NEMOGCM/NEMO/OPA_SRC/ZDF
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/UKMO/dev_r5518_GO6_starthour_obsoper/NEMOGCM/NEMO/OPA_SRC/ZDF/zdfbfr.F90

    r12555 r15603  
    2626   USE wrk_nemo        ! Memory Allocation 
    2727   USE phycst, ONLY: vkarmn 
     28   USE stopack 
    2829 
    2930   IMPLICIT NONE 
     
    5253   REAL(wp), PUBLIC ::   rn_tfrz0     ! bottom roughness for loglayer bfr coeff (PUBLIC for TAM) 
    5354   LOGICAL , PUBLIC ::   ln_bfrimp    ! logical switch for implicit bottom friction 
    54    REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:), PUBLIC ::  bfrcoef2d, tfrcoef2d   ! 2D bottom/top drag coefficient (PUBLIC for TAM) 
     55   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:), PUBLIC ::  bfrcoef2d, tfrcoef2d,bfrcoef2d0   ! 2D bottom/top drag coefficient (PUBLIC for TAM) 
    5556 
    5657   !! * Substitutions 
     
    6869      !!                ***  FUNCTION zdf_bfr_alloc  *** 
    6970      !!---------------------------------------------------------------------- 
    70       ALLOCATE( bfrcoef2d(jpi,jpj), tfrcoef2d(jpi,jpj), STAT=zdf_bfr_alloc ) 
     71      ALLOCATE( bfrcoef2d(jpi,jpj), tfrcoef2d(jpi,jpj), bfrcoef2d0(jpi,jpj),STAT=zdf_bfr_alloc ) 
    7172      ! 
    7273      IF( lk_mpp             )   CALL mpp_sum ( zdf_bfr_alloc ) 
     
    107108         IF(lflush) CALL flush(numout) 
    108109      ENDIF 
     110      ! 
     111#if defined key_traldf_c2d || key_traldf_c3d 
     112      IF( ln_stopack .AND. ( nn_spp_bfr > 0 ) ) THEN 
     113         bfrcoef2d = bfrcoef2d0 
     114         CALL spp_gen(kt, bfrcoef2d, nn_spp_bfr, rn_bfr_sd, jk_spp_bfr) 
     115      ENDIF 
     116#else 
     117      IF ( ln_stopack .AND. ( nn_spp_bfr > 0 ) ) & 
     118         & CALL ctl_stop( 'zdf_bfr: parameter perturbation will only work with '// & 
     119                          'key_traldf_c2d or key_traldf_c3d') 
     120#endif 
    109121      ! 
    110122      IF( nn_bfr == 2 ) THEN                 ! quadratic bottom friction only 
     
    135147               END DO 
    136148            END IF 
    137          !    
     149         ! 
    138150         ELSE 
    139151            zbfrt(:,:) = bfrcoef2d(:,:) 
     
    178190               DO ji = 2, jpim1 
    179191                  ! (ISF) ======================================================================== 
    180                   ikbu = miku(ji,jj)         ! ocean top level at u- and v-points  
     192                  ikbu = miku(ji,jj)         ! ocean top level at u- and v-points 
    181193                  ikbv = mikv(ji,jj)         ! (1st wet ocean u- and v-points) 
    182194                  ! 
     
    359371            bfrcoef2d(:,:) = rn_bfri2  ! initialize bfrcoef2d to the namelist variable 
    360372         ENDIF 
    361           
     373 
    362374         IF ( ln_isfcav ) THEN 
    363375            IF(ln_tfr2d) THEN 
     
    494506      ENDIF 
    495507      ! 
     508      bfrcoef2d0(:,:) = bfrcoef2d(:,:) 
    496509      IF( nn_timing == 1 )  CALL timing_stop('zdf_bfr_init') 
    497510      ! 
  • branches/UKMO/dev_r5518_GO6_starthour_obsoper/NEMOGCM/NEMO/OPA_SRC/ZDF/zdfevd.F90

    r12555 r15603  
    2020   USE zdfkpp          ! KPP vertical mixing 
    2121   USE trd_oce         ! trends: ocean variables 
    22    USE trdtra          ! trends manager: tracers  
     22   USE trdtra          ! trends manager: tracers 
    2323   USE in_out_manager  ! I/O manager 
    2424   USE iom             ! for iom_put 
    2525   USE lbclnk          ! ocean lateral boundary conditions (or mpp link) 
    2626   USE timing          ! Timing 
     27   USE stopack 
    2728 
    2829   IMPLICIT NONE 
     
    3031 
    3132   PUBLIC   zdf_evd    ! called by step.F90 
     33   REAL(wp), SAVE, ALLOCATABLE, DIMENSION(:,:) :: rn_avevd0 
    3234 
    3335   !! * Substitutions 
     
    4345      !!---------------------------------------------------------------------- 
    4446      !!                  ***  ROUTINE zdf_evd  *** 
    45       !!                    
     47      !! 
    4648      !! ** Purpose :   Local increased the vertical eddy viscosity and diffu- 
    4749      !!      sivity coefficients when a static instability is encountered. 
    4850      !! 
    4951      !! ** Method  :   avt, avm, and the 4 neighbouring avmu, avmv coefficients 
    50       !!      are set to avevd (namelist parameter) if the water column is  
     52      !!      are set to avevd (namelist parameter) if the water column is 
    5153      !!      statically unstable (i.e. if rn2 < -1.e-12 ) 
    5254      !! 
     
    7072         IF(lwp) WRITE(numout,*) 
    7173         IF(lwp .AND. lflush) CALL flush(numout) 
     74         ALLOCATE ( rn_avevd0(jpi,jpj) ) 
     75         rn_avevd0(:,:) = rn_avevd 
    7276      ENDIF 
    7377 
    7478      zavt_evd(:,:,:) = avt(:,:,:)           ! set avt prior to evd application 
     79 
     80#if defined key_traldf_c2d || key_traldf_c3d 
     81      IF( ln_stopack .AND. ( nn_spp_aevd > 0 ) ) THEN 
     82         rn_avevd0(:,:) = rn_avevd 
     83         CALL spp_gen(kt, rn_avevd0, nn_spp_aevd, rn_aevd_sd, jk_spp_aevd) 
     84      ENDIF 
     85#else 
     86      IF ( ln_stopack .AND. ( nn_spp_aevd > 0 ) ) & 
     87         & CALL ctl_stop( 'zdf_evd: parameter perturbation will only work with '// & 
     88                          'key_traldf_c2d or key_traldf_c3d') 
     89#endif 
    7590 
    7691      SELECT CASE ( nn_evdm ) 
     
    8095         zavm_evd(:,:,:) = avm(:,:,:)           ! set avm prior to evd application 
    8196         ! 
    82          DO jk = 1, jpkm1  
     97         DO jk = 1, jpkm1 
    8398            DO jj = 2, jpj             ! no vector opt. 
    8499               DO ji = 2, jpi 
     
    89104                  IF(  MIN( rn2(ji,jj,jk), rn2b(ji,jj,jk) ) <= -1.e-12 ) THEN 
    90105#endif 
    91                      avt (ji  ,jj  ,jk) = rn_avevd * tmask(ji  ,jj  ,jk) 
    92                      avm (ji  ,jj  ,jk) = rn_avevd * tmask(ji  ,jj  ,jk) 
    93                      avmu(ji  ,jj  ,jk) = rn_avevd * umask(ji  ,jj  ,jk) 
    94                      avmu(ji-1,jj  ,jk) = rn_avevd * umask(ji-1,jj  ,jk) 
    95                      avmv(ji  ,jj  ,jk) = rn_avevd * vmask(ji  ,jj  ,jk) 
    96                      avmv(ji  ,jj-1,jk) = rn_avevd * vmask(ji  ,jj-1,jk) 
     106                     avt (ji  ,jj  ,jk) = rn_avevd0(ji,jj) * tmask(ji  ,jj  ,jk) 
     107                     avm (ji  ,jj  ,jk) = rn_avevd0(ji,jj) * tmask(ji  ,jj  ,jk) 
     108                     avmu(ji  ,jj  ,jk) = rn_avevd0(ji,jj) * umask(ji  ,jj  ,jk) 
     109                     avmu(ji-1,jj  ,jk) = rn_avevd0(ji,jj) * umask(ji-1,jj  ,jk) 
     110                     avmv(ji  ,jj  ,jk) = rn_avevd0(ji,jj) * vmask(ji  ,jj  ,jk) 
     111                     avmv(ji  ,jj-1,jk) = rn_avevd0(ji,jj) * vmask(ji  ,jj-1,jk) 
    97112                  ENDIF 
    98113               END DO 
    99114            END DO 
    100          END DO  
     115         END DO 
    101116         CALL lbc_lnk( avt , 'W', 1. )   ;   CALL lbc_lnk( avm , 'W', 1. )   ! Lateral boundary conditions 
    102117         CALL lbc_lnk( avmu, 'U', 1. )   ;   CALL lbc_lnk( avmv, 'V', 1. ) 
     
    105120         CALL iom_put( "avm_evd", zavm_evd )              ! output this change 
    106121         ! 
    107       CASE DEFAULT         ! enhance vertical eddy diffusivity only (if rn2<-1.e-12)  
     122      CASE DEFAULT         ! enhance vertical eddy diffusivity only (if rn2<-1.e-12) 
    108123         DO jk = 1, jpkm1 
    109 !!!         WHERE( rn2(:,:,jk) <= -1.e-12 ) avt(:,:,jk) = tmask(:,:,jk) * avevd   ! agissant sur T SEUL!  
     124!!!         WHERE( rn2(:,:,jk) <= -1.e-12 ) avt(:,:,jk) = tmask(:,:,jk) * avevd   ! agissant sur T SEUL! 
    110125            DO jj = 1, jpj             ! loop over the whole domain (no lbc_lnk call) 
    111126               DO ji = 1, jpi 
    112127#if defined key_zdfkpp 
    113128                  ! no evd mixing in the boundary layer with KPP 
    114                   IF(  MIN( rn2(ji,jj,jk), rn2b(ji,jj,jk) ) <= -1.e-12  .AND.  fsdepw(ji,jj,jk) > hkpp(ji,jj)  )   &           
     129                  IF(  MIN( rn2(ji,jj,jk), rn2b(ji,jj,jk) ) <= -1.e-12  .AND.  fsdepw(ji,jj,jk) > hkpp(ji,jj)  )   & 
    115130#else 
    116131                  IF(  MIN( rn2(ji,jj,jk), rn2b(ji,jj,jk) ) <= -1.e-12 )   & 
    117132#endif 
    118                      avt(ji,jj,jk) = rn_avevd * tmask(ji,jj,jk) 
     133                     avt(ji,jj,jk) = rn_avevd0(ji,jj) * tmask(ji,jj,jk) 
    119134               END DO 
    120135            END DO 
    121136         END DO 
    122137         ! 
    123       END SELECT  
     138      END SELECT 
    124139 
    125140      zavt_evd(:,:,:) = avt(:,:,:) - zavt_evd(:,:,:)   ! change in avt due to evd 
  • branches/UKMO/dev_r5518_GO6_starthour_obsoper/NEMOGCM/NEMO/OPA_SRC/ZDF/zdfgls.F90

    r12555 r15603  
    22   !!====================================================================== 
    33   !!                       ***  MODULE  zdfgls  *** 
    4    !! Ocean physics:  vertical mixing coefficient computed from the gls  
     4   !! Ocean physics:  vertical mixing coefficient computed from the gls 
    55   !!                 turbulent closure parameterization 
    66   !!====================================================================== 
     
    1616   !!   gls_rst       : read/write gls restart in ocean restart file 
    1717   !!---------------------------------------------------------------------- 
    18    USE oce            ! ocean dynamics and active tracers  
     18   USE oce            ! ocean dynamics and active tracers 
    1919   USE dom_oce        ! ocean space and time domain 
    2020   USE domvvl         ! ocean space and time domain : variable volume layer 
     
    3131   USE iom            ! I/O manager library 
    3232   USE timing         ! Timing 
    33    USE lib_fortran    ! Fortran utilities (allows no signed zero when 'key_nosignedzero' defined)   
     33   USE lib_fortran    ! Fortran utilities (allows no signed zero when 'key_nosignedzero' defined) 
     34   USE stopack 
    3435 
    3536   IMPLICIT NONE 
     
    6162   REAL(wp) ::   rn_crban          ! Craig and Banner constant for surface breaking waves mixing 
    6263   REAL(wp) ::   rn_hsro           ! Minimum surface roughness 
    63    REAL(wp) ::   rn_frac_hs        ! Fraction of wave height as surface roughness (if nn_z0_met > 1)  
     64   REAL(wp) ::   rn_frac_hs        ! Fraction of wave height as surface roughness (if nn_z0_met > 1) 
    6465 
    6566   REAL(wp) ::   rcm_sf        =  0.73_wp     ! Shear free turbulence parameters 
    66    REAL(wp) ::   ra_sf         = -2.0_wp      ! Must be negative -2 < ra_sf < -1  
    67    REAL(wp) ::   rl_sf         =  0.2_wp      ! 0 <rl_sf<vkarmn     
     67   REAL(wp) ::   ra_sf         = -2.0_wp      ! Must be negative -2 < ra_sf < -1 
     68   REAL(wp) ::   rl_sf         =  0.2_wp      ! 0 <rl_sf<vkarmn 
    6869   REAL(wp) ::   rghmin        = -0.28_wp 
    6970   REAL(wp) ::   rgh0          =  0.0329_wp 
     
    7273   REAL(wp) ::   ra2           =  0.74_wp 
    7374   REAL(wp) ::   rb1           = 16.60_wp 
    74    REAL(wp) ::   rb2           = 10.10_wp          
    75    REAL(wp) ::   re2           =  1.33_wp          
     75   REAL(wp) ::   rb2           = 10.10_wp 
     76   REAL(wp) ::   re2           =  1.33_wp 
    7677   REAL(wp) ::   rl1           =  0.107_wp 
    7778   REAL(wp) ::   rl2           =  0.0032_wp 
     
    133134      INTEGER  ::   ji, jj, jk, ibot, ibotm1, dir  ! dummy loop arguments 
    134135      REAL(wp) ::   zesh2, zsigpsi, zcoef, zex1, zex2   ! local scalars 
    135       REAL(wp) ::   ztx2, zty2, zup, zdown, zcof        !   -      -  
     136      REAL(wp) ::   ztx2, zty2, zup, zdown, zcof        !   -      - 
    136137      REAL(wp) ::   zratio, zrn2, zflxb, sh             !   -      - 
    137138      REAL(wp) ::   prod, buoy, diss, zdiss, sm         !   -      - 
     
    139140      REAL(wp), POINTER, DIMENSION(:,:  ) ::   zdep 
    140141      REAL(wp), POINTER, DIMENSION(:,:  ) ::   zkar 
    141       REAL(wp), POINTER, DIMENSION(:,:  ) ::   zflxs       ! Turbulence fluxed induced by internal waves  
     142      REAL(wp), POINTER, DIMENSION(:,:  ) ::   zflxs       ! Turbulence fluxed induced by internal waves 
    142143      REAL(wp), POINTER, DIMENSION(:,:  ) ::   zhsro       ! Surface roughness (surface waves) 
    143144      REAL(wp), POINTER, DIMENSION(:,:,:) ::   eb          ! tke at time before 
     
    156157      CALL wrk_alloc( jpi,jpj, zdep, zkar, zflxs, zhsro ) 
    157158      CALL wrk_alloc( jpi,jpj,jpk, eb, mxlb, shear, eps, zwall_psi, z_elem_a, z_elem_b, z_elem_c, psi  ) 
    158        
     159 
    159160      ! Preliminary computing 
    160161 
     
    165166         avm (:,:,:) = avm_k (:,:,:) 
    166167         avmu(:,:,:) = avmu_k(:,:,:) 
    167          avmv(:,:,:) = avmv_k(:,:,:)  
     168         avmv(:,:,:) = avmv_k(:,:,:) 
    168169      ENDIF 
    169170 
    170171      ! Compute surface and bottom friction at T-points 
    171 !CDIR NOVERRCHK           
    172       DO jj = 2, jpjm1           
    173 !CDIR NOVERRCHK          
    174          DO ji = fs_2, fs_jpim1   ! vector opt.          
     172!CDIR NOVERRCHK 
     173      DO jj = 2, jpjm1 
     174!CDIR NOVERRCHK 
     175         DO ji = fs_2, fs_jpim1   ! vector opt. 
    175176            ! 
    176177            ! surface friction 
    177178            ustars2(ji,jj) = r1_rau0 * taum(ji,jj) * tmask(ji,jj,1) 
    178             !    
    179             ! bottom friction (explicit before friction)         
    180             ! Note that we chose here not to bound the friction as in dynbfr)    
    181             ztx2 = (  bfrua(ji,jj)  * ub(ji,jj,mbku(ji,jj)) + bfrua(ji-1,jj) * ub(ji-1,jj,mbku(ji-1,jj))  )   &          
    182                & * ( 1._wp - 0.5_wp * umask(ji,jj,1) * umask(ji-1,jj,1)  )       
    183             zty2 = (  bfrva(ji,jj)  * vb(ji,jj,mbkv(ji,jj)) + bfrva(ji,jj-1) * vb(ji,jj-1,mbkv(ji,jj-1))  )   &          
    184                & * ( 1._wp - 0.5_wp * vmask(ji,jj,1) * vmask(ji,jj-1,1)  )       
    185             ustarb2(ji,jj) = SQRT( ztx2 * ztx2 + zty2 * zty2 ) * tmask(ji,jj,1)          
    186          END DO          
    187       END DO     
     179            ! 
     180            ! bottom friction (explicit before friction) 
     181            ! Note that we chose here not to bound the friction as in dynbfr) 
     182            ztx2 = (  bfrua(ji,jj)  * ub(ji,jj,mbku(ji,jj)) + bfrua(ji-1,jj) * ub(ji-1,jj,mbku(ji-1,jj))  )   & 
     183               & * ( 1._wp - 0.5_wp * umask(ji,jj,1) * umask(ji-1,jj,1)  ) 
     184            zty2 = (  bfrva(ji,jj)  * vb(ji,jj,mbkv(ji,jj)) + bfrva(ji,jj-1) * vb(ji,jj-1,mbkv(ji,jj-1))  )   & 
     185               & * ( 1._wp - 0.5_wp * vmask(ji,jj,1) * vmask(ji,jj-1,1)  ) 
     186            ustarb2(ji,jj) = SQRT( ztx2 * ztx2 + zty2 * zty2 ) * tmask(ji,jj,1) 
     187         END DO 
     188      END DO 
    188189 
    189190      ! Set surface roughness length 
    190191      SELECT CASE ( nn_z0_met ) 
    191192      ! 
    192       CASE ( 0 )             ! Constant roughness           
     193      CASE ( 0 )             ! Constant roughness 
    193194         zhsro(:,:) = rn_hsro 
    194195      CASE ( 1 )             ! Standard Charnock formula 
     
    226227      IF( nn_clos == 0 ) THEN    ! Mellor-Yamada 
    227228         DO jk = 2, jpkm1 
    228             DO jj = 2, jpjm1  
     229            DO jj = 2, jpjm1 
    229230               DO ji = fs_2, fs_jpim1   ! vector opt. 
    230231                  zup   = mxln(ji,jj,jk) * fsdepw(ji,jj,mbkt(ji,jj)+1) 
     
    275276               IF( ln_sigpsi ) THEN 
    276277                  zsigpsi = MIN( 1._wp, zesh2 / eps(ji,jj,jk) )     ! 0. <= zsigpsi <= 1. 
    277                   zwall_psi(ji,jj,jk) = rsc_psi /   &  
     278                  zwall_psi(ji,jj,jk) = rsc_psi /   & 
    278279                     &     (  zsigpsi * rsc_psi + (1._wp-zsigpsi) * rsc_psi0 / MAX( zwall(ji,jj,jk), 1._wp )  ) 
    279280               ELSE 
     
    294295               ! diagonal 
    295296               z_elem_b(ji,jj,jk) = 1._wp - z_elem_a(ji,jj,jk) - z_elem_c(ji,jj,jk)  & 
    296                   &                       + rdt * zdiss * tmask(ji,jj,jk)  
     297                  &                       + rdt * zdiss * tmask(ji,jj,jk) 
    297298               ! 
    298299               ! right hand side in en 
     
    316317      ! First level 
    317318      en(:,:,1) = rc02r * ustars2(:,:) * (1._wp + rsbc_tke1)**(2._wp/3._wp) 
    318       en(:,:,1) = MAX(en(:,:,1), rn_emin)  
     319      en(:,:,1) = MAX(en(:,:,1), rn_emin) 
    319320      z_elem_a(:,:,1) = en(:,:,1) 
    320321      z_elem_c(:,:,1) = 0._wp 
    321322      z_elem_b(:,:,1) = 1._wp 
    322       !  
     323      ! 
    323324      ! One level below 
    324325      en(:,:,2) = rc02r * ustars2(:,:) * (1._wp + rsbc_tke1 * ((zhsro(:,:)+fsdepw(:,:,2)) & 
    325326          &            / zhsro(:,:) )**(1.5_wp*ra_sf))**(2._wp/3._wp) 
    326327      en(:,:,2) = MAX(en(:,:,2), rn_emin ) 
    327       z_elem_a(:,:,2) = 0._wp  
     328      z_elem_a(:,:,2) = 0._wp 
    328329      z_elem_c(:,:,2) = 0._wp 
    329330      z_elem_b(:,:,2) = 1._wp 
     
    334335      ! Dirichlet conditions at k=1 
    335336      en(:,:,1)       = rc02r * ustars2(:,:) * (1._wp + rsbc_tke1)**(2._wp/3._wp) 
    336       en(:,:,1)       = MAX(en(:,:,1), rn_emin)       
     337      en(:,:,1)       = MAX(en(:,:,1), rn_emin) 
    337338      z_elem_a(:,:,1) = en(:,:,1) 
    338339      z_elem_c(:,:,1) = 0._wp 
     
    357358      SELECT CASE ( nn_bc_bot ) 
    358359      ! 
    359       CASE ( 0 )             ! Dirichlet  
     360      CASE ( 0 )             ! Dirichlet 
    360361         !                      ! en(ibot) = u*^2 / Co2 and mxln(ibot) = rn_lmin 
    361362         !                      ! Balance between the production and the dissipation terms 
     
    377378               z_elem_c(ji,jj,ibotm1) = 0._wp 
    378379               z_elem_b(ji,jj,ibotm1) = 1._wp 
    379                en(ji,jj,ibotm1) = MAX( rc02r * ustarb2(ji,jj), rn_emin )  
     380               en(ji,jj,ibotm1) = MAX( rc02r * ustarb2(ji,jj), rn_emin ) 
    380381            END DO 
    381382         END DO 
    382383         ! 
    383384      CASE ( 1 )             ! Neumman boundary condition 
    384          !                       
     385         ! 
    385386!CDIR NOVERRCHK 
    386387         DO jj = 2, jpjm1 
     
    428429         END DO 
    429430      END DO 
    430       !                                            ! set the minimum value of tke  
     431      !                                            ! set the minimum value of tke 
    431432      en(:,:,:) = MAX( en(:,:,:), rn_emin ) 
    432433 
     
    470471            DO jj = 2, jpjm1 
    471472               DO ji = fs_2, fs_jpim1   ! vector opt. 
    472                   psi(ji,jj,jk)  = rc02 * eb(ji,jj,jk) * mxlb(ji,jj,jk)**rnn  
     473                  psi(ji,jj,jk)  = rc02 * eb(ji,jj,jk) * mxlb(ji,jj,jk)**rnn 
    473474               END DO 
    474475            END DO 
     
    489490               ! 
    490491               ! psi / k 
    491                zratio = psi(ji,jj,jk) / eb(ji,jj,jk)  
     492               zratio = psi(ji,jj,jk) / eb(ji,jj,jk) 
    492493               ! 
    493494               ! psi3+ : stable : B=-KhN²<0 => N²>0 if rn2>0 dir = 1 (stable) otherwise dir = 0 (unstable) 
     
    509510               zesh2 = dir * ( prod + buoy )          + (1._wp - dir ) * prod                        ! production term 
    510511               zdiss = dir * ( diss / psi(ji,jj,jk) ) + (1._wp - dir ) * (diss-buoy) / psi(ji,jj,jk) ! dissipation term 
    511                !                                                         
     512               ! 
    512513               ! building the matrix 
    513514               zcof = rfact_psi * zwall_psi(ji,jj,jk) * tmask(ji,jj,jk) 
     
    551552      z_elem_c(:,:,2) = 0._wp 
    552553      z_elem_b(:,:,2) = 1._wp 
    553       !  
     554      ! 
    554555      ! 
    555556      CASE ( 1 )             ! Neumann boundary condition on d(psi)/dz 
     
    575576      psi(:,:,2) = psi(:,:,2) + zflxs(:,:) / fse3w(:,:,2) 
    576577 
    577       !    
     578      ! 
    578579      ! 
    579580      END SELECT 
     
    585586      ! 
    586587      ! 
    587       CASE ( 0 )             ! Dirichlet  
     588      CASE ( 0 )             ! Dirichlet 
    588589         !                      ! en(ibot) = u*^2 / Co2 and mxln(ibot) = vkarmn * rn_bfrz0 
    589590         !                      ! Balance between the production and the dissipation terms 
     
    610611         ! 
    611612      CASE ( 1 )             ! Neumman boundary condition 
    612          !                       
     613         ! 
    613614!CDIR NOVERRCHK 
    614615         DO jj = 2, jpjm1 
     
    692693            DO jj = 2, jpjm1 
    693694               DO ji = fs_2, fs_jpim1   ! vector opt. 
    694                   eps(ji,jj,jk) = rc04 * en(ji,jj,jk) * psi(ji,jj,jk)  
     695                  eps(ji,jj,jk) = rc04 * en(ji,jj,jk) * psi(ji,jj,jk) 
    695696               END DO 
    696697            END DO 
     
    719720               eps(ji,jj,jk)  = MAX( eps(ji,jj,jk), rn_epsmin ) 
    720721               mxln(ji,jj,jk)  = rc03 * en(ji,jj,jk) * SQRT( en(ji,jj,jk) ) / eps(ji,jj,jk) 
    721                ! Galperin criterium (NOTE : Not required if the proper value of C3 in stable cases is calculated)  
     722               ! Galperin criterium (NOTE : Not required if the proper value of C3 in stable cases is calculated) 
    722723               zrn2 = MAX( rn2(ji,jj,jk), rsmall ) 
    723724               IF (ln_length_lim) mxln(ji,jj,jk) = MIN(  rn_clim_galp * SQRT( 2._wp * en(ji,jj,jk) / zrn2 ), mxln(ji,jj,jk) ) 
    724725            END DO 
    725726         END DO 
    726       END DO  
     727      END DO 
    727728 
    728729      ! 
     
    806807            END DO 
    807808         END DO 
     809#if defined key_traldf_c2d || key_traldf_c3d 
     810         IF( ln_stopack) THEN 
     811            IF( nn_spp_avt > 0 ) CALL spp_gen(kt, avt(:,:,jk), nn_spp_avt, rn_avt_sd,jk) 
     812            IF( nn_spp_avm > 0 ) CALL spp_gen(kt, avm(:,:,jk), nn_spp_avm, rn_avm_sd,jk) 
     813         ENDIF 
     814#else 
     815         IF ( ln_stopack ) & 
     816            & CALL ctl_stop( 'zdf_gls: parameter perturbation will only work with '// & 
     817                             'key_traldf_c2d or key_traldf_c3d') 
     818#endif 
    808819      END DO 
    809820      ! 
     
    846857      !!---------------------------------------------------------------------- 
    847858      !!                  ***  ROUTINE zdf_gls_init  *** 
    848       !!                      
    849       !! ** Purpose :   Initialization of the vertical eddy diffivity and  
     859      !! 
     860      !! ** Purpose :   Initialization of the vertical eddy diffivity and 
    850861      !!      viscosity when using a gls turbulent closure scheme 
    851862      !! 
     
    881892      READ  ( numnam_cfg, namzdf_gls, IOSTAT = ios, ERR = 902 ) 
    882893902   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namzdf_gls in configuration namelist', lwp ) 
    883       IF(lwm .AND. nprint > 2) WRITE ( numond, namzdf_gls ) 
     894      IF(lwm) WRITE ( numond, namzdf_gls ) 
    884895 
    885896      IF(lwp) THEN                     !* Control print 
     
    10691080      END SELECT 
    10701081      ! 
    1071       IF(lwp .AND. lflush) CALL flush(numout)  
     1082      IF(lwp .AND. lflush) CALL flush(numout) 
    10721083      !                                !* Set Schmidt number for psi diffusion in the wave breaking case 
    10731084      !                                     ! See Eq. (13) of Carniel et al, OM, 30, 225-239, 2009 
    10741085      !                                     !  or Eq. (17) of Burchard, JPO, 31, 3133-3145, 2001 
    10751086      IF( ln_sigpsi ) THEN 
    1076          ra_sf = -1.5 ! Set kinetic energy slope, then deduce rsc_psi and rl_sf  
     1087         ra_sf = -1.5 ! Set kinetic energy slope, then deduce rsc_psi and rl_sf 
    10771088         ! Verification: retrieve Burchard (2001) results by uncomenting the line below: 
    10781089         ! Note that the results depend on the value of rn_cm_sf which is constant (=rc0) in his work 
     
    10821093         rsc_psi0 = rsc_psi 
    10831094      ENDIF 
    1084   
     1095 
    10851096      !                                !* Shear free turbulence parameters 
    10861097      ! 
     
    11291140      rc04  = rc03 * rc0 
    11301141      rsbc_tke1 = -3._wp/2._wp*rn_crban*ra_sf*rl_sf                      ! Dirichlet + Wave breaking 
    1131       rsbc_tke2 = rdt * rn_crban / rl_sf                                 ! Neumann + Wave breaking  
     1142      rsbc_tke2 = rdt * rn_crban / rl_sf                                 ! Neumann + Wave breaking 
    11321143      zcr = MAX(rsmall, rsbc_tke1**(1./(-ra_sf*3._wp/2._wp))-1._wp ) 
    1133       rtrans = 0.2_wp / zcr                                              ! Ad. inverse transition length between log and wave layer  
     1144      rtrans = 0.2_wp / zcr                                              ! Ad. inverse transition length between log and wave layer 
    11341145      rsbc_zs1  = rn_charn/grav                                          ! Charnock formula for surface roughness 
    1135       rsbc_zs2  = rn_frac_hs / 0.85_wp / grav * 665._wp                  ! Rascle formula for surface roughness  
     1146      rsbc_zs2  = rn_frac_hs / 0.85_wp / grav * 665._wp                  ! Rascle formula for surface roughness 
    11361147      rsbc_psi1 = -0.5_wp * rdt * rc0**(rpp-2._wp*rmm) / rsc_psi 
    1137       rsbc_psi2 = -0.5_wp * rdt * rc0**rpp * rnn * vkarmn**rnn / rsc_psi ! Neumann + NO Wave breaking  
     1148      rsbc_psi2 = -0.5_wp * rdt * rc0**rpp * rnn * vkarmn**rnn / rsc_psi ! Neumann + NO Wave breaking 
    11381149 
    11391150      rfact_tke = -0.5_wp / rsc_tke * rdt                                ! Cst used for the Diffusion term of tke 
     
    11501161         avmv(:,:,jk) = avmb(jk) * vmask(:,:,jk) 
    11511162      END DO 
    1152       !                               
     1163      ! 
    11531164      CALL gls_rst( nit000, 'READ' )   !* read or initialize all required files 
    11541165      ! 
     
    11611172      !!--------------------------------------------------------------------- 
    11621173      !!                   ***  ROUTINE ts_rst  *** 
    1163       !!                      
     1174      !! 
    11641175      !! ** Purpose :   Read or write TKE file (en) in restart file 
    11651176      !! 
    11661177      !! ** Method  :   use of IOM library 
    1167       !!                if the restart does not contain TKE, en is either  
     1178      !!                if the restart does not contain TKE, en is either 
    11681179      !!                set to rn_emin or recomputed (nn_igls/=0) 
    11691180      !!---------------------------------------------------------------------- 
     
    11771188      !!---------------------------------------------------------------------- 
    11781189      ! 
    1179       IF( TRIM(cdrw) == 'READ' ) THEN        ! Read/initialise  
     1190      IF( TRIM(cdrw) == 'READ' ) THEN        ! Read/initialise 
    11801191         !                                   ! --------------- 
    11811192         IF( ln_rstart ) THEN                   !* Read the restart file 
     
    11961207               CALL iom_get( numror, jpdom_autoglo, 'mxln'  , mxln   ) 
    11971208               IF(nn_timing == 2)  CALL timing_stop('iom_rstget') 
    1198             ELSE                         
     1209            ELSE 
    11991210               IF(lwp) WRITE(numout,*) ' ===>>>> : previous run without gls scheme, en and mxln computed by iterative loop' 
    12001211               IF(lwp .AND. lflush) CALL flush(numout) 
    12011212               en  (:,:,:) = rn_emin 
    1202                mxln(:,:,:) = 0.05         
     1213               mxln(:,:,:) = 0.05 
    12031214               avt_k (:,:,:) = avt (:,:,:) 
    12041215               avm_k (:,:,:) = avm (:,:,:) 
     
    12111222            IF(lwp .AND. lflush) CALL flush(numout) 
    12121223            en  (:,:,:) = rn_emin 
    1213             mxln(:,:,:) = 0.05        
     1224            mxln(:,:,:) = 0.05 
    12141225         ENDIF 
    12151226         ! 
     
    12191230         IF(lwp .AND. lflush) CALL flush(numout) 
    12201231         IF(nn_timing == 2)  CALL timing_start('iom_rstput') 
    1221          CALL iom_rstput( kt, nitrst, numrow, 'en'   , en     )  
     1232         CALL iom_rstput( kt, nitrst, numrow, 'en'   , en     ) 
    12221233         CALL iom_rstput( kt, nitrst, numrow, 'avt'  , avt_k  ) 
    12231234         CALL iom_rstput( kt, nitrst, numrow, 'avm'  , avm_k  ) 
    1224          CALL iom_rstput( kt, nitrst, numrow, 'avmu' , avmu_k )  
     1235         CALL iom_rstput( kt, nitrst, numrow, 'avmu' , avmu_k ) 
    12251236         CALL iom_rstput( kt, nitrst, numrow, 'avmv' , avmv_k ) 
    12261237         CALL iom_rstput( kt, nitrst, numrow, 'mxln' , mxln   ) 
     
    12411252      WRITE(*,*) 'zdf_gls_init: You should not have seen this print! error?' 
    12421253   END SUBROUTINE zdf_gls_init 
    1243     
     1254 
    12441255   SUBROUTINE zdf_gls( kt )          ! Empty routine 
    12451256   IMPLICIT NONE 
    1246       INTEGER, INTENT(in) ::   kt ! ocean time step    
     1257      INTEGER, INTENT(in) ::   kt ! ocean time step 
    12471258      WRITE(*,*) 'zdf_gls: You should not have seen this print! error?', kt 
    12481259   END SUBROUTINE zdf_gls 
    1249     
     1260 
    12501261   SUBROUTINE gls_rst( kt, cdrw )          ! Empty routine 
    12511262   IMPLICIT NONE 
     
    12581269   !!====================================================================== 
    12591270END MODULE zdfgls 
    1260  
  • branches/UKMO/dev_r5518_GO6_starthour_obsoper/NEMOGCM/NEMO/OPA_SRC/ZDF/zdftke.F90

    r12555 r15603  
    22   !!====================================================================== 
    33   !!                       ***  MODULE  zdftke  *** 
    4    !! Ocean physics:  vertical mixing coefficient computed from the tke  
     4   !! Ocean physics:  vertical mixing coefficient computed from the tke 
    55   !!                 turbulent closure parameterization 
    66   !!===================================================================== 
     
    2222   !!             -   !  2008-05  (J.-M. Molines, G. Madec)  2D form of avtb 
    2323   !!             -   !  2008-06  (G. Madec)  style + DOCTOR name for namelist parameters 
    24    !!             -   !  2008-12  (G. Reffray) stable discretization of the production term  
    25    !!            3.2  !  2009-06  (G. Madec, S. Masson) TKE restart compatible with key_cpl  
     24   !!             -   !  2008-12  (G. Reffray) stable discretization of the production term 
     25   !!            3.2  !  2009-06  (G. Madec, S. Masson) TKE restart compatible with key_cpl 
    2626   !!                 !                                + cleaning of the parameters + bugs correction 
    2727   !!            3.3  !  2010-10  (C. Ethe, G. Madec) reorganisation of initialisation phase 
     
    5252   USE wrk_nemo       ! work arrays 
    5353   USE timing         ! Timing 
    54    USE lib_fortran    ! Fortran utilities (allows no signed zero when 'key_nosignedzero' defined)   
     54   USE lib_fortran    ! Fortran utilities (allows no signed zero when 'key_nosignedzero' defined) 
    5555#if defined key_agrif 
    5656   USE agrif_opa_interp 
    5757   USE agrif_opa_update 
    5858#endif 
    59  
    60  
     59   USE stopack 
    6160 
    6261   IMPLICIT NONE 
     
    7574   INTEGER  ::   nn_pdl    ! Prandtl number or not (ratio avt/avm) (=0/1) 
    7675   REAL(wp) ::   rn_ediff  ! coefficient for avt: avt=rn_ediff*mxl*sqrt(e) 
    77    REAL(wp) ::   rn_ediss  ! coefficient of the Kolmogoroff dissipation  
     76   REAL(wp) ::   rn_ediss  ! coefficient of the Kolmogoroff dissipation 
    7877   REAL(wp) ::   rn_ebb    ! coefficient of the surface input of tke 
    7978   REAL(wp) ::   rn_emin   ! minimum value of tke           [m2/s2] 
     
    9493 
    9594   REAL(wp)        , ALLOCATABLE, SAVE, DIMENSION(:,:)   ::   htau           ! depth of tke penetration (nn_htau) 
    96    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   e_niw          !: TKE budget- near-inertial waves term 
    97    REAL(wp)        , ALLOCATABLE, SAVE, DIMENSION(:,:)   ::   efr            ! surface boundary condition for nn_etau = 4 
    9895   REAL(wp)        , ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   dissl          ! now mixing lenght of dissipation 
    9996#if defined key_c1d 
     
    10299   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   e_pdl, e_ric   !: prandl and local Richardson numbers 
    103100#endif 
     101   REAL(wp)        , ALLOCATABLE, SAVE, DIMENSION(:,:)   ::   rn_lc0, rn_ediff0, rn_ediss0, rn_ebb0, rn_efr0 
     102   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   e_niw          !: TKE budget- near-inertial waves term 
     103   REAL(wp)        , ALLOCATABLE, SAVE, DIMENSION(:,:)   ::   efr            ! surface boundary condition for nn_etau = 4 
    104104 
    105105   !! * Substitutions 
     
    118118      !!---------------------------------------------------------------------- 
    119119      ALLOCATE(                                                                    & 
    120          &      efr  (jpi,jpj)     , e_niw(jpi,jpj,jpk) ,                         &       
     120         &      efr  (jpi,jpj)     , e_niw(jpi,jpj,jpk) ,                         & 
    121121#if defined key_c1d 
    122122         &      e_dis(jpi,jpj,jpk) , e_mix(jpi,jpj,jpk) ,                          & 
     
    147147      !!         surface: en = max( rn_emin0, rn_ebb * taum ) 
    148148      !!         bottom : en = rn_emin 
    149       !!      The associated critical Richardson number is: ri_cri = 2/(2+rn_ediss/rn_ediff)  
    150       !! 
    151       !!        The now Turbulent kinetic energy is computed using the following  
     149      !!      The associated critical Richardson number is: ri_cri = 2/(2+rn_ediss/rn_ediff) 
     150      !! 
     151      !!        The now Turbulent kinetic energy is computed using the following 
    152152      !!      time stepping: implicit for vertical diffusion term, linearized semi 
    153       !!      implicit for kolmogoroff dissipation term, and explicit forward for  
    154       !!      both buoyancy and shear production terms. Therefore a tridiagonal  
     153      !!      implicit for kolmogoroff dissipation term, and explicit forward for 
     154      !!      both buoyancy and shear production terms. Therefore a tridiagonal 
    155155      !!      linear system is solved. Note that buoyancy and shear terms are 
    156156      !!      discretized in a energy conserving form (Bruchard 2002). 
     
    160160      !! 
    161161      !!        The now vertical eddy vicosity and diffusivity coefficients are 
    162       !!      given by:  
     162      !!      given by: 
    163163      !!              avm = max( avtb, rn_ediff * zmxlm * en^1/2 ) 
    164       !!              avt = max( avmb, pdl * avm                 )   
     164      !!              avt = max( avmb, pdl * avm                 ) 
    165165      !!              eav = max( avmb, avm ) 
    166166      !!      where pdl, the inverse of the Prandtl number is 1 if nn_pdl=0 and 
    167       !!      given by an empirical funtion of the localRichardson number if nn_pdl=1  
     167      !!      given by an empirical funtion of the localRichardson number if nn_pdl=1 
    168168      !! 
    169169      !! ** Action  :   compute en (now turbulent kinetic energy) 
     
    180180      ! 
    181181      IF( kt /= nit000 ) THEN   ! restore before value to compute tke 
    182          avt (:,:,:) = avt_k (:,:,:)  
    183          avm (:,:,:) = avm_k (:,:,:)  
    184          avmu(:,:,:) = avmu_k(:,:,:)  
    185          avmv(:,:,:) = avmv_k(:,:,:)  
    186       ENDIF  
     182         avt (:,:,:) = avt_k (:,:,:) 
     183         avm (:,:,:) = avm_k (:,:,:) 
     184         avmu(:,:,:) = avmu_k(:,:,:) 
     185         avmv(:,:,:) = avmv_k(:,:,:) 
     186      ENDIF 
     187      ! 
     188#if defined key_traldf_c2d || key_traldf_c3d 
     189      IF( ln_stopack) THEN 
     190         IF( nn_spp_tkelc > 0 ) THEN 
     191             rn_lc0 = rn_lc 
     192             CALL spp_gen( kt, rn_lc0, nn_spp_tkelc, rn_tkelc_sd, jk_spp_tkelc ) 
     193         ENDIF 
     194         IF( nn_spp_tkedf > 0 ) THEN 
     195             rn_ediff0 = rn_ediff 
     196             CALL spp_gen( kt, rn_ediff0, nn_spp_tkedf, rn_tkedf_sd, jk_spp_tkedf ) 
     197         ENDIF 
     198         IF( nn_spp_tkeds > 0 ) THEN 
     199             rn_ediss0 = rn_ediss 
     200             CALL spp_gen( kt, rn_ediss0, nn_spp_tkeds, rn_tkeds_sd, jk_spp_tkeds ) 
     201         ENDIF 
     202         IF( nn_spp_tkebb > 0 ) THEN 
     203             rn_ebb0 = rn_ebb 
     204             CALL spp_gen( kt, rn_ebb0, nn_spp_tkebb, rn_tkebb_sd, jk_spp_tkebb ) 
     205        ENDIF 
     206         IF( nn_spp_tkefr > 0 ) THEN 
     207             rn_efr0 = rn_efr 
     208             CALL spp_gen( kt, rn_efr0, nn_spp_tkefr, rn_tkefr_sd, jk_spp_tkefr ) 
     209         ENDIF 
     210      ENDIF 
     211#else 
     212      IF ( ln_stopack ) & 
     213         & CALL ctl_stop( 'zdf_tke: parameter perturbation will only work with '// & 
     214                          'key_traldf_c2d or key_traldf_c3d') 
     215#endif 
    187216      ! 
    188217      CALL tke_tke      ! now tke (en) 
     
    190219      CALL tke_avn      ! now avt, avm, avmu, avmv 
    191220      ! 
    192       avt_k (:,:,:) = avt (:,:,:)  
    193       avm_k (:,:,:) = avm (:,:,:)  
    194       avmu_k(:,:,:) = avmu(:,:,:)  
    195       avmv_k(:,:,:) = avmv(:,:,:)  
     221      avt_k (:,:,:) = avt (:,:,:) 
     222      avm_k (:,:,:) = avm (:,:,:) 
     223      avmu_k(:,:,:) = avmu(:,:,:) 
     224      avmv_k(:,:,:) = avmv(:,:,:) 
    196225      ! 
    197226#if defined key_agrif 
    198       ! Update child grid f => parent grid  
     227      ! Update child grid f => parent grid 
    199228      IF( .NOT.Agrif_Root() )   CALL Agrif_Update_Tke( kt )      ! children only 
    200 #endif       
    201      !  
     229#endif 
     230      IF (  kt == nitend ) THEN 
     231        DEALLOCATE ( rn_lc0, rn_ediff0, rn_ediss0, rn_ebb0, rn_efr0 ) 
     232      ENDIF 
     233      ! 
     234 
    202235   END SUBROUTINE zdf_tke 
    203236 
     
    225258      REAL(wp) ::   zrhoa  = 1.22                   ! Air density kg/m3 
    226259      REAL(wp) ::   zcdrag = 1.5e-3                 ! drag coefficient 
    227       REAL(wp) ::   zbbrau, zesh2                   ! temporary scalars 
    228       REAL(wp) ::   zfact1, zfact2, zfact3          !    -         - 
     260      REAL(wp) ::   zesh2                           ! temporary scalars 
     261      REAL(wp) ::   zfact1                          !    -         - 
    229262      REAL(wp) ::   ztx2  , zty2  , zcof            !    -         - 
    230263      REAL(wp) ::   ztau  , zdif                    !    -         - 
     
    233266!!bfr      REAL(wp) ::   zebot                           !    -         - 
    234267      INTEGER , POINTER, DIMENSION(:,:  ) :: imlc 
    235       REAL(wp), POINTER, DIMENSION(:,:  ) :: zhlc 
     268      REAL(wp), POINTER, DIMENSION(:,:  ) :: zhlc, zbbrau,zfact2,zfact3 
    236269      REAL(wp), POINTER, DIMENSION(:,:,:) :: zpelc, zdiag, zd_up, zd_lw 
    237270      !!-------------------------------------------------------------------- 
     
    240273      ! 
    241274      CALL wrk_alloc( jpi,jpj, imlc )    ! integer 
    242       CALL wrk_alloc( jpi,jpj, zhlc )  
    243       CALL wrk_alloc( jpi,jpj,jpk, zpelc, zdiag, zd_up, zd_lw )  
    244       ! 
    245       zbbrau = rn_ebb / rau0       ! Local constant initialisation 
    246       zfact1 = -.5_wp * rdt  
    247       zfact2 = 1.5_wp * rdt * rn_ediss 
    248       zfact3 = 0.5_wp       * rn_ediss 
     275      CALL wrk_alloc( jpi,jpj, zhlc ) 
     276      CALL wrk_alloc( jpi,jpj, zbbrau ) 
     277      CALL wrk_alloc( jpi,jpj, zfact2 ) 
     278      CALL wrk_alloc( jpi,jpj, zfact3 ) 
     279      CALL wrk_alloc( jpi,jpj,jpk, zpelc, zdiag, zd_up, zd_lw ) 
     280      ! 
     281      zbbrau = rn_ebb0 / rau0       ! Local constant initialisation 
     282      zfact1 = -.5_wp * rdt 
     283      zfact2 = 1.5_wp * rdt * rn_ediss0 
     284      zfact3 = 0.5_wp       * rn_ediss0 
    249285      ! 
    250286      ! 
     
    261297      DO jj = 2, jpjm1            ! en(1)   = rn_ebb taum / rau0  (min value rn_emin0) 
    262298         DO ji = fs_2, fs_jpim1   ! vector opt. 
    263             en(ji,jj,1) = MAX( rn_emin0, zbbrau * taum(ji,jj) ) * tmask(ji,jj,1) 
    264          END DO 
    265       END DO 
    266        
     299            en(ji,jj,1) = MAX( rn_emin0, zbbrau(ji,jj) * taum(ji,jj) ) * tmask(ji,jj,1) 
     300         END DO 
     301      END DO 
     302 
    267303!!bfr   - start commented area 
    268304      !                     !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 
     
    303339         imlc(:,:) = mbkt(:,:) + 1       ! Initialization to the number of w ocean point (=2 over land) 
    304340         DO jk = jpkm1, 2, -1 
    305             DO jj = 1, jpj               ! Last w-level at which zpelc>=0.5*us*us  
     341            DO jj = 1, jpj               ! Last w-level at which zpelc>=0.5*us*us 
    306342               DO ji = 1, jpi            !      with us=0.016*wind(starting from jpk-1) 
    307343                  zus  = zcof * taum(ji,jj) 
     
    311347         END DO 
    312348         !                               ! finite LC depth 
    313          DO jj = 1, jpj  
     349         DO jj = 1, jpj 
    314350            DO ji = 1, jpi 
    315351               zhlc(ji,jj) = fsdepw(ji,jj,imlc(ji,jj)) 
     
    326362                  !                                           ! vertical velocity due to LC 
    327363                  zind = 0.5 - SIGN( 0.5, fsdepw(ji,jj,jk) - zhlc(ji,jj) ) 
    328                   zwlc = zind * rn_lc * zus * SIN( rpi * fsdepw(ji,jj,jk) / zhlc(ji,jj) ) 
     364                  zwlc = zind * rn_lc0(ji,jj) * zus * SIN( rpi * fsdepw(ji,jj,jk) / zhlc(ji,jj) ) 
    329365                  !                                           ! TKE Langmuir circulation source term 
    330                   en(ji,jj,jk) = en(ji,jj,jk) + rdt * ( 1._wp - fr_i(ji,jj) ) * ( zwlc * zwlc * zwlc ) /   & 
     366                  en(ji,jj,jk) = en(ji,jj,jk) + rdt * ( 1._wp - fr_i(ji,jj) )* ( zwlc * zwlc * zwlc ) /   & 
    331367                     &   zhlc(ji,jj) * wmask(ji,jj,jk) * tmask(ji,jj,1) 
     368 
    332369               END DO 
    333370            END DO 
     
    347384            DO ji = 1, jpi 
    348385               avmu(ji,jj,jk) = avmu(ji,jj,jk) * ( un(ji,jj,jk-1) - un(ji,jj,jk) )   & 
    349                   &                            * ( ub(ji,jj,jk-1) - ub(ji,jj,jk) )   &  
     386                  &                            * ( ub(ji,jj,jk-1) - ub(ji,jj,jk) )   & 
    350387                  &                            / (  fse3uw_n(ji,jj,jk)               & 
    351388                  &                              *  fse3uw_b(ji,jj,jk)  ) 
     
    376413                  !                                                           ! shear prod. at w-point weightened by mask 
    377414               zesh2  =  ( avmu(ji-1,jj,jk) + avmu(ji,jj,jk) ) / MAX( 1._wp , umask(ji-1,jj,jk) + umask(ji,jj,jk) )   & 
    378                   &    + ( avmv(ji,jj-1,jk) + avmv(ji,jj,jk) ) / MAX( 1._wp , vmask(ji,jj-1,jk) + vmask(ji,jj,jk) )     
     415                  &    + ( avmv(ji,jj-1,jk) + avmv(ji,jj,jk) ) / MAX( 1._wp , vmask(ji,jj-1,jk) + vmask(ji,jj,jk) ) 
    379416                  ! 
    380417               zd_up(ji,jj,jk) = zzd_up            ! Matrix (zdiag, zd_up, zd_lw) 
    381418               zd_lw(ji,jj,jk) = zzd_lw 
    382                zdiag(ji,jj,jk) = 1._wp - zzd_lw - zzd_up + zfact2 * dissl(ji,jj,jk) * tmask(ji,jj,jk) 
     419               zdiag(ji,jj,jk) = 1._wp - zzd_lw - zzd_up + zfact2(ji,jj) * dissl(ji,jj,jk) * tmask(ji,jj,jk) 
    383420               ! 
    384421               !                                   ! right hand side in en 
    385422               en(ji,jj,jk) = en(ji,jj,jk) + rdt * (  zesh2  -   avt(ji,jj,jk) * rn2(ji,jj,jk)    & 
    386                   &                                 + zfact3 * dissl(ji,jj,jk) * en (ji,jj,jk)  ) & 
     423                  &                                 + zfact3(ji,jj) * dissl(ji,jj,jk) * en (ji,jj,jk)  ) & 
    387424                  &                                 * wmask(ji,jj,jk) 
    388425            END DO 
     
    433470      END DO 
    434471 
    435       !                                 ! Save TKE prior to nn_etau addition   
    436       e_niw(:,:,:) = en(:,:,:)   
    437       !   
     472      !                                 ! Save TKE prior to nn_etau addition 
     473      e_niw(:,:,:) = en(:,:,:) 
     474      ! 
    438475      !                            !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 
    439476      !                            !  TKE due to surface and internal wave breaking 
     
    455492            DO jj = 2, jpjm1 
    456493               DO ji = fs_2, fs_jpim1   ! vector opt. 
    457                   en(ji,jj,jk) = en(ji,jj,jk) + rn_efr * en(ji,jj,1) * EXP( -fsdepw(ji,jj,jk) / htau(ji,jj) )   & 
     494                  en(ji,jj,jk) = en(ji,jj,jk) + rn_efr0(ji,jj) * en(ji,jj,1) * EXP( -fsdepw(ji,jj,jk) / htau(ji,jj) )   & 
    458495                     &                                 * ( 1._wp - fr_i(ji,jj) )  * wmask(ji,jj,jk) * tmask(ji,jj,1) 
    459496               END DO 
     
    464501            DO ji = fs_2, fs_jpim1   ! vector opt. 
    465502               jk = nmln(ji,jj) 
    466                en(ji,jj,jk) = en(ji,jj,jk) + rn_efr * en(ji,jj,1) * EXP( -fsdepw(ji,jj,jk) / htau(ji,jj) )   & 
     503               en(ji,jj,jk) = en(ji,jj,jk) + rn_efr0(ji,jj) * en(ji,jj,1) * EXP( -fsdepw(ji,jj,jk) / htau(ji,jj) )   & 
    467504                  &                                 * ( 1._wp - fr_i(ji,jj) )  * wmask(ji,jj,jk) * tmask(ji,jj,1) 
    468505            END DO 
     
    477514                  ztx2 = utau(ji-1,jj  ) + utau(ji,jj) 
    478515                  zty2 = vtau(ji  ,jj-1) + vtau(ji,jj) 
    479                   ztau = 0.5_wp * SQRT( ztx2 * ztx2 + zty2 * zty2 ) * tmask(ji,jj,1)    ! module of the mean stress  
    480                   zdif = taum(ji,jj) - ztau                            ! mean of modulus - modulus of the mean  
     516                  ztau = 0.5_wp * SQRT( ztx2 * ztx2 + zty2 * zty2 ) * tmask(ji,jj,1)    ! module of the mean stress 
     517                  zdif = taum(ji,jj) - ztau                            ! mean of modulus - modulus of the mean 
    481518                  zdif = rhftau_scl * MAX( 0._wp, zdif + rhftau_add )  ! apply some modifications... 
    482                   en(ji,jj,jk) = en(ji,jj,jk) + zbbrau * zdif * EXP( -fsdepw(ji,jj,jk) / htau(ji,jj) )   & 
     519                  en(ji,jj,jk) = en(ji,jj,jk) + zbbrau(ji,jj) * zdif * EXP( -fsdepw(ji,jj,jk) / htau(ji,jj) )   & 
    483520                     &                        * ( 1._wp - fr_i(ji,jj) ) * wmask(ji,jj,jk) * tmask(ji,jj,1) 
    484521               END DO 
     
    486523         END DO 
    487524      ELSEIF( nn_etau == 4 ) THEN       !* column integral independant of htau (rn_efr must be scaled up) 
    488          IF( nn_htau == 2 ) THEN        ! efr dependant on time-varying htau  
     525         IF( nn_htau == 2 ) THEN        ! efr dependant on time-varying htau 
    489526            DO jj = 2, jpjm1 
    490527               DO ji = fs_2, fs_jpim1   ! vector opt. 
     
    504541      CALL lbc_lnk( en, 'W', 1. )      ! Lateral boundary conditions (sign unchanged) 
    505542      ! 
    506       DO jk = 2, jpkm1                             ! TKE budget: near-inertial waves term   
    507          DO jj = 2, jpjm1   
    508             DO ji = fs_2, fs_jpim1   ! vector opt.   
    509                e_niw(ji,jj,jk) = en(ji,jj,jk) - e_niw(ji,jj,jk)   
    510             END DO   
    511          END DO   
    512       END DO   
    513       !   
    514       CALL lbc_lnk( e_niw, 'W', 1. )   
     543      DO jk = 2, jpkm1                             ! TKE budget: near-inertial waves term 
     544         DO jj = 2, jpjm1 
     545            DO ji = fs_2, fs_jpim1   ! vector opt. 
     546               e_niw(ji,jj,jk) = en(ji,jj,jk) - e_niw(ji,jj,jk) 
     547            END DO 
     548         END DO 
     549      END DO 
     550      ! 
     551      CALL lbc_lnk( e_niw, 'W', 1. ) 
    515552      ! 
    516553      CALL wrk_dealloc( jpi,jpj, imlc )    ! integer 
    517       CALL wrk_dealloc( jpi,jpj, zhlc )  
    518       CALL wrk_dealloc( jpi,jpj,jpk, zpelc, zdiag, zd_up, zd_lw )  
     554      CALL wrk_dealloc( jpi,jpj, zhlc ) 
     555      CALL wrk_dealloc( jpi,jpj, zbbrau ) 
     556      CALL wrk_dealloc( jpi,jpj, zfact2 ) 
     557      CALL wrk_dealloc( jpi,jpj, zfact3 ) 
     558      CALL wrk_dealloc( jpi,jpj,jpk, zpelc, zdiag, zd_up, zd_lw ) 
    519559      ! 
    520560      IF( nn_timing == 1 )  CALL timing_stop('tke_tke') 
     
    529569      !! ** Purpose :   Compute the vertical eddy viscosity and diffusivity 
    530570      !! 
    531       !! ** Method  :   At this stage, en, the now TKE, is known (computed in  
    532       !!              the tke_tke routine). First, the now mixing lenth is  
     571      !! ** Method  :   At this stage, en, the now TKE, is known (computed in 
     572      !!              the tke_tke routine). First, the now mixing lenth is 
    533573      !!      computed from en and the strafification (N^2), then the mixings 
    534574      !!      coefficients are computed. 
    535575      !!              - Mixing length : a first evaluation of the mixing lengh 
    536576      !!      scales is: 
    537       !!                      mxl = sqrt(2*en) / N   
     577      !!                      mxl = sqrt(2*en) / N 
    538578      !!      where N is the brunt-vaisala frequency, with a minimum value set 
    539579      !!      to rmxl_min (rn_mxl0) in the interior (surface) ocean. 
    540       !!        The mixing and dissipative length scale are bound as follow :  
     580      !!        The mixing and dissipative length scale are bound as follow : 
    541581      !!         nn_mxl=0 : mxl bounded by the distance to surface and bottom. 
    542582      !!                        zmxld = zmxlm = mxl 
    543583      !!         nn_mxl=1 : mxl bounded by the e3w and zmxld = zmxlm = mxl 
    544       !!         nn_mxl=2 : mxl bounded such that the vertical derivative of mxl is  
     584      !!         nn_mxl=2 : mxl bounded such that the vertical derivative of mxl is 
    545585      !!                    less than 1 (|d/dz(mxl)|<1) and zmxld = zmxlm = mxl 
    546586      !!         nn_mxl=3 : mxl is bounded from the surface to the bottom usings 
    547       !!                    |d/dz(xml)|<1 to obtain lup, and from the bottom to  
    548       !!                    the surface to obtain ldown. the resulting length  
     587      !!                    |d/dz(xml)|<1 to obtain lup, and from the bottom to 
     588      !!                    the surface to obtain ldown. the resulting length 
    549589      !!                    scales are: 
    550       !!                        zmxld = sqrt( lup * ldown )  
     590      !!                        zmxld = sqrt( lup * ldown ) 
    551591      !!                        zmxlm = min ( lup , ldown ) 
    552592      !!              - Vertical eddy viscosity and diffusivity: 
    553593      !!                      avm = max( avtb, rn_ediff * zmxlm * en^1/2 ) 
    554       !!                      avt = max( avmb, pdlr * avm )   
     594      !!                      avt = max( avmb, pdlr * avm ) 
    555595      !!      with pdlr=1 if nn_pdl=0, pdlr=1/pdl=F(Ri) otherwise. 
    556596      !! 
     
    567607      IF( nn_timing == 1 )  CALL timing_start('tke_avn') 
    568608 
    569       CALL wrk_alloc( jpi,jpj,jpk, zmpdl, zmxlm, zmxld )  
     609      CALL wrk_alloc( jpi,jpj,jpk, zmpdl, zmxlm, zmxld ) 
    570610 
    571611      !                     !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 
     
    576616      ! 
    577617      ! initialisation of interior minimum value (avoid a 2d loop with mikt) 
    578       zmxlm(:,:,:)  = rmxl_min     
     618      zmxlm(:,:,:)  = rmxl_min 
    579619      zmxld(:,:,:)  = rmxl_min 
    580620      ! 
     
    586626            END DO 
    587627         END DO 
    588       ELSE  
     628      ELSE 
    589629         zmxlm(:,:,1) = rn_mxl0 
    590630      ENDIF 
     
    604644      !                     !* Physical limits for the mixing length 
    605645      ! 
    606       zmxld(:,:,1  ) = zmxlm(:,:,1)   ! surface set to the minimum value  
     646      zmxld(:,:,1  ) = zmxlm(:,:,1)   ! surface set to the minimum value 
    607647      zmxld(:,:,jpk) = rmxl_min       ! last level  set to the minimum value 
    608648      ! 
     
    698738            DO ji = fs_2, fs_jpim1   ! vector opt. 
    699739               zsqen = SQRT( en(ji,jj,jk) ) 
    700                zav   = rn_ediff * zmxlm(ji,jj,jk) * zsqen 
     740               zav   = rn_ediff0(ji,jj) * zmxlm(ji,jj,jk) * zsqen 
    701741               avm  (ji,jj,jk) = MAX( zav,                  avmb(jk) ) * wmask(ji,jj,jk) 
    702742               avt  (ji,jj,jk) = MAX( zav, avtb_2d(ji,jj) * avtb(jk) ) * wmask(ji,jj,jk) 
     
    704744            END DO 
    705745         END DO 
     746#if defined key_traldf_c2d || key_traldf_c3d 
     747         IF( ln_stopack) THEN 
     748            IF(nn_spp_avt > 0 ) CALL spp_gen( 1, avt(:,:,jk), nn_spp_avt, rn_avt_sd, jk_spp_avt, jk) 
     749            IF(nn_spp_avm > 0 ) CALL spp_gen( 1, avm(:,:,jk), nn_spp_avm, rn_avm_sd, jk_spp_avm, jk) 
     750         ENDIF 
     751#else 
     752         IF ( ln_stopack  ) & 
     753            & CALL ctl_stop( 'tke_avn: parameter perturbation will only work with '// & 
     754                             'key_traldf_c2d or key_traldf_c3d') 
     755#endif 
    706756      END DO 
    707757      CALL lbc_lnk( avm, 'W', 1. )      ! Lateral boundary conditions (sign unchanged) 
     
    749799      ENDIF 
    750800      ! 
    751       CALL wrk_dealloc( jpi,jpj,jpk, zmpdl, zmxlm, zmxld )  
     801      CALL wrk_dealloc( jpi,jpj,jpk, zmpdl, zmxlm, zmxld ) 
    752802      ! 
    753803      IF( nn_timing == 1 )  CALL timing_stop('tke_avn') 
     
    759809      !!---------------------------------------------------------------------- 
    760810      !!                  ***  ROUTINE zdf_tke_init  *** 
    761       !!                      
    762       !! ** Purpose :   Initialization of the vertical eddy diffivity and  
     811      !! 
     812      !! ** Purpose :   Initialization of the vertical eddy diffivity and 
    763813      !!              viscosity when using a tke turbulent closure scheme 
    764814      !! 
     
    776826         &                 rn_emin0, rn_bshear, nn_mxl , ln_mxl0  ,   & 
    777827         &                 rn_mxl0 , nn_pdl   , ln_lc  , rn_lc    ,   & 
    778          &                 nn_etau , nn_htau  , rn_efr , rn_c    
     828         &                 nn_etau , nn_htau  , rn_efr , rn_c 
    779829      !!---------------------------------------------------------------------- 
    780830 
     
    843893         rn_mxl0 = rmxl_min 
    844894      ENDIF 
    845        
     895 
     896      ALLOCATE( rn_lc0   (jpi,jpj) ) ; rn_lc0    = rn_lc 
     897      ALLOCATE( rn_ediff0(jpi,jpj) ) ; rn_ediff0 = rn_ediff 
     898      ALLOCATE( rn_ediss0(jpi,jpj) ) ; rn_ediss0 = rn_ediss 
     899      ALLOCATE( rn_ebb0  (jpi,jpj) ) ; rn_ebb0   = rn_ebb 
     900      ALLOCATE( rn_efr0  (jpi,jpj) ) ; rn_efr0   = rn_efr 
     901 
    846902      IF( nn_etau == 2  ) THEN 
    847903          ierr = zdf_mxl_alloc() 
     
    855911 
    856912      !                               !* depth of penetration of surface tke 
    857       IF( nn_etau /= 0 ) THEN       
     913      IF( nn_etau /= 0 ) THEN 
    858914         htau(:,:) = 0._wp 
    859915         SELECT CASE( nn_htau )             ! Choice of the depth of penetration 
     
    861917            htau(:,:) = 10._wp 
    862918         CASE( 1 )                                 ! F(latitude) : 0.5m to 30m poleward of 40 degrees 
    863             htau(:,:) = MAX(  0.5_wp, MIN( 30._wp, 45._wp* ABS( SIN( rpi/180._wp * gphit(:,:) ) ) )   )             
     919            htau(:,:) = MAX(  0.5_wp, MIN( 30._wp, 45._wp* ABS( SIN( rpi/180._wp * gphit(:,:) ) ) )   ) 
    864920         CASE( 2 )                                 ! fraction of depth-integrated TKE within mixed-layer 
    865921            rhtau = -1._wp / LOG( 1._wp - rn_c ) 
     
    904960      END DO 
    905961      dissl(:,:,:) = 1.e-12_wp 
    906       !                               
     962      ! 
    907963      CALL tke_rst( nit000, 'READ' )  !* read or initialize all required files 
    908964      ! 
     
    913969     !!--------------------------------------------------------------------- 
    914970     !!                   ***  ROUTINE tke_rst  *** 
    915      !!                      
     971     !! 
    916972     !! ** Purpose :   Read or write TKE file (en) in restart file 
    917973     !! 
    918974     !! ** Method  :   use of IOM library 
    919      !!                if the restart does not contain TKE, en is either  
    920      !!                set to rn_emin or recomputed  
     975     !!                if the restart does not contain TKE, en is either 
     976     !!                set to rn_emin or recomputed 
    921977     !!---------------------------------------------------------------------- 
    922978     INTEGER         , INTENT(in) ::   kt     ! ocean time-step 
     
    927983     !!---------------------------------------------------------------------- 
    928984     ! 
    929      IF( TRIM(cdrw) == 'READ' ) THEN        ! Read/initialise  
     985     IF( TRIM(cdrw) == 'READ' ) THEN        ! Read/initialise 
    930986        !                                   ! --------------- 
    931987        IF( ln_rstart ) THEN                   !* Read the restart file 
     
    9561012              CALL tke_avn                               ! recompute avt, avm, avmu, avmv and dissl (approximation) 
    9571013              ! 
    958               avt_k (:,:,:) = avt (:,:,:) 
    959               avm_k (:,:,:) = avm (:,:,:) 
    960               avmu_k(:,:,:) = avmu(:,:,:) 
    961               avmv_k(:,:,:) = avmv(:,:,:) 
    962               ! 
    9631014              DO jit = nit000 + 1, nit000 + 10   ;   CALL zdf_tke( jit )   ;   END DO 
    9641015           ENDIF 
    9651016        ELSE                                   !* Start from rest 
    9661017           en(:,:,:) = rn_emin * tmask(:,:,:) 
    967            DO jk = 1, jpk                           ! set the Kz to the background value 
    968               avt (:,:,jk) = avtb(jk) * wmask (:,:,jk) 
    969               avm (:,:,jk) = avmb(jk) * wmask (:,:,jk) 
    970               avmu(:,:,jk) = avmb(jk) * wumask(:,:,jk) 
    971               avmv(:,:,jk) = avmb(jk) * wvmask(:,:,jk) 
    972            END DO 
    9731018        ENDIF 
    9741019        ! 
     1020        avt_k (:,:,:) = avt (:,:,:) 
     1021        avm_k (:,:,:) = avm (:,:,:) 
     1022        avmu_k(:,:,:) = avmu(:,:,:) 
     1023        avmv_k(:,:,:) = avmv(:,:,:) 
     1024 
    9751025     ELSEIF( TRIM(cdrw) == 'WRITE' ) THEN   ! Create restart file 
    9761026        !                                   ! ------------------- 
Note: See TracChangeset for help on using the changeset viewer.