Index: NEMO/trunk/src/SWE/nemogcm.F90
===================================================================
--- NEMO/trunk/src/SWE/nemogcm.F90	(revision 14136)
+++ NEMO/trunk/src/SWE/nemogcm.F90	(revision 14137)
@@ -33,5 +33,5 @@
    USE lbcnfd  , ONLY : isendto, nsndto  ! Setup of north fold exchanges 
    USE lib_fortran    ! Fortran utilities (allows no signed zero when 'key_nosignedzero' defined)
-   USE halo_mng       ! Halo manager
+   USE halo_mng       ! halo manager
 
    IMPLICIT NONE
@@ -127,5 +127,6 @@
       IF( nstop /= 0 .AND. lwp ) THEN        ! error print
          WRITE(ctmp1,*) '   ==>>>   nemo_gcm: a total of ', nstop, ' errors have been found'
-         CALL ctl_stop( ctmp1 )
+         WRITE(ctmp2,*) '           Look for "E R R O R" messages in all existing ocean_output* files'
+         CALL ctl_stop( ' ', ctmp1, ' ', ctmp2 )
       ENDIF
       !
@@ -216,5 +217,8 @@
          WRITE(numout,*) '                       NEMO team'
          WRITE(numout,*) '            Ocean General Circulation Model'
-         WRITE(numout,*) '                NEMO version 4.0  (2019) '
+         WRITE(numout,*) '                NEMO version 4.0  (2020) '
+         WRITE(numout,*)
+         WRITE(numout,*) '                 Shallow Water Equation'
+         WRITE(numout,*) '                 ======================'
          WRITE(numout,*)
          WRITE(numout,*) "           ._      ._      ._      ._      ._    "
@@ -232,14 +236,14 @@
          WRITE(numout,*) "     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ "
          WRITE(numout,*)
-         
-         ! Print the working precision to ocean.output
-         IF (wp == dp) THEN
-            WRITE(numout,*) "Working precision = double-precision"
-         ELSE
-            WRITE(numout,*) "Working precision = single-precision"
+         !
+         WRITE(numout,cform_aaa)    ! Flag AAAAAAA
+         !
+         !                          ! Control print of the working precision
+         WRITE(numout,*)
+         IF( wp == dp ) THEN   ;   WRITE(numout,*) "par_kind : wp = Working precision = dp = double-precision"
+         ELSE                  ;   WRITE(numout,*) "par_kind : wp = Working precision = sp = single-precision"
          ENDIF
-         WRITE(numout,*)
-         !
-         WRITE(numout,cform_aaa)                                        ! Flag AAAAAAA
+                                   WRITE(numout,*) "~~~~~~~~                                 ****************"
+                                   WRITE(numout,*)
          !
       ENDIF
@@ -280,5 +284,5 @@
       !                             !-------------------------------!
 
-      CALL nemo_ctl                          ! Control prints
+      CALL nemo_ctl                          ! Control prints of namctl and namcfg
       !
       !                                      ! General initialization
@@ -429,5 +433,5 @@
    END SUBROUTINE nemo_alloc
 
-   
+
    SUBROUTINE nemo_set_cfctl(sn_cfctl, setto )
       !!----------------------------------------------------------------------
Index: NEMO/trunk/src/SWE/restart.F90
===================================================================
--- NEMO/trunk/src/SWE/restart.F90	(revision 14136)
+++ 	(revision )
@@ -1,279 +1,0 @@
-MODULE restart
-   !!======================================================================
-   !!                     ***  MODULE  restart  ***
-   !! Ocean restart :  write the ocean restart file
-   !!======================================================================
-   !! History :  OPA  !  1999-11  (M. Imbard)  Original code
-   !!   NEMO     1.0  !  2002-08  (G. Madec)  F90: Free form
-   !!            2.0  !  2006-07  (S. Masson)  use IOM for restart
-   !!            3.3  !  2010-04  (M. Leclair, G. Madec)  modified LF-RA
-   !!            - -  !  2010-10  (C. Ethe, G. Madec) TRC-TRA merge (T-S in 4D)
-   !!            3.7  !  2014-01  (G. Madec) suppression of curl and hdiv from the restart
-   !!             -   !  2014-12  (G. Madec) remove KPP scheme
-   !!----------------------------------------------------------------------
-
-   !!----------------------------------------------------------------------
-   !!   rst_opn    : open the ocean restart file
-   !!   rst_write  : write the ocean restart file
-   !!   rst_read   : read the ocean restart file
-   !!----------------------------------------------------------------------
-   USE oce             ! ocean dynamics and tracers 
-   USE dom_oce         ! ocean space and time domain
-   USE sbc_ice         ! only lk_si3 
-   USE phycst          ! physical constants
-!!st   USE eosbn2          ! equation of state            (eos bn2 routine)
-!!st   USE trdmxl_oce      ! ocean active mixed layer tracers trends variables
-   !
-   USE in_out_manager  ! I/O manager
-   USE iom             ! I/O module
-   USE diu_bulk
-   USE lib_mpp         ! distribued memory computing library
-
-   IMPLICIT NONE
-   PRIVATE
-
-   PUBLIC   rst_opn         ! routine called by step module
-   PUBLIC   rst_write       ! routine called by step module
-   PUBLIC   rst_read        ! routine called by istate module
-   PUBLIC   rst_read_open   ! routine called in rst_read and (possibly) in dom_vvl_init
-
-   !!----------------------------------------------------------------------
-   !! NEMO/OCE 4.0 , NEMO Consortium (2018)
-   !! $Id: restart.F90 13427 2020-08-21 16:26:57Z techene $
-   !! Software governed by the CeCILL license (see ./LICENSE)
-   !!----------------------------------------------------------------------
-CONTAINS
-
-   SUBROUTINE rst_opn( kt )
-      !!---------------------------------------------------------------------
-      !!                   ***  ROUTINE rst_opn  ***
-      !!                     
-      !! ** Purpose : + initialization (should be read in the namelist) of nitrst 
-      !!              + open the restart when we are one time step before nitrst
-      !!                   - restart header is defined when kt = nitrst-1
-      !!                   - restart data  are written when kt = nitrst
-      !!              + define lrst_oce to .TRUE. when we need to define or write the restart
-      !!----------------------------------------------------------------------
-      INTEGER, INTENT(in) ::   kt     ! ocean time-step
-      !!
-      CHARACTER(LEN=20)   ::   clkt      ! ocean time-step deine as a character
-      CHARACTER(LEN=50)   ::   clname    ! ocean output restart file name
-      CHARACTER(lc)       ::   clpath    ! full path to ocean output restart file
-      CHARACTER(LEN=52)   ::   clpname   ! ocean output restart file name including prefix for AGRIF
-      CHARACTER(LEN=256)  ::   clinfo    ! info character
-      !!----------------------------------------------------------------------
-      !
-      IF( kt == nit000 ) THEN   ! default definitions
-         lrst_oce = .FALSE.   
-         IF( ln_rst_list ) THEN
-            nrst_lst = 1
-            nitrst = nn_stocklist( nrst_lst )
-         ELSE
-            nitrst = nitend
-         ENDIF
-      ENDIF
-      
-      IF( .NOT. ln_rst_list .AND. nn_stock == -1 )   RETURN   ! we will never do any restart
-
-      ! frequency-based restart dumping (nn_stock)
-      IF( .NOT. ln_rst_list .AND. MOD( kt - 1, nn_stock ) == 0 ) THEN   
-         ! we use kt - 1 and not kt - nit000 to keep the same periodicity from the beginning of the experiment
-         nitrst = kt + nn_stock - 1                  ! define the next value of nitrst for restart writing
-         IF( nitrst > nitend )   nitrst = nitend   ! make sure we write a restart at the end of the run
-      ENDIF
-      ! to get better performances with NetCDF format:
-      ! we open and define the ocean restart file one time step before writing the data (-> at nitrst - 1)
-      ! except if we write ocean restart files every time step or if an ocean restart file was writen at nitend - 1
-      IF( kt == nitrst - 1 .OR. nn_stock == 1 .OR. ( kt == nitend .AND. .NOT. lrst_oce ) ) THEN
-         IF( nitrst <= nitend .AND. nitrst > 0 ) THEN 
-            ! beware of the format used to write kt (default is i8.8, that should be large enough...)
-            IF( nitrst > 999999999 ) THEN   ;   WRITE(clkt, *       ) nitrst
-            ELSE                            ;   WRITE(clkt, '(i8.8)') nitrst
-            ENDIF
-            ! create the file
-            clname = TRIM(cexper)//"_"//TRIM(ADJUSTL(clkt))//"_"//TRIM(cn_ocerst_out)
-            clpath = TRIM(cn_ocerst_outdir)
-            IF( clpath(LEN_TRIM(clpath):) /= '/' ) clpath = TRIM(clpath) // '/'
-            IF(lwp) THEN
-               WRITE(numout,*)
-               IF(.NOT.lwxios) THEN
-                  WRITE(numout,*) '             open ocean restart NetCDF file: ',TRIM(clpath)//TRIM(clname)
-                  IF ( snc4set%luse )      WRITE(numout,*) '             opened for NetCDF4 chunking and compression'
-                  IF( kt == nitrst - 1 ) THEN   ;   WRITE(numout,*) '             kt = nitrst - 1 = ', kt
-                  ELSE                          ;   WRITE(numout,*) '             kt = '             , kt
-                  ENDIF
-               ENDIF
-            ENDIF
-            !
-            IF(.NOT.lwxios) THEN
-               CALL iom_open( TRIM(clpath)//TRIM(clname), numrow, ldwrt = .TRUE. )
-            ELSE
-#if defined key_iomput
-               cwxios_context = "rstw_"//TRIM(ADJUSTL(clkt))
-               IF( TRIM(Agrif_CFixed()) == '0' ) THEN
-                  clpname = clname
-               ELSE
-                  clpname = TRIM(Agrif_CFixed())//"_"//clname   
-               ENDIF
-               CALL iom_init( cwxios_context, TRIM(clpath)//TRIM(clpname), .false. )
-               CALL xios_update_calendar(nitrst)
-               CALL iom_swap(      cxios_context          )
-#else
-               clinfo = 'Can not use XIOS in rst_opn'
-               CALL ctl_stop(TRIM(clinfo))
-#endif
-            ENDIF
-            lrst_oce = .TRUE.
-         ENDIF
-      ENDIF
-      !
-   END SUBROUTINE rst_opn
-
-
-   SUBROUTINE rst_write( kt, Kbb, Kmm )
-      !!---------------------------------------------------------------------
-      !!                   ***  ROUTINE rstwrite  ***
-      !!                     
-      !! ** Purpose :   Write restart fields in NetCDF format
-      !!
-      !! ** Method  :   Write in numrow when kt == nitrst in NetCDF
-      !!              file, save fields which are necessary for restart
-      !!----------------------------------------------------------------------
-      INTEGER, INTENT(in) ::   kt         ! ocean time-step
-      INTEGER, INTENT(in) ::   Kbb, Kmm   ! ocean time level indices
-      !!----------------------------------------------------------------------
-      IF(lwxios) CALL iom_swap(      cwxios_context          )
-      CALL iom_rstput( kt, nitrst, numrow, 'rdt'    , rn_Dt       , ldxios = lwxios)   ! dynamics time step
-      CALL iom_delay_rst( 'WRITE', 'OCE', numrow )   ! save only ocean delayed global communication variables
-      
-      CALL iom_rstput( kt, nitrst, numrow, 'ub'  , uu(:,:,:,Kbb), ldxios = lwxios )     ! before fields
-      CALL iom_rstput( kt, nitrst, numrow, 'vb'  , vv(:,:,:,Kbb), ldxios = lwxios )
-      CALL iom_rstput( kt, nitrst, numrow, 'sshb',ssh(:,:  ,Kbb), ldxios = lwxios )
-      !
-      CALL iom_rstput( kt, nitrst, numrow, 'un'  , uu(:,:,:,Kmm), ldxios = lwxios )     ! now fields
-      CALL iom_rstput( kt, nitrst, numrow, 'vn'  , vv(:,:,:,Kmm), ldxios = lwxios )
-      CALL iom_rstput( kt, nitrst, numrow, 'sshn',ssh(:,:  ,Kmm), ldxios = lwxios )
-      
-      IF(lwxios) CALL iom_swap(      cxios_context          )
-      IF( kt == nitrst ) THEN
-         IF(.NOT.lwxios) THEN
-            CALL iom_close( numrow )     ! close the restart file (only at last time step)
-         ELSE
-            CALL iom_context_finalize(      cwxios_context          )
-         ENDIF
-         lrst_oce = .FALSE.
-         IF( ln_rst_list ) THEN
-            nrst_lst = MIN(nrst_lst + 1, SIZE(nn_stocklist,1))
-            nitrst = nn_stocklist( nrst_lst )
-         ENDIF
-      ENDIF
-      !
-   END SUBROUTINE rst_write
-
-
-   SUBROUTINE rst_read_open
-      !!---------------------------------------------------------------------- 
-      !!                   ***  ROUTINE rst_read_open  ***
-      !! 
-      !! ** Purpose :   Open read files for NetCDF restart
-      !! 
-      !! ** Method  :   Use a non-zero, positive value of numror to assess whether or not
-      !!                the file has already been opened
-      !!----------------------------------------------------------------------
-      LOGICAL        ::   llok
-      CHARACTER(lc)  ::   clpath   ! full path to ocean output restart file
-      !!----------------------------------------------------------------------
-      !
-      IF( numror <= 0 ) THEN
-         IF(lwp) THEN                                             ! Contol prints
-            WRITE(numout,*)
-            WRITE(numout,*) 'rst_read : read oce NetCDF restart file'
-            IF ( snc4set%luse )      WRITE(numout,*) 'rst_read : configured with NetCDF4 support'
-            WRITE(numout,*) '~~~~~~~~'
-         ENDIF
-         lxios_sini = .FALSE.
-         clpath = TRIM(cn_ocerst_indir)
-         IF( clpath(LEN_TRIM(clpath):) /= '/' ) clpath = TRIM(clpath) // '/'
-         CALL iom_open( TRIM(clpath)//cn_ocerst_in, numror )
-! are we using XIOS to read the data? Part above will have to modified once XIOS
-! can handle checking if variable is in the restart file (there will be no need to open
-! restart)
-         IF(.NOT.lxios_set) lrxios = lrxios.AND.lxios_sini
-         IF( lrxios) THEN
-             crxios_context = 'nemo_rst'
-             IF( .NOT.lxios_set ) THEN
-                 IF(lwp) WRITE(numout,*) 'Enable restart reading by XIOS'
-                 CALL iom_init( crxios_context )
-                 lxios_set = .TRUE.
-             ENDIF
-         ENDIF
-         IF( TRIM(Agrif_CFixed()) /= '0' .AND. lrxios) THEN
-             CALL iom_init( crxios_context )
-             IF(lwp) WRITE(numout,*) 'Enable restart reading by XIOS for AGRIF'
-             lxios_set = .TRUE.
-         ENDIF 
-      ENDIF
-
-   END SUBROUTINE rst_read_open
-
-
-   SUBROUTINE rst_read( Kbb, Kmm )
-      !!---------------------------------------------------------------------- 
-      !!                   ***  ROUTINE rst_read  ***
-      !! 
-      !! ** Purpose :   Read files for NetCDF restart
-      !! 
-      !! ** Method  :   Read in restart.nc file fields which are necessary for restart
-      !!----------------------------------------------------------------------
-      INTEGER, INTENT(in) ::   Kbb, Kmm   ! ocean time level indices
-      REAL(wp) ::   zrdt
-      INTEGER  ::   jk
-      REAL(wp), DIMENSION(jpi, jpj, jpk) :: w3d
-      !!----------------------------------------------------------------------
-
-      CALL rst_read_open           ! open restart for reading (if not already opened)
-
-      ! Check dynamics and tracer time-step consistency and force Euler restart if changed
-      IF( iom_varid( numror, 'rdt', ldstop = .FALSE. ) > 0 )   THEN
-         CALL iom_get( numror, 'rdt', zrdt, ldxios = lrxios )
-         IF( zrdt /= rn_Dt ) THEN
-            IF(lwp) WRITE( numout,*)
-            IF(lwp) WRITE( numout,*) 'rst_read:  rdt not equal to the read one'
-            IF(lwp) WRITE( numout,*)
-            IF(lwp) WRITE( numout,*) '      ==>>>   forced euler first time-step'
-            l_1st_euler =  .TRUE.
-         ENDIF
-      ENDIF
-
-      CALL iom_delay_rst( 'READ', 'OCE', numror )   ! read only ocean delayed global communication variables
-      
-      IF( iom_varid( numror, 'ub', ldstop = .FALSE. ) > 0 ) THEN
-         ! before fields
-         CALL iom_get( numror, jpdom_auto, 'ub'     , uu(:,:,:       ,Kbb), ldxios = lrxios, cd_type = 'U', psgn = -1._wp )
-         CALL iom_get( numror, jpdom_auto, 'vb'     , vv(:,:,:       ,Kbb), ldxios = lrxios, cd_type = 'V', psgn = -1._wp )
-#if ! defined key_qco
-         CALL iom_get( numror, jpdom_auto, 'sshb'   ,ssh(:,:         ,Kbb), ldxios = lrxios )
-#endif
-      ELSE
-         l_1st_euler =  .TRUE.      ! before field not found, forced euler 1st time-step
-      ENDIF
-      !
-      ! now fields
-      CALL iom_get( numror, jpdom_auto, 'un'     , uu(:,:,:       ,Kmm), ldxios = lrxios, cd_type = 'U', psgn = -1._wp )
-      CALL iom_get( numror, jpdom_auto, 'vn'     , vv(:,:,:       ,Kmm), ldxios = lrxios, cd_type = 'V', psgn = -1._wp )
-#if ! defined key_qco
-      CALL iom_get( numror, jpdom_auto, 'sshn'   ,ssh(:,:         ,Kmm), ldxios = lrxios )
-#endif
-      !
-      IF( l_1st_euler ) THEN                                  ! Euler restart 
-         uu   (:,:,:  ,Kbb) = uu   (:,:,:  ,Kmm)              ! all before fields set to now values
-         vv   (:,:,:  ,Kbb) = vv   (:,:,:  ,Kmm)
-         ssh  (:,:    ,Kbb) = ssh  (:,:    ,Kmm)
-      ENDIF
-      !
-      ww (:,:,:) = 0._wp !!st  gm is right 3D only !! 
-      !
-   END SUBROUTINE rst_read
-
-   !!=====================================================================
-END MODULE restart
Index: NEMO/trunk/src/SWE/stp_oce.F90
===================================================================
--- NEMO/trunk/src/SWE/stp_oce.F90	(revision 14136)
+++ NEMO/trunk/src/SWE/stp_oce.F90	(revision 14137)
@@ -93,5 +93,5 @@
    !                                                   (dyn_asm_inc routine)
    USE asmbkg          ! writing out state trajectory
-   USE stpctl          ! time stepping control            (stp_ctl routine)
+   USE stpctl          ! time stepping control            (stp_ctl_SWE routine)
    USE restart         ! ocean restart                    (rst_wri routine)
    USE prtctl          ! Print control                    (prt_ctl routine)
Index: NEMO/trunk/src/SWE/stpctl.F90
===================================================================
--- NEMO/trunk/src/SWE/stpctl.F90	(revision 14136)
+++ 	(revision )
@@ -1,261 +1,0 @@
-MODULE stpctl
-   !!======================================================================
-   !!                       ***  MODULE  stpctl  ***
-   !! Ocean run control :  gross check of the ocean time stepping
-   !!              *** Shallow Water Equation (SWE) case ***
-   !!               ( No test on temperature and salinity )
-   !!======================================================================
-   !! History :  SWE  ! 2020-09  (A. Nasser, S. Techene ) OCE/stpctl adaptated to SWE
-   !!----------------------------------------------------------------------
-
-   !!----------------------------------------------------------------------
-   !!   stp_ctl      : Control the run
-   !!----------------------------------------------------------------------
-   USE oce             ! ocean dynamics and tracers variables
-   USE dom_oce         ! ocean space and time domain variables 
-   USE c1d             ! 1D vertical configuration
-   USE zdf_oce ,  ONLY : ln_zad_Aimp       ! ocean vertical physics variables
-   USE wet_dry,   ONLY : ll_wd, ssh_ref    ! reference depth for negative bathy
-   !
-   USE diawri          ! Standard run outputs       (dia_wri_state routine)
-   USE in_out_manager  ! I/O manager
-   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
-   USE lib_mpp         ! distributed memory computing
-   USE netcdf          ! NetCDF library
-
-   IMPLICIT NONE
-   PRIVATE
-
-   PUBLIC stp_ctl           ! routine called by step.F90
-
-   INTEGER                ::   nrunid   ! netcdf file id
-   INTEGER, DIMENSION(2)  ::   nvarid   ! netcdf variable id
-
-#  include "domzgr_substitute.h90"
-   !!----------------------------------------------------------------------
-   !! NEMO/OCE 4.0 , NEMO Consortium (2018)
-   !! $Id: stpctl.F90 13216 2020-07-02 09:25:49Z rblod $
-   !! Software governed by the CeCILL license (see ./LICENSE)
-   !!----------------------------------------------------------------------
-CONTAINS
-
-   SUBROUTINE stp_ctl( kt, Kmm )
-      !!----------------------------------------------------------------------
-      !!                    ***  ROUTINE stp_ctl  ***
-      !!                     
-      !! ** Purpose :   Control the run
-      !!
-      !! ** Method  : - Save the time step in numstp
-      !!              - Print it each 50 time steps
-      !!              - Stop the run IF problem encountered by setting nstop > 0
-      !!                Problems checked: e3t0+ssh minimum smaller that 0
-      !!                                  |U|   maximum larger than 10 m/s 
-      !!                                  ( not for SWE : negative sea surface salinity )
-      !!
-      !! ** Actions :   "time.step" file = last ocean time-step
-      !!                "run.stat"  file = run statistics
-      !!                 nstop indicator sheared among all local domain
-      !!----------------------------------------------------------------------
-      INTEGER, INTENT(in   ) ::   kt       ! ocean time-step index
-      INTEGER, INTENT(in   ) ::   Kmm      ! ocean time level index
-      !!
-      INTEGER                         ::   ji                                    ! dummy loop indices
-      INTEGER                         ::   idtime, istatus
-      INTEGER , DIMENSION(3)          ::   iareasum, iareamin, iareamax
-      INTEGER , DIMENSION(3,4)        ::   iloc                                  ! min/max loc indices
-      REAL(wp)                        ::   zzz                                   ! local real 
-      REAL(wp), DIMENSION(3)          ::   zmax, zmaxlocal
-      LOGICAL                         ::   ll_wrtstp, ll_colruns, ll_wrtruns
-      LOGICAL, DIMENSION(jpi,jpj,jpk) ::   llmsk
-      CHARACTER(len=20)               ::   clname
-      !!----------------------------------------------------------------------
-      IF( nstop > 0 .AND. ngrdstop > -1 )   RETURN   !   stpctl was already called by a child grid
-      !
-      IF( nstop > 0 .AND. ngrdstop > -1 )   RETURN   !   stpctl was already called by a child grid
-      !
-      ll_wrtstp  = ( MOD( kt-nit000, sn_cfctl%ptimincr ) == 0 ) .OR. ( kt == nitend )
-      ll_colruns = ll_wrtstp .AND. sn_cfctl%l_runstat .AND. jpnij > 1 
-      ll_wrtruns = ( ll_colruns .OR. jpnij == 1 ) .AND. lwm
-      !
-      IF( kt == nit000 ) THEN
-         !
-         IF( lwp ) THEN
-            WRITE(numout,*)
-            WRITE(numout,*) 'stp_ctl : time-stepping control'
-            WRITE(numout,*) '~~~~~~~'
-         ENDIF
-         !                                ! open time.step    ascii file, done only by 1st subdomain
-         IF( lwm )   CALL ctl_opn( numstp, 'time.step', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, numout, lwp, narea )
-         !
-         IF( ll_wrtruns ) THEN
-            !                             ! open run.stat     ascii file, done only by 1st subdomain
-            CALL ctl_opn( numrun, 'run.stat', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, numout, lwp, narea )
-            !                             ! open run.stat.nc netcdf file, done only by 1st subdomain
-            clname = 'run.stat.nc'
-            IF( .NOT. Agrif_Root() )   clname = TRIM(Agrif_CFixed())//"_"//TRIM(clname)
-            istatus = NF90_CREATE( TRIM(clname), NF90_CLOBBER, nrunid )
-            istatus = NF90_DEF_DIM( nrunid, 'time', NF90_UNLIMITED, idtime )
-            istatus = NF90_DEF_VAR( nrunid, 'abs_ssh_max', NF90_DOUBLE, (/ idtime /), nvarid(1) )
-            istatus = NF90_DEF_VAR( nrunid,   'abs_u_max', NF90_DOUBLE, (/ idtime /), nvarid(2) )
-            istatus = NF90_ENDDEF(nrunid)
-         ENDIF
-         !    
-      ENDIF
-      !
-      !                                   !==              write current time step              ==!
-      !                                   !==  done only by 1st subdomain at writting timestep  ==!
-      IF( lwm .AND. ll_wrtstp ) THEN
-         WRITE ( numstp, '(1x, i8)' )   kt
-         REWIND( numstp )
-      ENDIF
-      !                                   !==            test of local extrema           ==!
-      !                                   !==  done by all processes at every time step  ==!
-      zmax(1) = MINVAL( e3t_0(:,:,1)+ssh(:,:,Kmm)  )                              ! e3t_Kmm min
-      llmsk(:,:,:) = umask(:,:,:) == 1._wp
-      zmax(2) = MAXVAL(  ABS( uu(:,:,:,Kmm) ), mask = llmsk )                     ! velocity max (zonal only)
-      zmax(3) = REAL( nstop , wp )                                            ! stop indicator
-      !                                   !==               get global extrema             ==!
-      !                                   !==  done by all processes if writting run.stat  ==!
-      llmsk(Nis0:Nie0,Njs0:Nje0,1) = tmask(Nis0:Nie0,Njs0:Nje0,1) == 1._wp         ! define only the inner domain
-      zmax(1) = MAXVAL(     -e3t(:,:,1,Kmm) ), mask = llmsk(:,:,1) )      ! ssh max
-      llmsk(Nis0:Nie0,Njs0:Nje0,:) = umask(Nis0:Nie0,Njs0:Nje0,:) == 1._wp        ! define only the inner domain
-      zmax(2) = MAXVAL(  ABS( uu(:,:,:,Kmm) ), mask = llmsk(:,:,:) )                     ! velocity max (zonal only)
-      zmax(3) = REAL( nstop, wp )                                                 ! stop indicator
-      !                                   !==               get global extrema             ==!
-      !                                   !==  done by all processes if writting run.stat  ==!
-      IF( ll_colruns ) THEN
-         zmaxlocal(:) = zmax(:)
-         CALL mpp_max( "stpctl", zmax )          ! max over the global domain
-         nstop = NINT( zmax(3) )                 ! update nstop indicator (now sheared among all local domains)
-      ENDIF
-      !                                   !==              write "run.stat" files              ==!
-      !                                   !==  done only by 1st subdomain at writting timestep  ==!
-      IF( ll_wrtruns ) THEN
-         WRITE(numrun,9500) kt, zmax(1), zmax(2)
-         istatus = NF90_PUT_VAR( nrunid, nvarid(1), (/ zmax(1)/), (/kt/), (/1/) )
-         istatus = NF90_PUT_VAR( nrunid, nvarid(2), (/ zmax(2)/), (/kt/), (/1/) )
-         IF( kt == nitend )   istatus = NF90_CLOSE(nrunid)
-      ENDIF
-      !                                   !==               error handling               ==!
-      !                                   !==  done by all processes at every time step  ==!
-      !
-!!SWE specific : start
-      IF(   zmax(1) <=   0._wp .OR.           &               ! negative e3t_Kmm
-         &  zmax(2) >   10._wp .OR.           &               ! too large velocity ( > 10 m/s)
-         &  ISNAN( zmax(1) + zmax(2) ) .OR.   &               ! NaN encounter in the tests
-         &  ABS(   zmax(1) + zmax(2) ) > HUGE(1._wp) ) THEN   ! Infinity encounter in the tests
-         !
-         iloc(:,:) = 0
-         IF( ll_colruns ) THEN   ! zmax is global, so it is the same on all subdomains -> no dead lock with mpp_maxloc
-            ! first: close the netcdf file, so we can read it
-            IF( lwm .AND. kt /= nitend )   istatus = NF90_CLOSE(nrunid)
-            ! get global loc on the min/max
-            CALL mpp_minloc( 'stpctl', e3t_0(:,:,1) + ssh(:,:,Kmm), ssmask(:,:  ), zzz, iloc(1:2,1) )   ! mpp_maxloc ok if mask = F 
-            CALL mpp_maxloc( 'stpctl', ABS( uu(:,:,:,Kmm))        ,  umask(:,:,:), zzz, iloc(1:3,2) )
-            ! find which subdomain has the max.
-            iareamin(:) = jpnij+1   ;   iareamax(:) = 0   ;   iareasum(:) = 0
-            DO ji = 1, 3
-               IF( zmaxlocal(ji) == zmax(ji) ) THEN
-                  iareamin(ji) = narea   ;   iareamax(ji) = narea   ;   iareasum(ji) = 1
-               ENDIF
-            END DO
-            CALL mpp_min( "stpctl", iareamin )         ! min over the global domain
-            CALL mpp_max( "stpctl", iareamax )         ! max over the global domain
-            CALL mpp_sum( "stpctl", iareasum )         ! sum over the global domain
-         ELSE                    ! find local min and max locations:
-            ! if we are here, this means that the subdomain contains some oce points -> no need to test the mask used in maxloc
-            iloc(1:2,1) = MINLOC( e3t_0(:,:,1) + ssh(:,:,Kmm), mask = ssmask(:,:  ) == 1._wp ) + (/ nimpp - 1, njmpp - 1    /)
-            iloc(1:3,2) = MAXLOC( ABS(  uu(:,:,:,       Kmm)), mask =  umask(:,:,:) == 1._wp ) + (/ nimpp - 1, njmpp - 1, 0 /)
-            iareamin(:) = narea   ;   iareamax(:) = narea   ;   iareasum(:) = 1         ! this is local information
-         ENDIF
-         !
-         WRITE(ctmp1,*) ' stp_ctl:  e3t0+ssh < 0 m  or  |U| > 10 m/s  or  NaN encounter in the tests'
-         CALL wrt_line( ctmp2, kt, 'e3t0+ssh min',  zmax(1), iloc(:,1), iareasum(1), iareamin(1), iareamax(1) )
-         CALL wrt_line( ctmp3, kt, '|U|   max'   ,  zmax(2), iloc(:,2), iareasum(2), iareamin(2), iareamax(2) )
-         IF( Agrif_Root() ) THEN
-            WRITE(ctmp6,*) '      ===> output of last computed fields in output.abort* files'
-         ELSE
-            WRITE(ctmp6,*) '      ===> output of last computed fields in '//TRIM(Agrif_CFixed())//'_output.abort* files'
-         ENDIF
-         !
-         CALL dia_wri_state( Kmm, 'output.abort' )     ! create an output.abort file
-         !
-         IF( ll_colruns .or. jpnij == 1 ) THEN   ! all processes synchronized -> use lwp to print in opened ocean.output files
-            IF(lwp) THEN   ;   CALL ctl_stop( ctmp1, ' ', ctmp2, ctmp3, ' ', ctmp6 )
-            ELSE           ;   nstop = MAX(1, nstop)   ! make sure nstop > 0 (automatically done when calling ctl_stop)
-            ENDIF
-         ELSE                                    ! only mpi subdomains with errors are here -> STOP now
-            CALL ctl_stop( 'STOP', ctmp1, ' ', ctmp2, ctmp3, ' ', ctmp6 )
-         ENDIF
-         !
-      ENDIF
-!!SWE specific : end
-      !
-      IF( nstop > 0 ) THEN                                                  ! an error was detected and we did not abort yet...
-         ngrdstop = Agrif_Fixed()                                           ! store which grid got this error
-         IF( .NOT. ll_colruns .AND. jpnij > 1 )   CALL ctl_stop( 'STOP' )   ! we must abort here to avoid MPI deadlock
-      ENDIF
-      !
-9500  FORMAT(' it :', i8, '      e3t_min: ', D23.16, ' |U|_max: ', D23.16)
-      !
-   END SUBROUTINE stp_ctl
-
-
-   SUBROUTINE wrt_line( cdline, kt, cdprefix, pval, kloc, ksum, kmin, kmax )
-      !!----------------------------------------------------------------------
-      !!                     ***  ROUTINE wrt_line  ***
-      !!
-      !! ** Purpose :   write information line
-      !!
-      !!----------------------------------------------------------------------
-      CHARACTER(len=*),      INTENT(  out) ::   cdline
-      CHARACTER(len=*),      INTENT(in   ) ::   cdprefix
-      REAL(wp),              INTENT(in   ) ::   pval
-      INTEGER, DIMENSION(3), INTENT(in   ) ::   kloc
-      INTEGER,               INTENT(in   ) ::   kt, ksum, kmin, kmax
-      !
-      CHARACTER(len=80) ::   clsuff
-      CHARACTER(len=9 ) ::   clkt, clsum, clmin, clmax
-      CHARACTER(len=9 ) ::   cli, clj, clk
-      CHARACTER(len=1 ) ::   clfmt
-      CHARACTER(len=4 ) ::   cl4   ! needed to be able to compile with Agrif, I don't know why
-      INTEGER           ::   ifmtk
-      !!----------------------------------------------------------------------
-      WRITE(clkt , '(i9)') kt
-      
-      WRITE(clfmt, '(i1)') INT(LOG10(REAL(jpnij  ,wp))) + 1     ! how many digits to we need to write ? (we decide max = 9)
-      !!! WRITE(clsum, '(i'//clfmt//')') ksum                   ! this is creating a compilation error with AGRIF
-      cl4 = '(i'//clfmt//')'   ;   WRITE(clsum, cl4) ksum
-      WRITE(clfmt, '(i1)') INT(LOG10(REAL(MAX(1,jpnij-1),wp))) + 1    ! how many digits to we need to write ? (we decide max = 9)
-      cl4 = '(i'//clfmt//')'   ;   WRITE(clmin, cl4) kmin-1
-                                   WRITE(clmax, cl4) kmax-1
-      !
-      WRITE(clfmt, '(i1)') INT(LOG10(REAL(jpiglo,wp))) + 1      ! how many digits to we need to write jpiglo? (we decide max = 9)
-      cl4 = '(i'//clfmt//')'   ;   WRITE(cli, cl4) kloc(1)      ! this is ok with AGRIF
-      WRITE(clfmt, '(i1)') INT(LOG10(REAL(jpjglo,wp))) + 1      ! how many digits to we need to write jpjglo? (we decide max = 9)
-      cl4 = '(i'//clfmt//')'   ;   WRITE(clj, cl4) kloc(2)      ! this is ok with AGRIF
-      !
-      IF( ksum == 1 ) THEN   ;   WRITE(clsuff,9100) TRIM(clmin)
-      ELSE                   ;   WRITE(clsuff,9200) TRIM(clsum), TRIM(clmin), TRIM(clmax)
-      ENDIF
-      IF(kloc(3) == 0) THEN
-         ifmtk = INT(LOG10(REAL(jpk,wp))) + 1                   ! how many digits to we need to write jpk? (we decide max = 9)
-         clk = REPEAT(' ', ifmtk)                               ! create the equivalent in blank string
-         WRITE(cdline,9300) TRIM(ADJUSTL(clkt)), TRIM(ADJUSTL(cdprefix)), pval, TRIM(cli), TRIM(clj), clk(1:ifmtk), TRIM(clsuff)
-      ELSE
-         WRITE(clfmt, '(i1)') INT(LOG10(REAL(jpk,wp))) + 1      ! how many digits to we need to write jpk? (we decide max = 9)
-         !!! WRITE(clk, '(i'//clfmt//')') kloc(3)               ! this is creating a compilation error with AGRIF
-         cl4 = '(i'//clfmt//')'   ;   WRITE(clk, cl4) kloc(3)   ! this is ok with AGRIF
-         WRITE(cdline,9400) TRIM(ADJUSTL(clkt)), TRIM(ADJUSTL(cdprefix)), pval, TRIM(cli), TRIM(clj),    TRIM(clk), TRIM(clsuff)
-      ENDIF
-      !
-9100  FORMAT('MPI rank ', a)
-9200  FORMAT('found in ', a, ' MPI tasks, spread out among ranks ', a, ' to ', a)
-9300  FORMAT('kt ', a, ' ', a, ' ', 1pg11.4, ' at i j   ', a, ' ', a, ' ', a, ' ', a)
-9400  FORMAT('kt ', a, ' ', a, ' ', 1pg11.4, ' at i j k ', a, ' ', a, ' ', a, ' ', a)
-      !
-   END SUBROUTINE wrt_line
-
-
-   !!======================================================================
-END MODULE stpctl
Index: NEMO/trunk/src/SWE/stpmlf.F90
===================================================================
--- NEMO/trunk/src/SWE/stpmlf.F90	(revision 14136)
+++ NEMO/trunk/src/SWE/stpmlf.F90	(revision 14137)
@@ -70,5 +70,5 @@
       ENDIF
 
-      IF( kstp == nit000 )   ww(:,:,:) = 0._wp   ! initialize vertical velocity one for all to zero
+      IF( kstp == nit000 )   ww(:,:,:) = 0._wp   ! initialize vertical velocity once for all to zero
 
       !
@@ -222,5 +222,5 @@
       ! Control
       !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
-                         CALL stp_ctl      ( kstp, Nnn )
+                         CALL stp_ctl_SWE   ( kstp, Nnn )
 
       IF( kstp == nit000 ) THEN                          ! 1st time step only
@@ -235,6 +235,4 @@
 !!st : cxios_context needed ? because opened earlier ???         
          CALL iom_context_finalize( cxios_context ) ! needed for XIOS+AGRIF
-!!st : crxios_context not needed associated with coarsening ! 
-         IF(lrxios) CALL iom_context_finalize( crxios_context )
       ENDIF
 #endif
Index: NEMO/trunk/src/SWE/stprk3.F90
===================================================================
--- NEMO/trunk/src/SWE/stprk3.F90	(revision 14136)
+++ NEMO/trunk/src/SWE/stprk3.F90	(revision 14137)
@@ -355,5 +355,5 @@
       ! Control
       !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
-                         CALL stp_ctl      ( kstp, Nnn )
+                         CALL stp_ctl_SWE  ( kstp, Nnn )
 
       IF( kstp == nit000 ) THEN                          ! 1st time step only
