Index: NEMO/branches/2020/dev_r13327_KERNEL-06_2_techene_e3/src/OCE/nemogcm.F90
===================================================================
--- NEMO/branches/2020/dev_r13327_KERNEL-06_2_techene_e3/src/OCE/nemogcm.F90	(revision 13607)
+++ NEMO/branches/2020/dev_r13327_KERNEL-06_2_techene_e3/src/OCE/nemogcm.F90	(revision 13608)
@@ -42,62 +42,39 @@
    !!----------------------------------------------------------------------
    USE step_oce       ! module used in the ocean time stepping module (step.F90)
+   !
    USE phycst         ! physical constant                  (par_cst routine)
    USE domain         ! domain initialization   (dom_init & dom_cfg routines)
-   USE closea         ! treatment of closed seas (for ln_closea)
-   USE usrdef_nam     ! user defined configuration
-   USE tide_mod, ONLY : tide_init ! tidal components initialization   (tide_init routine)
-   USE bdyini         ! open boundary cond. setting       (bdy_init routine)
+   USE wet_dry        ! Wetting and drying setting   (wad_init routine)
+   USE usrdef_nam     ! user defined configuration namelist
+   USE tide_mod, ONLY : tide_init   ! tidal components initialization   (tide_init routine)
+   USE bdyini  , ONLY : bdy_init    ! open boundary cond. setting       (bdy_init routine)
    USE istate         ! initial state setting          (istate_init routine)
-   USE ldfdyn         ! lateral viscosity setting      (ldfdyn_init routine)
-   USE ldftra         ! lateral diffusivity setting    (ldftra_init routine)
    USE trdini         ! dyn/tra trends initialization     (trd_init routine)
-   USE asminc         ! assimilation increments     
-   USE asmbkg         ! writing out state trajectory
-   USE diaptr         ! poleward transports           (dia_ptr_init routine)
-   USE diadct         ! sections transports           (dia_dct_init routine)
-   USE diaobs         ! Observation diagnostics       (dia_obs_init routine)
-   USE diacfl         ! CFL diagnostics               (dia_cfl_init routine)
-   USE diamlr         ! IOM context management for multiple-linear-regression analysis
+   USE icbini         ! handle bergs, initialisation
+   USE icbstp  , ONLY : icb_end     ! handle bergs, close iceberg files
+   USE cpl_oasis3     ! OASIS3 coupling
+   USE dyndmp         ! Momentum damping (C1D only)
+   USE step_diu       ! diurnal bulk SST timestepping (called from here if run offline)
+   USE crsini         ! initialise grid coarsening utility
+   USE dia25h  , ONLY : dia_25h_init   ! 25h mean output (initialisation)
+   USE c1d            ! 1D configuration
+   USE step_c1d       ! Time stepping loop for the 1D configuration
+#if defined key_top
+   USE trcini         ! passive tracer initialisation
+#endif
+#if defined key_nemocice_decomp
+   USE ice_domain_size, only: nx_global, ny_global
+#endif
 #if defined key_qco
-   USE stepMLF        ! NEMO time-stepping               (stp_MLF   routine)
+   USE stpMLF        ! NEMO time-stepping               (stp_MLF   routine)
 #else
    USE step           ! NEMO time-stepping                 (stp     routine)
 #endif
-   USE isfstp         ! ice shelf                     (isf_stp_init routine)
-   USE icbini         ! handle bergs, initialisation
-   USE icbstp         ! handle bergs, calving, themodynamics and transport
-   USE cpl_oasis3     ! OASIS3 coupling
-   USE c1d            ! 1D configuration
-   USE step_c1d       ! Time stepping loop for the 1D configuration
-   USE dyndmp         ! Momentum damping
-   USE stopar         ! Stochastic param.: ???
-   USE stopts         ! Stochastic param.: ???
-   USE diu_layers     ! diurnal bulk SST and coolskin
-   USE step_diu       ! diurnal bulk SST timestepping (called from here if run offline)
-   USE crsini         ! initialise grid coarsening utility
-   USE dia25h         ! 25h mean output
-   USE diadetide      ! Weights computation for daily detiding of model diagnostics
-   USE sbc_oce , ONLY : lk_oasis
-   USE wet_dry        ! Wetting and drying setting   (wad_init routine)
-#if defined key_top
-   USE trcini         ! passive tracer initialisation
-#endif
-#if defined key_nemocice_decomp
-   USE ice_domain_size, only: nx_global, ny_global
-#endif
    !
-   USE prtctl         ! Print control
-   USE in_out_manager ! I/O manager
    USE lib_mpp        ! distributed memory computing
    USE mppini         ! shared/distributed memory setting (mpp_init routine)
    USE lbcnfd  , ONLY : isendto, nsndto  ! Setup of north fold exchanges 
    USE lib_fortran    ! Fortran utilities (allows no signed zero when 'key_nosignedzero' defined)
-#if defined key_iomput
-   USE xios           ! xIOserver
-#endif
-#if defined key_agrif
-   USE agrif_all_update   ! Master Agrif update
-#endif
-   USE halo_mng
+   USE halo_mng       ! Halo manager
 
    IMPLICIT NONE
@@ -196,5 +173,5 @@
          !
          DO WHILE( istp <= nitend .AND. nstop == 0 )
-
+            !
             ncom_stp = istp
             IF( ln_timing ) THEN
@@ -203,5 +180,5 @@
                IF ( istp ==         nitend ) elapsed_time = zstptiming - elapsed_time
             ENDIF
-            
+            !
 #  if defined key_qco
             CALL stp_MLF      ( istp )
@@ -210,7 +187,7 @@
 #  endif
             istp = istp + 1
-
+            !
             IF( lwp .AND. ln_timing )   WRITE(numtime,*) 'timing step ', istp-1, ' : ', MPI_Wtime() - zstptiming
-
+            !
          END DO
          !
@@ -280,6 +257,6 @@
       INTEGER ::   ios, ilocal_comm   ! local integers
       !!
-      NAMELIST/namctl/ sn_cfctl, ln_timing, ln_diacfl,                                &
-         &             nn_isplt,  nn_jsplt,  nn_ictls, nn_ictle, nn_jctls, nn_jctle            
+      NAMELIST/namctl/ sn_cfctl, ln_timing, ln_diacfl, nn_isplt, nn_jsplt , nn_ictls,   &
+         &                                             nn_ictle, nn_jctls , nn_jctle
       NAMELIST/namcfg/ ln_read_cfg, cn_domcfg, ln_closea, ln_write_cfg, cn_domcfg_out, ln_use_jattr
       !!----------------------------------------------------------------------
Index: NEMO/branches/2020/dev_r13327_KERNEL-06_2_techene_e3/src/OCE/oce.F90
===================================================================
--- NEMO/branches/2020/dev_r13327_KERNEL-06_2_techene_e3/src/OCE/oce.F90	(revision 13607)
+++ NEMO/branches/2020/dev_r13327_KERNEL-06_2_techene_e3/src/OCE/oce.F90	(revision 13608)
@@ -16,5 +16,6 @@
    PRIVATE
 
-   PUBLIC oce_alloc ! routine called by nemo_init in nemogcm.F90
+   PUBLIC oce_alloc       ! routine called by nemo_init in     nemogcm.F90
+   PUBLIC oce_SWE_alloc   ! routine called by nemo_init in SWE/nemogcm.F90 (Shallow Water Eq. case)
 
    !! dynamics and tracer fields
@@ -68,4 +69,7 @@
    INTEGER, PUBLIC, DIMENSION(2) :: noce_array                             !: unused array but seems to be needed to prevent agrif from creating an empty module
 
+   !! Shallow Water Eq. case (SWE)
+   LOGICAL, PUBLIC ::   lk_SWE = .FALSE.                                   !: shallow water flag =T in SWE configurations only
+   
    !!----------------------------------------------------------------------
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
@@ -115,4 +119,26 @@
    END FUNCTION oce_alloc
 
+
+   INTEGER FUNCTION oce_SWE_alloc()
+      !!----------------------------------------------------------------------
+      !!                   ***  FUNCTION oce_SWE_alloc  ***
+      !!----------------------------------------------------------------------
+      INTEGER :: ierr(2)
+      !!----------------------------------------------------------------------
+      !
+      lk_SWE  = .TRUE.                   ! =T SWE case 
+      !
+      ierr(:) = 0 
+      ALLOCATE( uu(jpi,jpj,jpk,jpt) , vv  (jpi,jpj,jpk,jpt) ,     &          
+         &      ww(jpi,jpj,jpk)     , hdiv(jpi,jpj,jpk)     , ssh(jpi,jpj,jpt) , STAT=ierr(1) )
+         !
+      ALLOCATE(   ts(jpi,jpj,jpk,jpts,jpt) , fraqsr_1lev(jpi,jpj) ,  &
+         &      uu_b(jpi,jpj,jpt) , vv_b(jpi,jpj,jpt)       , rn2(jpi,jpj,jpk) , STAT=ierr(2) )
+         !
+      oce_SWE_alloc = MAXVAL( ierr )
+      IF( oce_SWE_alloc /= 0 )   CALL ctl_stop( 'STOP', 'oce_SWE_alloc: failed to allocate arrays' )
+      !
+   END FUNCTION oce_SWE_alloc
+
    !!======================================================================
 END MODULE oce
Index: NEMO/branches/2020/dev_r13327_KERNEL-06_2_techene_e3/src/OCE/step.F90
===================================================================
--- NEMO/branches/2020/dev_r13327_KERNEL-06_2_techene_e3/src/OCE/step.F90	(revision 13607)
+++ NEMO/branches/2020/dev_r13327_KERNEL-06_2_techene_e3/src/OCE/step.F90	(revision 13608)
@@ -42,6 +42,4 @@
    !!----------------------------------------------------------------------
    USE step_oce         ! time stepping definition modules
-   !
-   USE iom              ! xIOs server
 
    IMPLICIT NONE
Index: NEMO/branches/2020/dev_r13327_KERNEL-06_2_techene_e3/src/OCE/step_oce.F90
===================================================================
--- NEMO/branches/2020/dev_r13327_KERNEL-06_2_techene_e3/src/OCE/step_oce.F90	(revision 13607)
+++ NEMO/branches/2020/dev_r13327_KERNEL-06_2_techene_e3/src/OCE/step_oce.F90	(revision 13608)
@@ -3,4 +3,5 @@
    !!                       ***  MODULE step_oce  ***
    !! Ocean time-stepping : module used in both initialisation phase and time stepping
+   !!                                     (i.e. nemo_init and stp or stp_MLF routines)
    !!======================================================================
    !! History :   3.3  !  2010-08  (C. Ethe)  Original code - reorganisation of the initial phase
@@ -9,6 +10,4 @@
    USE oce             ! ocean dynamics and tracers variables
    USE dom_oce         ! ocean space and time domain variables
-   USE zdf_oce         ! ocean vertical physics variables
-   USE zdfdrg  ,  ONLY : ln_drgimp   ! implicit top/bottom friction
 
    USE daymod          ! calendar                         (day     routine)
@@ -19,9 +18,29 @@
    USE sbccpl          ! surface boundary condition: coupled formulation (call send at end of step)
    USE sbcapr          ! surface boundary condition: atmospheric pressure
-   USE tide_mod, ONLY : ln_tide, tide_update
    USE sbcwave         ! Wave intialisation
+   USE tide_mod        ! tides
+
+   USE bdy_oce  , ONLY : ln_bdy
+   USE bdydta          ! open boundary condition data     (bdy_dta routine)
+   USE bdytra          ! bdy cond. for tracers            (bdy_tra routine)
+   USE bdydyn3d        ! bdy cond. for baroclinic vel.  (bdy_dyn3d routine)
 
    USE isf_oce         ! ice shelf boundary condition
    USE isfstp          ! ice shelf boundary condition     (isf_stp routine)
+
+   USE sshwzv          ! vertical velocity and ssh        (ssh_nxt routine)
+   !                                                      (ssh_swp routine)
+   !                                                      (wzv     routine)
+   USE domvvl          ! variable vertical scale factors  (dom_vvl_sf_nxt routine)
+   !                                                      (dom_vvl_sf_swp routine)
+   
+   USE divhor          ! horizontal divergence            (div_hor routine)
+   USE dynadv          ! advection                        (dyn_adv routine)
+   USE dynvor          ! vorticity term                   (dyn_vor routine)
+   USE dynhpg          ! hydrostatic pressure grad.       (dyn_hpg routine)
+   USE dynldf          ! lateral momentum diffusion       (dyn_ldf routine)
+   USE dynzdf          ! vertical diffusion               (dyn_zdf routine)
+   USE dynspg          ! surface pressure gradient        (dyn_spg routine)
+   USE dynatf          ! time-filtering                   (dyn_atf routine)
 
    USE traqsr          ! solar radiation penetration      (tra_qsr routine)
@@ -39,27 +58,6 @@
    USE eosbn2          ! equation of state                (eos_bn2 routine)
 
-   USE divhor          ! horizontal divergence            (div_hor routine)
-   USE dynadv          ! advection                        (dyn_adv routine)
-   USE dynvor          ! vorticity term                   (dyn_vor routine)
-   USE dynhpg          ! hydrostatic pressure grad.       (dyn_hpg routine)
-   USE dynldf          ! lateral momentum diffusion       (dyn_ldf routine)
-   USE dynzdf          ! vertical diffusion               (dyn_zdf routine)
-   USE dynspg          ! surface pressure gradient        (dyn_spg routine)
-
-   USE dynatf          ! time-filtering                   (dyn_atf routine)
-
    USE stopar          ! Stochastic parametrization       (sto_par routine)
    USE stopts 
-
-   USE bdy_oce  , ONLY : ln_bdy
-   USE bdydta          ! open boundary condition data     (bdy_dta routine)
-   USE bdytra          ! bdy cond. for tracers            (bdy_tra routine)
-   USE bdydyn3d        ! bdy cond. for baroclinic vel.  (bdy_dyn3d routine)
-
-   USE sshwzv          ! vertical velocity and ssh        (ssh_nxt routine)
-   !                                                       (ssh_swp routine)
-   !                                                       (wzv     routine)
-   USE domvvl          ! variable vertical scale factors  (dom_vvl_sf_nxt routine)
-   !                                                       (dom_vvl_sf_swp routine)
 
    USE ldfslp          ! iso-neutral slopes               (ldf_slp routine)
@@ -67,6 +65,8 @@
    USE ldftra          ! lateral eddy diffusive coef.     (ldf_tra routine)
 
+   USE zdf_oce         ! ocean vertical physics variables
    USE zdfphy          ! vertical physics manager      (zdf_phy_init routine)
-   USE zdfosm  , ONLY : osm_rst, dyn_osm, tra_osm      ! OSMOSIS routines used in step.F90
+   USE zdfdrg   , ONLY : ln_drgimp   ! implicit top/bottom friction
+   USE zdfosm   , ONLY : osm_rst, dyn_osm, tra_osm      ! OSMOSIS routines used in step.F90
 
    USE diu_layers      ! diurnal SST bulk and coolskin routines
@@ -81,6 +81,6 @@
    USE diahth          ! thermocline depth                (dia_hth routine)
    USE diahsb          ! heat, salt and volume budgets    (dia_hsb routine)
-   USE diacfl
-   USE diaobs          ! Observation operator
+   USE diacfl          ! CFL diagnostics                  (dia_cfl routine)
+   USE diaobs          ! Observation operator             (dia_obs routine)
    USE diadetide       ! Weights computation for daily detiding of model diagnostics
    USE diamlr          ! IOM context management for multiple-linear-regression analysis
@@ -92,5 +92,5 @@
    USE asminc          ! assimilation increments      (tra_asm_inc routine)
    !                                                   (dyn_asm_inc routine)
-   USE asmbkg
+   USE asmbkg          ! writing out state trajectory
    USE stpctl          ! time stepping control            (stp_ctl routine)
    USE restart         ! ocean restart                    (rst_wri routine)
Index: NEMO/branches/2020/dev_r13327_KERNEL-06_2_techene_e3/src/OCE/stpMLF.F90
===================================================================
--- NEMO/branches/2020/dev_r13327_KERNEL-06_2_techene_e3/src/OCE/stpMLF.F90	(revision 13607)
+++ NEMO/branches/2020/dev_r13327_KERNEL-06_2_techene_e3/src/OCE/stpMLF.F90	(revision 13608)
@@ -1,6 +1,7 @@
-MODULE stepMLF
+MODULE stpMLF
    !!======================================================================
-   !!                       ***  MODULE step  ***
+   !!                       ***  MODULE stpMLF  ***
    !! Time-stepping   : manager of the ocean, tracer and ice time stepping
+   !!                   using Modified Leap Frog for OCE
    !!======================================================================
    !! History :  OPA  !  1991-03  (G. Madec)  Original code
@@ -32,5 +33,5 @@
    !!            4.0  !  2017-05  (G. Madec)  introduction of the vertical physics manager (zdfphy)
    !!            4.1  !  2019-08  (A. Coward, D. Storkey) rewrite in preparation for new timestepping scheme
-   !!            4.x  !  2020-08  (S. Techene, G. Madec)  quasi eulerian coordinate time stepping 
+   !!            4.x  !  2020-08  (S. Techene, G. Madec)  quasi eulerian coordinate time stepping
    !!----------------------------------------------------------------------
 
@@ -45,6 +46,5 @@
    USE step_oce       ! time stepping definition modules
    !
-   USE iom            ! xIOs server
-   USE domqco
+   USE domqco         ! quasi-eulerian coordinate
    USE traatfqco      ! time filtering                   (tra_atf_qco routine)
    USE dynatfqco      ! time filtering                   (dyn_atf_qco routine)
@@ -57,8 +57,8 @@
    PUBLIC   stp_MLF   ! called by nemogcm.F90
 
-   !!----------------------------------------------------------------------
-   !! time level indices
-   !!----------------------------------------------------------------------
-   INTEGER, PUBLIC :: Nbb, Nnn, Naa, Nrhs          !! used by nemo_init
+   !                                          !**  time level indices  **!
+   INTEGER, PUBLIC ::   Nbb, Nnn, Naa, Nrhs   !: used by nemo_init
+
+   !! * Substitutions
 #  include "domzgr_substitute.h90"
    !!----------------------------------------------------------------------
@@ -94,7 +94,4 @@
       INTEGER ::   ji, jj, jk   ! dummy loop indice
       INTEGER ::   indic        ! error indicator if < 0
-!!gm kcall can be removed, I guess
-      INTEGER ::   kcall        ! optional integer argument (dom_vvl_sf_nxt)
-!!st patch
       REAL(wp),              DIMENSION(jpi,jpj,jpk) ::   zgdept
       REAL(wp), ALLOCATABLE, DIMENSION(:,:)         ::   zssh_f
@@ -119,12 +116,10 @@
       !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
       !
-      IF( l_1st_euler ) THEN  
-         ! start or restart with Euler 1st time-step
-         rDt =  rn_Dt   
+      IF( l_1st_euler ) THEN     ! start or restart with Euler 1st time-step
+         rDt   = rn_Dt   
          r1_Dt = 1._wp / rDt
       ENDIF
       !
       !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-
       ! update I/O and calendar
       !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
@@ -374,5 +369,5 @@
       !
       IF( l_1st_euler ) THEN         ! recover Leap-frog timestep
-         rDt = 2._wp * rn_Dt   
+         rDt   = 2._wp * rn_Dt   
          r1_Dt = 1._wp / rDt
          l_1st_euler = .FALSE.      
@@ -477,3 +472,3 @@
    
    !!======================================================================
-END MODULE stepMLF
+END MODULE stpMLF
Index: NEMO/branches/2020/dev_r13327_KERNEL-06_2_techene_e3/src/OCE/stpctl.F90
===================================================================
--- NEMO/branches/2020/dev_r13327_KERNEL-06_2_techene_e3/src/OCE/stpctl.F90	(revision 13607)
+++ NEMO/branches/2020/dev_r13327_KERNEL-06_2_techene_e3/src/OCE/stpctl.F90	(revision 13608)
@@ -26,6 +26,6 @@
    USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
    USE lib_mpp         ! distributed memory computing
-   !
    USE netcdf          ! NetCDF library
+
    IMPLICIT NONE
    PRIVATE
@@ -72,4 +72,5 @@
       CHARACTER(len=20)               ::   clname
       !!----------------------------------------------------------------------
+      !
       IF( nstop > 0 .AND. ngrdstop > -1 )   RETURN   !   stpctl was already called by a child grid
       !
@@ -166,5 +167,5 @@
          ENDIF
          IF( kt == nitend )   istatus = NF90_CLOSE(nrunid)
-      END IF
+      ENDIF
       !                                   !==               error handling               ==!
       !                                   !==  done by all processes at every time step  ==!
Index: NEMO/branches/2020/dev_r13327_KERNEL-06_2_techene_e3/src/OFF/nemogcm.F90
===================================================================
--- NEMO/branches/2020/dev_r13327_KERNEL-06_2_techene_e3/src/OFF/nemogcm.F90	(revision 13607)
+++ NEMO/branches/2020/dev_r13327_KERNEL-06_2_techene_e3/src/OFF/nemogcm.F90	(revision 13608)
@@ -65,5 +65,5 @@
    USE lbcnfd  , ONLY : isendto, nsndto   ! Setup of north fold exchanges
 #if defined key_qco
-   USE stepMLF , ONLY : Nbb, Nnn, Naa, Nrhs   ! time level indices
+   USE stpMLF , ONLY : Nbb, Nnn, Naa, Nrhs   ! time level indices
 #else
    USE step    , ONLY : Nbb, Nnn, Naa, Nrhs   ! time level indices
