Index: /NEMO/branches/2020/r4.0-HEAD_r12713_clem_dan_fixcpl/tests/CANAL/EXPREF/namelist_cfg
===================================================================
--- /NEMO/branches/2020/r4.0-HEAD_r12713_clem_dan_fixcpl/tests/CANAL/EXPREF/namelist_cfg	(revision 12750)
+++ /NEMO/branches/2020/r4.0-HEAD_r12713_clem_dan_fixcpl/tests/CANAL/EXPREF/namelist_cfg	(revision 12751)
@@ -20,10 +20,10 @@
 &namusr_def    !   User defined :   CANAL configuration: Flat bottom, beta-plane
 !-----------------------------------------------------------------------
-   rn_domszx   =   3600.   !  x horizontal size         [km]
-   rn_domszy   =   1800.   !  y horizontal size         [km]
-   rn_domszz   =   5000.   !  z vertical size            [m]
-   rn_dx       =     30.   !  x horizontal resolution   [km]
-   rn_dy       =     30.   !  y horizontal resolution   [km]
-   rn_dz       =    500.   !  z vertical resolution      [m]
+   rn_domszx   =   2000.   !  x horizontal size         [km]
+   rn_domszy   =   1000.   !  y horizontal size         [km]
+   rn_domszz   =   1000.   !  z vertical size            [m]
+   rn_dx       =     10.   !  x horizontal resolution   [km]
+   rn_dy       =     10.   !  y horizontal resolution   [km]
+   rn_dz       =   1000.   !  z vertical resolution      [m]
    rn_0xratio  =      0.5  !  x-domain ratio of the 0
    rn_0yratio  =      0.5  !  y-domain ratio of the 0
@@ -31,16 +31,23 @@
    rn_ppgphi0  =    38.5   !  Reference latitude      [degrees]
    rn_u10      =      0.   !  10m wind speed              [m/s]
-     rn_windszx =   4000.   !  longitudinal wind extension   [km]
-     rn_windszy =   4000.   !  latitudinal wind extension    [km]
-     rn_uofac  =      0.   !  Uoce multiplicative factor (0.:absolute or 1.:relative winds)
+     rn_windszx =   90.    !  longitudinal wind extension   [km]
+     rn_windszy =   90.    !  latitudinal wind extension    [km]
+!!clem     rn_uofac  =     0.    !  Uoce multiplicative factor (0.:absolute or 1.:relative winds)
    rn_vtxmax   =      1.   !  initial vortex max current  [m/s]
    rn_uzonal   =      1.   !  initial zonal current       [m/s]
-     rn_ujetszx =   4000.   !  longitudinal jet extension   [km]
-     rn_ujetszy =   4000.   !  latitudinal jet extension    [km]
+     rn_ujetszx =   4000.  !  longitudinal jet extension   [km]
+     rn_ujetszy =   400.   !  latitudinal jet extension    [km]
    nn_botcase  =      0    !  bottom definition (0:flat, 1:bump)
-   nn_initcase =      1    !  initial condition case (0:rest, 1:zonal current, 2:current shear, 3: gaussian zonal current,
-      !                    !                          4: geostrophic zonal pulse, 5: vortex)
-   ln_sshnoise =  .false.  !  add random noise on initial ssh
-   rn_lambda   =     50.   ! gaussian lambda
+   nn_initcase =      1    !  initial condition case
+   !                       !          -1 : stratif at rest
+   !                       !           0 : rest
+   !                       !           1 : zonal current
+   !                       !           2 : current shear
+   !                       !           3 : gaussian zonal current
+   !                       !           4 : geostrophic zonal pulse
+   !                       !           5 : baroclinic vortex
+   ln_sshnoise =  .FALSE.  !  add random noise on initial ssh
+   rn_lambda   =     50.   !  gaussian lambda
+   nn_perio    = 1
 /
 !-----------------------------------------------------------------------
@@ -59,6 +66,12 @@
 !-----------------------------------------------------------------------
    ln_linssh   =  .false.  !  =T  linear free surface  ==>>  model level are fixed in time
-   rn_rdt      =   1440.   !  time step for the dynamics (and tracer if nn_acc=0)
-   rn_atfp     =   0.05    !  asselin time filter parameter
+   rn_rdt      =   1200.   !  time step for the dynamics (and tracer if nn_acc=0)
+   rn_atfp     =   0.0     !  asselin time filter parameter
+/
+!-----------------------------------------------------------------------
+&namcfg        !   parameters of the configuration                      (default: use namusr_def in namelist_cfg)
+!-----------------------------------------------------------------------
+   ln_write_cfg = .false.   !  (=T) create the domain configuration file
+      cn_domcfg_out = "domain_cfg" ! newly created domain configuration filename
 /
 !!======================================================================
@@ -148,8 +161,8 @@
    ln_traadv_OFF = .false. !  No tracer advection
    ln_traadv_cen = .false. !  2nd order centered scheme
-      nn_cen_h   =  4            !  =2/4, horizontal 2nd order CEN / 4th order CEN
-      nn_cen_v   =  4            !  =2/4, vertical   2nd order CEN / 4th order COMPACT
+      nn_cen_h   =  2            !  =2/4, horizontal 2nd order CEN / 4th order CEN
+      nn_cen_v   =  2            !  =2/4, vertical   2nd order CEN / 4th order COMPACT
    ln_traadv_fct = .false. !  FCT scheme
-      nn_fct_h   =  2            !  =2/4, horizontal 2nd / 4th order
+      nn_fct_h   =  4            !  =2/4, horizontal 2nd / 4th order
       nn_fct_v   =  2            !  =2/4, vertical   2nd / COMPACT 4th order
    ln_traadv_mus = .false. !  MUSCL scheme
@@ -162,5 +175,35 @@
 &namtra_ldf    !   lateral diffusion scheme for tracers                 (default: NO selection)
 !-----------------------------------------------------------------------
-   ln_traldf_OFF   =  .true.  !  No explicit diffusion
+   !                       !  Operator type:
+   ln_traldf_OFF   = .true.    !  No explicit diffusion
+   ln_traldf_lap   = .false.   !    laplacian operator
+   ln_traldf_blp   = .false.   !  bilaplacian operator
+   !
+   !                       !  Direction of action:
+   ln_traldf_lev   = .false.   !  iso-level
+   ln_traldf_hor   = .true.    !  horizontal  (geopotential)
+   ln_traldf_iso   = .false.   !  iso-neutral (standard operator)
+   ln_traldf_triad = .false.   !  iso-neutral (triad    operator)
+   !
+   !                             !  iso-neutral options:
+   ln_traldf_msc   = .false.   !  Method of Stabilizing Correction      (both operators)
+   rn_slpmax       =  0.01     !  slope limit                           (both operators)
+   ln_triad_iso    = .false.   !  pure horizontal mixing in ML              (triad only)
+   rn_sw_triad     = 1         !  =1 switching triad ; =0 all 4 triads used (triad only)
+   ln_botmix_triad = .false.   !  lateral mixing on bottom                  (triad only)
+   !
+   !                       !  Coefficients:
+   nn_aht_ijk_t    = 31         !  space/time variation of eddy coefficient:
+      !                             !   =-20 (=-30)    read in eddy_diffusivity_2D.nc (..._3D.nc) file
+      !                             !   =  0           constant
+      !                             !   = 10 F(k)      =ldf_c1d
+      !                             !   = 20 F(i,j)    =ldf_c2d
+      !                             !   = 21 F(i,j,t)  =Treguier et al. JPO 1997 formulation
+      !                             !   = 30 F(i,j,k)  =ldf_c2d * ldf_c1d
+      !                             !   = 31 F(i,j,k,t)=F(local velocity and grid-spacing)
+      !                        !  time invariant coefficients:  aht0 = 1/2  Ud*Ld   (lap case)
+      !                             !                           or   = 1/12 Ud*Ld^3 (blp case)
+      rn_Ud        = 0.01           !  lateral diffusive velocity [m/s] (nn_aht_ijk_t= 0, 10, 20, 30)
+      rn_Ld        = 200.e+3        !  lateral diffusive length   [m]   (nn_aht_ijk_t= 0, 10)
 /
 !!======================================================================
@@ -183,13 +226,15 @@
       nn_dynkeg     = 0       ! scheme for grad(KE): =0   C2  ;  =1   Hollingsworth correction
    ln_dynadv_cen2 = .false. !  flux form - 2nd order centered scheme
-   ln_dynadv_ubs = .true.  !  flux form - 3rd order UBS      scheme
+   ln_dynadv_ubs  = .true.  !  flux form - 3rd order UBS      scheme
 /
 !-----------------------------------------------------------------------
 &namdyn_vor    !   Vorticity / Coriolis scheme                          (default: NO selection)
 !-----------------------------------------------------------------------
-   ln_dynvor_ene = .true.  !  energy conserving scheme
-   ln_dynvor_ens = .false. !  enstrophy conserving scheme
-   ln_dynvor_mix = .false. !  mixed scheme
+   ln_dynvor_ene = .false.  !  energy conserving scheme
+   ln_dynvor_ens = .false.  !  enstrophy conserving scheme
+   ln_dynvor_mix = .false.  !  mixed scheme
    ln_dynvor_een = .false.  !  energy & enstrophy scheme
+   ln_dynvor_enT = .false.  !  energy conserving scheme (T-point)
+   ln_dynvor_eeT = .true.   !  energy conserving scheme (een using e3t)
       nn_een_e3f = 0             !  e3f = masked averaging of e3t divided by 4 (=0) or by the sum of mask (=1)
 /
@@ -210,5 +255,5 @@
          !                          !                     = 1 Boxcar over   nn_baro sub-steps
          !                          !                     = 2 Boxcar over 2*nn_baro  "    "
-      ln_bt_auto    = .false.    ! Number of sub-step defined from:
+      ln_bt_auto    = .true.    ! Number of sub-step defined from:
          nn_baro      =  24         ! =F : the number of sub-step in rn_rdt seconds
 /
@@ -222,8 +267,8 @@
    !                       !  Direction of action  :
    ln_dynldf_lev =  .false.    !  iso-level
-   ln_dynldf_hor =  .true.    !  horizontal (geopotential)
+   ln_dynldf_hor =  .false.    !  horizontal (geopotential)
    ln_dynldf_iso =  .false.    !  iso-neutral
    !                       !  Coefficient
-   nn_ahm_ijk_t  = 20           !  space/time variation of eddy coef
+   nn_ahm_ijk_t  = 31           !  space/time variation of eddy coef
       !                             !  =-30  read in eddy_viscosity_3D.nc file
       !                             !  =-20  read in eddy_viscosity_2D.nc file
@@ -275,7 +320,8 @@
 !!   namdiu       Cool skin and warm layer models                       (default: OFF)
 !!   namdiu       Cool skin and warm layer models                       (default: OFF)
-!!   namflo       float parameters                                      (default: OFF)
-!!   nam_diaharm  Harmonic analysis of tidal constituents               (default: OFF)
-!!   nam_diadct   transports through some sections                      (default: OFF)
+!!   namflo       float parameters                                      ("key_float")
+!!   nam_diaharm  Harmonic analysis of tidal constituents               ("key_diaharm")
+!!   namdct       transports through some sections                      ("key_diadct")
+!!   nam_diatmb   Top Middle Bottom Output                              (default: OFF)
 !!   nam_dia25h   25h Mean Output                                       (default: OFF)
 !!   namnc4       netcdf4 chunking and compression settings             ("key_netcdf4")
@@ -286,5 +332,5 @@
 !-----------------------------------------------------------------------
    ln_glo_trd  = .false.   ! (T) global domain averaged diag for T, T^2, KE, and PE
-   ln_dyn_trd  = .true.   ! (T) 3D momentum trend output
+   ln_dyn_trd  = .true.    ! (T) 3D momentum trend output
    ln_dyn_mxl  = .false.   ! (T) 2D momentum trends averaged over the mixed layer (not coded yet)
    ln_vor_trd  = .false.   ! (T) 2D barotropic vorticity trends (not coded yet)
@@ -313,8 +359,12 @@
 &nammpp        !   Massively Parallel Processing                        ("key_mpp_mpi")
 !-----------------------------------------------------------------------
+!!   jpni        =   8       !  jpni   number of processors following i (set automatically if < 1)
+!!   jpnj        =   1       !  jpnj   number of processors following j (set automatically if < 1)
 /
 !-----------------------------------------------------------------------
 &namctl        !   Control prints                                       (default: OFF)
 !-----------------------------------------------------------------------
+   ln_timing   = .true.   !  timing by routine write out in timing.output file
+!!   ln_diacfl   = .true.   !  CFL diagnostics write out in cfl_diagnostics.ascii
 /
 !-----------------------------------------------------------------------
Index: /NEMO/branches/2020/r4.0-HEAD_r12713_clem_dan_fixcpl/tests/CANAL/MY_SRC/usrdef_istate.F90
===================================================================
--- /NEMO/branches/2020/r4.0-HEAD_r12713_clem_dan_fixcpl/tests/CANAL/MY_SRC/usrdef_istate.F90	(revision 12750)
+++ /NEMO/branches/2020/r4.0-HEAD_r12713_clem_dan_fixcpl/tests/CANAL/MY_SRC/usrdef_istate.F90	(revision 12751)
@@ -64,9 +64,24 @@
       IF(lwp) WRITE(numout,*) '~~~~~~~~~~~~~~   '
       !
-      IF (ln_sshnoise) CALL RANDOM_NUMBER(zrandom)
       zjetx = ABS(rn_ujetszx)/2.
       zjety = ABS(rn_ujetszy)/2.
       !
+      zf0   = 2._wp * omega * SIN( rad * rn_ppgphi0 )
+      !
       SELECT CASE(nn_initcase)
+
+      CASE(-1)    ! stratif at rest
+
+         ! sea level:
+         pssh(:,:) = 0.
+         ! temperature:
+         pts(:,:,1,jp_tem) = 25. !!30._wp
+         pts(:,:,2:jpk,jp_tem) = 22. !!24._wp
+         ! salinity:  
+         pts(:,:,:,jp_sal) = 35._wp
+         ! velocities:
+         pu(:,:,:) = 0.
+         pv(:,:,:) = 0.
+
       CASE(0)    ! rest
          
@@ -96,7 +111,7 @@
             zbeta = 2._wp * omega * COS( rad * rn_ppgphi0 ) / ra
             WHERE( ABS(gphit) <= zjety )
-               pssh(:,:) = - rn_uzonal / grav * ( ff_t(:,:) * gphit(:,:) * 1.e3 + 0.5 * zbeta * gphit(:,:) * gphit(:,:) * 1.e6 )
-            ELSEWHERE
-               pssh(:,:) = - rn_uzonal / grav * ( ff_t(:,:) * SIGN(zjety, gphit(:,:)) * 1.e3   &
+               pssh(:,:) = - rn_uzonal / grav * ( zf0 * gphit(:,:) * 1.e3 + 0.5 * zbeta * gphit(:,:) * gphit(:,:) * 1.e6 )
+            ELSEWHERE
+               pssh(:,:) = - rn_uzonal / grav * ( zf0 * SIGN(zjety, gphit(:,:)) * 1.e3   &
                   &                             + 0.5 * zbeta * zjety * zjety * 1.e6 )
             END WHERE
@@ -107,5 +122,10 @@
          pts(:,:,jpk,jp_sal) = 0.
          DO jk=1, jpkm1
-            pts(:,:,jk,jp_sal) = gphit(:,:)
+            WHERE( ABS(gphit) <= zjety )
+!!$            WHERE( ABS(gphit) <= zjety*0.5 .AND. ABS(glamt) <= zjety*0.5 ) ! for a square of salt
+               pts(:,:,jk,jp_sal) = 35.
+            ELSEWHERE
+               pts(:,:,jk,jp_sal) = 30.
+            END WHERE                    
          END DO
          ! velocities:
@@ -132,8 +152,8 @@
             WHERE( ABS(gphit) <= zjety )
                pssh(:,:) = - SIGN(rn_uzonal, gphit(:,:)) / grav   &
-                  &        * ( ff_t(:,:) * gphit(:,:) * 1.e3 + 0.5 * zbeta * gphit(:,:) * gphit(:,:) * 1.e6 )
+                  &        * ( zf0 * gphit(:,:) * 1.e3 + 0.5 * zbeta * gphit(:,:) * gphit(:,:) * 1.e6 )
             ELSEWHERE
                pssh(:,:) = - SIGN(rn_uzonal, gphit(:,:)) / grav   &
-                  &        * ( ff_t(:,:) * SIGN(zjety, gphit(:,:)) * 1.e3 + 0.5 * zbeta * zjety * zjety * 1.e6 )
+                  &        * ( zf0 * SIGN(zjety, gphit(:,:)) * 1.e3 + 0.5 * zbeta * zjety * zjety * 1.e6 )
             END WHERE
          END SELECT
@@ -141,7 +161,7 @@
          pts(:,:,:,jp_tem) = 10._wp
          ! salinity:  
-         pts(:,:,:,jp_sal) = 2.
-         DO jk=1, jpkm1
-            WHERE( ABS(gphiv) <= zjety ) pts(:,:,jk,jp_sal) = 2. + SIGN(1.,gphiv(:,:))
+         pts(:,:,:,jp_sal) = 30.
+         DO jk=1, jpkm1
+            WHERE( ABS(gphiv) <= zjety ) pts(:,:,jk,jp_sal) = 30. + SIGN(1.,gphiv(:,:))
          END DO
          ! velocities:
@@ -176,5 +196,5 @@
          ! salinity:  
          DO jk=1, jpkm1
-            pts(:,:,jk,jp_sal) = gphit(:,:)
+            pts(:,:,jk,jp_sal) = pssh(:,:)
          END DO
          ! velocities:
@@ -213,5 +233,5 @@
          zf0   = 2._wp * omega * SIN( rad * rn_ppgphi0 )
          zumax = rn_vtxmax * SIGN(1._wp, zf0) ! Here Anticyclonic: set zumax=-1 for cyclonic
-         zlambda = SQRT(2._wp)*rn_lambda       ! Horizontal scale in meters 
+         zlambda = SQRT(2._wp)*rn_lambda*1.e3       ! Horizontal scale in meters 
          zn2 = 3.e-3**2
          zH = 0.5_wp * 5000._wp
@@ -253,6 +273,6 @@
          ! velocities:
          za = 2._wp * zP0 / zlambda**2
-         DO jj=1, jpj
-            DO ji=1, jpim1
+         DO jj = 2, jpjm1
+            DO ji = 2, jpim1
                zx = glamu(ji,jj) * 1.e3
                zy = gphiu(ji,jj) * 1.e3
@@ -270,6 +290,6 @@
          END DO
          !
-         DO jj=1, jpjm1
-            DO ji=1, jpi
+         DO jj = 2, jpjm1
+            DO ji = 2, jpim1
                zx = glamv(ji,jj) * 1.e3
                zy = gphiv(ji,jj) * 1.e3
@@ -287,15 +307,14 @@
          END DO
          !            
+         CALL lbc_lnk_multi( 'usrdef_istate', pu, 'U', -1., pv, 'V', -1. )
+
       END SELECT
 
       IF (ln_sshnoise) THEN
+         CALL RANDOM_SEED()
          CALL RANDOM_NUMBER(zrandom)
          pssh(:,:) = pssh(:,:) + ( 0.1  * zrandom(:,:) - 0.05 )
       END IF
-      CALL lbc_lnk( 'usrdef_istate', pssh, 'T',  1. )
-      CALL lbc_lnk(  'usrdef_istate', pts, 'T',  1. )
-      CALL lbc_lnk(   'usrdef_istate', pu, 'U', -1. )
-      CALL lbc_lnk(   'usrdef_istate', pv, 'V', -1. )
-
+  
    END SUBROUTINE usr_def_istate
 
Index: /NEMO/branches/2020/r4.0-HEAD_r12713_clem_dan_fixcpl/tests/CANAL/MY_SRC/usrdef_nam.F90
===================================================================
--- /NEMO/branches/2020/r4.0-HEAD_r12713_clem_dan_fixcpl/tests/CANAL/MY_SRC/usrdef_nam.F90	(revision 12750)
+++ /NEMO/branches/2020/r4.0-HEAD_r12713_clem_dan_fixcpl/tests/CANAL/MY_SRC/usrdef_nam.F90	(revision 12751)
@@ -50,4 +50,5 @@
    LOGICAL , PUBLIC ::   ln_sshnoise=.false. ! add random noise on initial ssh
    REAL(wp), PUBLIC ::   rn_lambda  = 50.    ! gaussian lambda
+   INTEGER , PUBLIC ::   nn_perio   =    0   ! periodicity of the channel (0=closed, 1=E-W)
 
    !!----------------------------------------------------------------------
@@ -79,7 +80,7 @@
       !!
       NAMELIST/namusr_def/  rn_domszx, rn_domszy, rn_domszz, rn_dx, rn_dy, rn_dz, rn_0xratio, rn_0yratio   &
-         &                 , nn_fcase, rn_ppgphi0, rn_vtxmax, rn_uzonal, rn_ujetszx, rn_ujetszy   &
-         &                 , rn_u10, rn_windszx, rn_windszy, rn_uofac   &
-         &                 , nn_botcase, nn_initcase, ln_sshnoise, rn_lambda
+         &                 , nn_fcase, rn_ppgphi0, rn_u10, rn_windszx, rn_windszy & !!, rn_uofac   &
+         &                 , rn_vtxmax, rn_uzonal, rn_ujetszx, rn_ujetszy  &
+         &                 , nn_botcase, nn_initcase, ln_sshnoise, rn_lambda, nn_perio
       !!----------------------------------------------------------------------
       !
@@ -151,8 +152,8 @@
          WRITE(numout,*) '      add random noise on initial ssh   ln_sshnoise= ', ln_sshnoise
          WRITE(numout,*) '      Gaussian lambda parameter          rn_lambda = ', rn_lambda
-         WRITE(numout,*) '   '
-         WRITE(numout,*) '   Lateral boundary condition of the global domain'
-         WRITE(numout,*) '      EW_CANAL : closed basin               jperio = ', kperio
+         WRITE(numout,*) '      Periodicity of the basin            nn_perio = ', nn_perio
       ENDIF
+      !                             ! Set the lateral boundary condition of the global domain
+      kperio = nn_perio                    ! EW_CANAL configuration : closed basin
       !
    END SUBROUTINE usr_def_nam
Index: /NEMO/branches/2020/r4.0-HEAD_r12713_clem_dan_fixcpl/tests/CANAL/MY_SRC/usrdef_sbc.F90
===================================================================
--- /NEMO/branches/2020/r4.0-HEAD_r12713_clem_dan_fixcpl/tests/CANAL/MY_SRC/usrdef_sbc.F90	(revision 12750)
+++ /NEMO/branches/2020/r4.0-HEAD_r12713_clem_dan_fixcpl/tests/CANAL/MY_SRC/usrdef_sbc.F90	(revision 12751)
@@ -17,5 +17,5 @@
    USE sbc_oce         ! Surface boundary condition: ocean fields
    USE phycst          ! physical constants
-   USE usrdef_nam, ONLY : rn_u10, rn_uofac, rn_windszy 
+   USE usrdef_nam, ONLY : rn_u10, rn_uofac, rn_windszy, rn_windszx 
    !
    USE in_out_manager  ! I/O manager
@@ -71,7 +71,4 @@
          !
          utau(:,:) = 0._wp
-         IF( rn_u10 /= 0. .AND. rn_windszy > 0. ) THEN
-            WHERE( ABS(gphit) <= rn_windszy/2. ) utau(:,:) = zrhocd * rn_u10 * rn_u10
-         ENDIF
          vtau(:,:) = 0._wp
          taum(:,:) = 0._wp
@@ -83,4 +80,12 @@
          qsr (:,:) = 0._wp
          !         
+      ENDIF
+
+      IF( rn_u10 /= 0. .AND. rn_windszy > 0. ) THEN
+         IF( nyear == 1 .AND. nmonth == 1 .AND. nday <= 10 ) THEN
+            WHERE( ABS(gphit) <= rn_windszy/2. .AND. ABS(glamt) <= rn_windszx/2. ) utau(:,:) = zrhocd * rn_u10 * rn_u10
+         ELSE
+            utau(:,:) = 0.
+         ENDIF
       ENDIF
 
Index: /NEMO/branches/2020/r4.0-HEAD_r12713_clem_dan_fixcpl/tests/CANAL/MY_SRC/usrdef_zgr.F90
===================================================================
--- /NEMO/branches/2020/r4.0-HEAD_r12713_clem_dan_fixcpl/tests/CANAL/MY_SRC/usrdef_zgr.F90	(revision 12750)
+++ /NEMO/branches/2020/r4.0-HEAD_r12713_clem_dan_fixcpl/tests/CANAL/MY_SRC/usrdef_zgr.F90	(revision 12751)
@@ -199,7 +199,7 @@
          zmaxlam = MAXVAL(glamt)
          CALL mpp_max( 'usrdef_zgr', zmaxlam )                 ! max over the global domain
-         zscl = rpi / zmaxlam
-         z2d(:,:) = 0.5 * ( 1. - COS( glamt(:,:) * zscl ) )
-         z2d(:,:) = REAL(jpkm1 - NINT( 0.75 * REAL(jpkm1,wp) * z2d(:,:) ), wp)
+         zscl = 0.5 * rpi / zmaxlam
+         z2d(:,:) = COS( glamt(:,:) * zscl )
+         z2d(:,:) = REAL(jpkm1 - NINT( 0.5 * REAL(jpkm1,wp) * z2d(:,:) ), wp)
       END SELECT
       !
